diff options
Diffstat (limited to 'include')
480 files changed, 7911 insertions, 12506 deletions
diff --git a/include/lldb/API/LLDB.h b/include/lldb/API/LLDB.h index 2b3dd96aef0e5..0806ab700a949 100644 --- a/include/lldb/API/LLDB.h +++ b/include/lldb/API/LLDB.h @@ -1,9 +1,8 @@ //===-- LLDB.h --------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -49,6 +48,7 @@ #include "lldb/API/SBProcessInfo.h" #include "lldb/API/SBQueue.h" #include "lldb/API/SBQueueItem.h" +#include "lldb/API/SBReproducer.h" #include "lldb/API/SBSection.h" #include "lldb/API/SBSourceManager.h" #include "lldb/API/SBStream.h" diff --git a/include/lldb/API/SBAddress.h b/include/lldb/API/SBAddress.h index 891324254cd62..2874a3602af2d 100644 --- a/include/lldb/API/SBAddress.h +++ b/include/lldb/API/SBAddress.h @@ -1,9 +1,8 @@ //===-- SBAddress.h ---------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -30,6 +29,12 @@ public: const lldb::SBAddress &operator=(const lldb::SBAddress &rhs); + explicit operator bool() const; + + // operator== is a free function + + bool operator!=(const SBAddress &rhs) const; + bool IsValid() const; void Clear(); @@ -115,7 +120,7 @@ protected: void SetAddress(const lldb_private::Address *lldb_object_ptr); private: - std::unique_ptr<lldb_private::Address> m_opaque_ap; + std::unique_ptr<lldb_private::Address> m_opaque_up; }; bool LLDB_API operator==(const SBAddress &lhs, const SBAddress &rhs); diff --git a/include/lldb/API/SBAttachInfo.h b/include/lldb/API/SBAttachInfo.h index 7ae006908cccb..3c20a08cb4a94 100644 --- a/include/lldb/API/SBAttachInfo.h +++ b/include/lldb/API/SBAttachInfo.h @@ -1,9 +1,8 @@ //===-- SBAttachInfo.h ------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -22,35 +21,32 @@ public: SBAttachInfo(lldb::pid_t pid); - //------------------------------------------------------------------ /// Attach to a process by name. /// /// This function implies that a future call to SBTarget::Attach(...) /// will be synchronous. /// - /// @param[in] path + /// \param[in] path /// A full or partial name for the process to attach to. /// - /// @param[in] wait_for + /// \param[in] wait_for /// If \b false, attach to an existing process whose name matches. /// If \b true, then wait for the next process whose name matches. - //------------------------------------------------------------------ SBAttachInfo(const char *path, bool wait_for); - //------------------------------------------------------------------ /// Attach to a process by name. /// /// Future calls to SBTarget::Attach(...) will be synchronous or /// asynchronous depending on the \a async argument. /// - /// @param[in] path + /// \param[in] path /// A full or partial name for the process to attach to. /// - /// @param[in] wait_for + /// \param[in] wait_for /// If \b false, attach to an existing process whose name matches. /// If \b true, then wait for the next process whose name matches. /// - /// @param[in] async + /// \param[in] async /// If \b false, then the SBTarget::Attach(...) call will be a /// synchronous call with no way to cancel the attach in /// progress. @@ -60,7 +56,6 @@ public: /// eventually found. If the client wants to cancel the event, /// SBProcess::Stop() can be called and an eStateExited process /// event will be delivered. - //------------------------------------------------------------------ SBAttachInfo(const char *path, bool wait_for, bool async); SBAttachInfo(const SBAttachInfo &rhs); @@ -79,31 +74,28 @@ public: bool GetWaitForLaunch(); - //------------------------------------------------------------------ /// Set attach by process name settings. /// /// Designed to be used after a call to SBAttachInfo::SetExecutable(). /// This function implies that a call to SBTarget::Attach(...) will /// be synchronous. /// - /// @param[in] b + /// \param[in] b /// If \b false, attach to an existing process whose name matches. /// If \b true, then wait for the next process whose name matches. - //------------------------------------------------------------------ void SetWaitForLaunch(bool b); - //------------------------------------------------------------------ /// Set attach by process name settings. /// /// Designed to be used after a call to SBAttachInfo::SetExecutable(). /// Future calls to SBTarget::Attach(...) will be synchronous or /// asynchronous depending on the \a async argument. /// - /// @param[in] b + /// \param[in] b /// If \b false, attach to an existing process whose name matches. /// If \b true, then wait for the next process whose name matches. /// - /// @param[in] async + /// \param[in] async /// If \b false, then the SBTarget::Attach(...) call will be a /// synchronous call with no way to cancel the attach in /// progress. @@ -113,7 +105,6 @@ public: /// eventually found. If the client wants to cancel the event, /// SBProcess::Stop() can be called and an eStateExited process /// event will be delivered. - //------------------------------------------------------------------ void SetWaitForLaunch(bool b, bool async); bool GetIgnoreExisting(); @@ -158,23 +149,19 @@ public: bool ParentProcessIDIsValid(); - //---------------------------------------------------------------------- /// Get the listener that will be used to receive process events. /// /// If no listener has been set via a call to /// SBAttachInfo::SetListener(), then an invalid SBListener will be /// returned (SBListener::IsValid() will return false). If a listener /// has been set, then the valid listener object will be returned. - //---------------------------------------------------------------------- SBListener GetListener(); - //---------------------------------------------------------------------- /// Set the listener that will be used to receive process events. /// /// By default the SBDebugger, which has a listener, that the SBTarget /// belongs to will listen for the process events. Calling this function /// allows a different listener to be used to listen for process events. - //---------------------------------------------------------------------- void SetListener(SBListener &listener); protected: diff --git a/include/lldb/API/SBBlock.h b/include/lldb/API/SBBlock.h index 112de96734237..0ca92ff0c6ac9 100644 --- a/include/lldb/API/SBBlock.h +++ b/include/lldb/API/SBBlock.h @@ -1,9 +1,8 @@ //===-- SBBlock.h -----------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -29,6 +28,8 @@ public: bool IsInlined() const; + explicit operator bool() const; + bool IsValid() const; const char *GetInlinedName() const; @@ -59,16 +60,14 @@ public: lldb::SBValueList GetVariables(lldb::SBTarget &target, bool arguments, bool locals, bool statics); - //------------------------------------------------------------------ /// Get the inlined block that contains this block. /// - /// @return + /// \return /// If this block is inlined, it will return this block, else /// parent blocks will be searched to see if any contain this /// block and are themselves inlined. An invalid SBBlock will /// be returned if this block nor any parent blocks are inlined /// function blocks. - //------------------------------------------------------------------ lldb::SBBlock GetContainingInlinedBlock(); bool GetDescription(lldb::SBStream &description); diff --git a/include/lldb/API/SBBreakpoint.h b/include/lldb/API/SBBreakpoint.h index 2c93bf103e3eb..75c0e69a4821e 100644 --- a/include/lldb/API/SBBreakpoint.h +++ b/include/lldb/API/SBBreakpoint.h @@ -1,9 +1,8 @@ //===-- SBBreakpoint.h ------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -37,6 +36,8 @@ public: break_id_t GetID() const; + explicit operator bool() const; + bool IsValid() const; void ClearAllBreakpointSites(); diff --git a/include/lldb/API/SBBreakpointLocation.h b/include/lldb/API/SBBreakpointLocation.h index 4b34bcbf1f28b..085bed9399b98 100644 --- a/include/lldb/API/SBBreakpointLocation.h +++ b/include/lldb/API/SBBreakpointLocation.h @@ -1,9 +1,8 @@ //===-- SBBreakpointLocation.h ----------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -28,6 +27,8 @@ public: break_id_t GetID(); + explicit operator bool() const; + bool IsValid() const; lldb::SBAddress GetAddress(); diff --git a/include/lldb/API/SBBreakpointName.h b/include/lldb/API/SBBreakpointName.h index 321f0d784d6f7..018238bcd074f 100644 --- a/include/lldb/API/SBBreakpointName.h +++ b/include/lldb/API/SBBreakpointName.h @@ -1,9 +1,8 @@ //===-- SBBreakpointName.h ------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -40,6 +39,8 @@ public: bool operator!=(const lldb::SBBreakpointName &rhs); + explicit operator bool() const; + bool IsValid() const; const char *GetName() const; diff --git a/include/lldb/API/SBBroadcaster.h b/include/lldb/API/SBBroadcaster.h index dc6c50ec0a8a5..fc5e8880e9f2b 100644 --- a/include/lldb/API/SBBroadcaster.h +++ b/include/lldb/API/SBBroadcaster.h @@ -1,9 +1,8 @@ //===-- SBBroadcaster.h -----------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -26,6 +25,8 @@ public: ~SBBroadcaster(); + explicit operator bool() const; + bool IsValid() const; void Clear(); diff --git a/include/lldb/API/SBCommandInterpreter.h b/include/lldb/API/SBCommandInterpreter.h index f988944788111..6c80e8eb26dc8 100644 --- a/include/lldb/API/SBCommandInterpreter.h +++ b/include/lldb/API/SBCommandInterpreter.h @@ -1,9 +1,8 @@ //===-- SBCommandInterpreter.h ----------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -88,6 +87,8 @@ public: static bool EventIsCommandInterpreterEvent(const lldb::SBEvent &event); + explicit operator bool() const; + bool IsValid() const; bool CommandExists(const char *cmd); @@ -189,16 +190,13 @@ public: lldb_private::CommandInterpreter *interpreter_ptr = nullptr); // Access using SBDebugger::GetCommandInterpreter(); - //---------------------------------------------------------------------- /// Return true if the command interpreter is the active IO handler. /// /// This indicates that any input coming into the debugger handles will /// go to the command interpreter and will result in LLDB command line /// commands being executed. - //---------------------------------------------------------------------- bool IsActive(); - //---------------------------------------------------------------------- /// Get the string that needs to be written to the debugger stdin file /// handle when a control character is typed. /// @@ -207,43 +205,34 @@ public: /// terminal, so this function allows GUI programs to emulate this /// functionality. /// - /// @param[in] ch + /// \param[in] ch /// The character that was typed along with the control key /// - /// @return + /// \return /// The string that should be written into the file handle that is /// feeding the input stream for the debugger, or nullptr if there is /// no string for this control key. - //---------------------------------------------------------------------- const char *GetIOHandlerControlSequence(char ch); bool GetPromptOnQuit(); 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. - //---------------------------------------------------------------------- void ResolveCommand(const char *command_line, SBCommandReturnObject &result); protected: @@ -256,8 +245,6 @@ protected: private: friend class SBDebugger; - static void InitializeSWIG(); - lldb_private::CommandInterpreter *m_opaque_ptr; }; @@ -275,6 +262,8 @@ class SBCommand { public: SBCommand(); + explicit operator bool() const; + bool IsValid(); const char *GetName(); diff --git a/include/lldb/API/SBCommandReturnObject.h b/include/lldb/API/SBCommandReturnObject.h index 798aa92a7ef25..2877afb9b8b05 100644 --- a/include/lldb/API/SBCommandReturnObject.h +++ b/include/lldb/API/SBCommandReturnObject.h @@ -1,9 +1,8 @@ //===-- SBCommandReturnObject.h ---------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -33,6 +32,8 @@ public: lldb_private::CommandReturnObject *Release(); + explicit operator bool() const; + bool IsValid() const; const char *GetOutput(); @@ -100,7 +101,7 @@ protected: void SetLLDBObjectPtr(lldb_private::CommandReturnObject *ptr); private: - std::unique_ptr<lldb_private::CommandReturnObject> m_opaque_ap; + std::unique_ptr<lldb_private::CommandReturnObject> m_opaque_up; }; } // namespace lldb diff --git a/include/lldb/API/SBCommunication.h b/include/lldb/API/SBCommunication.h index f0016275b634a..5b803fc6017c6 100644 --- a/include/lldb/API/SBCommunication.h +++ b/include/lldb/API/SBCommunication.h @@ -1,9 +1,8 @@ //===-- SBCommunication.h ---------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -38,6 +37,8 @@ public: SBCommunication(const char *broadcaster_name); ~SBCommunication(); + explicit operator bool() const; + bool IsValid() const; lldb::SBBroadcaster GetBroadcaster(); diff --git a/include/lldb/API/SBCompileUnit.h b/include/lldb/API/SBCompileUnit.h index 4d5f9f36f246e..b6b138207d600 100644 --- a/include/lldb/API/SBCompileUnit.h +++ b/include/lldb/API/SBCompileUnit.h @@ -1,9 +1,8 @@ //===-- SBCompileUnit.h -----------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -25,6 +24,8 @@ public: const lldb::SBCompileUnit &operator=(const lldb::SBCompileUnit &rhs); + explicit operator bool() const; + bool IsValid() const; lldb::SBFileSpec GetFileSpec() const; @@ -47,11 +48,10 @@ public: uint32_t FindSupportFileIndex(uint32_t start_idx, const SBFileSpec &sb_file, bool full); - //------------------------------------------------------------------ /// Get all types matching \a type_mask from debug info in this /// compile unit. /// - /// @param[in] type_mask + /// \param[in] type_mask /// A bitfield that consists of one or more bits logically OR'ed /// together from the lldb::TypeClass enumeration. This allows /// you to request only structure types, or only class, struct @@ -59,9 +59,8 @@ public: /// all types found in the debug information for this compile /// unit. /// - /// @return + /// \return /// A list of types in this compile unit that match \a type_mask - //------------------------------------------------------------------ lldb::SBTypeList GetTypes(uint32_t type_mask = lldb::eTypeClassAny); lldb::LanguageType GetLanguage(); diff --git a/include/lldb/API/SBData.h b/include/lldb/API/SBData.h index 7ff619e68667b..886fe829a4699 100644 --- a/include/lldb/API/SBData.h +++ b/include/lldb/API/SBData.h @@ -1,9 +1,8 @@ //===-- SBData.h -----------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -30,6 +29,8 @@ public: void Clear(); + explicit operator bool() const; + bool IsValid(); size_t GetByteSize(); diff --git a/include/lldb/API/SBDebugger.h b/include/lldb/API/SBDebugger.h index 3f31bf16da8dd..417cead24a8c6 100644 --- a/include/lldb/API/SBDebugger.h +++ b/include/lldb/API/SBDebugger.h @@ -1,9 +1,8 @@ //===-- SBDebugger.h --------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -13,7 +12,6 @@ #include <stdio.h> #include "lldb/API/SBDefines.h" -#include "lldb/API/SBInitializerOptions.h" #include "lldb/API/SBPlatform.h" namespace lldb { @@ -23,12 +21,12 @@ public: SBInputReader() = default; ~SBInputReader() = default; - SBError Initialize(lldb::SBDebugger &, - unsigned long (*)(void *, lldb::SBInputReader *, - lldb::InputReaderAction, char const *, - unsigned long), - void *, lldb::InputReaderGranularity, char const *, - char const *, bool); + SBError Initialize(lldb::SBDebugger &sb_debugger, + unsigned long (*callback)(void *, lldb::SBInputReader *, + lldb::InputReaderAction, + char const *, unsigned long), + void *a, lldb::InputReaderGranularity b, char const *c, + char const *d, bool e); void SetIsDone(bool); bool IsActive() const; }; @@ -46,7 +44,8 @@ public: lldb::SBDebugger &operator=(const lldb::SBDebugger &rhs); static void Initialize(); - static lldb::SBError Initialize(SBInitializerOptions &options); + + static lldb::SBError InitializeWithErrorHandling(); static void Terminate(); @@ -63,6 +62,8 @@ public: static void MemoryPressureDetected(); + explicit operator bool() const; + bool IsValid() const; void Clear(); @@ -150,7 +151,7 @@ public: /// Get the name and description of one of the available platforms. /// - /// @param[in] idx + /// \param[in] idx /// Zero-based index of the platform for which info should be retrieved, /// must be less than the value returned by GetNumAvailablePlatforms(). lldb::SBStructuredData GetAvailablePlatformInfoAtIndex(uint32_t idx); @@ -254,15 +255,11 @@ public: SBTypeFormat GetFormatForType(SBTypeNameSpecifier); -#ifndef LLDB_DISABLE_PYTHON SBTypeSummary GetSummaryForType(SBTypeNameSpecifier); -#endif SBTypeFilter GetFilterForType(SBTypeNameSpecifier); -#ifndef LLDB_DISABLE_PYTHON SBTypeSynthetic GetSyntheticForType(SBTypeNameSpecifier); -#endif void RunCommandInterpreter(bool auto_handle_events, bool spawn_thread); diff --git a/include/lldb/API/SBDeclaration.h b/include/lldb/API/SBDeclaration.h index 42cf769638477..d2b423e40fec6 100644 --- a/include/lldb/API/SBDeclaration.h +++ b/include/lldb/API/SBDeclaration.h @@ -1,10 +1,9 @@ //===-- SBDeclaration.h -------------------------------------------*- C++ //-*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -26,6 +25,8 @@ public: const lldb::SBDeclaration &operator=(const lldb::SBDeclaration &rhs); + explicit operator bool() const; + bool IsValid() const; lldb::SBFileSpec GetFileSpec() const; @@ -62,7 +63,7 @@ private: void SetDeclaration(const lldb_private::Declaration &lldb_object_ref); - std::unique_ptr<lldb_private::Declaration> m_opaque_ap; + std::unique_ptr<lldb_private::Declaration> m_opaque_up; }; } // namespace lldb diff --git a/include/lldb/API/SBDefines.h b/include/lldb/API/SBDefines.h index c5c9851272f2c..838c84cece6de 100644 --- a/include/lldb/API/SBDefines.h +++ b/include/lldb/API/SBDefines.h @@ -1,9 +1,8 @@ //===-- SBDefines.h ---------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -17,10 +16,6 @@ #include "lldb/lldb-types.h" #include "lldb/lldb-versioning.h" -#ifdef SWIG -#define LLDB_API -#endif - // Forward Declarations namespace lldb { @@ -51,7 +46,6 @@ class LLDB_API SBFileSpecList; class LLDB_API SBFrame; class LLDB_API SBFunction; class LLDB_API SBHostOS; -class LLDB_API SBInitializerOptions; class LLDB_API SBInstruction; class LLDB_API SBInstructionList; class LLDB_API SBLanguageRuntime; diff --git a/include/lldb/API/SBError.h b/include/lldb/API/SBError.h index a27d2d0426907..b076f87b7669a 100644 --- a/include/lldb/API/SBError.h +++ b/include/lldb/API/SBError.h @@ -1,9 +1,8 @@ //===-- SBError.h -----------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -47,27 +46,30 @@ public: int SetErrorStringWithFormat(const char *format, ...) __attribute__((format(printf, 2, 3))); + explicit operator bool() const; + bool IsValid() const; bool GetDescription(lldb::SBStream &description); protected: + friend class SBBreakpoint; + friend class SBBreakpointLocation; + friend class SBBreakpointName; friend class SBCommandReturnObject; + friend class SBCommunication; friend class SBData; friend class SBDebugger; - friend class SBCommunication; friend class SBHostOS; friend class SBPlatform; friend class SBProcess; + friend class SBReproducer; friend class SBStructuredData; + friend class SBTarget; friend class SBThread; friend class SBTrace; - friend class SBTarget; friend class SBValue; friend class SBWatchpoint; - friend class SBBreakpoint; - friend class SBBreakpointLocation; - friend class SBBreakpointName; lldb_private::Status *get(); @@ -80,7 +82,7 @@ protected: void SetError(const lldb_private::Status &lldb_error); private: - std::unique_ptr<lldb_private::Status> m_opaque_ap; + std::unique_ptr<lldb_private::Status> m_opaque_up; void CreateIfNeeded(); }; diff --git a/include/lldb/API/SBEvent.h b/include/lldb/API/SBEvent.h index ff15716d853ed..d297cbeff671f 100644 --- a/include/lldb/API/SBEvent.h +++ b/include/lldb/API/SBEvent.h @@ -1,9 +1,8 @@ //===-- SBEvent.h -----------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -36,6 +35,8 @@ public: const SBEvent &operator=(const lldb::SBEvent &rhs); + explicit operator bool() const; + bool IsValid() const; const char *GetDataFlavor(); diff --git a/include/lldb/API/SBExecutionContext.h b/include/lldb/API/SBExecutionContext.h index c19d539bc80a9..45c0b1b7f97b6 100644 --- a/include/lldb/API/SBExecutionContext.h +++ b/include/lldb/API/SBExecutionContext.h @@ -1,10 +1,9 @@ //===-- SBExecutionContext.h -----------------------------------------*- C++ //-*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -51,8 +50,6 @@ public: SBFrame GetFrame() const; protected: - ExecutionContextRefSP &GetSP() const; - void reset(lldb::ExecutionContextRefSP &event_sp); lldb_private::ExecutionContextRef *get() const; diff --git a/include/lldb/API/SBExpressionOptions.h b/include/lldb/API/SBExpressionOptions.h index b861436caf988..04cd74f730f21 100644 --- a/include/lldb/API/SBExpressionOptions.h +++ b/include/lldb/API/SBExpressionOptions.h @@ -1,9 +1,8 @@ -//===-- SBEvent.h -----------------------------------------------*- C++ -*-===// +//===-- SBExpressionOptions.h -----------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -90,17 +89,14 @@ public: bool GetTopLevel(); void SetTopLevel(bool b = true); - + // Gets whether we will JIT an expression if it cannot be interpreted bool GetAllowJIT(); - + // Sets whether we will JIT an expression if it cannot be interpreted void SetAllowJIT(bool allow); protected: - SBExpressionOptions( - lldb_private::EvaluateExpressionOptions &expression_options); - lldb_private::EvaluateExpressionOptions *get() const; lldb_private::EvaluateExpressionOptions &ref() const; @@ -111,7 +107,7 @@ protected: private: // This auto_pointer is made in the constructor and is always valid. - mutable std::unique_ptr<lldb_private::EvaluateExpressionOptions> m_opaque_ap; + mutable std::unique_ptr<lldb_private::EvaluateExpressionOptions> m_opaque_up; }; } // namespace lldb diff --git a/include/lldb/API/SBFileSpec.h b/include/lldb/API/SBFileSpec.h index 9ad1a5df0cfa6..27149775901e8 100644 --- a/include/lldb/API/SBFileSpec.h +++ b/include/lldb/API/SBFileSpec.h @@ -1,9 +1,8 @@ //===-- SBFileSpec.h --------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -29,6 +28,12 @@ public: const SBFileSpec &operator=(const lldb::SBFileSpec &rhs); + explicit operator bool() const; + + bool operator==(const SBFileSpec &rhs) const; + + bool operator!=(const SBFileSpec &rhs) const; + bool IsValid() const; bool Exists() const; @@ -59,7 +64,6 @@ private: friend class SBDeclaration; friend class SBFileSpecList; friend class SBHostOS; - friend class SBInitializerOptions; friend class SBLaunchInfo; friend class SBLineEntry; friend class SBModule; @@ -83,7 +87,7 @@ private: const lldb_private::FileSpec &ref() const; - std::unique_ptr<lldb_private::FileSpec> m_opaque_ap; + std::unique_ptr<lldb_private::FileSpec> m_opaque_up; }; } // namespace lldb diff --git a/include/lldb/API/SBFileSpecList.h b/include/lldb/API/SBFileSpecList.h index 97f843adbb5ff..5a131509d2699 100644 --- a/include/lldb/API/SBFileSpecList.h +++ b/include/lldb/API/SBFileSpecList.h @@ -1,10 +1,9 @@ //===-- SBFileSpecList.h --------------------------------------------*- C++ //-*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -50,7 +49,7 @@ private: const lldb_private::FileSpecList &ref() const; - std::unique_ptr<lldb_private::FileSpecList> m_opaque_ap; + std::unique_ptr<lldb_private::FileSpecList> m_opaque_up; }; } // namespace lldb diff --git a/include/lldb/API/SBFrame.h b/include/lldb/API/SBFrame.h index 1123dade5de26..b213f89855109 100644 --- a/include/lldb/API/SBFrame.h +++ b/include/lldb/API/SBFrame.h @@ -1,9 +1,8 @@ //===-- SBFrame.h -----------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -27,6 +26,8 @@ public: bool IsEqual(const lldb::SBFrame &that) const; + explicit operator bool() const; + bool IsValid() const; uint32_t GetFrameID() const; diff --git a/include/lldb/API/SBFunction.h b/include/lldb/API/SBFunction.h index 23da02102cfb4..43f01d7e57dee 100644 --- a/include/lldb/API/SBFunction.h +++ b/include/lldb/API/SBFunction.h @@ -1,9 +1,8 @@ //===-- SBFunction.h --------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -26,6 +25,8 @@ public: ~SBFunction(); + explicit operator bool() const; + bool IsValid() const; const char *GetName() const; diff --git a/include/lldb/API/SBHostOS.h b/include/lldb/API/SBHostOS.h index 1671917f865c1..ecd7920f2c14a 100644 --- a/include/lldb/API/SBHostOS.h +++ b/include/lldb/API/SBHostOS.h @@ -1,9 +1,8 @@ //===-- SBHostOS.h ----------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// diff --git a/include/lldb/API/SBInitializerOptions.h b/include/lldb/API/SBInitializerOptions.h deleted file mode 100644 index 184c82df4f869..0000000000000 --- a/include/lldb/API/SBInitializerOptions.h +++ /dev/null @@ -1,43 +0,0 @@ -//===-- SBInitializerOptions.h ----------------------------------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -#ifndef LLDB_SBInitializerOptuions_h_ -#define LLDB_SBInitializerOptuions_h_ - -#include "lldb/API/SBDefines.h" -#include "lldb/API/SBFileSpec.h" - -namespace lldb_private { -struct InitializerOptions; -} - -namespace lldb { - -class LLDB_API SBInitializerOptions { -public: - SBInitializerOptions(); - SBInitializerOptions(const lldb::SBInitializerOptions &rhs); - ~SBInitializerOptions(); - const SBInitializerOptions &operator=(const lldb::SBInitializerOptions &rhs); - - void SetCaptureReproducer(bool b); - void SetReplayReproducer(bool b); - void SetReproducerPath(const char *path); - - lldb_private::InitializerOptions &ref() const; - -private: - friend class SBDebugger; - - std::unique_ptr<lldb_private::InitializerOptions> m_opaque_up; -}; - -} // namespace lldb - -#endif // LLDB_SBInitializerOptuions_h_ diff --git a/include/lldb/API/SBInstruction.h b/include/lldb/API/SBInstruction.h index 5ef02b8f696ad..0bb5877956074 100644 --- a/include/lldb/API/SBInstruction.h +++ b/include/lldb/API/SBInstruction.h @@ -1,9 +1,8 @@ //===-- SBInstruction.h -----------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -32,6 +31,8 @@ public: ~SBInstruction(); + explicit operator bool() const; + bool IsValid(); SBAddress GetAddress(); diff --git a/include/lldb/API/SBInstructionList.h b/include/lldb/API/SBInstructionList.h index c8fed5c83192b..4434d50f471f4 100644 --- a/include/lldb/API/SBInstructionList.h +++ b/include/lldb/API/SBInstructionList.h @@ -1,9 +1,8 @@ //===-- SBInstructionList.h -------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -26,17 +25,17 @@ public: ~SBInstructionList(); + explicit operator bool() const; + bool IsValid() const; size_t GetSize(); 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 // instructions on which a breakpoint can be set. - // ---------------------------------------------------------------------- size_t GetInstructionsCount(const SBAddress &start, const SBAddress &end, bool canSetBreakpoint = false); diff --git a/include/lldb/API/SBLanguageRuntime.h b/include/lldb/API/SBLanguageRuntime.h index 3912f352491bf..d28c441593eae 100644 --- a/include/lldb/API/SBLanguageRuntime.h +++ b/include/lldb/API/SBLanguageRuntime.h @@ -1,9 +1,8 @@ //===-- SBLanguageRuntime.h -------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// diff --git a/include/lldb/API/SBLaunchInfo.h b/include/lldb/API/SBLaunchInfo.h index 80eea7e429212..c7b381ffdf972 100644 --- a/include/lldb/API/SBLaunchInfo.h +++ b/include/lldb/API/SBLaunchInfo.h @@ -1,9 +1,8 @@ //===-- SBLaunchInfo.h ------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -43,7 +42,6 @@ public: SBFileSpec GetExecutableFile(); - //---------------------------------------------------------------------- /// Set the executable file that will be used to launch the process and /// optionally set it as the first argument in the argument vector. /// @@ -58,33 +56,28 @@ public: /// SBTarget::Launch(...), the target will use the resolved executable /// path that was used to create the target. /// - /// @param[in] exe_file + /// \param[in] exe_file /// The override path to use when launching the executable. /// - /// @param[in] add_as_first_arg + /// \param[in] add_as_first_arg /// If true, then the path will be inserted into the argument vector /// prior to launching. Otherwise the argument vector will be left /// alone. - //---------------------------------------------------------------------- void SetExecutableFile(SBFileSpec exe_file, bool add_as_first_arg); - //---------------------------------------------------------------------- /// Get the listener that will be used to receive process events. /// /// If no listener has been set via a call to /// SBLaunchInfo::SetListener(), then an invalid SBListener will be /// returned (SBListener::IsValid() will return false). If a listener /// has been set, then the valid listener object will be returned. - //---------------------------------------------------------------------- SBListener GetListener(); - //---------------------------------------------------------------------- /// Set the listener that will be used to receive process events. /// /// By default the SBDebugger, which has a listener, that the SBTarget /// belongs to will listen for the process events. Calling this function /// allows a different listener to be used to listen for process events. - //---------------------------------------------------------------------- void SetListener(SBListener &listener); uint32_t GetNumArguments(); diff --git a/include/lldb/API/SBLineEntry.h b/include/lldb/API/SBLineEntry.h index 3d58ea8278ea0..855c28d14b83a 100644 --- a/include/lldb/API/SBLineEntry.h +++ b/include/lldb/API/SBLineEntry.h @@ -1,9 +1,8 @@ //===-- SBLineEntry.h -------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -30,6 +29,8 @@ public: lldb::SBAddress GetEndAddress() const; + explicit operator bool() const; + bool IsValid() const; lldb::SBFileSpec GetFileSpec() const; @@ -69,7 +70,7 @@ private: void SetLineEntry(const lldb_private::LineEntry &lldb_object_ref); - std::unique_ptr<lldb_private::LineEntry> m_opaque_ap; + std::unique_ptr<lldb_private::LineEntry> m_opaque_up; }; } // namespace lldb diff --git a/include/lldb/API/SBListener.h b/include/lldb/API/SBListener.h index a2f82a83c3edd..21aface97bd1c 100644 --- a/include/lldb/API/SBListener.h +++ b/include/lldb/API/SBListener.h @@ -1,9 +1,8 @@ //===-- SBListener.h --------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -30,6 +29,8 @@ public: void Clear(); + explicit operator bool() const; + bool IsValid() const; uint32_t StartListeningForEventClass(SBDebugger &debugger, diff --git a/include/lldb/API/SBMemoryRegionInfo.h b/include/lldb/API/SBMemoryRegionInfo.h index 5675d93b8eaf6..2a9ae94218f2e 100644 --- a/include/lldb/API/SBMemoryRegionInfo.h +++ b/include/lldb/API/SBMemoryRegionInfo.h @@ -1,9 +1,8 @@ //===-- SBMemoryRegionInfo.h ------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -28,64 +27,50 @@ public: void Clear(); - //------------------------------------------------------------------ /// Get the base address of this memory range. /// - /// @return + /// \return /// The base address of this memory range. - //------------------------------------------------------------------ lldb::addr_t GetRegionBase(); - //------------------------------------------------------------------ /// Get the end address of this memory range. /// - /// @return + /// \return /// The base address of this memory range. - //------------------------------------------------------------------ lldb::addr_t GetRegionEnd(); - //------------------------------------------------------------------ /// Check if this memory address is marked readable to the process. /// - /// @return + /// \return /// true if this memory address is marked readable - //------------------------------------------------------------------ bool IsReadable(); - //------------------------------------------------------------------ /// Check if this memory address is marked writable to the process. /// - /// @return + /// \return /// true if this memory address is marked writable - //------------------------------------------------------------------ bool IsWritable(); - //------------------------------------------------------------------ /// Check if this memory address is marked executable to the process. /// - /// @return + /// \return /// true if this memory address is marked executable - //------------------------------------------------------------------ bool IsExecutable(); - //------------------------------------------------------------------ /// Check if this memory address is mapped into the process address /// space. /// - /// @return + /// \return /// true if this memory address is in the process address space. - //------------------------------------------------------------------ bool IsMapped(); - //------------------------------------------------------------------ /// Returns the name of the memory region mapped at the given /// address. /// - /// @return + /// \return /// In case of memory mapped files it is the absolute path of /// the file otherwise it is a name associated with the memory /// region. If no name can be determined the returns nullptr. - //------------------------------------------------------------------ const char *GetName(); bool operator==(const lldb::SBMemoryRegionInfo &rhs) const; @@ -105,7 +90,7 @@ private: // Unused. SBMemoryRegionInfo(const lldb_private::MemoryRegionInfo *lldb_object_ptr); - lldb::MemoryRegionInfoUP m_opaque_ap; + lldb::MemoryRegionInfoUP m_opaque_up; }; } // namespace lldb diff --git a/include/lldb/API/SBMemoryRegionInfoList.h b/include/lldb/API/SBMemoryRegionInfoList.h index 1e67997cdaf10..5592efef4851e 100644 --- a/include/lldb/API/SBMemoryRegionInfoList.h +++ b/include/lldb/API/SBMemoryRegionInfoList.h @@ -1,9 +1,8 @@ //===-- SBMemoryRegionInfoList.h --------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -48,7 +47,7 @@ private: const lldb_private::MemoryRegionInfos &ref() const; - std::unique_ptr<MemoryRegionInfoListImpl> m_opaque_ap; + std::unique_ptr<MemoryRegionInfoListImpl> m_opaque_up; }; } // namespace lldb diff --git a/include/lldb/API/SBModule.h b/include/lldb/API/SBModule.h index 7a10e9fc96b36..d2b6a18db84d3 100644 --- a/include/lldb/API/SBModule.h +++ b/include/lldb/API/SBModule.h @@ -1,9 +1,8 @@ //===-- SBModule.h ----------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -32,23 +31,22 @@ public: ~SBModule(); + explicit operator bool() const; + bool IsValid() const; void Clear(); - //------------------------------------------------------------------ /// Get const accessor for the module file specification. /// /// This function returns the file for the module on the host system /// that is running LLDB. This can differ from the path on the /// platform since we might be doing remote debugging. /// - /// @return + /// \return /// A const reference to the file specification object. - //------------------------------------------------------------------ lldb::SBFileSpec GetFileSpec() const; - //------------------------------------------------------------------ /// Get accessor for the module platform file specification. /// /// Platform file refers to the path of the module as it is known on @@ -60,14 +58,12 @@ public: /// '/tmp/lldb/platform-cache/remote.host.computer/usr/lib/liba.dylib' /// The file could also be cached in a local developer kit directory. /// - /// @return + /// \return /// A const reference to the file specification object. - //------------------------------------------------------------------ lldb::SBFileSpec GetPlatformFileSpec() const; bool SetPlatformFileSpec(const lldb::SBFileSpec &platform_file); - //------------------------------------------------------------------ /// Get accessor for the remote install path for a module. /// /// When debugging to a remote platform by connecting to a remote @@ -76,12 +72,10 @@ public: /// the target will install this module on the remote platform prior /// to launching. /// - /// @return + /// \return /// A file specification object. - //------------------------------------------------------------------ lldb::SBFileSpec GetRemoteInstallFileSpec(); - //------------------------------------------------------------------ /// Set accessor for the remote install path for a module. /// /// When debugging to a remote platform by connecting to a remote @@ -96,9 +90,8 @@ public: /// or "./usr/lib", then the install path will be resolved using /// the platform's current working directory as the base path. /// - /// @param[in] file + /// \param[in] file /// A file specification object. - //------------------------------------------------------------------ bool SetRemoteInstallFileSpec(lldb::SBFileSpec &file); lldb::ByteOrder GetByteOrder(); @@ -129,18 +122,16 @@ public: lldb::SBCompileUnit GetCompileUnitAtIndex(uint32_t); - //------------------------------------------------------------------ /// Find compile units related to *this module and passed source /// file. /// - /// @param[in] sb_file_spec + /// \param[in] sb_file_spec /// A lldb::SBFileSpec object that contains source file /// specification. /// - /// @return + /// \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); @@ -157,59 +148,53 @@ public: size_t GetNumSections(); lldb::SBSection GetSectionAtIndex(size_t idx); - //------------------------------------------------------------------ /// Find functions by name. /// - /// @param[in] name + /// \param[in] name /// The name of the function we are looking for. /// - /// @param[in] name_type_mask + /// \param[in] name_type_mask /// A logical OR of one or more FunctionNameType enum bits that /// indicate what kind of names should be used when doing the /// lookup. Bits include fully qualified names, base names, /// C++ methods, or ObjC selectors. /// See FunctionNameType for more details. /// - /// @return + /// \return /// A lldb::SBSymbolContextList that gets filled in with all of /// the symbol contexts for all the matches. - //------------------------------------------------------------------ lldb::SBSymbolContextList FindFunctions(const char *name, uint32_t name_type_mask = lldb::eFunctionNameTypeAny); - //------------------------------------------------------------------ /// Find global and static variables by name. /// - /// @param[in] target + /// \param[in] target /// A valid SBTarget instance representing the debuggee. /// - /// @param[in] name + /// \param[in] name /// The name of the global or static variable we are looking /// for. /// - /// @param[in] max_matches + /// \param[in] max_matches /// Allow the number of matches to be limited to \a max_matches. /// - /// @return + /// \return /// A list of matched variables in an SBValueList. - //------------------------------------------------------------------ lldb::SBValueList FindGlobalVariables(lldb::SBTarget &target, const char *name, uint32_t max_matches); - //------------------------------------------------------------------ /// Find the first global (or static) variable by name. /// - /// @param[in] target + /// \param[in] target /// A valid SBTarget instance representing the debuggee. /// - /// @param[in] name + /// \param[in] name /// The name of the global or static variable we are looking /// for. /// - /// @return + /// \return /// An SBValue that gets filled in with the found variable (if any). - //------------------------------------------------------------------ lldb::SBValue FindFirstGlobalVariable(lldb::SBTarget &target, const char *name); @@ -217,7 +202,6 @@ public: lldb::SBTypeList FindTypes(const char *type); - //------------------------------------------------------------------ /// Get a type using its type ID. /// /// Each symbol file reader will assign different user IDs to their @@ -226,34 +210,30 @@ public: /// /// For DWARF debug info, the type ID is the DIE offset. /// - /// @param[in] uid + /// \param[in] uid /// The type user ID. /// - /// @return + /// \return /// An SBType for the given type ID, or an empty SBType if the /// type was not found. - //------------------------------------------------------------------ lldb::SBType GetTypeByID(lldb::user_id_t uid); lldb::SBType GetBasicType(lldb::BasicType type); - //------------------------------------------------------------------ /// Get all types matching \a type_mask from debug info in this /// module. /// - /// @param[in] type_mask + /// \param[in] type_mask /// A bitfield that consists of one or more bits logically OR'ed /// together from the lldb::TypeClass enumeration. This allows /// you to request only structure types, or only class, struct /// and union types. Passing in lldb::eTypeClassAny will return /// all types found in the debug information for this module. /// - /// @return + /// \return /// A list of types in this module that match \a type_mask - //------------------------------------------------------------------ lldb::SBTypeList GetTypes(uint32_t type_mask = lldb::eTypeClassAny); - //------------------------------------------------------------------ /// Get the module version numbers. /// /// Many object files have a set of version numbers that describe @@ -267,7 +247,7 @@ public: /// 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 + /// \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 @@ -278,7 +258,7 @@ public: /// will be filled with \a num_versions UINT32_MAX values /// and zero will be returned. /// - /// @param[in] num_versions + /// \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 @@ -288,14 +268,12 @@ public: /// numbers in this object file, only \a num_versions will be /// filled into \a versions (if \a versions is non-NULL). /// - /// @return + /// \return /// This function always returns the number of version numbers /// that this object file has regardless of the number of /// version numbers that were copied into \a versions. - //------------------------------------------------------------------ uint32_t GetVersion(uint32_t *versions, uint32_t num_versions); - //------------------------------------------------------------------ /// Get accessor for the symbol file specification. /// /// When debugging an object file an additional debug information can @@ -303,9 +281,8 @@ public: /// like '/usr/lib/liba.dylib' then debug information can be located /// in folder like '/usr/lib/liba.dylib.dSYM/'. /// - /// @return + /// \return /// A const reference to the file specification object. - //------------------------------------------------------------------ lldb::SBFileSpec GetSymbolFileSpec() const; lldb::SBAddress GetObjectFileHeaderAddress() const; diff --git a/include/lldb/API/SBModuleSpec.h b/include/lldb/API/SBModuleSpec.h index 1a862703a702f..29b3117a261d9 100644 --- a/include/lldb/API/SBModuleSpec.h +++ b/include/lldb/API/SBModuleSpec.h @@ -1,9 +1,8 @@ //===-- SBModuleSpec.h ------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -25,25 +24,24 @@ public: const SBModuleSpec &operator=(const SBModuleSpec &rhs); + explicit operator bool() const; + bool IsValid() const; void Clear(); - //------------------------------------------------------------------ /// Get const accessor for the module file. /// /// This function returns the file for the module on the host system /// that is running LLDB. This can differ from the path on the /// platform since we might be doing remote debugging. /// - /// @return + /// \return /// A const reference to the file specification object. - //------------------------------------------------------------------ lldb::SBFileSpec GetFileSpec(); void SetFileSpec(const lldb::SBFileSpec &fspec); - //------------------------------------------------------------------ /// Get accessor for the module platform file. /// /// Platform file refers to the path of the module as it is known on @@ -55,9 +53,8 @@ public: /// '/tmp/lldb/platform-cache/remote.host.computer/usr/lib/liba.dylib' /// The file could also be cached in a local developer kit directory. /// - /// @return + /// \return /// A const reference to the file specification object. - //------------------------------------------------------------------ lldb::SBFileSpec GetPlatformFileSpec(); void SetPlatformFileSpec(const lldb::SBFileSpec &fspec); @@ -87,7 +84,7 @@ private: friend class SBModule; friend class SBTarget; - std::unique_ptr<lldb_private::ModuleSpec> m_opaque_ap; + std::unique_ptr<lldb_private::ModuleSpec> m_opaque_up; }; class SBModuleSpecList { @@ -117,7 +114,7 @@ public: bool GetDescription(lldb::SBStream &description); private: - std::unique_ptr<lldb_private::ModuleSpecList> m_opaque_ap; + std::unique_ptr<lldb_private::ModuleSpecList> m_opaque_up; }; } // namespace lldb diff --git a/include/lldb/API/SBPlatform.h b/include/lldb/API/SBPlatform.h index 952e310663190..7207b2e2a78d8 100644 --- a/include/lldb/API/SBPlatform.h +++ b/include/lldb/API/SBPlatform.h @@ -1,9 +1,8 @@ //===-- SBPlatform.h --------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -92,6 +91,8 @@ public: ~SBPlatform(); + explicit operator bool() const; + bool IsValid() const; void Clear(); @@ -108,9 +109,7 @@ public: bool IsConnected(); - //---------------------------------------------------------------------- // The following functions will work if the platform is connected - //---------------------------------------------------------------------- const char *GetTriple(); const char *GetHostname(); diff --git a/include/lldb/API/SBProcess.h b/include/lldb/API/SBProcess.h index 69cf8b4ce8544..863cb3ced6743 100644 --- a/include/lldb/API/SBProcess.h +++ b/include/lldb/API/SBProcess.h @@ -1,9 +1,8 @@ //===-- SBProcess.h ---------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -23,9 +22,7 @@ class SBEvent; class LLDB_API SBProcess { public: - //------------------------------------------------------------------ /// Broadcaster event bits definitions. - //------------------------------------------------------------------ FLAGS_ANONYMOUS_ENUM(){eBroadcastBitStateChanged = (1 << 0), eBroadcastBitInterrupt = (1 << 1), eBroadcastBitSTDOUT = (1 << 2), @@ -52,6 +49,8 @@ public: void Clear(); + explicit operator bool() const; + bool IsValid() const; lldb::SBTarget GetTarget() const; @@ -71,11 +70,9 @@ public: void AppendEventStateReport(const lldb::SBEvent &event, lldb::SBCommandReturnObject &result); - //------------------------------------------------------------------ /// Remote connection related functions. These will fail if the /// process is not in eStateConnected. They are intended for use /// when connecting to an externally managed debugserver instance. - //------------------------------------------------------------------ bool RemoteAttachToProcessWithID(lldb::pid_t pid, lldb::SBError &error); bool RemoteLaunch(char const **argv, char const **envp, @@ -84,9 +81,7 @@ public: uint32_t launch_flags, bool stop_at_entry, lldb::SBError &error); - //------------------------------------------------------------------ // Thread related functions - //------------------------------------------------------------------ uint32_t GetNumThreads(); lldb::SBThread GetThreadAtIndex(size_t index); @@ -97,12 +92,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. - //------------------------------------------------------------------ lldb::SBThread CreateOSPluginThread(lldb::tid_t tid, lldb::addr_t context); bool SetSelectedThread(const lldb::SBThread &thread); @@ -111,16 +104,12 @@ public: bool SetSelectedThreadByIndexID(uint32_t index_id); - //------------------------------------------------------------------ // Queue related functions - //------------------------------------------------------------------ uint32_t GetNumQueues(); lldb::SBQueue GetQueueAtIndex(size_t index); - //------------------------------------------------------------------ // Stepping related functions - //------------------------------------------------------------------ lldb::StateType GetState(); @@ -128,7 +117,6 @@ public: const char *GetExitDescription(); - //------------------------------------------------------------------ /// Gets the process ID /// /// Returns the process identifier for the process as it is known @@ -136,15 +124,13 @@ public: /// this is typically the same as if you called "getpid()" in the /// process. /// - /// @return + /// \return /// Returns LLDB_INVALID_PROCESS_ID if this object does not /// contain a valid process object, or if the process has not /// been launched. Returns a valid process ID if the process is /// valid. - //------------------------------------------------------------------ lldb::pid_t GetProcessID(); - //------------------------------------------------------------------ /// Gets the unique ID associated with this process object /// /// Unique IDs start at 1 and increment up with each new process @@ -152,11 +138,10 @@ public: /// create a process with the same process ID, there needs to be a /// way to tell two process instances apart. /// - /// @return + /// \return /// Returns a non-zero integer ID if this object contains a /// valid process object, zero if this object does not contain /// a valid process object. - //------------------------------------------------------------------ uint32_t GetUniqueID(); uint32_t GetAddressByteSize() const; @@ -181,18 +166,16 @@ public: uint32_t GetStopID(bool include_expression_stops = false); - //------------------------------------------------------------------ /// Gets the stop event corresponding to stop ID. // /// Note that it wasn't fully implemented and tracks only the stop /// event for the last natural stop ID. /// - /// @param [in] stop_id + /// \param [in] stop_id /// The ID of the stop event to return. /// - /// @return + /// \return /// The stop event corresponding to stop ID. - //------------------------------------------------------------------ lldb::SBEvent GetStopEventForStopID(uint32_t stop_id); size_t ReadMemory(addr_t addr, void *buf, size_t size, lldb::SBError &error); @@ -235,10 +218,9 @@ public: bool GetDescription(lldb::SBStream &description); - //------------------------------------------------------------------ /// Start Tracing with the given SBTraceOptions. /// - /// @param[in] options + /// \param[in] options /// Class containing trace options like trace buffer size, meta /// data buffer size, TraceType and any custom parameters /// {formatted as a JSON Dictionary}. In case of errors in @@ -253,95 +235,88 @@ public: /// parameters, only the parameters recognized by the target /// would be used and others would be ignored. /// - /// @param[out] error + /// \param[out] error /// An error explaining what went wrong. /// - /// @return + /// \return /// A SBTrace instance, which should be used /// to get the trace data or other trace related operations. - //------------------------------------------------------------------ lldb::SBTrace StartTrace(SBTraceOptions &options, lldb::SBError &error); uint32_t GetNumSupportedHardwareWatchpoints(lldb::SBError &error) const; - //------------------------------------------------------------------ /// Load a shared library into this process. /// - /// @param[in] remote_image_spec + /// \param[in] remote_image_spec /// The path for the shared library on the target what you want /// to load. /// - /// @param[out] error + /// \param[out] error /// An error object that gets filled in with any errors that /// might occur when trying to load the shared library. /// - /// @return + /// \return /// A token that represents the shared library that can be /// later used to unload the shared library. A value of /// LLDB_INVALID_IMAGE_TOKEN will be returned if the shared /// library can't be opened. - //------------------------------------------------------------------ uint32_t LoadImage(lldb::SBFileSpec &remote_image_spec, lldb::SBError &error); - //------------------------------------------------------------------ /// Load a shared library into this process. /// - /// @param[in] local_image_spec + /// \param[in] local_image_spec /// The file spec that points to the shared library that you /// want to load if the library is located on the host. The /// library will be copied over to the location specified by /// remote_image_spec or into the current working directory with /// the same filename if the remote_image_spec isn't specified. /// - /// @param[in] remote_image_spec + /// \param[in] remote_image_spec /// If local_image_spec is specified then the location where the /// library should be copied over from the host. If /// local_image_spec isn't specified, then the path for the /// shared library on the target what you want to load. /// - /// @param[out] error + /// \param[out] error /// An error object that gets filled in with any errors that /// might occur when trying to load the shared library. /// - /// @return + /// \return /// A token that represents the shared library that can be /// later used to unload the shared library. A value of /// LLDB_INVALID_IMAGE_TOKEN will be returned if the shared /// library can't be opened. - //------------------------------------------------------------------ uint32_t LoadImage(const lldb::SBFileSpec &local_image_spec, 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] image_spec + /// \param[in] image_spec /// The name of the shared library that you want to load. /// If image_spec is a relative path, the relative path will be /// appended to the search paths. /// If the image_spec is an absolute path, just the basename is used. /// - /// @param[in] paths + /// \param[in] paths /// A list of paths to search for the library whose basename is /// local_spec. /// - /// @param[out] loaded_path + /// \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 + /// \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 + /// \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, @@ -351,7 +326,6 @@ public: lldb::SBError SendEventData(const char *data); - //------------------------------------------------------------------ /// Return the number of different thread-origin extended backtraces /// this process can support. /// @@ -360,25 +334,22 @@ public: /// or the work item was enqueued to it (in the case of a libdispatch /// queue). /// - /// @return + /// \return /// The number of thread-origin extended backtrace types that may be /// available. - //------------------------------------------------------------------ uint32_t GetNumExtendedBacktraceTypes(); - //------------------------------------------------------------------ /// Return the name of one of the thread-origin extended backtrace /// methods. /// - /// @param [in] idx + /// \param [in] idx /// The index of the name to return. They will be returned in /// the order that the user will most likely want to see them. /// e.g. if the type at index 0 is not available for a thread, /// see if the type at index 1 provides an extended backtrace. /// - /// @return + /// \return /// The name at that index. - //------------------------------------------------------------------ const char *GetExtendedBacktraceTypeAtIndex(uint32_t idx); lldb::SBThreadCollection GetHistoryThreads(addr_t addr); @@ -388,40 +359,34 @@ public: /// Save the state of the process in a core file (or mini dump on Windows). lldb::SBError SaveCore(const char *file_name); - //------------------------------------------------------------------ /// Query the address load_addr and store the details of the memory /// region that contains it in the supplied SBMemoryRegionInfo object. /// To iterate over all memory regions use GetMemoryRegionList. /// - /// @param[in] load_addr + /// \param[in] load_addr /// The address to be queried. /// - /// @param[out] region_info + /// \param[out] region_info /// A reference to an SBMemoryRegionInfo object that will contain /// the details of the memory region containing load_addr. /// - /// @return + /// \return /// An error object describes any errors that occurred while /// querying load_addr. - //------------------------------------------------------------------ lldb::SBError GetMemoryRegionInfo(lldb::addr_t load_addr, lldb::SBMemoryRegionInfo ®ion_info); - //------------------------------------------------------------------ /// Return the list of memory regions within the process. /// - /// @return + /// \return /// A list of all witin the process memory regions. - //------------------------------------------------------------------ lldb::SBMemoryRegionInfoList GetMemoryRegions(); - //------------------------------------------------------------------ /// Return information about the process. /// /// Valid process info will only be returned when the process is /// alive, use SBProcessInfo::IsValid() to check returned info is /// valid. - //------------------------------------------------------------------ lldb::SBProcessInfo GetProcessInfo(); protected: diff --git a/include/lldb/API/SBProcessInfo.h b/include/lldb/API/SBProcessInfo.h index 421227f82c2d9..86dba9a8e116b 100644 --- a/include/lldb/API/SBProcessInfo.h +++ b/include/lldb/API/SBProcessInfo.h @@ -1,9 +1,8 @@ //===-- SBProcessInfo.h -----------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -23,6 +22,8 @@ public: SBProcessInfo &operator=(const SBProcessInfo &rhs); + explicit operator bool() const; + bool IsValid() const; const char *GetName(); @@ -56,7 +57,7 @@ private: void SetProcessInfo(const lldb_private::ProcessInstanceInfo &proc_info_ref); - std::unique_ptr<lldb_private::ProcessInstanceInfo> m_opaque_ap; + std::unique_ptr<lldb_private::ProcessInstanceInfo> m_opaque_up; }; } // namespace lldb diff --git a/include/lldb/API/SBQueue.h b/include/lldb/API/SBQueue.h index 53612c0a125f0..0124c1c90dd27 100644 --- a/include/lldb/API/SBQueue.h +++ b/include/lldb/API/SBQueue.h @@ -1,9 +1,8 @@ //===-- SBQueue.h -----------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -29,6 +28,8 @@ public: ~SBQueue(); + explicit operator bool() const; + bool IsValid() const; void Clear(); @@ -59,10 +60,6 @@ protected: void SetQueue(const lldb::QueueSP &queue_sp); - void FetchThreads(); - - void FetchItems(); - private: std::shared_ptr<lldb_private::QueueImpl> m_opaque_sp; }; diff --git a/include/lldb/API/SBQueueItem.h b/include/lldb/API/SBQueueItem.h index 78ca3ba02db1b..455a1f98379a8 100644 --- a/include/lldb/API/SBQueueItem.h +++ b/include/lldb/API/SBQueueItem.h @@ -1,9 +1,8 @@ //===-- SBQueueItem.h -------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -23,6 +22,8 @@ public: ~SBQueueItem(); + explicit operator bool() const; + bool IsValid() const; void Clear(); diff --git a/include/lldb/API/SBReproducer.h b/include/lldb/API/SBReproducer.h new file mode 100644 index 0000000000000..0f1739d0c5bda --- /dev/null +++ b/include/lldb/API/SBReproducer.h @@ -0,0 +1,28 @@ +//===-- SBReproducer.h ------------------------------------------*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef LLDB_API_SBREPRODUCER_H +#define LLDB_API_SBREPRODUCER_H + +#include "lldb/API/SBDefines.h" + +namespace lldb { + +/// The SBReproducer class is special because it bootstraps the capture and +/// replay of SB API calls. As a result we cannot rely on any other SB objects +/// in the interface or implementation of this class. +class LLDB_API SBReproducer { +public: + static const char *Capture(); + static const char *Capture(const char *path); + static const char *Replay(const char *path); +}; + +} // namespace lldb + +#endif diff --git a/include/lldb/API/SBSection.h b/include/lldb/API/SBSection.h index ffd8bf7c979bd..06a195ee78df0 100644 --- a/include/lldb/API/SBSection.h +++ b/include/lldb/API/SBSection.h @@ -1,9 +1,8 @@ //===-- SBSection.h ---------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -25,6 +24,8 @@ public: const lldb::SBSection &operator=(const lldb::SBSection &rhs); + explicit operator bool() const; + bool IsValid() const; const char *GetName(); @@ -53,7 +54,6 @@ public: SectionType GetSectionType(); - //------------------------------------------------------------------ /// Gets the permissions (RWX) of the section of the object file /// /// Returns a mask of bits of enum lldb::Permissions for this section. @@ -62,21 +62,18 @@ public: /// i.e. for a section having read and execute permissions, the value /// returned is 6 /// - /// @return + /// \return /// Returns an unsigned value for Permissions for the section. - //------------------------------------------------------------------ uint32_t GetPermissions() const; - //------------------------------------------------------------------ /// Return the size of a target's byte represented by this section /// in numbers of host bytes. Note that certain architectures have /// varying minimum addressable unit (i.e. byte) size for their /// CODE or DATA buses. /// - /// @return + /// \return /// The number of host (8-bit) bytes needed to hold a target byte - //------------------------------------------------------------------ uint32_t GetTargetByteSize(); bool operator==(const lldb::SBSection &rhs); diff --git a/include/lldb/API/SBSourceManager.h b/include/lldb/API/SBSourceManager.h index 6f1c49504d52f..3d69aa25a9342 100644 --- a/include/lldb/API/SBSourceManager.h +++ b/include/lldb/API/SBSourceManager.h @@ -1,9 +1,8 @@ //===-- SBSourceManager.h ---------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -39,10 +38,8 @@ protected: friend class SBCommandInterpreter; friend class SBDebugger; - SBSourceManager(lldb_private::SourceManager *source_manager); - private: - std::unique_ptr<lldb_private::SourceManagerImpl> m_opaque_ap; + std::unique_ptr<lldb_private::SourceManagerImpl> m_opaque_up; }; } // namespace lldb diff --git a/include/lldb/API/SBStream.h b/include/lldb/API/SBStream.h index 7364ca7797f89..8afbf4575621a 100644 --- a/include/lldb/API/SBStream.h +++ b/include/lldb/API/SBStream.h @@ -1,9 +1,8 @@ //===-- SBStream.h ----------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -24,6 +23,8 @@ public: ~SBStream(); + explicit operator bool() const; + bool IsValid() const; // If this stream is not redirected to a file, it will maintain a local cache @@ -95,7 +96,7 @@ protected: private: DISALLOW_COPY_AND_ASSIGN(SBStream); - std::unique_ptr<lldb_private::Stream> m_opaque_ap; + std::unique_ptr<lldb_private::Stream> m_opaque_up; bool m_is_file; }; diff --git a/include/lldb/API/SBStringList.h b/include/lldb/API/SBStringList.h index 943384e544cd1..1df1e45f96fea 100644 --- a/include/lldb/API/SBStringList.h +++ b/include/lldb/API/SBStringList.h @@ -1,9 +1,8 @@ //===-- SBStringList.h ------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -24,6 +23,8 @@ public: ~SBStringList(); + explicit operator bool() const; + bool IsValid() const; void AppendString(const char *str); @@ -56,7 +57,7 @@ protected: const lldb_private::StringList &operator*() const; private: - std::unique_ptr<lldb_private::StringList> m_opaque_ap; + std::unique_ptr<lldb_private::StringList> m_opaque_up; }; } // namespace lldb diff --git a/include/lldb/API/SBStructuredData.h b/include/lldb/API/SBStructuredData.h index 629d4f3e35ee3..5b10133500ef1 100644 --- a/include/lldb/API/SBStructuredData.h +++ b/include/lldb/API/SBStructuredData.h @@ -1,9 +1,8 @@ //===-- SBStructuredData.h --------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -29,6 +28,8 @@ public: lldb::SBStructuredData &operator=(const lldb::SBStructuredData &rhs); + explicit operator bool() const; + bool IsValid() const; lldb::SBError SetFromJSON(lldb::SBStream &stream); @@ -39,69 +40,51 @@ public: lldb::SBError GetDescription(lldb::SBStream &stream) const; - //------------------------------------------------------------------ /// Return the type of data in this data structure - //------------------------------------------------------------------ lldb::StructuredDataType GetType() const; - //------------------------------------------------------------------ /// Return the size (i.e. number of elements) in this data structure /// if it is an array or dictionary type. For other types, 0 will be // returned. - //------------------------------------------------------------------ size_t GetSize() const; - //------------------------------------------------------------------ /// Fill keys with the keys in this object and return true if this data /// structure is a dictionary. Returns false otherwise. - //------------------------------------------------------------------ bool GetKeys(lldb::SBStringList &keys) const; - //------------------------------------------------------------------ /// Return the value corresponding to a key if this data structure /// is a dictionary type. - //------------------------------------------------------------------ lldb::SBStructuredData GetValueForKey(const char *key) const; - //------------------------------------------------------------------ /// Return the value corresponding to an index if this data structure /// is array. - //------------------------------------------------------------------ lldb::SBStructuredData GetItemAtIndex(size_t idx) const; - //------------------------------------------------------------------ /// Return the integer value if this data structure is an integer type. - //------------------------------------------------------------------ uint64_t GetIntegerValue(uint64_t fail_value = 0) const; - //------------------------------------------------------------------ /// Return the floating point value if this data structure is a floating /// type. - //------------------------------------------------------------------ double GetFloatValue(double fail_value = 0.0) const; - //------------------------------------------------------------------ /// Return the boolean value if this data structure is a boolean type. - //------------------------------------------------------------------ bool GetBooleanValue(bool fail_value = false) const; - //------------------------------------------------------------------ /// Provides the string value if this data structure is a string type. /// - /// @param[out] dst + /// \param[out] dst /// pointer where the string value will be written. In case it is null, - /// nothing will be written at @dst. + /// nothing will be written at \a dst. /// - /// @param[in] dst_len - /// max number of characters that can be written at @dst. In case it is - /// zero, nothing will be written at @dst. If this length is not enough - /// to write the complete string value, (dst_len-1) bytes of the string - /// value will be written at @dst followed by a null character. + /// \param[in] dst_len + /// max number of characters that can be written at \a dst. In case it is + /// zero, nothing will be written at \a dst. If this length is not enough + /// to write the complete string value, (\a dst_len - 1) bytes of the + /// string value will be written at \a dst followed by a null character. /// - /// @return + /// \return /// Returns the byte size needed to completely write the string value at - /// @dst in all cases. - //------------------------------------------------------------------ + /// \a dst in all cases. size_t GetStringValue(char *dst, size_t dst_len) const; protected: diff --git a/include/lldb/API/SBSymbol.h b/include/lldb/API/SBSymbol.h index a29ac61d2912b..52486b83d1a74 100644 --- a/include/lldb/API/SBSymbol.h +++ b/include/lldb/API/SBSymbol.h @@ -1,9 +1,8 @@ //===-- SBSymbol.h ----------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -27,6 +26,8 @@ public: const lldb::SBSymbol &operator=(const lldb::SBSymbol &rhs); + explicit operator bool() const; + bool IsValid() const; const char *GetName() const; @@ -54,16 +55,12 @@ public: bool GetDescription(lldb::SBStream &description); - //---------------------------------------------------------------------- // Returns true if the symbol is externally visible in the module that it is // defined in - //---------------------------------------------------------------------- bool IsExternal(); - //---------------------------------------------------------------------- // Returns true if the symbol was synthetically generated from something // other than the actual symbol table itself in the object file. - //---------------------------------------------------------------------- bool IsSynthetic(); protected: diff --git a/include/lldb/API/SBSymbolContext.h b/include/lldb/API/SBSymbolContext.h index 9078b5b789e08..3d16d0989ca11 100644 --- a/include/lldb/API/SBSymbolContext.h +++ b/include/lldb/API/SBSymbolContext.h @@ -1,9 +1,8 @@ //===-- SBSymbolContext.h ---------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -30,6 +29,8 @@ public: ~SBSymbolContext(); + explicit operator bool() const; + bool IsValid() const; const lldb::SBSymbolContext &operator=(const lldb::SBSymbolContext &rhs); @@ -74,7 +75,7 @@ protected: void SetSymbolContext(const lldb_private::SymbolContext *sc_ptr); private: - std::unique_ptr<lldb_private::SymbolContext> m_opaque_ap; + std::unique_ptr<lldb_private::SymbolContext> m_opaque_up; }; } // namespace lldb diff --git a/include/lldb/API/SBSymbolContextList.h b/include/lldb/API/SBSymbolContextList.h index e7299dd5330c9..577993ce96ddb 100644 --- a/include/lldb/API/SBSymbolContextList.h +++ b/include/lldb/API/SBSymbolContextList.h @@ -1,9 +1,8 @@ //===-- SBSymbolContextList.h -----------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -26,6 +25,8 @@ public: const lldb::SBSymbolContextList & operator=(const lldb::SBSymbolContextList &rhs); + explicit operator bool() const; + bool IsValid() const; uint32_t GetSize() const; @@ -49,7 +50,7 @@ protected: lldb_private::SymbolContextList &operator*() const; private: - std::unique_ptr<lldb_private::SymbolContextList> m_opaque_ap; + std::unique_ptr<lldb_private::SymbolContextList> m_opaque_up; }; } // namespace lldb diff --git a/include/lldb/API/SBTarget.h b/include/lldb/API/SBTarget.h index 18de267fee00a..80a7fa00dbc51 100644 --- a/include/lldb/API/SBTarget.h +++ b/include/lldb/API/SBTarget.h @@ -1,9 +1,8 @@ //===-- SBTarget.h ----------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -29,9 +28,7 @@ class SBPlatform; class LLDB_API SBTarget { public: - //------------------------------------------------------------------ // Broadcaster bits. - //------------------------------------------------------------------ enum { eBroadcastBitBreakpointChanged = (1 << 0), eBroadcastBitModulesLoaded = (1 << 1), @@ -40,22 +37,20 @@ public: eBroadcastBitSymbolsLoaded = (1 << 4) }; - //------------------------------------------------------------------ // Constructors - //------------------------------------------------------------------ SBTarget(); SBTarget(const lldb::SBTarget &rhs); SBTarget(const lldb::TargetSP &target_sp); - //------------------------------------------------------------------ // Destructor - //------------------------------------------------------------------ ~SBTarget(); const lldb::SBTarget &operator=(const lldb::SBTarget &rhs); + explicit operator bool() const; + bool IsValid() const; static bool EventIsTargetEvent(const lldb::SBEvent &event); @@ -71,45 +66,34 @@ public: lldb::SBProcess GetProcess(); - //------------------------------------------------------------------ /// Sets whether we should collect statistics on lldb or not. /// - /// @param[in] v + /// \param[in] v /// A boolean to control the collection. - /// @return - /// void - //------------------------------------------------------------------ void SetCollectingStats(bool v); - //------------------------------------------------------------------ /// Returns whether statistics collection are enabled. /// - /// @return + /// \return /// true if statistics are currently being collected, false /// otherwise. - //------------------------------------------------------------------ bool GetCollectingStats(); - //------------------------------------------------------------------ /// Returns a dump of the collected statistics. /// - /// @return + /// \return /// A SBStructuredData with the statistics collected. - //------------------------------------------------------------------ lldb::SBStructuredData GetStatistics(); - //------------------------------------------------------------------ /// Return the platform object associated with the target. /// /// After return, the platform object should be checked for /// validity. /// - /// @return + /// \return /// A platform object. - //------------------------------------------------------------------ lldb::SBPlatform GetPlatform(); - //------------------------------------------------------------------ /// Install any binaries that need to be installed. /// /// This function does nothing when debugging on the host system. @@ -119,13 +103,11 @@ public: /// have an install location set, it will be installed in the remote /// platform's working directory. /// - /// @return + /// \return /// An error describing anything that went wrong during /// installation. - //------------------------------------------------------------------ SBError Install(); - //------------------------------------------------------------------ /// Launch a new process. /// /// Launch a new process by spawning a new process using the @@ -135,49 +117,48 @@ public: /// optionally re-directed to \a stdin_path, \a stdout_path, and /// \a stderr_path. /// - /// @param[in] listener + /// \param[in] listener /// An optional listener that will receive all process events. /// If \a listener is valid then \a listener will listen to all /// process events. If not valid, then this target's debugger /// (SBTarget::GetDebugger()) will listen to all process events. /// - /// @param[in] argv + /// \param[in] argv /// The argument array. /// - /// @param[in] envp + /// \param[in] envp /// The environment array. /// - /// @param[in] stdin_path + /// \param[in] stdin_path /// The path to use when re-directing the STDIN of the new /// process. If all stdXX_path arguments are nullptr, a pseudo /// terminal will be used. /// - /// @param[in] stdout_path + /// \param[in] stdout_path /// The path to use when re-directing the STDOUT of the new /// process. If all stdXX_path arguments are nullptr, a pseudo /// terminal will be used. /// - /// @param[in] stderr_path + /// \param[in] stderr_path /// The path to use when re-directing the STDERR of the new /// process. If all stdXX_path arguments are nullptr, a pseudo /// terminal will be used. /// - /// @param[in] working_directory + /// \param[in] working_directory /// The working directory to have the child process run in /// - /// @param[in] launch_flags + /// \param[in] launch_flags /// Some launch options specified by logical OR'ing /// lldb::LaunchFlags enumeration values together. /// - /// @param[in] stop_at_entry + /// \param[in] stop_at_entry /// If false do not stop the inferior at the entry point. /// - /// @param[out] error + /// \param[out] error /// An error object. Contains the reason if there is some failure. /// - /// @return + /// \return /// A process object for the newly created process. - //------------------------------------------------------------------ lldb::SBProcess Launch(SBListener &listener, char const **argv, char const **envp, const char *stdin_path, const char *stdout_path, const char *stderr_path, @@ -188,16 +169,15 @@ public: SBProcess LoadCore(const char *core_file); SBProcess LoadCore(const char *core_file, lldb::SBError &error); - //------------------------------------------------------------------ /// Launch a new process with sensible defaults. /// - /// @param[in] argv + /// \param[in] argv /// The argument array. /// - /// @param[in] envp + /// \param[in] envp /// The environment array. /// - /// @param[in] working_directory + /// \param[in] working_directory /// The working directory to have the child process run in /// /// Default: listener @@ -211,9 +191,8 @@ public: /// Default: stderr_path /// A pseudo terminal will be used. /// - /// @return + /// \return /// A process object for the newly created process. - //------------------------------------------------------------------ SBProcess LaunchSimple(const char **argv, const char **envp, const char *working_directory); @@ -221,73 +200,67 @@ public: SBProcess Attach(SBAttachInfo &attach_info, SBError &error); - //------------------------------------------------------------------ /// Attach to process with pid. /// - /// @param[in] listener + /// \param[in] listener /// An optional listener that will receive all process events. /// If \a listener is valid then \a listener will listen to all /// process events. If not valid, then this target's debugger /// (SBTarget::GetDebugger()) will listen to all process events. /// - /// @param[in] pid + /// \param[in] pid /// The process ID to attach to. /// - /// @param[out] error + /// \param[out] error /// An error explaining what went wrong if attach fails. /// - /// @return + /// \return /// A process object for the attached process. - //------------------------------------------------------------------ lldb::SBProcess AttachToProcessWithID(SBListener &listener, lldb::pid_t pid, lldb::SBError &error); - //------------------------------------------------------------------ /// Attach to process with name. /// - /// @param[in] listener + /// \param[in] listener /// An optional listener that will receive all process events. /// If \a listener is valid then \a listener will listen to all /// process events. If not valid, then this target's debugger /// (SBTarget::GetDebugger()) will listen to all process events. /// - /// @param[in] name + /// \param[in] name /// Basename of process to attach to. /// - /// @param[in] wait_for + /// \param[in] wait_for /// If true wait for a new instance of 'name' to be launched. /// - /// @param[out] error + /// \param[out] error /// An error explaining what went wrong if attach fails. /// - /// @return + /// \return /// A process object for the attached process. - //------------------------------------------------------------------ lldb::SBProcess AttachToProcessWithName(SBListener &listener, const char *name, bool wait_for, lldb::SBError &error); - //------------------------------------------------------------------ /// Connect to a remote debug server with url. /// - /// @param[in] listener + /// \param[in] listener /// An optional listener that will receive all process events. /// If \a listener is valid then \a listener will listen to all /// process events. If not valid, then this target's debugger /// (SBTarget::GetDebugger()) will listen to all process events. /// - /// @param[in] url + /// \param[in] url /// The url to connect to, e.g., 'connect://localhost:12345'. /// - /// @param[in] plugin_name + /// \param[in] plugin_name /// The plugin name to be used; can be nullptr. /// - /// @param[out] error + /// \param[out] error /// An error explaining what went wrong if the connect fails. /// - /// @return + /// \return /// A process object for the connected process. - //------------------------------------------------------------------ lldb::SBProcess ConnectRemote(SBListener &listener, const char *url, const char *plugin_name, SBError &error); @@ -317,18 +290,16 @@ 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 + /// \param[in] sb_file_spec /// A lldb::SBFileSpec object that contains source file /// specification. /// - /// @return + /// \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); @@ -338,55 +309,46 @@ public: const char *GetTriple(); - //------------------------------------------------------------------ /// Architecture data byte width accessor /// - /// @return + /// \return /// The size in 8-bit (host) bytes of a minimum addressable /// unit from the Architecture's data bus - //------------------------------------------------------------------ uint32_t GetDataByteSize(); - //------------------------------------------------------------------ /// Architecture code byte width accessor /// - /// @return + /// \return /// The size in 8-bit (host) bytes of a minimum addressable /// unit from the Architecture's code bus - //------------------------------------------------------------------ uint32_t GetCodeByteSize(); - //------------------------------------------------------------------ /// Set the base load address for a module section. /// - /// @param[in] section + /// \param[in] section /// The section whose base load address will be set within this /// target. /// - /// @param[in] section_base_addr + /// \param[in] section_base_addr /// The base address for the section. /// - /// @return + /// \return /// An error to indicate success, fail, and any reason for /// failure. - //------------------------------------------------------------------ lldb::SBError SetSectionLoadAddress(lldb::SBSection section, lldb::addr_t section_base_addr); - //------------------------------------------------------------------ /// Clear the base load address for a module section. /// - /// @param[in] section + /// \param[in] section /// The section whose base load address will be cleared within /// this target. /// - /// @return + /// \return /// An error to indicate success, fail, and any reason for /// failure. - //------------------------------------------------------------------ lldb::SBError ClearSectionLoadAddress(lldb::SBSection section); - //------------------------------------------------------------------ /// Slide all file addresses for all module sections so that \a module /// appears to loaded at these slide addresses. /// @@ -395,150 +357,132 @@ public: /// this function will allow you to easily and quickly slide all /// module sections. /// - /// @param[in] module + /// \param[in] module /// The module to load. /// - /// @param[in] sections_offset + /// \param[in] sections_offset /// An offset that will be applied to all section file addresses /// (the virtual addresses found in the object file itself). /// - /// @return + /// \return /// An error to indicate success, fail, and any reason for /// failure. - //------------------------------------------------------------------ lldb::SBError SetModuleLoadAddress(lldb::SBModule module, int64_t sections_offset); - //------------------------------------------------------------------ /// Clear the section base load addresses for all sections in a module. /// - /// @param[in] module + /// \param[in] module /// The module to unload. /// - /// @return + /// \return /// An error to indicate success, fail, and any reason for /// failure. - //------------------------------------------------------------------ lldb::SBError ClearModuleLoadAddress(lldb::SBModule module); - //------------------------------------------------------------------ /// Find functions by name. /// - /// @param[in] name + /// \param[in] name /// The name of the function we are looking for. /// - /// @param[in] name_type_mask + /// \param[in] name_type_mask /// A logical OR of one or more FunctionNameType enum bits that /// indicate what kind of names should be used when doing the /// lookup. Bits include fully qualified names, base names, /// C++ methods, or ObjC selectors. /// See FunctionNameType for more details. /// - /// @return + /// \return /// A lldb::SBSymbolContextList that gets filled in with all of /// the symbol contexts for all the matches. - //------------------------------------------------------------------ lldb::SBSymbolContextList FindFunctions(const char *name, uint32_t name_type_mask = lldb::eFunctionNameTypeAny); - //------------------------------------------------------------------ /// Find global and static variables by name. /// - /// @param[in] name + /// \param[in] name /// The name of the global or static variable we are looking /// for. /// - /// @param[in] max_matches + /// \param[in] max_matches /// Allow the number of matches to be limited to \a max_matches. /// - /// @return + /// \return /// A list of matched variables in an SBValueList. - //------------------------------------------------------------------ lldb::SBValueList FindGlobalVariables(const char *name, uint32_t max_matches); - //------------------------------------------------------------------ /// Find the first global (or static) variable by name. /// - /// @param[in] name + /// \param[in] name /// The name of the global or static variable we are looking /// for. /// - /// @return + /// \return /// An SBValue that gets filled in with the found variable (if any). - //------------------------------------------------------------------ lldb::SBValue FindFirstGlobalVariable(const char *name); - //------------------------------------------------------------------ /// Find global and static variables by pattern. /// - /// @param[in] name + /// \param[in] name /// The pattern to search for global or static variables /// - /// @param[in] max_matches + /// \param[in] max_matches /// Allow the number of matches to be limited to \a max_matches. /// - /// @param[in] matchtype + /// \param[in] matchtype /// The match type to use. /// - /// @return + /// \return /// A list of matched variables in an SBValueList. - //------------------------------------------------------------------ lldb::SBValueList FindGlobalVariables(const char *name, uint32_t max_matches, MatchType matchtype); - //------------------------------------------------------------------ /// Find global functions by their name with pattern matching. /// - /// @param[in] name + /// \param[in] name /// The pattern to search for global or static variables /// - /// @param[in] max_matches + /// \param[in] max_matches /// Allow the number of matches to be limited to \a max_matches. /// - /// @param[in] matchtype + /// \param[in] matchtype /// The match type to use. /// - /// @return + /// \return /// A list of matched variables in an SBValueList. - //------------------------------------------------------------------ lldb::SBSymbolContextList FindGlobalFunctions(const char *name, uint32_t max_matches, MatchType matchtype); void Clear(); - //------------------------------------------------------------------ /// Resolve a current file address into a section offset address. /// - /// @param[in] file_addr + /// \param[in] file_addr /// The file address to resolve. /// - /// @return + /// \return /// An SBAddress which will be valid if... - //------------------------------------------------------------------ lldb::SBAddress ResolveFileAddress(lldb::addr_t file_addr); - //------------------------------------------------------------------ /// Resolve a current load address into a section offset address. /// - /// @param[in] vm_addr + /// \param[in] vm_addr /// A virtual address from the current process state that is to /// be translated into a section offset address. /// - /// @return + /// \return /// An SBAddress which will be valid if \a vm_addr was /// successfully resolved into a section offset address, or an /// invalid SBAddress if \a vm_addr doesn't resolve to a section /// in a module. - //------------------------------------------------------------------ lldb::SBAddress ResolveLoadAddress(lldb::addr_t vm_addr); - //------------------------------------------------------------------ /// Resolve a current load address into a section offset address /// using the process stop ID to identify a time in the past. /// - /// @param[in] stop_id + /// \param[in] stop_id /// Each time a process stops, the process stop ID integer gets /// incremented. These stop IDs are used to identify past times /// and can be used in history objects as a cheap way to store @@ -546,44 +490,41 @@ public: /// UINT32_MAX will always resolve the address using the /// currently loaded sections. /// - /// @param[in] vm_addr + /// \param[in] vm_addr /// A virtual address from the current process state that is to /// be translated into a section offset address. /// - /// @return + /// \return /// An SBAddress which will be valid if \a vm_addr was /// successfully resolved into a section offset address, or an /// invalid SBAddress if \a vm_addr doesn't resolve to a section /// in a module. - //------------------------------------------------------------------ lldb::SBAddress ResolvePastLoadAddress(uint32_t stop_id, lldb::addr_t vm_addr); SBSymbolContext ResolveSymbolContextForAddress(const SBAddress &addr, uint32_t resolve_scope); - //------------------------------------------------------------------ /// Read target memory. If a target process is running then memory /// is read from here. Otherwise the memory is read from the object /// files. For a target whose bytes are sized as a multiple of host /// bytes, the data read back will preserve the target's byte order. /// - /// @param[in] addr + /// \param[in] addr /// A target address to read from. /// - /// @param[out] buf + /// \param[out] buf /// The buffer to read memory into. /// - /// @param[in] size + /// \param[in] size /// The maximum number of host bytes to read in the buffer passed /// into this call /// - /// @param[out] error + /// \param[out] error /// Status information is written here if the memory read fails. /// - /// @return + /// \return /// The amount of data read in host bytes. - //------------------------------------------------------------------ size_t ReadMemory(const SBAddress addr, void *buf, size_t size, lldb::SBError &error); @@ -684,30 +625,28 @@ public: lldb::SBBreakpoint BreakpointCreateBySBAddress(SBAddress &address); - //------------------------------------------------------------------ /// Create a breakpoint using a scripted resolver. /// - /// @param[in] class_name + /// \param[in] class_name /// This is the name of the class that implements a scripted resolver. /// - /// @param[in] extra_args + /// \param[in] extra_args /// This is an SBStructuredData object that will get passed to the /// constructor of the class in class_name. You can use this to /// reuse the same class, parametrizing with entries from this /// dictionary. /// - /// @param module_list + /// \param module_list /// If this is non-empty, this will be used as the module filter in the /// SearchFilter created for this breakpoint. /// - /// @param file_list + /// \param file_list /// If this is non-empty, this will be used as the comp unit filter in the /// SearchFilter created for this breakpoint. /// - /// @return + /// \return /// An SBBreakpoint that will set locations based on the logic in the /// resolver's search callback. - //------------------------------------------------------------------ lldb::SBBreakpoint BreakpointCreateFromScript( const char *class_name, SBStructuredData &extra_args, @@ -715,71 +654,63 @@ public: const SBFileSpecList &file_list, bool request_hardware = false); - //------------------------------------------------------------------ /// Read breakpoints from source_file and return the newly created /// breakpoints in bkpt_list. /// - /// @param[in] source_file + /// \param[in] source_file /// The file from which to read the breakpoints. /// - /// @param[out] new_bps + /// \param[out] new_bps /// A list of the newly created breakpoints. /// - /// @return + /// \return /// An SBError detailing any errors in reading in the breakpoints. - //------------------------------------------------------------------ lldb::SBError BreakpointsCreateFromFile(SBFileSpec &source_file, SBBreakpointList &new_bps); - //------------------------------------------------------------------ /// Read breakpoints from source_file and return the newly created /// breakpoints in bkpt_list. /// - /// @param[in] source_file + /// \param[in] source_file /// The file from which to read the breakpoints. /// - /// @param[in] matching_names + /// \param[in] matching_names /// Only read in breakpoints whose names match one of the names in this /// list. /// - /// @param[out] new_bps + /// \param[out] new_bps /// A list of the newly created breakpoints. /// - /// @return + /// \return /// An SBError detailing any errors in reading in the breakpoints. - //------------------------------------------------------------------ lldb::SBError BreakpointsCreateFromFile(SBFileSpec &source_file, SBStringList &matching_names, SBBreakpointList &new_bps); - //------------------------------------------------------------------ /// Write breakpoints to dest_file. /// - /// @param[in] dest_file + /// \param[in] dest_file /// The file to which to write the breakpoints. /// - /// @return + /// \return /// An SBError detailing any errors in writing in the breakpoints. - //------------------------------------------------------------------ lldb::SBError BreakpointsWriteToFile(SBFileSpec &dest_file); - //------------------------------------------------------------------ /// Write breakpoints listed in bkpt_list to dest_file. /// - /// @param[in] dest_file + /// \param[in] dest_file /// The file to which to write the breakpoints. /// - /// @param[in] bkpt_list + /// \param[in] bkpt_list /// Only write breakpoints from this list. /// - /// @param[in] append - /// If \btrue, append the breakpoints in bkpt_list to the others + /// \param[in] append + /// If \b true, append the breakpoints in bkpt_list to the others /// serialized in dest_file. If dest_file doesn't exist, then a new /// file will be created and the breakpoints in bkpt_list written to it. /// - /// @return + /// \return /// An SBError detailing any errors in writing in the breakpoints. - //------------------------------------------------------------------ lldb::SBError BreakpointsWriteToFile(SBFileSpec &dest_file, SBBreakpointList &bkpt_list, bool append = false); @@ -905,10 +836,8 @@ protected: friend class SBValue; friend class SBVariablesOptions; - //------------------------------------------------------------------ // 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 63816eef51b7d..da8726a2a9b2d 100644 --- a/include/lldb/API/SBThread.h +++ b/include/lldb/API/SBThread.h @@ -1,9 +1,8 @@ //===-- SBThread.h ----------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -40,6 +39,8 @@ public: lldb::SBQueue GetQueue() const; + explicit operator bool() const; + bool IsValid() const; void Clear(); @@ -50,7 +51,6 @@ public: /// See also GetStopReasonDataAtIndex(). size_t GetStopReasonDataCount(); - //-------------------------------------------------------------------------- /// Get information associated with a stop reason. /// /// Breakpoint stop reasons will have data that consists of pairs of @@ -67,7 +67,6 @@ public: /// eStopReasonException N exception data /// eStopReasonExec 0 /// eStopReasonPlanComplete 0 - //-------------------------------------------------------------------------- uint64_t GetStopReasonDataAtIndex(uint32_t idx); bool GetStopReasonExtendedInfoAsJSON(lldb::SBStream &stream); @@ -133,7 +132,6 @@ public: SBError UnwindInnermostExpression(); - //-------------------------------------------------------------------------- /// LLDB currently supports process centric debugging which means when any /// thread in a process stops, all other threads are stopped. The Suspend() /// call here tells our process to suspend a thread and not let it run when @@ -153,7 +151,6 @@ public: /// Suspend() and Resume() functions are not currently reference counted, if /// anyone has the need for them to be reference counted, please let us /// know. - //-------------------------------------------------------------------------- bool Suspend(); bool Suspend(SBError &error); @@ -204,14 +201,7 @@ public: bool SafeToCallFunctions(); -#ifndef SWIG - lldb_private::Thread *operator->(); - - lldb_private::Thread *get(); - -#endif - -protected: +private: friend class SBBreakpoint; friend class SBBreakpointLocation; friend class SBBreakpointCallbackBaton; @@ -222,16 +212,18 @@ protected: friend class SBValue; friend class lldb_private::QueueImpl; friend class SBQueueItem; + friend class SBThreadPlan; void SetThread(const lldb::ThreadSP &lldb_object_sp); -#ifndef SWIG SBError ResumeNewPlan(lldb_private::ExecutionContext &exe_ctx, lldb_private::ThreadPlan *new_plan); -#endif -private: lldb::ExecutionContextRefSP m_opaque_sp; + + lldb_private::Thread *operator->(); + + lldb_private::Thread *get(); }; } // namespace lldb diff --git a/include/lldb/API/SBThreadCollection.h b/include/lldb/API/SBThreadCollection.h index 715b0826b9620..1c6b4639c6ef0 100644 --- a/include/lldb/API/SBThreadCollection.h +++ b/include/lldb/API/SBThreadCollection.h @@ -1,9 +1,8 @@ //===-- SBThreadCollection.h ------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -24,6 +23,8 @@ public: ~SBThreadCollection(); + explicit operator bool() const; + bool IsValid() const; size_t GetSize(); diff --git a/include/lldb/API/SBThreadPlan.h b/include/lldb/API/SBThreadPlan.h index 5084a427e1b8f..007e9e2de21a4 100644 --- a/include/lldb/API/SBThreadPlan.h +++ b/include/lldb/API/SBThreadPlan.h @@ -1,9 +1,8 @@ -//===-- SBThread.h ----------------------------------------------*- C++ -*-===// +//===-- SBThreadPlan.h ------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -31,6 +30,8 @@ public: ~SBThreadPlan(); + explicit operator bool() const; + bool IsValid() const; void Clear(); @@ -41,7 +42,6 @@ public: /// See also GetStopReasonDataAtIndex(). size_t GetStopReasonDataCount(); - //-------------------------------------------------------------------------- /// Get information associated with a stop reason. /// /// Breakpoint stop reasons will have data that consists of pairs of @@ -58,7 +58,6 @@ public: /// eStopReasonException N exception data /// eStopReasonExec 0 /// eStopReasonPlanComplete 0 - //-------------------------------------------------------------------------- uint64_t GetStopReasonDataAtIndex(uint32_t idx); SBThread GetThread() const; @@ -102,11 +101,7 @@ public: SBThreadPlan QueueThreadPlanForStepScripted(const char *script_class_name, SBError &error); -#ifndef SWIG - lldb_private::ThreadPlan *get(); -#endif - -protected: +private: friend class SBBreakpoint; friend class SBBreakpointLocation; friend class SBFrame; @@ -116,11 +111,9 @@ protected: friend class lldb_private::QueueImpl; friend class SBQueueItem; -#ifndef SWIG + lldb_private::ThreadPlan *get(); void SetThreadPlan(const lldb::ThreadPlanSP &lldb_object_sp); -#endif -private: lldb::ThreadPlanSP m_opaque_sp; }; diff --git a/include/lldb/API/SBTrace.h b/include/lldb/API/SBTrace.h index 244a01e5ce110..87c67adac75b6 100644 --- a/include/lldb/API/SBTrace.h +++ b/include/lldb/API/SBTrace.h @@ -1,9 +1,8 @@ //===-- SBTrace.h -----------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -20,25 +19,24 @@ namespace lldb { class LLDB_API SBTrace { public: SBTrace(); - //------------------------------------------------------------------ /// Obtain the trace data as raw bytes. /// - /// @param[out] error + /// \param[out] error /// An error explaining what went wrong. /// - /// @param[in] buf + /// \param[in] buf /// Buffer to write the trace data to. /// - /// @param[in] size + /// \param[in] size /// The size of the buffer used to read the data. This is /// also the size of the data intended to read. It is also /// possible to partially read the trace data for some trace /// technologies by specifying a smaller buffer. /// - /// @param[in] offset + /// \param[in] offset /// The start offset to begin reading the trace data. /// - /// @param[in] thread_id + /// \param[in] thread_id /// Tracing could be started for the complete process or a /// single thread, in the first case the traceid obtained would /// map to all the threads existing within the process and the @@ -46,28 +44,24 @@ public: /// such a scenario to select the trace data for a specific /// thread. /// - /// @return + /// \return /// The size of the trace data effectively read by the API call. - //------------------------------------------------------------------ size_t GetTraceData(SBError &error, void *buf, size_t size, size_t offset = 0, lldb::tid_t thread_id = LLDB_INVALID_THREAD_ID); - //------------------------------------------------------------------ /// Obtain any meta data as raw bytes for the tracing instance. /// The input parameter definition is similar to the previous /// function. - //------------------------------------------------------------------ size_t GetMetaData(SBError &error, void *buf, size_t size, size_t offset = 0, lldb::tid_t thread_id = LLDB_INVALID_THREAD_ID); - //------------------------------------------------------------------ /// Stop the tracing instance. Stopping the trace will also /// lead to deletion of any gathered trace data. /// - /// @param[out] error + /// \param[out] error /// An error explaining what went wrong. /// - /// @param[in] thread_id + /// \param[in] thread_id /// The trace id could map to a tracing instance for a thread /// or could also map to a group of threads being traced with /// the same trace options. A thread_id is normally optional @@ -81,26 +75,25 @@ public: /// trace id of the process. /// Now if the StopTrace API is called for the whole process, /// thread A will not be stopped and must be stopped separately. - //------------------------------------------------------------------ void StopTrace(SBError &error, lldb::tid_t thread_id = LLDB_INVALID_THREAD_ID); - //------------------------------------------------------------------ /// Get the trace configuration being used for the trace instance. /// The threadid in the SBTraceOptions needs to be set when the /// configuration used by a specific thread is being requested. /// - /// @param[out] options + /// \param[out] options /// The trace options actually used by the trace instance /// would be filled by the API. /// - /// @param[out] error + /// \param[out] error /// An error explaining what went wrong. - //------------------------------------------------------------------ void GetTraceConfig(SBTraceOptions &options, SBError &error); lldb::user_id_t GetTraceUID(); + explicit operator bool() const; + bool IsValid(); protected: diff --git a/include/lldb/API/SBTraceOptions.h b/include/lldb/API/SBTraceOptions.h index c9735e1ca2467..4c586bfd55c47 100644 --- a/include/lldb/API/SBTraceOptions.h +++ b/include/lldb/API/SBTraceOptions.h @@ -1,9 +1,8 @@ //===-- SBTraceOptions ------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -45,6 +44,8 @@ public: lldb::tid_t getThreadID(); + explicit operator bool() const; + bool IsValid(); protected: diff --git a/include/lldb/API/SBType.h b/include/lldb/API/SBType.h index 0dde0257909fc..b3f92b7bcd042 100644 --- a/include/lldb/API/SBType.h +++ b/include/lldb/API/SBType.h @@ -1,9 +1,8 @@ //===-- SBType.h ------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -26,6 +25,8 @@ public: lldb::SBTypeMember &operator=(const lldb::SBTypeMember &rhs); + explicit operator bool() const; + bool IsValid() const; const char *GetName(); @@ -52,7 +53,7 @@ protected: const lldb_private::TypeMemberImpl &ref() const; - std::unique_ptr<lldb_private::TypeMemberImpl> m_opaque_ap; + std::unique_ptr<lldb_private::TypeMemberImpl> m_opaque_up; }; class SBTypeMemberFunction { @@ -65,6 +66,8 @@ public: lldb::SBTypeMemberFunction &operator=(const lldb::SBTypeMemberFunction &rhs); + explicit operator bool() const; + bool IsValid() const; const char *GetName(); @@ -106,6 +109,8 @@ public: ~SBType(); + explicit operator bool() const; + bool IsValid() const; uint64_t GetByteSize(); @@ -236,6 +241,8 @@ public: lldb::SBTypeList &operator=(const lldb::SBTypeList &rhs); + explicit operator bool() const; + bool IsValid(); void Append(lldb::SBType type); @@ -245,7 +252,7 @@ public: uint32_t GetSize(); private: - std::unique_ptr<lldb_private::TypeListImpl> m_opaque_ap; + std::unique_ptr<lldb_private::TypeListImpl> m_opaque_up; friend class SBModule; friend class SBCompileUnit; }; diff --git a/include/lldb/API/SBTypeCategory.h b/include/lldb/API/SBTypeCategory.h index f44dfc451e44d..c0f4cee1d268f 100644 --- a/include/lldb/API/SBTypeCategory.h +++ b/include/lldb/API/SBTypeCategory.h @@ -1,10 +1,9 @@ //===-- SBTypeCategory.h --------------------------------------------*- C++ //-*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -23,6 +22,8 @@ public: ~SBTypeCategory(); + explicit operator bool() const; + bool IsValid() const; bool GetEnabled(); @@ -46,9 +47,7 @@ public: uint32_t GetNumFilters(); -#ifndef LLDB_DISABLE_PYTHON uint32_t GetNumSynthetics(); -#endif SBTypeNameSpecifier GetTypeNameSpecifierForFilterAtIndex(uint32_t); @@ -56,43 +55,29 @@ public: SBTypeNameSpecifier GetTypeNameSpecifierForSummaryAtIndex(uint32_t); -#ifndef LLDB_DISABLE_PYTHON SBTypeNameSpecifier GetTypeNameSpecifierForSyntheticAtIndex(uint32_t); -#endif SBTypeFilter GetFilterForType(SBTypeNameSpecifier); SBTypeFormat GetFormatForType(SBTypeNameSpecifier); -#ifndef LLDB_DISABLE_PYTHON SBTypeSummary GetSummaryForType(SBTypeNameSpecifier); -#endif -#ifndef LLDB_DISABLE_PYTHON SBTypeSynthetic GetSyntheticForType(SBTypeNameSpecifier); -#endif -#ifndef LLDB_DISABLE_PYTHON SBTypeFilter GetFilterAtIndex(uint32_t); -#endif SBTypeFormat GetFormatAtIndex(uint32_t); -#ifndef LLDB_DISABLE_PYTHON SBTypeSummary GetSummaryAtIndex(uint32_t); -#endif -#ifndef LLDB_DISABLE_PYTHON SBTypeSynthetic GetSyntheticAtIndex(uint32_t); -#endif bool AddTypeFormat(SBTypeNameSpecifier, SBTypeFormat); bool DeleteTypeFormat(SBTypeNameSpecifier); -#ifndef LLDB_DISABLE_PYTHON bool AddTypeSummary(SBTypeNameSpecifier, SBTypeSummary); -#endif bool DeleteTypeSummary(SBTypeNameSpecifier); @@ -100,11 +85,9 @@ public: bool DeleteTypeFilter(SBTypeNameSpecifier); -#ifndef LLDB_DISABLE_PYTHON bool AddTypeSynthetic(SBTypeNameSpecifier, SBTypeSynthetic); bool DeleteTypeSynthetic(SBTypeNameSpecifier); -#endif lldb::SBTypeCategory &operator=(const lldb::SBTypeCategory &rhs); diff --git a/include/lldb/API/SBTypeEnumMember.h b/include/lldb/API/SBTypeEnumMember.h index f45c234d2c777..2410dbcc21255 100644 --- a/include/lldb/API/SBTypeEnumMember.h +++ b/include/lldb/API/SBTypeEnumMember.h @@ -1,10 +1,9 @@ //===-- SBTypeEnumMember.h --------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -25,6 +24,8 @@ public: SBTypeEnumMember &operator=(const SBTypeEnumMember &rhs); + explicit operator bool() const; + bool IsValid() const; int64_t GetValueAsSigned(); @@ -63,6 +64,8 @@ public: SBTypeEnumMemberList &operator=(const SBTypeEnumMemberList &rhs); + explicit operator bool() const; + bool IsValid(); void Append(SBTypeEnumMember entry); @@ -72,7 +75,7 @@ public: uint32_t GetSize(); private: - std::unique_ptr<lldb_private::TypeEnumMemberListImpl> m_opaque_ap; + std::unique_ptr<lldb_private::TypeEnumMemberListImpl> m_opaque_up; }; } // namespace lldb diff --git a/include/lldb/API/SBTypeFilter.h b/include/lldb/API/SBTypeFilter.h index 19888ba7cfb69..4a0de11d19c43 100644 --- a/include/lldb/API/SBTypeFilter.h +++ b/include/lldb/API/SBTypeFilter.h @@ -1,10 +1,9 @@ //===-- SBTypeFilter.h --------------------------------------------*- C++ //-*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -25,6 +24,8 @@ public: ~SBTypeFilter(); + explicit operator bool() const; + bool IsValid() const; uint32_t GetNumberOfExpressionPaths(); diff --git a/include/lldb/API/SBTypeFormat.h b/include/lldb/API/SBTypeFormat.h index d0429e97ff9c3..8a0ac77a1e9d0 100644 --- a/include/lldb/API/SBTypeFormat.h +++ b/include/lldb/API/SBTypeFormat.h @@ -1,10 +1,9 @@ //===-- SBTypeFormat.h --------------------------------------------*- C++ //-*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -29,6 +28,8 @@ public: ~SBTypeFormat(); + explicit operator bool() const; + bool IsValid() const; lldb::Format GetFormat(); diff --git a/include/lldb/API/SBTypeNameSpecifier.h b/include/lldb/API/SBTypeNameSpecifier.h index 2a4f09c2068b3..9fe449d029c6a 100644 --- a/include/lldb/API/SBTypeNameSpecifier.h +++ b/include/lldb/API/SBTypeNameSpecifier.h @@ -1,10 +1,9 @@ //===-- SBTypeNameSpecifier.h --------------------------------------*- C++ //-*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -27,6 +26,8 @@ public: ~SBTypeNameSpecifier(); + explicit operator bool() const; + bool IsValid() const; const char *GetName(); diff --git a/include/lldb/API/SBTypeSummary.h b/include/lldb/API/SBTypeSummary.h index c9ccdff834ce9..bb7121f8ae40b 100644 --- a/include/lldb/API/SBTypeSummary.h +++ b/include/lldb/API/SBTypeSummary.h @@ -1,10 +1,9 @@ //===-- SBTypeSummary.h -------------------------------------------*- C++ //-*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -24,6 +23,8 @@ public: ~SBTypeSummaryOptions(); + explicit operator bool() const; + bool IsValid(); lldb::LanguageType GetLanguage(); @@ -50,7 +51,7 @@ protected: void SetOptions(const lldb_private::TypeSummaryOptions *lldb_object_ptr); private: - std::unique_ptr<lldb_private::TypeSummaryOptions> m_opaque_ap; + std::unique_ptr<lldb_private::TypeSummaryOptions> m_opaque_up; }; class SBTypeSummary { @@ -80,6 +81,8 @@ public: ~SBTypeSummary(); + explicit operator bool() const; + bool IsValid() const; bool IsFunctionCode(); diff --git a/include/lldb/API/SBTypeSynthetic.h b/include/lldb/API/SBTypeSynthetic.h index 2099df3161949..c190643c1ebba 100644 --- a/include/lldb/API/SBTypeSynthetic.h +++ b/include/lldb/API/SBTypeSynthetic.h @@ -1,10 +1,9 @@ //===-- SBTypeSynthetic.h -----------------------------------------*- C++ //-*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -13,8 +12,6 @@ #include "lldb/API/SBDefines.h" -#ifndef LLDB_DISABLE_PYTHON - namespace lldb { class LLDB_API SBTypeSynthetic { @@ -33,6 +30,8 @@ public: ~SBTypeSynthetic(); + explicit operator bool() const; + bool IsValid() const; bool IsClassCode(); @@ -78,6 +77,4 @@ protected: } // namespace lldb -#endif // LLDB_DISABLE_PYTHON - #endif // LLDB_SBTypeSynthetic_h_ diff --git a/include/lldb/API/SBUnixSignals.h b/include/lldb/API/SBUnixSignals.h index d44a508fbb425..c7e99d1f63d18 100644 --- a/include/lldb/API/SBUnixSignals.h +++ b/include/lldb/API/SBUnixSignals.h @@ -1,10 +1,9 @@ //===-- SBUnixSignals.h -----------------------------------------------*- C++ //-*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -27,6 +26,8 @@ public: void Clear(); + explicit operator bool() const; + bool IsValid() const; const char *GetSignalAsCString(int32_t signo) const; diff --git a/include/lldb/API/SBValue.h b/include/lldb/API/SBValue.h index ab5bdfea993dd..c36ba20297f04 100644 --- a/include/lldb/API/SBValue.h +++ b/include/lldb/API/SBValue.h @@ -1,9 +1,8 @@ //===-- SBValue.h -----------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -29,6 +28,8 @@ public: ~SBValue(); + explicit operator bool() const; + bool IsValid(); void Clear(); @@ -111,9 +112,7 @@ public: lldb::SBTypeFilter GetTypeFilter(); -#ifndef LLDB_DISABLE_PYTHON lldb::SBTypeSynthetic GetTypeSynthetic(); -#endif lldb::SBValue GetChildAtIndex(uint32_t idx); @@ -138,7 +137,6 @@ public: lldb::SBValue CreateValueFromData(const char *name, lldb::SBData data, lldb::SBType type); - //------------------------------------------------------------------ /// Get a child value by index from a value. /// /// Structs, unions, classes, arrays and pointers have child @@ -176,22 +174,21 @@ public: /// that aren't in the array bounds using positive or negative /// indexes. /// - /// @param[in] idx + /// \param[in] idx /// The index of the child value to get /// - /// @param[in] use_dynamic + /// \param[in] use_dynamic /// An enumeration that specifies whether to get dynamic values, /// and also if the target can be run to figure out the dynamic /// type of the child value. /// - /// @param[in] can_create_synthetic + /// \param[in] can_create_synthetic /// If \b true, then allow child values to be created by index /// for pointers and arrays for indexes that normally wouldn't /// be allowed. /// - /// @return + /// \return /// A new SBValue object that represents the child member value. - //------------------------------------------------------------------ lldb::SBValue GetChildAtIndex(uint32_t idx, lldb::DynamicValueType use_dynamic, bool can_create_synthetic); @@ -218,46 +215,41 @@ public: lldb::SBAddress GetAddress(); - //------------------------------------------------------------------ /// Get an SBData wrapping what this SBValue points to. /// /// This method will dereference the current SBValue, if its /// data type is a T* or T[], and extract item_count elements /// of type T from it, copying their contents in an SBData. /// - /// @param[in] item_idx + /// \param[in] item_idx /// The index of the first item to retrieve. For an array /// this is equivalent to array[item_idx], for a pointer /// to *(pointer + item_idx). In either case, the measurement /// unit for item_idx is the sizeof(T) rather than the byte /// - /// @param[in] item_count + /// \param[in] item_count /// How many items should be copied into the output. By default /// only one item is copied, but more can be asked for. /// - /// @return + /// \return /// An SBData with the contents of the copied items, on success. /// An empty SBData otherwise. - //------------------------------------------------------------------ lldb::SBData GetPointeeData(uint32_t item_idx = 0, uint32_t item_count = 1); - //------------------------------------------------------------------ /// Get an SBData wrapping the contents of this SBValue. /// /// This method will read the contents of this object in memory /// and copy them into an SBData for future use. /// - /// @return + /// \return /// An SBData with the contents of this SBValue, on success. /// An empty SBData otherwise. - //------------------------------------------------------------------ lldb::SBData GetData(); bool SetData(lldb::SBData &data, lldb::SBError &error); lldb::SBDeclaration GetDeclaration(); - //------------------------------------------------------------------ /// Find out if a SBValue might have children. /// /// This call is much more efficient than GetNumChildren() as it @@ -269,10 +261,9 @@ public: /// pointers, references, arrays and more. Again, it does so without /// doing any expensive type completion. /// - /// @return + /// \return /// Returns \b true if the SBValue might have children, or \b /// false otherwise. - //------------------------------------------------------------------ bool MightHaveChildren(); bool IsRuntimeSupportValue(); @@ -307,70 +298,72 @@ public: bool GetExpressionPath(lldb::SBStream &description, bool qualify_cxx_base_classes); + lldb::SBValue EvaluateExpression(const char *expr) const; + lldb::SBValue EvaluateExpression(const char *expr, + const SBExpressionOptions &options) const; + lldb::SBValue EvaluateExpression(const char *expr, + const SBExpressionOptions &options, + const char *name) const; + SBValue(const lldb::ValueObjectSP &value_sp); - //------------------------------------------------------------------ /// Watch this value if it resides in memory. /// /// Sets a watchpoint on the value. /// - /// @param[in] resolve_location + /// \param[in] resolve_location /// Resolve the location of this value once and watch its address. /// This value must currently be set to \b true as watching all /// locations of a variable or a variable path is not yet supported, /// though we plan to support it in the future. /// - /// @param[in] read + /// \param[in] read /// Stop when this value is accessed. /// - /// @param[in] write + /// \param[in] write /// Stop when this value is modified /// - /// @param[out] error + /// \param[out] error /// An error object. Contains the reason if there is some failure. /// - /// @return + /// \return /// An SBWatchpoint object. This object might not be valid upon /// return due to a value not being contained in memory, too /// large, or watchpoint resources are not available or all in /// use. - //------------------------------------------------------------------ lldb::SBWatchpoint Watch(bool resolve_location, bool read, bool write, SBError &error); // Backward compatibility fix in the interim. lldb::SBWatchpoint Watch(bool resolve_location, bool read, bool write); - //------------------------------------------------------------------ /// Watch this value that this value points to in memory /// /// Sets a watchpoint on the value. /// - /// @param[in] resolve_location + /// \param[in] resolve_location /// Resolve the location of this value once and watch its address. /// This value must currently be set to \b true as watching all /// locations of a variable or a variable path is not yet supported, /// though we plan to support it in the future. /// - /// @param[in] read + /// \param[in] read /// Stop when this value is accessed. /// - /// @param[in] write + /// \param[in] write /// Stop when this value is modified /// - /// @param[out] error + /// \param[out] error /// An error object. Contains the reason if there is some failure. /// - /// @return + /// \return /// An SBWatchpoint object. This object might not be valid upon /// return due to a value not being contained in memory, too /// large, or watchpoint resources are not available or all in /// use. - //------------------------------------------------------------------ lldb::SBWatchpoint WatchPointee(bool resolve_location, bool read, bool write, SBError &error); - //------------------------------------------------------------------ /// Same as the protected version of GetSP that takes a locker, except that we /// make the /// locker locally in the function. Since the Target API mutex is recursive, @@ -379,10 +372,9 @@ public: /// already /// holding the two above-mentioned locks. /// - /// @return + /// \return /// A ValueObjectSP of the best kind (static, dynamic or synthetic) we /// can cons up, in accordance with the SBValue's settings. - //------------------------------------------------------------------ lldb::ValueObjectSP GetSP() const; protected: @@ -392,7 +384,6 @@ protected: friend class SBThread; friend class SBValueList; - //------------------------------------------------------------------ /// Get the appropriate ValueObjectSP from this SBValue, consulting the /// use_dynamic and use_synthetic options passed in to SetSP when the /// SBValue's contents were set. Since this often requires examining memory, @@ -407,16 +398,15 @@ protected: /// ValueObject.h/cpp or somewhere else convenient. We haven't needed to so /// far. /// - /// @param[in] value_locker + /// \param[in] value_locker /// An object that will hold the Target API, and Process RunLocks, and /// auto-destroy them when it goes out of scope. Currently this is only /// useful in /// SBValue.cpp. /// - /// @return + /// \return /// A ValueObjectSP of the best kind (static, dynamic or synthetic) we /// can cons up, in accordance with the SBValue's settings. - //------------------------------------------------------------------ lldb::ValueObjectSP GetSP(ValueLocker &value_locker) const; // these calls do the right thing WRT adjusting their settings according to diff --git a/include/lldb/API/SBValueList.h b/include/lldb/API/SBValueList.h index 0242dd7f71a27..d305b3564c2bf 100644 --- a/include/lldb/API/SBValueList.h +++ b/include/lldb/API/SBValueList.h @@ -1,9 +1,8 @@ //===-- SBValueList.h -------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -24,6 +23,8 @@ public: ~SBValueList(); + explicit operator bool() const; + bool IsValid() const; void Clear(); @@ -66,7 +67,7 @@ private: ValueListImpl &ref(); - std::unique_ptr<ValueListImpl> m_opaque_ap; + std::unique_ptr<ValueListImpl> m_opaque_up; }; } // namespace lldb diff --git a/include/lldb/API/SBVariablesOptions.h b/include/lldb/API/SBVariablesOptions.h index 0059a41129c50..e226ce4ae13b6 100644 --- a/include/lldb/API/SBVariablesOptions.h +++ b/include/lldb/API/SBVariablesOptions.h @@ -1,10 +1,9 @@ //===-- SBVariablesOptions.h ------------------------------------------*- C++ //-*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -27,6 +26,8 @@ public: ~SBVariablesOptions(); + explicit operator bool() const; + bool IsValid() const; bool GetIncludeArguments() const; @@ -73,7 +74,7 @@ protected: void SetOptions(VariablesOptionsImpl *lldb_object_ptr); private: - std::unique_ptr<VariablesOptionsImpl> m_opaque_ap; + std::unique_ptr<VariablesOptionsImpl> m_opaque_up; }; } // namespace lldb diff --git a/include/lldb/API/SBWatchpoint.h b/include/lldb/API/SBWatchpoint.h index 92d4851fc14d6..05ff0ca7e443e 100644 --- a/include/lldb/API/SBWatchpoint.h +++ b/include/lldb/API/SBWatchpoint.h @@ -1,9 +1,8 @@ //===-- SBWatchpoint.h ----------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -26,6 +25,12 @@ public: const lldb::SBWatchpoint &operator=(const lldb::SBWatchpoint &rhs); + explicit operator bool() const; + + bool operator==(const SBWatchpoint &rhs) const; + + bool operator!=(const SBWatchpoint &rhs) const; + bool IsValid() const; SBError GetError(); diff --git a/include/lldb/Breakpoint/Breakpoint.h b/include/lldb/Breakpoint/Breakpoint.h index 5861a3be36e1c..f561b6d900a19 100644 --- a/include/lldb/Breakpoint/Breakpoint.h +++ b/include/lldb/Breakpoint/Breakpoint.h @@ -1,9 +1,8 @@ //===-- Breakpoint.h --------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -28,12 +27,9 @@ namespace lldb_private { -//---------------------------------------------------------------------- -/// @class Breakpoint Breakpoint.h "lldb/Breakpoint/Breakpoint.h" Class that +/// \class Breakpoint Breakpoint.h "lldb/Breakpoint/Breakpoint.h" Class that /// manages logical breakpoint setting. -//---------------------------------------------------------------------- -//---------------------------------------------------------------------- /// General Outline: /// A breakpoint has four main parts, a filter, a resolver, the list of /// breakpoint @@ -79,17 +75,14 @@ namespace lldb_private { /// 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 { public: - static const ConstString &GetEventIdentifier(); + static ConstString GetEventIdentifier(); - //------------------------------------------------------------------ /// An enum specifying the match style for breakpoint settings. At present /// only used for function name style breakpoints. - //------------------------------------------------------------------ - typedef enum { Exact, Regexp, Glob } MatchType; + enum MatchType { Exact, Regexp, Glob }; private: enum class OptionNames : uint32_t { Names = 0, Hardware, LastOptionName }; @@ -109,9 +102,9 @@ public: ~BreakpointEventData() override; - static const ConstString &GetFlavorString(); + static ConstString GetFlavorString(); - const ConstString &GetFlavor() const override; + ConstString GetFlavor() const override; lldb::BreakpointEventType GetBreakpointEventType() const; @@ -147,19 +140,6 @@ public: DISALLOW_COPY_AND_ASSIGN(BreakpointEventData); }; - class BreakpointPrecondition { - public: - virtual ~BreakpointPrecondition() = default; - - virtual bool EvaluatePrecondition(StoppointCallbackContext &context); - - virtual Status ConfigurePrecondition(Args &options); - - virtual void GetDescription(Stream &stream, lldb::DescriptionLevel level); - }; - - typedef std::shared_ptr<BreakpointPrecondition> BreakpointPreconditionSP; - // Saving & restoring breakpoints: static lldb::BreakpointSP CreateFromStructuredData( Target &target, StructuredData::ObjectSP &data_object_sp, Status &error); @@ -171,173 +151,138 @@ public: virtual StructuredData::ObjectSP SerializeToStructuredData(); static const char *GetSerializationKey() { return "Breakpoint"; } - //------------------------------------------------------------------ /// 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. - //------------------------------------------------------------------ ~Breakpoint() override; - //------------------------------------------------------------------ // Methods - //------------------------------------------------------------------ - //------------------------------------------------------------------ - /// 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; - //------------------------------------------------------------------ /// Standard "Dump" method. At present it does nothing. - //------------------------------------------------------------------ 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. - //------------------------------------------------------------------ - //------------------------------------------------------------------ /// Tell this breakpoint to clear all its breakpoint sites. Done when the /// process holding the breakpoint sites is destroyed. - //------------------------------------------------------------------ void ClearAllBreakpointSites(); - //------------------------------------------------------------------ /// Tell this breakpoint to scan it's target's module list and resolve any /// new locations that match the breakpoint's specifications. - //------------------------------------------------------------------ void ResolveBreakpoint(); - //------------------------------------------------------------------ /// Tell this breakpoint to scan a given module list and resolve any new /// locations that match the breakpoint's specifications. /// - /// @param[in] module_list + /// \param[in] module_list /// The list of modules to look in for new locations. /// - /// @param[in] send_event + /// \param[in] send_event /// If \b true, send a breakpoint location added event for non-internal /// breakpoints. - //------------------------------------------------------------------ void ResolveBreakpointInModules(ModuleList &module_list, bool send_event = true); - //------------------------------------------------------------------ /// Tell this breakpoint to scan a given module list and resolve any new /// locations that match the breakpoint's specifications. /// - /// @param[in] changed_modules + /// \param[in] changed_modules /// The list of modules to look in for new locations. /// - /// @param[in] new_locations + /// \param[in] new_locations /// Fills new_locations with the new locations that were made. - //------------------------------------------------------------------ void ResolveBreakpointInModules(ModuleList &module_list, BreakpointLocationCollection &new_locations); - //------------------------------------------------------------------ /// Like ResolveBreakpointInModules, but allows for "unload" events, in /// which case we will remove any locations that are in modules that got /// unloaded. /// - /// @param[in] changedModules + /// \param[in] changedModules /// The list of modules to look in for new locations. - /// @param[in] load_event + /// \param[in] load_event /// If \b true then the modules were loaded, if \b false, unloaded. - /// @param[in] delete_locations + /// \param[in] delete_locations /// If \b true then the modules were unloaded delete any locations in the /// changed modules. - //------------------------------------------------------------------ void ModulesChanged(ModuleList &changed_modules, bool load_event, 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.) /// - /// @param[in] old_module_sp + /// \param[in] old_module_sp /// The old module that is going away. - /// @param[in] new_module_sp + /// \param[in] new_module_sp /// The new module that is replacing it. - //------------------------------------------------------------------ void ModuleReplaced(lldb::ModuleSP old_module_sp, lldb::ModuleSP new_module_sp); - //------------------------------------------------------------------ // 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? /// - /// @param[in] addr + /// \param[in] addr /// The Address specifying the new location. - /// @param[out] new_location + /// \param[out] new_location /// Set to \b true if a new location was created, to \b false if there /// already was a location at this Address. - /// @return + /// \return /// Returns a pointer to the new location. - //------------------------------------------------------------------ lldb::BreakpointLocationSP AddLocation(const Address &addr, bool *new_location = nullptr); - //------------------------------------------------------------------ /// Find a breakpoint location by Address. /// - /// @param[in] addr + /// \param[in] addr /// The Address specifying the location. - /// @return + /// \return /// Returns a shared pointer to the location at \a addr. The pointer /// in the shared pointer will be nullptr if there is no location at that /// address. - //------------------------------------------------------------------ lldb::BreakpointLocationSP FindLocationByAddress(const Address &addr); - //------------------------------------------------------------------ /// Find a breakpoint location ID by Address. /// - /// @param[in] addr + /// \param[in] addr /// The Address specifying the location. - /// @return + /// \return /// Returns the UID of the location at \a addr, or \b LLDB_INVALID_ID if /// there is no breakpoint location at that address. - //------------------------------------------------------------------ lldb::break_id_t FindLocationIDByAddress(const Address &addr); - //------------------------------------------------------------------ /// Find a breakpoint location for a given breakpoint location ID. /// - /// @param[in] bp_loc_id + /// \param[in] bp_loc_id /// The ID specifying the location. - /// @return + /// \return /// Returns a shared pointer to the location with ID \a bp_loc_id. The /// pointer /// in the shared pointer will be nullptr if there is no location with that /// ID. - //------------------------------------------------------------------ lldb::BreakpointLocationSP FindLocationByID(lldb::break_id_t bp_loc_id); - //------------------------------------------------------------------ /// Get breakpoint locations by index. /// - /// @param[in] index + /// \param[in] index /// The location index. /// - /// @return + /// \return /// Returns a shared pointer to the location with index \a /// index. The shared pointer might contain nullptr if \a index is /// greater than then number of actual locations. - //------------------------------------------------------------------ lldb::BreakpointLocationSP GetLocationAtIndex(size_t index); - //------------------------------------------------------------------ /// Removes all invalid breakpoint locations. /// /// Removes all breakpoint locations with architectures that aren't @@ -348,86 +293,61 @@ public: /// This is typically used after the process calls exec, or anytime the /// architecture of the target changes. /// - /// @param[in] arch + /// \param[in] arch /// If valid, check the module in each breakpoint to make sure /// they are compatible, otherwise, ignore architecture. - //------------------------------------------------------------------ void RemoveInvalidLocations(const ArchSpec &arch); - //------------------------------------------------------------------ // The next section deals with various breakpoint options. - //------------------------------------------------------------------ - //------------------------------------------------------------------ /// If \a enable is \b true, enable the breakpoint, if \b false disable it. - //------------------------------------------------------------------ void SetEnabled(bool enable) override; - //------------------------------------------------------------------ /// Check the Enable/Disable state. - /// @return + /// \return /// \b true if the breakpoint is enabled, \b false if disabled. - //------------------------------------------------------------------ bool IsEnabled() override; - //------------------------------------------------------------------ /// Set the breakpoint to ignore the next \a count breakpoint hits. - /// @param[in] count + /// \param[in] count /// The number of breakpoint hits to ignore. - //------------------------------------------------------------------ void SetIgnoreCount(uint32_t count); - //------------------------------------------------------------------ /// Return the current ignore count/ - /// @return + /// \return /// The number of breakpoint hits to be ignored. - //------------------------------------------------------------------ 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; - //------------------------------------------------------------------ /// If \a one_shot is \b true, breakpoint will be deleted on first hit. - //------------------------------------------------------------------ void SetOneShot(bool one_shot); - //------------------------------------------------------------------ /// Check the OneShot state. - /// @return + /// \return /// \b true if the breakpoint is one shot, \b false otherwise. - //------------------------------------------------------------------ bool IsOneShot() const; - //------------------------------------------------------------------ /// If \a auto_continue is \b true, breakpoint will auto-continue when on /// hit. - //------------------------------------------------------------------ void SetAutoContinue(bool auto_continue); - //------------------------------------------------------------------ /// Check the AutoContinue state. - /// @return + /// \return /// \b true if the breakpoint is set to auto-continue, \b false otherwise. - //------------------------------------------------------------------ bool IsAutoContinue() const; - //------------------------------------------------------------------ /// Set the valid thread to be checked when the breakpoint is hit. - /// @param[in] thread_id + /// \param[in] thread_id /// If this thread hits the breakpoint, we stop, otherwise not. - //------------------------------------------------------------------ void SetThreadID(lldb::tid_t thread_id); - //------------------------------------------------------------------ /// Return the current stop thread value. - /// @return + /// \return /// The thread id for which the breakpoint hit will stop, /// LLDB_INVALID_THREAD_ID for all threads. - //------------------------------------------------------------------ lldb::tid_t GetThreadID() const; void SetThreadIndex(uint32_t index); @@ -442,22 +362,20 @@ public: const char *GetQueueName() const; - //------------------------------------------------------------------ /// Set the callback action invoked when the breakpoint is hit. /// - /// @param[in] callback + /// \param[in] callback /// The method that will get called when the breakpoint is hit. - /// @param[in] baton + /// \param[in] baton /// A void * pointer that will get passed back to the callback function. - /// @param[in] is_synchronous + /// \param[in] is_synchronous /// If \b true the callback will be run on the private event thread /// before the stop event gets reported. If false, the callback will get /// handled on the public event thread after the stop has been posted. /// - /// @return + /// \return /// \b true if the process should stop when you hit the breakpoint. /// \b false if it should continue. - //------------------------------------------------------------------ void SetCallback(BreakpointHitCallback callback, void *baton, bool is_synchronous = false); @@ -467,92 +385,72 @@ public: void ClearCallback(); - //------------------------------------------------------------------ /// Set the breakpoint's condition. /// - /// @param[in] condition + /// \param[in] condition /// The condition expression to evaluate when the breakpoint is hit. /// Pass in nullptr to clear the condition. - //------------------------------------------------------------------ void SetCondition(const char *condition); - //------------------------------------------------------------------ /// Return a pointer to the text of the condition expression. /// - /// @return + /// \return /// A pointer to the condition expression text, or nullptr if no // condition has been set. - //------------------------------------------------------------------ const char *GetConditionText() const; - //------------------------------------------------------------------ // The next section are various utility functions. - //------------------------------------------------------------------ - //------------------------------------------------------------------ /// Return the number of breakpoint locations that have resolved to actual /// breakpoint sites. /// - /// @return + /// \return /// The number locations resolved breakpoint sites. - //------------------------------------------------------------------ size_t GetNumResolvedLocations() const; - //------------------------------------------------------------------ /// Return whether this breakpoint has any resolved locations. /// - /// @return + /// \return /// True if GetNumResolvedLocations > 0 - //------------------------------------------------------------------ bool HasResolvedLocations() const; - //------------------------------------------------------------------ /// Return the number of breakpoint locations. /// - /// @return + /// \return /// The number breakpoint locations. - //------------------------------------------------------------------ size_t GetNumLocations() const; - //------------------------------------------------------------------ /// Put a description of this breakpoint into the stream \a s. /// - /// @param[in] s + /// \param[in] s /// Stream into which to dump the description. /// - /// @param[in] level + /// \param[in] level /// The description level that indicates the detail level to /// provide. /// - /// @see lldb::DescriptionLevel - //------------------------------------------------------------------ + /// \see lldb::DescriptionLevel void GetDescription(Stream *s, lldb::DescriptionLevel level, bool show_locations = false); - //------------------------------------------------------------------ /// 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. /// - /// @param[in] kind + /// \param[in] kind /// New "kind" description. - //------------------------------------------------------------------ void SetBreakpointKind(const char *kind) { m_kind_description.assign(kind); } - //------------------------------------------------------------------ /// Return the "kind" description for a breakpoint. /// - /// @return + /// \return /// The breakpoint kind, or nullptr if none is set. - //------------------------------------------------------------------ const char *GetBreakpointKind() const { return m_kind_description.c_str(); } - //------------------------------------------------------------------ /// Accessor for the breakpoint Target. - /// @return + /// \return /// This breakpoint's Target. - //------------------------------------------------------------------ Target &GetTarget() { return m_target; } const Target &GetTarget() const { return m_target; } @@ -561,13 +459,12 @@ public: void GetResolverDescription(Stream *s); - //------------------------------------------------------------------ /// 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. /// - /// @return + /// \return /// True if there is a match /// /// The locations which match the filename and line_number in loc_coll. @@ -575,46 +472,39 @@ public: /// size is 0 and true is returned, it means the breakpoint fully matches /// the /// description. - //------------------------------------------------------------------ - bool GetMatchingFileLine(const ConstString &filename, uint32_t line_number, + bool GetMatchingFileLine(ConstString filename, uint32_t line_number, BreakpointLocationCollection &loc_coll); void GetFilterDescription(Stream *s); - //------------------------------------------------------------------ /// Returns the BreakpointOptions structure set at the breakpoint level. /// /// Meant to be used by the BreakpointLocation class. /// - /// @return + /// \return /// A pointer to this breakpoint's BreakpointOptions. - //------------------------------------------------------------------ BreakpointOptions *GetOptions(); - //------------------------------------------------------------------ /// Returns the BreakpointOptions structure set at the breakpoint level. /// /// Meant to be used by the BreakpointLocation class. /// - /// @return + /// \return /// A pointer to this breakpoint's BreakpointOptions. - //------------------------------------------------------------------ const BreakpointOptions *GetOptions() const; - //------------------------------------------------------------------ /// Invoke the callback action when the breakpoint is hit. /// /// Meant to be used by the BreakpointLocation class. /// - /// @param[in] context + /// \param[in] context /// Described the breakpoint event. /// - /// @param[in] bp_loc_id + /// \param[in] bp_loc_id /// Which breakpoint location hit this breakpoint. /// - /// @return + /// \return /// \b true if the target should stop at this breakpoint and \b false not. - //------------------------------------------------------------------ bool InvokeCallback(StoppointCallbackContext *context, lldb::break_id_t bp_loc_id); @@ -645,7 +535,6 @@ public: } } - //------------------------------------------------------------------ /// Set a pre-condition filter that overrides all user provided /// filters/callbacks etc. /// @@ -656,15 +545,14 @@ public: /// 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) { + void SetPrecondition(lldb::BreakpointPreconditionSP precondition_sp) { m_precondition_sp = precondition_sp; } bool EvaluatePrecondition(StoppointCallbackContext &context); - BreakpointPreconditionSP GetPrecondition() { return m_precondition_sp; } - + lldb::BreakpointPreconditionSP GetPrecondition() { return m_precondition_sp; } + // Produces the OR'ed values for all the names assigned to this breakpoint. const BreakpointName::Permissions &GetPermissions() const { return m_permissions; @@ -686,39 +574,35 @@ public: protected: friend class Target; - //------------------------------------------------------------------ // Protected Methods - //------------------------------------------------------------------ - //------------------------------------------------------------------ /// 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. /// - /// @param[in] target + /// \param[in] target /// The target in which the breakpoint will be set. /// - /// @param[in] filter_sp + /// \param[in] filter_sp /// Shared pointer to the search filter that restricts the search domain of /// the breakpoint. /// - /// @param[in] resolver_sp + /// \param[in] resolver_sp /// Shared pointer to the resolver object that will determine breakpoint /// matches. /// - /// @param hardware + /// \param hardware /// If true, request a hardware breakpoint to be used to implement the /// breakpoint locations. /// - /// @param resolve_indirect_symbols + /// \param resolve_indirect_symbols /// If true, and the address of a given breakpoint location in this /// breakpoint is set on an /// indirect symbol (i.e. Symbol::IsIndirect returns true) then the actual /// breakpoint site will /// be set on the target of the indirect symbol. - //------------------------------------------------------------------ // This is the generic constructor Breakpoint(Target &target, lldb::SearchFilterSP &filter_sp, lldb::BreakpointResolverSP &resolver_sp, bool hardware, @@ -749,9 +633,7 @@ private: // target - primarily from the dummy target to prime new targets. Breakpoint(Target &new_target, Breakpoint &bp_to_copy_from); - //------------------------------------------------------------------ // For Breakpoint only - //------------------------------------------------------------------ bool m_being_created; bool m_hardware; // If this breakpoint is required to use a hardware breakpoint @@ -764,9 +646,9 @@ private: m_filter_sp; // The filter that constrains the breakpoint's domain. lldb::BreakpointResolverSP m_resolver_sp; // The resolver that defines this breakpoint. - BreakpointPreconditionSP m_precondition_sp; // The precondition is a - // breakpoint-level hit filter - // that can be used + lldb::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. diff --git a/include/lldb/Breakpoint/BreakpointID.h b/include/lldb/Breakpoint/BreakpointID.h index 5acb942ed2adb..095132988eb22 100644 --- a/include/lldb/Breakpoint/BreakpointID.h +++ b/include/lldb/Breakpoint/BreakpointID.h @@ -1,9 +1,8 @@ //===-- BreakpointID.h ------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -19,9 +18,7 @@ namespace lldb_private { -//---------------------------------------------------------------------- // class BreakpointID -//---------------------------------------------------------------------- class BreakpointID { public: @@ -51,49 +48,43 @@ public: static bool IsValidIDExpression(llvm::StringRef str); static llvm::ArrayRef<llvm::StringRef> GetRangeSpecifiers(); - //------------------------------------------------------------------ /// Takes an input string containing the description of a breakpoint or /// breakpoint and location and returns a BreakpointID filled out with /// the proper id and location. /// - /// @param[in] input + /// \param[in] input /// A string containing JUST the breakpoint description. - /// @return + /// \return /// If \p input was not a valid breakpoint ID string, returns /// \b llvm::None. Otherwise returns a BreakpointID with members filled /// out accordingly. - //------------------------------------------------------------------ static llvm::Optional<BreakpointID> ParseCanonicalReference(llvm::StringRef input); - //------------------------------------------------------------------ /// Takes an input string and checks to see whether it is a breakpoint name. /// If it is a mal-formed breakpoint name, error will be set to an appropriate /// error string. /// - /// @param[in] input + /// \param[in] input /// A string containing JUST the breakpoint description. - /// @param[out] error + /// \param[out] error /// If the name is a well-formed breakpoint name, set to success, /// otherwise set to an error. - /// @return + /// \return /// \b true if the name is a breakpoint name (as opposed to an ID or /// range) false otherwise. - //------------------------------------------------------------------ static bool StringIsBreakpointName(llvm::StringRef str, Status &error); - //------------------------------------------------------------------ /// Takes a breakpoint ID and the breakpoint location id and returns /// a string containing the canonical description for the breakpoint /// or breakpoint location. /// - /// @param[out] break_id + /// \param[out] break_id /// This is the break id. /// - /// @param[out] break_loc_id + /// \param[out] break_loc_id /// This is breakpoint location id, or LLDB_INVALID_BREAK_ID is no /// location is to be specified. - //------------------------------------------------------------------ static void GetCanonicalReference(Stream *s, lldb::break_id_t break_id, lldb::break_id_t break_loc_id); diff --git a/include/lldb/Breakpoint/BreakpointIDList.h b/include/lldb/Breakpoint/BreakpointIDList.h index 2820b9fdcaa5f..c6429220c7ff8 100644 --- a/include/lldb/Breakpoint/BreakpointIDList.h +++ b/include/lldb/Breakpoint/BreakpointIDList.h @@ -1,9 +1,8 @@ //===-- BreakpointIDList.h --------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -21,9 +20,7 @@ namespace lldb_private { -//---------------------------------------------------------------------- // class BreakpointIDList -//---------------------------------------------------------------------- class BreakpointIDList { public: diff --git a/include/lldb/Breakpoint/BreakpointList.h b/include/lldb/Breakpoint/BreakpointList.h index c4fc650a29f00..fe10adbda8a6d 100644 --- a/include/lldb/Breakpoint/BreakpointList.h +++ b/include/lldb/Breakpoint/BreakpointList.h @@ -1,9 +1,8 @@ //===-- BreakpointList.h ----------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -17,15 +16,11 @@ namespace lldb_private { -//---------------------------------------------------------------------- -/// @class BreakpointList BreakpointList.h "lldb/Breakpoint/BreakpointList.h" +/// \class BreakpointList BreakpointList.h "lldb/Breakpoint/BreakpointList.h" /// This class manages a list of breakpoints. -//---------------------------------------------------------------------- -//---------------------------------------------------------------------- /// General Outline: /// Allows adding and removing breakpoints and find by ID and index. -//---------------------------------------------------------------------- class BreakpointList { public: @@ -33,81 +28,66 @@ public: ~BreakpointList(); - //------------------------------------------------------------------ /// Add the breakpoint \a bp_sp to the list. /// - /// @param[in] bp_sp + /// \param[in] bp_sp /// Shared pointer to the breakpoint that will get added to the list. /// - /// @result + /// \result /// Returns breakpoint id. - //------------------------------------------------------------------ lldb::break_id_t Add(lldb::BreakpointSP &bp_sp, bool notify); - //------------------------------------------------------------------ /// Standard "Dump" method. At present it does nothing. - //------------------------------------------------------------------ void Dump(Stream *s) const; - //------------------------------------------------------------------ /// Returns a shared pointer to the breakpoint with id \a breakID. Const /// version. /// - /// @param[in] breakID + /// \param[in] breakID /// The breakpoint ID to seek for. /// - /// @result + /// \result /// A shared pointer to the breakpoint. May contain a NULL pointer if the /// breakpoint doesn't exist. - //------------------------------------------------------------------ lldb::BreakpointSP FindBreakpointByID(lldb::break_id_t breakID) const; - //------------------------------------------------------------------ /// Returns a shared pointer to the breakpoint with index \a i. /// - /// @param[in] i + /// \param[in] i /// The breakpoint index to seek for. /// - /// @result + /// \result /// A shared pointer to the breakpoint. May contain a NULL pointer if the /// breakpoint doesn't exist. - //------------------------------------------------------------------ lldb::BreakpointSP GetBreakpointAtIndex(size_t i) const; - //------------------------------------------------------------------ /// Find all the breakpoints with a given name /// - /// @param[in] name + /// \param[in] name /// The breakpoint name for which to search. /// - /// @result + /// \result /// \bfalse if the input name was not a legal breakpoint name. - //------------------------------------------------------------------ bool FindBreakpointsByName(const char *name, BreakpointList &matching_bps); - //------------------------------------------------------------------ /// Returns the number of elements in this breakpoint list. /// - /// @result + /// \result /// The number of elements. - //------------------------------------------------------------------ size_t GetSize() const { std::lock_guard<std::recursive_mutex> guard(m_mutex); return m_breakpoints.size(); } - //------------------------------------------------------------------ /// Removes the breakpoint given by \b breakID from this list. /// - /// @param[in] breakID + /// \param[in] breakID /// The breakpoint index to remove. /// - /// @result + /// \result /// \b true if the breakpoint \a breakID was in the list. - //------------------------------------------------------------------ bool Remove(lldb::break_id_t breakID, bool notify); - //------------------------------------------------------------------ /// Removes all invalid breakpoint locations. /// /// Removes all breakpoint locations in the list with architectures that @@ -118,43 +98,36 @@ public: /// This is typically used after the process calls exec, or anytime the /// architecture of the target changes. /// - /// @param[in] arch + /// \param[in] arch /// If valid, check the module in each breakpoint to make sure /// they are compatible, otherwise, ignore architecture. - //------------------------------------------------------------------ void RemoveInvalidLocations(const ArchSpec &arch); void SetEnabledAll(bool enabled); void SetEnabledAllowed(bool enabled); - //------------------------------------------------------------------ /// Removes all the breakpoints from this list. - //------------------------------------------------------------------ void RemoveAll(bool notify); - //------------------------------------------------------------------ /// 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. - //------------------------------------------------------------------ void RemoveAllowed(bool notify); - //------------------------------------------------------------------ /// Tell all the breakpoints to update themselves due to a change in the /// modules in \a module_list. \a added says whether the module was loaded /// or unloaded. /// - /// @param[in] module_list + /// \param[in] module_list /// The module list that has changed. /// - /// @param[in] load + /// \param[in] load /// \b true if the modules are loaded, \b false if unloaded. /// - /// @param[in] delete_locations + /// \param[in] delete_locations /// If \a load is \b false, then delete breakpoint locations when /// when updating breakpoints. - //------------------------------------------------------------------ void UpdateBreakpoints(ModuleList &module_list, bool load, bool delete_locations); @@ -163,12 +136,10 @@ public: void ClearAllBreakpointSites(); - //------------------------------------------------------------------ /// Sets the passed in Locker to hold the Breakpoint List mutex. /// - /// @param[in] locker + /// \param[in] locker /// The locker object that is set. - //------------------------------------------------------------------ void GetListMutex(std::unique_lock<std::recursive_mutex> &lock); protected: diff --git a/include/lldb/Breakpoint/BreakpointLocation.h b/include/lldb/Breakpoint/BreakpointLocation.h index 6448cb16e9272..7b27160563a08 100644 --- a/include/lldb/Breakpoint/BreakpointLocation.h +++ b/include/lldb/Breakpoint/BreakpointLocation.h @@ -1,9 +1,8 @@ //===-- BreakpointLocation.h ------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -21,13 +20,10 @@ namespace lldb_private { -//---------------------------------------------------------------------- -/// @class BreakpointLocation BreakpointLocation.h +/// \class BreakpointLocation BreakpointLocation.h /// "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 @@ -37,7 +33,6 @@ namespace lldb_private { /// 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. -//---------------------------------------------------------------------- class BreakpointLocation : public std::enable_shared_from_this<BreakpointLocation>, @@ -45,100 +40,76 @@ class BreakpointLocation 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(); Target &GetTarget(); - //------------------------------------------------------------------ /// 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. /// - /// @return + /// \return /// \b true if this breakpoint location thinks we should stop, /// \b false otherwise. - //------------------------------------------------------------------ bool ShouldStop(StoppointCallbackContext *context) override; - //------------------------------------------------------------------ // The next section deals with various breakpoint options. - //------------------------------------------------------------------ - //------------------------------------------------------------------ /// If \a enable is \b true, enable the breakpoint, if \b false disable it. - //------------------------------------------------------------------ void SetEnabled(bool enabled); - //------------------------------------------------------------------ /// Check the Enable/Disable state. /// - /// @return + /// \return /// \b true if the breakpoint is enabled, \b false if disabled. - //------------------------------------------------------------------ bool IsEnabled() const; - //------------------------------------------------------------------ /// If \a auto_continue is \b true, set the breakpoint to continue when hit. - //------------------------------------------------------------------ void SetAutoContinue(bool auto_continue); - //------------------------------------------------------------------ /// Check the AutoContinue state. /// - /// @return + /// \return /// \b true if the breakpoint is set to auto-continue, \b false if not. - //------------------------------------------------------------------ bool IsAutoContinue() const; - //------------------------------------------------------------------ /// Return the current Ignore Count. /// - /// @return + /// \return /// The number of breakpoint hits to be ignored. - //------------------------------------------------------------------ uint32_t GetIgnoreCount(); - //------------------------------------------------------------------ /// Set the breakpoint to ignore the next \a count breakpoint hits. /// - /// @param[in] count + /// \param[in] count /// The number of breakpoint hits to ignore. - //------------------------------------------------------------------ void SetIgnoreCount(uint32_t n); - //------------------------------------------------------------------ /// 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. /// - /// @param[in] callback + /// \param[in] callback /// The method that will get called when the breakpoint is hit. /// - /// @param[in] callback_baton_sp + /// \param[in] callback_baton_sp /// A shared pointer to a Baton that provides the void * needed /// for the callback. /// - /// @see lldb_private::Baton - //------------------------------------------------------------------ + /// \see lldb_private::Baton void SetCallback(BreakpointHitCallback callback, const lldb::BatonSP &callback_baton_sp, bool is_synchronous); @@ -147,31 +118,25 @@ public: void ClearCallback(); - //------------------------------------------------------------------ /// Set the breakpoint location's condition. /// - /// @param[in] condition + /// \param[in] condition /// The condition expression to evaluate when the breakpoint is hit. - //------------------------------------------------------------------ void SetCondition(const char *condition); - //------------------------------------------------------------------ /// Return a pointer to the text of the condition expression. /// - /// @return + /// \return /// A pointer to the condition expression text, or nullptr if no // condition has been set. - //------------------------------------------------------------------ const char *GetConditionText(size_t *hash = nullptr) const; bool ConditionSaysStop(ExecutionContext &exe_ctx, Status &error); - //------------------------------------------------------------------ /// Set the valid thread to be checked when the breakpoint is hit. /// - /// @param[in] thread_id + /// \param[in] thread_id /// If this thread hits the breakpoint, we stop, otherwise not. - //------------------------------------------------------------------ void SetThreadID(lldb::tid_t thread_id); lldb::tid_t GetThreadID(); @@ -188,150 +153,122 @@ public: const char *GetQueueName() const; - //------------------------------------------------------------------ // The next section deals with this location's breakpoint sites. - //------------------------------------------------------------------ - //------------------------------------------------------------------ /// Try to resolve the breakpoint site for this location. /// - /// @return + /// \return /// \b true if we were successful at setting a breakpoint site, /// \b false otherwise. - //------------------------------------------------------------------ bool ResolveBreakpointSite(); - //------------------------------------------------------------------ /// Clear this breakpoint location's breakpoint site - for instance when /// disabling the breakpoint. /// - /// @return + /// \return /// \b true if there was a breakpoint site to be cleared, \b false /// otherwise. - //------------------------------------------------------------------ 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. - //------------------------------------------------------------------ bool IsResolved() const; lldb::BreakpointSiteSP GetBreakpointSite() const; - //------------------------------------------------------------------ // The next section are generic report functions. - //------------------------------------------------------------------ - //------------------------------------------------------------------ /// Print a description of this breakpoint location to the stream \a s. /// - /// @param[in] s + /// \param[in] s /// The stream to which to print the description. /// - /// @param[in] level + /// \param[in] level /// The description level that indicates the detail level to /// provide. /// - /// @see lldb::DescriptionLevel - //------------------------------------------------------------------ + /// \see lldb::DescriptionLevel void GetDescription(Stream *s, lldb::DescriptionLevel level); - //------------------------------------------------------------------ /// Standard "Dump" method. At present it does nothing. - //------------------------------------------------------------------ void Dump(Stream *s) const override; - //------------------------------------------------------------------ /// 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 /// - /// @return + /// \return /// A pointer to the breakpoint options. - //------------------------------------------------------------------ BreakpointOptions *GetLocationOptions(); - //------------------------------------------------------------------ /// Use this to access breakpoint options from this breakpoint location. /// This will return the options that have a setting for the specified /// BreakpointOptions kind. /// - /// @param[in] kind + /// \param[in] kind /// The particular option you are looking up. - /// @return + /// \return /// A pointer to the containing breakpoint's options if this /// location doesn't have its own copy. - //------------------------------------------------------------------ const BreakpointOptions *GetOptionsSpecifyingKind( BreakpointOptions::OptionKind kind) const; bool ValidForThisThread(Thread *thread); - //------------------------------------------------------------------ /// Invoke the callback action when the breakpoint is hit. /// /// Meant to be used by the BreakpointLocation class. /// - /// @param[in] context + /// \param[in] context /// Described the breakpoint event. /// - /// @param[in] bp_loc_id + /// \param[in] bp_loc_id /// Which breakpoint location hit this breakpoint. /// - /// @return + /// \return /// \b true if the target should stop at this breakpoint and \b /// false not. - //------------------------------------------------------------------ bool InvokeCallback(StoppointCallbackContext *context); - //------------------------------------------------------------------ /// Returns whether we should resolve Indirect functions in setting the /// breakpoint site for this location. /// - /// @return + /// \return /// \b true if the breakpoint SITE for this location should be set on the /// resolved location for Indirect functions. - //------------------------------------------------------------------ bool ShouldResolveIndirectFunctions() { return m_should_resolve_indirect_functions; } - //------------------------------------------------------------------ /// Returns whether the address set in the breakpoint site for this location /// was found by resolving an indirect symbol. /// - /// @return + /// \return /// \b true or \b false as given in the description above. - //------------------------------------------------------------------ bool IsIndirect() { return m_is_indirect; } void SetIsIndirect(bool is_indirect) { m_is_indirect = is_indirect; } - //------------------------------------------------------------------ /// Returns whether the address set in the breakpoint location was re-routed /// to the target of a re-exported symbol. /// - /// @return + /// \return /// \b true or \b false as given in the description above. - //------------------------------------------------------------------ bool IsReExported() { return m_is_reexported; } void SetIsReExported(bool is_reexported) { m_is_reexported = is_reexported; } - //------------------------------------------------------------------ /// 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. /// - /// @param[in] location + /// \param[in] location /// The location to compare against. /// - /// @return + /// \return /// \b true or \b false as given in the description above. - //------------------------------------------------------------------ bool EquivalentToLocation(BreakpointLocation &location); protected: @@ -340,16 +277,14 @@ protected: friend class Process; friend class StopInfoBreakpoint; - //------------------------------------------------------------------ /// Set the breakpoint site for this location to \a bp_site_sp. /// - /// @param[in] bp_site_sp + /// \param[in] bp_site_sp /// The breakpoint site we are setting for this location. /// - /// @return + /// \return /// \b true if we were successful at setting the breakpoint site, /// \b false otherwise. - //------------------------------------------------------------------ bool SetBreakpointSite(lldb::BreakpointSiteSP &bp_site_sp); void DecrementIgnoreCount(); @@ -363,46 +298,40 @@ private: void UndoBumpHitCount(); - //------------------------------------------------------------------ // Constructors and Destructors // // Only the Breakpoint can make breakpoint locations, and it owns them. - //------------------------------------------------------------------ - //------------------------------------------------------------------ /// Constructor. /// - /// @param[in] owner + /// \param[in] owner /// A back pointer to the breakpoint that owns this location. /// - /// @param[in] addr + /// \param[in] addr /// The Address defining this location. /// - /// @param[in] tid + /// \param[in] tid /// The thread for which this breakpoint location is valid, or /// LLDB_INVALID_THREAD_ID if it is valid for all threads. /// - /// @param[in] hardware + /// \param[in] hardware /// \b true if a hardware breakpoint is requested. - //------------------------------------------------------------------ BreakpointLocation(lldb::break_id_t bid, Breakpoint &owner, const Address &addr, lldb::tid_t tid, bool hardware, bool check_for_resolver = true); - //------------------------------------------------------------------ // Data members: - //------------------------------------------------------------------ bool m_being_created; bool m_should_resolve_indirect_functions; bool m_is_reexported; bool m_is_indirect; Address m_address; ///< The address defining this location. Breakpoint &m_owner; ///< The breakpoint that produced this object. - std::unique_ptr<BreakpointOptions> m_options_ap; ///< Breakpoint options - ///pointer, nullptr if we're - ///using our breakpoint's - ///options. + std::unique_ptr<BreakpointOptions> m_options_up; ///< Breakpoint options + /// pointer, nullptr if we're + /// using our breakpoint's + /// options. lldb::BreakpointSiteSP m_bp_site_sp; ///< Our breakpoint site (it may be ///shared by more than one location.) lldb::UserExpressionSP m_user_expression_sp; ///< The compiled expression to diff --git a/include/lldb/Breakpoint/BreakpointLocationCollection.h b/include/lldb/Breakpoint/BreakpointLocationCollection.h index 5a188539622bf..3da52eb7962a8 100644 --- a/include/lldb/Breakpoint/BreakpointLocationCollection.h +++ b/include/lldb/Breakpoint/BreakpointLocationCollection.h @@ -1,9 +1,8 @@ //===-- BreakpointLocationCollection.h --------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -23,165 +22,141 @@ public: BreakpointLocationCollection(); ~BreakpointLocationCollection(); + + BreakpointLocationCollection &operator=(const BreakpointLocationCollection &rhs); - //------------------------------------------------------------------ /// Add the breakpoint \a bp_loc_sp to the list. /// - /// @param[in] bp_sp + /// \param[in] bp_sp /// Shared pointer to the breakpoint location that will get added /// to the list. /// - /// @result + /// \result /// Returns breakpoint location id. - //------------------------------------------------------------------ void Add(const lldb::BreakpointLocationSP &bp_loc_sp); - //------------------------------------------------------------------ /// Removes the breakpoint location given by \b breakID from this /// list. /// - /// @param[in] break_id + /// \param[in] break_id /// The breakpoint index to remove. /// - /// @param[in] break_loc_id + /// \param[in] break_loc_id /// The breakpoint location index in break_id to remove. /// - /// @result + /// \result /// \b true if the breakpoint was in the list. - //------------------------------------------------------------------ bool Remove(lldb::break_id_t break_id, lldb::break_id_t break_loc_id); - //------------------------------------------------------------------ /// Returns a shared pointer to the breakpoint location with id \a /// breakID. /// - /// @param[in] break_id + /// \param[in] break_id /// The breakpoint ID to seek for. /// - /// @param[in] break_loc_id + /// \param[in] break_loc_id /// The breakpoint location ID in \a break_id to seek for. /// - /// @result + /// \result /// A shared pointer to the breakpoint. May contain a NULL /// pointer if the breakpoint doesn't exist. - //------------------------------------------------------------------ lldb::BreakpointLocationSP FindByIDPair(lldb::break_id_t break_id, lldb::break_id_t break_loc_id); - //------------------------------------------------------------------ /// Returns a shared pointer to the breakpoint location with id \a /// breakID, const version. /// - /// @param[in] breakID + /// \param[in] breakID /// The breakpoint location ID to seek for. /// - /// @param[in] break_loc_id + /// \param[in] break_loc_id /// The breakpoint location ID in \a break_id to seek for. /// - /// @result + /// \result /// A shared pointer to the breakpoint. May contain a NULL /// pointer if the breakpoint doesn't exist. - //------------------------------------------------------------------ const lldb::BreakpointLocationSP FindByIDPair(lldb::break_id_t break_id, lldb::break_id_t break_loc_id) const; - //------------------------------------------------------------------ /// Returns a shared pointer to the breakpoint location with index /// \a i. /// - /// @param[in] i + /// \param[in] i /// The breakpoint location index to seek for. /// - /// @result + /// \result /// A shared pointer to the breakpoint. May contain a NULL /// pointer if the breakpoint doesn't exist. - //------------------------------------------------------------------ lldb::BreakpointLocationSP GetByIndex(size_t i); - //------------------------------------------------------------------ /// Returns a shared pointer to the breakpoint location with index /// \a i, const version. /// - /// @param[in] i + /// \param[in] i /// The breakpoint location index to seek for. /// - /// @result + /// \result /// A shared pointer to the breakpoint. May contain a NULL /// pointer if the breakpoint doesn't exist. - //------------------------------------------------------------------ const lldb::BreakpointLocationSP GetByIndex(size_t i) const; - //------------------------------------------------------------------ /// Returns the number of elements in this breakpoint location list. /// - /// @result + /// \result /// The number of elements. - //------------------------------------------------------------------ size_t GetSize() const { return m_break_loc_collection.size(); } - //------------------------------------------------------------------ /// Enquires of all the breakpoint locations in this list whether /// we should stop at a hit at \a breakID. /// - /// @param[in] context + /// \param[in] context /// This contains the information about this stop. /// - /// @param[in] breakID + /// \param[in] breakID /// This break ID that we hit. /// - /// @return + /// \return /// \b true if we should stop, \b false otherwise. - //------------------------------------------------------------------ bool ShouldStop(StoppointCallbackContext *context); - //------------------------------------------------------------------ /// Print a description of the breakpoint locations in this list /// to the stream \a s. /// - /// @param[in] s + /// \param[in] s /// The stream to which to print the description. /// - /// @param[in] level + /// \param[in] level /// The description level that indicates the detail level to /// provide. /// - /// @see lldb::DescriptionLevel - //------------------------------------------------------------------ + /// \see lldb::DescriptionLevel void GetDescription(Stream *s, lldb::DescriptionLevel level); - //------------------------------------------------------------------ /// Check whether this collection of breakpoint locations have any /// thread specifiers, and if yes, is \a thread_id contained in any /// of these specifiers. /// - /// @param[in] thread + /// \param[in] thread /// The thread against which to test. /// /// return /// \b true if the collection contains at least one location that /// would be valid for this thread, false otherwise. - //------------------------------------------------------------------ bool ValidForThisThread(Thread *thread); - //------------------------------------------------------------------ /// Tell whether ALL the breakpoints in the location collection are internal. /// - /// @result + /// \result /// \b true if all breakpoint locations are owned by internal breakpoints, /// \b false otherwise. - //------------------------------------------------------------------ bool IsInternal() const; protected: - //------------------------------------------------------------------ // Classes that inherit from BreakpointLocationCollection can see and modify // these - //------------------------------------------------------------------ private: - //------------------------------------------------------------------ // For BreakpointLocationCollection only - //------------------------------------------------------------------ typedef std::vector<lldb::BreakpointLocationSP> collection; diff --git a/include/lldb/Breakpoint/BreakpointLocationList.h b/include/lldb/Breakpoint/BreakpointLocationList.h index 01ee5b5dcce9d..b7e0e49cff83a 100644 --- a/include/lldb/Breakpoint/BreakpointLocationList.h +++ b/include/lldb/Breakpoint/BreakpointLocationList.h @@ -1,9 +1,8 @@ //===-- BreakpointLocationList.h --------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -20,12 +19,10 @@ namespace lldb_private { -//---------------------------------------------------------------------- -/// @class BreakpointLocationList BreakpointLocationList.h +/// \class BreakpointLocationList BreakpointLocationList.h /// "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 @@ -37,178 +34,146 @@ class BreakpointLocationList { public: virtual ~BreakpointLocationList(); - //------------------------------------------------------------------ /// Standard "Dump" method. At present it does nothing. - //------------------------------------------------------------------ void Dump(Stream *s) const; - //------------------------------------------------------------------ /// Returns a shared pointer to the breakpoint location at address \a addr - /// const version. /// - /// @param[in] addr + /// \param[in] addr /// The address to look for. /// - /// @result + /// \result /// A shared pointer to the breakpoint. May contain a nullptr /// pointer if the breakpoint doesn't exist. - //------------------------------------------------------------------ const lldb::BreakpointLocationSP FindByAddress(const Address &addr) const; - //------------------------------------------------------------------ /// Returns a shared pointer to the breakpoint location with id \a breakID, /// const version. /// - /// @param[in] breakID + /// \param[in] breakID /// The breakpoint location ID to seek for. /// - /// @result + /// \result /// A shared pointer to the breakpoint. May contain a nullptr /// pointer if the breakpoint doesn't exist. - //------------------------------------------------------------------ lldb::BreakpointLocationSP FindByID(lldb::break_id_t breakID) const; - //------------------------------------------------------------------ /// Returns the breakpoint location id to the breakpoint location at address /// \a addr. /// - /// @param[in] addr + /// \param[in] addr /// The address to match. /// - /// @result + /// \result /// The ID of the breakpoint location, or LLDB_INVALID_BREAK_ID. - //------------------------------------------------------------------ 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. /// - /// @param[in] module + /// \param[in] module /// The module to seek in. /// - /// @param[in] + /// \param[in] /// A breakpoint collection that gets any breakpoint locations /// that match \a module appended to. /// - /// @result + /// \result /// The number of matches - //------------------------------------------------------------------ size_t FindInModule(Module *module, BreakpointLocationCollection &bp_loc_list); - //------------------------------------------------------------------ /// Returns a shared pointer to the breakpoint location with index \a i. /// - /// @param[in] i + /// \param[in] i /// The breakpoint location index to seek for. /// - /// @result + /// \result /// A shared pointer to the breakpoint. May contain a nullptr /// pointer if the breakpoint doesn't exist. - //------------------------------------------------------------------ lldb::BreakpointLocationSP GetByIndex(size_t i); - //------------------------------------------------------------------ /// Returns a shared pointer to the breakpoint location with index \a i, /// const version. /// - /// @param[in] i + /// \param[in] i /// The breakpoint location index to seek for. /// - /// @result + /// \result /// A shared pointer to the breakpoint. May contain a nullptr /// pointer if the breakpoint doesn't exist. - //------------------------------------------------------------------ const lldb::BreakpointLocationSP GetByIndex(size_t i) const; - //------------------------------------------------------------------ /// 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. - //------------------------------------------------------------------ void ResolveAllBreakpointSites(); - //------------------------------------------------------------------ /// Returns the number of breakpoint locations in this list with resolved /// breakpoints. /// - /// @result + /// \result /// Number of qualifying breakpoint locations. - //------------------------------------------------------------------ size_t GetNumResolvedLocations() const; - //------------------------------------------------------------------ /// Returns the number hit count of all locations in this list. /// - /// @result + /// \result /// Hit count of all locations in this list. - //------------------------------------------------------------------ uint32_t GetHitCount() const; - //------------------------------------------------------------------ /// Enquires of the breakpoint location in this list with ID \a breakID /// whether we should stop. /// - /// @param[in] context + /// \param[in] context /// This contains the information about this stop. /// - /// @param[in] breakID + /// \param[in] breakID /// This break ID that we hit. /// - /// @return + /// \return /// \b true if we should stop, \b false otherwise. - //------------------------------------------------------------------ bool ShouldStop(StoppointCallbackContext *context, lldb::break_id_t breakID); - //------------------------------------------------------------------ /// Returns the number of elements in this breakpoint location list. /// - /// @result + /// \result /// The number of elements. - //------------------------------------------------------------------ size_t GetSize() const { return m_locations.size(); } - //------------------------------------------------------------------ /// Print a description of the breakpoint locations in this list to the /// stream \a s. /// - /// @param[in] s + /// \param[in] s /// The stream to which to print the description. /// - /// @param[in] level + /// \param[in] level /// The description level that indicates the detail level to /// provide. /// - /// @see lldb::DescriptionLevel - //------------------------------------------------------------------ + /// \see lldb::DescriptionLevel void GetDescription(Stream *s, lldb::DescriptionLevel level); 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. - //------------------------------------------------------------------ BreakpointLocationList(Breakpoint &owner); - //------------------------------------------------------------------ /// Add the breakpoint \a bp_loc_sp to the list. /// - /// @param[in] bp_sp + /// \param[in] bp_sp /// Shared pointer to the breakpoint location that will get /// added to the list. /// - /// @result + /// \result /// Returns breakpoint location id. - //------------------------------------------------------------------ lldb::BreakpointLocationSP Create(const Address &addr, bool resolve_indirect_symbols); diff --git a/include/lldb/Breakpoint/BreakpointName.h b/include/lldb/Breakpoint/BreakpointName.h index 5e5a04fe9117f..61020a6280707 100644 --- a/include/lldb/Breakpoint/BreakpointName.h +++ b/include/lldb/Breakpoint/BreakpointName.h @@ -1,9 +1,8 @@ //===-- BreakpointName.h --------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -137,13 +136,13 @@ public: } }; - BreakpointName(const ConstString &name, const char *help = nullptr) : + BreakpointName(ConstString name, const char *help = nullptr) : m_name(name), m_options(false) { SetHelp(help); } - BreakpointName(const ConstString &name, + BreakpointName(ConstString name, BreakpointOptions &options, const Permissions &permissions = Permissions(), const char *help = nullptr) : @@ -157,10 +156,10 @@ public: m_permissions(rhs.m_permissions), m_help(rhs.m_help) {} - BreakpointName(const ConstString &name, const Breakpoint &bkpt, + BreakpointName(ConstString name, const Breakpoint &bkpt, const char *help); - const ConstString &GetName() const { return m_name; } + ConstString GetName() const { return m_name; } BreakpointOptions &GetOptions() { return m_options; } const BreakpointOptions &GetOptions() const { return m_options; } diff --git a/include/lldb/Breakpoint/BreakpointOptions.h b/include/lldb/Breakpoint/BreakpointOptions.h index e91df20ed3055..cdac5d3dbd75d 100644 --- a/include/lldb/Breakpoint/BreakpointOptions.h +++ b/include/lldb/Breakpoint/BreakpointOptions.h @@ -1,9 +1,8 @@ //===-- BreakpointOptions.h -------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -21,11 +20,9 @@ namespace lldb_private { -//---------------------------------------------------------------------- -/// @class BreakpointOptions BreakpointOptions.h +/// \class BreakpointOptions BreakpointOptions.h /// "lldb/Breakpoint/BreakpointOptions.h" Class that manages the options on a /// breakpoint or breakpoint location. -//---------------------------------------------------------------------- class BreakpointOptions { friend class BreakpointLocation; @@ -96,32 +93,26 @@ public: typedef std::shared_ptr<CommandBaton> CommandBatonSP; - //------------------------------------------------------------------ // Constructors and Destructors - //------------------------------------------------------------------ - //------------------------------------------------------------------ /// 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 + /// \param[in] condition /// The expression which if it evaluates to \b true if we are to stop /// - /// @param[in] enabled + /// \param[in] enabled /// Is this breakpoint enabled. /// - /// @param[in] ignore + /// \param[in] ignore /// How many breakpoint hits we should ignore before stopping. /// - //------------------------------------------------------------------ BreakpointOptions(const char *condition, bool enabled = true, int32_t ignore = 0, bool one_shot = false, bool auto_continue = false); - //------------------------------------------------------------------ /// 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); @@ -136,17 +127,12 @@ public: static const char *GetSerializationKey() { return "BKPTOptions"; } - //------------------------------------------------------------------ // Operators - //------------------------------------------------------------------ const BreakpointOptions &operator=(const BreakpointOptions &rhs); - //------------------------------------------------------------------ /// Copy over only the options set in the incoming BreakpointOptions. - //------------------------------------------------------------------ void CopyOverSetOptions(const BreakpointOptions &rhs); - //------------------------------------------------------------------ // Callbacks // // Breakpoint callbacks come in two forms, synchronous and asynchronous. @@ -178,21 +164,18 @@ public: // 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. // - //------------------------------------------------------------------ - //------------------------------------------------------------------ /// Adds a callback to the breakpoint option set. /// - /// @param[in] callback + /// \param[in] callback /// The function to be called when the breakpoint gets hit. /// - /// @param[in] baton_sp + /// \param[in] baton_sp /// A baton which will get passed back to the callback when it is invoked. /// - /// @param[in] synchronous + /// \param[in] synchronous /// Whether this is a synchronous or asynchronous callback. See discussion /// above. - //------------------------------------------------------------------ void SetCallback(BreakpointHitCallback callback, const lldb::BatonSP &baton_sp, bool synchronous = false); @@ -200,30 +183,25 @@ public: const BreakpointOptions::CommandBatonSP &command_baton_sp, bool synchronous = false); - //------------------------------------------------------------------ /// Returns the command line commands for the callback on this breakpoint. /// - /// @param[out] command_list + /// \param[out] command_list /// The commands will be appended to this list. /// - /// @return + /// \return /// \btrue if the command callback is a command-line callback, /// \bfalse otherwise. - //------------------------------------------------------------------ bool GetCommandLineCallbacks(StringList &command_list); - //------------------------------------------------------------------ /// Remove the callback from this option set. - //------------------------------------------------------------------ void ClearCallback(); // 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. /// - /// @param[in] context + /// \param[in] context /// The context in which the callback is to be invoked. This includes the /// stop event, the /// execution context of the stop (since you might hit the same breakpoint @@ -231,169 +209,128 @@ public: /// whether we are currently executing synchronous or asynchronous /// callbacks. /// - /// @param[in] break_id + /// \param[in] break_id /// The breakpoint ID that owns this option set. /// - /// @param[in] break_loc_id + /// \param[in] break_loc_id /// The breakpoint location ID that owns this option set. /// - /// @return + /// \return /// The callback return value. - //------------------------------------------------------------------ bool InvokeCallback(StoppointCallbackContext *context, lldb::user_id_t break_id, lldb::user_id_t break_loc_id); - //------------------------------------------------------------------ /// Used in InvokeCallback to tell whether it is the right time to run this /// kind of callback. /// - /// @return + /// \return /// The synchronicity of our callback. - //------------------------------------------------------------------ bool IsCallbackSynchronous() const { return m_callback_is_synchronous; } - //------------------------------------------------------------------ /// Fetch the baton from the callback. /// - /// @return + /// \return /// The baton. - //------------------------------------------------------------------ Baton *GetBaton(); - //------------------------------------------------------------------ /// Fetch a const version of the baton from the callback. /// - /// @return + /// \return /// The baton. - //------------------------------------------------------------------ const Baton *GetBaton() const; - //------------------------------------------------------------------ // Condition - //------------------------------------------------------------------ - //------------------------------------------------------------------ /// Set the breakpoint option's condition. /// - /// @param[in] condition + /// \param[in] condition /// The condition expression to evaluate when the breakpoint is hit. - //------------------------------------------------------------------ void SetCondition(const char *condition); - //------------------------------------------------------------------ /// Return a pointer to the text of the condition expression. /// - /// @return + /// \return /// A pointer to the condition expression text, or nullptr if no // condition has been set. - //------------------------------------------------------------------ const char *GetConditionText(size_t *hash = nullptr) const; - //------------------------------------------------------------------ // Enabled/Ignore Count - //------------------------------------------------------------------ - //------------------------------------------------------------------ /// Check the Enable/Disable state. - /// @return + /// \return /// \b true if the breakpoint is enabled, \b false if disabled. - //------------------------------------------------------------------ bool IsEnabled() const { return m_enabled; } - //------------------------------------------------------------------ /// If \a enable is \b true, enable the breakpoint, if \b false disable it. - //------------------------------------------------------------------ void SetEnabled(bool enabled) { m_enabled = enabled; m_set_flags.Set(eEnabled); } - //------------------------------------------------------------------ /// Check the auto-continue state. - /// @return + /// \return /// \b true if the breakpoint is set to auto-continue, \b false otherwise. - //------------------------------------------------------------------ bool IsAutoContinue() const { return m_auto_continue; } - //------------------------------------------------------------------ /// Set the auto-continue state. - //------------------------------------------------------------------ void SetAutoContinue(bool auto_continue) { m_auto_continue = auto_continue; m_set_flags.Set(eAutoContinue); } - //------------------------------------------------------------------ /// Check the One-shot state. - /// @return + /// \return /// \b true if the breakpoint is one-shot, \b false otherwise. - //------------------------------------------------------------------ bool IsOneShot() const { return m_one_shot; } - //------------------------------------------------------------------ /// If \a enable is \b true, enable the breakpoint, if \b false disable it. - //------------------------------------------------------------------ void SetOneShot(bool one_shot) { m_one_shot = one_shot; m_set_flags.Set(eOneShot); } - //------------------------------------------------------------------ /// Set the breakpoint to ignore the next \a count breakpoint hits. - /// @param[in] count + /// \param[in] count /// The number of breakpoint hits to ignore. - //------------------------------------------------------------------ void SetIgnoreCount(uint32_t n) { m_ignore_count = n; m_set_flags.Set(eIgnoreCount); } - //------------------------------------------------------------------ /// Return the current Ignore Count. - /// @return + /// \return /// The number of breakpoint hits to be ignored. - //------------------------------------------------------------------ uint32_t GetIgnoreCount() const { return m_ignore_count; } - //------------------------------------------------------------------ /// Return the current thread spec for this option. This will return nullptr /// if the no thread specifications have been set for this Option yet. - /// @return + /// \return /// The thread specification pointer for this option, or nullptr if none /// has /// been set yet. - //------------------------------------------------------------------ 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 /// ThreadSpec items for this option. - //------------------------------------------------------------------ ThreadSpec *GetThreadSpec(); void SetThreadID(lldb::tid_t thread_id); void GetDescription(Stream *s, lldb::DescriptionLevel level) const; - //------------------------------------------------------------------ /// Returns true if the breakpoint option has a callback set. - //------------------------------------------------------------------ bool HasCallback() const; - //------------------------------------------------------------------ /// This is the default empty callback. - //------------------------------------------------------------------ static bool NullCallback(void *baton, StoppointCallbackContext *context, lldb::user_id_t break_id, lldb::user_id_t break_loc_id); - //------------------------------------------------------------------ - /// Set a callback based on BreakpointOptions::CommandData. @param[in] + /// 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. - //------------------------------------------------------------------ void SetCommandDataCallback(std::unique_ptr<CommandData> &cmd_data); void Clear(); @@ -403,9 +340,7 @@ public: } protected: -//------------------------------------------------------------------ // Classes that inherit from BreakpointOptions can see and modify these - //------------------------------------------------------------------ bool IsOptionSet(OptionKind kind) { return m_set_flags.Test(kind); @@ -432,9 +367,7 @@ protected: void SetThreadSpec(std::unique_ptr<ThreadSpec> &thread_spec_up); private: - //------------------------------------------------------------------ // For BreakpointOptions only - //------------------------------------------------------------------ BreakpointHitCallback m_callback; // This is the callback function pointer lldb::BatonSP m_callback_baton_sp; // This is the client data for the callback bool m_baton_is_command_baton; @@ -443,7 +376,7 @@ private: bool m_one_shot; uint32_t m_ignore_count; // Number of times to ignore this breakpoint std::unique_ptr<ThreadSpec> - m_thread_spec_ap; // Thread for which this breakpoint will take + m_thread_spec_up; // Thread for which this breakpoint will take std::string m_condition_text; // The condition to test. size_t m_condition_text_hash; // Its hash, so that locations know when the // condition is updated. diff --git a/include/lldb/Breakpoint/BreakpointPrecondition.h b/include/lldb/Breakpoint/BreakpointPrecondition.h new file mode 100644 index 0000000000000..2a9461b52fab2 --- /dev/null +++ b/include/lldb/Breakpoint/BreakpointPrecondition.h @@ -0,0 +1,30 @@ +//===-- BreakpointPrecondition.h --------------------------------*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef liblldb_BreakpointPrecondition_h_ +#define liblldb_BreakpointPrecondition_h_ + +#include "lldb/lldb-enumerations.h" + +namespace lldb_private { + +class Args; +class Status; +class StoppointCallbackContext; +class Stream; + +class BreakpointPrecondition { +public: + virtual ~BreakpointPrecondition() = default; + virtual bool EvaluatePrecondition(StoppointCallbackContext &context); + virtual Status ConfigurePrecondition(Args &args); + virtual void GetDescription(Stream &stream, lldb::DescriptionLevel level); +}; +} // namespace lldb_private + +#endif diff --git a/include/lldb/Breakpoint/BreakpointResolver.h b/include/lldb/Breakpoint/BreakpointResolver.h index 32008f3dd96f7..11e183b33482d 100644 --- a/include/lldb/Breakpoint/BreakpointResolver.h +++ b/include/lldb/Breakpoint/BreakpointResolver.h @@ -1,9 +1,8 @@ //===-- BreakpointResolver.h ------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -20,13 +19,10 @@ namespace lldb_private { -//---------------------------------------------------------------------- -/// @class BreakpointResolver BreakpointResolver.h +/// \class BreakpointResolver BreakpointResolver.h /// "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 @@ -35,92 +31,73 @@ namespace lldb_private { /// Each Breakpoint has a BreakpointResolver, and it calls either /// ResolveBreakpoint or ResolveBreakpointInModules to tell it to look for new /// breakpoint locations. -//---------------------------------------------------------------------- class BreakpointResolver : public Searcher { friend class Breakpoint; 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. /// - /// @param[in] bkpt + /// \param[in] bkpt /// The breakpoint that owns this resolver. - /// @param[in] resolverType + /// \param[in] resolverType /// The concrete breakpoint resolver type for this breakpoint. /// - /// @result + /// \result /// Returns breakpoint location id. - //------------------------------------------------------------------ BreakpointResolver(Breakpoint *bkpt, unsigned char resolverType, lldb::addr_t offset = 0); - //------------------------------------------------------------------ /// The Destructor is virtual, all significant breakpoint resolvers derive /// from this class. - //------------------------------------------------------------------ ~BreakpointResolver() override; - //------------------------------------------------------------------ /// This sets the breakpoint for this resolver. /// - /// @param[in] bkpt + /// \param[in] bkpt /// The breakpoint that owns this resolver. - //------------------------------------------------------------------ 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. /// - /// @param[in] offset + /// \param[in] offset /// The offset to add to all locations. - //------------------------------------------------------------------ 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. /// - /// @param[in] offset + /// \param[in] offset /// The offset to add to all locations. - //------------------------------------------------------------------ lldb::addr_t GetOffset() const { return m_offset; } - //------------------------------------------------------------------ /// In response to this method the resolver scans all the modules in the /// breakpoint's target, and adds any new locations it finds. /// - /// @param[in] filter + /// \param[in] filter /// The filter that will manage the search for this resolver. - //------------------------------------------------------------------ virtual void ResolveBreakpoint(SearchFilter &filter); - //------------------------------------------------------------------ /// In response to this method the resolver scans the modules in the module /// list \a modules, and adds any new locations it finds. /// - /// @param[in] filter + /// \param[in] filter /// The filter that will manage the search for this resolver. - //------------------------------------------------------------------ virtual void ResolveBreakpointInModules(SearchFilter &filter, ModuleList &modules); - //------------------------------------------------------------------ /// Prints a canonical description for the breakpoint to the stream \a s. /// - /// @param[in] s + /// \param[in] s /// Stream to which the output is copied. - //------------------------------------------------------------------ void GetDescription(Stream *s) override = 0; - //------------------------------------------------------------------ /// Standard "Dump" method. At present it does nothing. - //------------------------------------------------------------------ virtual void Dump(Stream *s) const = 0; /// This section handles serializing and deserializing from StructuredData @@ -143,8 +120,6 @@ public: StructuredData::DictionarySP WrapOptionsDict(StructuredData::DictionarySP options_dict_sp); - //------------------------------------------------------------------ - //------------------------------------------------------------------ /// 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 @@ -164,7 +139,6 @@ public: // index, and one for UnknownResolver. static const char *g_ty_to_name[LastKnownResolverType + 2]; - //------------------------------------------------------------------ /// getResolverID - Return an ID for the concrete type of this object. This /// is used to implement the LLVM classof checks. This should not be used /// for any other purpose, as the values may change as LLDB evolves. @@ -221,7 +195,6 @@ public: } protected: - //------------------------------------------------------------------ /// 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 @@ -236,7 +209,7 @@ protected: const char *) = delete; lldb::BreakpointLocationSP AddLocation(Address loc_addr, - bool *new_location = NULL); + bool *new_location = nullptr); Breakpoint *m_breakpoint; // This is the breakpoint we add locations to. lldb::addr_t m_offset; // A random offset the user asked us to add to any diff --git a/include/lldb/Breakpoint/BreakpointResolverAddress.h b/include/lldb/Breakpoint/BreakpointResolverAddress.h index 5d8c0b6b75301..949a788282b96 100644 --- a/include/lldb/Breakpoint/BreakpointResolverAddress.h +++ b/include/lldb/Breakpoint/BreakpointResolverAddress.h @@ -1,9 +1,8 @@ //===-- BreakpointResolverAddress.h -----------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -15,12 +14,10 @@ namespace lldb_private { -//---------------------------------------------------------------------- -/// @class BreakpointResolverAddress BreakpointResolverAddress.h +/// \class BreakpointResolverAddress BreakpointResolverAddress.h /// "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 { public: diff --git a/include/lldb/Breakpoint/BreakpointResolverFileLine.h b/include/lldb/Breakpoint/BreakpointResolverFileLine.h index 8671cd2e55620..f146a704ca54e 100644 --- a/include/lldb/Breakpoint/BreakpointResolverFileLine.h +++ b/include/lldb/Breakpoint/BreakpointResolverFileLine.h @@ -1,9 +1,8 @@ //===-- BreakpointResolverFileLine.h ----------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -14,12 +13,10 @@ namespace lldb_private { -//---------------------------------------------------------------------- -/// @class BreakpointResolverFileLine BreakpointResolverFileLine.h +/// \class BreakpointResolverFileLine BreakpointResolverFileLine.h /// "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 { public: diff --git a/include/lldb/Breakpoint/BreakpointResolverFileRegex.h b/include/lldb/Breakpoint/BreakpointResolverFileRegex.h index db4f67cf39511..963145722e39a 100644 --- a/include/lldb/Breakpoint/BreakpointResolverFileRegex.h +++ b/include/lldb/Breakpoint/BreakpointResolverFileRegex.h @@ -1,10 +1,9 @@ //===-- BreakpointResolverFileRegex.h ----------------------------*- C++ //-*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -17,12 +16,10 @@ namespace lldb_private { -//---------------------------------------------------------------------- -/// @class BreakpointResolverFileRegex BreakpointResolverFileRegex.h +/// \class BreakpointResolverFileRegex BreakpointResolverFileRegex.h /// "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. -//---------------------------------------------------------------------- class BreakpointResolverFileRegex : public BreakpointResolver { public: diff --git a/include/lldb/Breakpoint/BreakpointResolverName.h b/include/lldb/Breakpoint/BreakpointResolverName.h index 416e1aa301b1c..85a41b6007f0b 100644 --- a/include/lldb/Breakpoint/BreakpointResolverName.h +++ b/include/lldb/Breakpoint/BreakpointResolverName.h @@ -1,9 +1,8 @@ //===-- BreakpointResolverName.h --------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -18,11 +17,9 @@ namespace lldb_private { -//---------------------------------------------------------------------- -/// @class BreakpointResolverName BreakpointResolverName.h +/// \class BreakpointResolverName BreakpointResolverName.h /// "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 { public: @@ -88,7 +85,7 @@ protected: lldb::LanguageType m_language; bool m_skip_prologue; - void AddNameLookup(const ConstString &name, + void AddNameLookup(ConstString name, lldb::FunctionNameType name_type_mask); }; diff --git a/include/lldb/Breakpoint/BreakpointResolverScripted.h b/include/lldb/Breakpoint/BreakpointResolverScripted.h index aaa9cbe4d3549..980bb4693d033 100644 --- a/include/lldb/Breakpoint/BreakpointResolverScripted.h +++ b/include/lldb/Breakpoint/BreakpointResolverScripted.h @@ -1,9 +1,8 @@ //===-- BreakpointResolverScripted.h -----------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -17,12 +16,10 @@ namespace lldb_private { -//---------------------------------------------------------------------- -/// @class BreakpointResolverScripted BreakpointResolverScripted.h +/// \class BreakpointResolverScripted BreakpointResolverScripted.h /// "lldb/Breakpoint/BreakpointResolverScripted.h" This class sets breakpoints /// on a given Address. This breakpoint only takes once, and then it won't /// attempt to reset itself. -//---------------------------------------------------------------------- class BreakpointResolverScripted : public BreakpointResolver { public: diff --git a/include/lldb/Breakpoint/BreakpointSite.h b/include/lldb/Breakpoint/BreakpointSite.h index 8d1d69076b1cb..51ed84f7bf2dd 100644 --- a/include/lldb/Breakpoint/BreakpointSite.h +++ b/include/lldb/Breakpoint/BreakpointSite.h @@ -1,9 +1,8 @@ //===-- BreakpointSite.h ----------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -22,8 +21,7 @@ namespace lldb_private { -//---------------------------------------------------------------------- -/// @class BreakpointSite BreakpointSite.h "lldb/Breakpoint/BreakpointSite.h" +/// \class BreakpointSite BreakpointSite.h "lldb/Breakpoint/BreakpointSite.h" /// Class that manages the actual breakpoint that will be inserted into the /// running program. /// @@ -33,7 +31,6 @@ namespace lldb_private { /// 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>, public StoppointLocation { @@ -50,182 +47,142 @@ public: ~BreakpointSite() override; - //---------------------------------------------------------------------- // This section manages the breakpoint traps - //---------------------------------------------------------------------- - //------------------------------------------------------------------ /// Returns the Opcode Bytes for this breakpoint - //------------------------------------------------------------------ uint8_t *GetTrapOpcodeBytes(); - //------------------------------------------------------------------ /// Returns the Opcode Bytes for this breakpoint - const version - //------------------------------------------------------------------ const uint8_t *GetTrapOpcodeBytes() const; - //------------------------------------------------------------------ /// Get the size of the trap opcode for this address - //------------------------------------------------------------------ size_t GetTrapOpcodeMaxByteSize() const; - //------------------------------------------------------------------ /// Sets the trap opcode - //------------------------------------------------------------------ bool SetTrapOpcode(const uint8_t *trap_opcode, uint32_t trap_opcode_size); - //------------------------------------------------------------------ /// Gets the original instruction bytes that were overwritten by the trap - //------------------------------------------------------------------ uint8_t *GetSavedOpcodeBytes(); - //------------------------------------------------------------------ /// Gets the original instruction bytes that were overwritten by the trap /// const version - //------------------------------------------------------------------ const uint8_t *GetSavedOpcodeBytes() const; - //------------------------------------------------------------------ /// Says whether \a addr and size \a size intersects with the address \a /// intersect_addr - //------------------------------------------------------------------ bool IntersectsRange(lldb::addr_t addr, size_t size, lldb::addr_t *intersect_addr, size_t *intersect_size, size_t *opcode_offset) const; - //------------------------------------------------------------------ /// 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. - //------------------------------------------------------------------ bool IsEnabled() const; - //------------------------------------------------------------------ /// Sets whether the current breakpoint site is enabled or not /// - /// @param[in] enabled + /// \param[in] enabled /// \b true if the breakpoint is enabled, \b false otherwise. - //------------------------------------------------------------------ void SetEnabled(bool enabled); - //------------------------------------------------------------------ /// Enquires of the breakpoint locations that produced this breakpoint site /// whether we should stop at this location. /// - /// @param[in] context + /// \param[in] context /// This contains the information about this stop. /// - /// @return + /// \return /// \b true if we should stop, \b false otherwise. - //------------------------------------------------------------------ bool ShouldStop(StoppointCallbackContext *context) override; - //------------------------------------------------------------------ /// Standard Dump method /// - /// @param[in] context + /// \param[in] context /// The stream to dump this output. - //------------------------------------------------------------------ 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. /// - /// @param[in] context + /// \param[in] context /// \a owner is the Breakpoint Location to add. - //------------------------------------------------------------------ void AddOwner(const lldb::BreakpointLocationSP &owner); - //------------------------------------------------------------------ /// This method returns the number of breakpoint locations currently located /// at this breakpoint site. /// - /// @return + /// \return /// The number of owners. - //------------------------------------------------------------------ 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 /// - /// @param[in] index + /// \param[in] index /// The index in the list of owners for which you wish the owner location. - /// @return + /// \return /// A shared pointer to the breakpoint location at that index. - //------------------------------------------------------------------ lldb::BreakpointLocationSP GetOwnerAtIndex(size_t idx); - //------------------------------------------------------------------ /// This method copies the breakpoint site's owners into a new collection. /// It does this while the owners mutex is locked. /// - /// @param[out] out_collection + /// \param[out] out_collection /// The BreakpointLocationCollection into which to put the owners /// of this breakpoint site. /// - /// @return + /// \return /// The number of elements copied into out_collection. - //------------------------------------------------------------------ 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. /// - /// @param[in] thread + /// \param[in] thread /// The thread against which to test. /// /// return /// \b true if the collection contains at least one location that /// would be valid for this thread, false otherwise. - //------------------------------------------------------------------ bool ValidForThisThread(Thread *thread); - //------------------------------------------------------------------ /// 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. /// - /// @param[in] s + /// \param[in] s /// The stream to which to print the description. /// - /// @param[in] level + /// \param[in] level /// The description level that indicates the detail level to /// provide. /// - /// @see lldb::DescriptionLevel - //------------------------------------------------------------------ + /// \see lldb::DescriptionLevel void GetDescription(Stream *s, lldb::DescriptionLevel level); - //------------------------------------------------------------------ /// Tell whether a breakpoint has a location at this site. /// - /// @param[in] bp_id + /// \param[in] bp_id /// The breakpoint id to query. /// - /// @result + /// \result /// \b true if bp_id has a location that is at this site, /// \b false otherwise. - //------------------------------------------------------------------ bool IsBreakpointAtThisSite(lldb::break_id_t bp_id); - //------------------------------------------------------------------ /// Tell whether ALL the breakpoints in the location collection are /// internal. /// - /// @result + /// \result /// \b true if all breakpoint locations are owned by internal breakpoints, /// \b false otherwise. - //------------------------------------------------------------------ bool IsInternal() const; BreakpointSite::Type GetType() const { return m_type; } @@ -242,13 +199,11 @@ private: void BumpHitCounts(); - //------------------------------------------------------------------ /// The method removes the owner at \a break_loc_id from this breakpoint /// list. /// - /// @param[in] context + /// \param[in] context /// \a break_loc_id is the Breakpoint Location to remove. - //------------------------------------------------------------------ size_t RemoveOwner(lldb::break_id_t break_id, lldb::break_id_t break_loc_id); BreakpointSite::Type m_type; ///< The type of this breakpoint site. diff --git a/include/lldb/Breakpoint/BreakpointSiteList.h b/include/lldb/Breakpoint/BreakpointSiteList.h index 2f2e31cd31269..b10d119fcce63 100644 --- a/include/lldb/Breakpoint/BreakpointSiteList.h +++ b/include/lldb/Breakpoint/BreakpointSiteList.h @@ -1,9 +1,8 @@ //===-- BreakpointSiteList.h ------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -18,11 +17,9 @@ namespace lldb_private { -//---------------------------------------------------------------------- -/// @class BreakpointSiteList BreakpointSiteList.h +/// \class BreakpointSiteList BreakpointSiteList.h /// "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 // do quick lookups into the map (using GetMap). @@ -30,123 +27,101 @@ class BreakpointSiteList { friend class Process; public: - //------------------------------------------------------------------ /// Default constructor makes an empty list. - //------------------------------------------------------------------ BreakpointSiteList(); - //------------------------------------------------------------------ /// Destructor, currently does nothing. - //------------------------------------------------------------------ ~BreakpointSiteList(); - //------------------------------------------------------------------ /// Add a BreakpointSite to the list. /// - /// @param[in] bp_site_sp + /// \param[in] bp_site_sp /// A shared pointer to a breakpoint site being added to the list. /// - /// @return + /// \return /// The ID of the BreakpointSite in the list. - //------------------------------------------------------------------ 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. /// - /// @param[in] addr + /// \param[in] addr /// The address to look for. /// - /// @result + /// \result /// A shared pointer to the breakpoint site. May contain a NULL /// pointer if no breakpoint site exists with a matching address. - //------------------------------------------------------------------ lldb::BreakpointSiteSP FindByAddress(lldb::addr_t addr); - //------------------------------------------------------------------ /// Returns a shared pointer to the breakpoint site with id \a breakID. /// - /// @param[in] breakID + /// \param[in] breakID /// The breakpoint site ID to seek for. /// - /// @result + /// \result /// A shared pointer to the breakpoint site. May contain a NULL pointer if /// the /// breakpoint doesn't exist. - //------------------------------------------------------------------ lldb::BreakpointSiteSP FindByID(lldb::break_id_t breakID); - //------------------------------------------------------------------ /// Returns a shared pointer to the breakpoint site with id \a breakID - /// const version. /// - /// @param[in] breakID + /// \param[in] breakID /// The breakpoint site ID to seek for. /// - /// @result + /// \result /// A shared pointer to the breakpoint site. May contain a NULL pointer if /// the /// breakpoint doesn't exist. - //------------------------------------------------------------------ const lldb::BreakpointSiteSP FindByID(lldb::break_id_t breakID) const; - //------------------------------------------------------------------ /// Returns the breakpoint site id to the breakpoint site at address \a /// addr. /// - /// @param[in] addr + /// \param[in] addr /// The address to match. /// - /// @result + /// \result /// The ID of the breakpoint site, or LLDB_INVALID_BREAK_ID. - //------------------------------------------------------------------ lldb::break_id_t FindIDByAddress(lldb::addr_t addr); - //------------------------------------------------------------------ /// Returns whether the breakpoint site \a bp_site_id has \a bp_id // as one of its owners. /// - /// @param[in] bp_site_id + /// \param[in] bp_site_id /// The breakpoint site id to query. /// - /// @param[in] bp_id + /// \param[in] bp_id /// The breakpoint id to look for in \a bp_site_id. /// - /// @result + /// \result /// True if \a bp_site_id exists in the site list AND \a bp_id is one of the /// owners of that site. - //------------------------------------------------------------------ bool BreakpointSiteContainsBreakpoint(lldb::break_id_t bp_site_id, lldb::break_id_t bp_id); void ForEach(std::function<void(BreakpointSite *)> const &callback); - //------------------------------------------------------------------ /// Removes the breakpoint site given by \b breakID from this list. /// - /// @param[in] breakID + /// \param[in] breakID /// The breakpoint site index to remove. /// - /// @result + /// \result /// \b true if the breakpoint site \a breakID was in the list. - //------------------------------------------------------------------ bool Remove(lldb::break_id_t breakID); - //------------------------------------------------------------------ /// Removes the breakpoint site at address \a addr from this list. /// - /// @param[in] addr + /// \param[in] addr /// The address from which to remove a breakpoint site. /// - /// @result + /// \result /// \b true if \a addr had a breakpoint site to remove from the list. - //------------------------------------------------------------------ bool RemoveByAddress(lldb::addr_t addr); bool FindInRange(lldb::addr_t lower_bound, lldb::addr_t upper_bound, @@ -155,27 +130,23 @@ public: typedef void (*BreakpointSiteSPMapFunc)(lldb::BreakpointSiteSP &bp, void *baton); - //------------------------------------------------------------------ /// 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 + /// \param[in] context /// This contains the information about this stop. /// - /// @param[in] breakID + /// \param[in] breakID /// This break ID that we hit. /// - /// @return + /// \return /// \b true if we should stop, \b false otherwise. - //------------------------------------------------------------------ bool ShouldStop(StoppointCallbackContext *context, lldb::break_id_t breakID); - //------------------------------------------------------------------ /// Returns the number of elements in the list. /// - /// @result + /// \result /// The number of elements. - //------------------------------------------------------------------ size_t GetSize() const { std::lock_guard<std::recursive_mutex> guard(m_mutex); return m_bp_site_list.size(); diff --git a/include/lldb/Breakpoint/Stoppoint.h b/include/lldb/Breakpoint/Stoppoint.h index 78baa6ce6cbb1..f20b100740510 100644 --- a/include/lldb/Breakpoint/Stoppoint.h +++ b/include/lldb/Breakpoint/Stoppoint.h @@ -1,9 +1,8 @@ //===-- Stoppoint.h ---------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -17,16 +16,12 @@ namespace lldb_private { class Stoppoint { public: - //------------------------------------------------------------------ // Constructors and Destructors - //------------------------------------------------------------------ Stoppoint(); virtual ~Stoppoint(); - //------------------------------------------------------------------ // Methods - //------------------------------------------------------------------ virtual void Dump(Stream *) = 0; virtual bool IsEnabled() = 0; @@ -41,9 +36,7 @@ protected: lldb::break_id_t m_bid; private: - //------------------------------------------------------------------ // For Stoppoint only - //------------------------------------------------------------------ DISALLOW_COPY_AND_ASSIGN(Stoppoint); }; diff --git a/include/lldb/Breakpoint/StoppointCallbackContext.h b/include/lldb/Breakpoint/StoppointCallbackContext.h index 1dac342d33255..c1724a6b276f8 100644 --- a/include/lldb/Breakpoint/StoppointCallbackContext.h +++ b/include/lldb/Breakpoint/StoppointCallbackContext.h @@ -1,9 +1,8 @@ //===-- StoppointCallbackContext.h ------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -15,18 +14,14 @@ namespace lldb_private { -//---------------------------------------------------------------------- -/// @class StoppointCallbackContext StoppointCallbackContext.h +/// \class StoppointCallbackContext StoppointCallbackContext.h /// "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. -//---------------------------------------------------------------------- class StoppointCallbackContext { public: @@ -35,17 +30,13 @@ public: StoppointCallbackContext(Event *event, const ExecutionContext &exe_ctx, bool synchronously = false); - //------------------------------------------------------------------ /// Clear the object's state. /// /// Sets the event, process and thread to NULL, and the frame index to an /// invalid value. - //------------------------------------------------------------------ void Clear(); - //------------------------------------------------------------------ // Member variables - //------------------------------------------------------------------ Event *event; // This is the event, the callback can modify this to indicate // the meaning of the breakpoint hit ExecutionContextRef diff --git a/include/lldb/Breakpoint/StoppointLocation.h b/include/lldb/Breakpoint/StoppointLocation.h index 5c78d2e3d659b..3926f452e564c 100644 --- a/include/lldb/Breakpoint/StoppointLocation.h +++ b/include/lldb/Breakpoint/StoppointLocation.h @@ -1,9 +1,8 @@ //===-- StoppointLocation.h -------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -18,9 +17,7 @@ namespace lldb_private { class StoppointLocation { public: - //------------------------------------------------------------------ // Constructors and Destructors - //------------------------------------------------------------------ StoppointLocation(lldb::break_id_t bid, lldb::addr_t m_addr, bool hardware); StoppointLocation(lldb::break_id_t bid, lldb::addr_t m_addr, @@ -28,13 +25,9 @@ public: virtual ~StoppointLocation(); - //------------------------------------------------------------------ // Operators - //------------------------------------------------------------------ - //------------------------------------------------------------------ // Methods - //------------------------------------------------------------------ virtual lldb::addr_t GetLoadAddress() const { return m_addr; } virtual void SetLoadAddress(lldb::addr_t addr) { m_addr = addr; } @@ -60,9 +53,7 @@ public: lldb::break_id_t GetID() const { return m_loc_id; } protected: - //------------------------------------------------------------------ // Classes that inherit from StoppointLocation can see and modify these - //------------------------------------------------------------------ lldb::break_id_t m_loc_id; // Stoppoint location ID lldb::addr_t m_addr; // The load address of this stop point. The base Stoppoint doesn't @@ -85,11 +76,9 @@ protected: void DecrementHitCount(); private: - //------------------------------------------------------------------ // For StoppointLocation only - //------------------------------------------------------------------ DISALLOW_COPY_AND_ASSIGN(StoppointLocation); - StoppointLocation(); // Disallow default constructor + StoppointLocation() = delete; }; } // namespace lldb_private diff --git a/include/lldb/Breakpoint/Watchpoint.h b/include/lldb/Breakpoint/Watchpoint.h index 2aaae37eb095e..e71f89b3e384e 100644 --- a/include/lldb/Breakpoint/Watchpoint.h +++ b/include/lldb/Breakpoint/Watchpoint.h @@ -1,9 +1,8 @@ //===-- Watchpoint.h --------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -32,9 +31,9 @@ public: ~WatchpointEventData() override; - static const ConstString &GetFlavorString(); + static ConstString GetFlavorString(); - const ConstString &GetFlavor() const override; + ConstString GetFlavor() const override; lldb::WatchpointEventType GetWatchpointEventType() const; @@ -98,30 +97,26 @@ public: Target &GetTarget() { return m_target; } const Status &GetError() { return m_error; } - //------------------------------------------------------------------ /// Returns the WatchpointOptions structure set for this watchpoint. /// - /// @return + /// \return /// A pointer to this watchpoint's WatchpointOptions. - //------------------------------------------------------------------ WatchpointOptions *GetOptions() { return &m_options; } - //------------------------------------------------------------------ /// Set the callback action invoked when the watchpoint is hit. /// - /// @param[in] callback + /// \param[in] callback /// The method that will get called when the watchpoint is hit. - /// @param[in] callback_baton + /// \param[in] callback_baton /// A void * pointer that will get passed back to the callback function. - /// @param[in] is_synchronous + /// \param[in] is_synchronous /// If \b true the callback will be run on the private event thread /// before the stop event gets reported. If false, the callback will get /// handled on the public event thread after the stop has been posted. /// - /// @return + /// \return /// \b true if the process should stop when you hit the watchpoint. /// \b false if it should continue. - //------------------------------------------------------------------ void SetCallback(WatchpointHitCallback callback, void *callback_baton, bool is_synchronous = false); @@ -131,36 +126,28 @@ public: void ClearCallback(); - //------------------------------------------------------------------ /// Invoke the callback action when the watchpoint is hit. /// - /// @param[in] context + /// \param[in] context /// Described the watchpoint event. /// - /// @return + /// \return /// \b true if the target should stop at this watchpoint and \b false not. - //------------------------------------------------------------------ bool InvokeCallback(StoppointCallbackContext *context); - //------------------------------------------------------------------ // Condition - //------------------------------------------------------------------ - //------------------------------------------------------------------ /// Set the watchpoint's condition. /// - /// @param[in] condition + /// \param[in] condition /// The condition expression to evaluate when the watchpoint is hit. /// Pass in nullptr to clear the condition. - //------------------------------------------------------------------ void SetCondition(const char *condition); - //------------------------------------------------------------------ /// Return a pointer to the text of the condition expression. /// - /// @return + /// \return /// A pointer to the condition expression text, or nullptr if no // condition has been set. - //------------------------------------------------------------------ const char *GetConditionText() const; void TurnOnEphemeralMode(); @@ -214,7 +201,7 @@ private: // the callback machinery. bool m_being_created; - std::unique_ptr<UserExpression> m_condition_ap; // The condition to test. + std::unique_ptr<UserExpression> m_condition_up; // The condition to test. void SetID(lldb::watch_id_t id) { m_loc_id = id; } diff --git a/include/lldb/Breakpoint/WatchpointList.h b/include/lldb/Breakpoint/WatchpointList.h index 9bfa817456bc8..98c64832d46dc 100644 --- a/include/lldb/Breakpoint/WatchpointList.h +++ b/include/lldb/Breakpoint/WatchpointList.h @@ -1,9 +1,8 @@ //===-- WatchpointList.h ----------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -19,12 +18,10 @@ namespace lldb_private { -//---------------------------------------------------------------------- -/// @class WatchpointList WatchpointList.h "lldb/Breakpoint/WatchpointList.h" +/// \class WatchpointList WatchpointList.h "lldb/Breakpoint/WatchpointList.h" /// 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 @@ -34,193 +31,157 @@ class WatchpointList { friend class Target; public: - //------------------------------------------------------------------ /// Default constructor makes an empty list. - //------------------------------------------------------------------ WatchpointList(); - //------------------------------------------------------------------ /// Destructor, currently does nothing. - //------------------------------------------------------------------ ~WatchpointList(); - //------------------------------------------------------------------ /// Add a Watchpoint to the list. /// - /// @param[in] wp_sp + /// \param[in] wp_sp /// A shared pointer to a watchpoint being added to the list. /// - /// @return + /// \return /// The ID of the Watchpoint in the list. - //------------------------------------------------------------------ lldb::watch_id_t Add(const lldb::WatchpointSP &wp_sp, bool notify); - //------------------------------------------------------------------ /// Standard "Dump" method. - //------------------------------------------------------------------ void Dump(Stream *s) const; - //------------------------------------------------------------------ /// Dump with lldb::DescriptionLevel. - //------------------------------------------------------------------ void DumpWithLevel(Stream *s, lldb::DescriptionLevel description_level) const; - //------------------------------------------------------------------ /// Returns a shared pointer to the watchpoint at address \a addr - const /// version. /// - /// @param[in] addr + /// \param[in] addr /// The address to look for. /// - /// @result + /// \result /// A shared pointer to the watchpoint. May contain a NULL /// pointer if the watchpoint doesn't exist. - //------------------------------------------------------------------ const lldb::WatchpointSP FindByAddress(lldb::addr_t addr) const; - //------------------------------------------------------------------ /// Returns a shared pointer to the watchpoint with watchpoint spec \a spec /// - const version. /// - /// @param[in] spec + /// \param[in] spec /// The watchpoint spec to look for. /// - /// @result + /// \result /// A shared pointer to the watchpoint. May contain a NULL /// pointer if the watchpoint doesn't exist. - //------------------------------------------------------------------ const lldb::WatchpointSP FindBySpec(std::string spec) const; - //------------------------------------------------------------------ /// Returns a shared pointer to the watchpoint with id \a watchID, const /// version. /// - /// @param[in] watchID + /// \param[in] watchID /// The watchpoint location ID to seek for. /// - /// @result + /// \result /// A shared pointer to the watchpoint. May contain a NULL /// pointer if the watchpoint doesn't exist. - //------------------------------------------------------------------ lldb::WatchpointSP FindByID(lldb::watch_id_t watchID) const; - //------------------------------------------------------------------ /// Returns the watchpoint id to the watchpoint at address \a addr. /// - /// @param[in] addr + /// \param[in] addr /// The address to match. /// - /// @result + /// \result /// The ID of the watchpoint, or LLDB_INVALID_WATCH_ID. - //------------------------------------------------------------------ lldb::watch_id_t FindIDByAddress(lldb::addr_t addr); - //------------------------------------------------------------------ /// Returns the watchpoint id to the watchpoint with watchpoint spec \a /// spec. /// - /// @param[in] spec + /// \param[in] spec /// The watchpoint spec to match. /// - /// @result + /// \result /// The ID of the watchpoint, or LLDB_INVALID_WATCH_ID. - //------------------------------------------------------------------ lldb::watch_id_t FindIDBySpec(std::string spec); - //------------------------------------------------------------------ /// Returns a shared pointer to the watchpoint with index \a i. /// - /// @param[in] i + /// \param[in] i /// The watchpoint index to seek for. /// - /// @result + /// \result /// A shared pointer to the watchpoint. May contain a NULL pointer if /// the watchpoint doesn't exist. - //------------------------------------------------------------------ lldb::WatchpointSP GetByIndex(uint32_t i); - //------------------------------------------------------------------ /// Returns a shared pointer to the watchpoint with index \a i, const /// version. /// - /// @param[in] i + /// \param[in] i /// The watchpoint index to seek for. /// - /// @result + /// \result /// A shared pointer to the watchpoint. May contain a NULL pointer if /// the watchpoint location doesn't exist. - //------------------------------------------------------------------ const lldb::WatchpointSP GetByIndex(uint32_t i) const; - //------------------------------------------------------------------ /// Removes the watchpoint given by \b watchID from this list. /// - /// @param[in] watchID + /// \param[in] watchID /// The watchpoint ID to remove. /// - /// @result + /// \result /// \b true if the watchpoint \a watchID was in the list. - //------------------------------------------------------------------ bool Remove(lldb::watch_id_t watchID, bool notify); - //------------------------------------------------------------------ /// Returns the number hit count of all watchpoints in this list. /// - /// @result + /// \result /// Hit count of all watchpoints in this list. - //------------------------------------------------------------------ uint32_t GetHitCount() const; - //------------------------------------------------------------------ /// Enquires of the watchpoint in this list with ID \a watchID whether we /// should stop. /// - /// @param[in] context + /// \param[in] context /// This contains the information about this stop. /// - /// @param[in] watchID + /// \param[in] watchID /// This watch ID that we hit. /// - /// @return + /// \return /// \b true if we should stop, \b false otherwise. - //------------------------------------------------------------------ bool ShouldStop(StoppointCallbackContext *context, lldb::watch_id_t watchID); - //------------------------------------------------------------------ /// Returns the number of elements in this watchpoint list. /// - /// @result + /// \result /// The number of elements. - //------------------------------------------------------------------ size_t GetSize() const { std::lock_guard<std::recursive_mutex> guard(m_mutex); return m_watchpoints.size(); } - //------------------------------------------------------------------ /// Print a description of the watchpoints in this list to the stream \a s. /// - /// @param[in] s + /// \param[in] s /// The stream to which to print the description. /// - /// @param[in] level + /// \param[in] level /// The description level that indicates the detail level to /// provide. /// - /// @see lldb::DescriptionLevel - //------------------------------------------------------------------ + /// \see lldb::DescriptionLevel void GetDescription(Stream *s, lldb::DescriptionLevel level); void SetEnabledAll(bool enabled); void RemoveAll(bool notify); - //------------------------------------------------------------------ /// Sets the passed in Locker to hold the Watchpoint List mutex. /// - /// @param[in] locker + /// \param[in] locker /// The locker object that is set. - //------------------------------------------------------------------ void GetListMutex(std::unique_lock<std::recursive_mutex> &lock); protected: diff --git a/include/lldb/Breakpoint/WatchpointOptions.h b/include/lldb/Breakpoint/WatchpointOptions.h index 0f4f399b5e4de..b395dde21901e 100644 --- a/include/lldb/Breakpoint/WatchpointOptions.h +++ b/include/lldb/Breakpoint/WatchpointOptions.h @@ -1,9 +1,8 @@ //===-- WatchpointOptions.h -------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -19,49 +18,38 @@ namespace lldb_private { -//---------------------------------------------------------------------- -/// @class WatchpointOptions WatchpointOptions.h +/// \class WatchpointOptions WatchpointOptions.h /// "lldb/Breakpoint/WatchpointOptions.h" Class that manages the options on a /// watchpoint. -//---------------------------------------------------------------------- class WatchpointOptions { public: - //------------------------------------------------------------------ // Constructors and Destructors - //------------------------------------------------------------------ - //------------------------------------------------------------------ /// Default constructor. The watchpoint is enabled, and has no condition, /// callback, ignore count, etc... - //------------------------------------------------------------------ WatchpointOptions(); WatchpointOptions(const WatchpointOptions &rhs); static WatchpointOptions *CopyOptionsNoCallback(WatchpointOptions &rhs); - //------------------------------------------------------------------ /// This constructor allows you to specify all the watchpoint options. /// - /// @param[in] callback + /// \param[in] callback /// This is the plugin for some code that gets run, returns \b true if we /// are to stop. /// - /// @param[in] baton + /// \param[in] baton /// Client data that will get passed to the callback. /// - /// @param[in] thread_id + /// \param[in] thread_id /// Only stop if \a thread_id hits the watchpoint. - //------------------------------------------------------------------ WatchpointOptions(WatchpointHitCallback callback, void *baton, lldb::tid_t thread_id = LLDB_INVALID_THREAD_ID); virtual ~WatchpointOptions(); - //------------------------------------------------------------------ // Operators - //------------------------------------------------------------------ const WatchpointOptions &operator=(const WatchpointOptions &rhs); - //------------------------------------------------------------------ // Callbacks // // Watchpoint callbacks come in two forms, synchronous and asynchronous. @@ -89,36 +77,30 @@ public: // take a bit of plumbing to get // that to work. // - //------------------------------------------------------------------ - //------------------------------------------------------------------ /// Adds a callback to the watchpoint option set. /// - /// @param[in] callback + /// \param[in] callback /// The function to be called when the watchpoint gets hit. /// - /// @param[in] baton_sp + /// \param[in] baton_sp /// A baton which will get passed back to the callback when it is invoked. /// - /// @param[in] synchronous + /// \param[in] synchronous /// Whether this is a synchronous or asynchronous callback. See discussion /// above. - //------------------------------------------------------------------ void SetCallback(WatchpointHitCallback callback, const lldb::BatonSP &baton_sp, bool synchronous = false); - //------------------------------------------------------------------ /// Remove the callback from this option set. - //------------------------------------------------------------------ void ClearCallback(); // 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. /// - /// @param[in] context + /// \param[in] context /// The context in which the callback is to be invoked. This includes the /// stop event, the /// execution context of the stop (since you might hit the same watchpoint @@ -126,77 +108,60 @@ public: /// whether we are currently executing synchronous or asynchronous /// callbacks. /// - /// @param[in] watch_id + /// \param[in] watch_id /// The watchpoint ID that owns this option set. /// - /// @return + /// \return /// The callback return value. - //------------------------------------------------------------------ bool InvokeCallback(StoppointCallbackContext *context, lldb::user_id_t watch_id); - //------------------------------------------------------------------ /// Used in InvokeCallback to tell whether it is the right time to run this /// kind of callback. /// - /// @return + /// \return /// The synchronicity of our callback. - //------------------------------------------------------------------ bool IsCallbackSynchronous() { return m_callback_is_synchronous; } - //------------------------------------------------------------------ /// Fetch the baton from the callback. /// - /// @return + /// \return /// The baton. - //------------------------------------------------------------------ Baton *GetBaton(); - //------------------------------------------------------------------ /// Fetch a const version of the baton from the callback. /// - /// @return + /// \return /// The baton. - //------------------------------------------------------------------ const Baton *GetBaton() const; - //------------------------------------------------------------------ /// Return the current thread spec for this option. This will return nullptr /// if the no thread specifications have been set for this Option yet. - /// @return + /// \return /// The thread specification pointer for this option, or nullptr if none /// has /// been set yet. - //------------------------------------------------------------------ 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 /// ThreadSpec items for this option. - //------------------------------------------------------------------ ThreadSpec *GetThreadSpec(); void SetThreadID(lldb::tid_t thread_id); void GetDescription(Stream *s, lldb::DescriptionLevel level) const; - //------------------------------------------------------------------ /// Get description for callback only. - //------------------------------------------------------------------ void GetCallbackDescription(Stream *s, lldb::DescriptionLevel level) const; - //------------------------------------------------------------------ /// Returns true if the watchpoint option has a callback set. - //------------------------------------------------------------------ bool HasCallback(); - //------------------------------------------------------------------ /// This is the default empty callback. - /// @return + /// \return /// The thread id for which the watchpoint hit will stop, /// LLDB_INVALID_THREAD_ID for all threads. - //------------------------------------------------------------------ static bool NullCallback(void *baton, StoppointCallbackContext *context, lldb::user_id_t watch_id); @@ -219,19 +184,15 @@ public: }; protected: - //------------------------------------------------------------------ // Classes that inherit from WatchpointOptions can see and modify these - //------------------------------------------------------------------ private: - //------------------------------------------------------------------ // For WatchpointOptions only - //------------------------------------------------------------------ WatchpointHitCallback m_callback; // This is the callback function pointer lldb::BatonSP m_callback_baton_sp; // This is the client data for the callback bool m_callback_is_synchronous; std::unique_ptr<ThreadSpec> - m_thread_spec_ap; // Thread for which this watchpoint will take + m_thread_spec_up; // Thread for which this watchpoint will take }; } // namespace lldb_private diff --git a/include/lldb/Core/Address.h b/include/lldb/Core/Address.h index a02a0d45a0821..080c00e76328e 100644 --- a/include/lldb/Core/Address.h +++ b/include/lldb/Core/Address.h @@ -1,9 +1,8 @@ //===-- Address.h -----------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -20,39 +19,17 @@ namespace lldb_private { class Block; -} -namespace lldb_private { class CompileUnit; -} -namespace lldb_private { class ExecutionContextScope; -} -namespace lldb_private { class Function; -} -namespace lldb_private { class SectionList; -} -namespace lldb_private { class Stream; -} -namespace lldb_private { class Symbol; -} -namespace lldb_private { class SymbolContext; -} -namespace lldb_private { class Target; -} -namespace lldb_private { struct LineEntry; -} -namespace lldb_private { - -//---------------------------------------------------------------------- -/// @class Address Address.h "lldb/Core/Address.h" +/// \class Address Address.h "lldb/Core/Address.h" /// A section + offset based address class. /// /// The Address class allows addresses to be relative to a section that can @@ -60,8 +37,8 @@ namespace lldb_private { /// 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 +/// \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 @@ -79,14 +56,11 @@ namespace lldb_private { /// 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. - //------------------------------------------------------------------ - typedef enum { + enum DumpStyle { DumpStyleInvalid, ///< Invalid dump style DumpStyleSectionNameOffset, ///< Display as the section name + offset. ///< \code @@ -102,7 +76,7 @@ public: /// // address for printf in libSystem.B.dylib as a file address /// 0x000000000005dcff \endcode DumpStyleModuleWithFileAddress, ///< Display as the file address with the - ///module name prepended (if any). + /// module name prepended (if any). ///< \code /// // address for printf in libSystem.B.dylib as a file address /// libSystem.B.dylib[0x000000000005dcff] \endcode @@ -111,54 +85,48 @@ public: /// // address for printf in libSystem.B.dylib as a load address /// 0x00007fff8306bcff \endcode DumpStyleResolvedDescription, ///< Display the details about what an address - ///resolves to. This can + /// resolves to. This can ///< be anything from a symbol context summary (module, function/symbol, ///< and file and line), to information about what the pointer points to ///< if the address is in a section (section of pointers, c strings, etc). DumpStyleResolvedDescriptionNoModule, DumpStyleResolvedDescriptionNoFunctionArguments, DumpStyleNoFunctionName, ///< Elide the function name; display an offset - ///into the current function. + /// into the current function. ///< Used primarily in disassembly symbolication DumpStyleDetailedSymbolContext, ///< Detailed symbol context information for - ///an address for all symbol + /// an address for all symbol ///< context members. DumpStyleResolvedPointerDescription ///< Dereference a pointer at the - ///current address and then lookup the + /// current address and then lookup the ///< dereferenced address using DumpStyleResolvedDescription - } DumpStyle; + }; - //------------------------------------------------------------------ /// Default constructor. /// /// Initialize with a invalid section (NULL) and an invalid offset /// (LLDB_INVALID_ADDRESS). - //------------------------------------------------------------------ Address() : m_section_wp(), m_offset(LLDB_INVALID_ADDRESS) {} - //------------------------------------------------------------------ /// Copy constructor /// /// Makes a copy of the another Address object \a rhs. /// - /// @param[in] rhs + /// \param[in] rhs /// A const Address object reference to copy. - //------------------------------------------------------------------ Address(const Address &rhs) : m_section_wp(rhs.m_section_wp), m_offset(rhs.m_offset) {} - //------------------------------------------------------------------ /// Construct with a section pointer and offset. /// /// Initialize the address with the supplied \a section and \a offset. /// - /// @param[in] section + /// \param[in] section /// A section pointer to a valid lldb::Section, or NULL if the /// address doesn't have a section or will get resolved later. /// - /// @param[in] offset + /// \param[in] offset /// The offset in bytes into \a section. - //------------------------------------------------------------------ Address(const lldb::SectionSP §ion_sp, lldb::addr_t offset) : m_section_wp(), // Don't init with section_sp in case section_sp is // invalid (the weak_ptr will throw) @@ -167,63 +135,53 @@ public: m_section_wp = section_sp; } - //------------------------------------------------------------------ /// Construct with a virtual address and section list. /// /// Initialize and resolve the address with the supplied virtual address \a /// file_addr. /// - /// @param[in] file_addr + /// \param[in] file_addr /// A virtual file address. /// - /// @param[in] section_list + /// \param[in] section_list /// A list of sections, one of which may contain the \a file_addr. - //------------------------------------------------------------------ Address(lldb::addr_t file_addr, const SectionList *section_list); Address(lldb::addr_t abs_addr); -//------------------------------------------------------------------ /// Assignment operator. /// /// Copies the address value from another Address object \a rhs into \a this /// object. /// -/// @param[in] rhs +/// \param[in] rhs /// A const Address object reference to copy. /// -/// @return +/// \return /// A const Address object reference to \a this. -//------------------------------------------------------------------ -#ifndef SWIG const Address &operator=(const Address &rhs); -#endif - //------------------------------------------------------------------ /// Clear the object's state. /// /// Sets the section to an invalid value (NULL) and an invalid offset /// (LLDB_INVALID_ADDRESS). - //------------------------------------------------------------------ void Clear() { m_section_wp.reset(); m_offset = LLDB_INVALID_ADDRESS; } - //------------------------------------------------------------------ /// Compare two Address objects. /// - /// @param[in] lhs + /// \param[in] lhs /// The Left Hand Side const Address object reference. /// - /// @param[in] rhs + /// \param[in] rhs /// The Right Hand Side const Address object reference. /// - /// @return - /// @li -1 if lhs < rhs - /// @li 0 if lhs == rhs - /// @li 1 if lhs > rhs - //------------------------------------------------------------------ + /// \return + /// \li -1 if lhs < rhs + /// \li 0 if lhs == rhs + /// \li 1 if lhs > rhs static int CompareFileAddress(const Address &lhs, const Address &rhs); static int CompareLoadAddress(const Address &lhs, const Address &rhs, @@ -242,51 +200,46 @@ 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. /// - /// @param[in] s + /// \param[in] s /// The stream to which to dump the object description. /// - /// @param[in] style + /// \param[in] style /// The display style for the address. /// - /// @param[in] fallback_style + /// \param[in] fallback_style /// The display style for the address. /// - /// @return + /// \return /// Returns \b true if the address was able to be displayed. /// File and load addresses may be unresolved and it may not be /// possible to display a valid value, \b false will be returned /// in such cases. /// - /// @see Address::DumpStyle - //------------------------------------------------------------------ + /// \see Address::DumpStyle bool Dump(Stream *s, ExecutionContextScope *exe_scope, DumpStyle style, DumpStyle fallback_style = DumpStyleInvalid, uint32_t addr_byte_size = UINT32_MAX) 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. /// - /// @return + /// \return /// The valid file virtual address, or LLDB_INVALID_ADDRESS if /// the address doesn't have a file virtual address (image is /// from memory only with no representation on disk). - //------------------------------------------------------------------ lldb::addr_t GetFileAddress() const; - //------------------------------------------------------------------ /// Get the load address. /// /// If an address comes from a file on disk that has section relative @@ -296,13 +249,11 @@ public: /// loaded/unloaded. If a section is loaded, then the load address can be /// resolved. /// - /// @return + /// \return /// The valid load virtual address, or LLDB_INVALID_ADDRESS if /// the address is currently not loaded. - //------------------------------------------------------------------ lldb::addr_t GetLoadAddress(Target *target) const; - //------------------------------------------------------------------ /// Get the load address as a callable code load address. /// /// This function will first resolve its address to a load address. Then, if @@ -312,14 +263,12 @@ public: /// target) that are required when changing the program counter to setting a /// return address. /// - /// @return + /// \return /// The valid load virtual address, or LLDB_INVALID_ADDRESS if /// the address is currently not loaded. - //------------------------------------------------------------------ lldb::addr_t GetCallableLoadAddress(Target *target, bool is_indirect = false) const; - //------------------------------------------------------------------ /// Get the load address as an opcode load address. /// /// This function will first resolve its address to a load address. Then, if @@ -331,25 +280,21 @@ public: /// special purposes. The result of this function can be used to safely /// write a software breakpoint trap to memory. /// - /// @return + /// \return /// The valid load virtual address with extra callable bits /// removed, or LLDB_INVALID_ADDRESS if the address is currently /// not loaded. - //------------------------------------------------------------------ lldb::addr_t GetOpcodeLoadAddress( Target *target, AddressClass addr_class = AddressClass::eInvalid) const; - //------------------------------------------------------------------ /// Get the section relative offset value. /// - /// @return + /// \return /// The current offset, or LLDB_INVALID_ADDRESS if this address /// doesn't contain a valid offset. - //------------------------------------------------------------------ lldb::addr_t GetOffset() const { return m_offset; } - //------------------------------------------------------------------ /// Check if an address is section offset. /// /// When converting a virtual file or load address into a section offset @@ -358,49 +303,41 @@ public: /// returns true if the current value contained in this object is section /// offset based. /// - /// @return + /// \return /// Returns \b true if the address has a valid section and /// offset, \b false otherwise. - //------------------------------------------------------------------ bool IsSectionOffset() const { return IsValid() && (GetSection().get() != nullptr); } - //------------------------------------------------------------------ /// Check if the object state is valid. /// /// A valid Address object contains either a section pointer and /// offset (for section offset based addresses), or just a valid offset /// (for absolute addresses that have no section). /// - /// @return + /// \return /// Returns \b true if the offset is valid, \b false /// otherwise. - //------------------------------------------------------------------ bool IsValid() const { return m_offset != LLDB_INVALID_ADDRESS; } - //------------------------------------------------------------------ /// Get the memory cost of this object. /// - /// @return + /// \return /// The number of bytes that this object occupies in memory. - //------------------------------------------------------------------ size_t MemorySize() const; - //------------------------------------------------------------------ /// Resolve a file virtual address using a section list. /// /// Given a list of sections, attempt to resolve \a addr as an offset into /// one of the file sections. /// - /// @return + /// \return /// Returns \b true if \a addr was able to be resolved, \b false /// otherwise. - //------------------------------------------------------------------ bool ResolveAddressUsingFileSections(lldb::addr_t addr, const SectionList *sections); - //------------------------------------------------------------------ /// Set the address to represent \a load_addr. /// /// The address will attempt to find a loaded section within \a target that @@ -408,25 +345,24 @@ public: /// 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 + /// \param[in] load_addr /// A load address from a current process. /// - /// @param[in] target + /// \param[in] target /// The target to use when trying resolve the address into /// a section + offset. The Target's SectionLoadList object /// is used to resolve the address. /// - /// @param[in] allow_section_end + /// \param[in] allow_section_end /// If true, treat an address pointing to the end of the module as /// belonging to that module. /// - /// @return + /// \return /// Returns \b true if the load address was resolved to be /// section/offset, \b false otherwise. It is often ok for an - /// address no not resolve to a section in a module, this often + /// address to not resolve to a section in a module, this often /// happens for JIT'ed code, or any load addresses on the stack /// or heap. - //------------------------------------------------------------------ bool SetLoadAddress(lldb::addr_t load_addr, Target *target, bool allow_section_end = false); @@ -437,34 +373,28 @@ public: bool SetCallableLoadAddress(lldb::addr_t load_addr, Target *target); - //------------------------------------------------------------------ /// Get accessor for the module for this address. /// - /// @return + /// \return /// Returns the Module pointer that this address is an offset /// in, or NULL if this address doesn't belong in a module, or /// isn't resolved yet. - //------------------------------------------------------------------ lldb::ModuleSP GetModule() const; - //------------------------------------------------------------------ /// Get const accessor for the section. /// - /// @return + /// \return /// Returns the const lldb::Section pointer that this address is an /// offset in, or NULL if this address is absolute. - //------------------------------------------------------------------ lldb::SectionSP GetSection() const { return m_section_wp.lock(); } - //------------------------------------------------------------------ /// Set accessor for the offset. /// - /// @param[in] offset + /// \param[in] offset /// A new offset value for this object. /// - /// @return + /// \return /// Returns \b true if the offset changed, \b false otherwise. - //------------------------------------------------------------------ bool SetOffset(lldb::addr_t offset) { bool changed = m_offset != offset; m_offset = offset; @@ -484,21 +414,18 @@ public: return false; } - //------------------------------------------------------------------ /// Set accessor for the section. /// - /// @param[in] section + /// \param[in] section /// A new lldb::Section pointer to use as the section base. Can /// be NULL for absolute addresses that are not relative to /// any section. - //------------------------------------------------------------------ void SetSection(const lldb::SectionSP §ion_sp) { m_section_wp = section_sp; } void ClearSection() { m_section_wp.reset(); } - //------------------------------------------------------------------ /// Reconstruct a symbol context from an address. /// /// This class doesn't inherit from SymbolContextScope because many address @@ -506,8 +433,7 @@ public: /// can reconstruct their symbol context by looking up the address in the /// module found in the section. /// - /// @see SymbolContextScope::CalculateSymbolContext(SymbolContext*) - //------------------------------------------------------------------ + /// \see SymbolContextScope::CalculateSymbolContext(SymbolContext*) uint32_t CalculateSymbolContext(SymbolContext *sc, lldb::SymbolContextItem resolve_scope = lldb::eSymbolContextEverything) const; @@ -524,33 +450,26 @@ 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 - //------------------------------------------------------------------ bool SectionWasDeleted() const; protected: - //------------------------------------------------------------------ // Member variables. - //------------------------------------------------------------------ lldb::SectionWP m_section_wp; ///< The section for the address, can be NULL. lldb::addr_t m_offset; ///< Offset into section if \a m_section_wp is valid... - //------------------------------------------------------------------ // Returns true if the m_section_wp once had a reference to a valid section // shared pointer, but no longer does. This can happen if we have an address // from a module that gets unloaded and deleted. This function should only be // called if GetSection() returns an empty shared pointer and you want to // know if this address used to have a valid section. - //------------------------------------------------------------------ bool 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 @@ -562,7 +481,6 @@ protected: // address results to make much sense // // 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); bool operator==(const Address &lhs, const Address &rhs); diff --git a/include/lldb/Core/AddressRange.h b/include/lldb/Core/AddressRange.h index e3c820782aafa..4a019bfcfc3f4 100644 --- a/include/lldb/Core/AddressRange.h +++ b/include/lldb/Core/AddressRange.h @@ -1,9 +1,8 @@ //===-- AddressRange.h ------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -18,179 +17,159 @@ namespace lldb_private { class SectionList; -} -namespace lldb_private { class Stream; -} -namespace lldb_private { class Target; -} - -namespace lldb_private { -//---------------------------------------------------------------------- -/// @class AddressRange AddressRange.h "lldb/Core/AddressRange.h" +/// \class AddressRange AddressRange.h "lldb/Core/AddressRange.h" /// 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. - //------------------------------------------------------------------ AddressRange(); - //------------------------------------------------------------------ /// Construct with a section pointer, offset, and byte_size. /// /// Initialize the address with the supplied \a section, \a offset and \a /// byte_size. /// - /// @param[in] section + /// \param[in] section /// A section pointer to a valid lldb::Section, or NULL if the /// address doesn't have a section or will get resolved later. /// - /// @param[in] offset + /// \param[in] offset /// The offset in bytes into \a section. /// - /// @param[in] byte_size + /// \param[in] byte_size /// The size in bytes of the address range. - //------------------------------------------------------------------ AddressRange(const lldb::SectionSP §ion, lldb::addr_t offset, lldb::addr_t byte_size); - //------------------------------------------------------------------ /// 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. /// - /// @param[in] file_addr + /// \param[in] file_addr /// A virtual address. /// - /// @param[in] byte_size + /// \param[in] byte_size /// The size in bytes of the address range. /// - /// @param[in] section_list + /// \param[in] section_list /// A list of sections, one of which may contain the \a vaddr. - //------------------------------------------------------------------ AddressRange(lldb::addr_t file_addr, lldb::addr_t byte_size, const SectionList *section_list = nullptr); - //------------------------------------------------------------------ /// 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. /// - /// @param[in] so_addr + /// \param[in] so_addr /// A section offset address object. /// - /// @param[in] byte_size + /// \param[in] byte_size /// The size in bytes of the address range. - //------------------------------------------------------------------ AddressRange(const Address &so_addr, lldb::addr_t byte_size); - //------------------------------------------------------------------ /// Destructor. /// /// The destructor is virtual in case this class is subclassed. - //------------------------------------------------------------------ ~AddressRange(); - //------------------------------------------------------------------ /// Clear the object's state. /// /// Sets the section to an invalid value (NULL), an invalid offset /// (LLDB_INVALID_ADDRESS) and a zero byte size. - //------------------------------------------------------------------ void Clear(); - //------------------------------------------------------------------ /// Check if a section offset address is contained in this range. /// - /// @param[in] so_addr + /// \param[in] so_addr /// A section offset address object reference. /// - /// @return + /// \return /// Returns \b true if \a so_addr is contained in this range, /// \b false otherwise. - //------------------------------------------------------------------ // bool // Contains (const Address &so_addr) const; - //------------------------------------------------------------------ /// Check if a section offset address is contained in this range. /// - /// @param[in] so_addr_ptr + /// \param[in] so_addr_ptr /// A section offset address object pointer. /// - /// @return + /// \return /// Returns \b true if \a so_addr is contained in this range, /// \b false otherwise. - //------------------------------------------------------------------ // bool // 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. /// - /// @param[in] so_addr + /// \param[in] so_addr /// A section offset address object reference. /// - /// @return + /// \return /// Returns \b true if both \a this and \a so_addr have /// resolvable file address values and \a so_addr is contained /// in the address range, \b false otherwise. - //------------------------------------------------------------------ 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. /// - /// @param[in] so_addr + /// \param[in] so_addr /// A section offset address object reference. /// - /// @return + /// \return /// Returns \b true if both \a this has a resolvable file /// address value and \a so_addr is contained in the address /// range, \b false otherwise. - //------------------------------------------------------------------ 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. /// - /// @param[in] so_addr + /// \param[in] so_addr /// A section offset address object reference. /// - /// @return + /// \return /// Returns \b true if both \a this and \a so_addr have /// resolvable load address values and \a so_addr is contained /// in the address range, \b false otherwise. - //------------------------------------------------------------------ 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. /// - /// @param[in] so_addr + /// \param[in] so_addr /// A section offset address object reference. /// - /// @return + /// \return /// Returns \b true if both \a this has a resolvable load /// address value and \a so_addr is contained in the address /// range, \b false otherwise. - //------------------------------------------------------------------ bool ContainsLoadAddress(lldb::addr_t load_addr, Target *target) const; //------------------------------------------------------------------ + /// Extends this range with \b rhs_range if it overlaps this range on the + /// right side. The range overlaps on the right side if the base address + /// of \b rhs_range lies within this range or if it's contiguous on its + /// right side. + /// + /// @param[in] rhs_range + /// The range to extend at the right side. + /// + /// @return + /// Returns \b true if this range was extended, \b false otherwise. + //------------------------------------------------------------------ + bool Extend(const AddressRange &rhs_range); + /// Dump a description of this object to a Stream. /// /// Dump a description of the contents of this object to the supplied stream @@ -198,25 +177,23 @@ public: /// range, and \a style lets the user choose how the base address gets /// displayed. /// - /// @param[in] s + /// \param[in] s /// The stream to which to dump the object description. /// - /// @param[in] style + /// \param[in] style /// The display style for the address. /// - /// @return + /// \return /// Returns \b true if the address was able to be displayed. /// File and load addresses may be unresolved and it may not be /// possible to display a valid value, \b false will be returned /// in such cases. /// - /// @see Address::DumpStyle - //------------------------------------------------------------------ + /// \see Address::DumpStyle bool Dump(Stream *s, Target *target, Address::DumpStyle style, Address::DumpStyle fallback_style = Address::DumpStyleInvalid) const; - //------------------------------------------------------------------ /// Dump a debug description of this object to a Stream. /// /// Dump a debug description of the contents of this object to the supplied @@ -225,59 +202,46 @@ public: /// The debug description contains verbose internal state such and pointer /// values, reference counts, etc. /// - /// @param[in] s + /// \param[in] s /// The stream to which to dump the object description. - //------------------------------------------------------------------ void DumpDebug(Stream *s) const; - //------------------------------------------------------------------ /// Get accessor for the base address of the range. /// - /// @return + /// \return /// A reference to the base address object. - //------------------------------------------------------------------ Address &GetBaseAddress() { return m_base_addr; } - //------------------------------------------------------------------ /// Get const accessor for the base address of the range. /// - /// @return + /// \return /// A const reference to the base address object. - //------------------------------------------------------------------ const Address &GetBaseAddress() const { return m_base_addr; } - //------------------------------------------------------------------ /// Get accessor for the byte size of this range. /// - /// @return + /// \return /// The size in bytes of this address range. - //------------------------------------------------------------------ lldb::addr_t GetByteSize() const { return m_byte_size; } - //------------------------------------------------------------------ /// Get the memory cost of this object. /// - /// @return + /// \return /// 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. return sizeof(AddressRange); } - //------------------------------------------------------------------ /// Set accessor for the byte size of this range. /// - /// @param[in] byte_size + /// \param[in] byte_size /// The new size in bytes of this address range. - //------------------------------------------------------------------ void SetByteSize(lldb::addr_t byte_size) { m_byte_size = byte_size; } protected: - //------------------------------------------------------------------ // Member variables - //------------------------------------------------------------------ Address m_base_addr; ///< The section offset base address of this range. lldb::addr_t m_byte_size; ///< The size in bytes of this address range. }; diff --git a/include/lldb/Core/AddressResolver.h b/include/lldb/Core/AddressResolver.h index 32751d64d6b4a..cd95c7c31cd60 100644 --- a/include/lldb/Core/AddressResolver.h +++ b/include/lldb/Core/AddressResolver.h @@ -1,9 +1,8 @@ //===-- AddressResolver.h ---------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -19,29 +18,21 @@ namespace lldb_private { class ModuleList; -} -namespace lldb_private { class Stream; -} -namespace lldb_private { -//---------------------------------------------------------------------- -/// @class AddressResolver AddressResolver.h "lldb/Core/AddressResolver.h" +/// \class AddressResolver AddressResolver.h "lldb/Core/AddressResolver.h" /// 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. -//---------------------------------------------------------------------- class AddressResolver : public Searcher { public: - typedef enum { Exact, Regexp, Glob } MatchType; + enum MatchType { Exact, Regexp, Glob }; AddressResolver(); diff --git a/include/lldb/Core/AddressResolverFileLine.h b/include/lldb/Core/AddressResolverFileLine.h index bee72245ee6b2..b98e7d4c63380 100644 --- a/include/lldb/Core/AddressResolverFileLine.h +++ b/include/lldb/Core/AddressResolverFileLine.h @@ -1,9 +1,8 @@ //===-- AddressResolverFileLine.h -------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -19,22 +18,13 @@ namespace lldb_private { class Address; -} -namespace lldb_private { class Stream; -} -namespace lldb_private { class SymbolContext; -} - -namespace lldb_private { -//---------------------------------------------------------------------- -/// @class AddressResolverFileLine AddressResolverFileLine.h +/// \class AddressResolverFileLine AddressResolverFileLine.h /// "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 { public: diff --git a/include/lldb/Core/AddressResolverName.h b/include/lldb/Core/AddressResolverName.h index b4291938b290b..ad14ef6daeb1d 100644 --- a/include/lldb/Core/AddressResolverName.h +++ b/include/lldb/Core/AddressResolverName.h @@ -1,9 +1,8 @@ //===-- AddressResolverName.h -----------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -18,21 +17,12 @@ namespace lldb_private { class Address; -} -namespace lldb_private { class Stream; -} -namespace lldb_private { class SymbolContext; -} - -namespace lldb_private { -//---------------------------------------------------------------------- -/// @class AddressResolverName AddressResolverName.h +/// \class AddressResolverName AddressResolverName.h /// "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 { public: diff --git a/include/lldb/Core/Architecture.h b/include/lldb/Core/Architecture.h index 20537d67b02c7..d8dbbb4f540fa 100644 --- a/include/lldb/Core/Architecture.h +++ b/include/lldb/Core/Architecture.h @@ -1,9 +1,8 @@ //===-- Architecture.h ------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -17,9 +16,8 @@ namespace lldb_private { class Architecture : public PluginInterface { public: Architecture() = default; - virtual ~Architecture() = default; + ~Architecture() override = default; - //------------------------------------------------------------------ /// This is currently intended to handle cases where a /// program stops at an instruction that won't get executed and it /// allows the stop reason, like "breakpoint hit", to be replaced @@ -30,10 +28,8 @@ public: /// executed and therefore it wouldn't be correct to show the program /// stopped at the current PC. The code is generic and applies to all /// ARM CPUs. - //------------------------------------------------------------------ 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 @@ -49,12 +45,10 @@ public: /// 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. @@ -63,12 +57,10 @@ public: /// 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 {} - //------------------------------------------------------------------ /// Get \a load_addr as a callable code load address for this target /// /// Take \a load_addr and potentially add any address bits that are @@ -78,13 +70,11 @@ public: /// adjustment will always happen. If it is set to an address class /// that doesn't have code in it, LLDB_INVALID_ADDRESS will be /// returned. - //------------------------------------------------------------------ virtual lldb::addr_t GetCallableLoadAddress( lldb::addr_t addr, AddressClass addr_class = AddressClass::eInvalid) const { return addr; } - //------------------------------------------------------------------ /// Get \a load_addr as an opcode for this target. /// /// Take \a load_addr and potentially strip any address bits that are @@ -95,7 +85,6 @@ public: /// adjustment will always happen. If it is set to an address class /// that doesn't have code in it, LLDB_INVALID_ADDRESS will be /// returned. - //------------------------------------------------------------------ virtual lldb::addr_t GetOpcodeLoadAddress( lldb::addr_t addr, AddressClass addr_class = AddressClass::eInvalid) const { diff --git a/include/lldb/Core/ClangForward.h b/include/lldb/Core/ClangForward.h index 3fc12a555301c..6b24b47c8a964 100644 --- a/include/lldb/Core/ClangForward.h +++ b/include/lldb/Core/ClangForward.h @@ -1,9 +1,8 @@ //===-- ClangForward.h ------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// diff --git a/include/lldb/Core/Communication.h b/include/lldb/Core/Communication.h index f129b8f879d0e..901b8fdb8c8bc 100644 --- a/include/lldb/Core/Communication.h +++ b/include/lldb/Core/Communication.h @@ -1,9 +1,8 @@ //===-- Communication.h -----------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -28,18 +27,10 @@ namespace lldb_private { class Connection; -} -namespace lldb_private { class ConstString; -} -namespace lldb_private { class Status; -} - -namespace lldb_private { -//---------------------------------------------------------------------- -/// @class Communication Communication.h "lldb/Core/Communication.h" An +/// \class Communication Communication.h "lldb/Core/Communication.h" An /// abstract communications class. /// /// Communication is an class that handles data communication between two data @@ -60,8 +51,8 @@ namespace lldb_private { /// "eBroadcastBit" below). /// /// There are two modes in which communications can occur: -/// @li single-threaded -/// @li multi-threaded +/// \li single-threaded +/// \li multi-threaded /// /// In single-threaded mode, all reads and writes happen synchronously on the /// calling thread. @@ -90,7 +81,6 @@ namespace lldb_private { /// 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: FLAGS_ANONYMOUS_ENUM(){ @@ -116,72 +106,61 @@ public: typedef void (*ReadThreadBytesReceived)(void *baton, const void *src, size_t src_len); - //------------------------------------------------------------------ /// Construct the Communication object with the specified name for the /// Broadcaster that this object inherits from. /// - /// @param[in] broadcaster_name + /// \param[in] broadcaster_name /// The name of the broadcaster object. This name should be as /// complete as possible to uniquely identify this object. The /// broadcaster name can be updated after the connect function /// is called. - //------------------------------------------------------------------ Communication(const char *broadcaster_name); - //------------------------------------------------------------------ /// Destructor. /// /// The destructor is virtual since this class gets subclassed. - //------------------------------------------------------------------ ~Communication() override; void Clear(); - //------------------------------------------------------------------ /// Connect using the current connection by passing \a url to its connect /// function. string. /// - /// @param[in] url + /// \param[in] url /// A string that contains all information needed by the /// subclass to connect to another client. /// - /// @return + /// \return /// \b True if the connect succeeded, \b false otherwise. The /// internal error object should be filled in with an /// appropriate value based on the result of this function. /// - /// @see Status& Communication::GetError (); - /// @see bool Connection::Connect (const char *url); - //------------------------------------------------------------------ + /// \see Status& Communication::GetError (); + /// \see bool Connection::Connect (const char *url); lldb::ConnectionStatus Connect(const char *url, Status *error_ptr); - //------------------------------------------------------------------ /// Disconnect the communications connection if one is currently connected. /// - /// @return + /// \return /// \b True if the disconnect succeeded, \b false otherwise. The /// internal error object should be filled in with an /// appropriate value based on the result of this function. /// - /// @see Status& Communication::GetError (); - /// @see bool Connection::Disconnect (); - //------------------------------------------------------------------ + /// \see Status& Communication::GetError (); + /// \see bool Connection::Disconnect (); lldb::ConnectionStatus Disconnect(Status *error_ptr = nullptr); - //------------------------------------------------------------------ /// Check if the connection is valid. /// - /// @return + /// \return /// \b True if this object is currently connected, \b false /// otherwise. - //------------------------------------------------------------------ bool IsConnected() const; bool HasConnection() const; lldb_private::Connection *GetConnection() { return m_connection_sp.get(); } - //------------------------------------------------------------------ /// Read bytes from the current connection. /// /// If no read thread is running, this function call the connection's @@ -194,46 +173,42 @@ public: /// event. If this function consumes all of the bytes in the cache, it will /// reset the \a eBroadcastBitReadThreadGotBytes event bit. /// - /// @param[in] dst + /// \param[in] dst /// A destination buffer that must be at least \a dst_len bytes /// long. /// - /// @param[in] dst_len + /// \param[in] dst_len /// The number of bytes to attempt to read, and also the max /// number of bytes that can be placed into \a dst. /// - /// @param[in] timeout + /// \param[in] timeout /// A timeout value or llvm::None for no timeout. /// - /// @return + /// \return /// The number of bytes actually read. /// - /// @see size_t Connection::Read (void *, size_t); - //------------------------------------------------------------------ + /// \see size_t Connection::Read (void *, size_t); size_t Read(void *dst, size_t dst_len, const Timeout<std::micro> &timeout, lldb::ConnectionStatus &status, Status *error_ptr); - //------------------------------------------------------------------ /// The actual write function that attempts to write to the communications /// protocol. /// /// Subclasses must override this function. /// - /// @param[in] src + /// \param[in] src /// A source buffer that must be at least \a src_len bytes /// long. /// - /// @param[in] src_len + /// \param[in] src_len /// The number of bytes to attempt to write, and also the /// number of bytes are currently available in \a src. /// - /// @return + /// \return /// The number of bytes actually Written. - //------------------------------------------------------------------ size_t Write(const void *src, size_t src_len, lldb::ConnectionStatus &status, Status *error_ptr); - //------------------------------------------------------------------ /// Sets the connection that it to be used by this class. /// /// By making a communication class that uses different connections it @@ -241,15 +216,13 @@ public: /// connection without any interruption to the client. It also allows the /// Communication class to be subclassed for packet based communication. /// - /// @param[in] connection + /// \param[in] connection /// A connection that this class will own and destroy. /// - /// @see + /// \see /// class Connection - //------------------------------------------------------------------ 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: /// @@ -265,60 +238,51 @@ public: /// default action of caching the bytes and broadcasting a \b /// eBroadcastBitReadThreadGotBytes event. /// - /// @return + /// \return /// \b True if the read thread was successfully started, \b /// false otherwise. /// - /// @see size_t Connection::Read (void *, size_t); - /// @see void Communication::AppendBytesToCache (const uint8_t * bytes, + /// \see size_t Connection::Read (void *, size_t); + /// \see void Communication::AppendBytesToCache (const uint8_t * bytes, /// size_t len, bool broadcast); - //------------------------------------------------------------------ virtual bool StartReadThread(Status *error_ptr = nullptr); - //------------------------------------------------------------------ /// Stops the read thread by cancelling it. /// - /// @return + /// \return /// \b True if the read thread was successfully canceled, \b /// false otherwise. - //------------------------------------------------------------------ virtual bool StopReadThread(Status *error_ptr = nullptr); virtual bool JoinReadThread(Status *error_ptr = nullptr); - //------------------------------------------------------------------ /// Checks if there is a currently running read thread. /// - /// @return + /// \return /// \b True if the read thread is running, \b false otherwise. - //------------------------------------------------------------------ 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. /// - /// @param[in] comm_ptr + /// \param[in] comm_ptr /// A pointer to an instance of this class. /// - /// @return + /// \return /// \b NULL. /// - /// @see void Communication::ReadThreadGotBytes (const uint8_t *, size_t); - //------------------------------------------------------------------ + /// \see void Communication::ReadThreadGotBytes (const uint8_t *, size_t); static lldb::thread_result_t ReadThread(lldb::thread_arg_t comm_ptr); void SetReadThreadBytesReceivedCallback(ReadThreadBytesReceived callback, void *callback_baton); - //------------------------------------------------------------------ /// Wait for the read thread to process all outstanding data. /// /// After this function returns, the read thread has processed all data that /// has been waiting in the Connection queue. /// - //------------------------------------------------------------------ void SynchronizeWithReadThread(); static const char *ConnectionStatusAsCString(lldb::ConnectionStatus status); @@ -355,7 +319,6 @@ protected: const Timeout<std::micro> &timeout, 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. @@ -368,34 +331,31 @@ protected: /// of the \a eBroadcastBitReadThreadGotBytes event by setting \a broadcast /// to false. /// - /// @param[in] src + /// \param[in] src /// A source buffer that must be at least \a src_len bytes /// long. /// - /// @param[in] src_len + /// \param[in] src_len /// The number of bytes to append to the cache. - //------------------------------------------------------------------ virtual void AppendBytesToCache(const uint8_t *src, size_t src_len, bool broadcast, 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. /// - /// @param[in] dst + /// \param[in] dst /// A destination buffer that must be at least \a dst_len bytes /// long. /// - /// @param[in] dst_len + /// \param[in] dst_len /// The number of bytes to attempt to read from the cache, /// and also the max number of bytes that can be placed into /// \a dst. /// - /// @return + /// \return /// The number of bytes extracted from the data cache. - //------------------------------------------------------------------ size_t GetCachedBytes(void *dst, size_t dst_len); private: diff --git a/include/lldb/Core/Debugger.h b/include/lldb/Core/Debugger.h index 09f75ef0f8c68..8e608717a801b 100644 --- a/include/lldb/Core/Debugger.h +++ b/include/lldb/Core/Debugger.h @@ -1,9 +1,8 @@ //===-- Debugger.h ----------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -46,36 +45,26 @@ #include <stddef.h> #include <stdio.h> -namespace lldb_private { -class Address; +namespace llvm { +class raw_ostream; } + namespace lldb_private { +class Address; class CommandInterpreter; -} -namespace lldb_private { class Process; -} -namespace lldb_private { class Stream; -} -namespace lldb_private { class SymbolContext; -} -namespace lldb_private { class Target; -} -namespace llvm { -class raw_ostream; -} -namespace lldb_private { +namespace repro { +class DataRecorder; +} -//---------------------------------------------------------------------- -/// @class Debugger Debugger.h "lldb/Core/Debugger.h" +/// \class Debugger Debugger.h "lldb/Core/Debugger.h" /// A class to manage flag bits. /// /// Provides a global root objects for the debugger core. -//---------------------------------------------------------------------- class Debugger : public std::enable_shared_from_this<Debugger>, public UserID, @@ -106,7 +95,7 @@ public: static lldb::DebuggerSP FindDebuggerWithID(lldb::user_id_t id); static lldb::DebuggerSP - FindDebuggerWithInstanceName(const ConstString &instance_name); + FindDebuggerWithInstanceName(ConstString instance_name); static size_t GetNumDebuggers(); @@ -130,7 +119,10 @@ public: lldb::StreamFileSP GetErrorFile() { return m_error_file_sp; } - void SetInputFileHandle(FILE *fh, bool tranfer_ownership); + repro::DataRecorder *GetInputRecorder(); + + void SetInputFileHandle(FILE *fh, bool tranfer_ownership, + repro::DataRecorder *recorder = nullptr); void SetOutputFileHandle(FILE *fh, bool tranfer_ownership); @@ -145,10 +137,12 @@ public: lldb::StreamSP GetAsyncErrorStream(); CommandInterpreter &GetCommandInterpreter() { - assert(m_command_interpreter_ap.get()); - return *m_command_interpreter_ap; + assert(m_command_interpreter_up.get()); + return *m_command_interpreter_up; } + ScriptInterpreter *GetScriptInterpreter(bool can_create = true); + lldb::ListenerSP GetListener() { return m_listener_sp; } // This returns the Debugger's scratch source manager. It won't be able to @@ -162,16 +156,14 @@ public: } ExecutionContext GetSelectedExecutionContext(); - //------------------------------------------------------------------ /// 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. /// - /// @return + /// \return /// A global shared target list. - //------------------------------------------------------------------ TargetList &GetTargetList() { return m_target_list; } PlatformList &GetPlatformList() { return m_platform_list; } @@ -180,10 +172,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 - //------------------------------------------------------------------ void AdoptTopIOHandlerFilesIfInvalid(lldb::StreamFileSP &in, lldb::StreamFileSP &out, lldb::StreamFileSP &err); @@ -222,9 +212,7 @@ public: void SetLoggingCallback(lldb::LogOutputCallback log_callback, void *baton); - //---------------------------------------------------------------------- // Properties Functions - //---------------------------------------------------------------------- enum StopDisassemblyType { eStopDisassemblyTypeNever = 0, eStopDisassemblyTypeNoDebugInfo, @@ -303,7 +291,7 @@ public: bool GetNotifyVoid() const; - const ConstString &GetInstanceName() { return m_instance_name; } + ConstString GetInstanceName() { return m_instance_name; } bool LoadPlugin(const FileSpec &spec, Status &error); @@ -371,6 +359,9 @@ protected: lldb::StreamFileSP m_output_file_sp; lldb::StreamFileSP m_error_file_sp; + /// Used for shadowing the input file when capturing a reproducer. + repro::DataRecorder *m_input_recorder; + lldb::BroadcasterManagerSP m_broadcaster_manager_sp; // The debugger acts as a // broadcaster manager of // last resort. @@ -382,7 +373,7 @@ protected: PlatformList m_platform_list; lldb::ListenerSP m_listener_sp; - std::unique_ptr<SourceManager> m_source_manager_ap; // This is a scratch + std::unique_ptr<SourceManager> m_source_manager_up; // This is a scratch // source manager that we // return if we have no // targets. @@ -391,7 +382,10 @@ protected: // this debugger used this // shared // source file cache. - std::unique_ptr<CommandInterpreter> m_command_interpreter_ap; + std::unique_ptr<CommandInterpreter> m_command_interpreter_up; + + lldb::ScriptInterpreterSP m_script_interpreter_sp; + std::recursive_mutex m_script_interpreter_mutex; IOHandlerStack m_input_reader_stack; llvm::StringMap<std::weak_ptr<llvm::raw_ostream>> m_log_streams; @@ -406,9 +400,7 @@ protected: lldb::ListenerSP m_forward_listener_sp; llvm::once_flag m_clear_once; - //---------------------------------------------------------------------- // Events for m_sync_broadcaster - //---------------------------------------------------------------------- enum { eBroadcastBitEventThreadIsListening = (1 << 0), }; diff --git a/include/lldb/Core/Disassembler.h b/include/lldb/Core/Disassembler.h index 7cec837e71f8b..ba9ca87832f6f 100644 --- a/include/lldb/Core/Disassembler.h +++ b/include/lldb/Core/Disassembler.h @@ -1,9 +1,8 @@ //===-- Disassembler.h ------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -39,41 +38,21 @@ #include <stdint.h> #include <stdio.h> -namespace lldb_private { -class AddressRange; +namespace llvm { +template <typename T> class SmallVectorImpl; } + namespace lldb_private { +class AddressRange; class DataExtractor; -} -namespace lldb_private { class Debugger; -} -namespace lldb_private { class Disassembler; -} -namespace lldb_private { class Module; -} -namespace lldb_private { class Stream; -} -namespace lldb_private { class SymbolContext; -} -namespace lldb_private { class SymbolContextList; -} -namespace lldb_private { class Target; -} -namespace lldb_private { struct RegisterInfo; -} -namespace llvm { -template <typename T> class SmallVectorImpl; -} - -namespace lldb_private { class Instruction { public: @@ -110,38 +89,37 @@ public: m_address = addr; } - //------------------------------------------------------------------ /// Dump the text representation of this Instruction to a Stream /// /// Print the (optional) address, (optional) bytes, opcode, /// operands, and instruction comments to a stream. /// - /// @param[in] s + /// \param[in] s /// The Stream to add the text to. /// - /// @param[in] show_address + /// \param[in] show_address /// Whether the address (using disassembly_addr_format_spec formatting) /// should be printed. /// - /// @param[in] show_bytes + /// \param[in] show_bytes /// Whether the bytes of the assembly instruction should be printed. /// - /// @param[in] max_opcode_byte_size + /// \param[in] max_opcode_byte_size /// The size (in bytes) of the largest instruction in the list that /// we are printing (for text justification/alignment purposes) /// Only needed if show_bytes is true. /// - /// @param[in] exe_ctx + /// \param[in] exe_ctx /// The current execution context, if available. May be used in /// the assembling of the operands+comments for this instruction. /// Pass NULL if not applicable. /// - /// @param[in] sym_ctx + /// \param[in] sym_ctx /// The SymbolContext for this instruction. /// Pass NULL if not available/computed. /// Only needed if show_address is true. /// - /// @param[in] prev_sym_ctx + /// \param[in] prev_sym_ctx /// The SymbolContext for the previous instruction. Depending on /// the disassembly address format specification, a change in /// Symbol / Function may mean that a line is printed with the new @@ -150,17 +128,16 @@ public: /// the InstructionList. /// Only needed if show_address is true. /// - /// @param[in] disassembly_addr_format + /// \param[in] disassembly_addr_format /// The format specification for how addresses are printed. /// Only needed if show_address is true. /// - /// @param[in] max_address_text_size + /// \param[in] max_address_text_size /// The length of the longest address string at the start of the /// disassembly line that will be printed (the /// Debugger::FormatDisassemblerAddress() string) /// so this method can properly align the instruction opcodes. /// May be 0 to indicate no indentation/alignment of the opcodes. - //------------------------------------------------------------------ virtual void Dump(Stream *s, uint32_t max_opcode_byte_size, bool show_address, bool show_bytes, const ExecutionContext *exe_ctx, const SymbolContext *sym_ctx, @@ -293,8 +270,32 @@ public: lldb::InstructionSP GetInstructionAtIndex(size_t idx) const; + //------------------------------------------------------------------ + /// Get the index of the next branch instruction. + /// + /// Given a list of instructions, find the next branch instruction + /// in the list by returning an index. + /// + /// @param[in] start + /// The instruction index of the first instruction to check. + /// + /// @param[in] target + /// A LLDB target object that is used to resolve addresses. + /// + /// @param[in] ignore_calls + /// It true, then fine the first branch instruction that isn't + /// a function call (a branch that calls and returns to the next + /// instruction). If false, find the instruction index of any + /// branch in the list. + /// + /// @return + /// The instruction index of the first branch that is at or past + /// \a start. Returns UINT32_MAX if no matching branches are + /// found. + //------------------------------------------------------------------ uint32_t GetIndexOfNextBranchInstruction(uint32_t start, - Target &target) const; + Target &target, + bool ignore_calls) const; uint32_t GetIndexOfInstructionAtLoadAddress(lldb::addr_t load_addr, Target &target); @@ -414,7 +415,7 @@ public: static bool Disassemble(Debugger &debugger, const ArchSpec &arch, const char *plugin_name, const char *flavor, const ExecutionContext &exe_ctx, - const ConstString &name, Module *module, + ConstString name, Module *module, uint32_t num_instructions, bool mixed_source_and_assembly, uint32_t num_mixed_context_lines, uint32_t options, Stream &strm); @@ -424,9 +425,7 @@ public: uint32_t num_instructions, bool mixed_source_and_assembly, uint32_t num_mixed_context_lines, uint32_t options, Stream &strm); - //------------------------------------------------------------------ // Constructors and Destructors - //------------------------------------------------------------------ Disassembler(const ArchSpec &arch, const char *flavor); ~Disassembler() override; @@ -536,18 +535,14 @@ protected: return ElideMixedSourceAndDisassemblyLine(exe_ctx, sc, sl); }; - //------------------------------------------------------------------ // Classes that inherit from Disassembler can see and modify these - //------------------------------------------------------------------ ArchSpec m_arch; InstructionList m_instruction_list; lldb::addr_t m_base_addr; std::string m_flavor; private: - //------------------------------------------------------------------ // For Disassembler only - //------------------------------------------------------------------ DISALLOW_COPY_AND_ASSIGN(Disassembler); }; diff --git a/include/lldb/Core/DumpDataExtractor.h b/include/lldb/Core/DumpDataExtractor.h index 88446d48fa646..2a9d778e0a6a8 100644 --- a/include/lldb/Core/DumpDataExtractor.h +++ b/include/lldb/Core/DumpDataExtractor.h @@ -1,9 +1,8 @@ //===-- DumpDataExtractor.h -------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -21,7 +20,6 @@ class DataExtractor; class ExecutionContextScope; class Stream; -//------------------------------------------------------------------ /// Dumps \a item_count objects into the stream \a s. /// /// Dumps \a item_count objects using \a item_format, each of which @@ -35,31 +33,31 @@ class Stream; /// same start offset, format and size, yet differing \a /// item_bit_size and \a item_bit_offset values. /// -/// @param[in] s +/// \param[in] s /// The stream to dump the output to. This value can not be nullptr. /// -/// @param[in] offset +/// \param[in] offset /// The offset into the data at which to start dumping. /// -/// @param[in] item_format +/// \param[in] item_format /// The format to use when dumping each item. /// -/// @param[in] item_byte_size +/// \param[in] item_byte_size /// The byte size of each item. /// -/// @param[in] item_count +/// \param[in] item_count /// The number of items to dump. /// -/// @param[in] num_per_line +/// \param[in] num_per_line /// The number of items to display on each line. /// -/// @param[in] base_addr +/// \param[in] base_addr /// The base address that gets added to the offset displayed on /// each line if the value is valid. Is \a base_addr is /// LLDB_INVALID_ADDRESS then no address values will be prepended /// to any lines. /// -/// @param[in] item_bit_size +/// \param[in] item_bit_size /// If the value to display is a bitfield, this value should /// be the number of bits that the bitfield item has within the /// item's byte size value. This function will need to be called @@ -68,7 +66,7 @@ class Stream; /// exist within the same integer value. If the items being /// displayed are not bitfields, this value should be zero. /// -/// @param[in] item_bit_offset +/// \param[in] item_bit_offset /// If the value to display is a bitfield, this value should /// be the offset in bits, or shift right amount, that the /// bitfield item occupies within the item's byte size value. @@ -78,9 +76,8 @@ class Stream; /// same integer value. If the items being displayed are not /// bitfields, this value should be zero. /// -/// @return +/// \return /// The offset at which dumping ended. -//------------------------------------------------------------------ lldb::offset_t DumpDataExtractor(const DataExtractor &DE, Stream *s, lldb::offset_t offset, lldb::Format item_format, size_t item_byte_size, diff --git a/include/lldb/Core/DumpRegisterValue.h b/include/lldb/Core/DumpRegisterValue.h index bc4860fbc0e5a..443fdb34266ae 100644 --- a/include/lldb/Core/DumpRegisterValue.h +++ b/include/lldb/Core/DumpRegisterValue.h @@ -1,9 +1,8 @@ //===-- DumpRegisterValue.h -------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// diff --git a/include/lldb/Core/EmulateInstruction.h b/include/lldb/Core/EmulateInstruction.h index 5198f3eac9221..6b19c17e5491c 100644 --- a/include/lldb/Core/EmulateInstruction.h +++ b/include/lldb/Core/EmulateInstruction.h @@ -1,9 +1,8 @@ //===-- EmulateInstruction.h ------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -24,29 +23,16 @@ #include <stddef.h> #include <stdint.h> + namespace lldb_private { class OptionValueDictionary; -} -namespace lldb_private { class RegisterContext; -} -namespace lldb_private { class RegisterValue; -} -namespace lldb_private { class Stream; -} -namespace lldb_private { class Target; -} -namespace lldb_private { class UnwindPlan; -} - -namespace lldb_private { -//---------------------------------------------------------------------- -/// @class EmulateInstruction EmulateInstruction.h +/// \class EmulateInstruction EmulateInstruction.h /// "lldb/Core/EmulateInstruction.h" /// A class that allows emulation of CPU opcodes. /// @@ -103,7 +89,6 @@ namespace lldb_private { /// 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 { public: @@ -368,9 +353,7 @@ public: ~EmulateInstruction() override = default; - //---------------------------------------------------------------------- // Mandatory overrides - //---------------------------------------------------------------------- virtual bool SupportsEmulatingInstructionsOfType(InstructionType inst_type) = 0; @@ -390,9 +373,7 @@ public: virtual bool GetRegisterInfo(lldb::RegisterKind reg_kind, uint32_t reg_num, RegisterInfo ®_info) = 0; - //---------------------------------------------------------------------- // Optional overrides - //---------------------------------------------------------------------- virtual bool SetInstruction(const Opcode &insn_opcode, const Address &inst_addr, Target *target); @@ -401,9 +382,7 @@ public: static const char *TranslateRegister(lldb::RegisterKind reg_kind, uint32_t reg_num, std::string ®_name); - //---------------------------------------------------------------------- // RegisterInfo variants - //---------------------------------------------------------------------- bool ReadRegister(const RegisterInfo *reg_info, RegisterValue ®_value); uint64_t ReadRegisterUnsigned(const RegisterInfo *reg_info, @@ -415,9 +394,7 @@ public: bool WriteRegisterUnsigned(const Context &context, const RegisterInfo *reg_info, uint64_t reg_value); - //---------------------------------------------------------------------- // Register kind and number variants - //---------------------------------------------------------------------- bool ReadRegister(lldb::RegisterKind reg_kind, uint32_t reg_num, RegisterValue ®_value); @@ -512,18 +489,16 @@ public: protected: ArchSpec m_arch; - void *m_baton; - ReadMemoryCallback m_read_mem_callback; - WriteMemoryCallback m_write_mem_callback; - ReadRegisterCallback m_read_reg_callback; - WriteRegisterCallback m_write_reg_callback; - lldb::addr_t m_addr; + void *m_baton = nullptr; + ReadMemoryCallback m_read_mem_callback = &ReadMemoryDefault; + WriteMemoryCallback m_write_mem_callback = &WriteMemoryDefault; + ReadRegisterCallback m_read_reg_callback = &ReadRegisterDefault; + WriteRegisterCallback m_write_reg_callback = &WriteRegisterDefault; + lldb::addr_t m_addr = LLDB_INVALID_ADDRESS; Opcode m_opcode; private: - //------------------------------------------------------------------ // For EmulateInstruction only - //------------------------------------------------------------------ DISALLOW_COPY_AND_ASSIGN(EmulateInstruction); }; diff --git a/include/lldb/Core/FileLineResolver.h b/include/lldb/Core/FileLineResolver.h index 6de99bc0c4dc9..1967ed58cd3b3 100644 --- a/include/lldb/Core/FileLineResolver.h +++ b/include/lldb/Core/FileLineResolver.h @@ -1,9 +1,8 @@ //===-- FileLineResolver.h --------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -19,18 +18,11 @@ namespace lldb_private { class Address; -} -namespace lldb_private { class Stream; -} - -namespace lldb_private { -//---------------------------------------------------------------------- -/// @class FileLineResolver FileLineResolver.h "lldb/Core/FileLineResolver.h" +/// \class FileLineResolver FileLineResolver.h "lldb/Core/FileLineResolver.h" /// 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 { public: diff --git a/include/lldb/Core/FileSpecList.h b/include/lldb/Core/FileSpecList.h index db6490ef71339..79623ef1fdca3 100644 --- a/include/lldb/Core/FileSpecList.h +++ b/include/lldb/Core/FileSpecList.h @@ -1,9 +1,8 @@ //===-- FileSpecList.h ------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -19,165 +18,138 @@ namespace lldb_private { class Stream; -} - -namespace lldb_private { -//---------------------------------------------------------------------- -/// @class FileSpecList FileSpecList.h "lldb/Core/FileSpecList.h" +/// \class FileSpecList FileSpecList.h "lldb/Core/FileSpecList.h" /// A file collection class. /// /// A class that contains a mutable list of FileSpec objects. -//---------------------------------------------------------------------- class FileSpecList { public: - //------------------------------------------------------------------ /// Default constructor. /// /// Initialize this object with an empty file list. - //------------------------------------------------------------------ FileSpecList(); - //------------------------------------------------------------------ /// Copy constructor. - /// - /// Initialize this object with a copy of the file list from \a rhs. - /// - /// @param[in] rhs - /// A const reference to another file list object. - //------------------------------------------------------------------ - FileSpecList(const FileSpecList &rhs); + FileSpecList(const FileSpecList &rhs) = default; + + /// Move constructor + FileSpecList(FileSpecList &&rhs) = default; + + /// Initialize this object from a vector of FileSpecs + FileSpecList(std::vector<FileSpec> &&rhs) : m_files(std::move(rhs)) {} - //------------------------------------------------------------------ /// Destructor. - //------------------------------------------------------------------ ~FileSpecList(); - //------------------------------------------------------------------ /// Assignment operator. /// /// Replace the file list in this object with the file list from \a rhs. /// - /// @param[in] rhs + /// \param[in] rhs /// A file list object to copy. /// - /// @return + /// \return /// A const reference to this object. - //------------------------------------------------------------------ - const FileSpecList &operator=(const FileSpecList &rhs); + FileSpecList &operator=(const FileSpecList &rhs) = default; + + /// Move-assignment operator. + FileSpecList &operator=(FileSpecList &&rhs) = default; - //------------------------------------------------------------------ /// Append a FileSpec object to the list. /// /// Appends \a file to the end of the file list. /// - /// @param[in] file + /// \param[in] file /// A new file to append to this file list. - //------------------------------------------------------------------ void Append(const FileSpec &file); - //------------------------------------------------------------------ /// 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. /// - /// @param[in] file + /// \param[in] file /// A new file to append to this file list. /// - /// @return + /// \return /// \b true if the file was appended, \b false otherwise. - //------------------------------------------------------------------ bool AppendIfUnique(const FileSpec &file); - //------------------------------------------------------------------ /// Clears the file list. - //------------------------------------------------------------------ void Clear(); - //------------------------------------------------------------------ /// Dumps the file list to the supplied stream pointer "s". /// - /// @param[in] s + /// \param[in] s /// The stream that will be used to dump the object description. - //------------------------------------------------------------------ void Dump(Stream *s, const char *separator_cstr = "\n") const; - //------------------------------------------------------------------ /// 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. /// - /// @param[in] idx + /// \param[in] idx /// An index into the file list. /// - /// @param[in] file + /// \param[in] file /// The file specification to search for. /// - /// @param[in] full + /// \param[in] full /// Should FileSpec::Equal be called with "full" true or false. /// - /// @return + /// \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) 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*(). /// - /// @param[in] idx + /// \param[in] idx /// An index into the file list. /// - /// @return + /// \return /// A copy of the FileSpec object at index \a idx. If \a idx /// is out of range, then an empty FileSpec object will be /// returned. - //------------------------------------------------------------------ const FileSpec &GetFileSpecAtIndex(size_t idx) const; - //------------------------------------------------------------------ /// 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*(). /// - /// @param[in] idx + /// \param[in] idx /// An index into the file list. /// - /// @return + /// \return /// A pointer to a contained FileSpec object at index \a idx. /// If \a idx is out of range, then an NULL is returned. - //------------------------------------------------------------------ const FileSpec *GetFileSpecPointerAtIndex(size_t idx) const; - //------------------------------------------------------------------ /// 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 + /// \return /// The number of bytes that this object occupies in memory. /// - /// @see ConstString::StaticMemorySize () - //------------------------------------------------------------------ + /// \see ConstString::StaticMemorySize () size_t MemorySize() const; bool IsEmpty() const { return m_files.empty(); } - //------------------------------------------------------------------ /// Get the number of files in the file list. /// - /// @return + /// \return /// The number of files in the file spec list. - //------------------------------------------------------------------ size_t GetSize() const; bool Insert(size_t idx, const FileSpec &file) { diff --git a/include/lldb/Core/FormatEntity.h b/include/lldb/Core/FormatEntity.h index b58f3b104e46f..634d9df2ad839 100644 --- a/include/lldb/Core/FormatEntity.h +++ b/include/lldb/Core/FormatEntity.h @@ -1,9 +1,8 @@ //===-- FormatEntity.h ------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -24,20 +23,10 @@ namespace lldb_private { class Address; -} -namespace lldb_private { class ExecutionContext; -} -namespace lldb_private { class Stream; -} -namespace lldb_private { class StringList; -} -namespace lldb_private { class SymbolContext; -} -namespace lldb_private { class ValueObject; } namespace llvm { @@ -52,7 +41,7 @@ public: Invalid, ParentNumber, ParentString, - InsertString, + EscapeCode, Root, String, Scope, @@ -111,14 +100,10 @@ public: CurrentPCArrow }; - enum FormatType { None, UInt32, UInt64, CString }; - struct Definition { const char *name; const char *string; // Insert this exact string into the output Entry::Type type; - FormatType format_type; // uint32_t, uint64_t, cstr, or anything that can - // be formatted by printf or lldb::Format uint64_t data; uint32_t num_children; Definition *children; // An array of "num_children" Definition entries, @@ -216,14 +201,12 @@ public: 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. - //---------------------------------------------------------------------- static bool FormatFileSpec(const FileSpec &file, Stream &s, llvm::StringRef elements, llvm::StringRef element_format); diff --git a/include/lldb/Core/Highlighter.h b/include/lldb/Core/Highlighter.h index 220557c1f032b..88d3bb3a3cd1a 100644 --- a/include/lldb/Core/Highlighter.h +++ b/include/lldb/Core/Highlighter.h @@ -1,9 +1,8 @@ //===-- Highlighter.h -------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -19,17 +18,13 @@ namespace lldb_private { -//---------------------------------------------------------------------- /// Represents style that the highlighter should apply to the given source code. /// Stores information about how every kind of token should be annotated. -//---------------------------------------------------------------------- struct HighlightStyle { - //---------------------------------------------------------------------- /// A pair of strings that should be placed around a certain token. Usually /// stores color codes in these strings (the suffix string is often used for /// resetting the terminal attributes back to normal). - //---------------------------------------------------------------------- class ColorStyle { std::string m_prefix; std::string m_suffix; @@ -48,8 +43,8 @@ struct HighlightStyle { void Apply(Stream &s, llvm::StringRef value) const; /// Sets the prefix and suffix strings. - /// @param prefix - /// @param suffix + /// \param prefix + /// \param suffix void Set(llvm::StringRef prefix, llvm::StringRef suffix); }; @@ -84,9 +79,7 @@ struct HighlightStyle { /// Matches '(' or ')' ColorStyle parentheses; - //----------------------------------------------------------------------- // C language specific options - //----------------------------------------------------------------------- /// Matches directives to a preprocessor (if the language has any). ColorStyle pp_directive; @@ -95,9 +88,7 @@ struct HighlightStyle { static HighlightStyle MakeVimStyle(); }; -//---------------------------------------------------------------------- /// Annotates source code with color attributes. -//---------------------------------------------------------------------- class Highlighter { public: Highlighter() = default; diff --git a/include/lldb/Core/IOHandler.h b/include/lldb/Core/IOHandler.h index 4bd577390b2ca..b7180675cf4e4 100644 --- a/include/lldb/Core/IOHandler.h +++ b/include/lldb/Core/IOHandler.h @@ -1,9 +1,8 @@ //===-- IOHandler.h ---------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -14,6 +13,7 @@ #include "lldb/Utility/ConstString.h" #include "lldb/Utility/Flags.h" #include "lldb/Utility/Predicate.h" +#include "lldb/Utility/Reproducer.h" #include "lldb/Utility/Stream.h" #include "lldb/Utility/StringList.h" #include "lldb/lldb-defines.h" @@ -59,7 +59,8 @@ public: IOHandler(Debugger &debugger, IOHandler::Type type, const lldb::StreamFileSP &input_sp, const lldb::StreamFileSP &output_sp, - const lldb::StreamFileSP &error_sp, uint32_t flags); + const lldb::StreamFileSP &error_sp, uint32_t flags, + repro::DataRecorder *data_recorder); virtual ~IOHandler(); @@ -137,23 +138,19 @@ public: const Flags &GetFlags() const { return m_flags; } - //------------------------------------------------------------------ /// Check if the input is being supplied interactively by a user /// /// This will return true if the input stream is a terminal (tty or /// pty) and can cause IO handlers to do different things (like /// for a confirmation when deleting all breakpoints). - //------------------------------------------------------------------ bool GetIsInteractive(); - //------------------------------------------------------------------ /// Check if the input is coming from a real terminal. /// /// A real terminal has a valid size with a certain number of rows /// and columns. If this function returns true, then terminal escape /// sequences are expected to work (cursor movement escape sequences, /// clearing lines, etc). - //------------------------------------------------------------------ bool GetIsRealTerminal(); void SetPopped(bool b); @@ -170,6 +167,7 @@ protected: lldb::StreamFileSP m_input_sp; lldb::StreamFileSP m_output_sp; lldb::StreamFileSP m_error_sp; + repro::DataRecorder *m_data_recorder; Predicate<bool> m_popped; Flags m_flags; Type m_type; @@ -181,14 +179,12 @@ private: DISALLOW_COPY_AND_ASSIGN(IOHandler); }; -//------------------------------------------------------------------ /// A delegate class for use with IOHandler subclasses. /// /// The IOHandler delegate is designed to be mixed into classes so /// they can use an IOHandler subclass to fetch input and notify the /// object that inherits from this delegate class when a token is /// received. -//------------------------------------------------------------------ class IOHandlerDelegate { public: enum class Completion { None, LLDBCommand, Expression }; @@ -198,7 +194,7 @@ public: virtual ~IOHandlerDelegate() = default; - virtual void IOHandlerActivated(IOHandler &io_handler) {} + virtual void IOHandlerActivated(IOHandler &io_handler, bool interactive) {} virtual void IOHandlerDeactivated(IOHandler &io_handler) {} @@ -209,37 +205,34 @@ public: virtual const char *IOHandlerGetFixIndentationCharacters() { return nullptr; } - //------------------------------------------------------------------ /// Called when a new line is created or one of an identified set of /// indentation characters is typed. /// /// This function determines how much indentation should be added /// or removed to match the recommended amount for the final line. /// - /// @param[in] io_handler + /// \param[in] io_handler /// The IOHandler that responsible for input. /// - /// @param[in] lines + /// \param[in] lines /// The current input up to the line to be corrected. Lines /// following the line containing the cursor are not included. /// - /// @param[in] cursor_position + /// \param[in] cursor_position /// The number of characters preceding the cursor on the final /// line at the time. /// - /// @return + /// \return /// Returns an integer describing the number of spaces needed /// to correct the indentation level. Positive values indicate /// that spaces should be added, while negative values represent /// spaces that should be removed. - //------------------------------------------------------------------ virtual int IOHandlerFixIndentation(IOHandler &io_handler, const StringList &lines, int cursor_position) { return 0; } - //------------------------------------------------------------------ /// Called when a line or lines have been retrieved. /// /// This function can handle the current line and possibly call @@ -247,29 +240,26 @@ public: /// "quit" is entered as a command, of when an empty line is /// received. It is up to the delegate to determine when a line /// should cause a IOHandler to exit. - //------------------------------------------------------------------ virtual void IOHandlerInputComplete(IOHandler &io_handler, std::string &data) = 0; virtual void IOHandlerInputInterrupted(IOHandler &io_handler, std::string &data) {} - //------------------------------------------------------------------ /// Called to determine whether typing enter after the last line in /// \a lines should end input. This function will not be called on /// IOHandler objects that are getting single lines. - /// @param[in] io_handler + /// \param[in] io_handler /// The IOHandler that responsible for updating the lines. /// - /// @param[in] lines + /// \param[in] lines /// The current multi-line content. May be altered to provide /// alternative input when complete. /// - /// @return + /// \return /// Return an boolean to indicate whether input is complete, /// true indicates that no additional input is necessary, while /// false indicates that more input is required. - //------------------------------------------------------------------ virtual bool IOHandlerIsInputComplete(IOHandler &io_handler, StringList &lines) { // Impose no requirements for input to be considered complete. subclasses @@ -285,24 +275,20 @@ public: virtual const char *IOHandlerGetHelpPrologue() { return nullptr; } - //------------------------------------------------------------------ // 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. - //------------------------------------------------------------------ virtual bool IOHandlerInterrupt(IOHandler &io_handler) { return false; } protected: Completion m_completion; // Support for common builtin completions }; -//---------------------------------------------------------------------- // IOHandlerDelegateMultiline // // A IOHandlerDelegate that handles terminating multi-line input when // the last line is equal to "end_line" which is specified in the constructor. -//---------------------------------------------------------------------- class IOHandlerDelegateMultiline : public IOHandlerDelegate { public: IOHandlerDelegateMultiline(const char *end_line, @@ -344,7 +330,8 @@ public: uint32_t line_number_start, // If non-zero show line numbers // starting at // 'line_number_start' - IOHandlerDelegate &delegate); + IOHandlerDelegate &delegate, + repro::DataRecorder *data_recorder); IOHandlerEditline(Debugger &debugger, IOHandler::Type type, const lldb::StreamFileSP &input_sp, @@ -356,7 +343,8 @@ public: uint32_t line_number_start, // If non-zero show line numbers // starting at // 'line_number_start' - IOHandlerDelegate &delegate); + IOHandlerDelegate &delegate, + repro::DataRecorder *data_recorder); IOHandlerEditline(Debugger &, IOHandler::Type, const char *, const char *, const char *, bool, bool, uint32_t, @@ -436,7 +424,7 @@ private: protected: #ifndef LLDB_DISABLE_LIBEDIT - std::unique_ptr<Editline> m_editline_ap; + std::unique_ptr<Editline> m_editline_up; #endif IOHandlerDelegate &m_delegate; std::string m_prompt; diff --git a/include/lldb/Core/IOStreamMacros.h b/include/lldb/Core/IOStreamMacros.h index 2562f179ca5d7..45bde88f94410 100644 --- a/include/lldb/Core/IOStreamMacros.h +++ b/include/lldb/Core/IOStreamMacros.h @@ -1,9 +1,8 @@ //===-- IOStreamMacros.h ----------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// diff --git a/include/lldb/Core/LoadedModuleInfoList.h b/include/lldb/Core/LoadedModuleInfoList.h index 5ef0f8929b890..f7f83604fc1a8 100644 --- a/include/lldb/Core/LoadedModuleInfoList.h +++ b/include/lldb/Core/LoadedModuleInfoList.h @@ -1,9 +1,8 @@ //===-- LoadedModuleInfoList.h ----------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// diff --git a/include/lldb/Core/Mangled.h b/include/lldb/Core/Mangled.h index 12edf8200e436..fb52afd6ed346 100644 --- a/include/lldb/Core/Mangled.h +++ b/include/lldb/Core/Mangled.h @@ -1,9 +1,8 @@ //===-- Mangled.h -----------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -23,8 +22,7 @@ namespace lldb_private { -//---------------------------------------------------------------------- -/// @class Mangled Mangled.h "lldb/Core/Mangled.h" +/// \class Mangled Mangled.h "lldb/Core/Mangled.h" /// A class that handles mangled names. /// /// Designed to handle mangled names. The demangled version of any names will @@ -34,7 +32,6 @@ namespace lldb_private { /// 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: enum NamePreference { @@ -49,188 +46,156 @@ public: eManglingSchemeItanium }; - //---------------------------------------------------------------------- /// Default constructor. /// /// Initialize with both mangled and demangled names empty. - //---------------------------------------------------------------------- Mangled(); - //---------------------------------------------------------------------- /// Construct with name. /// /// Constructor with an optional string and a boolean indicating if it is /// the mangled version. /// - /// @param[in] name + /// \param[in] name /// The already const name to copy into this object. /// - /// @param[in] is_mangled + /// \param[in] is_mangled /// If \b true then \a name is a mangled name, if \b false then /// \a name is demangled. - //---------------------------------------------------------------------- - Mangled(const ConstString &name, bool is_mangled); + Mangled(ConstString name, bool is_mangled); Mangled(llvm::StringRef name, bool is_mangled); - //---------------------------------------------------------------------- /// Construct with name. /// /// Constructor with an optional string and auto-detect if \a name is /// mangled or not. /// - /// @param[in] name + /// \param[in] name /// The already const name to copy into this object. - //---------------------------------------------------------------------- - explicit Mangled(const ConstString &name); + explicit Mangled(ConstString name); explicit Mangled(llvm::StringRef name); - //---------------------------------------------------------------------- /// Destructor /// /// 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: /// - /// @code + /// \code /// Mangled mangled(...); /// if (mangled) /// { ... - /// @endcode + /// \endcode /// - /// @return + /// \return /// A pointer to this object if either the mangled or unmangled /// name is set, NULL otherwise. - //---------------------------------------------------------------------- operator void *() const; - //---------------------------------------------------------------------- /// Logical NOT operator. /// /// This allows code to check a Mangled object to see if it contains an /// empty mangled name using code such as: /// - /// @code + /// \code /// Mangled mangled(...); /// if (!mangled) /// { ... - /// @endcode + /// \endcode /// - /// @return + /// \return /// Returns \b true if the object has an empty mangled and /// unmangled name, \b false otherwise. - //---------------------------------------------------------------------- bool operator!() const; - //---------------------------------------------------------------------- /// Clear the mangled and demangled values. - //---------------------------------------------------------------------- void Clear(); - //---------------------------------------------------------------------- /// Compare the mangled string values /// /// Compares the Mangled::GetName() string in \a lhs and \a rhs. /// - /// @param[in] lhs + /// \param[in] lhs /// A const reference to the Left Hand Side object to compare. /// - /// @param[in] rhs + /// \param[in] rhs /// A const reference to the Right Hand Side object to compare. /// - /// @return - /// @li -1 if \a lhs is less than \a rhs - /// @li 0 if \a lhs is equal to \a rhs - /// @li 1 if \a lhs is greater than \a rhs - //---------------------------------------------------------------------- + /// \return + /// \li -1 if \a lhs is less than \a rhs + /// \li 0 if \a lhs is equal to \a rhs + /// \li 1 if \a lhs is greater than \a rhs static int Compare(const Mangled &lhs, const Mangled &rhs); - //---------------------------------------------------------------------- /// 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). /// - /// @param[in] s + /// \param[in] s /// The stream to which to dump the object description. - //---------------------------------------------------------------------- void Dump(Stream *s) const; - //---------------------------------------------------------------------- /// Dump a debug description of this object to a Stream \a s. /// - /// @param[in] s + /// \param[in] s /// The stream to which to dump the object description. - //---------------------------------------------------------------------- void DumpDebug(Stream *s) const; - //---------------------------------------------------------------------- /// Demangled name get accessor. /// - /// @return + /// \return /// A const reference to the demangled name string object. - //---------------------------------------------------------------------- - const ConstString &GetDemangledName(lldb::LanguageType language) const; + ConstString GetDemangledName(lldb::LanguageType language) const; - //---------------------------------------------------------------------- /// Display demangled name get accessor. /// - /// @return + /// \return /// A const reference to the display demangled name string object. - //---------------------------------------------------------------------- ConstString GetDisplayDemangledName(lldb::LanguageType language) const; - void SetDemangledName(const ConstString &name) { m_demangled = name; } + void SetDemangledName(ConstString name) { m_demangled = name; } - void SetMangledName(const ConstString &name) { m_mangled = name; } + void SetMangledName(ConstString name) { m_mangled = name; } - //---------------------------------------------------------------------- /// Mangled name get accessor. /// - /// @return + /// \return /// A reference to the mangled name string object. - //---------------------------------------------------------------------- ConstString &GetMangledName() { return m_mangled; } - //---------------------------------------------------------------------- /// Mangled name get accessor. /// - /// @return + /// \return /// A const reference to the mangled name string object. - //---------------------------------------------------------------------- - const ConstString &GetMangledName() const { return m_mangled; } + ConstString GetMangledName() const { return m_mangled; } - //---------------------------------------------------------------------- /// Best name get accessor. /// - /// @param[in] preference + /// \param[in] preference /// Which name would you prefer to get? /// - /// @return + /// \return /// A const reference to the preferred name string object if this /// object has a valid name of that kind, else a const reference to the /// other name is returned. - //---------------------------------------------------------------------- ConstString GetName(lldb::LanguageType language, NamePreference preference = ePreferDemangled) const; - //---------------------------------------------------------------------- /// Check if "name" matches either the mangled or demangled name. /// - /// @param[in] name + /// \param[in] name /// A name to match against both strings. /// - /// @return + /// \return /// \b True if \a name matches either name, \b false otherwise. - //---------------------------------------------------------------------- - bool NameMatches(const ConstString &name, lldb::LanguageType language) const { + bool NameMatches(ConstString name, lldb::LanguageType language) const { if (m_mangled == name) return true; return GetDemangledName(language) == name; @@ -238,47 +203,40 @@ public: bool NameMatches(const RegularExpression ®ex, lldb::LanguageType language) const; - //---------------------------------------------------------------------- /// 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 + /// \return /// The number of bytes that this object occupies in memory. /// - /// @see ConstString::StaticMemorySize () - //---------------------------------------------------------------------- + /// \see ConstString::StaticMemorySize () size_t MemorySize() const; - //---------------------------------------------------------------------- /// 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. /// - /// @param[in] name + /// \param[in] name /// The already const version of the name for this object. /// - /// @param[in] is_mangled + /// \param[in] is_mangled /// If \b true then \a name is a mangled name, if \b false then /// \a name is demangled. - //---------------------------------------------------------------------- - void SetValue(const ConstString &name, bool is_mangled); + void SetValue(ConstString name, bool is_mangled); - //---------------------------------------------------------------------- /// Set the string value in this object. /// /// This version auto detects if the string is mangled by inspecting the /// string value and looking for common mangling prefixes. /// - /// @param[in] name + /// \param[in] name /// The already const version of the name for this object. - //---------------------------------------------------------------------- - void SetValue(const ConstString &name); + void SetValue(ConstString name); - //---------------------------------------------------------------------- /// Try to guess the language from the mangling. /// /// For a mangled name to have a language it must have both a mangled and a @@ -290,16 +248,14 @@ public: /// aren't mangled and it isn't clear what language the name represents /// (there will be no mangled name). /// - /// @return + /// \return /// The language for the mangled/demangled name, eLanguageTypeUnknown /// if there is no mangled or demangled counterpart. - //---------------------------------------------------------------------- lldb::LanguageType GuessLanguage() const; /// Function signature for filtering mangled names. using SkipMangledNameFn = bool(llvm::StringRef, ManglingScheme); - //---------------------------------------------------------------------- /// Trigger explicit demangling to obtain rich mangling information. This is /// optimized for batch processing while populating a name index. To get the /// pure demangled name string for a single entity, use GetDemangledName() @@ -312,24 +268,21 @@ public: /// This function is thread-safe when used with different \a context /// instances in different threads. /// - /// @param[in] context + /// \param[in] context /// The context for this function. A single instance can be stack- /// allocated in the caller's frame and used for multiple calls. /// - /// @param[in] skip_mangled_name + /// \param[in] skip_mangled_name /// A filtering function for skipping entities based on name and mangling /// scheme. This can be null if unused. /// - /// @return + /// \return /// True on success, false otherwise. - //---------------------------------------------------------------------- bool DemangleWithRichManglingInfo(RichManglingContext &context, SkipMangledNameFn *skip_mangled_name); private: - //---------------------------------------------------------------------- /// Mangled member variables. - //---------------------------------------------------------------------- ConstString m_mangled; ///< The mangled version of the name mutable ConstString m_demangled; ///< Mutable so we can get it on demand with ///a const version of this object diff --git a/include/lldb/Core/MappedHash.h b/include/lldb/Core/MappedHash.h index 8d9a91e690793..7dc9b5be34657 100644 --- a/include/lldb/Core/MappedHash.h +++ b/include/lldb/Core/MappedHash.h @@ -1,9 +1,8 @@ //===-- MappedHash.h --------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// diff --git a/include/lldb/Core/Module.h b/include/lldb/Core/Module.h index 270a401172fac..544895ea89e9e 100644 --- a/include/lldb/Core/Module.h +++ b/include/lldb/Core/Module.h @@ -1,9 +1,8 @@ //===-- Module.h ------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -40,60 +39,24 @@ namespace lldb_private { class CompilerDeclContext; -} -namespace lldb_private { class Function; -} -namespace lldb_private { class Log; -} -namespace lldb_private { class ObjectFile; -} -namespace lldb_private { class RegularExpression; -} -namespace lldb_private { class SectionList; -} -namespace lldb_private { class Stream; -} -namespace lldb_private { class Symbol; -} -namespace lldb_private { class SymbolContext; -} -namespace lldb_private { class SymbolContextList; -} -namespace lldb_private { class SymbolFile; -} -namespace lldb_private { class SymbolVendor; -} -namespace lldb_private { class Symtab; -} -namespace lldb_private { class Target; -} -namespace lldb_private { class TypeList; -} -namespace lldb_private { class TypeMap; -} -namespace lldb_private { class VariableList; -} - -namespace lldb_private { -//---------------------------------------------------------------------- -/// @class Module Module.h "lldb/Core/Module.h" +/// \class Module Module.h "lldb/Core/Module.h" /// A class that describes an executable image and its associated /// object and symbol files. /// @@ -108,7 +71,6 @@ namespace lldb_private { /// Module::GetSymbolVendor() is called. /// /// The module will parse more detailed information as more queries are made. -//---------------------------------------------------------------------- class Module : public std::enable_shared_from_this<Module>, public SymbolContextScope { public: @@ -124,30 +86,28 @@ public: static std::recursive_mutex &GetAllocationModuleCollectionMutex(); - //------------------------------------------------------------------ /// Construct with file specification and architecture. /// /// Clients that wish to share modules with other targets should use /// ModuleList::GetSharedModule(). /// - /// @param[in] file_spec + /// \param[in] file_spec /// The file specification for the on disk representation of /// this executable image. /// - /// @param[in] arch + /// \param[in] arch /// The architecture to set as the current architecture in /// this module. /// - /// @param[in] object_name + /// \param[in] object_name /// The name of an object in a module used to extract a module /// within a module (.a files and modules that contain multiple /// architectures). /// - /// @param[in] object_offset + /// \param[in] object_offset /// The offset within an existing module used to extract a /// module within a module (.a files and modules that contain /// multiple architectures). - //------------------------------------------------------------------ Module( const FileSpec &file_spec, const ArchSpec &arch, const ConstString *object_name = nullptr, @@ -164,25 +124,26 @@ public: 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 (ArchSpec arch = module_sp->m_objfile_sp->GetArchitecture()) { - module_sp->m_arch = arch; - return module_sp; - } - return nullptr; + module_sp->m_did_load_objfile.store(true, std::memory_order_relaxed); + + // Once we get the object file, set module ArchSpec to the one we get from + // the object file. If the object file does not have an architecture, we + // consider the creation a failure. + ArchSpec arch = module_sp->m_objfile_sp->GetArchitecture(); + if (!arch) + return nullptr; + module_sp->m_arch = arch; + + // Also copy the object file's FileSpec. + module_sp->m_file = module_sp->m_objfile_sp->GetFileSpec(); + return module_sp; } - //------------------------------------------------------------------ /// Destructor. - //------------------------------------------------------------------ ~Module() override; bool MatchesModuleSpec(const ModuleSpec &module_ref); - //------------------------------------------------------------------ /// Set the load address for all sections in a module to be the file address /// plus \a slide. /// @@ -191,23 +152,23 @@ public: /// address for all top level sections to be the section file address + /// offset. /// - /// @param[in] target + /// \param[in] target /// The target in which to apply the section load addresses. /// - /// @param[in] value + /// \param[in] value /// if \a value_is_offset is true, then value is the offset to /// apply to all file addresses for all top level sections in /// the object file as each section load address is being set. /// If \a value_is_offset is false, then "value" is the new /// absolute base address for the image. /// - /// @param[in] value_is_offset + /// \param[in] value_is_offset /// If \b true, then \a value is an offset to apply to each /// file address of each top level section. /// If \b false, then \a value is the image base address that /// will be used to rigidly slide all loadable sections. /// - /// @param[out] changed + /// \param[out] changed /// If any section load addresses were changed in \a target, /// then \a changed will be set to \b true. Else \a changed /// will be set to false. This allows this function to be @@ -216,18 +177,15 @@ public: /// be false and no module updated notification will need to /// be sent out. /// - /// @return + /// \return /// /b True if any sections were successfully loaded in \a target, /// /b false otherwise. - //------------------------------------------------------------------ bool SetLoadAddress(Target &target, lldb::addr_t value, bool value_is_offset, bool &changed); - //------------------------------------------------------------------ - /// @copydoc SymbolContextScope::CalculateSymbolContext(SymbolContext*) + /// \copydoc SymbolContextScope::CalculateSymbolContext(SymbolContext*) /// - /// @see SymbolContextScope - //------------------------------------------------------------------ + /// \see SymbolContextScope void CalculateSymbolContext(SymbolContext *sc) override; lldb::ModuleSP CalculateSymbolContextModule() override; @@ -236,7 +194,6 @@ public: GetDescription(Stream *s, lldb::DescriptionLevel level = lldb::eDescriptionLevelFull); - //------------------------------------------------------------------ /// Get the module path and object name. /// /// Modules can refer to object files. In this case the specification is @@ -252,12 +209,10 @@ public: /// There are many places where logging wants to log this fully qualified /// specification, so we centralize this functionality here. /// - /// @return + /// \return /// The object path + object name if there is one. - //------------------------------------------------------------------ std::string GetSpecificationDescription() const; - //------------------------------------------------------------------ /// Dump a description of this object to a Stream. /// /// Dump a description of the contents of this object to the supplied stream @@ -265,39 +220,34 @@ public: /// 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 + /// \param[in] s /// The stream to which to dump the object description. - //------------------------------------------------------------------ void Dump(Stream *s); - //------------------------------------------------------------------ - /// @copydoc SymbolContextScope::DumpSymbolContext(Stream*) + /// \copydoc SymbolContextScope::DumpSymbolContext(Stream*) /// - /// @see SymbolContextScope - //------------------------------------------------------------------ + /// \see SymbolContextScope void DumpSymbolContext(Stream *s) override; - //------------------------------------------------------------------ /// Find a symbol in the object file's symbol table. /// - /// @param[in] name + /// \param[in] name /// The name of the symbol that we are looking for. /// - /// @param[in] symbol_type + /// \param[in] symbol_type /// If set to eSymbolTypeAny, find a symbol of any type that /// has a name that matches \a name. If set to any other valid /// SymbolType enumeration value, then search only for /// symbols that match \a symbol_type. /// - /// @return + /// \return /// Returns a valid symbol pointer if a symbol was found, /// nullptr otherwise. - //------------------------------------------------------------------ const Symbol *FindFirstSymbolWithNameAndType( - const ConstString &name, + ConstString name, lldb::SymbolType symbol_type = lldb::eSymbolTypeAny); - size_t FindSymbolsWithNameAndType(const ConstString &name, + size_t FindSymbolsWithNameAndType(ConstString name, lldb::SymbolType symbol_type, SymbolContextList &sc_list); @@ -305,132 +255,123 @@ public: lldb::SymbolType symbol_type, SymbolContextList &sc_list); - //------------------------------------------------------------------ /// Find a function symbols in the object file's symbol table. /// - /// @param[in] name + /// \param[in] name /// The name of the symbol that we are looking for. /// - /// @param[in] name_type_mask + /// \param[in] name_type_mask /// A mask that has one or more bitwise OR'ed values from the /// lldb::FunctionNameType enumeration type that indicate what /// kind of names we are looking for. /// - /// @param[out] sc_list + /// \param[out] sc_list /// A list to append any matching symbol contexts to. /// - /// @return + /// \return /// The number of symbol contexts that were added to \a sc_list - //------------------------------------------------------------------ - size_t FindFunctionSymbols(const ConstString &name, uint32_t name_type_mask, + size_t FindFunctionSymbols(ConstString name, uint32_t name_type_mask, SymbolContextList &sc_list); - //------------------------------------------------------------------ /// 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. /// - /// @param[in] path + /// \param[in] path /// The name of the function we are looking for. /// - /// @param[in] append + /// \param[in] append /// If \b true, then append any compile units that were found /// to \a sc_list. If \b false, then the \a sc_list is cleared /// and the contents of \a sc_list are replaced. /// - /// @param[out] sc_list + /// \param[out] sc_list /// A symbol context list that gets filled in with all of the /// matches. /// - /// @return + /// \return /// The number of matches added to \a sc_list. - //------------------------------------------------------------------ size_t FindCompileUnits(const FileSpec &path, bool append, SymbolContextList &sc_list); - //------------------------------------------------------------------ /// Find functions by name. /// /// 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. /// - /// @param[in] name + /// \param[in] name /// The name of the compile unit we are looking for. /// - /// @param[in] namespace_decl + /// \param[in] namespace_decl /// If valid, a namespace to search in. /// - /// @param[in] name_type_mask + /// \param[in] name_type_mask /// A bit mask of bits that indicate what kind of names should /// be used when doing the lookup. Bits include fully qualified /// names, base names, C++ methods, or ObjC selectors. /// See FunctionNameType for more details. /// - /// @param[in] append + /// \param[in] append /// If \b true, any matches will be appended to \a sc_list, else /// matches replace the contents of \a sc_list. /// - /// @param[out] sc_list + /// \param[out] sc_list /// A symbol context list that gets filled in with all of the /// matches. /// - /// @return + /// \return /// The number of matches added to \a sc_list. - //------------------------------------------------------------------ - size_t FindFunctions(const ConstString &name, + size_t FindFunctions(ConstString name, const CompilerDeclContext *parent_decl_ctx, lldb::FunctionNameType name_type_mask, bool symbols_ok, bool inlines_ok, bool append, SymbolContextList &sc_list); - //------------------------------------------------------------------ /// Find functions by name. /// /// 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. /// - /// @param[in] regex + /// \param[in] regex /// A regular expression to use when matching the name. /// - /// @param[in] append + /// \param[in] append /// If \b true, any matches will be appended to \a sc_list, else /// matches replace the contents of \a sc_list. /// - /// @param[out] sc_list + /// \param[out] sc_list /// A symbol context list that gets filled in with all of the /// matches. /// - /// @return + /// \return /// The number of matches added to \a sc_list. - //------------------------------------------------------------------ size_t FindFunctions(const RegularExpression ®ex, bool symbols_ok, bool inlines_ok, bool append, SymbolContextList &sc_list); - //------------------------------------------------------------------ /// Find addresses by file/line /// - /// @param[in] target_sp + /// \param[in] target_sp /// The target the addresses are desired for. /// - /// @param[in] file + /// \param[in] file /// Source file to locate. /// - /// @param[in] line + /// \param[in] line /// Source line to locate. /// - /// @param[in] function + /// \param[in] function /// Optional filter function. Addresses within this function will be /// added to the 'local' list. All others will be added to the 'extern' /// list. /// - /// @param[out] output_local + /// \param[out] output_local /// All matching addresses within 'function' /// - /// @param[out] output_extern + /// \param[out] output_extern /// All matching addresses not within 'function' void FindAddressesForLine(const lldb::TargetSP target_sp, const FileSpec &file, uint32_t line, @@ -438,50 +379,45 @@ public: std::vector<Address> &output_local, std::vector<Address> &output_extern); - //------------------------------------------------------------------ /// Find global and static variables by name. /// - /// @param[in] name + /// \param[in] name /// The name of the global or static variable we are looking /// for. /// - /// @param[in] parent_decl_ctx + /// \param[in] parent_decl_ctx /// If valid, a decl context that results must exist within /// - /// @param[in] max_matches + /// \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 + /// \param[in] variable_list /// A list of variables that gets the matches appended to. /// - /// @return + /// \return /// The number of matches added to \a variable_list. - //------------------------------------------------------------------ - size_t FindGlobalVariables(const ConstString &name, + size_t FindGlobalVariables(ConstString name, const CompilerDeclContext *parent_decl_ctx, size_t max_matches, VariableList &variable_list); - //------------------------------------------------------------------ /// Find global and static variables by regular expression. /// - /// @param[in] regex + /// \param[in] regex /// A regular expression to use when matching the name. /// - /// @param[in] max_matches + /// \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 + /// \param[in] variable_list /// A list of variables that gets the matches appended to. /// - /// @return + /// \return /// The number of matches added to \a 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 @@ -499,74 +435,66 @@ public: /// have to specify complete scoping on all expressions, but it also allows /// for exact matching when required. /// - /// @param[in] type_name + /// \param[in] type_name /// The name of the type we are looking for that is a fully /// or partially qualified type name. /// - /// @param[in] exact_match + /// \param[in] exact_match /// If \b true, \a type_name is fully qualified and must match /// exactly. If \b false, \a type_name is a partially qualified /// name where the leading namespaces or classes can be /// omitted to make finding types that a user may type /// easier. /// - /// @param[out] type_list + /// \param[out] type_list /// A type list gets populated with any matches. /// - /// @return + /// \return /// The number of matches added to \a type_list. - //------------------------------------------------------------------ size_t - FindTypes(const ConstString &type_name, bool exact_match, size_t max_matches, + FindTypes(ConstString type_name, bool exact_match, size_t max_matches, llvm::DenseSet<lldb_private::SymbolFile *> &searched_symbol_files, TypeList &types); lldb::TypeSP FindFirstType(const SymbolContext &sc, - const ConstString &type_name, bool exact_match); + 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. /// - /// @param[in] type_name + /// \param[in] type_name /// The name of a type within a namespace that should not include /// any qualifying namespaces (just a type basename). /// - /// @param[in] namespace_decl + /// \param[in] namespace_decl /// The namespace declaration that this type must exist in. /// - /// @param[out] type_list + /// \param[out] type_list /// A type list gets populated with any matches. /// - /// @return + /// \return /// The number of matches added to \a type_list. - //------------------------------------------------------------------ - size_t FindTypesInNamespace(const ConstString &type_name, + size_t FindTypesInNamespace(ConstString type_name, const CompilerDeclContext *parent_decl_ctx, size_t max_matches, TypeList &type_list); - //------------------------------------------------------------------ /// Get const accessor for the module architecture. /// - /// @return + /// \return /// A const reference to the architecture object. - //------------------------------------------------------------------ const ArchSpec &GetArchitecture() const; - //------------------------------------------------------------------ /// Get const accessor for the module file specification. /// /// This function returns the file for the module on the host system that is /// running LLDB. This can differ from the path on the platform since we /// might be doing remote debugging. /// - /// @return + /// \return /// A const reference to the file specification object. - //------------------------------------------------------------------ const FileSpec &GetFileSpec() const { return m_file; } - //------------------------------------------------------------------ /// Get accessor for the module platform file specification. /// /// Platform file refers to the path of the module as it is known on the @@ -577,9 +505,8 @@ public: /// "/tmp/lldb/platform-cache/remote.host.computer/usr/lib/liba.dylib" The /// file could also be cached in a local developer kit directory. /// - /// @return + /// \return /// A const reference to the file specification object. - //------------------------------------------------------------------ const FileSpec &GetPlatformFileSpec() const { if (m_platform_file) return m_platform_file; @@ -614,63 +541,54 @@ public: m_mod_time = mod_time; } - //------------------------------------------------------------------ /// Tells whether this module is capable of being the main executable for a /// process. /// - /// @return + /// \return /// \b true if it is, \b false otherwise. - //------------------------------------------------------------------ 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. /// - /// @param[in] target + /// \param[in] target /// The target to check whether this is loaded in. /// - /// @return + /// \return /// \b true if it is, \b false otherwise. - //------------------------------------------------------------------ bool IsLoadedInTarget(Target *target); bool LoadScriptingResourceInTarget(Target *target, Status &error, Stream *feedback_stream = nullptr); - //------------------------------------------------------------------ /// Get the number of compile units for this module. /// - /// @return + /// \return /// The number of compile units that the symbol vendor plug-in /// finds. - //------------------------------------------------------------------ size_t GetNumCompileUnits(); lldb::CompUnitSP GetCompileUnitAtIndex(size_t idx); - const ConstString &GetObjectName() const; + ConstString GetObjectName() const; uint64_t GetObjectOffset() const { return m_object_offset; } - //------------------------------------------------------------------ /// 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. /// - /// @return + /// \return /// If Module::m_file does not exist, or no plug-in was found /// that can parse the file, or the object file doesn't contain /// the current architecture in Module::m_arch, nullptr will be /// returned, else a valid object file interface will be /// returned. The returned pointer is owned by this object and /// remains valid as long as the object is around. - //------------------------------------------------------------------ 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. @@ -678,12 +596,10 @@ public: /// If the symbol vendor has not been loaded yet, this function will return /// the section list for the object file. /// - /// @return + /// \return /// Unified module section list. - //------------------------------------------------------------------ virtual SectionList *GetSectionList(); - //------------------------------------------------------------------ /// Notify the module that the file addresses for the Sections have been /// updated. /// @@ -691,12 +607,23 @@ public: /// 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(); + /// Returns a reference to the UnwindTable for this Module + /// + /// The UnwindTable contains FuncUnwinders objects for any function in this + /// Module. 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 module. If this object has no + /// associated object file, an empty UnwindTable is returned. + UnwindTable &GetUnwindTable(); + llvm::VersionTuple GetVersion(); - //------------------------------------------------------------------ /// Load an object file from memory. /// /// If available, the size of the object file in memory may be passed to @@ -705,54 +632,46 @@ public: /// enable the ObjectFile plugins to read the header of the object file /// without going back to the process. /// - /// @return + /// \return /// The object file loaded from memory or nullptr, if the operation /// failed (see the `error` for more information in that case). - //------------------------------------------------------------------ ObjectFile *GetMemoryObjectFile(const lldb::ProcessSP &process_sp, lldb::addr_t header_addr, Status &error, size_t size_to_read = 512); - //------------------------------------------------------------------ /// 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. /// - /// @return + /// \return /// If this module does not have a valid object file, or no /// plug-in can be found that can use the object file, nullptr will /// be returned, else a valid symbol vendor plug-in interface /// will be returned. The returned pointer is owned by this /// object and remains valid as long as the object is around. - //------------------------------------------------------------------ virtual SymbolVendor * GetSymbolVendor(bool can_create = true, lldb_private::Stream *feedback_strm = nullptr); - //------------------------------------------------------------------ /// Get accessor the type list for this module. /// - /// @return + /// \return /// A valid type list pointer, or nullptr if there is no valid /// symbol vendor for this module. - //------------------------------------------------------------------ TypeList *GetTypeList(); - //------------------------------------------------------------------ /// 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. /// - /// @return + /// \return /// A const pointer to the internal copy of the UUID value in /// this module if this module has a valid UUID value, NULL /// otherwise. - //------------------------------------------------------------------ const lldb_private::UUID &GetUUID(); - //------------------------------------------------------------------ /// A debugging function that will cause everything in a module to /// be parsed. /// @@ -763,12 +682,10 @@ public: /// 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(); bool ResolveFileAddress(lldb::addr_t vm_addr, Address &so_addr); - //------------------------------------------------------------------ /// Resolve the symbol context for the given address. /// /// Tries to resolve the matching symbol context based on a lookup from the @@ -782,10 +699,10 @@ public: /// line entry. Use the return value to determine which of these properties /// have been modified. /// - /// @param[in] so_addr + /// \param[in] so_addr /// A load address to resolve. /// - /// @param[in] resolve_scope + /// \param[in] resolve_scope /// The scope that should be resolved (see SymbolContext::Scope). /// A combination of flags from the enumeration SymbolContextItem /// requesting a resolution depth. Note that the flags that are @@ -794,24 +711,22 @@ public: /// eSymbolContextModule, and eSymbolContextFunction requires /// eSymbolContextSymbol. /// - /// @param[out] sc + /// \param[out] sc /// The SymbolContext that is modified based on symbol resolution. /// - /// @param[in] resolve_tail_call_address + /// \param[in] resolve_tail_call_address /// Determines if so_addr should resolve to a symbol in the case /// of a function whose last instruction is a call. In this case, /// the PC can be one past the address range of the function. /// - /// @return + /// \return /// The scope that has been resolved (see SymbolContext::Scope). /// - /// @see SymbolContext::Scope - //------------------------------------------------------------------ + /// \see SymbolContext::Scope uint32_t ResolveSymbolContextForAddress( const Address &so_addr, lldb::SymbolContextItem resolve_scope, SymbolContext &sc, bool resolve_tail_call_address = false); - //------------------------------------------------------------------ /// Resolve items in the symbol context for a given file and line. /// /// Tries to resolve \a file_path and \a line to a list of matching symbol @@ -823,40 +738,38 @@ public: /// to only what is needed -- typically the module, compile unit, line table /// and line table entry are sufficient. /// - /// @param[in] file_path + /// \param[in] file_path /// A path to a source file to match. If \a file_path does not /// specify a directory, then this query will match all files /// whose base filename matches. If \a file_path does specify /// a directory, the fullpath to the file must match. /// - /// @param[in] line + /// \param[in] line /// The source line to match, or zero if just the compile unit /// should be resolved. /// - /// @param[in] check_inlines + /// \param[in] check_inlines /// Check for inline file and line number matches. This option /// should be used sparingly as it will cause all line tables /// for every compile unit to be parsed and searched for /// matching inline file entries. /// - /// @param[in] resolve_scope + /// \param[in] resolve_scope /// The scope that should be resolved (see /// SymbolContext::Scope). /// - /// @param[out] sc_list + /// \param[out] sc_list /// A symbol context list that gets matching symbols contexts /// appended to. /// - /// @return + /// \return /// The number of matches that were added to \a sc_list. /// - /// @see SymbolContext::Scope - //------------------------------------------------------------------ + /// \see SymbolContext::Scope uint32_t ResolveSymbolContextForFilePath( const char *file_path, uint32_t line, bool check_inlines, lldb::SymbolContextItem resolve_scope, SymbolContextList &sc_list); - //------------------------------------------------------------------ /// Resolve items in the symbol context for a given file and line. /// /// Tries to resolve \a file_spec and \a line to a list of matching symbol @@ -868,42 +781,41 @@ public: /// to only what is needed -- typically the module, compile unit, line table /// and line table entry are sufficient. /// - /// @param[in] file_spec + /// \param[in] file_spec /// A file spec to a source file to match. If \a file_path does /// not specify a directory, then this query will match all /// files whose base filename matches. If \a file_path does /// specify a directory, the fullpath to the file must match. /// - /// @param[in] line + /// \param[in] line /// The source line to match, or zero if just the compile unit /// should be resolved. /// - /// @param[in] check_inlines + /// \param[in] check_inlines /// Check for inline file and line number matches. This option /// should be used sparingly as it will cause all line tables /// for every compile unit to be parsed and searched for /// matching inline file entries. /// - /// @param[in] resolve_scope + /// \param[in] resolve_scope /// The scope that should be resolved (see /// SymbolContext::Scope). /// - /// @param[out] sc_list + /// \param[out] sc_list /// A symbol context list that gets filled in with all of the /// matches. /// - /// @return + /// \return /// A integer that contains SymbolContext::Scope bits set for /// each item that was successfully resolved. /// - /// @see SymbolContext::Scope - //------------------------------------------------------------------ + /// \see SymbolContext::Scope uint32_t ResolveSymbolContextsForFileSpec( const FileSpec &file_spec, uint32_t line, bool check_inlines, lldb::SymbolContextItem resolve_scope, SymbolContextList &sc_list); void SetFileSpecAndObjectName(const FileSpec &file, - const ConstString &object_name); + ConstString object_name); bool GetIsDynamicLinkEditor(); @@ -931,17 +843,13 @@ public: void ReportErrorIfModifyDetected(const char *format, ...) __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. - //------------------------------------------------------------------ bool FileHasChanged() const; - //------------------------------------------------------------------ // SymbolVendor, SymbolFile and ObjectFile member objects should lock the // module mutex to avoid deadlocks. - //------------------------------------------------------------------ std::recursive_mutex &GetMutex() const { return m_mutex; } PathMappingList &GetSourceMappingList() { return m_source_mappings; } @@ -950,7 +858,6 @@ public: return m_source_mappings; } - //------------------------------------------------------------------ /// Finds a source file given a file spec using the module source path /// remappings (if any). /// @@ -959,41 +866,37 @@ public: /// 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 + /// \param[in] orig_spec /// The original source file path to try and remap. /// - /// @param[out] new_spec + /// \param[out] new_spec /// The newly remapped filespec that is guaranteed to exist. /// - /// @return + /// \return /// /b true if \a orig_spec was successfully located and /// \a new_spec is filled in with an existing file spec, /// \b false otherwise. - //------------------------------------------------------------------ bool FindSourceFile(const FileSpec &orig_spec, FileSpec &new_spec) const; - //------------------------------------------------------------------ /// 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. /// - /// @param[in] path + /// \param[in] path /// The original source file path to try and remap. /// - /// @param[out] new_path + /// \param[out] new_path /// The newly remapped filespec that is may or may not exist. /// - /// @return + /// \return /// /b true if \a path was successfully located and \a new_path /// is filled in with a new source path, \b false otherwise. - //------------------------------------------------------------------ bool RemapSourceFile(llvm::StringRef path, std::string &new_path) const; bool RemapSourceFile(const char *, std::string &) const = delete; - //---------------------------------------------------------------------- - /// @class LookupInfo Module.h "lldb/Core/Module.h" + /// \class LookupInfo Module.h "lldb/Core/Module.h" /// A class that encapsulates name lookup information. /// /// Users can type a wide variety of partial names when setting breakpoints @@ -1014,7 +917,6 @@ public: /// Function lookups are done in Module.cpp, ModuleList.cpp and in /// BreakpointResolverName.cpp and they all now use this class to do lookups /// correctly. - //---------------------------------------------------------------------- class LookupInfo { public: LookupInfo() @@ -1022,16 +924,16 @@ public: m_name_type_mask(lldb::eFunctionNameTypeNone), m_match_name_after_lookup(false) {} - LookupInfo(const ConstString &name, lldb::FunctionNameType name_type_mask, + LookupInfo(ConstString name, lldb::FunctionNameType name_type_mask, lldb::LanguageType language); - const ConstString &GetName() const { return m_name; } + ConstString GetName() const { return m_name; } - void SetName(const ConstString &name) { m_name = name; } + void SetName(ConstString name) { m_name = name; } - const ConstString &GetLookupName() const { return m_lookup_name; } + ConstString GetLookupName() const { return m_lookup_name; } - void SetLookupName(const ConstString &name) { m_lookup_name = name; } + void SetLookupName(ConstString name) { m_lookup_name = name; } lldb::FunctionNameType GetNameTypeMask() const { return m_name_type_mask; } @@ -1061,9 +963,7 @@ public: }; protected: - //------------------------------------------------------------------ // Member Variables - //------------------------------------------------------------------ mutable std::recursive_mutex m_mutex; ///< A mutex to keep this object happy ///in multi-threaded environments. @@ -1091,8 +991,11 @@ protected: lldb::ObjectFileSP m_objfile_sp; ///< A shared pointer to the object file ///parser for this module as it may or may ///not be shared with the SymbolFile + llvm::Optional<UnwindTable> m_unwind_table; ///< Table of FuncUnwinders + /// objects created for this + /// Module's functions lldb::SymbolVendorUP - m_symfile_ap; ///< A pointer to the symbol vendor for this module. + m_symfile_up; ///< A pointer to the symbol vendor for this module. std::vector<lldb::SymbolVendorUP> m_old_symfiles; ///< If anyone calls Module::SetSymbolFileFileSpec() and ///changes the symbol file, @@ -1104,9 +1007,9 @@ protected: ///when you have debug info for a module ///that doesn't match where the sources ///currently are - lldb::SectionListUP m_sections_ap; ///< Unified section list for module that - ///is used by the ObjectFile and and - ///ObjectFile instances for the debug info + lldb::SectionListUP m_sections_up; ///< Unified section list for module that + /// is used by the ObjectFile and and + /// ObjectFile instances for the debug info std::atomic<bool> m_did_load_objfile{false}; std::atomic<bool> m_did_load_symbol_vendor{false}; @@ -1115,7 +1018,6 @@ protected: m_first_file_changed_log : 1; /// See if the module was modified after it /// was initially opened. - //------------------------------------------------------------------ /// Resolve a file or load virtual address. /// /// Tries to resolve \a vm_addr as a file address (if \a @@ -1124,31 +1026,30 @@ protected: /// indicates what clients wish to resolve and can be used to limit the /// scope of what is parsed. /// - /// @param[in] vm_addr + /// \param[in] vm_addr /// The load virtual address to resolve. /// - /// @param[in] vm_addr_is_file_addr + /// \param[in] vm_addr_is_file_addr /// If \b true, \a vm_addr is a file address, else \a vm_addr /// if a load address. /// - /// @param[in] resolve_scope + /// \param[in] resolve_scope /// The scope that should be resolved (see /// SymbolContext::Scope). /// - /// @param[out] so_addr + /// \param[out] so_addr /// The section offset based address that got resolved if /// any bits are returned. /// - /// @param[out] sc + /// \param[out] sc // The symbol context that has objects filled in. Each bit /// in the \a resolve_scope pertains to a member in the \a sc. /// - /// @return + /// \return /// A integer that contains SymbolContext::Scope bits set for /// each item that was successfully resolved. /// - /// @see SymbolContext::Scope - //------------------------------------------------------------------ + /// \see SymbolContext::Scope uint32_t ResolveSymbolContextForAddress(lldb::addr_t vm_addr, bool vm_addr_is_file_addr, lldb::SymbolContextItem resolve_scope, @@ -1172,7 +1073,7 @@ private: Module(); // Only used internally by CreateJITModule () size_t FindTypes_Impl( - const ConstString &name, const CompilerDeclContext *parent_decl_ctx, + ConstString name, const CompilerDeclContext *parent_decl_ctx, bool append, size_t max_matches, llvm::DenseSet<lldb_private::SymbolFile *> &searched_symbol_files, TypeMap &types); diff --git a/include/lldb/Core/ModuleChild.h b/include/lldb/Core/ModuleChild.h index 73438040c3595..8a81c1a6cf8a6 100644 --- a/include/lldb/Core/ModuleChild.h +++ b/include/lldb/Core/ModuleChild.h @@ -1,9 +1,8 @@ //===-- ModuleChild.h -------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -14,68 +13,46 @@ namespace lldb_private { -//---------------------------------------------------------------------- -/// @class ModuleChild ModuleChild.h "lldb/Core/ModuleChild.h" +/// \class ModuleChild ModuleChild.h "lldb/Core/ModuleChild.h" /// A mix in class that contains a pointer back to the module /// that owns the object which inherits from it. -//---------------------------------------------------------------------- class ModuleChild { public: - //------------------------------------------------------------------ /// Construct with owning module. /// - /// @param[in] module + /// \param[in] module /// The module that owns the object that inherits from this /// class. - //------------------------------------------------------------------ ModuleChild(const lldb::ModuleSP &module_sp); - //------------------------------------------------------------------ - /// Copy constructor. - /// - /// @param[in] rhs - /// A const ModuleChild class reference to copy. - //------------------------------------------------------------------ - ModuleChild(const ModuleChild &rhs); - - //------------------------------------------------------------------ /// Destructor. - //------------------------------------------------------------------ ~ModuleChild(); - //------------------------------------------------------------------ /// Assignment operator. /// - /// @param[in] rhs + /// \param[in] rhs /// A const ModuleChild class reference to copy. /// - /// @return + /// \return /// A const reference to this object. - //------------------------------------------------------------------ const ModuleChild &operator=(const ModuleChild &rhs); - //------------------------------------------------------------------ /// Get const accessor for the module pointer. /// - /// @return + /// \return /// A const pointer to the module that owns the object that /// inherits from this class. - //------------------------------------------------------------------ lldb::ModuleSP GetModule() const; - //------------------------------------------------------------------ /// Set accessor for the module pointer. /// - /// @param[in] module + /// \param[in] module /// A new module that owns the object that inherits from this /// class. - //------------------------------------------------------------------ void SetModule(const lldb::ModuleSP &module_sp); protected: - //------------------------------------------------------------------ // Member variables - //------------------------------------------------------------------ lldb::ModuleWP m_module_wp; ///< The Module that owns the object that inherits ///< from this class. }; diff --git a/include/lldb/Core/ModuleList.h b/include/lldb/Core/ModuleList.h index a28d97113d63e..1e26c35e4c157 100644 --- a/include/lldb/Core/ModuleList.h +++ b/include/lldb/Core/ModuleList.h @@ -1,9 +1,8 @@ //===-- ModuleList.h --------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -32,48 +31,19 @@ namespace lldb_private { class ConstString; -} -namespace lldb_private { class FileSpecList; -} -namespace lldb_private { class Function; -} -namespace lldb_private { class Log; -} -namespace lldb_private { class Module; -} -namespace lldb_private { class RegularExpression; -} -namespace lldb_private { class Stream; -} -namespace lldb_private { class SymbolContext; -} -namespace lldb_private { class SymbolContextList; -} -namespace lldb_private { class SymbolFile; -} -namespace lldb_private { class Target; -} -namespace lldb_private { class TypeList; -} -namespace lldb_private { class UUID; -} -namespace lldb_private { class VariableList; -} - -namespace lldb_private { class ModuleListProperties : public Properties { public: @@ -82,91 +52,101 @@ public: FileSpec GetClangModulesCachePath() const; bool SetClangModulesCachePath(llvm::StringRef path); bool GetEnableExternalLookup() const; + bool SetEnableExternalLookup(bool new_value); }; -//---------------------------------------------------------------------- -/// @class ModuleList ModuleList.h "lldb/Core/ModuleList.h" +/// \class ModuleList ModuleList.h "lldb/Core/ModuleList.h" /// A collection class for Module objects. /// /// Modules in the module collection class are stored as reference counted /// shared pointers to Module objects. -//---------------------------------------------------------------------- class ModuleList { public: class Notifier { public: virtual ~Notifier() = default; - virtual void ModuleAdded(const ModuleList &module_list, - const lldb::ModuleSP &module_sp) = 0; - virtual void ModuleRemoved(const ModuleList &module_list, - const lldb::ModuleSP &module_sp) = 0; - virtual void ModuleUpdated(const ModuleList &module_list, - const lldb::ModuleSP &old_module_sp, - const lldb::ModuleSP &new_module_sp) = 0; - virtual void WillClearList(const ModuleList &module_list) = 0; + virtual void NotifyModuleAdded(const ModuleList &module_list, + const lldb::ModuleSP &module_sp) = 0; + virtual void NotifyModuleRemoved(const ModuleList &module_list, + const lldb::ModuleSP &module_sp) = 0; + virtual void NotifyModuleUpdated(const ModuleList &module_list, + const lldb::ModuleSP &old_module_sp, + const lldb::ModuleSP &new_module_sp) = 0; + virtual void NotifyWillClearList(const ModuleList &module_list) = 0; + + virtual void NotifyModulesRemoved(lldb_private::ModuleList &module_list) = 0; }; - //------------------------------------------------------------------ /// Default constructor. /// /// Creates an empty list of Module objects. - //------------------------------------------------------------------ ModuleList(); - //------------------------------------------------------------------ /// Copy Constructor. /// /// Creates a new module list object with a copy of the modules from \a rhs. /// - /// @param[in] rhs + /// \param[in] rhs /// Another module list object. - //------------------------------------------------------------------ ModuleList(const ModuleList &rhs); ModuleList(ModuleList::Notifier *notifier); - //------------------------------------------------------------------ /// Destructor. - //------------------------------------------------------------------ ~ModuleList(); - //------------------------------------------------------------------ /// Assignment operator. /// /// Copies the module list from \a rhs into this list. /// - /// @param[in] rhs + /// \param[in] rhs /// Another module list object. /// - /// @return + /// \return /// A const reference to this object. - //------------------------------------------------------------------ const ModuleList &operator=(const ModuleList &rhs); - //------------------------------------------------------------------ /// Append a module to the module list. /// - /// Appends the module to the collection. - /// - /// @param[in] module_sp + /// \param[in] module_sp /// A shared pointer to a module to add to this collection. - //------------------------------------------------------------------ - void Append(const lldb::ModuleSP &module_sp); + /// + /// \param[in] notify + /// If true, and a notifier function is set, the notifier function + /// will be called. Defaults to true. + /// + /// When this ModuleList is the Target's ModuleList, the notifier + /// function is Target::ModulesDidLoad -- the call to + /// ModulesDidLoad may be deferred when adding multiple Modules + /// to the Target, but it must be called at the end, + /// before resuming execution. + void Append(const lldb::ModuleSP &module_sp, bool notify = true); - //------------------------------------------------------------------ /// 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. /// - /// @param[in] module_sp + /// \param[in] module_sp /// A shared pointer to a module to replace in this collection. - //------------------------------------------------------------------ void ReplaceEquivalent(const lldb::ModuleSP &module_sp); - bool AppendIfNeeded(const lldb::ModuleSP &module_sp); + /// Append a module to the module list, if it is not already there. + /// + /// \param[in] module_sp + /// + /// \param[in] notify + /// If true, and a notifier function is set, the notifier function + /// will be called. Defaults to true. + /// + /// When this ModuleList is the Target's ModuleList, the notifier + /// function is Target::ModulesDidLoad -- the call to + /// ModulesDidLoad may be deferred when adding multiple Modules + /// to the Target, but it must be called at the end, + /// before resuming execution. + bool AppendIfNeeded(const lldb::ModuleSP &module_sp, bool notify = true); void Append(const ModuleList &module_list); @@ -175,36 +155,30 @@ public: bool ReplaceModule(const lldb::ModuleSP &old_module_sp, const lldb::ModuleSP &new_module_sp); - //------------------------------------------------------------------ /// 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. - //------------------------------------------------------------------ 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) - //------------------------------------------------------------------ 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. /// - /// @param[in] s + /// \param[in] s /// The stream to which to dump the object description. /// - /// @see Module::Dump(Stream *) const - //------------------------------------------------------------------ + /// \see Module::Dump(Stream *) const void Dump(Stream *s) const; void LogUUIDAndPaths(Log *log, const char *prefix_cstr); @@ -213,155 +187,134 @@ public: size_t GetIndexForModule(const Module *module) const; - //------------------------------------------------------------------ /// Get the module shared pointer for the module at index \a idx. /// - /// @param[in] idx + /// \param[in] idx /// An index into this module collection. /// - /// @return + /// \return /// A shared pointer to a Module which can contain NULL if /// \a idx is out of range. /// - /// @see ModuleList::GetSize() - //------------------------------------------------------------------ + /// \see ModuleList::GetSize() lldb::ModuleSP GetModuleAtIndex(size_t idx) const; - //------------------------------------------------------------------ /// 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. /// - /// @param[in] idx + /// \param[in] idx /// An index into this module collection. /// - /// @return + /// \return /// A shared pointer to a Module which can contain NULL if /// \a idx is out of range. /// - /// @see ModuleList::GetSize() - //------------------------------------------------------------------ + /// \see ModuleList::GetSize() lldb::ModuleSP GetModuleAtIndexUnlocked(size_t idx) const; - //------------------------------------------------------------------ /// Get the module pointer for the module at index \a idx. /// - /// @param[in] idx + /// \param[in] idx /// An index into this module collection. /// - /// @return + /// \return /// A pointer to a Module which can by nullptr if \a idx is out /// of range. /// - /// @see ModuleList::GetSize() - //------------------------------------------------------------------ + /// \see ModuleList::GetSize() 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. /// - /// @param[in] idx + /// \param[in] idx /// An index into this module collection. /// - /// @return + /// \return /// A pointer to a Module which can by nullptr if \a idx is out /// of range. /// - /// @see ModuleList::GetSize() - //------------------------------------------------------------------ + /// \see ModuleList::GetSize() Module *GetModulePointerAtIndexUnlocked(size_t idx) const; - //------------------------------------------------------------------ /// 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. /// - /// @param[in] path + /// \param[in] path /// The name of the compile unit we are looking for. /// - /// @param[in] append + /// \param[in] append /// If \b true, then append any compile units that were found /// to \a sc_list. If \b false, then the \a sc_list is cleared /// and the contents of \a sc_list are replaced. /// - /// @param[out] sc_list + /// \param[out] sc_list /// A symbol context list that gets filled in with all of the /// matches. /// - /// @return + /// \return /// The number of matches added to \a sc_list. - //------------------------------------------------------------------ size_t FindCompileUnits(const FileSpec &path, bool append, SymbolContextList &sc_list) const; - //------------------------------------------------------------------ - /// @see Module::FindFunctions () - //------------------------------------------------------------------ - size_t FindFunctions(const ConstString &name, + /// \see Module::FindFunctions () + size_t FindFunctions(ConstString name, lldb::FunctionNameType name_type_mask, bool include_symbols, bool include_inlines, bool append, SymbolContextList &sc_list) const; - //------------------------------------------------------------------ - /// @see Module::FindFunctionSymbols () - //------------------------------------------------------------------ - size_t FindFunctionSymbols(const ConstString &name, + /// \see Module::FindFunctionSymbols () + size_t FindFunctionSymbols(ConstString name, lldb::FunctionNameType name_type_mask, SymbolContextList &sc_list); - //------------------------------------------------------------------ - /// @see Module::FindFunctions () - //------------------------------------------------------------------ + /// \see Module::FindFunctions () size_t FindFunctions(const RegularExpression &name, bool include_symbols, bool include_inlines, bool append, SymbolContextList &sc_list); - //------------------------------------------------------------------ /// Find global and static variables by name. /// - /// @param[in] name + /// \param[in] name /// The name of the global or static variable we are looking /// for. /// - /// @param[in] max_matches + /// \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 + /// \param[in] variable_list /// A list of variables that gets the matches appended to. /// - /// @return + /// \return /// The number of matches added to \a variable_list. - //------------------------------------------------------------------ - size_t FindGlobalVariables(const ConstString &name, size_t max_matches, + size_t FindGlobalVariables(ConstString name, size_t max_matches, VariableList &variable_list) const; - //------------------------------------------------------------------ /// Find global and static variables by regular expression. /// - /// @param[in] regex + /// \param[in] regex /// A regular expression to use when matching the name. /// - /// @param[in] max_matches + /// \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 + /// \param[in] variable_list /// A list of variables that gets the matches appended to. /// - /// @return + /// \return /// The number of matches added to \a variable_list. - //------------------------------------------------------------------ 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. /// - /// @param[in] file_spec_ptr + /// \param[in] file_spec_ptr /// A file specification object to match against the Module's /// file specifications. If \a file_spec does not have /// directory information, matches will occur by matching only @@ -369,42 +322,39 @@ public: /// NULL, then file specifications won't be compared when /// searching for matching modules. /// - /// @param[in] arch_ptr + /// \param[in] arch_ptr /// The architecture to search for if non-NULL. If this value /// is NULL no architecture matching will be performed. /// - /// @param[in] uuid_ptr + /// \param[in] uuid_ptr /// The uuid to search for if non-NULL. If this value is NULL /// no uuid matching will be performed. /// - /// @param[in] object_name + /// \param[in] object_name /// An optional object name that must match as well. This value /// can be NULL. /// - /// @param[out] matching_module_list + /// \param[out] matching_module_list /// A module list that gets filled in with any modules that /// match the search criteria. /// - /// @return + /// \return /// The number of matching modules found by the search. - //------------------------------------------------------------------ size_t FindModules(const ModuleSpec &module_spec, ModuleList &matching_module_list) const; lldb::ModuleSP FindModule(const Module *module_ptr) const; - //------------------------------------------------------------------ // 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. - //------------------------------------------------------------------ lldb::ModuleSP FindModule(const UUID &uuid) const; lldb::ModuleSP FindFirstModule(const ModuleSpec &module_spec) const; - size_t FindSymbolsWithNameAndType(const ConstString &name, + size_t FindSymbolsWithNameAndType(ConstString name, lldb::SymbolType symbol_type, SymbolContextList &sc_list, bool append = false) const; @@ -414,67 +364,64 @@ public: SymbolContextList &sc_list, bool append = false) const; - //------------------------------------------------------------------ /// Find types by name. /// - /// @param[in] search_first + /// \param[in] search_first /// If non-null, this module will be searched before any other /// modules. /// - /// @param[in] name + /// \param[in] name /// The name of the type we are looking for. /// - /// @param[in] append + /// \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 + /// \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] encoding + /// \param[in] encoding /// Limit the search to specific types, or get all types if /// set to Type::invalid. /// - /// @param[in] udt_name + /// \param[in] udt_name /// If the encoding is a user defined type, specify the name /// of the user defined type ("struct", "union", "class", etc). /// - /// @param[out] type_list + /// \param[out] type_list /// A type list gets populated with any matches. /// - /// @return + /// \return /// The number of matches added to \a type_list. - //------------------------------------------------------------------ - size_t FindTypes(Module *search_first, const ConstString &name, + size_t FindTypes(Module *search_first, ConstString name, bool name_is_fully_qualified, size_t max_matches, llvm::DenseSet<SymbolFile *> &searched_symbol_files, TypeList &types) const; bool FindSourceFile(const FileSpec &orig_spec, FileSpec &new_spec) const; - //------------------------------------------------------------------ /// Find addresses by file/line /// - /// @param[in] target_sp + /// \param[in] target_sp /// The target the addresses are desired for. /// - /// @param[in] file + /// \param[in] file /// Source file to locate. /// - /// @param[in] line + /// \param[in] line /// Source line to locate. /// - /// @param[in] function + /// \param[in] function /// Optional filter function. Addresses within this function will be /// added to the 'local' list. All others will be added to the 'extern' /// list. /// - /// @param[out] output_local + /// \param[out] output_local /// All matching addresses within 'function' /// - /// @param[out] output_extern + /// \param[out] output_extern /// All matching addresses not within 'function' void FindAddressesForLine(const lldb::TargetSP target_sp, const FileSpec &file, uint32_t line, @@ -482,7 +429,21 @@ public: std::vector<Address> &output_local, std::vector<Address> &output_extern); - bool Remove(const lldb::ModuleSP &module_sp); + /// Remove a module from the module list. + /// + /// \param[in] module_sp + /// A shared pointer to a module to remove from this collection. + /// + /// \param[in] notify + /// If true, and a notifier function is set, the notifier function + /// will be called. Defaults to true. + /// + /// When this ModuleList is the Target's ModuleList, the notifier + /// function is Target::ModulesDidUnload -- the call to + /// ModulesDidUnload may be deferred when removing multiple Modules + /// from the Target, but it must be called at the end, + /// before resuming execution. + bool Remove(const lldb::ModuleSP &module_sp, bool notify = true); size_t Remove(ModuleList &module_list); @@ -492,36 +453,28 @@ public: bool ResolveFileAddress(lldb::addr_t vm_addr, Address &so_addr) const; - //------------------------------------------------------------------ - /// @copydoc Module::ResolveSymbolContextForAddress (const Address + /// \copydoc Module::ResolveSymbolContextForAddress (const Address /// &,uint32_t,SymbolContext&) - //------------------------------------------------------------------ uint32_t ResolveSymbolContextForAddress(const Address &so_addr, lldb::SymbolContextItem resolve_scope, SymbolContext &sc) const; - //------------------------------------------------------------------ - /// @copydoc Module::ResolveSymbolContextForFilePath (const char + /// \copydoc Module::ResolveSymbolContextForFilePath (const char /// *,uint32_t,bool,uint32_t,SymbolContextList&) - //------------------------------------------------------------------ uint32_t ResolveSymbolContextForFilePath( const char *file_path, uint32_t line, bool check_inlines, lldb::SymbolContextItem resolve_scope, SymbolContextList &sc_list) const; - //------------------------------------------------------------------ - /// @copydoc Module::ResolveSymbolContextsForFileSpec (const FileSpec + /// \copydoc Module::ResolveSymbolContextsForFileSpec (const FileSpec /// &,uint32_t,bool,uint32_t,SymbolContextList&) - //------------------------------------------------------------------ uint32_t ResolveSymbolContextsForFileSpec( const FileSpec &file_spec, uint32_t line, bool check_inlines, lldb::SymbolContextItem resolve_scope, SymbolContextList &sc_list) const; - //------------------------------------------------------------------ /// Gets the size of the module list. /// - /// @return + /// \return /// The number of modules in the module list. - //------------------------------------------------------------------ size_t GetSize() const; bool LoadScriptingResourcesInTarget(Target *target, std::list<Status> &errors, @@ -552,9 +505,7 @@ public: &callback) const; protected: - //------------------------------------------------------------------ // Class typedefs. - //------------------------------------------------------------------ typedef std::vector<lldb::ModuleSP> collection; ///< The module collection type. @@ -567,9 +518,7 @@ protected: void ClearImpl(bool use_notifier = true); - //------------------------------------------------------------------ // Member variables. - //------------------------------------------------------------------ collection m_modules; ///< The collection of modules. mutable std::recursive_mutex m_modules_mutex; diff --git a/include/lldb/Core/ModuleSpec.h b/include/lldb/Core/ModuleSpec.h index ae772c2a1efe0..ab0f4e9912a8d 100644 --- a/include/lldb/Core/ModuleSpec.h +++ b/include/lldb/Core/ModuleSpec.h @@ -1,9 +1,8 @@ //===-- ModuleSpec.h --------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -125,7 +124,7 @@ public: ConstString &GetObjectName() { return m_object_name; } - const ConstString &GetObjectName() const { return m_object_name; } + ConstString GetObjectName() const { return m_object_name; } uint64_t GetObjectOffset() const { return m_object_offset; } @@ -312,8 +311,10 @@ public: ModuleSpecList &operator=(const ModuleSpecList &rhs) { if (this != &rhs) { - std::lock_guard<std::recursive_mutex> lhs_guard(m_mutex); - std::lock_guard<std::recursive_mutex> rhs_guard(rhs.m_mutex); + std::lock(m_mutex, rhs.m_mutex); + std::lock_guard<std::recursive_mutex> lhs_guard(m_mutex, std::adopt_lock); + std::lock_guard<std::recursive_mutex> rhs_guard(rhs.m_mutex, + std::adopt_lock); m_specs = rhs.m_specs; } return *this; diff --git a/include/lldb/Core/Opcode.h b/include/lldb/Core/Opcode.h index fb6cc825abd26..1a30ce4834ac0 100644 --- a/include/lldb/Core/Opcode.h +++ b/include/lldb/Core/Opcode.h @@ -1,9 +1,8 @@ //===-- Opcode.h ------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -19,18 +18,13 @@ #include <stdint.h> #include <string.h> -namespace lldb_private { -class DataExtractor; -} -namespace lldb_private { -class Stream; -} - namespace lldb { class SBInstruction; } namespace lldb_private { +class DataExtractor; +class Stream; class Opcode { public: diff --git a/include/lldb/Core/PluginInterface.h b/include/lldb/Core/PluginInterface.h index 24f53c62ab095..6e625a605917d 100644 --- a/include/lldb/Core/PluginInterface.h +++ b/include/lldb/Core/PluginInterface.h @@ -1,9 +1,8 @@ //===-- PluginInterface.h ---------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// diff --git a/include/lldb/Core/PluginManager.h b/include/lldb/Core/PluginManager.h index 598ee9a8d8e35..1bac1e5df6940 100644 --- a/include/lldb/Core/PluginManager.h +++ b/include/lldb/Core/PluginManager.h @@ -1,9 +1,8 @@ //===-- PluginManager.h -----------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -23,17 +22,9 @@ namespace lldb_private { class CommandInterpreter; -} -namespace lldb_private { class ConstString; -} -namespace lldb_private { class Debugger; -} -namespace lldb_private { class StringList; -} -namespace lldb_private { class PluginManager { public: @@ -41,10 +32,8 @@ public: static void Terminate(); - //------------------------------------------------------------------ // ABI - //------------------------------------------------------------------ - static bool RegisterPlugin(const ConstString &name, const char *description, + static bool RegisterPlugin(ConstString name, const char *description, ABICreateInstance create_callback); static bool UnregisterPlugin(ABICreateInstance create_callback); @@ -52,15 +41,13 @@ public: static ABICreateInstance GetABICreateCallbackAtIndex(uint32_t idx); static ABICreateInstance - GetABICreateCallbackForPluginName(const ConstString &name); + GetABICreateCallbackForPluginName(ConstString name); - //------------------------------------------------------------------ // Architecture - //------------------------------------------------------------------ using ArchitectureCreateInstance = std::unique_ptr<Architecture> (*)(const ArchSpec &); - static void RegisterPlugin(const ConstString &name, + static void RegisterPlugin(ConstString name, llvm::StringRef description, ArchitectureCreateInstance create_callback); @@ -69,10 +56,8 @@ public: static std::unique_ptr<Architecture> CreateArchitectureInstance(const ArchSpec &arch); - //------------------------------------------------------------------ // Disassembler - //------------------------------------------------------------------ - static bool RegisterPlugin(const ConstString &name, const char *description, + static bool RegisterPlugin(ConstString name, const char *description, DisassemblerCreateInstance create_callback); static bool UnregisterPlugin(DisassemblerCreateInstance create_callback); @@ -81,13 +66,11 @@ public: GetDisassemblerCreateCallbackAtIndex(uint32_t idx); static DisassemblerCreateInstance - GetDisassemblerCreateCallbackForPluginName(const ConstString &name); + GetDisassemblerCreateCallbackForPluginName(ConstString name); - //------------------------------------------------------------------ // DynamicLoader - //------------------------------------------------------------------ static bool - RegisterPlugin(const ConstString &name, const char *description, + RegisterPlugin(ConstString name, const char *description, DynamicLoaderCreateInstance create_callback, DebuggerInitializeCallback debugger_init_callback = nullptr); @@ -97,13 +80,11 @@ public: GetDynamicLoaderCreateCallbackAtIndex(uint32_t idx); static DynamicLoaderCreateInstance - GetDynamicLoaderCreateCallbackForPluginName(const ConstString &name); + GetDynamicLoaderCreateCallbackForPluginName(ConstString name); - //------------------------------------------------------------------ // JITLoader - //------------------------------------------------------------------ static bool - RegisterPlugin(const ConstString &name, const char *description, + RegisterPlugin(ConstString name, const char *description, JITLoaderCreateInstance create_callback, DebuggerInitializeCallback debugger_init_callback = nullptr); @@ -113,12 +94,10 @@ public: GetJITLoaderCreateCallbackAtIndex(uint32_t idx); static JITLoaderCreateInstance - GetJITLoaderCreateCallbackForPluginName(const ConstString &name); + GetJITLoaderCreateCallbackForPluginName(ConstString name); - //------------------------------------------------------------------ // EmulateInstruction - //------------------------------------------------------------------ - static bool RegisterPlugin(const ConstString &name, const char *description, + static bool RegisterPlugin(ConstString name, const char *description, EmulateInstructionCreateInstance create_callback); static bool @@ -128,12 +107,10 @@ public: GetEmulateInstructionCreateCallbackAtIndex(uint32_t idx); static EmulateInstructionCreateInstance - GetEmulateInstructionCreateCallbackForPluginName(const ConstString &name); + GetEmulateInstructionCreateCallbackForPluginName(ConstString name); - //------------------------------------------------------------------ // OperatingSystem - //------------------------------------------------------------------ - static bool RegisterPlugin(const ConstString &name, const char *description, + static bool RegisterPlugin(ConstString name, const char *description, OperatingSystemCreateInstance create_callback, DebuggerInitializeCallback debugger_init_callback); @@ -143,12 +120,10 @@ public: GetOperatingSystemCreateCallbackAtIndex(uint32_t idx); static OperatingSystemCreateInstance - GetOperatingSystemCreateCallbackForPluginName(const ConstString &name); + GetOperatingSystemCreateCallbackForPluginName(ConstString name); - //------------------------------------------------------------------ // Language - //------------------------------------------------------------------ - static bool RegisterPlugin(const ConstString &name, const char *description, + static bool RegisterPlugin(ConstString name, const char *description, LanguageCreateInstance create_callback); static bool UnregisterPlugin(LanguageCreateInstance create_callback); @@ -156,15 +131,14 @@ public: static LanguageCreateInstance GetLanguageCreateCallbackAtIndex(uint32_t idx); static LanguageCreateInstance - GetLanguageCreateCallbackForPluginName(const ConstString &name); + GetLanguageCreateCallbackForPluginName(ConstString name); - //------------------------------------------------------------------ // LanguageRuntime - //------------------------------------------------------------------ - static bool - RegisterPlugin(const ConstString &name, const char *description, - LanguageRuntimeCreateInstance create_callback, - LanguageRuntimeGetCommandObject command_callback = nullptr); + static bool RegisterPlugin( + ConstString name, const char *description, + LanguageRuntimeCreateInstance create_callback, + LanguageRuntimeGetCommandObject command_callback = nullptr, + LanguageRuntimeGetExceptionPrecondition precondition_callback = nullptr); static bool UnregisterPlugin(LanguageRuntimeCreateInstance create_callback); @@ -174,13 +148,14 @@ public: static LanguageRuntimeGetCommandObject GetLanguageRuntimeGetCommandObjectAtIndex(uint32_t idx); + static LanguageRuntimeGetExceptionPrecondition + GetLanguageRuntimeGetExceptionPreconditionAtIndex(uint32_t idx); + static LanguageRuntimeCreateInstance - GetLanguageRuntimeCreateCallbackForPluginName(const ConstString &name); + GetLanguageRuntimeCreateCallbackForPluginName(ConstString name); - //------------------------------------------------------------------ // SystemRuntime - //------------------------------------------------------------------ - static bool RegisterPlugin(const ConstString &name, const char *description, + static bool RegisterPlugin(ConstString name, const char *description, SystemRuntimeCreateInstance create_callback); static bool UnregisterPlugin(SystemRuntimeCreateInstance create_callback); @@ -189,13 +164,11 @@ public: GetSystemRuntimeCreateCallbackAtIndex(uint32_t idx); static SystemRuntimeCreateInstance - GetSystemRuntimeCreateCallbackForPluginName(const ConstString &name); + GetSystemRuntimeCreateCallbackForPluginName(ConstString name); - //------------------------------------------------------------------ // ObjectFile - //------------------------------------------------------------------ static bool - RegisterPlugin(const ConstString &name, const char *description, + RegisterPlugin(ConstString name, const char *description, ObjectFileCreateInstance create_callback, ObjectFileCreateMemoryInstance create_memory_callback, ObjectFileGetModuleSpecifications get_module_specifications, @@ -213,19 +186,17 @@ public: GetObjectFileGetModuleSpecificationsCallbackAtIndex(uint32_t idx); static ObjectFileCreateInstance - GetObjectFileCreateCallbackForPluginName(const ConstString &name); + GetObjectFileCreateCallbackForPluginName(ConstString name); static ObjectFileCreateMemoryInstance - GetObjectFileCreateMemoryCallbackForPluginName(const ConstString &name); + GetObjectFileCreateMemoryCallbackForPluginName(ConstString name); static Status SaveCore(const lldb::ProcessSP &process_sp, const FileSpec &outfile); - //------------------------------------------------------------------ // ObjectContainer - //------------------------------------------------------------------ static bool - RegisterPlugin(const ConstString &name, const char *description, + RegisterPlugin(ConstString name, const char *description, ObjectContainerCreateInstance create_callback, ObjectFileGetModuleSpecifications get_module_specifications); @@ -235,16 +206,14 @@ public: GetObjectContainerCreateCallbackAtIndex(uint32_t idx); static ObjectContainerCreateInstance - GetObjectContainerCreateCallbackForPluginName(const ConstString &name); + GetObjectContainerCreateCallbackForPluginName(ConstString name); static ObjectFileGetModuleSpecifications GetObjectContainerGetModuleSpecificationsCallbackAtIndex(uint32_t idx); - //------------------------------------------------------------------ // Platform - //------------------------------------------------------------------ static bool - RegisterPlugin(const ConstString &name, const char *description, + RegisterPlugin(ConstString name, const char *description, PlatformCreateInstance create_callback, DebuggerInitializeCallback debugger_init_callback = nullptr); @@ -253,7 +222,7 @@ public: static PlatformCreateInstance GetPlatformCreateCallbackAtIndex(uint32_t idx); static PlatformCreateInstance - GetPlatformCreateCallbackForPluginName(const ConstString &name); + GetPlatformCreateCallbackForPluginName(ConstString name); static const char *GetPlatformPluginNameAtIndex(uint32_t idx); @@ -261,11 +230,9 @@ public: static size_t AutoCompletePlatformName(llvm::StringRef partial_name, StringList &matches); - //------------------------------------------------------------------ // Process - //------------------------------------------------------------------ static bool - RegisterPlugin(const ConstString &name, const char *description, + RegisterPlugin(ConstString name, const char *description, ProcessCreateInstance create_callback, DebuggerInitializeCallback debugger_init_callback = nullptr); @@ -274,16 +241,14 @@ public: static ProcessCreateInstance GetProcessCreateCallbackAtIndex(uint32_t idx); static ProcessCreateInstance - GetProcessCreateCallbackForPluginName(const ConstString &name); + GetProcessCreateCallbackForPluginName(ConstString name); static const char *GetProcessPluginNameAtIndex(uint32_t idx); static const char *GetProcessPluginDescriptionAtIndex(uint32_t idx); - //------------------------------------------------------------------ // ScriptInterpreter - //------------------------------------------------------------------ - static bool RegisterPlugin(const ConstString &name, const char *description, + static bool RegisterPlugin(ConstString name, const char *description, lldb::ScriptLanguage script_lang, ScriptInterpreterCreateInstance create_callback); @@ -294,32 +259,29 @@ public: static lldb::ScriptInterpreterSP GetScriptInterpreterForLanguage(lldb::ScriptLanguage script_lang, - CommandInterpreter &interpreter); + Debugger &debugger); - //------------------------------------------------------------------ // StructuredDataPlugin - //------------------------------------------------------------------ - //------------------------------------------------------------------ /// Register a StructuredDataPlugin class along with optional /// callbacks for debugger initialization and Process launch info /// filtering and manipulation. /// - /// @param[in] name + /// \param[in] name /// The name of the plugin. /// - /// @param[in] description + /// \param[in] description /// A description string for the plugin. /// - /// @param[in] create_callback + /// \param[in] create_callback /// The callback that will be invoked to create an instance of /// the callback. This may not be nullptr. /// - /// @param[in] debugger_init_callback + /// \param[in] debugger_init_callback /// An optional callback that will be made when a Debugger /// instance is initialized. /// - /// @param[in] filter_callback + /// \param[in] filter_callback /// An optional callback that will be invoked before LLDB /// launches a process for debugging. The callback must /// do the following: @@ -331,11 +293,10 @@ public: /// plugin if, for instance, additional environment variables /// are needed to support the feature when enabled. /// - /// @return + /// \return /// Returns true upon success; otherwise, false. - //------------------------------------------------------------------ static bool - RegisterPlugin(const ConstString &name, const char *description, + RegisterPlugin(ConstString name, const char *description, StructuredDataPluginCreateInstance create_callback, DebuggerInitializeCallback debugger_init_callback = nullptr, StructuredDataFilterLaunchInfo filter_callback = nullptr); @@ -347,17 +308,15 @@ public: GetStructuredDataPluginCreateCallbackAtIndex(uint32_t idx); static StructuredDataPluginCreateInstance - GetStructuredDataPluginCreateCallbackForPluginName(const ConstString &name); + GetStructuredDataPluginCreateCallbackForPluginName(ConstString name); static StructuredDataFilterLaunchInfo GetStructuredDataFilterCallbackAtIndex(uint32_t idx, bool &iteration_complete); - //------------------------------------------------------------------ // SymbolFile - //------------------------------------------------------------------ static bool - RegisterPlugin(const ConstString &name, const char *description, + RegisterPlugin(ConstString name, const char *description, SymbolFileCreateInstance create_callback, DebuggerInitializeCallback debugger_init_callback = nullptr); @@ -367,12 +326,10 @@ public: GetSymbolFileCreateCallbackAtIndex(uint32_t idx); static SymbolFileCreateInstance - GetSymbolFileCreateCallbackForPluginName(const ConstString &name); + GetSymbolFileCreateCallbackForPluginName(ConstString name); - //------------------------------------------------------------------ // SymbolVendor - //------------------------------------------------------------------ - static bool RegisterPlugin(const ConstString &name, const char *description, + static bool RegisterPlugin(ConstString name, const char *description, SymbolVendorCreateInstance create_callback); static bool UnregisterPlugin(SymbolVendorCreateInstance create_callback); @@ -381,12 +338,10 @@ public: GetSymbolVendorCreateCallbackAtIndex(uint32_t idx); static SymbolVendorCreateInstance - GetSymbolVendorCreateCallbackForPluginName(const ConstString &name); + GetSymbolVendorCreateCallbackForPluginName(ConstString name); - //------------------------------------------------------------------ // UnwindAssembly - //------------------------------------------------------------------ - static bool RegisterPlugin(const ConstString &name, const char *description, + static bool RegisterPlugin(ConstString name, const char *description, UnwindAssemblyCreateInstance create_callback); static bool UnregisterPlugin(UnwindAssemblyCreateInstance create_callback); @@ -395,12 +350,10 @@ public: GetUnwindAssemblyCreateCallbackAtIndex(uint32_t idx); static UnwindAssemblyCreateInstance - GetUnwindAssemblyCreateCallbackForPluginName(const ConstString &name); + GetUnwindAssemblyCreateCallbackForPluginName(ConstString name); - //------------------------------------------------------------------ // MemoryHistory - //------------------------------------------------------------------ - static bool RegisterPlugin(const ConstString &name, const char *description, + static bool RegisterPlugin(ConstString name, const char *description, MemoryHistoryCreateInstance create_callback); static bool UnregisterPlugin(MemoryHistoryCreateInstance create_callback); @@ -409,13 +362,11 @@ public: GetMemoryHistoryCreateCallbackAtIndex(uint32_t idx); static MemoryHistoryCreateInstance - GetMemoryHistoryCreateCallbackForPluginName(const ConstString &name); + GetMemoryHistoryCreateCallbackForPluginName(ConstString name); - //------------------------------------------------------------------ // InstrumentationRuntime - //------------------------------------------------------------------ static bool - RegisterPlugin(const ConstString &name, const char *description, + RegisterPlugin(ConstString name, const char *description, InstrumentationRuntimeCreateInstance create_callback, InstrumentationRuntimeGetType get_type_callback); @@ -429,13 +380,11 @@ public: GetInstrumentationRuntimeCreateCallbackAtIndex(uint32_t idx); static InstrumentationRuntimeCreateInstance - GetInstrumentationRuntimeCreateCallbackForPluginName(const ConstString &name); + GetInstrumentationRuntimeCreateCallbackForPluginName(ConstString name); - //------------------------------------------------------------------ // TypeSystem - //------------------------------------------------------------------ static bool RegisterPlugin( - const ConstString &name, const char *description, + ConstString name, const char *description, TypeSystemCreateInstance create_callback, TypeSystemEnumerateSupportedLanguages enumerate_languages_callback); @@ -445,20 +394,18 @@ public: GetTypeSystemCreateCallbackAtIndex(uint32_t idx); static TypeSystemCreateInstance - GetTypeSystemCreateCallbackForPluginName(const ConstString &name); + GetTypeSystemCreateCallbackForPluginName(ConstString name); static TypeSystemEnumerateSupportedLanguages GetTypeSystemEnumerateSupportedLanguagesCallbackAtIndex(uint32_t idx); static TypeSystemEnumerateSupportedLanguages GetTypeSystemEnumerateSupportedLanguagesCallbackForPluginName( - const ConstString &name); + ConstString name); - //------------------------------------------------------------------ // REPL - //------------------------------------------------------------------ static bool - RegisterPlugin(const ConstString &name, const char *description, + RegisterPlugin(ConstString name, const char *description, REPLCreateInstance create_callback, REPLEnumerateSupportedLanguages enumerate_languages_callback); @@ -467,79 +414,77 @@ public: static REPLCreateInstance GetREPLCreateCallbackAtIndex(uint32_t idx); static REPLCreateInstance - GetREPLCreateCallbackForPluginName(const ConstString &name); + GetREPLCreateCallbackForPluginName(ConstString name); static REPLEnumerateSupportedLanguages GetREPLEnumerateSupportedLanguagesCallbackAtIndex(uint32_t idx); static REPLEnumerateSupportedLanguages GetREPLSystemEnumerateSupportedLanguagesCallbackForPluginName( - const ConstString &name); + 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. - //------------------------------------------------------------------ static void DebuggerInitialize(Debugger &debugger); static lldb::OptionValuePropertiesSP GetSettingForDynamicLoaderPlugin(Debugger &debugger, - const ConstString &setting_name); + ConstString setting_name); static bool CreateSettingForDynamicLoaderPlugin( Debugger &debugger, const lldb::OptionValuePropertiesSP &properties_sp, - const ConstString &description, bool is_global_property); + ConstString description, bool is_global_property); static lldb::OptionValuePropertiesSP GetSettingForPlatformPlugin(Debugger &debugger, - const ConstString &setting_name); + ConstString setting_name); static bool CreateSettingForPlatformPlugin( Debugger &debugger, const lldb::OptionValuePropertiesSP &properties_sp, - const ConstString &description, bool is_global_property); + ConstString description, bool is_global_property); static lldb::OptionValuePropertiesSP GetSettingForProcessPlugin(Debugger &debugger, - const ConstString &setting_name); + ConstString setting_name); static bool CreateSettingForProcessPlugin( Debugger &debugger, const lldb::OptionValuePropertiesSP &properties_sp, - const ConstString &description, bool is_global_property); + ConstString description, bool is_global_property); static lldb::OptionValuePropertiesSP GetSettingForSymbolFilePlugin(Debugger &debugger, - const ConstString &setting_name); + ConstString setting_name); static bool CreateSettingForSymbolFilePlugin( Debugger &debugger, const lldb::OptionValuePropertiesSP &properties_sp, - const ConstString &description, bool is_global_property); + ConstString description, bool is_global_property); static lldb::OptionValuePropertiesSP GetSettingForJITLoaderPlugin(Debugger &debugger, - const ConstString &setting_name); + ConstString setting_name); static bool CreateSettingForJITLoaderPlugin( Debugger &debugger, const lldb::OptionValuePropertiesSP &properties_sp, - const ConstString &description, bool is_global_property); + ConstString description, bool is_global_property); static lldb::OptionValuePropertiesSP GetSettingForOperatingSystemPlugin(Debugger &debugger, - const ConstString &setting_name); + ConstString setting_name); static bool CreateSettingForOperatingSystemPlugin( Debugger &debugger, const lldb::OptionValuePropertiesSP &properties_sp, - const ConstString &description, bool is_global_property); + ConstString description, bool is_global_property); static lldb::OptionValuePropertiesSP GetSettingForStructuredDataPlugin(Debugger &debugger, - const ConstString &setting_name); + ConstString setting_name); static bool CreateSettingForStructuredDataPlugin( Debugger &debugger, const lldb::OptionValuePropertiesSP &properties_sp, - const ConstString &description, bool is_global_property); + ConstString description, bool is_global_property); }; } // namespace lldb_private diff --git a/include/lldb/Core/RichManglingContext.h b/include/lldb/Core/RichManglingContext.h index 30841bfb2668c..e6fa2599e55a2 100644 --- a/include/lldb/Core/RichManglingContext.h +++ b/include/lldb/Core/RichManglingContext.h @@ -1,9 +1,8 @@ //===-- RichManglingContext.h -----------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -34,11 +33,11 @@ public: /// Use the ItaniumPartialDemangler to obtain rich mangling information from /// the given mangled name. - bool FromItaniumName(const ConstString &mangled); + bool FromItaniumName(ConstString mangled); /// Use the legacy language parser implementation to obtain rich mangling /// information from the given demangled name. - bool FromCxxMethodName(const ConstString &demangled); + bool FromCxxMethodName(ConstString demangled); /// If this symbol describes a constructor or destructor. bool IsCtorOrDtor() const; diff --git a/include/lldb/Core/STLUtils.h b/include/lldb/Core/STLUtils.h index 0ed354fa4e32f..830aca36a1165 100644 --- a/include/lldb/Core/STLUtils.h +++ b/include/lldb/Core/STLUtils.h @@ -1,9 +1,8 @@ //===-- STLUtils.h ----------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -17,28 +16,22 @@ #include <vector> -//---------------------------------------------------------------------- // C string less than compare function object -//---------------------------------------------------------------------- struct CStringCompareFunctionObject { bool operator()(const char *s1, const char *s2) const { return strcmp(s1, s2) < 0; } }; -//---------------------------------------------------------------------- // C string equality function object (binary predicate). -//---------------------------------------------------------------------- struct CStringEqualBinaryPredicate { bool operator()(const char *s1, const char *s2) const { return strcmp(s1, s2) == 0; } }; -//---------------------------------------------------------------------- // 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: ValueEquals(const S &val) : second_value(val) {} diff --git a/include/lldb/Core/SearchFilter.h b/include/lldb/Core/SearchFilter.h index f53ef658fd3ff..f38690c95f523 100644 --- a/include/lldb/Core/SearchFilter.h +++ b/include/lldb/Core/SearchFilter.h @@ -1,9 +1,8 @@ //===-- SearchFilter.h ------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -20,55 +19,33 @@ namespace lldb_private { class Address; -} -namespace lldb_private { class Breakpoint; -} -namespace lldb_private { class CompileUnit; -} -namespace lldb_private { class Status; -} -namespace lldb_private { class Function; -} -namespace lldb_private { class ModuleList; -} -namespace lldb_private { class SearchFilter; -} -namespace lldb_private { class Stream; -} -namespace lldb_private { class SymbolContext; -} -namespace lldb_private { class Target; } namespace lldb_private { -//---------------------------------------------------------------------- -/// @class Searcher SearchFilter.h "lldb/Core/SearchFilter.h" Class that is +/// \class Searcher SearchFilter.h "lldb/Core/SearchFilter.h" Class that is /// driven by the SearchFilter to search the SymbolContext space of the target /// program. -//---------------------------------------------------------------------- -//---------------------------------------------------------------------- /// General Outline: /// Provides the callback and search depth for the SearchFilter search. -//---------------------------------------------------------------------- class Searcher { public: - typedef enum { + enum CallbackReturn { eCallbackReturnStop = 0, // Stop the iteration eCallbackReturnContinue, // Continue the iteration eCallbackReturnPop // Pop one level up and continue iterating - } CallbackReturn; + }; Searcher(); @@ -80,23 +57,18 @@ public: virtual lldb::SearchDepth GetDepth() = 0; - //------------------------------------------------------------------ /// Prints a canonical description for the searcher to the stream \a s. /// - /// @param[in] s + /// \param[in] s /// Stream to which the output is copied. - //------------------------------------------------------------------ virtual void GetDescription(Stream *s); }; -//---------------------------------------------------------------------- -/// @class SearchFilter SearchFilter.h "lldb/Core/SearchFilter.h" Class +/// \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. -//---------------------------------------------------------------------- -//---------------------------------------------------------------------- /// General Outline: /// Provides the callback and search depth for the SearchFilter search. /// @@ -107,141 +79,112 @@ public: /// 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 { public: - //------------------------------------------------------------------ /// The basic constructor takes a Target, which gives the space to search. /// - /// @param[in] target + /// \param[in] target /// The Target that provides the module list to search. - //------------------------------------------------------------------ SearchFilter(const lldb::TargetSP &target_sp); - SearchFilter(const SearchFilter &rhs); - SearchFilter(const lldb::TargetSP &target_sp, unsigned char filterType); virtual ~SearchFilter(); - SearchFilter &operator=(const SearchFilter &rhs); - - //------------------------------------------------------------------ /// Call this method with a file spec to see if that spec passes the filter. /// - /// @param[in] spec + /// \param[in] spec /// The file spec to check against the filter. - /// @return + /// \return /// \b true if \a spec passes, and \b false otherwise. - //------------------------------------------------------------------ virtual bool ModulePasses(const FileSpec &spec); - //------------------------------------------------------------------ /// Call this method with a Module to see if that module passes the filter. /// - /// @param[in] module + /// \param[in] module /// The Module to check against the filter. /// - /// @return + /// \return /// \b true if \a module passes, and \b false otherwise. - //------------------------------------------------------------------ virtual bool ModulePasses(const lldb::ModuleSP &module_sp); - //------------------------------------------------------------------ /// Call this method with a Address to see if \a address passes the filter. /// - /// @param[in] addr + /// \param[in] addr /// The address to check against the filter. /// - /// @return + /// \return /// \b true if \a address passes, and \b false otherwise. - //------------------------------------------------------------------ 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. /// - /// @param[in] fileSpec + /// \param[in] fileSpec /// The file spec to check against the filter. /// - /// @return + /// \return /// \b true if \a file spec passes, and \b false otherwise. - //------------------------------------------------------------------ virtual bool CompUnitPasses(FileSpec &fileSpec); - //------------------------------------------------------------------ /// Call this method with a CompileUnit to see if \a comp unit passes the /// filter. /// - /// @param[in] compUnit + /// \param[in] compUnit /// The CompileUnit to check against the filter. /// - /// @return + /// \return /// \b true if \a Comp Unit passes, and \b false otherwise. - //------------------------------------------------------------------ virtual bool CompUnitPasses(CompileUnit &compUnit); - //------------------------------------------------------------------ /// Call this method with a Function to see if \a function passes the /// filter. /// - /// @param[in] function + /// \param[in] function /// The Functions to check against the filter. /// - /// @return + /// \return /// \b true if \a function passes, and \b false otherwise. - //------------------------------------------------------------------ virtual bool FunctionPasses(Function &function); - //------------------------------------------------------------------ /// Call this method to do the search using the Searcher. /// - /// @param[in] searcher + /// \param[in] searcher /// The searcher to drive with this search. /// - //------------------------------------------------------------------ virtual void Search(Searcher &searcher); - //------------------------------------------------------------------ /// Call this method to do the search using the Searcher in the module list /// \a modules. /// - /// @param[in] searcher + /// \param[in] searcher /// The searcher to drive with this search. /// - /// @param[in] modules + /// \param[in] modules /// The module list within which to restrict the search. /// - //------------------------------------------------------------------ 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 /// things that obviously won't pass. /// - /// @return + /// \return /// The required elements for the search, which is an or'ed together /// set of lldb:SearchContextItem enum's. /// - //------------------------------------------------------------------ virtual uint32_t GetFilterRequiredItems(); - //------------------------------------------------------------------ /// Prints a canonical description for the search filter to the stream \a s. /// - /// @param[in] s + /// \param[in] s /// Stream to which the output is copied. - //------------------------------------------------------------------ virtual void GetDescription(Stream *s); - //------------------------------------------------------------------ /// Standard "Dump" method. At present it does nothing. - //------------------------------------------------------------------ virtual void Dump(Stream *s) const; lldb::SearchFilterSP CopyForBreakpoint(Breakpoint &breakpoint); @@ -329,12 +272,10 @@ private: unsigned char SubclassID; }; -//---------------------------------------------------------------------- -/// @class SearchFilterForUnconstrainedSearches SearchFilter.h +/// \class SearchFilterForUnconstrainedSearches SearchFilter.h /// "lldb/Core/SearchFilter.h" This is a SearchFilter that searches through /// all modules. It also consults the /// Target::ModuleIsExcludedForUnconstrainedSearches. -//---------------------------------------------------------------------- class SearchFilterForUnconstrainedSearches : public SearchFilter { public: SearchFilterForUnconstrainedSearches(const lldb::TargetSP &target_sp) @@ -357,31 +298,23 @@ protected: lldb::SearchFilterSP DoCopyForBreakpoint(Breakpoint &breakpoint) override; }; -//---------------------------------------------------------------------- -/// @class SearchFilterByModule SearchFilter.h "lldb/Core/SearchFilter.h" This +/// \class SearchFilterByModule SearchFilter.h "lldb/Core/SearchFilter.h" This /// is a SearchFilter that restricts the search to a given module. -//---------------------------------------------------------------------- class SearchFilterByModule : public SearchFilter { public: - //------------------------------------------------------------------ /// The basic constructor takes a Target, which gives the space to search, /// and the module to restrict the search to. /// - /// @param[in] target + /// \param[in] target /// The Target that provides the module list to search. /// - /// @param[in] module + /// \param[in] module /// The Module that limits the search. - //------------------------------------------------------------------ SearchFilterByModule(const lldb::TargetSP &targetSP, const FileSpec &module); - SearchFilterByModule(const SearchFilterByModule &rhs); - ~SearchFilterByModule() override; - SearchFilterByModule &operator=(const SearchFilterByModule &rhs); - bool ModulePasses(const lldb::ModuleSP &module_sp) override; bool ModulePasses(const FileSpec &spec) override; @@ -416,16 +349,14 @@ private: class SearchFilterByModuleList : public SearchFilter { public: - //------------------------------------------------------------------ /// The basic constructor takes a Target, which gives the space to search, /// and the module list to restrict the search to. /// - /// @param[in] target + /// \param[in] target /// The Target that provides the module list to search. /// - /// @param[in] module + /// \param[in] module /// The Module that limits the search. - //------------------------------------------------------------------ SearchFilterByModuleList(const lldb::TargetSP &targetSP, const FileSpecList &module_list); @@ -433,8 +364,6 @@ public: const FileSpecList &module_list, enum FilterTy filter_ty); - SearchFilterByModuleList(const SearchFilterByModuleList &rhs); - ~SearchFilterByModuleList() override; SearchFilterByModuleList &operator=(const SearchFilterByModuleList &rhs); @@ -475,16 +404,14 @@ protected: class SearchFilterByModuleListAndCU : public SearchFilterByModuleList { public: - //------------------------------------------------------------------ /// The basic constructor takes a Target, which gives the space to search, /// and the module list to restrict the search to. /// - /// @param[in] target + /// \param[in] target /// The Target that provides the module list to search. /// - /// @param[in] module + /// \param[in] module /// The Module that limits the search. - //------------------------------------------------------------------ SearchFilterByModuleListAndCU(const lldb::TargetSP &targetSP, const FileSpecList &module_list, const FileSpecList &cu_list); diff --git a/include/lldb/Core/Section.h b/include/lldb/Core/Section.h index 4157bb877b4cc..881d43702ceee 100644 --- a/include/lldb/Core/Section.h +++ b/include/lldb/Core/Section.h @@ -1,9 +1,8 @@ //===-- Section.h -----------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -27,24 +26,11 @@ namespace lldb_private { class Address; -} -namespace lldb_private { class DataExtractor; -} -namespace lldb_private { class ObjectFile; -} -namespace lldb_private { class Section; -} -namespace lldb_private { class Stream; -} -namespace lldb_private { class Target; -} - -namespace lldb_private { class SectionList { public: @@ -52,6 +38,11 @@ public: typedef collection::iterator iterator; typedef collection::const_iterator const_iterator; + const_iterator begin() const { return m_sections.begin(); } + const_iterator end() const { return m_sections.end(); } + const_iterator begin() { return m_sections.begin(); } + const_iterator end() { return m_sections.end(); } + SectionList(); ~SectionList(); @@ -68,7 +59,7 @@ public: void Dump(Stream *s, Target *target, bool show_header, uint32_t depth) const; - lldb::SectionSP FindSectionByName(const ConstString §ion_dstr) const; + lldb::SectionSP FindSectionByName(ConstString section_dstr) const; lldb::SectionSP FindSectionByID(lldb::user_id_t sect_id) const; @@ -110,7 +101,7 @@ class Section : public std::enable_shared_from_this<Section>, public: // Create a root section (one that has no parent) Section(const lldb::ModuleSP &module_sp, ObjectFile *obj_file, - lldb::user_id_t sect_id, const ConstString &name, + lldb::user_id_t sect_id, ConstString name, lldb::SectionType sect_type, lldb::addr_t file_vm_addr, lldb::addr_t vm_size, lldb::offset_t file_offset, lldb::offset_t file_size, uint32_t log2align, uint32_t flags, @@ -121,7 +112,7 @@ public: // sections, non-NULL for // child sections const lldb::ModuleSP &module_sp, ObjectFile *obj_file, - lldb::user_id_t sect_id, const ConstString &name, + lldb::user_id_t sect_id, ConstString name, lldb::SectionType sect_type, lldb::addr_t file_vm_addr, lldb::addr_t vm_size, lldb::offset_t file_offset, lldb::offset_t file_size, uint32_t log2align, uint32_t flags, @@ -176,7 +167,7 @@ public: bool IsDescendant(const Section *section); - const ConstString &GetName() const { return m_name; } + ConstString GetName() const { return m_name; } bool Slide(lldb::addr_t slide_amount, bool slide_children); @@ -190,56 +181,48 @@ public: void SetIsThreadSpecific(bool b) { m_thread_specific = b; } - //------------------------------------------------------------------ /// Get the permissions as OR'ed bits from lldb::Permissions - //------------------------------------------------------------------ uint32_t GetPermissions() const; - //------------------------------------------------------------------ /// Set the permissions using bits OR'ed from lldb::Permissions - //------------------------------------------------------------------ void SetPermissions(uint32_t permissions); ObjectFile *GetObjectFile() { return m_obj_file; } const ObjectFile *GetObjectFile() const { return m_obj_file; } - //------------------------------------------------------------------ /// Read the section data from the object file that the section /// resides in. /// - /// @param[in] dst + /// \param[in] dst /// Where to place the data /// - /// @param[in] dst_len + /// \param[in] dst_len /// How many bytes of section data to read /// - /// @param[in] offset + /// \param[in] offset /// The offset in bytes within this section's data at which to /// start copying data from. /// - /// @return + /// \return /// The number of bytes read from the section, or zero if the /// section has no data or \a offset is not a valid offset /// in this section. - //------------------------------------------------------------------ lldb::offset_t GetSectionData(void *dst, lldb::offset_t dst_len, lldb::offset_t offset = 0); - //------------------------------------------------------------------ /// Get the shared reference to the section data from the object /// file that the section resides in. No copies of the data will be /// make unless the object file has been read from memory. If the /// object file is on disk, it will shared the mmap data for the /// entire object file. /// - /// @param[in] data + /// \param[in] data /// Where to place the data, address byte size, and byte order /// - /// @return + /// \return /// The number of bytes read from the section, or zero if the /// section has no data or \a offset is not a valid offset /// in this section. - //------------------------------------------------------------------ lldb::offset_t GetSectionData(DataExtractor &data); uint32_t GetLog2Align() { return m_log2align; } diff --git a/include/lldb/Core/SourceManager.h b/include/lldb/Core/SourceManager.h index d31ba037c5d6c..bca817750d8da 100644 --- a/include/lldb/Core/SourceManager.h +++ b/include/lldb/Core/SourceManager.h @@ -1,9 +1,8 @@ //===-- SourceManager.h -----------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -25,22 +24,12 @@ namespace lldb_private { class RegularExpression; -} -namespace lldb_private { class Stream; -} -namespace lldb_private { class SymbolContextList; -} -namespace lldb_private { class Target; -} - -namespace lldb_private { class SourceManager { public: -#ifndef SWIG class File { friend bool operator==(const SourceManager::File &lhs, const SourceManager::File &rhs); @@ -100,11 +89,9 @@ public: private: void CommonInitializer(const FileSpec &file_spec, Target *target); }; -#endif // SWIG typedef std::shared_ptr<File> FileSP; -#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. @@ -120,11 +107,8 @@ public: typedef std::map<FileSpec, FileSP> FileCache; FileCache m_file_cache; }; -#endif // SWIG - //------------------------------------------------------------------ // Constructors and Destructors - //------------------------------------------------------------------ // A source manager can be made with a non-null target, in which case it can // use the path remappings to find // source files that are not in their build locations. With no target it diff --git a/include/lldb/Core/StreamAsynchronousIO.h b/include/lldb/Core/StreamAsynchronousIO.h index 89667be058781..6237e12b7d1ea 100644 --- a/include/lldb/Core/StreamAsynchronousIO.h +++ b/include/lldb/Core/StreamAsynchronousIO.h @@ -1,9 +1,8 @@ //===-- StreamAsynchronousIO.h -----------------------------------*- C++-*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -18,9 +17,6 @@ namespace lldb_private { class Debugger; -} - -namespace lldb_private { class StreamAsynchronousIO : public Stream { public: diff --git a/include/lldb/Core/StreamBuffer.h b/include/lldb/Core/StreamBuffer.h index 7b2468330ad22..6c516519781ff 100644 --- a/include/lldb/Core/StreamBuffer.h +++ b/include/lldb/Core/StreamBuffer.h @@ -1,9 +1,8 @@ //===-- StreamBuffer.h ------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -24,9 +23,9 @@ public: StreamBuffer(uint32_t flags, uint32_t addr_size, lldb::ByteOrder byte_order) : Stream(flags, addr_size, byte_order), m_packet() {} - virtual ~StreamBuffer() {} + ~StreamBuffer() override {} - virtual void Flush() { + void Flush() override { // Nothing to do when flushing a buffer based stream... } @@ -43,7 +42,7 @@ public: protected: llvm::SmallVector<char, N> m_packet; - virtual size_t WriteImpl(const void *s, size_t length) { + size_t WriteImpl(const void *s, size_t length) override { if (s && length) m_packet.append((const char *)s, ((const char *)s) + length); return length; diff --git a/include/lldb/Core/StreamFile.h b/include/lldb/Core/StreamFile.h index 86db3e4ae4877..54aeab16b3f1a 100644 --- a/include/lldb/Core/StreamFile.h +++ b/include/lldb/Core/StreamFile.h @@ -1,9 +1,8 @@ //===-- StreamFile.h --------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -22,9 +21,7 @@ namespace lldb_private { class StreamFile : public Stream { public: - //------------------------------------------------------------------ // Constructors and Destructors - //------------------------------------------------------------------ StreamFile(); StreamFile(uint32_t flags, uint32_t addr_size, lldb::ByteOrder byte_order); @@ -48,9 +45,7 @@ public: protected: - //------------------------------------------------------------------ // Classes that inherit from StreamFile can see and modify these - //------------------------------------------------------------------ File m_file; size_t WriteImpl(const void *s, size_t length) override; diff --git a/include/lldb/Core/StructuredDataImpl.h b/include/lldb/Core/StructuredDataImpl.h index 2912f4ec7de0b..79a709af7ca31 100644 --- a/include/lldb/Core/StructuredDataImpl.h +++ b/include/lldb/Core/StructuredDataImpl.h @@ -1,9 +1,8 @@ //===-- StructuredDataImpl.h ------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// diff --git a/include/lldb/Core/ThreadSafeDenseMap.h b/include/lldb/Core/ThreadSafeDenseMap.h index 2fc428c4f7d43..c485b91acb47a 100644 --- a/include/lldb/Core/ThreadSafeDenseMap.h +++ b/include/lldb/Core/ThreadSafeDenseMap.h @@ -1,10 +1,9 @@ //===-- ThreadSafeDenseMap.h ------------------------------------------*- C++ //-*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// diff --git a/include/lldb/Core/ThreadSafeDenseSet.h b/include/lldb/Core/ThreadSafeDenseSet.h index 74a010544705f..fbc8d3fb02f84 100644 --- a/include/lldb/Core/ThreadSafeDenseSet.h +++ b/include/lldb/Core/ThreadSafeDenseSet.h @@ -1,10 +1,9 @@ //===-- ThreadSafeDenseSet.h ------------------------------------------*- C++ //-*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// diff --git a/include/lldb/Core/ThreadSafeSTLMap.h b/include/lldb/Core/ThreadSafeSTLMap.h index 4058fdfe15a88..df0208cd49b31 100644 --- a/include/lldb/Core/ThreadSafeSTLMap.h +++ b/include/lldb/Core/ThreadSafeSTLMap.h @@ -1,9 +1,8 @@ //===-- ThreadSafeSTLMap.h --------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -22,9 +21,7 @@ public: typedef std::map<_Key, _Tp> collection; typedef typename collection::iterator iterator; typedef typename collection::const_iterator const_iterator; - //------------------------------------------------------------------ // Constructors and Destructors - //------------------------------------------------------------------ ThreadSafeSTLMap() : m_collection(), m_mutex() {} ~ThreadSafeSTLMap() {} @@ -122,9 +119,7 @@ private: collection m_collection; mutable std::recursive_mutex m_mutex; - //------------------------------------------------------------------ // For ThreadSafeSTLMap only - //------------------------------------------------------------------ DISALLOW_COPY_AND_ASSIGN(ThreadSafeSTLMap); }; diff --git a/include/lldb/Core/ThreadSafeSTLVector.h b/include/lldb/Core/ThreadSafeSTLVector.h index b65936f81fec1..e1666a69ef7ea 100644 --- a/include/lldb/Core/ThreadSafeSTLVector.h +++ b/include/lldb/Core/ThreadSafeSTLVector.h @@ -1,10 +1,9 @@ //===-- ThreadSafeSTLVector.h ------------------------------------*- C++ //-*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -23,9 +22,7 @@ public: typedef std::vector<_Object> collection; typedef typename collection::iterator iterator; typedef typename collection::const_iterator const_iterator; - //------------------------------------------------------------------ // Constructors and Destructors - //------------------------------------------------------------------ ThreadSafeSTLVector() : m_collection(), m_mutex() {} ~ThreadSafeSTLVector() = default; @@ -66,9 +63,7 @@ private: collection m_collection; mutable std::recursive_mutex m_mutex; - //------------------------------------------------------------------ // For ThreadSafeSTLVector only - //------------------------------------------------------------------ DISALLOW_COPY_AND_ASSIGN(ThreadSafeSTLVector); }; diff --git a/include/lldb/Core/ThreadSafeValue.h b/include/lldb/Core/ThreadSafeValue.h index 35424a1791e67..91f96814363f2 100644 --- a/include/lldb/Core/ThreadSafeValue.h +++ b/include/lldb/Core/ThreadSafeValue.h @@ -1,9 +1,8 @@ //===-- ThreadSafeValue.h ---------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -19,9 +18,7 @@ namespace lldb_private { template <class T> class ThreadSafeValue { public: - //------------------------------------------------------------------ // Constructors and Destructors - //------------------------------------------------------------------ ThreadSafeValue() : m_value(), m_mutex() {} ThreadSafeValue(const T &value) : m_value(value), m_mutex() {} @@ -56,9 +53,7 @@ private: T m_value; mutable std::recursive_mutex m_mutex; - //------------------------------------------------------------------ // For ThreadSafeValue only - //------------------------------------------------------------------ DISALLOW_COPY_AND_ASSIGN(ThreadSafeValue); }; diff --git a/include/lldb/Core/UniqueCStringMap.h b/include/lldb/Core/UniqueCStringMap.h index cfb84b4c2160f..9949bd45f4fa9 100644 --- a/include/lldb/Core/UniqueCStringMap.h +++ b/include/lldb/Core/UniqueCStringMap.h @@ -1,9 +1,8 @@ //===-- UniqueCStringMap.h --------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -18,38 +17,24 @@ 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 // C string value. ConstString::GetCString() can provide such strings. // Any other string table that has guaranteed unique values can also be used. -//---------------------------------------------------------------------- template <typename T> class UniqueCStringMap { public: struct Entry { - Entry() {} - - Entry(ConstString cstr) : cstring(cstr), value() {} - Entry(ConstString cstr, const T &v) : cstring(cstr), value(v) {} - // This is only for uniqueness, not lexicographical ordering, so we can - // just compare pointers. - bool operator<(const Entry &rhs) const { - return cstring.GetCString() < rhs.cstring.GetCString(); - } - ConstString cstring; T value; }; - //------------------------------------------------------------------ // 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)); } @@ -58,25 +43,10 @@ public: void Clear() { m_map.clear(); } - //------------------------------------------------------------------ - // 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); - m_map.insert(std::upper_bound(m_map.begin(), m_map.end(), e), e); - } - - void Insert(const Entry &e) { - m_map.insert(std::upper_bound(m_map.begin(), m_map.end(), e), e); - } - - //------------------------------------------------------------------ // 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. - //------------------------------------------------------------------ bool GetValueAtIndex(uint32_t idx, T &value) const { if (idx < m_map.size()) { value = m_map[idx].value; @@ -103,49 +73,37 @@ public: return ((idx < m_map.size()) ? m_map[idx].cstring : ConstString()); } - //------------------------------------------------------------------ // 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 // T values and only if there is a sensible failure value that can // be returned and that won't match any existing values. - //------------------------------------------------------------------ T Find(ConstString unique_cstr, T fail_value) const { - Entry search_entry(unique_cstr); - const_iterator end = m_map.end(); - const_iterator pos = std::lower_bound(m_map.begin(), end, search_entry); - if (pos != end) { - if (pos->cstring == unique_cstr) - return pos->value; - } + auto pos = llvm::lower_bound(m_map, unique_cstr, Compare()); + if (pos != m_map.end() && pos->cstring == unique_cstr) + return pos->value; return fail_value; } - //------------------------------------------------------------------ // 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. - //------------------------------------------------------------------ const Entry *FindFirstValueForName(ConstString unique_cstr) const { - Entry search_entry(unique_cstr); - const_iterator end = m_map.end(); - const_iterator pos = std::lower_bound(m_map.begin(), end, search_entry); - if (pos != end && pos->cstring == unique_cstr) + auto pos = llvm::lower_bound(m_map, unique_cstr, Compare()); + if (pos != m_map.end() && pos->cstring == unique_cstr) return &(*pos); return nullptr; } - //------------------------------------------------------------------ // 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. - //------------------------------------------------------------------ const Entry *FindNextValueForName(const Entry *entry_ptr) const { if (!m_map.empty()) { const Entry *first_entry = &m_map[0]; @@ -162,15 +120,9 @@ public: size_t GetValues(ConstString unique_cstr, std::vector<T> &values) const { const size_t start_size = values.size(); - Entry search_entry(unique_cstr); - const_iterator pos, end = m_map.end(); - for (pos = std::lower_bound(m_map.begin(), end, search_entry); pos != end; - ++pos) { - if (pos->cstring == unique_cstr) - values.push_back(pos->value); - else - break; - } + for (const Entry &entry : llvm::make_range(std::equal_range( + m_map.begin(), m_map.end(), unique_cstr, Compare()))) + values.push_back(entry.value); return values.size() - start_size; } @@ -188,25 +140,18 @@ public: return values.size() - start_size; } - //------------------------------------------------------------------ // Get the total number of entries in this map. - //------------------------------------------------------------------ size_t GetSize() const { return m_map.size(); } - //------------------------------------------------------------------ // Returns true if this map is empty. - //------------------------------------------------------------------ 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(). - //------------------------------------------------------------------ void Reserve(size_t n) { m_map.reserve(n); } - //------------------------------------------------------------------ // Sort the unsorted contents in this map. A typical code flow would be: // size_t approximate_num_entries = .... // UniqueCStringMap<uint32_t> my_map; @@ -216,16 +161,13 @@ public: // my_map.Append (UniqueCStringMap::Entry(GetName(...), GetValue(...))); // } // my_map.Sort(); - //------------------------------------------------------------------ - void Sort() { llvm::sort(m_map.begin(), m_map.end()); } + void Sort() { llvm::sort(m_map.begin(), m_map.end(), Compare()); } - //------------------------------------------------------------------ // 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()) { collection temp(m_map.begin(), m_map.end()); @@ -233,28 +175,27 @@ public: } } - size_t Erase(ConstString unique_cstr) { - size_t num_removed = 0; - Entry search_entry(unique_cstr); - iterator end = m_map.end(); - iterator begin = m_map.begin(); - iterator lower_pos = std::lower_bound(begin, end, search_entry); - if (lower_pos != end) { - if (lower_pos->cstring == unique_cstr) { - iterator upper_pos = std::upper_bound(lower_pos, end, search_entry); - if (lower_pos == upper_pos) { - m_map.erase(lower_pos); - num_removed = 1; - } else { - num_removed = std::distance(lower_pos, upper_pos); - m_map.erase(lower_pos, upper_pos); - } - } +protected: + struct Compare { + bool operator()(const Entry &lhs, const Entry &rhs) { + return operator()(lhs.cstring, rhs.cstring); } - return num_removed; - } -protected: + bool operator()(const Entry &lhs, ConstString rhs) { + return operator()(lhs.cstring, rhs); + } + + bool operator()(ConstString lhs, const Entry &rhs) { + return operator()(lhs, rhs.cstring); + } + + // This is only for uniqueness, not lexicographical ordering, so we can + // just compare pointers. *However*, comparing pointers from different + // allocations is UB, so we need compare their integral values instead. + bool operator()(ConstString lhs, ConstString rhs) { + return uintptr_t(lhs.GetCString()) < uintptr_t(rhs.GetCString()); + } + }; typedef std::vector<Entry> collection; typedef typename collection::iterator iterator; typedef typename collection::const_iterator const_iterator; diff --git a/include/lldb/Core/UserSettingsController.h b/include/lldb/Core/UserSettingsController.h index 350b5babb47bf..6ae3bdec16650 100644 --- a/include/lldb/Core/UserSettingsController.h +++ b/include/lldb/Core/UserSettingsController.h @@ -1,9 +1,8 @@ //====-- UserSettingsController.h --------------------------------*- C++-*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -23,17 +22,9 @@ namespace lldb_private { class CommandInterpreter; -} -namespace lldb_private { class ConstString; -} -namespace lldb_private { class ExecutionContext; -} -namespace lldb_private { class Property; -} -namespace lldb_private { class Stream; } @@ -78,7 +69,7 @@ public: std::vector<const Property *> &matching_properties) const; lldb::OptionValuePropertiesSP GetSubProperty(const ExecutionContext *exe_ctx, - const ConstString &name); + ConstString name); // 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 diff --git a/include/lldb/Core/Value.h b/include/lldb/Core/Value.h index 249adb24fbc9a..b786e4866f6c1 100644 --- a/include/lldb/Core/Value.h +++ b/include/lldb/Core/Value.h @@ -1,9 +1,8 @@ //===-- Value.h -------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -27,20 +26,10 @@ namespace lldb_private { class DataExtractor; -} -namespace lldb_private { class ExecutionContext; -} -namespace lldb_private { class Module; -} -namespace lldb_private { class Stream; -} -namespace lldb_private { class Type; -} -namespace lldb_private { class Variable; } diff --git a/include/lldb/Core/ValueObject.h b/include/lldb/Core/ValueObject.h index cb6de7b418073..0808b86c67a1c 100644 --- a/include/lldb/Core/ValueObject.h +++ b/include/lldb/Core/ValueObject.h @@ -1,9 +1,8 @@ //===-- ValueObject.h -------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -40,40 +39,19 @@ #include <stddef.h> #include <stdint.h> + namespace lldb_private { class Declaration; -} -namespace lldb_private { class DumpValueObjectOptions; -} -namespace lldb_private { class EvaluateExpressionOptions; -} -namespace lldb_private { class ExecutionContextScope; -} -namespace lldb_private { class Log; -} -namespace lldb_private { class Scalar; -} -namespace lldb_private { class Stream; -} -namespace lldb_private { class SymbolContextScope; -} -namespace lldb_private { class TypeFormatImpl; -} -namespace lldb_private { class TypeSummaryImpl; -} -namespace lldb_private { class TypeSummaryOptions; -} -namespace lldb_private { /// ValueObject: /// @@ -380,16 +358,12 @@ public: virtual bool CanProvideValue(); - //------------------------------------------------------------------ // Subclasses must implement the functions below. - //------------------------------------------------------------------ virtual uint64_t GetByteSize() = 0; virtual lldb::ValueType GetValueType() const = 0; - //------------------------------------------------------------------ // Subclasses can implement the functions below. - //------------------------------------------------------------------ virtual ConstString GetTypeName(); virtual ConstString GetDisplayTypeName(); @@ -479,12 +453,10 @@ public: virtual bool GetDeclaration(Declaration &decl); - //------------------------------------------------------------------ // The functions below should NOT be modified by subclasses - //------------------------------------------------------------------ const Status &GetError(); - const ConstString &GetName() const; + ConstString GetName() const; virtual lldb::ValueObjectSP GetChildAtIndex(size_t idx, bool can_create); @@ -504,10 +476,10 @@ public: GetChildAtNamePath(llvm::ArrayRef<std::pair<ConstString, bool>> names, ConstString *name_of_error = nullptr); - virtual lldb::ValueObjectSP GetChildMemberWithName(const ConstString &name, + virtual lldb::ValueObjectSP GetChildMemberWithName(ConstString name, bool can_create); - virtual size_t GetIndexOfChildWithName(const ConstString &name); + virtual size_t GetIndexOfChildWithName(ConstString name); size_t GetNumChildren(uint32_t max = UINT32_MAX); @@ -574,14 +546,14 @@ public: // Change the name of the current ValueObject. Should *not* be used from a // synthetic child provider as it would change the name of the non synthetic // child as well. - void SetName(const ConstString &name); + void SetName(ConstString name); virtual lldb::addr_t GetAddressOf(bool scalar_is_load_address = true, AddressType *address_type = nullptr); lldb::addr_t GetPointerValue(AddressType *address_type = nullptr); - lldb::ValueObjectSP GetSyntheticChild(const ConstString &key) const; + lldb::ValueObjectSP GetSyntheticChild(ConstString key) const; lldb::ValueObjectSP GetSyntheticArrayMember(size_t index, bool can_create); @@ -618,7 +590,7 @@ public: GetQualifiedRepresentationIfAvailable(lldb::DynamicValueType dynValue, bool synthValue); - virtual lldb::ValueObjectSP CreateConstantValue(const ConstString &name); + virtual lldb::ValueObjectSP CreateConstantValue(ConstString name); virtual lldb::ValueObjectSP Dereference(Status &error); @@ -626,7 +598,7 @@ public: // ValueObject as its parent. It should be used when we want to change the // name of a ValueObject without modifying the actual ValueObject itself // (e.g. sythetic child provider). - virtual lldb::ValueObjectSP Clone(const ConstString &new_name); + virtual lldb::ValueObjectSP Clone(ConstString new_name); virtual lldb::ValueObjectSP AddressOf(Status &error); @@ -789,7 +761,6 @@ public: void SetHasCompleteType() { m_did_calculate_complete_objc_class_type = true; } - //------------------------------------------------------------------ /// Find out if a ValueObject might have children. /// /// This call is much more efficient than CalculateNumChildren() as @@ -801,10 +772,9 @@ public: /// pointers, references, arrays and more. Again, it does so without /// doing any expensive type completion. /// - /// @return + /// \return /// Returns \b true if the ValueObject might have children, or \b /// false otherwise. - //------------------------------------------------------------------ virtual bool MightHaveChildren(); virtual lldb::VariableSP GetVariable() { return nullptr; } @@ -859,9 +829,7 @@ protected: size_t m_children_count; }; - //------------------------------------------------------------------ // Classes that inherit from ValueObject can see and modify these - //------------------------------------------------------------------ ValueObject *m_parent; // The parent value object, or nullptr if this has no parent ValueObject *m_root; // The root of the hierarchy for this ValueObject (or @@ -944,9 +912,7 @@ protected: friend class ValueObjectConstResultImpl; friend class ValueObjectSynthetic; // For ClearUserVisibleData - //------------------------------------------------------------------ // Constructors and Destructors - //------------------------------------------------------------------ // Use the no-argument constructor to make a constant variable object (with // no ExecutionContextScope.) @@ -1000,15 +966,13 @@ protected: void ClearUserVisibleData( uint32_t items = ValueObject::eClearUserVisibleDataItemsAllStrings); - void AddSyntheticChild(const ConstString &key, ValueObject *valobj); + void AddSyntheticChild(ConstString key, ValueObject *valobj); DataExtractor &GetDataExtractor(); void ClearDynamicTypeInformation(); - //------------------------------------------------------------------ // Subclasses must implement the functions below. - //------------------------------------------------------------------ virtual CompilerType GetCompilerTypeImpl() = 0; @@ -1032,14 +996,12 @@ private: DISALLOW_COPY_AND_ASSIGN(ValueObject); }; -//------------------------------------------------------------------------------ // 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 // ID and will update the user type when needed. -//------------------------------------------------------------------------------ class ValueObjectManager { // The root value object is the static typed variable object. lldb::ValueObjectSP m_root_valobj_sp; diff --git a/include/lldb/Core/ValueObjectCast.h b/include/lldb/Core/ValueObjectCast.h index 34814d9b17bb8..feee493dfafbc 100644 --- a/include/lldb/Core/ValueObjectCast.h +++ b/include/lldb/Core/ValueObjectCast.h @@ -1,9 +1,8 @@ -//===-- ValueObjectDynamicValue.h -------------------------------*- C++ -*-===// +//===-- ValueObjectCast.h ---------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -21,19 +20,14 @@ namespace lldb_private { class ConstString; -} - -namespace lldb_private { -//--------------------------------------------------------------------------------- // A ValueObject that represents a given value represented as a different type. -//--------------------------------------------------------------------------------- class ValueObjectCast : public ValueObject { public: ~ValueObjectCast() override; static lldb::ValueObjectSP Create(ValueObject &parent, - const ConstString &name, + ConstString name, const CompilerType &cast_type); uint64_t GetByteSize() override; @@ -53,7 +47,7 @@ public: } protected: - ValueObjectCast(ValueObject &parent, const ConstString &name, + ValueObjectCast(ValueObject &parent, ConstString name, const CompilerType &cast_type); bool UpdateValue() override; diff --git a/include/lldb/Core/ValueObjectChild.h b/include/lldb/Core/ValueObjectChild.h index 6800775dc8f9d..76209a22ec204 100644 --- a/include/lldb/Core/ValueObjectChild.h +++ b/include/lldb/Core/ValueObjectChild.h @@ -1,9 +1,8 @@ //===-- ValueObjectChild.h --------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -26,9 +25,7 @@ namespace lldb_private { -//---------------------------------------------------------------------- // A child of another ValueObject. -//---------------------------------------------------------------------- class ValueObjectChild : public ValueObject { public: ~ValueObjectChild() override; @@ -84,7 +81,7 @@ protected: friend class ValueObjectConstResultImpl; ValueObjectChild(ValueObject &parent, const CompilerType &compiler_type, - const ConstString &name, uint64_t byte_size, + ConstString name, uint64_t byte_size, int32_t byte_offset, uint32_t bitfield_bit_size, uint32_t bitfield_bit_offset, bool is_base_class, bool is_deref_of_parent, diff --git a/include/lldb/Core/ValueObjectConstResult.h b/include/lldb/Core/ValueObjectConstResult.h index c1c56d8dcb223..3bc957ef2b849 100644 --- a/include/lldb/Core/ValueObjectConstResult.h +++ b/include/lldb/Core/ValueObjectConstResult.h @@ -1,9 +1,8 @@ //===-- ValueObjectConstResult.h --------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -27,18 +26,10 @@ namespace lldb_private { class DataExtractor; -} -namespace lldb_private { class ExecutionContextScope; -} -namespace lldb_private { class Module; -} -namespace lldb_private { -//---------------------------------------------------------------------- // A frozen ValueObject copied into host memory -//---------------------------------------------------------------------- class ValueObjectConstResult : public ValueObject { public: ~ValueObjectConstResult() override; @@ -49,22 +40,22 @@ public: static lldb::ValueObjectSP Create(ExecutionContextScope *exe_scope, const CompilerType &compiler_type, - const ConstString &name, const DataExtractor &data, + ConstString name, const DataExtractor &data, lldb::addr_t address = LLDB_INVALID_ADDRESS); static lldb::ValueObjectSP Create(ExecutionContextScope *exe_scope, const CompilerType &compiler_type, - const ConstString &name, const lldb::DataBufferSP &result_data_sp, + ConstString name, const lldb::DataBufferSP &result_data_sp, lldb::ByteOrder byte_order, uint32_t addr_size, lldb::addr_t address = LLDB_INVALID_ADDRESS); static lldb::ValueObjectSP Create(ExecutionContextScope *exe_scope, const CompilerType &compiler_type, - const ConstString &name, lldb::addr_t address, + ConstString name, lldb::addr_t address, AddressType address_type, uint32_t addr_byte_size); static lldb::ValueObjectSP Create(ExecutionContextScope *exe_scope, - Value &value, const ConstString &name, + Value &value, ConstString name, Module *module = nullptr); // When an expression fails to evaluate, we return an error @@ -135,23 +126,23 @@ private: ValueObjectConstResult(ExecutionContextScope *exe_scope, const CompilerType &compiler_type, - const ConstString &name, const DataExtractor &data, + ConstString name, const DataExtractor &data, lldb::addr_t address); ValueObjectConstResult(ExecutionContextScope *exe_scope, const CompilerType &compiler_type, - const ConstString &name, + ConstString name, const lldb::DataBufferSP &result_data_sp, lldb::ByteOrder byte_order, uint32_t addr_size, lldb::addr_t address); ValueObjectConstResult(ExecutionContextScope *exe_scope, const CompilerType &compiler_type, - const ConstString &name, lldb::addr_t address, + ConstString name, lldb::addr_t address, AddressType address_type, uint32_t addr_byte_size); ValueObjectConstResult(ExecutionContextScope *exe_scope, const Value &value, - const ConstString &name, Module *module = nullptr); + ConstString name, Module *module = nullptr); ValueObjectConstResult(ExecutionContextScope *exe_scope, const Status &error); diff --git a/include/lldb/Core/ValueObjectConstResultCast.h b/include/lldb/Core/ValueObjectConstResultCast.h index bb2b4e6f092fb..be9b12b4b57cb 100644 --- a/include/lldb/Core/ValueObjectConstResultCast.h +++ b/include/lldb/Core/ValueObjectConstResultCast.h @@ -1,9 +1,8 @@ //===-- ValueObjectConstResultCast.h ----------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -23,19 +22,12 @@ namespace lldb_private { class DataExtractor; -} -namespace lldb_private { class Status; -} -namespace lldb_private { class ValueObject; -} - -namespace lldb_private { class ValueObjectConstResultCast : public ValueObjectCast { public: - ValueObjectConstResultCast(ValueObject &parent, const ConstString &name, + ValueObjectConstResultCast(ValueObject &parent, ConstString name, const CompilerType &cast_type, lldb::addr_t live_address = LLDB_INVALID_ADDRESS); diff --git a/include/lldb/Core/ValueObjectConstResultChild.h b/include/lldb/Core/ValueObjectConstResultChild.h index f14fb75640e65..16fa74f71ed57 100644 --- a/include/lldb/Core/ValueObjectConstResultChild.h +++ b/include/lldb/Core/ValueObjectConstResultChild.h @@ -1,9 +1,8 @@ //===-- ValueObjectConstResultChild.h ----------------------------*- C++-*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -20,26 +19,18 @@ #include <stddef.h> #include <stdint.h> + namespace lldb_private { class DataExtractor; -} -namespace lldb_private { class Status; -} -namespace lldb_private { class ValueObject; -} - -namespace lldb_private { -//---------------------------------------------------------------------- // A child of a ValueObjectConstResult. -//---------------------------------------------------------------------- class ValueObjectConstResultChild : public ValueObjectChild { public: ValueObjectConstResultChild(ValueObject &parent, const CompilerType &compiler_type, - const ConstString &name, uint32_t byte_size, + ConstString name, uint32_t byte_size, int32_t byte_offset, uint32_t bitfield_bit_size, uint32_t bitfield_bit_offset, bool is_base_class, bool is_deref_of_parent, diff --git a/include/lldb/Core/ValueObjectConstResultImpl.h b/include/lldb/Core/ValueObjectConstResultImpl.h index 5ea47bb3b3fa3..ffac98e12e611 100644 --- a/include/lldb/Core/ValueObjectConstResultImpl.h +++ b/include/lldb/Core/ValueObjectConstResultImpl.h @@ -1,9 +1,8 @@ //===-- ValueObjectConstResultImpl.h ----------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -20,24 +19,16 @@ #include <stdint.h> namespace lldb_private { class CompilerType; -} -namespace lldb_private { class DataExtractor; -} -namespace lldb_private { class Status; -} -namespace lldb_private { class ValueObject; } namespace lldb_private { -//---------------------------------------------------------------------- // A class wrapping common implementation details for operations in // ValueObjectConstResult ( & Child ) that may need to jump from the host // memory space into the target's memory space -//---------------------------------------------------------------------- class ValueObjectConstResultImpl { public: ValueObjectConstResultImpl(ValueObject *valobj, diff --git a/include/lldb/Core/ValueObjectDynamicValue.h b/include/lldb/Core/ValueObjectDynamicValue.h index 0c9ec8cce06ef..f656d42e9a970 100644 --- a/include/lldb/Core/ValueObjectDynamicValue.h +++ b/include/lldb/Core/ValueObjectDynamicValue.h @@ -1,9 +1,8 @@ //===-- ValueObjectDynamicValue.h -------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -27,19 +26,11 @@ namespace lldb_private { class DataExtractor; -} -namespace lldb_private { class Declaration; -} -namespace lldb_private { class Status; -} -namespace lldb_private { -//---------------------------------------------------------------------- // A ValueObject that represents memory at a given address, viewed as some // set lldb type. -//---------------------------------------------------------------------- class ValueObjectDynamicValue : public ValueObject { public: ~ValueObjectDynamicValue() override; diff --git a/include/lldb/Core/ValueObjectList.h b/include/lldb/Core/ValueObjectList.h index d17510f7f581e..42d19676d5d35 100644 --- a/include/lldb/Core/ValueObjectList.h +++ b/include/lldb/Core/ValueObjectList.h @@ -1,9 +1,8 @@ //===-- ValueObjectList.h ---------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -19,24 +18,10 @@ namespace lldb_private { class ValueObject; -} - -namespace lldb_private { -//---------------------------------------------------------------------- // A collection of ValueObject values that -//---------------------------------------------------------------------- class ValueObjectList { public: - //------------------------------------------------------------------ - // Constructors and Destructors - //------------------------------------------------------------------ - ValueObjectList(); - - ValueObjectList(const ValueObjectList &rhs); - - ~ValueObjectList(); - const ValueObjectList &operator=(const ValueObjectList &rhs); void Append(const lldb::ValueObjectSP &val_obj_sp); @@ -68,9 +53,7 @@ public: } protected: typedef std::vector<lldb::ValueObjectSP> collection; - //------------------------------------------------------------------ // Classes that inherit from ValueObjectList can see and modify these - //------------------------------------------------------------------ collection m_value_objects; }; diff --git a/include/lldb/Core/ValueObjectMemory.h b/include/lldb/Core/ValueObjectMemory.h index c4b946af98ce3..df3557f149891 100644 --- a/include/lldb/Core/ValueObjectMemory.h +++ b/include/lldb/Core/ValueObjectMemory.h @@ -1,9 +1,8 @@ //===-- ValueObjectMemory.h -----------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -24,14 +23,9 @@ namespace lldb_private { class ExecutionContextScope; -} - -namespace lldb_private { -//---------------------------------------------------------------------- // A ValueObject that represents memory at a given address, viewed as some // set lldb type. -//---------------------------------------------------------------------- class ValueObjectMemory : public ValueObject { public: ~ValueObjectMemory() override; @@ -75,9 +69,7 @@ private: ValueObjectMemory(ExecutionContextScope *exe_scope, llvm::StringRef name, const Address &address, const CompilerType &ast_type); - //------------------------------------------------------------------ // For ValueObject only - //------------------------------------------------------------------ DISALLOW_COPY_AND_ASSIGN(ValueObjectMemory); }; diff --git a/include/lldb/Core/ValueObjectRegister.h b/include/lldb/Core/ValueObjectRegister.h index fb10c259e7d02..e584be6e60572 100644 --- a/include/lldb/Core/ValueObjectRegister.h +++ b/include/lldb/Core/ValueObjectRegister.h @@ -1,9 +1,8 @@ //===-- ValueObjectRegister.h -----------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -24,26 +23,13 @@ namespace lldb_private { class DataExtractor; -} -namespace lldb_private { class Status; -} -namespace lldb_private { class ExecutionContextScope; -} -namespace lldb_private { class Scalar; -} -namespace lldb_private { class Stream; -} - -namespace lldb_private { -//---------------------------------------------------------------------- // A ValueObject that contains a root variable that may or may not // have children. -//---------------------------------------------------------------------- class ValueObjectRegisterContext : public ValueObject { public: ~ValueObjectRegisterContext() override; @@ -75,9 +61,7 @@ protected: private: ValueObjectRegisterContext(ValueObject &parent, lldb::RegisterContextSP ®_ctx_sp); - //------------------------------------------------------------------ // For ValueObject only - //------------------------------------------------------------------ DISALLOW_COPY_AND_ASSIGN(ValueObjectRegisterContext); }; @@ -104,10 +88,10 @@ public: ValueObject *CreateChildAtIndex(size_t idx, bool synthetic_array_member, int32_t synthetic_index) override; - lldb::ValueObjectSP GetChildMemberWithName(const ConstString &name, + lldb::ValueObjectSP GetChildMemberWithName(ConstString name, bool can_create) override; - size_t GetIndexOfChildWithName(const ConstString &name) override; + size_t GetIndexOfChildWithName(ConstString name) override; protected: bool UpdateValue() override; @@ -124,9 +108,7 @@ private: ValueObjectRegisterSet(ExecutionContextScope *exe_scope, lldb::RegisterContextSP ®_ctx_sp, uint32_t set_idx); - //------------------------------------------------------------------ // For ValueObject only - //------------------------------------------------------------------ DISALLOW_COPY_AND_ASSIGN(ValueObjectRegisterSet); }; @@ -180,9 +162,7 @@ private: ValueObjectRegister(ExecutionContextScope *exe_scope, lldb::RegisterContextSP ®_ctx_sp, uint32_t reg_num); - //------------------------------------------------------------------ // For ValueObject only - //------------------------------------------------------------------ DISALLOW_COPY_AND_ASSIGN(ValueObjectRegister); }; diff --git a/include/lldb/Core/ValueObjectSyntheticFilter.h b/include/lldb/Core/ValueObjectSyntheticFilter.h index 9495d4ca5e250..3b14a3e9f3885 100644 --- a/include/lldb/Core/ValueObjectSyntheticFilter.h +++ b/include/lldb/Core/ValueObjectSyntheticFilter.h @@ -1,9 +1,8 @@ //===-- ValueObjectSyntheticFilter.h ----------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -27,22 +26,14 @@ namespace lldb_private { class Declaration; -} -namespace lldb_private { class Status; -} -namespace lldb_private { class SyntheticChildrenFrontEnd; -} -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 -//---------------------------------------------------------------------- class ValueObjectSynthetic : public ValueObject { public: ~ValueObjectSynthetic() override; @@ -63,10 +54,10 @@ public: lldb::ValueObjectSP GetChildAtIndex(size_t idx, bool can_create) override; - lldb::ValueObjectSP GetChildMemberWithName(const ConstString &name, + lldb::ValueObjectSP GetChildMemberWithName(ConstString name, bool can_create) override; - size_t GetIndexOfChildWithName(const ConstString &name) override; + size_t GetIndexOfChildWithName(ConstString name) override; lldb::ValueObjectSP GetDynamicValue(lldb::DynamicValueType valueType) override; @@ -142,7 +133,7 @@ protected: // we need to hold on to the SyntheticChildren because someone might delete // the type binding while we are alive lldb::SyntheticChildrenSP m_synth_sp; - std::unique_ptr<SyntheticChildrenFrontEnd> m_synth_filter_ap; + std::unique_ptr<SyntheticChildrenFrontEnd> m_synth_filter_up; typedef ThreadSafeSTLMap<uint32_t, ValueObject *> ByIndexMap; typedef ThreadSafeSTLMap<const char *, uint32_t> NameToIndexMap; diff --git a/include/lldb/Core/ValueObjectVariable.h b/include/lldb/Core/ValueObjectVariable.h index 81a8eabdacbb0..86bb8ef90070b 100644 --- a/include/lldb/Core/ValueObjectVariable.h +++ b/include/lldb/Core/ValueObjectVariable.h @@ -1,9 +1,8 @@ //===-- ValueObjectVariable.h -----------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -24,26 +23,13 @@ namespace lldb_private { class DataExtractor; -} -namespace lldb_private { class Declaration; -} -namespace lldb_private { class Status; -} -namespace lldb_private { class ExecutionContextScope; -} -namespace lldb_private { class SymbolContextScope; -} - -namespace lldb_private { -//---------------------------------------------------------------------- // A ValueObject that contains a root variable that may or may not // have children. -//---------------------------------------------------------------------- class ValueObjectVariable : public ValueObject { public: ~ValueObjectVariable() override; @@ -77,7 +63,7 @@ public: bool SetData(DataExtractor &data, Status &error) override; - virtual lldb::VariableSP GetVariable() override { return m_variable_sp; } + lldb::VariableSP GetVariable() override { return m_variable_sp; } protected: bool UpdateValue() override; @@ -92,9 +78,7 @@ protected: private: ValueObjectVariable(ExecutionContextScope *exe_scope, const lldb::VariableSP &var_sp); - //------------------------------------------------------------------ // For ValueObject only - //------------------------------------------------------------------ DISALLOW_COPY_AND_ASSIGN(ValueObjectVariable); }; diff --git a/include/lldb/Core/dwarf.h b/include/lldb/Core/dwarf.h index 651a2bc294755..afe62e09fe168 100644 --- a/include/lldb/Core/dwarf.h +++ b/include/lldb/Core/dwarf.h @@ -1,22 +1,20 @@ //===-- dwarf.h -------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// #ifndef DebugBase_dwarf_h_ #define DebugBase_dwarf_h_ +#include "lldb/Utility/RangeMap.h" #include <stdint.h> // Get the DWARF constant definitions from llvm #include "llvm/BinaryFormat/Dwarf.h" -#include "lldb/Core/RangeMap.h" - // and stuff them in our default namespace using namespace llvm::dwarf; @@ -29,15 +27,8 @@ typedef uint64_t dw_addr_t; // Dwarf address define that must be big enough for // any addresses in the compile units that get // parsed -#ifdef DWARFUTILS_DWARF64 -#define DWARF_REF_ADDR_SIZE 8 -typedef uint64_t dw_offset_t; // Dwarf Debug Information Entry offset for any - // offset into the file -#else -#define DWARF_REF_ADDR_SIZE 4 typedef uint32_t dw_offset_t; // Dwarf Debug Information Entry offset for any // offset into the file -#endif /* Constants */ #define DW_INVALID_OFFSET (~(dw_offset_t)0) diff --git a/include/lldb/DataFormatters/CXXFunctionPointer.h b/include/lldb/DataFormatters/CXXFunctionPointer.h index 13af2fd9da1c8..b5417895f7bf8 100644 --- a/include/lldb/DataFormatters/CXXFunctionPointer.h +++ b/include/lldb/DataFormatters/CXXFunctionPointer.h @@ -1,9 +1,8 @@ //===-- CXXFunctionPointer.h ------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// diff --git a/include/lldb/DataFormatters/DataVisualization.h b/include/lldb/DataFormatters/DataVisualization.h index 9ca2e95cd9cb6..cdb2eab995fce 100644 --- a/include/lldb/DataFormatters/DataVisualization.h +++ b/include/lldb/DataFormatters/DataVisualization.h @@ -1,9 +1,8 @@ //===-- DataVisualization.h -------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -43,23 +42,14 @@ public: static lldb::TypeSummaryImplSP GetSummaryForType(lldb::TypeNameSpecifierImplSP type_sp); -#ifndef LLDB_DISABLE_PYTHON - static lldb::SyntheticChildrenSP - GetSyntheticChildrenForType(lldb::TypeNameSpecifierImplSP type_sp); -#endif - static lldb::TypeFilterImplSP GetFilterForType(lldb::TypeNameSpecifierImplSP type_sp); -#ifndef LLDB_DISABLE_PYTHON static lldb::ScriptedSyntheticChildrenSP GetSyntheticForType(lldb::TypeNameSpecifierImplSP type_sp); -#endif -#ifndef LLDB_DISABLE_PYTHON static lldb::SyntheticChildrenSP GetSyntheticChildren(ValueObject &valobj, lldb::DynamicValueType use_dynamic); -#endif static lldb::TypeValidatorImplSP GetValidator(ValueObject &valobj, lldb::DynamicValueType use_dynamic); @@ -76,13 +66,13 @@ public: class NamedSummaryFormats { public: - static bool GetSummaryFormat(const ConstString &type, + static bool GetSummaryFormat(ConstString type, lldb::TypeSummaryImplSP &entry); - static void Add(const ConstString &type, + static void Add(ConstString type, const lldb::TypeSummaryImplSP &entry); - static bool Delete(const ConstString &type); + static bool Delete(ConstString type); static void Clear(); @@ -95,27 +85,27 @@ public: class Categories { public: - static bool GetCategory(const ConstString &category, + static bool GetCategory(ConstString category, lldb::TypeCategoryImplSP &entry, bool allow_create = true); static bool GetCategory(lldb::LanguageType language, lldb::TypeCategoryImplSP &entry); - static void Add(const ConstString &category); + static void Add(ConstString category); - static bool Delete(const ConstString &category); + static bool Delete(ConstString category); static void Clear(); - static void Clear(const ConstString &category); + static void Clear(ConstString category); - static void Enable(const ConstString &category, + static void Enable(ConstString category, TypeCategoryMap::Position = TypeCategoryMap::Default); static void Enable(lldb::LanguageType lang_type); - static void Disable(const ConstString &category); + static void Disable(ConstString category); static void Disable(lldb::LanguageType lang_type); diff --git a/include/lldb/DataFormatters/DumpValueObjectOptions.h b/include/lldb/DataFormatters/DumpValueObjectOptions.h index 113c48afa6f87..c37411539de63 100644 --- a/include/lldb/DataFormatters/DumpValueObjectOptions.h +++ b/include/lldb/DataFormatters/DumpValueObjectOptions.h @@ -1,9 +1,8 @@ //===-- DumpValueObjectOptions.h --------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// diff --git a/include/lldb/DataFormatters/FormatCache.h b/include/lldb/DataFormatters/FormatCache.h index 2c09b65a420a8..7a6774b7f8378 100644 --- a/include/lldb/DataFormatters/FormatCache.h +++ b/include/lldb/DataFormatters/FormatCache.h @@ -1,10 +1,9 @@ //===-- FormatCache.h ---------------------------------------------*- C++ //-*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -72,29 +71,29 @@ private: uint64_t m_cache_hits; uint64_t m_cache_misses; - Entry &GetEntry(const ConstString &type); + Entry &GetEntry(ConstString type); public: FormatCache(); - bool GetFormat(const ConstString &type, lldb::TypeFormatImplSP &format_sp); + bool GetFormat(ConstString type, lldb::TypeFormatImplSP &format_sp); - bool GetSummary(const ConstString &type, lldb::TypeSummaryImplSP &summary_sp); + bool GetSummary(ConstString type, lldb::TypeSummaryImplSP &summary_sp); - bool GetSynthetic(const ConstString &type, + bool GetSynthetic(ConstString type, lldb::SyntheticChildrenSP &synthetic_sp); - bool GetValidator(const ConstString &type, + bool GetValidator(ConstString type, lldb::TypeValidatorImplSP &summary_sp); - void SetFormat(const ConstString &type, lldb::TypeFormatImplSP &format_sp); + void SetFormat(ConstString type, lldb::TypeFormatImplSP &format_sp); - void SetSummary(const ConstString &type, lldb::TypeSummaryImplSP &summary_sp); + void SetSummary(ConstString type, lldb::TypeSummaryImplSP &summary_sp); - void SetSynthetic(const ConstString &type, + void SetSynthetic(ConstString type, lldb::SyntheticChildrenSP &synthetic_sp); - void SetValidator(const ConstString &type, + void SetValidator(ConstString type, lldb::TypeValidatorImplSP &synthetic_sp); void Clear(); diff --git a/include/lldb/DataFormatters/FormatClasses.h b/include/lldb/DataFormatters/FormatClasses.h index 1f08485d02927..5144bc6079a9c 100644 --- a/include/lldb/DataFormatters/FormatClasses.h +++ b/include/lldb/DataFormatters/FormatClasses.h @@ -1,9 +1,8 @@ //===-- FormatClasses.h -----------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -123,14 +122,14 @@ public: TypeNameSpecifierImpl(lldb::TypeSP type) : m_is_regex(false), m_type() { if (type) { m_type.m_type_name = type->GetName().GetStringRef(); - m_type.m_type_pair.SetType(type); + m_type.m_compiler_type = type->GetForwardCompilerType(); } } TypeNameSpecifierImpl(CompilerType type) : m_is_regex(false), m_type() { if (type.IsValid()) { m_type.m_type_name.assign(type.GetConstTypeName().GetCString()); - m_type.m_type_pair.SetType(type); + m_type.m_compiler_type = type; } } @@ -140,15 +139,9 @@ public: return nullptr; } - lldb::TypeSP GetTypeSP() { - if (m_type.m_type_pair.IsValid()) - return m_type.m_type_pair.GetTypeSP(); - return lldb::TypeSP(); - } - CompilerType GetCompilerType() { - if (m_type.m_type_pair.IsValid()) - return m_type.m_type_pair.GetCompilerType(); + if (m_type.m_compiler_type.IsValid()) + return m_type.m_compiler_type; return CompilerType(); } @@ -156,11 +149,10 @@ 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 + // TODO: Replace this with TypeAndOrName. struct TypeOrName { std::string m_type_name; - TypePair m_type_pair; + CompilerType m_compiler_type; }; TypeOrName m_type; diff --git a/include/lldb/DataFormatters/FormatManager.h b/include/lldb/DataFormatters/FormatManager.h index 9046ccf2e0bbf..afaafda47e761 100644 --- a/include/lldb/DataFormatters/FormatManager.h +++ b/include/lldb/DataFormatters/FormatManager.h @@ -1,9 +1,8 @@ //===-- FormatManager.h -----------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -51,19 +50,19 @@ public: } void - EnableCategory(const ConstString &category_name, + EnableCategory(ConstString category_name, TypeCategoryMap::Position pos = TypeCategoryMap::Default) { EnableCategory(category_name, pos, std::initializer_list<lldb::LanguageType>()); } - void EnableCategory(const ConstString &category_name, + void EnableCategory(ConstString category_name, TypeCategoryMap::Position pos, lldb::LanguageType lang) { std::initializer_list<lldb::LanguageType> langs = {lang}; EnableCategory(category_name, pos, langs); } - void EnableCategory(const ConstString &category_name, + void EnableCategory(ConstString category_name, TypeCategoryMap::Position pos = TypeCategoryMap::Default, std::initializer_list<lldb::LanguageType> langs = {}) { TypeCategoryMap::ValueSP category_sp; @@ -74,7 +73,7 @@ public: } } - void DisableCategory(const ConstString &category_name) { + void DisableCategory(ConstString category_name) { m_categories_map.Disable(category_name); } @@ -92,7 +91,7 @@ public: void DisableAllCategories(); - bool DeleteCategory(const ConstString &category_name) { + bool DeleteCategory(ConstString category_name) { return m_categories_map.Delete(category_name); } @@ -113,7 +112,7 @@ public: return GetCategory(ConstString(category_name)); } - lldb::TypeCategoryImplSP GetCategory(const ConstString &category_name, + lldb::TypeCategoryImplSP GetCategory(ConstString category_name, bool can_create = true); lldb::TypeFormatImplSP @@ -125,15 +124,8 @@ public: lldb::TypeFilterImplSP GetFilterForType(lldb::TypeNameSpecifierImplSP type_sp); -#ifndef LLDB_DISABLE_PYTHON lldb::ScriptedSyntheticChildrenSP GetSyntheticForType(lldb::TypeNameSpecifierImplSP type_sp); -#endif - -#ifndef LLDB_DISABLE_PYTHON - lldb::SyntheticChildrenSP - GetSyntheticChildrenForType(lldb::TypeNameSpecifierImplSP type_sp); -#endif lldb::TypeValidatorImplSP GetValidatorForType(lldb::TypeNameSpecifierImplSP type_sp); @@ -144,10 +136,8 @@ public: lldb::TypeSummaryImplSP GetSummaryFormat(ValueObject &valobj, lldb::DynamicValueType use_dynamic); -#ifndef LLDB_DISABLE_PYTHON lldb::SyntheticChildrenSP GetSyntheticChildren(ValueObject &valobj, lldb::DynamicValueType use_dynamic); -#endif lldb::TypeValidatorImplSP GetValidator(ValueObject &valobj, lldb::DynamicValueType use_dynamic); @@ -174,7 +164,7 @@ public: // 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); + static ConstString GetValidTypeName(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 diff --git a/include/lldb/DataFormatters/FormattersContainer.h b/include/lldb/DataFormatters/FormattersContainer.h index dd8995d81132e..9d7d37343ac25 100644 --- a/include/lldb/DataFormatters/FormattersContainer.h +++ b/include/lldb/DataFormatters/FormattersContainer.h @@ -1,9 +1,8 @@ //===-- FormattersContainer.h -----------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -43,7 +42,7 @@ public: // 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) { +static inline ConstString GetValidTypeName_Impl(ConstString type) { if (type.IsEmpty()) return type; @@ -239,7 +238,7 @@ protected: m_format_map.Add(type, entry); } - void Add_Impl(const ConstString &type, const MapValueType &entry, + void Add_Impl(ConstString type, const MapValueType &entry, ConstString *dummy) { m_format_map.Add(GetValidTypeName_Impl(type), entry); } diff --git a/include/lldb/DataFormatters/FormattersHelpers.h b/include/lldb/DataFormatters/FormattersHelpers.h index 028d5cc27688f..79bd376c76eb6 100644 --- a/include/lldb/DataFormatters/FormattersHelpers.h +++ b/include/lldb/DataFormatters/FormattersHelpers.h @@ -1,10 +1,9 @@ //===-- FormattersHelpers.h --------------------------------------*- C++ //-*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -37,7 +36,6 @@ void AddOneLineSummary(TypeCategoryImpl::SharedPointer category_sp, ConstString type_name, TypeSummaryImpl::Flags flags, bool regex = false); -#ifndef LLDB_DISABLE_PYTHON void AddCXXSummary(TypeCategoryImpl::SharedPointer category_sp, CXXFunctionSummaryFormat::Callback funct, const char *description, ConstString type_name, @@ -53,7 +51,6 @@ void AddFilter(TypeCategoryImpl::SharedPointer category_sp, std::vector<std::string> children, const char *description, ConstString type_name, ScriptedSyntheticChildren::Flags flags, bool regex = false); -#endif size_t ExtractIndexFromString(const char *item_name); diff --git a/include/lldb/DataFormatters/LanguageCategory.h b/include/lldb/DataFormatters/LanguageCategory.h index f2ac628636d43..f109d46194ad9 100644 --- a/include/lldb/DataFormatters/LanguageCategory.h +++ b/include/lldb/DataFormatters/LanguageCategory.h @@ -1,10 +1,9 @@ //===-- LanguageCategory.h----------------------------------------*- C++ //-*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// diff --git a/include/lldb/DataFormatters/StringPrinter.h b/include/lldb/DataFormatters/StringPrinter.h index 38033f915bf96..41d5edd880216 100644 --- a/include/lldb/DataFormatters/StringPrinter.h +++ b/include/lldb/DataFormatters/StringPrinter.h @@ -1,9 +1,8 @@ //===-- StringPrinter.h -----------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// diff --git a/include/lldb/DataFormatters/TypeCategory.h b/include/lldb/DataFormatters/TypeCategory.h index 177e602e6ec33..bdb393abd848c 100644 --- a/include/lldb/DataFormatters/TypeCategory.h +++ b/include/lldb/DataFormatters/TypeCategory.h @@ -1,9 +1,8 @@ //===-- TypeCategory.h ------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -69,10 +68,7 @@ private: typedef FormatterContainerPair<TypeSummaryImpl> SummaryContainer; typedef FormatterContainerPair<TypeFilterImpl> FilterContainer; typedef FormatterContainerPair<TypeValidatorImpl> ValidatorContainer; - -#ifndef LLDB_DISABLE_PYTHON typedef FormatterContainerPair<SyntheticChildren> SynthContainer; -#endif // LLDB_DISABLE_PYTHON public: typedef uint16_t FormatCategoryItems; @@ -86,10 +82,9 @@ public: typedef FilterContainer::ExactMatchContainerSP FilterContainerSP; typedef FilterContainer::RegexMatchContainerSP RegexFilterContainerSP; -#ifndef LLDB_DISABLE_PYTHON + typedef SynthContainer::ExactMatchContainerSP SynthContainerSP; typedef SynthContainer::RegexMatchContainerSP RegexSynthContainerSP; -#endif // LLDB_DISABLE_PYTHON typedef ValidatorContainer::ExactMatchContainerSP ValidatorContainerSP; typedef ValidatorContainer::RegexMatchContainerSP RegexValidatorContainerSP; @@ -138,7 +133,6 @@ public: return *this; } -#ifndef LLDB_DISABLE_PYTHON template <typename U = SyntheticChildren> typename std::enable_if<std::is_same<U, T>::value, ForEachCallbacks &>::type SetExact(SynthContainer::ExactMatchForEachCallback callback) { @@ -151,7 +145,6 @@ public: m_synth_regex = callback; return *this; } -#endif // LLDB_DISABLE_PYTHON template <typename U = TypeValidatorImpl> typename std::enable_if<std::is_same<U, T>::value, ForEachCallbacks &>::type SetExact(ValidatorContainer::ExactMatchForEachCallback callback) { @@ -188,14 +181,12 @@ public: return m_filter_regex; } -#ifndef LLDB_DISABLE_PYTHON SynthContainer::ExactMatchForEachCallback GetSynthExactCallback() const { return m_synth_exact; } SynthContainer::RegexMatchForEachCallback GetSynthRegexCallback() const { return m_synth_regex; } -#endif // LLDB_DISABLE_PYTHON ValidatorContainer::ExactMatchForEachCallback GetValidatorExactCallback() const { @@ -216,10 +207,8 @@ public: FilterContainer::ExactMatchForEachCallback m_filter_exact; FilterContainer::RegexMatchForEachCallback m_filter_regex; -#ifndef LLDB_DISABLE_PYTHON SynthContainer::ExactMatchForEachCallback m_synth_exact; SynthContainer::RegexMatchForEachCallback m_synth_regex; -#endif // LLDB_DISABLE_PYTHON ValidatorContainer::ExactMatchForEachCallback m_validator_exact; ValidatorContainer::RegexMatchForEachCallback m_validator_regex; @@ -239,10 +228,8 @@ public: GetTypeFiltersContainer()->ForEach(foreach.GetFilterExactCallback()); GetRegexTypeFiltersContainer()->ForEach(foreach.GetFilterRegexCallback()); -#ifndef LLDB_DISABLE_PYTHON GetTypeSyntheticsContainer()->ForEach(foreach.GetSynthExactCallback()); GetRegexTypeSyntheticsContainer()->ForEach(foreach.GetSynthRegexCallback()); -#endif // LLDB_DISABLE_PYTHON GetTypeValidatorsContainer()->ForEach(foreach.GetValidatorExactCallback()); GetRegexTypeValidatorsContainer()->ForEach( @@ -288,10 +275,8 @@ public: FilterContainer::MapValueType GetFilterForType(lldb::TypeNameSpecifierImplSP type_sp); -#ifndef LLDB_DISABLE_PYTHON SynthContainer::MapValueType GetSyntheticForType(lldb::TypeNameSpecifierImplSP type_sp); -#endif ValidatorContainer::MapValueType GetValidatorForType(lldb::TypeNameSpecifierImplSP type_sp); @@ -311,7 +296,6 @@ public: lldb::TypeNameSpecifierImplSP GetTypeNameSpecifierForFilterAtIndex(size_t index); -#ifndef LLDB_DISABLE_PYTHON SynthContainerSP GetTypeSyntheticsContainer() { return m_synth_cont.GetExactMatch(); } @@ -326,7 +310,6 @@ public: lldb::TypeNameSpecifierImplSP GetTypeNameSpecifierForSyntheticAtIndex(size_t index); -#endif // LLDB_DISABLE_PYTHON ValidatorContainerSP GetTypeValidatorsContainer() { return m_validator_cont.GetExactMatch(); @@ -392,9 +375,7 @@ private: FormatContainer m_format_cont; SummaryContainer m_summary_cont; FilterContainer m_filter_cont; -#ifndef LLDB_DISABLE_PYTHON SynthContainer m_synth_cont; -#endif // LLDB_DISABLE_PYTHON ValidatorContainer m_validator_cont; bool m_enabled; @@ -432,11 +413,9 @@ private: friend class FormattersContainer<ConstString, TypeFilterImpl>; friend class FormattersContainer<lldb::RegularExpressionSP, TypeFilterImpl>; -#ifndef LLDB_DISABLE_PYTHON friend class FormattersContainer<ConstString, ScriptedSyntheticChildren>; friend class FormattersContainer<lldb::RegularExpressionSP, ScriptedSyntheticChildren>; -#endif // LLDB_DISABLE_PYTHON friend class FormattersContainer<ConstString, TypeValidatorImpl>; friend class FormattersContainer<lldb::RegularExpressionSP, diff --git a/include/lldb/DataFormatters/TypeCategoryMap.h b/include/lldb/DataFormatters/TypeCategoryMap.h index 0ff078edf51b1..753b58cb465ea 100644 --- a/include/lldb/DataFormatters/TypeCategoryMap.h +++ b/include/lldb/DataFormatters/TypeCategoryMap.h @@ -1,9 +1,8 @@ //===-- TypeCategoryMap.h ---------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -82,10 +81,8 @@ public: lldb::TypeSummaryImplSP GetSummaryFormat(FormattersMatchData &match_data); -#ifndef LLDB_DISABLE_PYTHON lldb::SyntheticChildrenSP GetSyntheticChildren(FormattersMatchData &match_data); -#endif lldb::TypeValidatorImplSP GetValidator(FormattersMatchData &match_data); diff --git a/include/lldb/DataFormatters/TypeFormat.h b/include/lldb/DataFormatters/TypeFormat.h index 57ef0cf942cb6..77e8c0efc7069 100644 --- a/include/lldb/DataFormatters/TypeFormat.h +++ b/include/lldb/DataFormatters/TypeFormat.h @@ -1,10 +1,9 @@ //===-- TypeFormat.h ----------------------------------------------*- C++ //-*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// diff --git a/include/lldb/DataFormatters/TypeSummary.h b/include/lldb/DataFormatters/TypeSummary.h index 78947728be293..9c97b3606f25b 100644 --- a/include/lldb/DataFormatters/TypeSummary.h +++ b/include/lldb/DataFormatters/TypeSummary.h @@ -1,9 +1,8 @@ //===-- TypeSummary.h -------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -27,12 +26,9 @@ namespace lldb_private { class TypeSummaryOptions { public: TypeSummaryOptions(); - TypeSummaryOptions(const TypeSummaryOptions &rhs); ~TypeSummaryOptions() = default; - TypeSummaryOptions &operator=(const TypeSummaryOptions &rhs); - lldb::LanguageType GetLanguage() const; lldb::TypeSummaryCapping GetCapping() const; diff --git a/include/lldb/DataFormatters/TypeSynthetic.h b/include/lldb/DataFormatters/TypeSynthetic.h index a9025fdb53977..93443cf7e84b7 100644 --- a/include/lldb/DataFormatters/TypeSynthetic.h +++ b/include/lldb/DataFormatters/TypeSynthetic.h @@ -1,9 +1,8 @@ //===-- TypeSynthetic.h -----------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -48,7 +47,7 @@ public: virtual lldb::ValueObjectSP GetChildAtIndex(size_t idx) = 0; - virtual size_t GetIndexOfChildWithName(const ConstString &name) = 0; + virtual size_t GetIndexOfChildWithName(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 @@ -111,7 +110,7 @@ public: lldb::ValueObjectSP GetChildAtIndex(size_t idx) override { return nullptr; } - size_t GetIndexOfChildWithName(const ConstString &name) override { + size_t GetIndexOfChildWithName(ConstString name) override { return UINT32_MAX; } @@ -327,7 +326,7 @@ public: bool MightHaveChildren() override { return filter->GetCount() > 0; } - size_t GetIndexOfChildWithName(const ConstString &name) override; + size_t GetIndexOfChildWithName(ConstString name) override; typedef std::shared_ptr<SyntheticChildrenFrontEnd> SharedPointer; @@ -376,8 +375,6 @@ private: DISALLOW_COPY_AND_ASSIGN(CXXSyntheticChildren); }; -#ifndef LLDB_DISABLE_PYTHON - class ScriptedSyntheticChildren : public SyntheticChildren { std::string m_python_class; std::string m_python_code; @@ -425,7 +422,7 @@ public: bool MightHaveChildren() override; - size_t GetIndexOfChildWithName(const ConstString &name) override; + size_t GetIndexOfChildWithName(ConstString name) override; lldb::ValueObjectSP GetSyntheticValue() override; @@ -453,7 +450,6 @@ public: private: DISALLOW_COPY_AND_ASSIGN(ScriptedSyntheticChildren); }; -#endif } // namespace lldb_private #endif // lldb_TypeSynthetic_h_ diff --git a/include/lldb/DataFormatters/TypeValidator.h b/include/lldb/DataFormatters/TypeValidator.h index a50949cf22fe0..531812eeb0568 100644 --- a/include/lldb/DataFormatters/TypeValidator.h +++ b/include/lldb/DataFormatters/TypeValidator.h @@ -1,10 +1,9 @@ //===-- TypeValidator.h ------------------------------------------*- C++ //-*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// diff --git a/include/lldb/DataFormatters/ValueObjectPrinter.h b/include/lldb/DataFormatters/ValueObjectPrinter.h index 13124c9210c8f..41adc2d2b5b22 100644 --- a/include/lldb/DataFormatters/ValueObjectPrinter.h +++ b/include/lldb/DataFormatters/ValueObjectPrinter.h @@ -1,10 +1,9 @@ //===-- ValueObjectPrinter.h ---------------------------------------*- C++ //-*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// diff --git a/include/lldb/DataFormatters/VectorIterator.h b/include/lldb/DataFormatters/VectorIterator.h index f695d22905024..cde4be498b0f4 100644 --- a/include/lldb/DataFormatters/VectorIterator.h +++ b/include/lldb/DataFormatters/VectorIterator.h @@ -1,10 +1,9 @@ //===-- VectorIterator.h ----------------------------------------------*- C++ //-*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -32,7 +31,7 @@ public: bool MightHaveChildren() override; - size_t GetIndexOfChildWithName(const ConstString &name) override; + size_t GetIndexOfChildWithName(ConstString name) override; private: ExecutionContextRef m_exe_ctx_ref; diff --git a/include/lldb/DataFormatters/VectorType.h b/include/lldb/DataFormatters/VectorType.h index 4ca0c4519f9f3..b757f758e77fe 100644 --- a/include/lldb/DataFormatters/VectorType.h +++ b/include/lldb/DataFormatters/VectorType.h @@ -1,9 +1,8 @@ //===-- VectorType.h ------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// diff --git a/include/lldb/Expression/DWARFExpression.h b/include/lldb/Expression/DWARFExpression.h index cdede56d86d9d..21830a5628004 100644 --- a/include/lldb/Expression/DWARFExpression.h +++ b/include/lldb/Expression/DWARFExpression.h @@ -1,9 +1,8 @@ //===-- DWARFExpression.h ---------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -22,8 +21,7 @@ class DWARFUnit; namespace lldb_private { -//---------------------------------------------------------------------- -/// @class DWARFExpression DWARFExpression.h +/// \class DWARFExpression DWARFExpression.h /// "lldb/Expression/DWARFExpression.h" Encapsulates a DWARF location /// expression and interprets it. /// @@ -34,7 +32,6 @@ namespace lldb_private { /// 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: enum LocationListFormat : uint8_t { @@ -46,84 +43,64 @@ public: // (.debug_loclists/.debug_loclists.dwo). }; - //------------------------------------------------------------------ - /// Constructor - //------------------------------------------------------------------ - explicit DWARFExpression(DWARFUnit *dwarf_cu); + DWARFExpression(); - //------------------------------------------------------------------ /// Constructor /// - /// @param[in] data + /// \param[in] data /// A data extractor configured to read the DWARF location expression's /// bytecode. /// - /// @param[in] data_offset + /// \param[in] data_offset /// The offset of the location expression in the extractor. /// - /// @param[in] data_length + /// \param[in] data_length /// The byte length of the location expression. - //------------------------------------------------------------------ DWARFExpression(lldb::ModuleSP module, const DataExtractor &data, - DWARFUnit *dwarf_cu, lldb::offset_t data_offset, + const DWARFUnit *dwarf_cu, lldb::offset_t data_offset, lldb::offset_t data_length); - //------------------------------------------------------------------ - /// Copy constructor - //------------------------------------------------------------------ - DWARFExpression(const DWARFExpression &rhs); - - //------------------------------------------------------------------ /// Destructor - //------------------------------------------------------------------ virtual ~DWARFExpression(); - //------------------------------------------------------------------ /// Print the description of the expression to a stream /// - /// @param[in] s + /// \param[in] s /// The stream to print to. /// - /// @param[in] level + /// \param[in] level /// The level of verbosity to use. /// - /// @param[in] location_list_base_addr + /// \param[in] location_list_base_addr /// If this is a location list based expression, this is the /// address of the object that owns it. NOTE: this value is /// different from the DWARF version of the location list base /// address which is compile unit relative. This base address /// is the address of the object that owns the location list. /// - /// @param[in] abi + /// \param[in] abi /// An optional ABI plug-in that can be used to resolve register /// names. - //------------------------------------------------------------------ void GetDescription(Stream *s, lldb::DescriptionLevel level, lldb::addr_t location_list_base_addr, ABI *abi) const; - //------------------------------------------------------------------ /// Return true if the location expression contains data - //------------------------------------------------------------------ bool IsValid() const; - //------------------------------------------------------------------ /// Return true if a location list was provided - //------------------------------------------------------------------ bool IsLocationList() const; - //------------------------------------------------------------------ /// Search for a load address in the location list /// - /// @param[in] process + /// \param[in] process /// The process to use when resolving the load address /// - /// @param[in] addr + /// \param[in] addr /// The address to resolve /// - /// @return + /// \return /// True if IsLocationList() is true and the address was found; /// false otherwise. - //------------------------------------------------------------------ // bool // LocationListContainsLoadAddress (Process* process, const Address &addr) // const; @@ -131,7 +108,6 @@ public: bool LocationListContainsAddress(lldb::addr_t loclist_base_addr, lldb::addr_t addr) const; - //------------------------------------------------------------------ /// 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 @@ -140,22 +116,24 @@ public: /// static variable since there is no other indication from DWARF debug /// info. /// - /// @param[in] op_addr_idx + /// \param[in] op_addr_idx /// The DW_OP_addr index to retrieve in case there is more than /// one DW_OP_addr opcode in the location byte stream. /// - /// @param[out] error + /// \param[out] error /// If the location stream contains unknown DW_OP opcodes or the /// data is missing, \a error will be set to \b true. /// - /// @return + /// \return /// LLDB_INVALID_ADDRESS if the location doesn't contain a /// DW_OP_addr for \a op_addr_idx, otherwise a valid file address - //------------------------------------------------------------------ lldb::addr_t GetLocation_DW_OP_addr(uint32_t op_addr_idx, bool &error) const; bool Update_DW_OP_addr(lldb::addr_t file_addr); + void UpdateValue(uint64_t const_value, lldb::offset_t const_value_byte_size, + uint8_t addr_byte_size); + void SetModule(const lldb::ModuleSP &module) { m_module_wp = module; } bool ContainsThreadLocalStorage() const; @@ -165,178 +143,100 @@ public: std::function<lldb::addr_t(lldb::addr_t file_addr)> const &link_address_callback); - //------------------------------------------------------------------ - /// 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 - /// bytecode. - //------------------------------------------------------------------ - void SetOpcodeData(const DataExtractor &data); - - //------------------------------------------------------------------ - /// Make the expression parser read its location information from a given - /// data source - /// - /// @param[in] module_sp - /// The module that defines the DWARF expression. - /// - /// @param[in] data - /// A data extractor configured to read the DWARF location expression's - /// bytecode. - /// - /// @param[in] data_offset - /// The offset of the location expression in the extractor. - /// - /// @param[in] data_length - /// The byte length of the location expression. - //------------------------------------------------------------------ - void SetOpcodeData(lldb::ModuleSP module_sp, const DataExtractor &data, - lldb::offset_t data_offset, lldb::offset_t data_length); - - //------------------------------------------------------------------ - /// Copy the DWARF location expression into a local buffer. - /// - /// 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. - /// - /// @param[in] data - /// A data extractor configured to read and copy the DWARF - /// location expression's bytecode. - /// - /// @param[in] data_offset - /// The offset of the location expression in the extractor. - /// - /// @param[in] data_length - /// The byte length of the location expression. - //------------------------------------------------------------------ - void CopyOpcodeData(lldb::ModuleSP module_sp, const DataExtractor &data, - lldb::offset_t data_offset, lldb::offset_t data_length); - - void CopyOpcodeData(const void *data, lldb::offset_t data_length, - lldb::ByteOrder byte_order, uint8_t addr_byte_size); - - void CopyOpcodeData(uint64_t const_value, - lldb::offset_t const_value_byte_size, - uint8_t addr_byte_size); - - //------------------------------------------------------------------ /// Tells the expression that it refers to a location list. /// - /// @param[in] slide + /// \param[in] slide /// This value should be a slide that is applied to any values /// in the location list data so the values become zero based /// offsets into the object that owns the location list. We need /// to make location lists relative to the objects that own them /// so we can relink addresses on the fly. - //------------------------------------------------------------------ void SetLocationListSlide(lldb::addr_t slide); - //------------------------------------------------------------------ /// Return the call-frame-info style register kind - //------------------------------------------------------------------ int GetRegisterKind(); - //------------------------------------------------------------------ /// Set the call-frame-info style register kind /// - /// @param[in] reg_kind + /// \param[in] reg_kind /// The register kind. - //------------------------------------------------------------------ void SetRegisterKind(lldb::RegisterKind reg_kind); - //------------------------------------------------------------------ /// Wrapper for the static evaluate function that accepts an /// 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, const Value *initial_value_ptr, const Value *object_address_ptr, Value &result, Status *error_ptr) const; - //------------------------------------------------------------------ /// 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, const Value *initial_value_ptr, const Value *object_address_ptr, Value &result, Status *error_ptr) const; - //------------------------------------------------------------------ /// Evaluate a DWARF location expression in a particular context /// - /// @param[in] exe_ctx + /// \param[in] exe_ctx /// The execution context in which to evaluate the location /// expression. The location expression may access the target's /// memory, especially if it comes from the expression parser. /// - /// @param[in] opcode_ctx + /// \param[in] opcode_ctx /// The module which defined the expression. /// - /// @param[in] opcodes + /// \param[in] opcodes /// This is a static method so the opcodes need to be provided /// explicitly. /// - /// @param[in] expr_locals + /// \param[in] expr_locals /// If the location expression was produced by the expression parser, /// the list of local variables referenced by the DWARF expression. /// This list should already have been populated during parsing; /// the DWARF expression refers to variables by index. Can be NULL if /// the location expression uses no locals. /// - /// @param[in] decl_map + /// \param[in] decl_map /// If the location expression was produced by the expression parser, /// the list of external variables referenced by the location /// expression. Can be NULL if the location expression uses no /// external variables. /// - /// @param[in] reg_ctx + /// \param[in] reg_ctx /// An optional parameter which provides a RegisterContext for use /// when evaluating the expression (i.e. for fetching register values). /// Normally this will come from the ExecutionContext's StackFrame but /// in the case where an expression needs to be evaluated while building /// the stack frame list, this short-cut is available. /// - /// @param[in] offset + /// \param[in] offset /// The offset of the location expression in the data extractor. /// - /// @param[in] length + /// \param[in] length /// The length in bytes of the location expression. /// - /// @param[in] reg_set + /// \param[in] reg_set /// The call-frame-info style register kind. /// - /// @param[in] initial_value_ptr + /// \param[in] initial_value_ptr /// A value to put on top of the interpreter stack before evaluating /// the expression, if the expression is parametrized. Can be NULL. /// - /// @param[in] result + /// \param[in] result /// A value into which the result of evaluating the expression is /// to be placed. /// - /// @param[in] error_ptr + /// \param[in] error_ptr /// If non-NULL, used to report errors in expression evaluation. /// - /// @return + /// \return /// True on success; false otherwise. If error_ptr is non-NULL, /// details of the failure are provided through it. - //------------------------------------------------------------------ static bool Evaluate(ExecutionContext *exe_ctx, RegisterContext *reg_ctx, lldb::ModuleSP opcode_ctx, const DataExtractor &opcodes, - DWARFUnit *dwarf_cu, const lldb::offset_t offset, + const DWARFUnit *dwarf_cu, const lldb::offset_t offset, const lldb::offset_t length, const lldb::RegisterKind reg_set, const Value *initial_value_ptr, @@ -366,26 +266,24 @@ public: bool MatchesOperand(StackFrame &frame, const Instruction::Operand &op); -protected: - //------------------------------------------------------------------ +private: /// Pretty-prints the location expression to a stream /// - /// @param[in] stream + /// \param[in] stream /// The stream to use for pretty-printing. /// - /// @param[in] offset + /// \param[in] offset /// The offset into the data buffer of the opcodes to be printed. /// - /// @param[in] length + /// \param[in] length /// The length in bytes of the opcodes to be printed. /// - /// @param[in] level + /// \param[in] level /// The level of detail to use in pretty-printing. /// - /// @param[in] abi + /// \param[in] abi /// An optional ABI plug-in that can be used to resolve register /// names. - //------------------------------------------------------------------ void DumpLocation(Stream *s, lldb::offset_t offset, lldb::offset_t length, lldb::DescriptionLevel level, ABI *abi) const; @@ -399,22 +297,24 @@ protected: bool GetOpAndEndOffsets(StackFrame &frame, lldb::offset_t &op_offset, lldb::offset_t &end_offset); - //------------------------------------------------------------------ - /// Classes that inherit from DWARFExpression can see and modify these - //------------------------------------------------------------------ - - lldb::ModuleWP m_module_wp; ///< Module which defined this expression. - DataExtractor m_data; ///< A data extractor capable of reading opcode bytes - 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) - lldb::RegisterKind - m_reg_kind; ///< One of the defines that starts with LLDB_REGKIND_ - lldb::addr_t m_loclist_slide; ///< A value used to slide the location list - ///offsets so that - ///< they are relative to the object that owns the location list - ///< (the function for frame base and variable location lists) + /// Module which defined this expression. + lldb::ModuleWP m_module_wp; + + /// A data extractor capable of reading opcode bytes + DataExtractor m_data; + + /// 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) + const DWARFUnit *m_dwarf_cu; + + /// One of the defines that starts with LLDB_REGKIND_ + lldb::RegisterKind m_reg_kind; + + /// A value used to slide the location list offsets so that m_c they are + /// relative to the object that owns the location list (the function for + /// frame base and variable location lists) + lldb::addr_t m_loclist_slide; }; } // namespace lldb_private diff --git a/include/lldb/Expression/DiagnosticManager.h b/include/lldb/Expression/DiagnosticManager.h index 83e67df2649ab..7e3e2bb8606a1 100644 --- a/include/lldb/Expression/DiagnosticManager.h +++ b/include/lldb/Expression/DiagnosticManager.h @@ -1,9 +1,8 @@ //===-- DiagnosticManager.h -------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// diff --git a/include/lldb/Expression/DynamicCheckerFunctions.h b/include/lldb/Expression/DynamicCheckerFunctions.h new file mode 100644 index 0000000000000..7be24b6ea962b --- /dev/null +++ b/include/lldb/Expression/DynamicCheckerFunctions.h @@ -0,0 +1,62 @@ +//===-- DynamicCheckerFunctions.h -------------------------------*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef liblldb_DynamicCheckerFunctions_h_ +#define liblldb_DynamicCheckerFunctions_h_ + +#include "lldb/lldb-types.h" + +namespace lldb_private { + +class DiagnosticManager; +class ExecutionContext; + +/// 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: +/// +/// 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. +class DynamicCheckerFunctions { +public: + enum DynamicCheckerFunctionsKind { + DCF_Clang, + }; + + DynamicCheckerFunctions(DynamicCheckerFunctionsKind kind) : m_kind(kind) {} + virtual ~DynamicCheckerFunctions() = default; + + /// 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. + /// + /// \param[in] exe_ctx + /// The execution context to install the functions into. + /// + /// \return + /// True on success; false on failure, or if the functions have + /// already been installed. + virtual bool Install(DiagnosticManager &diagnostic_manager, + ExecutionContext &exe_ctx) = 0; + virtual bool DoCheckersExplainStop(lldb::addr_t addr, Stream &message) = 0; + + DynamicCheckerFunctionsKind GetKind() const { return m_kind; } + +private: + const DynamicCheckerFunctionsKind m_kind; +}; +} // namespace lldb_private + +#endif // liblldb_DynamicCheckerFunctions_h_ diff --git a/include/lldb/Expression/Expression.h b/include/lldb/Expression/Expression.h index 162dcd3e4672e..2f0183cf269b7 100644 --- a/include/lldb/Expression/Expression.h +++ b/include/lldb/Expression/Expression.h @@ -1,9 +1,8 @@ //===-- Expression.h --------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -23,8 +22,7 @@ namespace lldb_private { class RecordingMemoryManager; -//---------------------------------------------------------------------- -/// @class Expression Expression.h "lldb/Expression/Expression.h" Encapsulates +/// \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 @@ -32,78 +30,72 @@ class RecordingMemoryManager; /// 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: + /// Discriminator for LLVM-style RTTI (dyn_cast<> et al.) + enum ExpressionKind { + eKindFunctionCaller, + eKindClangFunctionCaller, + eKindUserExpression, + eKindLLVMUserExpression, + eKindClangUserExpression, + eKindUtilityFunction, + eKindClangUtilityFunction, + }; + enum ResultType { eResultTypeAny, eResultTypeId }; - Expression(Target &target); + Expression(Target &target, ExpressionKind kind); - Expression(ExecutionContextScope &exe_scope); + Expression(ExecutionContextScope &exe_scope, ExpressionKind kind); - //------------------------------------------------------------------ /// Destructor - //------------------------------------------------------------------ virtual ~Expression() {} - //------------------------------------------------------------------ /// Return the string that the parser should parse. Must be a full /// translation unit. - //------------------------------------------------------------------ virtual const char *Text() = 0; - //------------------------------------------------------------------ /// Return the function name that should be used for executing the /// 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. - //------------------------------------------------------------------ virtual lldb::LanguageType Language() { return lldb::eLanguageTypeUnknown; } - //------------------------------------------------------------------ /// Return the desired result type of the function, or eResultTypeAny if /// indifferent. - //------------------------------------------------------------------ virtual ResultType DesiredResultType() { return eResultTypeAny; } - //------------------------------------------------------------------ /// Flags - //------------------------------------------------------------------ - //------------------------------------------------------------------ /// 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. - //------------------------------------------------------------------ virtual bool NeedsVariableResolution() = 0; virtual EvaluateExpressionOptions *GetOptions() { return nullptr; }; - //------------------------------------------------------------------ /// Return the address of the function's JIT-compiled code, or /// LLDB_INVALID_ADDRESS if the function is not JIT compiled - //------------------------------------------------------------------ lldb::addr_t StartAddress() { return m_jit_start_addr; } - //------------------------------------------------------------------ /// Called to notify the expression that it is about to be executed. - //------------------------------------------------------------------ virtual void WillStartExecuting() {} - //------------------------------------------------------------------ /// Called to notify the expression that its execution has finished. - //------------------------------------------------------------------ virtual void DidFinishExecuting() {} virtual ExpressionTypeSystemHelper *GetTypeSystemHelper() { return nullptr; } + /// LLVM-style RTTI support. + ExpressionKind getKind() const { return m_kind; } + +private: + /// LLVM-style RTTI support. + const ExpressionKind m_kind; protected: lldb::TargetWP m_target_wp; /// Expression's always have to have a target... lldb::ProcessWP m_jit_process_wp; /// An expression might have a process, but diff --git a/include/lldb/Expression/ExpressionParser.h b/include/lldb/Expression/ExpressionParser.h index 7d337bd00ca63..59f7c1592e83d 100644 --- a/include/lldb/Expression/ExpressionParser.h +++ b/include/lldb/Expression/ExpressionParser.h @@ -1,9 +1,8 @@ //===-- ExpressionParser.h --------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -19,58 +18,51 @@ namespace lldb_private { class IRExecutionUnit; -//---------------------------------------------------------------------- -/// @class ExpressionParser ExpressionParser.h +/// \class ExpressionParser ExpressionParser.h /// "lldb/Expression/ExpressionParser.h" Encapsulates an instance of a /// compiler that can parse expressions. /// /// ExpressionParser is the base class for llvm based Expression parsers. -//---------------------------------------------------------------------- class ExpressionParser { public: - //------------------------------------------------------------------ /// Constructor /// /// Initializes class variables. /// - /// @param[in] exe_scope, + /// \param[in] exe_scope, /// If non-NULL, an execution context scope that can help to /// correctly create an expression with a valid process for /// optional tuning Objective-C runtime support. Can be NULL. /// - /// @param[in] expr + /// \param[in] expr /// The expression to be parsed. - //------------------------------------------------------------------ ExpressionParser(ExecutionContextScope *exe_scope, Expression &expr, bool generate_debug_info) : m_expr(expr), m_generate_debug_info(generate_debug_info) {} - //------------------------------------------------------------------ /// Destructor - //------------------------------------------------------------------ virtual ~ExpressionParser(){}; - //------------------------------------------------------------------ /// Attempts to find possible command line completions for the given /// expression. /// - /// @param[out] request + /// \param[out] request /// The completion request to fill out. The completion should be a string /// that would complete the current token at the cursor position. /// Note that the string in the list replaces the current token /// in the command line. /// - /// @param[in] line + /// \param[in] line /// The line with the completion cursor inside the expression as a string. /// The first line in the expression has the number 0. /// - /// @param[in] pos + /// \param[in] pos /// The character position in the line with the completion cursor. /// If the value is 0, then the cursor is on top of the first character /// in the line (i.e. the user has requested completion from the start of /// the expression). /// - /// @param[in] typed_pos + /// \param[in] typed_pos /// The cursor position in the line as typed by the user. If the user /// expression has not been transformed in some form (e.g. wrapping it /// in a function body for C languages), then this is equal to the @@ -78,73 +70,66 @@ public: /// 'pos' (e.g. a value of 0 means the cursor is at start of the /// expression). /// - /// @return + /// \return /// True if we added any completion results to the output; /// false otherwise. - //------------------------------------------------------------------ virtual bool Complete(CompletionRequest &request, unsigned line, unsigned pos, unsigned typed_pos) = 0; - //------------------------------------------------------------------ /// Parse a single expression and convert it to IR using Clang. Don't wrap /// the expression in anything at all. /// - /// @param[in] diagnostic_manager + /// \param[in] diagnostic_manager /// The diagnostic manager in which to store the errors and warnings. /// - /// @return + /// \return /// The number of errors encountered during parsing. 0 means /// success. - //------------------------------------------------------------------ virtual unsigned Parse(DiagnosticManager &diagnostic_manager) = 0; - //------------------------------------------------------------------ /// 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. /// - /// @param[in] diagnostic_manager + /// \param[in] diagnostic_manager /// The diagnostic manager containing fixit's to apply. /// - /// @return + /// \return /// \b true if the rewrite was successful, \b false otherwise. - //------------------------------------------------------------------ virtual bool RewriteExpression(DiagnosticManager &diagnostic_manager) { return false; } - //------------------------------------------------------------------ /// Ready an already-parsed expression for execution, possibly evaluating it /// statically. /// - /// @param[out] func_addr + /// \param[out] func_addr /// The address to which the function has been written. /// - /// @param[out] func_end + /// \param[out] func_end /// The end of the function's allocated memory region. (func_addr /// and func_end do not delimit an allocated region; the allocated /// region may begin before func_addr.) /// - /// @param[in] execution_unit_sp + /// \param[in] execution_unit_sp /// After parsing, ownership of the execution unit for /// for the expression is handed to this shared pointer. /// - /// @param[in] exe_ctx + /// \param[in] exe_ctx /// The execution context to write the function into. /// - /// @param[out] can_interpret + /// \param[out] can_interpret /// Set to true if the expression could be interpreted statically; /// untouched otherwise. /// - /// @param[in] execution_policy + /// \param[in] execution_policy /// Determines whether the expression must be JIT-compiled, must be /// evaluated statically, or whether this decision may be made /// opportunistically. /// - /// @return + /// \return /// An error code indicating the success or failure of the operation. /// Test with Success(). - //------------------------------------------------------------------ virtual Status PrepareForExecution(lldb::addr_t &func_addr, lldb::addr_t &func_end, std::shared_ptr<IRExecutionUnit> &execution_unit_sp, diff --git a/include/lldb/Expression/ExpressionSourceCode.h b/include/lldb/Expression/ExpressionSourceCode.h index b5a6187bf3c5f..d0d01b5f9b596 100644 --- a/include/lldb/Expression/ExpressionSourceCode.h +++ b/include/lldb/Expression/ExpressionSourceCode.h @@ -1,9 +1,8 @@ //===-- ExpressionSourceCode.h ----------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -11,42 +10,19 @@ #define liblldb_ExpressionSourceCode_h #include "lldb/lldb-enumerations.h" +#include "llvm/ADT/ArrayRef.h" #include <string> namespace lldb_private { -class ExecutionContext; - class ExpressionSourceCode { public: - static const char *g_expression_prefix; - - static ExpressionSourceCode *CreateWrapped(const char *prefix, - const char *body) { - return new ExpressionSourceCode("$__lldb_expr", prefix, body, true); - } - - static ExpressionSourceCode *CreateUnwrapped(const char *name, - const char *body) { - return new ExpressionSourceCode(name, "", body, false); - } - bool NeedsWrapping() const { return m_wrap; } const char *GetName() const { return m_name.c_str(); } - bool GetText(std::string &text, lldb::LanguageType wrapping_language, - 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. - static bool GetOriginalBodyBounds(std::string transformed_text, - lldb::LanguageType wrapping_language, - size_t &start_loc, size_t &end_loc); - -private: +protected: ExpressionSourceCode(const char *name, const char *prefix, const char *body, bool wrap) : m_name(name), m_prefix(prefix), m_body(body), m_wrap(wrap) {} diff --git a/include/lldb/Expression/ExpressionTypeSystemHelper.h b/include/lldb/Expression/ExpressionTypeSystemHelper.h index ffcad54fb9f9b..9c645532cdc19 100644 --- a/include/lldb/Expression/ExpressionTypeSystemHelper.h +++ b/include/lldb/Expression/ExpressionTypeSystemHelper.h @@ -1,10 +1,9 @@ //===-- ExpressionTypeSystemHelper.h ---------------------------------*- C++ //-*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -15,8 +14,7 @@ namespace lldb_private { -//---------------------------------------------------------------------- -/// @class ExpressionTypeSystemHelper ExpressionTypeSystemHelper.h +/// \class ExpressionTypeSystemHelper ExpressionTypeSystemHelper.h /// "lldb/Expression/ExpressionTypeSystemHelper.h" /// A helper object that the Expression can pass to its ExpressionParser /// to provide generic information that @@ -24,7 +22,6 @@ namespace lldb_private { /// dyn_cast so that the expression parser can cast it back to the requisite /// specific type. /// -//---------------------------------------------------------------------- class ExpressionTypeSystemHelper { public: diff --git a/include/lldb/Expression/ExpressionVariable.h b/include/lldb/Expression/ExpressionVariable.h index 01e9c416e7c01..08c987270bfe7 100644 --- a/include/lldb/Expression/ExpressionVariable.h +++ b/include/lldb/Expression/ExpressionVariable.h @@ -1,9 +1,8 @@ //===-- ExpressionVariable.h ------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -21,14 +20,10 @@ namespace lldb_private { -class ClangExpressionVariable; - class ExpressionVariable : public std::enable_shared_from_this<ExpressionVariable> { public: - //---------------------------------------------------------------------- // See TypeSystem.h for how to add subclasses to this. - //---------------------------------------------------------------------- enum LLVMCastKind { eKindClang, eKindSwift, eKindGo, kNumKinds }; LLVMCastKind getKind() const { return m_kind; } @@ -39,7 +34,7 @@ public: size_t GetByteSize() { return m_frozen_sp->GetByteSize(); } - const ConstString &GetName() { return m_frozen_sp->GetName(); } + ConstString GetName() { return m_frozen_sp->GetName(); } lldb::ValueObjectSP GetValueObject() { return m_frozen_sp; } @@ -62,7 +57,7 @@ public: m_frozen_sp->GetValue().SetCompilerType(compiler_type); } - void SetName(const ConstString &name) { m_frozen_sp->SetName(name); } + void SetName(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- @@ -119,18 +114,14 @@ public: LLVMCastKind m_kind; }; -//---------------------------------------------------------------------- -/// @class ExpressionVariableList ExpressionVariable.h +/// \class ExpressionVariableList ExpressionVariable.h /// "lldb/Expression/ExpressionVariable.h" /// A list of variable references. /// /// This class stores variables internally, acting as the permanent store. -//---------------------------------------------------------------------- class ExpressionVariableList { public: - //---------------------------------------------------------------------- /// Implementation of methods in ExpressionVariableListBase - //---------------------------------------------------------------------- size_t GetSize() { return m_variables.size(); } lldb::ExpressionVariableSP GetVariableAtIndex(size_t index) { @@ -161,17 +152,15 @@ public: return false; } - //---------------------------------------------------------------------- /// Finds a variable by name in the list. /// - /// @param[in] name + /// \param[in] name /// The name of the requested variable. /// - /// @return + /// \return /// The variable requested, or nullptr if that variable is not in the /// list. - //---------------------------------------------------------------------- - lldb::ExpressionVariableSP GetVariable(const ConstString &name) { + lldb::ExpressionVariableSP GetVariable(ConstString name) { lldb::ExpressionVariableSP var_sp; for (size_t index = 0, size = GetSize(); index < size; ++index) { var_sp = GetVariableAtIndex(index); @@ -215,9 +204,7 @@ private: class PersistentExpressionState : public ExpressionVariableList { public: - //---------------------------------------------------------------------- // See TypeSystem.h for how to add subclasses to this. - //---------------------------------------------------------------------- enum LLVMCastKind { eKindClang, eKindSwift, eKindGo, kNumKinds }; LLVMCastKind getKind() const { return m_kind; } @@ -231,7 +218,7 @@ public: virtual lldb::ExpressionVariableSP CreatePersistentVariable(ExecutionContextScope *exe_scope, - const ConstString &name, const CompilerType &type, + ConstString name, const CompilerType &type, lldb::ByteOrder byte_order, uint32_t addr_byte_size) = 0; @@ -245,7 +232,10 @@ public: virtual void RemovePersistentVariable(lldb::ExpressionVariableSP variable) = 0; - virtual lldb::addr_t LookupSymbol(const ConstString &name); + virtual llvm::Optional<CompilerType> + GetCompilerTypeFromPersistentDecl(ConstString type_name) = 0; + + virtual lldb::addr_t LookupSymbol(ConstString name); void RegisterExecutionUnit(lldb::IRExecutionUnitSP &execution_unit_sp); diff --git a/include/lldb/Expression/FunctionCaller.h b/include/lldb/Expression/FunctionCaller.h index 0ec7e202dac9b..ea9d0205bf867 100644 --- a/include/lldb/Expression/FunctionCaller.h +++ b/include/lldb/Expression/FunctionCaller.h @@ -1,9 +1,8 @@ //===-- FunctionCaller.h ----------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -23,8 +22,7 @@ namespace lldb_private { -//---------------------------------------------------------------------- -/// @class FunctionCaller FunctionCaller.h "lldb/Expression/FunctionCaller.h" +/// \class FunctionCaller FunctionCaller.h "lldb/Expression/FunctionCaller.h" /// Encapsulates a function that can be called. /// /// A given FunctionCaller object can handle a single function signature. @@ -55,152 +53,141 @@ namespace lldb_private { /// /// Any of the methods that take arg_addr_ptr can be passed nullptr, and the /// argument space will be managed for you. -//---------------------------------------------------------------------- class FunctionCaller : public Expression { public: - //------------------------------------------------------------------ + /// LLVM-style RTTI support. + static bool classof(const Expression *E) { + return E->getKind() == eKindFunctionCaller; + } + /// Constructor /// - /// @param[in] exe_scope + /// \param[in] exe_scope /// An execution context scope that gets us at least a target and /// process. /// - /// @param[in] ast_context + /// \param[in] ast_context /// The AST context to evaluate argument types in. /// - /// @param[in] return_qualtype + /// \param[in] return_qualtype /// An opaque Clang QualType for the function result. Should be /// defined in ast_context. /// - /// @param[in] function_address + /// \param[in] function_address /// The address of the function to call. /// - /// @param[in] arg_value_list + /// \param[in] arg_value_list /// The default values to use when calling this function. Can /// be overridden using WriteFunctionArguments(). - //------------------------------------------------------------------ FunctionCaller(ExecutionContextScope &exe_scope, const CompilerType &return_type, const Address &function_address, const ValueList &arg_value_list, const char *name); - //------------------------------------------------------------------ /// Destructor - //------------------------------------------------------------------ ~FunctionCaller() override; - //------------------------------------------------------------------ /// Compile the wrapper function /// - /// @param[in] thread_to_use_sp + /// \param[in] thread_to_use_sp /// Compilation might end up calling functions. Pass in the thread you /// want the compilation to use. If you pass in an empty ThreadSP it will /// use the currently selected thread. /// - /// @param[in] diagnostic_manager + /// \param[in] diagnostic_manager /// The diagnostic manager to report parser errors to. /// - /// @return + /// \return /// The number of errors. - //------------------------------------------------------------------ virtual unsigned CompileFunction(lldb::ThreadSP thread_to_use_sp, DiagnosticManager &diagnostic_manager) = 0; - //------------------------------------------------------------------ /// Insert the default function wrapper and its default argument struct /// - /// @param[in] exe_ctx + /// \param[in] exe_ctx /// The execution context to insert the function and its arguments /// into. /// - /// @param[in,out] args_addr_ref + /// \param[in,out] args_addr_ref /// The address of the structure to write the arguments into. May /// be LLDB_INVALID_ADDRESS; if it is, a new structure is allocated /// and args_addr_ref is pointed to it. /// - /// @param[in] diagnostic_manager + /// \param[in] diagnostic_manager /// The diagnostic manager to report errors to. /// - /// @return + /// \return /// True on success; false otherwise. - //------------------------------------------------------------------ bool InsertFunction(ExecutionContext &exe_ctx, lldb::addr_t &args_addr_ref, DiagnosticManager &diagnostic_manager); - //------------------------------------------------------------------ /// Insert the default function wrapper (using the JIT) /// - /// @param[in] exe_ctx + /// \param[in] exe_ctx /// The execution context to insert the function and its arguments /// into. /// - /// @param[in] diagnostic_manager + /// \param[in] diagnostic_manager /// The diagnostic manager to report errors to. /// - /// @return + /// \return /// True on success; false otherwise. - //------------------------------------------------------------------ bool WriteFunctionWrapper(ExecutionContext &exe_ctx, DiagnosticManager &diagnostic_manager); - //------------------------------------------------------------------ /// Insert the default function argument struct /// - /// @param[in] exe_ctx + /// \param[in] exe_ctx /// The execution context to insert the function and its arguments /// into. /// - /// @param[in,out] args_addr_ref + /// \param[in,out] args_addr_ref /// The address of the structure to write the arguments into. May /// be LLDB_INVALID_ADDRESS; if it is, a new structure is allocated /// and args_addr_ref is pointed to it. /// - /// @param[in] diagnostic_manager + /// \param[in] diagnostic_manager /// The diagnostic manager to report errors to. /// - /// @return + /// \return /// True on success; false otherwise. - //------------------------------------------------------------------ bool WriteFunctionArguments(ExecutionContext &exe_ctx, lldb::addr_t &args_addr_ref, DiagnosticManager &diagnostic_manager); - //------------------------------------------------------------------ /// Insert an argument struct with a non-default function address and non- /// default argument values /// - /// @param[in] exe_ctx + /// \param[in] exe_ctx /// The execution context to insert the function and its arguments /// into. /// - /// @param[in,out] args_addr_ref + /// \param[in,out] args_addr_ref /// The address of the structure to write the arguments into. May /// be LLDB_INVALID_ADDRESS; if it is, a new structure is allocated /// and args_addr_ref is pointed at it. /// - /// @param[in] arg_values + /// \param[in] arg_values /// The values of the function's arguments. /// - /// @param[in] diagnostic_manager + /// \param[in] diagnostic_manager /// The diagnostic manager to report errors to. /// - /// @return + /// \return /// True on success; false otherwise. - //------------------------------------------------------------------ bool WriteFunctionArguments(ExecutionContext &exe_ctx, lldb::addr_t &args_addr_ref, ValueList &arg_values, DiagnosticManager &diagnostic_manager); - //------------------------------------------------------------------ /// Run the function this FunctionCaller was created with. /// /// This is the full version. /// - /// @param[in] exe_ctx + /// \param[in] exe_ctx /// The thread & process in which this function will run. /// - /// @param[in] args_addr_ptr + /// \param[in] args_addr_ptr /// If nullptr, the function will take care of allocating & deallocating /// the wrapper /// args structure. Otherwise, if set to LLDB_INVALID_ADDRESS, a new @@ -212,118 +199,99 @@ public: /// this should point to an already allocated structure with the values /// already written. /// - /// @param[in] diagnostic_manager + /// \param[in] diagnostic_manager /// The diagnostic manager to report errors to. /// - /// @param[in] options + /// \param[in] options /// The options for this expression execution. /// - /// @param[out] results + /// \param[out] results /// The result value will be put here after running the function. /// - /// @return + /// \return /// Returns one of the ExpressionResults enum indicating function call /// status. - //------------------------------------------------------------------ lldb::ExpressionResults ExecuteFunction(ExecutionContext &exe_ctx, lldb::addr_t *args_addr_ptr, const EvaluateExpressionOptions &options, DiagnosticManager &diagnostic_manager, Value &results); - //------------------------------------------------------------------ /// Get a thread plan to run the function this FunctionCaller was created /// with. /// - /// @param[in] exe_ctx + /// \param[in] exe_ctx /// The execution context to insert the function and its arguments /// into. /// - /// @param[in] func_addr + /// \param[in] func_addr /// The address of the function in the target process. /// - /// @param[in] args_addr + /// \param[in] args_addr /// The address of the argument struct. /// - /// @param[in] diagnostic_manager + /// \param[in] diagnostic_manager /// The diagnostic manager to report errors to. /// - /// @param[in] stop_others + /// \param[in] stop_others /// True if other threads should pause during execution. /// - /// @param[in] unwind_on_error + /// \param[in] unwind_on_error /// True if the thread plan may simply be discarded if an error occurs. /// - /// @return + /// \return /// A ThreadPlan shared pointer for executing the function. - //------------------------------------------------------------------ lldb::ThreadPlanSP GetThreadPlanToCallFunction(ExecutionContext &exe_ctx, lldb::addr_t args_addr, const EvaluateExpressionOptions &options, DiagnosticManager &diagnostic_manager); - //------------------------------------------------------------------ /// Get the result of the function from its struct /// - /// @param[in] exe_ctx + /// \param[in] exe_ctx /// The execution context to retrieve the result from. /// - /// @param[in] args_addr + /// \param[in] args_addr /// The address of the argument struct. /// - /// @param[out] ret_value + /// \param[out] ret_value /// The value returned by the function. /// - /// @return + /// \return /// True on success; false otherwise. - //------------------------------------------------------------------ bool FetchFunctionResults(ExecutionContext &exe_ctx, lldb::addr_t args_addr, Value &ret_value); - //------------------------------------------------------------------ /// Deallocate the arguments structure /// - /// @param[in] exe_ctx + /// \param[in] exe_ctx /// The execution context to insert the function and its arguments /// into. /// - /// @param[in] args_addr + /// \param[in] args_addr /// The address of the argument struct. - //------------------------------------------------------------------ void DeallocateFunctionResults(ExecutionContext &exe_ctx, lldb::addr_t args_addr); - //------------------------------------------------------------------ /// Interface for ClangExpression - //------------------------------------------------------------------ - //------------------------------------------------------------------ /// Return the string that the parser should parse. Must be a full /// translation unit. - //------------------------------------------------------------------ const char *Text() override { return m_wrapper_function_text.c_str(); } - //------------------------------------------------------------------ /// Return the function name that should be used for executing the /// 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. - //------------------------------------------------------------------ ExpressionVariableList *LocalVariables() { return nullptr; } - //------------------------------------------------------------------ /// 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. - //------------------------------------------------------------------ bool NeedsVariableResolution() override { return false; } ValueList GetArgumentValues() const { return m_arg_values; } @@ -362,7 +330,6 @@ protected: bool m_struct_valid; ///< True if the ASTStructExtractor has populated the ///variables below. - //------------------------------------------------------------------ /// These values are populated by the ASTStructExtractor size_t m_struct_size; ///< The size of the argument struct, in bytes. std::vector<uint64_t> @@ -370,7 +337,6 @@ protected: uint64_t m_return_size; ///< The size of the result variable, in bytes. uint64_t m_return_offset; ///< The offset of the result variable in the ///struct, in bytes. - //------------------------------------------------------------------ ValueList m_arg_values; ///< The default values of the arguments. diff --git a/include/lldb/Expression/IRDynamicChecks.h b/include/lldb/Expression/IRDynamicChecks.h deleted file mode 100644 index f31c03cfb9efa..0000000000000 --- a/include/lldb/Expression/IRDynamicChecks.h +++ /dev/null @@ -1,171 +0,0 @@ -//===-- IRDynamicChecks.h ---------------------------------------------*- C++ -//-*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -#ifndef liblldb_IRDynamicChecks_h_ -#define liblldb_IRDynamicChecks_h_ - -#include "lldb/lldb-types.h" -#include "llvm/Pass.h" - -namespace llvm { -class BasicBlock; -class CallInst; -class Constant; -class Function; -class Instruction; -class Module; -class DataLayout; -class Value; -} - -namespace lldb_private { - -class ClangExpressionDeclMap; -class ExecutionContext; -class Stream; - -//---------------------------------------------------------------------- -/// @class DynamicCheckerFunctions IRDynamicChecks.h -/// "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: -/// -/// 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. -//---------------------------------------------------------------------- -class DynamicCheckerFunctions { -public: - //------------------------------------------------------------------ - /// Constructor - //------------------------------------------------------------------ - DynamicCheckerFunctions(); - - //------------------------------------------------------------------ - /// Destructor - //------------------------------------------------------------------ - ~DynamicCheckerFunctions(); - - //------------------------------------------------------------------ - /// 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. - /// - /// @param[in] exe_ctx - /// The execution context to install the functions into. - /// - /// @return - /// True on success; false on failure, or if the functions have - /// already been installed. - //------------------------------------------------------------------ - bool Install(DiagnosticManager &diagnostic_manager, - ExecutionContext &exe_ctx); - - bool DoCheckersExplainStop(lldb::addr_t addr, Stream &message); - - std::unique_ptr<UtilityFunction> m_valid_pointer_check; - std::unique_ptr<UtilityFunction> m_objc_object_check; -}; - -//---------------------------------------------------------------------- -/// @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. -/// -/// IRDynamicChecks adds calls to the functions in DynamicCheckerFunctions to -/// appropriate locations in an expression's IR. -//---------------------------------------------------------------------- -class IRDynamicChecks : public llvm::ModulePass { -public: - //------------------------------------------------------------------ - /// Constructor - /// - /// @param[in] checker_functions - /// The checker functions for the target process. - /// - /// @param[in] func_name - /// The name of the function to prepare for execution in the target. - /// - /// @param[in] decl_map - /// The mapping used to look up entities in the target process. In - /// this case, used to find objc_msgSend - //------------------------------------------------------------------ - IRDynamicChecks(DynamicCheckerFunctions &checker_functions, - const char *func_name = "$__lldb_expr"); - - //------------------------------------------------------------------ - /// Destructor - //------------------------------------------------------------------ - ~IRDynamicChecks() override; - - //------------------------------------------------------------------ - /// Run this IR transformer on a single module - /// - /// @param[in] M - /// The module to run on. This module is searched for the function - /// $__lldb_expr, and that function is passed to the passes one by - /// one. - /// - /// @return - /// True on success; false otherwise - //------------------------------------------------------------------ - bool runOnModule(llvm::Module &M) override; - - //------------------------------------------------------------------ - /// Interface stub - //------------------------------------------------------------------ - void assignPassManager( - llvm::PMStack &PMS, - llvm::PassManagerType T = llvm::PMT_ModulePassManager) override; - - //------------------------------------------------------------------ - /// Returns PMT_ModulePassManager - //------------------------------------------------------------------ - llvm::PassManagerType getPotentialPassManagerType() const override; - -private: - //------------------------------------------------------------------ - /// A basic block-level pass to find all pointer dereferences and - /// validate them before use. - //------------------------------------------------------------------ - - //------------------------------------------------------------------ - /// The top-level pass implementation - /// - /// @param[in] M - /// The module currently being processed. - /// - /// @param[in] BB - /// The basic block currently being processed. - /// - /// @return - /// True on success; false otherwise - //------------------------------------------------------------------ - bool FindDataLoads(llvm::Module &M, llvm::BasicBlock &BB); - - std::string m_func_name; ///< The name of the function to add checks to - DynamicCheckerFunctions - &m_checker_functions; ///< The checker functions for the process -}; - -} // namespace lldb_private - -#endif // liblldb_IRDynamicChecks_h_ diff --git a/include/lldb/Expression/IRExecutionUnit.h b/include/lldb/Expression/IRExecutionUnit.h index b966d135deabc..beff44db9d5ed 100644 --- a/include/lldb/Expression/IRExecutionUnit.h +++ b/include/lldb/Expression/IRExecutionUnit.h @@ -1,9 +1,8 @@ //===-- IRExecutionUnit.h ---------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -37,8 +36,7 @@ namespace lldb_private { class Status; -//---------------------------------------------------------------------- -/// @class IRExecutionUnit IRExecutionUnit.h +/// \class IRExecutionUnit IRExecutionUnit.h /// "lldb/Expression/IRExecutionUnit.h" Contains the IR and, optionally, JIT- /// compiled code for a module. /// @@ -55,22 +53,17 @@ class Status; /// 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, public ObjectFileJITDelegate { public: - //------------------------------------------------------------------ /// Constructor - //------------------------------------------------------------------ - IRExecutionUnit(std::unique_ptr<llvm::LLVMContext> &context_ap, - std::unique_ptr<llvm::Module> &module_ap, ConstString &name, + IRExecutionUnit(std::unique_ptr<llvm::LLVMContext> &context_up, + std::unique_ptr<llvm::Module> &module_up, ConstString &name, const lldb::TargetSP &target_sp, const SymbolContext &sym_ctx, std::vector<std::string> &cpu_features); - //------------------------------------------------------------------ /// Destructor - //------------------------------------------------------------------ ~IRExecutionUnit() override; ConstString GetFunctionName() { return m_name; } @@ -85,19 +78,15 @@ public: void GetRunnableInfo(Status &error, lldb::addr_t &func_addr, 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. - //------------------------------------------------------------------ lldb::addr_t WriteNow(const uint8_t *bytes, size_t size, Status &error); void FreeNow(lldb::addr_t allocation); - //------------------------------------------------------------------ /// ObjectFileJITDelegate overrides - //------------------------------------------------------------------ lldb::ByteOrder GetByteOrder() const override; uint32_t GetAddressByteSize() const override; @@ -112,41 +101,37 @@ public: lldb::ModuleSP GetJITModule(); - lldb::addr_t FindSymbol(const ConstString &name); + lldb::addr_t FindSymbol(ConstString name, bool &missing_weak); void GetStaticInitializers(std::vector<lldb::addr_t> &static_initializers); - //---------------------------------------------------------------------- - /// @class JittedFunction IRExecutionUnit.h + /// \class JittedFunction IRExecutionUnit.h /// "lldb/Expression/IRExecutionUnit.h" /// 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 /// represents a function possibly resident in both. - //---------------------------------------------------------------------- struct JittedEntity { ConstString m_name; ///< The function's name lldb::addr_t m_local_addr; ///< The address of the function in LLDB's memory lldb::addr_t m_remote_addr; ///< The address of the function in the target's memory - //------------------------------------------------------------------ /// Constructor /// /// Initializes class variabes. /// - /// @param[in] name + /// \param[in] name /// The name of the function. /// - /// @param[in] local_addr + /// \param[in] local_addr /// The address of the function in LLDB, or LLDB_INVALID_ADDRESS if /// it is not present in LLDB's memory. /// - /// @param[in] remote_addr + /// \param[in] remote_addr /// The address of the function in the target, or LLDB_INVALID_ADDRESS /// if it is not present in the target's memory. - //------------------------------------------------------------------ JittedEntity(const char *name, lldb::addr_t local_addr = LLDB_INVALID_ADDRESS, lldb::addr_t remote_addr = LLDB_INVALID_ADDRESS) @@ -177,63 +162,53 @@ 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 /// - /// @param[in] local_address + /// \param[in] local_address /// The address in the debugger. /// - /// @return + /// \return /// The address in the target process. - //------------------------------------------------------------------ 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 /// - /// @param[in] local_address + /// \param[in] local_address /// The address in the debugger. /// - /// @return + /// \return /// The range of the containing object in the target process. - //------------------------------------------------------------------ typedef std::pair<lldb::addr_t, uintptr_t> AddrRange; AddrRange GetRemoteRangeForLocal(lldb::addr_t local_address); - //------------------------------------------------------------------ /// Commit all allocations to the process and record where they were stored. /// - /// @param[in] process + /// \param[in] process /// The process to allocate memory in. /// - /// @return + /// \return /// True <=> all allocations were performed successfully. /// This method will attempt to free allocated memory if the /// operation fails. - //------------------------------------------------------------------ bool CommitAllocations(lldb::ProcessSP &process_sp); - //------------------------------------------------------------------ /// Report all committed allocations to the execution engine. /// - /// @param[in] engine + /// \param[in] engine /// The execution engine to notify. - //------------------------------------------------------------------ void ReportAllocations(llvm::ExecutionEngine &engine); - //------------------------------------------------------------------ /// Write the contents of all allocations to the process. /// - /// @param[in] local_address + /// \param[in] local_address /// The process containing the allocations. /// - /// @return + /// \return /// True <=> all allocations were performed successfully. - //------------------------------------------------------------------ bool WriteData(lldb::ProcessSP &process_sp); Status DisassembleFunction(Stream &stream, lldb::ProcessSP &process_sp); @@ -241,7 +216,7 @@ private: struct SearchSpec; void CollectCandidateCNames(std::vector<SearchSpec> &C_specs, - const ConstString &name); + ConstString name); void CollectCandidateCPlusPlusNames(std::vector<SearchSpec> &CPP_specs, const std::vector<SearchSpec> &C_specs, @@ -251,7 +226,8 @@ private: const std::vector<SearchSpec> &C_specs); lldb::addr_t FindInSymbols(const std::vector<SearchSpec> &specs, - const lldb_private::SymbolContext &sc); + const lldb_private::SymbolContext &sc, + bool &symbol_was_missing_weak); lldb::addr_t FindInRuntimes(const std::vector<SearchSpec> &specs, const lldb_private::SymbolContext &sc); @@ -259,7 +235,7 @@ private: lldb::addr_t FindInUserDefinedSymbols(const std::vector<SearchSpec> &specs, const lldb_private::SymbolContext &sc); - void ReportSymbolLookupError(const ConstString &name); + void ReportSymbolLookupError(ConstString name); class MemoryManager : public llvm::SectionMemoryManager { public: @@ -267,59 +243,53 @@ private: ~MemoryManager() override; - //------------------------------------------------------------------ /// Allocate space for executable code, and add it to the m_spaceBlocks /// map /// - /// @param[in] Size + /// \param[in] Size /// The size of the area. /// - /// @param[in] Alignment + /// \param[in] Alignment /// The required alignment of the area. /// - /// @param[in] SectionID + /// \param[in] SectionID /// A unique identifier for the section. /// - /// @return + /// \return /// Allocated space. - //------------------------------------------------------------------ uint8_t *allocateCodeSection(uintptr_t Size, unsigned Alignment, unsigned SectionID, llvm::StringRef SectionName) override; - //------------------------------------------------------------------ /// Allocate space for data, and add it to the m_spaceBlocks map /// - /// @param[in] Size + /// \param[in] Size /// The size of the area. /// - /// @param[in] Alignment + /// \param[in] Alignment /// The required alignment of the area. /// - /// @param[in] SectionID + /// \param[in] SectionID /// A unique identifier for the section. /// - /// @param[in] IsReadOnly + /// \param[in] IsReadOnly /// Flag indicating the section is read-only. /// - /// @return + /// \return /// Allocated space. - //------------------------------------------------------------------ uint8_t *allocateDataSection(uintptr_t Size, unsigned Alignment, unsigned SectionID, llvm::StringRef SectionName, bool IsReadOnly) override; - //------------------------------------------------------------------ /// Called when object loading is complete and section page permissions /// can be applied. Currently unimplemented for LLDB. /// - /// @param[out] ErrMsg + /// \param[out] ErrMsg /// The error that prevented the page protection from succeeding. /// - /// @return + /// \return /// True in case of failure, false in case of success. - //------------------------------------------------------------------ bool finalizeMemory(std::string *ErrMsg) override { // TODO: Ensure that the instruction cache is flushed because // relocations are updated by dy-load. See: @@ -332,31 +302,36 @@ private: size_t Size) override {} uint64_t getSymbolAddress(const std::string &Name) override; + + // Find the address of the symbol Name. If Name is a missing weak symbol + // then missing_weak will be true. + uint64_t GetSymbolAddressAndPresence(const std::string &Name, + bool &missing_weak); + + llvm::JITSymbol findSymbol(const std::string &Name) override; void *getPointerToNamedFunction(const std::string &Name, bool AbortOnFailure = true) override; private: - std::unique_ptr<SectionMemoryManager> m_default_mm_ap; ///< The memory - ///allocator to use - ///in actually - ///creating space. - ///All calls are - ///passed through to - ///it. + std::unique_ptr<SectionMemoryManager> m_default_mm_up; ///< The memory + /// allocator to use + /// in actually + /// creating space. + /// All calls are + /// passed through to + /// it. IRExecutionUnit &m_parent; ///< The execution unit this is a proxy for. }; static const unsigned eSectionIDInvalid = (unsigned)-1; - //---------------------------------------------------------------------- - /// @class AllocationRecord IRExecutionUnit.h + /// \class AllocationRecord IRExecutionUnit.h /// "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. - //---------------------------------------------------------------------- enum class AllocationKind { Stub, Code, Data, Global, Bytes }; static lldb::SectionType @@ -393,11 +368,11 @@ private: typedef std::vector<AllocationRecord> RecordVector; RecordVector m_records; - std::unique_ptr<llvm::LLVMContext> m_context_ap; - std::unique_ptr<llvm::ExecutionEngine> m_execution_engine_ap; - std::unique_ptr<llvm::ObjectCache> m_object_cache_ap; + std::unique_ptr<llvm::LLVMContext> m_context_up; + std::unique_ptr<llvm::ExecutionEngine> m_execution_engine_up; + std::unique_ptr<llvm::ObjectCache> m_object_cache_up; std::unique_ptr<llvm::Module> - m_module_ap; ///< Holder for the module until it's been handed off + m_module_up; ///< Holder for the module until it's been handed off llvm::Module *m_module; ///< Owned by the execution engine std::vector<std::string> m_cpu_features; std::vector<JittedFunction> m_jitted_functions; ///< A vector of all functions diff --git a/include/lldb/Expression/IRInterpreter.h b/include/lldb/Expression/IRInterpreter.h index 2d87346b70663..6148093e718ff 100644 --- a/include/lldb/Expression/IRInterpreter.h +++ b/include/lldb/Expression/IRInterpreter.h @@ -1,9 +1,8 @@ //===-- IRInterpreter.h -----------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -27,15 +26,13 @@ class ClangExpressionDeclMap; class IRMemoryMap; } -//---------------------------------------------------------------------- -/// @class IRInterpreter IRInterpreter.h "lldb/Expression/IRInterpreter.h" +/// \class IRInterpreter IRInterpreter.h "lldb/Expression/IRInterpreter.h" /// 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. -//---------------------------------------------------------------------- class IRInterpreter { public: static bool CanInterpret(llvm::Module &module, llvm::Function &function, diff --git a/include/lldb/Expression/IRMemoryMap.h b/include/lldb/Expression/IRMemoryMap.h index 026ca6b981106..d6a17a9848fb6 100644 --- a/include/lldb/Expression/IRMemoryMap.h +++ b/include/lldb/Expression/IRMemoryMap.h @@ -1,9 +1,8 @@ -//===-- IRExecutionUnit.h ---------------------------------------*- C++ -*-===// +//===-- IRMemoryMap.h -------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -18,8 +17,7 @@ namespace lldb_private { -//---------------------------------------------------------------------- -/// @class IRMemoryMap IRMemoryMap.h "lldb/Expression/IRMemoryMap.h" +/// \class IRMemoryMap IRMemoryMap.h "lldb/Expression/IRMemoryMap.h" /// Encapsulates memory that may exist in the process but must /// also be available in the host process. /// @@ -33,7 +31,6 @@ namespace lldb_private { /// 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: IRMemoryMap(lldb::TargetSP target_sp); diff --git a/include/lldb/Expression/LLVMUserExpression.h b/include/lldb/Expression/LLVMUserExpression.h index 1ba822265fcaa..c2af7239951b5 100644 --- a/include/lldb/Expression/LLVMUserExpression.h +++ b/include/lldb/Expression/LLVMUserExpression.h @@ -1,9 +1,8 @@ //===-- LLVMUserExpression.h ------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -20,8 +19,7 @@ namespace lldb_private { -//---------------------------------------------------------------------- -/// @class LLVMUserExpression LLVMUserExpression.h +/// \class LLVMUserExpression LLVMUserExpression.h /// "lldb/Expression/LLVMUserExpression.h" Encapsulates a one-time expression /// for use in lldb. /// @@ -31,9 +29,13 @@ namespace lldb_private { /// 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: + /// LLVM-style RTTI support. + static bool classof(const Expression *E) { + return E->getKind() == eKindLLVMUserExpression; + } + // 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 @@ -49,7 +51,8 @@ public: LLVMUserExpression(ExecutionContextScope &exe_scope, llvm::StringRef expr, llvm::StringRef prefix, lldb::LanguageType language, ResultType desired_type, - const EvaluateExpressionOptions &options); + const EvaluateExpressionOptions &options, + ExpressionKind kind); ~LLVMUserExpression() override; bool FinalizeJITExecution( @@ -60,10 +63,8 @@ public: bool CanInterpret() override { return m_can_interpret; } - //------------------------------------------------------------------ /// Return the string that the parser should parse. Must be a full /// translation unit. - //------------------------------------------------------------------ const char *Text() override { return m_transformed_text.c_str(); } lldb::ModuleSP GetJITModule() override; @@ -98,9 +99,9 @@ protected: std::shared_ptr<IRExecutionUnit> m_execution_unit_sp; ///< The execution unit the expression is stored in. - std::unique_ptr<Materializer> m_materializer_ap; ///< The materializer to use - ///when running the - ///expression. + std::unique_ptr<Materializer> m_materializer_up; ///< The materializer to use + /// when running the + /// expression. lldb::ModuleWP m_jit_module_wp; bool m_enforce_valid_object; ///< True if the expression parser should enforce ///the presence of a valid class pointer diff --git a/include/lldb/Expression/Materializer.h b/include/lldb/Expression/Materializer.h index 0bdfd372e9214..603b4e0066cd4 100644 --- a/include/lldb/Expression/Materializer.h +++ b/include/lldb/Expression/Materializer.h @@ -1,9 +1,8 @@ //===-- Materializer.h ------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// diff --git a/include/lldb/Expression/REPL.h b/include/lldb/Expression/REPL.h index f7780772cbeac..850d2f6f961a9 100644 --- a/include/lldb/Expression/REPL.h +++ b/include/lldb/Expression/REPL.h @@ -1,9 +1,8 @@ //===-- REPL.h --------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -12,17 +11,16 @@ #include <string> -#include "lldb/../../source/Commands/CommandObjectExpression.h" +#include "lldb/Core/IOHandler.h" #include "lldb/Interpreter/OptionGroupFormat.h" #include "lldb/Interpreter/OptionGroupValueObjectDisplay.h" +#include "lldb/Target/Target.h" namespace lldb_private { class REPL : public IOHandlerDelegate { public: - //---------------------------------------------------------------------- // See TypeSystem.h for how to add subclasses to this. - //---------------------------------------------------------------------- enum LLVMCastKind { eKindClang, eKindSwift, eKindGo, kNumKinds }; LLVMCastKind getKind() const { return m_kind; } @@ -31,31 +29,29 @@ public: ~REPL() override; - //------------------------------------------------------------------ /// Get a REPL with an existing target (or, failing that, a debugger to use), /// and (optional) extra arguments for the compiler. /// - /// @param[out] error + /// \param[out] error /// If this language is supported but the REPL couldn't be created, this /// error is populated with the reason. /// - /// @param[in] language + /// \param[in] language /// The language to create a REPL for. /// - /// @param[in] debugger + /// \param[in] debugger /// If provided, and target is nullptr, the debugger to use when setting /// up a top-level REPL. /// - /// @param[in] target + /// \param[in] target /// If provided, the target to put the REPL inside. /// - /// @param[in] repl_options + /// \param[in] repl_options /// If provided, additional options for the compiler when parsing REPL /// expressions. /// - /// @return + /// \return /// The range of the containing object in the target process. - //------------------------------------------------------------------ static lldb::REPLSP Create(Status &Status, lldb::LanguageType language, Debugger *debugger, Target *target, const char *repl_options); @@ -69,9 +65,8 @@ public: m_varobj_options = options; } - void - SetCommandOptions(const CommandObjectExpression::CommandOptions &options) { - m_command_options = options; + void SetEvaluateOptions(const EvaluateExpressionOptions &options) { + m_expr_options = options; } void SetCompilerOptions(const char *options) { @@ -83,10 +78,8 @@ public: Status RunLoop(); - //------------------------------------------------------------------ // IOHandler::Delegate functions - //------------------------------------------------------------------ - void IOHandlerActivated(IOHandler &io_handler) override; + void IOHandlerActivated(IOHandler &io_handler, bool interactive) override; bool IOHandlerInterrupt(IOHandler &io_handler) override; @@ -118,9 +111,7 @@ public: protected: static int CalculateActualIndentation(const StringList &lines); - //---------------------------------------------------------------------- // Subclasses should override these functions to implement a functional REPL. - //---------------------------------------------------------------------- virtual Status DoInitialization() = 0; @@ -146,7 +137,7 @@ protected: OptionGroupFormat m_format_options = OptionGroupFormat(lldb::eFormatDefault); OptionGroupValueObjectDisplay m_varobj_options; - CommandObjectExpression::CommandOptions m_command_options; + EvaluateExpressionOptions m_expr_options; std::string m_compiler_options; bool m_enable_auto_indent = true; diff --git a/include/lldb/Expression/UserExpression.h b/include/lldb/Expression/UserExpression.h index 812d7e9a0eacc..b1d52f8ddd55d 100644 --- a/include/lldb/Expression/UserExpression.h +++ b/include/lldb/Expression/UserExpression.h @@ -1,9 +1,8 @@ //===-- UserExpression.h ----------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -24,8 +23,7 @@ namespace lldb_private { -//---------------------------------------------------------------------- -/// @class UserExpression UserExpression.h "lldb/Expression/UserExpression.h" +/// \class UserExpression UserExpression.h "lldb/Expression/UserExpression.h" /// Encapsulates a one-time expression for use in lldb. /// /// LLDB uses expressions for various purposes, notably to call functions @@ -34,89 +32,86 @@ namespace lldb_private { /// JIT an expression. The actual parsing part will be provided by the specific /// implementations of UserExpression - which will be vended through the /// appropriate TypeSystem. -//---------------------------------------------------------------------- class UserExpression : public Expression { public: + /// LLVM-style RTTI support. + static bool classof(const Expression *E) { + return E->getKind() == eKindUserExpression; + } + enum { kDefaultTimeout = 500000u }; - //------------------------------------------------------------------ /// Constructor /// - /// @param[in] expr + /// \param[in] expr /// The expression to parse. /// - /// @param[in] expr_prefix + /// \param[in] expr_prefix /// If non-nullptr, a C string containing translation-unit level /// definitions to be included when the expression is parsed. /// - /// @param[in] language + /// \param[in] language /// If not eLanguageTypeUnknown, a language to use when parsing /// the expression. Currently restricted to those languages /// supported by Clang. /// - /// @param[in] desired_type + /// \param[in] desired_type /// If not eResultTypeAny, the type to use for the expression /// result. - //------------------------------------------------------------------ UserExpression(ExecutionContextScope &exe_scope, llvm::StringRef expr, llvm::StringRef prefix, lldb::LanguageType language, ResultType desired_type, - const EvaluateExpressionOptions &options); + const EvaluateExpressionOptions &options, + ExpressionKind kind); - //------------------------------------------------------------------ /// Destructor - //------------------------------------------------------------------ ~UserExpression() override; - //------------------------------------------------------------------ /// Parse the expression /// - /// @param[in] diagnostic_manager + /// \param[in] diagnostic_manager /// A diagnostic manager to report parse errors and warnings to. /// - /// @param[in] exe_ctx + /// \param[in] exe_ctx /// The execution context to use when looking up entities that /// are needed for parsing (locations of functions, types of /// variables, persistent variables, etc.) /// - /// @param[in] execution_policy + /// \param[in] execution_policy /// Determines whether interpretation is possible or mandatory. /// - /// @param[in] keep_result_in_memory + /// \param[in] keep_result_in_memory /// True if the resulting persistent variable should reside in /// target memory, if applicable. /// - /// @return + /// \return /// True on success (no errors); false otherwise. - //------------------------------------------------------------------ virtual bool Parse(DiagnosticManager &diagnostic_manager, ExecutionContext &exe_ctx, lldb_private::ExecutionPolicy execution_policy, bool keep_result_in_memory, bool generate_debug_info) = 0; - //------------------------------------------------------------------ /// Attempts to find possible command line completions for the given /// (possible incomplete) user expression. /// - /// @param[in] exe_ctx + /// \param[in] exe_ctx /// The execution context to use when looking up entities that /// are needed for parsing and completing (locations of functions, types /// of variables, persistent variables, etc.) /// - /// @param[out] request + /// \param[out] request /// The completion request to fill out. The completion should be a string /// that would complete the current token at the cursor position. /// Note that the string in the list replaces the current token /// in the command line. /// - /// @param[in] complete_pos + /// \param[in] complete_pos /// The position of the cursor inside the user expression string. /// The completion process starts on the token that the cursor is in. /// - /// @return + /// \return /// True if we added any completion results to the output; /// false otherwise. - //------------------------------------------------------------------ virtual bool Complete(ExecutionContext &exe_ctx, CompletionRequest &request, unsigned complete_pos) { return false; @@ -126,105 +121,87 @@ public: bool MatchesContext(ExecutionContext &exe_ctx); - //------------------------------------------------------------------ /// Execute the parsed expression by callinng the derived class's DoExecute /// method. /// - /// @param[in] diagnostic_manager + /// \param[in] diagnostic_manager /// A diagnostic manager to report errors to. /// - /// @param[in] exe_ctx + /// \param[in] exe_ctx /// The execution context to use when looking up entities that /// are needed for parsing (locations of variables, etc.) /// - /// @param[in] options + /// \param[in] options /// Expression evaluation options. /// - /// @param[in] shared_ptr_to_me + /// \param[in] shared_ptr_to_me /// This is a shared pointer to this UserExpression. This is /// needed because Execute can push a thread plan that will hold onto /// the UserExpression for an unbounded period of time. So you /// need to give the thread plan a reference to this object that can /// keep it alive. /// - /// @param[in] result + /// \param[in] result /// A pointer to direct at the persistent variable in which the /// expression's result is stored. /// - /// @return + /// \return /// A Process::Execution results value. - //------------------------------------------------------------------ lldb::ExpressionResults Execute(DiagnosticManager &diagnostic_manager, ExecutionContext &exe_ctx, const EvaluateExpressionOptions &options, lldb::UserExpressionSP &shared_ptr_to_me, lldb::ExpressionVariableSP &result); - //------------------------------------------------------------------ /// Apply the side effects of the function to program state. /// - /// @param[in] diagnostic_manager + /// \param[in] diagnostic_manager /// A diagnostic manager to report errors to. /// - /// @param[in] exe_ctx + /// \param[in] exe_ctx /// The execution context to use when looking up entities that /// are needed for parsing (locations of variables, etc.) /// - /// @param[in] result + /// \param[in] result /// A pointer to direct at the persistent variable in which the /// expression's result is stored. /// - /// @param[in] function_stack_pointer + /// \param[in] function_stack_pointer /// A pointer to the base of the function's stack frame. This /// is used to determine whether the expression result resides in /// memory that will still be valid, or whether it needs to be /// treated as homeless for the purpose of future expressions. /// - /// @return + /// \return /// A Process::Execution results value. - //------------------------------------------------------------------ virtual bool FinalizeJITExecution( DiagnosticManager &diagnostic_manager, ExecutionContext &exe_ctx, lldb::ExpressionVariableSP &result, lldb::addr_t function_stack_bottom = LLDB_INVALID_ADDRESS, lldb::addr_t function_stack_top = LLDB_INVALID_ADDRESS) = 0; - //------------------------------------------------------------------ /// Return the string that the parser should parse. - //------------------------------------------------------------------ const char *Text() override { return m_expr_text.c_str(); } - //------------------------------------------------------------------ /// Return the string that the user typed. - //------------------------------------------------------------------ const char *GetUserText() { return m_expr_text.c_str(); } - //------------------------------------------------------------------ /// Return the function name that should be used for executing the /// 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. - //------------------------------------------------------------------ lldb::LanguageType Language() override { return m_language; } - //------------------------------------------------------------------ /// 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. - //------------------------------------------------------------------ bool NeedsValidation() override { return true; } - //------------------------------------------------------------------ /// Return true if external variables in the expression should be resolved. - //------------------------------------------------------------------ bool NeedsVariableResolution() override { return true; } EvaluateExpressionOptions *GetOptions() override { return &m_options; } @@ -236,53 +213,58 @@ 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. /// - /// @param[in] exe_ctx + /// \param[in] exe_ctx /// The execution context to use when evaluating the expression. /// - /// @param[in] options + /// \param[in] options /// Expression evaluation options. N.B. The language in the /// evaluation options will be used to determine the language used for /// expression evaluation. /// - /// @param[in] expr_cstr + /// \param[in] expr_cstr /// A C string containing the expression to be evaluated. /// - /// @param[in] expr_prefix + /// \param[in] expr_prefix /// If non-nullptr, a C string containing translation-unit level /// definitions to be included when the expression is parsed. /// - /// @param[in,out] result_valobj_sp + /// \param[in,out] result_valobj_sp /// If execution is successful, the result valobj is placed here. /// - /// @param[out] error + /// \param[out] error /// Filled in with an error in case the expression evaluation /// fails to parse, run, or evaluated. /// - /// @param[in] line_offset - /// The offset of the first line of the expression from the "beginning" of - /// a virtual source file used for error reporting and debug info. - /// - /// @param[out] fixed_expression + /// \param[out] fixed_expression /// If non-nullptr, the fixed expression is copied into the provided /// string. /// - /// @param[out] jit_module_sp_ptr + /// \param[out] jit_module_sp_ptr /// If non-nullptr, used to persist the generated IR module. /// - /// @result + /// \param[in] ctx_obj + /// If specified, then the expression will be evaluated in the context of + /// this object. It means that the context object's address will be + /// treated as `this` for the expression (the expression will be + /// evaluated as if it was inside of a method of the context object's + /// class, and its `this` parameter were pointing to the context object). + /// The parameter makes sense for class and union types only. + /// Currently there is a limitation: the context object must be located + /// in the debuggee process' memory (and have the load address). + /// + /// \result /// A Process::ExpressionResults value. eExpressionCompleted for /// success. - //------------------------------------------------------------------ static lldb::ExpressionResults Evaluate(ExecutionContext &exe_ctx, const EvaluateExpressionOptions &options, llvm::StringRef expr_cstr, llvm::StringRef expr_prefix, lldb::ValueObjectSP &result_valobj_sp, Status &error, - uint32_t line_offset = 0, std::string *fixed_expression = nullptr, - lldb::ModuleSP *jit_module_sp_ptr = nullptr); + std::string *fixed_expression = nullptr, + lldb::ModuleSP *jit_module_sp_ptr = nullptr, + ValueObject *ctx_obj = nullptr); static const Status::ValueType kNoResult = 0x1001; ///< ValueObject::GetError() returns this if there is no result @@ -304,10 +286,8 @@ protected: static lldb::addr_t GetObjectPointer(lldb::StackFrameSP frame_sp, ConstString &object_name, Status &err); - //------------------------------------------------------------------ /// Populate m_in_cplusplus_method and m_in_objectivec_method based on the /// environment. - //------------------------------------------------------------------ void InstallContext(ExecutionContext &exe_ctx); diff --git a/include/lldb/Expression/UtilityFunction.h b/include/lldb/Expression/UtilityFunction.h index 4c87f4d104796..26da081ddced0 100644 --- a/include/lldb/Expression/UtilityFunction.h +++ b/include/lldb/Expression/UtilityFunction.h @@ -1,10 +1,9 @@ //===-- UtilityFunction.h ----------------------------------------*- C++ //-*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -20,8 +19,7 @@ namespace lldb_private { -//---------------------------------------------------------------------- -/// @class UtilityFunction UtilityFunction.h +/// \class UtilityFunction UtilityFunction.h /// "lldb/Expression/UtilityFunction.h" Encapsulates a bit of source code that /// provides a function that is callable /// @@ -29,83 +27,71 @@ namespace lldb_private { /// 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 { public: - //------------------------------------------------------------------ + /// LLVM-style RTTI support. + static bool classof(const Expression *E) { + return E->getKind() == eKindUtilityFunction; + } + /// Constructor /// - /// @param[in] text + /// \param[in] text /// The text of the function. Must be a full translation unit. /// - /// @param[in] name + /// \param[in] name /// The name of the function, as used in the text. - //------------------------------------------------------------------ UtilityFunction(ExecutionContextScope &exe_scope, const char *text, - const char *name); + const char *name, ExpressionKind kind); ~UtilityFunction() override; - //------------------------------------------------------------------ /// Install the utility function into a process /// - /// @param[in] diagnostic_manager + /// \param[in] diagnostic_manager /// A diagnostic manager to print parse errors and warnings to. /// - /// @param[in] exe_ctx + /// \param[in] exe_ctx /// The execution context to install the utility function to. /// - /// @return + /// \return /// True on success (no errors); false otherwise. - //------------------------------------------------------------------ virtual bool Install(DiagnosticManager &diagnostic_manager, ExecutionContext &exe_ctx) = 0; - //------------------------------------------------------------------ /// Check whether the given PC is inside the function /// /// Especially useful if the function dereferences nullptr to indicate a /// failed assert. /// - /// @param[in] pc + /// \param[in] pc /// The program counter to check. /// - /// @return + /// \return /// True if the program counter falls within the function's bounds; /// 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 return (address >= m_jit_start_addr && address < m_jit_end_addr); } - //------------------------------------------------------------------ /// Return the string that the parser should parse. Must be a full /// translation unit. - //------------------------------------------------------------------ const char *Text() override { return m_function_text.c_str(); } - //------------------------------------------------------------------ /// Return the function name that should be used for executing the /// 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. - //------------------------------------------------------------------ ExpressionVariableList *LocalVariables() { return nullptr; } - //------------------------------------------------------------------ /// 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. - //------------------------------------------------------------------ bool NeedsVariableResolution() override { return false; } // This makes the function caller function. Pass in the ThreadSP if you have diff --git a/include/lldb/Host/Config.h.cmake b/include/lldb/Host/Config.h.cmake index 02a57ad8ca921..b8fb9e9de868d 100644 --- a/include/lldb/Host/Config.h.cmake +++ b/include/lldb/Host/Config.h.cmake @@ -1,9 +1,8 @@ //===-- Config.h -----------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// diff --git a/include/lldb/Host/ConnectionFileDescriptor.h b/include/lldb/Host/ConnectionFileDescriptor.h index 0d486a34c8d0a..00444d011af30 100644 --- a/include/lldb/Host/ConnectionFileDescriptor.h +++ b/include/lldb/Host/ConnectionFileDescriptor.h @@ -1,9 +1,8 @@ //===-- ConnectionFileDescriptor.h ------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// diff --git a/include/lldb/Host/Debug.h b/include/lldb/Host/Debug.h index d88725cf4e2e0..036ce1ebccd59 100644 --- a/include/lldb/Host/Debug.h +++ b/include/lldb/Host/Debug.h @@ -1,9 +1,8 @@ //===-- Debug.h -------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -16,9 +15,7 @@ namespace lldb_private { -//------------------------------------------------------------------ // Tells a thread what it needs to do when the process is resumed. -//------------------------------------------------------------------ struct ResumeAction { lldb::tid_t tid; // The thread ID that this action applies to, // LLDB_INVALID_THREAD_ID for the default thread @@ -29,12 +26,10 @@ struct ResumeAction { // value is > 0 }; -//------------------------------------------------------------------ // 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. -//------------------------------------------------------------------ class ResumeActionList { public: ResumeActionList() : m_actions(), m_signal_handled() {} diff --git a/include/lldb/Host/Editline.h b/include/lldb/Host/Editline.h index 51d6e58c1e7a4..a942ede05ce59 100644 --- a/include/lldb/Host/Editline.h +++ b/include/lldb/Host/Editline.h @@ -1,9 +1,8 @@ //===-- Editline.h ----------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// diff --git a/include/lldb/Host/File.h b/include/lldb/Host/File.h index 69ae2004e4222..eb28c4ada0e71 100644 --- a/include/lldb/Host/File.h +++ b/include/lldb/Host/File.h @@ -1,9 +1,8 @@ //===-- File.h --------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -15,19 +14,18 @@ #include "lldb/Utility/Status.h" #include "lldb/lldb-private.h" +#include <mutex> #include <stdarg.h> #include <stdio.h> #include <sys/types.h> namespace lldb_private { -//---------------------------------------------------------------------- -/// @class File File.h "lldb/Host/File.h" +/// \class File File.h "lldb/Host/File.h" /// A file class. /// /// A file class that divides abstracts the LLDB core from host file /// functionality. -//---------------------------------------------------------------------- class File : public IOObject { public: static int kInvalidDescriptor; @@ -72,59 +70,51 @@ public: m_is_interactive(eLazyBoolCalculate), m_is_real_terminal(eLazyBoolCalculate) {} - //------------------------------------------------------------------ /// Destructor. /// /// The destructor is virtual in case this class is subclassed. - //------------------------------------------------------------------ ~File() override; bool IsValid() const override { return DescriptorIsValid() || StreamIsValid(); } - //------------------------------------------------------------------ /// Convert to pointer operator. /// /// This allows code to check a File object to see if it contains anything /// valid using code such as: /// - /// @code + /// \code /// File file(...); /// if (file) /// { ... - /// @endcode + /// \endcode /// - /// @return + /// \return /// A pointer to this object if either the directory or filename /// is valid, nullptr otherwise. - //------------------------------------------------------------------ operator bool() const { return DescriptorIsValid() || StreamIsValid(); } - //------------------------------------------------------------------ /// Logical NOT operator. /// /// This allows code to check a File object to see if it is invalid using /// code such as: /// - /// @code + /// \code /// File file(...); /// if (!file) /// { ... - /// @endcode + /// \endcode /// - /// @return + /// \return /// Returns \b true if the object has an empty directory and /// filename, \b false otherwise. - //------------------------------------------------------------------ bool operator!() const { return !DescriptorIsValid() && !StreamIsValid(); } - //------------------------------------------------------------------ /// Get the file spec for this file. /// - /// @return + /// \return /// A reference to the file specification object. - //------------------------------------------------------------------ Status GetFileSpec(FileSpec &file_spec) const; Status Close() override; @@ -141,172 +131,157 @@ public: void SetStream(FILE *fh, bool transfer_ownership); - //------------------------------------------------------------------ /// 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. /// - /// @param[in] buf + /// \param[in] buf /// A buffer where to put the bytes that are read. /// - /// @param[in,out] num_bytes + /// \param[in,out] num_bytes /// The number of bytes to read form the current file position /// which gets modified with the number of bytes that were read. /// - /// @return + /// \return /// An error object that indicates success or the reason for /// failure. - //------------------------------------------------------------------ Status Read(void *buf, size_t &num_bytes) override; - //------------------------------------------------------------------ /// 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. /// - /// @param[in] buf + /// \param[in] buf /// A buffer where to put the bytes that are read. /// - /// @param[in,out] num_bytes + /// \param[in,out] num_bytes /// The number of bytes to write to the current file position /// which gets modified with the number of bytes that were /// written. /// - /// @return + /// \return /// An error object that indicates success or the reason for /// failure. - //------------------------------------------------------------------ Status Write(const void *buf, size_t &num_bytes) override; - //------------------------------------------------------------------ /// 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 *, + /// File::Read (void *, size_t, off_t &) \see File::Write (const void *, /// size_t, off_t &) /// - /// @param[in] offset + /// \param[in] offset /// The offset to seek to within the file relative to the /// beginning of the file. /// - /// @param[in] error_ptr + /// \param[in] error_ptr /// A pointer to a lldb_private::Status object that will be /// filled in if non-nullptr. /// - /// @return + /// \return /// The resulting seek offset, or -1 on error. - //------------------------------------------------------------------ off_t SeekFromStart(off_t offset, Status *error_ptr = nullptr); - //------------------------------------------------------------------ /// 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 *, + /// File::Read (void *, size_t, off_t &) \see File::Write (const void *, /// size_t, off_t &) /// - /// @param[in] offset + /// \param[in] offset /// The offset to seek to within the file relative to the /// current file position. /// - /// @param[in] error_ptr + /// \param[in] error_ptr /// A pointer to a lldb_private::Status object that will be /// filled in if non-nullptr. /// - /// @return + /// \return /// The resulting seek offset, or -1 on error. - //------------------------------------------------------------------ off_t SeekFromCurrent(off_t offset, Status *error_ptr = nullptr); - //------------------------------------------------------------------ /// 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 *, + /// File::Read (void *, size_t, off_t &) \see File::Write (const void *, /// size_t, off_t &) /// - /// @param[in,out] offset + /// \param[in,out] offset /// The offset to seek to within the file relative to the /// end of the file which gets filled in with the resulting /// absolute file offset. /// - /// @param[in] error_ptr + /// \param[in] error_ptr /// A pointer to a lldb_private::Status object that will be /// filled in if non-nullptr. /// - /// @return + /// \return /// The resulting seek offset, or -1 on error. - //------------------------------------------------------------------ off_t SeekFromEnd(off_t offset, Status *error_ptr = nullptr); - //------------------------------------------------------------------ /// 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. /// - /// @param[in] dst + /// \param[in] dst /// A buffer where to put the bytes that are read. /// - /// @param[in,out] num_bytes + /// \param[in,out] num_bytes /// The number of bytes to read form the current file position /// which gets modified with the number of bytes that were read. /// - /// @param[in,out] offset + /// \param[in,out] offset /// The offset within the file from which to read \a num_bytes /// bytes. This offset gets incremented by the number of bytes /// that were read. /// - /// @return + /// \return /// An error object that indicates success or the reason for /// failure. - //------------------------------------------------------------------ Status Read(void *dst, size_t &num_bytes, off_t &offset); - //------------------------------------------------------------------ /// 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. /// - /// @param[in,out] num_bytes + /// \param[in,out] num_bytes /// The number of bytes to read form the current file position /// which gets modified with the number of bytes that were read. /// - /// @param[in,out] offset + /// \param[in,out] offset /// The offset within the file from which to read \a num_bytes /// bytes. This offset gets incremented by the number of bytes /// that were read. /// - /// @param[in] null_terminate + /// \param[in] null_terminate /// Ensure that the data that is read is terminated with a NULL /// character so that the data can be used as a C string. /// - /// @param[out] data_buffer_sp + /// \param[out] data_buffer_sp /// A data buffer to create and fill in that will contain any /// data that is read from the file. This buffer will be reset /// if an error occurs. /// - /// @return + /// \return /// An error object that indicates success or the reason for /// failure. - //------------------------------------------------------------------ Status Read(size_t &num_bytes, off_t &offset, bool null_terminate, lldb::DataBufferSP &data_buffer_sp); - //------------------------------------------------------------------ /// Write bytes to a file at the specified file offset. /// /// NOTE: This function is thread safe in that clients manager their @@ -314,88 +289,75 @@ public: /// own locking externally to avoid multiple people writing to the file at /// the same time. /// - /// @param[in] src + /// \param[in] src /// A buffer containing the bytes to write. /// - /// @param[in,out] num_bytes + /// \param[in,out] num_bytes /// The number of bytes to write to the file at offset \a offset. /// \a num_bytes gets modified with the number of bytes that /// were read. /// - /// @param[in,out] offset + /// \param[in,out] offset /// The offset within the file at which to write \a num_bytes /// bytes. This offset gets incremented by the number of bytes /// that were written. /// - /// @return + /// \return /// An error object that indicates success or the reason for /// failure. - //------------------------------------------------------------------ Status Write(const void *src, size_t &num_bytes, off_t &offset); - //------------------------------------------------------------------ /// Flush the current stream /// - /// @return + /// \return /// An error object that indicates success or the reason for /// failure. - //------------------------------------------------------------------ Status Flush(); - //------------------------------------------------------------------ /// Sync to disk. /// - /// @return + /// \return /// An error object that indicates success or the reason for /// failure. - //------------------------------------------------------------------ Status Sync(); - //------------------------------------------------------------------ /// Get the permissions for a this file. /// - /// @return + /// \return /// Bits logical OR'ed together from the permission bits defined /// in lldb_private::File::Permissions. - //------------------------------------------------------------------ uint32_t GetPermissions(Status &error) const; - //------------------------------------------------------------------ /// Return true if this file is interactive. /// - /// @return + /// \return /// True if this file is a terminal (tty or pty), false /// otherwise. - //------------------------------------------------------------------ bool GetIsInteractive(); - //------------------------------------------------------------------ /// 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. /// - /// @return + /// \return /// True if this file is a terminal (tty, not a pty) that has /// a non-zero width and height, false otherwise. - //------------------------------------------------------------------ bool GetIsRealTerminal(); bool GetIsTerminalWithColors(); - //------------------------------------------------------------------ /// Output printf formatted output to the stream. /// /// Print some formatted output to the stream. /// - /// @param[in] format + /// \param[in] format /// A printf style format string. /// - /// @param[in] ... + /// \param[in] ... /// Variable arguments that are needed for the printf style /// format string \a format. - //------------------------------------------------------------------ size_t Printf(const char *format, ...) __attribute__((format(printf, 2, 3))); size_t PrintfVarArg(const char *format, va_list args); @@ -411,9 +373,7 @@ protected: void CalculateInteractiveAndTerminal(); - //------------------------------------------------------------------ // Member variables - //------------------------------------------------------------------ int m_descriptor; FILE *m_stream; uint32_t m_options; @@ -421,6 +381,7 @@ protected: LazyBool m_is_interactive; LazyBool m_is_real_terminal; LazyBool m_supports_colors; + std::mutex offset_access_mutex; private: DISALLOW_COPY_AND_ASSIGN(File); diff --git a/include/lldb/Target/FileAction.h b/include/lldb/Host/FileAction.h index f80f57ac588b5..4d333bb327a54 100644 --- a/include/lldb/Target/FileAction.h +++ b/include/lldb/Host/FileAction.h @@ -1,14 +1,13 @@ //===-- FileAction.h --------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// -#ifndef liblldb_Target_FileAction_h -#define liblldb_Target_FileAction_h +#ifndef LLDB_HOST_FILEACTION_H +#define LLDB_HOST_FILEACTION_H #include "lldb/Utility/FileSpec.h" #include <string> diff --git a/include/lldb/Host/FileCache.h b/include/lldb/Host/FileCache.h index 1c03540c1eb37..0c1ef1961645a 100644 --- a/include/lldb/Host/FileCache.h +++ b/include/lldb/Host/FileCache.h @@ -1,9 +1,8 @@ //===-- FileCache.h ---------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// #ifndef liblldb_Host_FileCache_h diff --git a/include/lldb/Host/FileSystem.h b/include/lldb/Host/FileSystem.h index 9e36649b00468..865b09b231030 100644 --- a/include/lldb/Host/FileSystem.h +++ b/include/lldb/Host/FileSystem.h @@ -1,9 +1,8 @@ //===-- FileSystem.h --------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -12,6 +11,7 @@ #include "lldb/Host/File.h" #include "lldb/Utility/DataBufferLLVM.h" +#include "lldb/Utility/FileCollector.h" #include "lldb/Utility/FileSpec.h" #include "lldb/Utility/Status.h" @@ -31,8 +31,15 @@ public: static const char *DEV_NULL; static const char *PATH_CONVERSION_ERROR; - FileSystem() : m_fs(llvm::vfs::getRealFileSystem()) {} - FileSystem(llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem> fs) : m_fs(fs) {} + FileSystem() + : m_fs(llvm::vfs::getRealFileSystem()), m_collector(nullptr), + m_mapped(false) {} + FileSystem(FileCollector &collector) + : m_fs(llvm::vfs::getRealFileSystem()), m_collector(&collector), + m_mapped(false) {} + FileSystem(llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem> fs, + bool mapped = false) + : m_fs(fs), m_collector(nullptr), m_mapped(mapped) {} FileSystem(const FileSystem &fs) = delete; FileSystem &operator=(const FileSystem &fs) = delete; @@ -40,6 +47,8 @@ public: static FileSystem &Instance(); static void Initialize(); + static void Initialize(FileCollector &collector); + static llvm::Error Initialize(const FileSpec &mapping); static void Initialize(llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem> fs); static void Terminate(); @@ -55,90 +64,91 @@ public: int Open(const char *path, int flags, int mode); Status Open(File &File, const FileSpec &file_spec, uint32_t options, - uint32_t permissions = lldb::eFilePermissionsFileDefault); + uint32_t permissions = lldb::eFilePermissionsFileDefault, + bool should_close_fd = true); /// Get a directory iterator. - /// @{ + /// \{ llvm::vfs::directory_iterator DirBegin(const FileSpec &file_spec, std::error_code &ec); llvm::vfs::directory_iterator DirBegin(const llvm::Twine &dir, std::error_code &ec); - /// @} + /// \} /// Returns the Status object for the given file. - /// @{ + /// \{ llvm::ErrorOr<llvm::vfs::Status> GetStatus(const FileSpec &file_spec) const; llvm::ErrorOr<llvm::vfs::Status> GetStatus(const llvm::Twine &path) const; - /// @} + /// \} /// Returns the modification time of the given file. - /// @{ + /// \{ llvm::sys::TimePoint<> GetModificationTime(const FileSpec &file_spec) const; llvm::sys::TimePoint<> GetModificationTime(const llvm::Twine &path) const; - /// @} + /// \} /// Returns the on-disk size of the given file in bytes. - /// @{ + /// \{ uint64_t GetByteSize(const FileSpec &file_spec) const; uint64_t GetByteSize(const llvm::Twine &path) const; - /// @} + /// \} /// Return the current permissions of the given file. /// /// Returns a bitmask for the current permissions of the file (zero or more /// of the permission bits defined in File::Permissions). - /// @{ + /// \{ uint32_t GetPermissions(const FileSpec &file_spec) const; uint32_t GetPermissions(const llvm::Twine &path) const; uint32_t GetPermissions(const FileSpec &file_spec, std::error_code &ec) const; uint32_t GetPermissions(const llvm::Twine &path, std::error_code &ec) const; - /// @} + /// \} /// Returns whether the given file exists. - /// @{ + /// \{ bool Exists(const FileSpec &file_spec) const; bool Exists(const llvm::Twine &path) const; - /// @} + /// \} /// Returns whether the given file is readable. - /// @{ + /// \{ bool Readable(const FileSpec &file_spec) const; bool Readable(const llvm::Twine &path) const; - /// @} + /// \} /// Returns whether the given path is a directory. - /// @{ + /// \{ bool IsDirectory(const FileSpec &file_spec) const; bool IsDirectory(const llvm::Twine &path) const; - /// @} + /// \} /// Returns whether the given path is local to the file system. - /// @{ + /// \{ bool IsLocal(const FileSpec &file_spec) const; bool IsLocal(const llvm::Twine &path) const; - /// @} + /// \} /// Make the given file path absolute. - /// @{ + /// \{ std::error_code MakeAbsolute(llvm::SmallVectorImpl<char> &path) const; std::error_code MakeAbsolute(FileSpec &file_spec) const; - /// @} + /// \} /// Resolve path to make it canonical. - /// @{ + /// \{ void Resolve(llvm::SmallVectorImpl<char> &path); void Resolve(FileSpec &file_spec); - /// @} + /// \} //// Create memory buffer from path. - /// @{ + /// \{ std::shared_ptr<DataBufferLLVM> CreateDataBuffer(const llvm::Twine &path, uint64_t size = 0, uint64_t offset = 0); std::shared_ptr<DataBufferLLVM> CreateDataBuffer(const FileSpec &file_spec, uint64_t size = 0, uint64_t offset = 0); - /// @} + /// \} /// Call into the Host to see if it can help find the file. bool ResolveExecutableLocation(FileSpec &file_spec); @@ -168,9 +178,18 @@ public: std::error_code GetRealPath(const llvm::Twine &path, llvm::SmallVectorImpl<char> &output) const; + llvm::ErrorOr<std::string> GetExternalPath(const llvm::Twine &path); + llvm::ErrorOr<std::string> GetExternalPath(const FileSpec &file_spec); + + llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem> GetVirtualFileSystem() { + return m_fs; + } + private: static llvm::Optional<FileSystem> &InstanceImpl(); llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem> m_fs; + FileCollector *m_collector; + bool m_mapped; }; } // namespace lldb_private diff --git a/include/lldb/Host/Host.h b/include/lldb/Host/Host.h index 459e9f563d1ee..884c5cf632134 100644 --- a/include/lldb/Host/Host.h +++ b/include/lldb/Host/Host.h @@ -1,9 +1,8 @@ //===-- Host.h --------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -27,10 +26,11 @@ namespace lldb_private { class FileAction; class ProcessLaunchInfo; +class ProcessInstanceInfo; +class ProcessInstanceInfoList; +class ProcessInstanceInfoMatch; -//---------------------------------------------------------------------- // Exit Type for inferior processes -//---------------------------------------------------------------------- struct WaitStatus { enum Type : uint8_t { Exit, // The status represents the return code from normal @@ -55,12 +55,10 @@ inline bool operator==(WaitStatus a, WaitStatus b) { inline bool operator!=(WaitStatus a, WaitStatus b) { return !(a == b); } -//---------------------------------------------------------------------- -/// @class Host Host.h "lldb/Host/Host.h" +/// \class Host Host.h "lldb/Host/Host.h" /// A class that provides host computer information. /// /// Host is a class that answers information about the host operating system. -//---------------------------------------------------------------------- class Host { public: typedef std::function<bool( @@ -69,7 +67,6 @@ public: int status)> // Exit value of process if signal is zero MonitorChildProcessCallback; - //------------------------------------------------------------------ /// Start monitoring a child process. /// /// Allows easy monitoring of child processes. \a callback will be called @@ -84,26 +81,25 @@ public: /// If the child process exits, the monitoring will automatically stop after /// the callback returned regardless of the callback return value. /// - /// @param[in] callback + /// \param[in] callback /// A function callback to call when a child receives a signal /// (if \a monitor_signals is true) or a child exits. /// - /// @param[in] pid + /// \param[in] pid /// The process ID of a child process to monitor, -1 for all /// processes. /// - /// @param[in] monitor_signals + /// \param[in] monitor_signals /// If \b true the callback will get called when the child /// process gets a signal. If \b false, the callback will only /// get called if the child process exits. /// - /// @return + /// \return /// A thread handle that can be used to cancel the thread that /// was spawned to monitor \a pid. /// - /// @see static void Host::StopMonitoringChildProcess (uint32_t) - //------------------------------------------------------------------ - static HostThread + /// \see static void Host::StopMonitoringChildProcess (uint32_t) + static llvm::Expected<HostThread> StartMonitoringChildProcess(const MonitorChildProcessCallback &callback, lldb::pid_t pid, bool monitor_signals); @@ -114,78 +110,68 @@ public: static void SystemLog(SystemLogType type, const char *format, va_list args); - //------------------------------------------------------------------ /// Get the process ID for the calling process. /// - /// @return + /// \return /// The process ID for the current process. - //------------------------------------------------------------------ static lldb::pid_t GetCurrentProcessID(); 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. /// - /// @return + /// \return /// The thread token for the calling thread in the current process. - //------------------------------------------------------------------ static lldb::thread_t GetCurrentThread(); 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. /// - /// @param[in] host_addr + /// \param[in] host_addr /// The pointer to some code in the current process. /// - /// @return + /// \return /// \b A file spec with the module that contains \a host_addr, /// which may be invalid if \a host_addr doesn't fall into /// any valid module address range. - //------------------------------------------------------------------ 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. /// - /// @param[in] file + /// \param[in] file /// A file spec that might point to a file in a bundle. /// - /// @param[out] bundle_directory + /// \param[out] bundle_directory /// An object will be filled in with the bundle directory for /// the bundle when \b true is returned. Otherwise \a file is /// left untouched and \b false is returned. /// - /// @return + /// \return /// \b true if \a file was resolved in \a bundle_directory, /// \b false otherwise. - //------------------------------------------------------------------ static bool GetBundleDirectory(const FileSpec &file, 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. /// - /// @param[in,out] file + /// \param[in,out] file /// A file spec that currently points to the bundle that will /// be filled in with the executable path within the bundle /// if \b true is returned. Otherwise \a file is left untouched. /// - /// @return + /// \return /// \b true if \a file was resolved, \b false if this function /// was not able to resolve the path. - //------------------------------------------------------------------ static bool ResolveExecutableInBundle(FileSpec &file); static uint32_t FindProcesses(const ProcessInstanceInfoMatch &match_info, @@ -197,44 +183,47 @@ public: static bool GetProcessInfo(lldb::pid_t pid, ProcessInstanceInfo &proc_info); - 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 - // environment variable replacement, and whatever other - // argument magic the platform defines as part of its typical - // user experience - //------------------------------------------------------------------ + /// environment variable replacement, and whatever other + /// argument magic the platform defines as part of its typical + /// user experience static Status ShellExpandArguments(ProcessLaunchInfo &launch_info); - // TODO: Convert this function to take a StringRef. - static Status RunShellCommand( - const char *command, // Shouldn't be NULL - const FileSpec &working_dir, // Pass empty FileSpec to use the current - // working directory - int *status_ptr, // Pass NULL if you don't want the process exit status - int *signo_ptr, // Pass NULL if you don't want the signal that caused the - // process to exit - std::string - *command_output, // Pass NULL if you don't want the command output - const Timeout<std::micro> &timeout, bool run_in_default_shell = true); - - static Status RunShellCommand( - const Args &args, - const FileSpec &working_dir, // Pass empty FileSpec to use the current - // working directory - int *status_ptr, // Pass NULL if you don't want the process exit status - int *signo_ptr, // Pass NULL if you don't want the signal that caused the - // process to exit - std::string - *command_output, // Pass NULL if you don't want the command output - const Timeout<std::micro> &timeout, bool run_in_default_shell = true); + /// Run a shell command. + /// \arg command shouldn't be NULL + /// \arg working_dir Pass empty FileSpec to use the current working directory + /// \arg status_ptr Pass NULL if you don't want the process exit status + /// \arg signo_ptr Pass NULL if you don't want the signal that caused the + /// process to exit + /// \arg command_output Pass NULL if you don't want the command output + /// \arg hide_stderr if this is false, redirect stderr to stdout + /// TODO: Convert this function to take a StringRef. + static Status RunShellCommand(const char *command, + const FileSpec &working_dir, int *status_ptr, + int *signo_ptr, std::string *command_output, + const Timeout<std::micro> &timeout, + bool run_in_default_shell = true, + bool hide_stderr = false); + + /// Run a shell command. + /// \arg working_dir Pass empty FileSpec to use the current working directory + /// \arg status_ptr Pass NULL if you don't want the process exit status + /// \arg signo_ptr Pass NULL if you don't want the signal that caused the + /// process to exit + /// \arg command_output Pass NULL if you don't want the command output + /// \arg hide_stderr if this is false, redirect stderr to stdout + static Status RunShellCommand(const Args &args, const FileSpec &working_dir, + int *status_ptr, int *signo_ptr, + std::string *command_output, + const Timeout<std::micro> &timeout, + bool run_in_default_shell = true, + bool hide_stderr = false); static bool OpenFileInExternalEditor(const FileSpec &file_spec, uint32_t line_no); diff --git a/include/lldb/Host/HostGetOpt.h b/include/lldb/Host/HostGetOpt.h index d37a2526ff049..dedeb2e2fcc3e 100644 --- a/include/lldb/Host/HostGetOpt.h +++ b/include/lldb/Host/HostGetOpt.h @@ -1,9 +1,8 @@ -//===-- GetOpt.h ------------------------------------------------*- C++ -*-===// +//===-- HostGetOpt.h --------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// #pragma once diff --git a/include/lldb/Host/HostInfo.h b/include/lldb/Host/HostInfo.h index df762d7160e05..196127d407635 100644 --- a/include/lldb/Host/HostInfo.h +++ b/include/lldb/Host/HostInfo.h @@ -1,17 +1,15 @@ -//===-- HostInfoBase.h ------------------------------------------*- C++ -*-===// +//===-- HostInfo.h ----------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// #ifndef lldb_Host_HostInfo_h_ #define lldb_Host_HostInfo_h_ -//---------------------------------------------------------------------- -/// @class HostInfo HostInfo.h "lldb/Host/HostInfo.h" +/// \class HostInfo HostInfo.h "lldb/Host/HostInfo.h" /// A class that provides host computer information. /// /// HostInfo is a class that answers information about the host operating @@ -33,7 +31,6 @@ /// method and if used in a context where the method doesn't make sense, will /// generate a compiler error. /// -//---------------------------------------------------------------------- #if defined(_WIN32) #include "lldb/Host/windows/HostInfoWindows.h" diff --git a/include/lldb/Host/HostInfoBase.h b/include/lldb/Host/HostInfoBase.h index f3e49c8f25d72..6f6688941ac7a 100644 --- a/include/lldb/Host/HostInfoBase.h +++ b/include/lldb/Host/HostInfoBase.h @@ -1,9 +1,8 @@ //===-- HostInfoBase.h ------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -12,8 +11,8 @@ #include "lldb/Utility/ArchSpec.h" #include "lldb/Utility/FileSpec.h" +#include "lldb/Utility/UserIDResolver.h" #include "lldb/lldb-enumerations.h" - #include "llvm/ADT/StringRef.h" #include <stdint.h> @@ -34,21 +33,17 @@ public: static void Initialize(); static void Terminate(); - //------------------------------------------------------------------ /// Gets the host target triple as a const string. /// - /// @return + /// \return /// A const string object containing the host target triple. - //------------------------------------------------------------------ static llvm::StringRef GetTargetTriple(); - //------------------------------------------------------------------ /// Gets the host architecture. /// - /// @return + /// \return /// A const architecture object that represents the host /// architecture. - //------------------------------------------------------------------ enum ArchitectureKind { eArchKindDefault, // The overall default architecture that applications will // run on this host @@ -93,13 +88,14 @@ public: /// FileSpec is filled in. static FileSpec GetGlobalTempDir(); - //--------------------------------------------------------------------------- /// If the triple does not specify the vendor, os, and environment parts, we /// "augment" these using information from the host and return the resulting /// ArchSpec object. - //--------------------------------------------------------------------------- static ArchSpec GetAugmentedArchSpec(llvm::StringRef triple); + static bool ComputePathRelativeToLibrary(FileSpec &file_spec, + llvm::StringRef dir); + protected: static bool ComputeSharedLibraryDirectory(FileSpec &file_spec); static bool ComputeSupportExeDirectory(FileSpec &file_spec); diff --git a/include/lldb/Host/HostNativeProcess.h b/include/lldb/Host/HostNativeProcess.h index 0aabfe197385a..c86a2aef38fce 100644 --- a/include/lldb/Host/HostNativeProcess.h +++ b/include/lldb/Host/HostNativeProcess.h @@ -1,9 +1,8 @@ //===-- HostNativeProcess.h -------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// diff --git a/include/lldb/Host/HostNativeProcessBase.h b/include/lldb/Host/HostNativeProcessBase.h index 07f98c24776c2..aaa517d532172 100644 --- a/include/lldb/Host/HostNativeProcessBase.h +++ b/include/lldb/Host/HostNativeProcessBase.h @@ -1,9 +1,8 @@ //===-- HostNativeProcessBase.h ---------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -36,7 +35,7 @@ public: lldb::process_t GetSystemHandle() const { return m_process; } - virtual HostThread + virtual llvm::Expected<HostThread> StartMonitoring(const Host::MonitorChildProcessCallback &callback, bool monitor_signals) = 0; diff --git a/include/lldb/Host/HostNativeThread.h b/include/lldb/Host/HostNativeThread.h index e33d978d5ae43..8bf65849d880f 100644 --- a/include/lldb/Host/HostNativeThread.h +++ b/include/lldb/Host/HostNativeThread.h @@ -1,9 +1,8 @@ //===-- HostNativeThread.h --------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// diff --git a/include/lldb/Host/HostNativeThreadBase.h b/include/lldb/Host/HostNativeThreadBase.h index 326a9c6c793f3..a196f0bc82ca2 100644 --- a/include/lldb/Host/HostNativeThreadBase.h +++ b/include/lldb/Host/HostNativeThreadBase.h @@ -1,9 +1,8 @@ //===-- HostNativeThreadBase.h ----------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// diff --git a/include/lldb/Host/HostNativeThreadForward.h b/include/lldb/Host/HostNativeThreadForward.h index 4691a22ac8440..261d3c7a836e2 100644 --- a/include/lldb/Host/HostNativeThreadForward.h +++ b/include/lldb/Host/HostNativeThreadForward.h @@ -1,9 +1,8 @@ //===-- HostNativeThreadForward.h -------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// diff --git a/include/lldb/Host/HostProcess.h b/include/lldb/Host/HostProcess.h index 626ebab7ce686..d48ff1fc90eef 100644 --- a/include/lldb/Host/HostProcess.h +++ b/include/lldb/Host/HostProcess.h @@ -1,9 +1,8 @@ //===-- HostProcess.h ------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -13,8 +12,7 @@ #include "lldb/Host/Host.h" #include "lldb/lldb-types.h" -//---------------------------------------------------------------------- -/// @class HostInfo HostInfo.h "lldb/Host/HostProcess.h" +/// \class HostInfo HostInfo.h "lldb/Host/HostProcess.h" /// A class that represents a running process on the host machine. /// /// HostProcess allows querying and manipulation of processes running on the @@ -27,7 +25,6 @@ /// statically to the concrete Process implementation for that platform. See /// HostInfo for more details. /// -//---------------------------------------------------------------------- namespace lldb_private { @@ -46,8 +43,9 @@ public: lldb::pid_t GetProcessId() const; bool IsRunning() const; - HostThread StartMonitoring(const Host::MonitorChildProcessCallback &callback, - bool monitor_signals); + llvm::Expected<HostThread> + StartMonitoring(const Host::MonitorChildProcessCallback &callback, + bool monitor_signals); HostNativeProcessBase &GetNativeProcess(); const HostNativeProcessBase &GetNativeProcess() const; diff --git a/include/lldb/Host/HostThread.h b/include/lldb/Host/HostThread.h index 120776283aa42..7bf2a1dc2db94 100644 --- a/include/lldb/Host/HostThread.h +++ b/include/lldb/Host/HostThread.h @@ -1,9 +1,8 @@ //===-- HostThread.h --------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -20,15 +19,13 @@ namespace lldb_private { class HostNativeThreadBase; -//---------------------------------------------------------------------- -/// @class HostInfo HostInfo.h "lldb/Host/HostThread.h" +/// \class HostInfo HostInfo.h "lldb/Host/HostThread.h" /// 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 /// machine. /// -//---------------------------------------------------------------------- class HostThread { public: HostThread(); diff --git a/include/lldb/Host/LockFile.h b/include/lldb/Host/LockFile.h index 81cb10c7fbcb4..2a1cd3dbb8f73 100644 --- a/include/lldb/Host/LockFile.h +++ b/include/lldb/Host/LockFile.h @@ -1,9 +1,8 @@ //===-- LockFile.h ----------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// diff --git a/include/lldb/Host/LockFileBase.h b/include/lldb/Host/LockFileBase.h index 4eda1916c72e9..be9e258c5c2d6 100644 --- a/include/lldb/Host/LockFileBase.h +++ b/include/lldb/Host/LockFileBase.h @@ -1,9 +1,8 @@ //===-- LockFileBase.h ------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// diff --git a/include/lldb/Host/MainLoop.h b/include/lldb/Host/MainLoop.h index 13d1ff0212fa4..d59aa28ccb0ed 100644 --- a/include/lldb/Host/MainLoop.h +++ b/include/lldb/Host/MainLoop.h @@ -1,9 +1,8 @@ //===-- MainLoop.h ----------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// diff --git a/include/lldb/Host/MainLoopBase.h b/include/lldb/Host/MainLoopBase.h index bf01ba16db0ec..3fee2b2c09d8c 100644 --- a/include/lldb/Host/MainLoopBase.h +++ b/include/lldb/Host/MainLoopBase.h @@ -1,9 +1,8 @@ //===-- MainLoopBase.h ------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// diff --git a/include/lldb/Host/MonitoringProcessLauncher.h b/include/lldb/Host/MonitoringProcessLauncher.h index 179823efb966f..59111a04fc98f 100644 --- a/include/lldb/Host/MonitoringProcessLauncher.h +++ b/include/lldb/Host/MonitoringProcessLauncher.h @@ -1,9 +1,8 @@ //===-- MonitoringProcessLauncher.h -----------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// diff --git a/include/lldb/Host/OptionParser.h b/include/lldb/Host/OptionParser.h index 1b0dc4ae19e00..b03eeb74ec4e0 100644 --- a/include/lldb/Host/OptionParser.h +++ b/include/lldb/Host/OptionParser.h @@ -1,9 +1,8 @@ //===-- OptionParser.h ------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -14,6 +13,7 @@ #include <string> #include "llvm/ADT/StringRef.h" +#include "llvm/ADT/ArrayRef.h" struct option; @@ -38,8 +38,11 @@ public: static void EnableError(bool error); - static int Parse(int argc, char *const argv[], llvm::StringRef optstring, - const Option *longopts, int *longindex); + /// Argv must be an argument vector "as passed to main", i.e. terminated with + /// a nullptr. + static int Parse(llvm::MutableArrayRef<char *> argv, + llvm::StringRef optstring, const Option *longopts, + int *longindex); static char *GetOptionArgument(); static int GetOptionIndex(); diff --git a/include/lldb/Host/Pipe.h b/include/lldb/Host/Pipe.h index 283fb1b83c250..ea75342e54270 100644 --- a/include/lldb/Host/Pipe.h +++ b/include/lldb/Host/Pipe.h @@ -1,9 +1,8 @@ //===-- Pipe.h --------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// diff --git a/include/lldb/Host/PipeBase.h b/include/lldb/Host/PipeBase.h index 88bd703960c41..1aa4db339b29e 100644 --- a/include/lldb/Host/PipeBase.h +++ b/include/lldb/Host/PipeBase.h @@ -1,10 +1,9 @@ //===-- PipeBase.h -----------------------------------------------*- C++ //-*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// diff --git a/include/lldb/Host/PosixApi.h b/include/lldb/Host/PosixApi.h index dae2bb4800916..04ca3a84983b9 100644 --- a/include/lldb/Host/PosixApi.h +++ b/include/lldb/Host/PosixApi.h @@ -1,9 +1,8 @@ //===-- PosixApi.h ----------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// diff --git a/include/lldb/Target/ProcessLaunchInfo.h b/include/lldb/Host/ProcessLaunchInfo.h index ef1d63035b18c..d068aa636bc7f 100644 --- a/include/lldb/Target/ProcessLaunchInfo.h +++ b/include/lldb/Host/ProcessLaunchInfo.h @@ -1,9 +1,8 @@ //===-- ProcessLaunchInfo.h -------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -16,19 +15,17 @@ // LLDB Headers #include "lldb/Utility/Flags.h" +#include "lldb/Host/FileAction.h" #include "lldb/Host/Host.h" #include "lldb/Host/PseudoTerminal.h" -#include "lldb/Target/FileAction.h" -#include "lldb/Target/ProcessInfo.h" #include "lldb/Utility/FileSpec.h" +#include "lldb/Utility/ProcessInfo.h" namespace lldb_private { -//---------------------------------------------------------------------- // ProcessLaunchInfo // // Describes any information that is required to launch a process. -//---------------------------------------------------------------------- class ProcessLaunchInfo : public ProcessInfo { public: diff --git a/include/lldb/Host/ProcessLauncher.h b/include/lldb/Host/ProcessLauncher.h index 49fa84113f6c3..a5b6a6c76bbad 100644 --- a/include/lldb/Host/ProcessLauncher.h +++ b/include/lldb/Host/ProcessLauncher.h @@ -1,9 +1,8 @@ //===-- ProcessLauncher.h ---------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// diff --git a/include/lldb/Host/ProcessRunLock.h b/include/lldb/Host/ProcessRunLock.h index 272772fedce1a..4927fbbf78215 100644 --- a/include/lldb/Host/ProcessRunLock.h +++ b/include/lldb/Host/ProcessRunLock.h @@ -1,9 +1,8 @@ //===-- ProcessRunLock.h ----------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -15,17 +14,13 @@ #include "lldb/lldb-defines.h" -//---------------------------------------------------------------------- /// Enumerations for broadcasting. -//---------------------------------------------------------------------- namespace lldb_private { -//---------------------------------------------------------------------- -/// @class ProcessRunLock ProcessRunLock.h "lldb/Host/ProcessRunLock.h" +/// \class ProcessRunLock ProcessRunLock.h "lldb/Host/ProcessRunLock.h" /// 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 { public: diff --git a/include/lldb/Host/PseudoTerminal.h b/include/lldb/Host/PseudoTerminal.h index 858bd35f73a6a..8b27890ddeebb 100644 --- a/include/lldb/Host/PseudoTerminal.h +++ b/include/lldb/Host/PseudoTerminal.h @@ -1,9 +1,8 @@ //===-- PseudoTerminal.h ----------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -17,47 +16,36 @@ namespace lldb_private { -//---------------------------------------------------------------------- -/// @class PseudoTerminal PseudoTerminal.h "lldb/Host/PseudoTerminal.h" +/// \class PseudoTerminal PseudoTerminal.h "lldb/Host/PseudoTerminal.h" /// A pseudo terminal helper class. /// /// The pseudo terminal class abstracts the use of pseudo terminals on the /// host system. -//---------------------------------------------------------------------- class PseudoTerminal { public: enum { invalid_fd = -1 ///< Invalid file descriptor value }; - //------------------------------------------------------------------ /// Default constructor /// /// 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() - //------------------------------------------------------------------ ~PseudoTerminal(); - //------------------------------------------------------------------ /// Close the master file descriptor if it is valid. - //------------------------------------------------------------------ void CloseMasterFileDescriptor(); - //------------------------------------------------------------------ /// Close the slave file descriptor if it is valid. - //------------------------------------------------------------------ void CloseSlaveFileDescriptor(); - //------------------------------------------------------------------ /// 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 @@ -73,18 +61,16 @@ public: /// PseudoTerminal::ReleaseMasterFileDescriptor() @li /// PseudoTerminal::ReleaseSaveFileDescriptor() /// - /// @param[out] error + /// \param[out] error /// An pointer to an error that can describe any errors that /// occur. This can be NULL if no error status is desired. /// - /// @return - /// @li \b Parent process: a child process ID that is greater + /// \return + /// \li \b Parent process: a child process ID that is greater /// than zero, or -1 if the fork fails. - /// @li \b Child process: zero. - //------------------------------------------------------------------ + /// \li \b Child process: zero. lldb::pid_t Fork(char *error_str, size_t error_len); - //------------------------------------------------------------------ /// The master file descriptor accessor. /// /// This object retains ownership of the master file descriptor when this @@ -92,15 +78,13 @@ public: /// PseudoTerminal::ReleaseMasterFileDescriptor() if this object should /// release ownership of the slave file descriptor. /// - /// @return + /// \return /// The master file descriptor, or PseudoTerminal::invalid_fd /// if the master file descriptor is not currently valid. /// - /// @see PseudoTerminal::ReleaseMasterFileDescriptor() - //------------------------------------------------------------------ + /// \see PseudoTerminal::ReleaseMasterFileDescriptor() int GetMasterFileDescriptor() const; - //------------------------------------------------------------------ /// The slave file descriptor accessor. /// /// This object retains ownership of the slave file descriptor when this @@ -108,25 +92,23 @@ public: /// PseudoTerminal::ReleaseSlaveFileDescriptor() if this object should /// release ownership of the slave file descriptor. /// - /// @return + /// \return /// The slave file descriptor, or PseudoTerminal::invalid_fd /// if the slave file descriptor is not currently valid. /// - /// @see PseudoTerminal::ReleaseSlaveFileDescriptor() - //------------------------------------------------------------------ + /// \see PseudoTerminal::ReleaseSlaveFileDescriptor() int GetSlaveFileDescriptor() const; - //------------------------------------------------------------------ /// Get the name of the slave pseudo terminal. /// /// A master pseudo terminal should already be valid prior to /// calling this function. /// - /// @param[out] error + /// \param[out] error /// An pointer to an error that can describe any errors that /// occur. This can be NULL if no error status is desired. /// - /// @return + /// \return /// The name of the slave pseudo terminal as a NULL terminated /// C. This string that comes from static memory, so a copy of /// the string should be made as subsequent calls can change @@ -134,11 +116,9 @@ public: /// a valid master pseudo terminal opened or if the call to /// \c ptsname() fails. /// - /// @see PseudoTerminal::OpenFirstAvailableMaster() - //------------------------------------------------------------------ + /// \see PseudoTerminal::OpenFirstAvailableMaster() const char *GetSlaveName(char *error_str, size_t error_len) const; - //------------------------------------------------------------------ /// Open the first available pseudo terminal. /// /// Opens the first available pseudo terminal with \a oflag as the @@ -152,25 +132,23 @@ public: /// If this object still has a valid master file descriptor when its /// destructor is called, it will close it. /// - /// @param[in] oflag + /// \param[in] oflag /// Flags to use when calling \c posix_openpt(\a oflag). /// A value of "O_RDWR|O_NOCTTY" is suggested. /// - /// @param[out] error + /// \param[out] error /// An pointer to an error that can describe any errors that /// occur. This can be NULL if no error status is desired. /// - /// @return - /// @li \b true when the master files descriptor is + /// \return + /// \li \b true when the master files descriptor is /// successfully opened. - /// @li \b false if anything goes wrong. + /// \li \b false if anything goes wrong. /// - /// @see PseudoTerminal::GetMasterFileDescriptor() @see + /// \see PseudoTerminal::GetMasterFileDescriptor() @see /// PseudoTerminal::ReleaseMasterFileDescriptor() - //------------------------------------------------------------------ bool OpenFirstAvailableMaster(int oflag, char *error_str, size_t error_len); - //------------------------------------------------------------------ /// Open the slave for the current master pseudo terminal. /// /// A master pseudo terminal should already be valid prior to @@ -184,25 +162,23 @@ public: /// If this object still has a valid slave file descriptor when its /// destructor is called, it will close it. /// - /// @param[in] oflag + /// \param[in] oflag /// Flags to use when calling \c open(\a oflag). /// - /// @param[out] error + /// \param[out] error /// An pointer to an error that can describe any errors that /// occur. This can be NULL if no error status is desired. /// - /// @return - /// @li \b true when the master files descriptor is + /// \return + /// \li \b true when the master files descriptor is /// successfully opened. - /// @li \b false if anything goes wrong. + /// \li \b false if anything goes wrong. /// - /// @see PseudoTerminal::OpenFirstAvailableMaster() @see + /// \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 @@ -210,13 +186,11 @@ public: /// descriptor if the ownership isn't released using this call and the /// master file descriptor has been opened. /// - /// @return + /// \return /// The master file descriptor, or PseudoTerminal::invalid_fd /// if the mast file descriptor is not currently valid. - //------------------------------------------------------------------ int ReleaseMasterFileDescriptor(); - //------------------------------------------------------------------ /// Release the slave file descriptor. /// /// Release ownership of the slave pseudo terminal file descriptor without @@ -224,16 +198,13 @@ public: /// descriptor if the ownership isn't released using this call and the slave /// file descriptor has been opened. /// - /// @return + /// \return /// The slave file descriptor, or PseudoTerminal::invalid_fd /// if the slave file descriptor is not currently valid. - //------------------------------------------------------------------ int ReleaseSlaveFileDescriptor(); protected: - //------------------------------------------------------------------ // Member variables - //------------------------------------------------------------------ int m_master_fd; ///< The file descriptor for the master. int m_slave_fd; ///< The file descriptor for the slave. diff --git a/include/lldb/Host/SafeMachO.h b/include/lldb/Host/SafeMachO.h index 1565b313f42b6..ec9887ececd5a 100644 --- a/include/lldb/Host/SafeMachO.h +++ b/include/lldb/Host/SafeMachO.h @@ -1,9 +1,8 @@ //===-- SafeMachO.h -----------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// #ifndef liblldb_SafeMachO_h_ diff --git a/include/lldb/Host/Socket.h b/include/lldb/Host/Socket.h index 8b7f9fa4ed933..6f96bd73e753e 100644 --- a/include/lldb/Host/Socket.h +++ b/include/lldb/Host/Socket.h @@ -1,9 +1,8 @@ //===-- Socket.h ------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -40,17 +39,20 @@ typedef int NativeSocket; class Socket : public IOObject { public: - typedef enum { + enum SocketProtocol { ProtocolTcp, ProtocolUdp, ProtocolUnixDomain, ProtocolUnixAbstract - } SocketProtocol; + }; static const NativeSocket kInvalidSocketValue; ~Socket() override; + static llvm::Error Initialize(); + static void Terminate(); + static std::unique_ptr<Socket> Create(const SocketProtocol protocol, bool child_processes_inherit, Status &error); @@ -100,6 +102,9 @@ public: std::string &host_str, std::string &port_str, int32_t &port, Status *error_ptr); + // If this Socket is connected then return the URI used to connect. + virtual std::string GetRemoteConnectionURI() const { return ""; }; + protected: Socket(SocketProtocol protocol, bool should_close, bool m_child_process_inherit); diff --git a/include/lldb/Host/SocketAddress.h b/include/lldb/Host/SocketAddress.h index 5e54ef1d8e0ce..620827ff6eb10 100644 --- a/include/lldb/Host/SocketAddress.h +++ b/include/lldb/Host/SocketAddress.h @@ -1,9 +1,8 @@ //===-- SocketAddress.h -----------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -34,28 +33,21 @@ namespace lldb_private { class SocketAddress { public: - //---------------------------------------------------------------------------- // Static method to get all address information for a host and/or service - //---------------------------------------------------------------------------- static std::vector<SocketAddress> GetAddressInfo(const char *hostname, const char *servname, int ai_family, int ai_socktype, int ai_protocol, int ai_flags = 0); - //------------------------------------------------------------------ // Constructors and Destructors - //------------------------------------------------------------------ SocketAddress(); SocketAddress(const struct addrinfo *addr_info); SocketAddress(const struct sockaddr &s); SocketAddress(const struct sockaddr_in &s); SocketAddress(const struct sockaddr_in6 &s); SocketAddress(const struct sockaddr_storage &s); - SocketAddress(const SocketAddress &rhs); ~SocketAddress(); - //------------------------------------------------------------------ // Operators - //------------------------------------------------------------------ const SocketAddress &operator=(const SocketAddress &rhs); const SocketAddress &operator=(const struct addrinfo *addr_info); @@ -71,53 +63,35 @@ public: bool operator==(const SocketAddress &rhs) const; bool operator!=(const SocketAddress &rhs) const; - //------------------------------------------------------------------ // Clear the contents of this socket address - //------------------------------------------------------------------ void Clear(); - //------------------------------------------------------------------ // Get the length for the current socket address family - //------------------------------------------------------------------ socklen_t GetLength() const; - //------------------------------------------------------------------ // Get the max length for the largest socket address supported. - //------------------------------------------------------------------ static socklen_t GetMaxLength(); - //------------------------------------------------------------------ // Get the socket address family - //------------------------------------------------------------------ sa_family_t GetFamily() const; - //------------------------------------------------------------------ // Set the socket address family - //------------------------------------------------------------------ void SetFamily(sa_family_t family); - //------------------------------------------------------------------ // Get the address - //------------------------------------------------------------------ std::string GetIPAddress() const; - //------------------------------------------------------------------ // Get the port if the socket address for the family has a port - //------------------------------------------------------------------ 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. - //------------------------------------------------------------------ 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. - //------------------------------------------------------------------ bool getaddrinfo(const char *host, // Hostname ("foo.bar.com" or "foo" or IP // address string ("123.234.12.1" or @@ -127,33 +101,23 @@ public: int ai_family = PF_UNSPEC, int ai_socktype = 0, 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. - //------------------------------------------------------------------ bool SetToLocalhost(sa_family_t family, uint16_t port); bool SetToAnyAddress(sa_family_t family, uint16_t port); - //------------------------------------------------------------------ // Returns true if there is a valid socket address in this object. - //------------------------------------------------------------------ bool IsValid() const; - //------------------------------------------------------------------ // Returns true if the socket is INADDR_ANY - //------------------------------------------------------------------ bool IsAnyAddr() const; - //------------------------------------------------------------------ // Returns true if the socket is INADDR_LOOPBACK - //------------------------------------------------------------------ bool IsLocalhost() const; - //------------------------------------------------------------------ // Direct access to all of the sockaddr structures - //------------------------------------------------------------------ struct sockaddr &sockaddr() { return m_socket_addr.sa; } @@ -184,12 +148,10 @@ public: return m_socket_addr.sa_storage; } - //------------------------------------------------------------------ // 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; } @@ -219,9 +181,7 @@ protected: struct sockaddr_storage sa_storage; } sockaddr_t; - //------------------------------------------------------------------ // Classes that inherit from SocketAddress can see and modify these - //------------------------------------------------------------------ sockaddr_t m_socket_addr; }; diff --git a/include/lldb/Host/StringConvert.h b/include/lldb/Host/StringConvert.h index 1a85471a20c22..4b2c6901a96b0 100644 --- a/include/lldb/Host/StringConvert.h +++ b/include/lldb/Host/StringConvert.h @@ -1,9 +1,8 @@ //===-- StringConvert.h -----------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -18,10 +17,8 @@ namespace lldb_private { namespace StringConvert { -//---------------------------------------------------------------------- -/// @namespace StringConvert StringConvert.h "lldb/Host/StringConvert.h" +/// \namespace StringConvert StringConvert.h "lldb/Host/StringConvert.h" /// Utility classes for converting strings into Integers -//---------------------------------------------------------------------- int32_t ToSInt32(const char *s, int32_t fail_value = 0, int base = 0, bool *success_ptr = nullptr); diff --git a/include/lldb/Host/TaskPool.h b/include/lldb/Host/TaskPool.h index 4001d187a2a9d..49805ce193ed0 100644 --- a/include/lldb/Host/TaskPool.h +++ b/include/lldb/Host/TaskPool.h @@ -1,9 +1,8 @@ //===--------------------- TaskPool.h ---------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// diff --git a/include/lldb/Host/Terminal.h b/include/lldb/Host/Terminal.h index 193b6d21d51e5..e5e96eeda3fe7 100644 --- a/include/lldb/Host/Terminal.h +++ b/include/lldb/Host/Terminal.h @@ -1,9 +1,8 @@ //===-- Terminal.h ----------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -42,170 +41,136 @@ protected: int m_fd; // This may or may not be a terminal file descriptor }; -//---------------------------------------------------------------------- -/// @class State Terminal.h "lldb/Host/Terminal.h" +/// \class State Terminal.h "lldb/Host/Terminal.h" /// 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. -//---------------------------------------------------------------------- class TerminalState { public: - //------------------------------------------------------------------ /// Default constructor - //------------------------------------------------------------------ TerminalState(); - //------------------------------------------------------------------ /// Destructor - //------------------------------------------------------------------ ~TerminalState(); - //------------------------------------------------------------------ /// 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. /// - /// @param[in] fd + /// \param[in] fd /// The file descriptor to save the state of. /// - /// @param[in] save_process_group + /// \param[in] save_process_group /// If \b true, save the process group settings, else do not /// save the process group settings for a TTY. /// - /// @return + /// \return /// Returns \b true if \a fd describes a TTY and if the state /// was able to be saved, \b false otherwise. - //------------------------------------------------------------------ bool Save(int fd, bool save_process_group); - //------------------------------------------------------------------ /// 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). /// - /// @return + /// \return /// Returns \b true if the TTY state was successfully restored, /// \b false otherwise. - //------------------------------------------------------------------ bool Restore() const; - //------------------------------------------------------------------ /// Test for valid cached TTY state information. /// - /// @return + /// \return /// Returns \b true if this object has valid saved TTY state /// settings that can be used to restore a previous state, /// \b false otherwise. - //------------------------------------------------------------------ bool IsValid() const; void Clear(); protected: - //------------------------------------------------------------------ /// Test if tflags is valid. /// - /// @return + /// \return /// Returns \b true if \a m_tflags is valid and can be restored, /// \b false otherwise. - //------------------------------------------------------------------ bool TFlagsIsValid() const; - //------------------------------------------------------------------ /// Test if ttystate is valid. /// - /// @return + /// \return /// Returns \b true if \a m_ttystate is valid and can be /// restored, \b false otherwise. - //------------------------------------------------------------------ bool TTYStateIsValid() const; - //------------------------------------------------------------------ /// Test if the process group information is valid. /// - /// @return + /// \return /// Returns \b true if \a m_process_group is valid and can be /// restored, \b false otherwise. - //------------------------------------------------------------------ bool ProcessGroupIsValid() const; - //------------------------------------------------------------------ // Member variables - //------------------------------------------------------------------ Terminal m_tty; ///< A terminal int m_tflags; ///< Cached tflags information. #ifdef LLDB_CONFIG_TERMIOS_SUPPORTED std::unique_ptr<struct termios> - m_termios_ap; ///< Cached terminal state information. + m_termios_up; ///< Cached terminal state information. #endif lldb::pid_t m_process_group; ///< Cached process group information. }; -//---------------------------------------------------------------------- -/// @class TerminalStateSwitcher Terminal.h "lldb/Host/Terminal.h" +/// \class TerminalStateSwitcher Terminal.h "lldb/Host/Terminal.h" /// 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. -//---------------------------------------------------------------------- class TerminalStateSwitcher { public: - //------------------------------------------------------------------ /// Constructor - //------------------------------------------------------------------ TerminalStateSwitcher(); - //------------------------------------------------------------------ /// Destructor - //------------------------------------------------------------------ ~TerminalStateSwitcher(); - //------------------------------------------------------------------ /// Get the number of possible states to save. /// - /// @return + /// \return /// The number of states that this TTY switcher object contains. - //------------------------------------------------------------------ uint32_t GetNumberOfStates() const; - //------------------------------------------------------------------ /// Restore the TTY state for state at index \a idx. /// - /// @return + /// \return /// Returns \b true if the TTY state was successfully restored, /// \b false otherwise. - //------------------------------------------------------------------ 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. /// - /// @param[in] idx + /// \param[in] idx /// The index into the state array where the state should be /// saved. /// - /// @param[in] fd + /// \param[in] fd /// The file descriptor for which to save the settings. /// - /// @param[in] save_process_group + /// \param[in] save_process_group /// If \b true, save the process group information for the TTY. /// - /// @return + /// \return /// Returns \b true if the save was successful, \b false /// otherwise. - //------------------------------------------------------------------ bool Save(uint32_t idx, int fd, bool save_process_group); protected: - //------------------------------------------------------------------ // Member variables - //------------------------------------------------------------------ mutable uint32_t m_currentState; ///< The currently active TTY state index. TerminalState m_ttystates[2]; ///< The array of TTY states that holds saved TTY info. diff --git a/include/lldb/Host/ThreadLauncher.h b/include/lldb/Host/ThreadLauncher.h index b50f0e2c2c433..e45ffa9df7571 100644 --- a/include/lldb/Host/ThreadLauncher.h +++ b/include/lldb/Host/ThreadLauncher.h @@ -1,10 +1,8 @@ -//===-- ThreadLauncher.h -----------------------------------------*- C++ -//-*-===// +//===-- ThreadLauncher.h ----------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -12,18 +10,18 @@ #define lldb_Host_ThreadLauncher_h_ #include "lldb/Host/HostThread.h" -#include "lldb/Utility/Status.h" #include "lldb/lldb-types.h" #include "llvm/ADT/StringRef.h" +#include "llvm/Support/Error.h" namespace lldb_private { class ThreadLauncher { public: - static HostThread + static llvm::Expected<HostThread> LaunchThread(llvm::StringRef name, lldb::thread_func_t thread_function, - lldb::thread_arg_t thread_arg, Status *error_ptr, + lldb::thread_arg_t thread_arg, size_t min_stack_byte_size = 0); // Minimum stack size in bytes, // set stack size to zero for // default platform thread stack diff --git a/include/lldb/Host/Time.h b/include/lldb/Host/Time.h index 3be30dd03375d..b27eb082167e1 100644 --- a/include/lldb/Host/Time.h +++ b/include/lldb/Host/Time.h @@ -1,9 +1,8 @@ //===-- Time.h --------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// diff --git a/include/lldb/Host/XML.h b/include/lldb/Host/XML.h index 57e300752003f..625cf4381286c 100644 --- a/include/lldb/Host/XML.h +++ b/include/lldb/Host/XML.h @@ -1,9 +1,8 @@ //===-- XML.h ---------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -85,20 +84,14 @@ public: XMLNode GetElementForPath(const NamePath &path); - //---------------------------------------------------------------------- // Iterate through all sibling nodes of any type - //---------------------------------------------------------------------- void ForEachSiblingNode(NodeCallback const &callback) const; - //---------------------------------------------------------------------- // Iterate through only the sibling nodes that are elements - //---------------------------------------------------------------------- void ForEachSiblingElement(NodeCallback const &callback) const; - //---------------------------------------------------------------------- // Iterate through only the sibling nodes that are elements and whose name // matches \a name. - //---------------------------------------------------------------------- void ForEachSiblingElementWithName(const char *name, NodeCallback const &callback) const; @@ -132,10 +125,8 @@ public: bool ParseMemory(const char *xml, size_t xml_length, 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. - //---------------------------------------------------------------------- XMLNode GetRootElement(const char *required_name = nullptr); llvm::StringRef GetErrors() const; diff --git a/include/lldb/Host/common/NativeBreakpointList.h b/include/lldb/Host/common/NativeBreakpointList.h index b57174e51564e..c2725b2df959b 100644 --- a/include/lldb/Host/common/NativeBreakpointList.h +++ b/include/lldb/Host/common/NativeBreakpointList.h @@ -1,9 +1,8 @@ //===-- NativeBreakpointList.h ----------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// diff --git a/include/lldb/Host/common/NativeProcessProtocol.h b/include/lldb/Host/common/NativeProcessProtocol.h index cb3b18eb0a3df..f05b8d01a1c9f 100644 --- a/include/lldb/Host/common/NativeProcessProtocol.h +++ b/include/lldb/Host/common/NativeProcessProtocol.h @@ -1,9 +1,8 @@ //===-- NativeProcessProtocol.h ---------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -33,9 +32,7 @@ namespace lldb_private { class MemoryRegionInfo; class ResumeActionList; -//------------------------------------------------------------------ // NativeProcessProtocol -//------------------------------------------------------------------ class NativeProcessProtocol { public: virtual ~NativeProcessProtocol() {} @@ -46,37 +43,29 @@ public: virtual Status Detach() = 0; - //------------------------------------------------------------------ /// Sends a process a UNIX signal \a signal. /// - /// @return + /// \return /// Returns an error object. - //------------------------------------------------------------------ virtual Status Signal(int signo) = 0; - //------------------------------------------------------------------ /// Tells a process to interrupt all operations as if by a Ctrl-C. /// /// The default implementation will send a local host's equivalent of /// a SIGSTOP to the process via the NativeProcessProtocol::Signal() /// operation. /// - /// @return + /// \return /// Returns an error object. - //------------------------------------------------------------------ virtual Status Interrupt(); virtual Status Kill() = 0; - //------------------------------------------------------------------ // Tells a process not to stop the inferior on given signals and just // reinject them back. - //------------------------------------------------------------------ virtual Status IgnoreSignals(llvm::ArrayRef<int> signals); - //---------------------------------------------------------------------- // Memory and memory region functions - //---------------------------------------------------------------------- virtual Status GetMemoryRegionInfo(lldb::addr_t load_addr, MemoryRegionInfo &range_info); @@ -103,26 +92,20 @@ public: virtual const ArchSpec &GetArchitecture() const = 0; - //---------------------------------------------------------------------- // Breakpoint functions - //---------------------------------------------------------------------- virtual Status SetBreakpoint(lldb::addr_t addr, uint32_t size, bool hardware) = 0; virtual Status RemoveBreakpoint(lldb::addr_t addr, bool hardware = false); - //---------------------------------------------------------------------- // Hardware Breakpoint functions - //---------------------------------------------------------------------- virtual const HardwareBreakpointMap &GetHardwareBreakpointMap() const; virtual Status SetHardwareBreakpoint(lldb::addr_t addr, size_t size); virtual Status RemoveHardwareBreakpoint(lldb::addr_t addr); - //---------------------------------------------------------------------- // Watchpoint functions - //---------------------------------------------------------------------- virtual const NativeWatchpointList::WatchpointMap &GetWatchpointMap() const; virtual llvm::Optional<std::pair<uint32_t, uint32_t>> @@ -133,9 +116,7 @@ public: virtual Status RemoveWatchpoint(lldb::addr_t addr); - //---------------------------------------------------------------------- // Accessors - //---------------------------------------------------------------------- lldb::pid_t GetID() const { return m_pid; } lldb::StateType GetState() const; @@ -152,19 +133,19 @@ public: return GetArchitecture().GetByteOrder(); } + uint32_t GetAddressByteSize() const { + return GetArchitecture().GetAddressByteSize(); + } + virtual llvm::ErrorOr<std::unique_ptr<llvm::MemoryBuffer>> GetAuxvData() const = 0; - //---------------------------------------------------------------------- // Exit Status - //---------------------------------------------------------------------- virtual llvm::Optional<WaitStatus> GetExitStatus(); virtual bool SetExitStatus(WaitStatus status, bool bNotifyStateChange); - //---------------------------------------------------------------------- // Access to threads - //---------------------------------------------------------------------- NativeThreadProtocol *GetThreadAtIndex(uint32_t idx); NativeThreadProtocol *GetThreadByID(lldb::tid_t tid); @@ -177,20 +158,14 @@ public: return GetThreadByID(m_current_thread_id); } - //---------------------------------------------------------------------- // Access to inferior stdio - //---------------------------------------------------------------------- virtual int GetTerminalFileDescriptor() { return m_terminal_fd; } - //---------------------------------------------------------------------- // Stop id interface - //---------------------------------------------------------------------- uint32_t GetStopID() const; - // --------------------------------------------------------------------- // Callbacks for low-level process state changes - // --------------------------------------------------------------------- class NativeDelegate { public: virtual ~NativeDelegate() {} @@ -203,7 +178,6 @@ public: virtual void DidExec(NativeProcessProtocol *process) = 0; }; - //------------------------------------------------------------------ /// Register a native delegate. /// /// Clients can register nofication callbacks by passing in a @@ -212,29 +186,26 @@ public: /// Note: it is required that the lifetime of the /// native_delegate outlive the NativeProcessProtocol. /// - /// @param[in] native_delegate + /// \param[in] native_delegate /// A NativeDelegate impl to be called when certain events /// happen within the NativeProcessProtocol or related threads. /// - /// @return + /// \return /// true if the delegate was registered successfully; /// false if the delegate was already registered. /// - /// @see NativeProcessProtocol::NativeDelegate. - //------------------------------------------------------------------ + /// \see NativeProcessProtocol::NativeDelegate. bool RegisterNativeDelegate(NativeDelegate &native_delegate); - //------------------------------------------------------------------ /// Unregister a native delegate previously registered. /// - /// @param[in] native_delegate + /// \param[in] native_delegate /// A NativeDelegate impl previously registered with this process. /// - /// @return Returns \b true if the NativeDelegate was + /// \return Returns \b true if the NativeDelegate was /// successfully removed from the process, \b false otherwise. /// - /// @see NativeProcessProtocol::NativeDelegate - //------------------------------------------------------------------ + /// \see NativeProcessProtocol::NativeDelegate bool UnregisterNativeDelegate(NativeDelegate &native_delegate); virtual Status GetLoadedModuleFileSpec(const char *module_path, @@ -246,153 +217,139 @@ public: class Factory { public: virtual ~Factory(); - //------------------------------------------------------------------ /// Launch a process for debugging. /// - /// @param[in] launch_info + /// \param[in] launch_info /// Information required to launch the process. /// - /// @param[in] native_delegate + /// \param[in] native_delegate /// The delegate that will receive messages regarding the /// inferior. Must outlive the NativeProcessProtocol /// instance. /// - /// @param[in] mainloop + /// \param[in] mainloop /// The mainloop instance with which the process can register /// callbacks. Must outlive the NativeProcessProtocol /// instance. /// - /// @return + /// \return /// A NativeProcessProtocol shared pointer if the operation succeeded or /// an error object if it failed. - //------------------------------------------------------------------ virtual llvm::Expected<std::unique_ptr<NativeProcessProtocol>> Launch(ProcessLaunchInfo &launch_info, NativeDelegate &native_delegate, MainLoop &mainloop) const = 0; - //------------------------------------------------------------------ /// Attach to an existing process. /// - /// @param[in] pid + /// \param[in] pid /// pid of the process locatable /// - /// @param[in] native_delegate + /// \param[in] native_delegate /// The delegate that will receive messages regarding the /// inferior. Must outlive the NativeProcessProtocol /// instance. /// - /// @param[in] mainloop + /// \param[in] mainloop /// The mainloop instance with which the process can register /// callbacks. Must outlive the NativeProcessProtocol /// instance. /// - /// @return + /// \return /// A NativeProcessProtocol shared pointer if the operation succeeded or /// an error object if it failed. - //------------------------------------------------------------------ virtual llvm::Expected<std::unique_ptr<NativeProcessProtocol>> Attach(lldb::pid_t pid, NativeDelegate &native_delegate, MainLoop &mainloop) const = 0; }; - //------------------------------------------------------------------ /// StartTracing API for starting a tracing instance with the /// TraceOptions on a specific thread or process. /// - /// @param[in] config + /// \param[in] config /// The configuration to use when starting tracing. /// - /// @param[out] error + /// \param[out] error /// Status indicates what went wrong. /// - /// @return + /// \return /// The API returns a user_id which can be used to get trace /// data, trace configuration or stopping the trace instance. /// The user_id is a key to identify and operate with a tracing /// instance. It may refer to the complete process or a single /// thread. - //------------------------------------------------------------------ virtual lldb::user_id_t StartTrace(const TraceOptions &config, Status &error) { error.SetErrorString("Not implemented"); return LLDB_INVALID_UID; } - //------------------------------------------------------------------ /// StopTracing API as the name suggests stops a tracing instance. /// - /// @param[in] traceid + /// \param[in] traceid /// The user id of the trace intended to be stopped. Now a /// user_id may map to multiple threads in which case this API /// could be used to stop the tracing for a specific thread by /// supplying its thread id. /// - /// @param[in] thread + /// \param[in] thread /// Thread is needed when the complete process is being traced /// and the user wishes to stop tracing on a particular thread. /// - /// @return + /// \return /// Status indicating what went wrong. - //------------------------------------------------------------------ virtual Status StopTrace(lldb::user_id_t traceid, lldb::tid_t thread = LLDB_INVALID_THREAD_ID) { return Status("Not implemented"); } - //------------------------------------------------------------------ /// This API provides the trace data collected in the form of raw /// data. /// - /// @param[in] traceid thread + /// \param[in] traceid thread /// The traceid and thread provide the context for the trace /// instance. /// - /// @param[in] buffer + /// \param[in] buffer /// The buffer provides the destination buffer where the trace /// data would be read to. The buffer should be truncated to the /// filled length by this function. /// - /// @param[in] offset + /// \param[in] offset /// There is possibility to read partially the trace data from /// a specified offset where in such cases the buffer provided /// may be smaller than the internal trace collection container. /// - /// @return + /// \return /// The size of the data actually read. - //------------------------------------------------------------------ virtual Status GetData(lldb::user_id_t traceid, lldb::tid_t thread, llvm::MutableArrayRef<uint8_t> &buffer, size_t offset = 0) { return Status("Not implemented"); } - //------------------------------------------------------------------ /// Similar API as above except it aims to provide any extra data /// useful for decoding the actual trace data. - //------------------------------------------------------------------ virtual Status GetMetaData(lldb::user_id_t traceid, lldb::tid_t thread, llvm::MutableArrayRef<uint8_t> &buffer, size_t offset = 0) { return Status("Not implemented"); } - //------------------------------------------------------------------ /// API to query the TraceOptions for a given user id /// - /// @param[in] traceid + /// \param[in] traceid /// The user id of the tracing instance. /// - /// @param[in] config + /// \param[in] config /// The thread id of the tracing instance, in case configuration /// for a specific thread is needed should be specified in the /// config. /// - /// @param[out] error + /// \param[out] error /// Status indicates what went wrong. /// - /// @param[out] config + /// \param[out] config /// The actual configuration being used for tracing. - //------------------------------------------------------------------ virtual Status GetTraceConfig(lldb::user_id_t traceid, TraceOptions &config) { return Status("Not implemented"); } @@ -434,9 +391,7 @@ protected: NativeProcessProtocol(lldb::pid_t pid, int terminal_fd, NativeDelegate &delegate); - // ----------------------------------------------------------- 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 @@ -445,9 +400,7 @@ protected: // Note this function is called with the state mutex obtained by the caller. virtual void DoStopIDBumped(uint32_t newBumpId); - // ----------------------------------------------------------- Internal // interface for software breakpoints - // ----------------------------------------------------------- Status SetSoftwareBreakpoint(lldb::addr_t addr, uint32_t size_hint); Status RemoveSoftwareBreakpoint(lldb::addr_t addr); @@ -466,12 +419,10 @@ protected: // resets it to point to the breakpoint itself. void FixupBreakpointPCAsNeeded(NativeThreadProtocol &thread); - // ----------------------------------------------------------- /// Notify the delegate that an exec occurred. /// /// Provide a mechanism for a delegate to clear out any exec- /// sensitive data. - // ----------------------------------------------------------- void NotifyDidExec(); NativeThreadProtocol *GetThreadByIDUnlocked(lldb::tid_t tid); diff --git a/include/lldb/Host/common/NativeRegisterContext.h b/include/lldb/Host/common/NativeRegisterContext.h index 268e0f2473fd4..6bba8f2a5d29a 100644 --- a/include/lldb/Host/common/NativeRegisterContext.h +++ b/include/lldb/Host/common/NativeRegisterContext.h @@ -1,9 +1,8 @@ //===-- NativeRegisterContext.h ---------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -20,9 +19,7 @@ class NativeThreadProtocol; class NativeRegisterContext : public std::enable_shared_from_this<NativeRegisterContext> { public: - //------------------------------------------------------------------ // Constructors and Destructors - //------------------------------------------------------------------ NativeRegisterContext(NativeThreadProtocol &thread); virtual ~NativeRegisterContext(); @@ -30,9 +27,7 @@ public: // void // InvalidateIfNeeded (bool force); - //------------------------------------------------------------------ // Subclasses must override these functions - //------------------------------------------------------------------ // virtual void // InvalidateAllRegisters () = 0; @@ -61,9 +56,7 @@ public: uint32_t ConvertRegisterKindToRegisterNumber(uint32_t kind, uint32_t num) const; - //------------------------------------------------------------------ // Subclasses can override these functions if desired - //------------------------------------------------------------------ virtual uint32_t NumSupportedHardwareBreakpoints(); virtual uint32_t SetHardwareBreakpoint(lldb::addr_t addr, size_t size); @@ -116,9 +109,7 @@ public: lldb::addr_t dst_addr, size_t dst_len, const RegisterValue ®_value); - //------------------------------------------------------------------ // Subclasses should not override these - //------------------------------------------------------------------ virtual lldb::tid_t GetThreadID() const; virtual NativeThreadProtocol &GetThread() { return m_thread; } @@ -171,18 +162,14 @@ public: // } protected: - //------------------------------------------------------------------ // Classes that inherit from RegisterContext can see and modify these - //------------------------------------------------------------------ NativeThreadProtocol &m_thread; // The thread that this register context belongs to. // uint32_t m_stop_id; // The stop ID that any data in this // context is valid for private: - //------------------------------------------------------------------ // For RegisterContext only - //------------------------------------------------------------------ DISALLOW_COPY_AND_ASSIGN(NativeRegisterContext); }; diff --git a/include/lldb/Host/common/NativeThreadProtocol.h b/include/lldb/Host/common/NativeThreadProtocol.h index 6f4452c688e71..36ae67933f53d 100644 --- a/include/lldb/Host/common/NativeThreadProtocol.h +++ b/include/lldb/Host/common/NativeThreadProtocol.h @@ -1,9 +1,8 @@ //===-- NativeThreadProtocol.h ----------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -17,9 +16,7 @@ #include "lldb/lldb-types.h" namespace lldb_private { -//------------------------------------------------------------------ // NativeThreadProtocol -//------------------------------------------------------------------ class NativeThreadProtocol { public: NativeThreadProtocol(NativeProcessProtocol &process, lldb::tid_t tid); @@ -39,17 +36,13 @@ public: NativeProcessProtocol &GetProcess() { return m_process; } - // --------------------------------------------------------------------- // Thread-specific watchpoints - // --------------------------------------------------------------------- virtual Status SetWatchpoint(lldb::addr_t addr, size_t size, uint32_t watch_flags, bool hardware) = 0; virtual Status RemoveWatchpoint(lldb::addr_t addr) = 0; - // --------------------------------------------------------------------- // Thread-specific Hardware Breakpoint routines - // --------------------------------------------------------------------- virtual Status SetHardwareBreakpoint(lldb::addr_t addr, size_t size) = 0; virtual Status RemoveHardwareBreakpoint(lldb::addr_t addr) = 0; diff --git a/include/lldb/Host/common/NativeWatchpointList.h b/include/lldb/Host/common/NativeWatchpointList.h index 02920e6faacb1..c83ba1eaadca3 100644 --- a/include/lldb/Host/common/NativeWatchpointList.h +++ b/include/lldb/Host/common/NativeWatchpointList.h @@ -1,9 +1,8 @@ //===-- NativeWatchpointList.h ----------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// diff --git a/include/lldb/Host/common/TCPSocket.h b/include/lldb/Host/common/TCPSocket.h index 0d32a70fd3817..faf3bb693c325 100644 --- a/include/lldb/Host/common/TCPSocket.h +++ b/include/lldb/Host/common/TCPSocket.h @@ -1,9 +1,8 @@ //===-- TCPSocket.h ---------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -47,6 +46,8 @@ public: bool IsValid() const override; + std::string GetRemoteConnectionURI() const override; + private: TCPSocket(NativeSocket socket, const TCPSocket &listen_socket); diff --git a/include/lldb/Host/common/UDPSocket.h b/include/lldb/Host/common/UDPSocket.h index 27b2d1dc98349..b7b6db67d10d9 100644 --- a/include/lldb/Host/common/UDPSocket.h +++ b/include/lldb/Host/common/UDPSocket.h @@ -1,9 +1,8 @@ //===-- UDPSocket.h ---------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -20,6 +19,8 @@ public: static Status Connect(llvm::StringRef name, bool child_processes_inherit, Socket *&socket); + std::string GetRemoteConnectionURI() const override; + private: UDPSocket(NativeSocket socket); diff --git a/include/lldb/Host/freebsd/HostInfoFreeBSD.h b/include/lldb/Host/freebsd/HostInfoFreeBSD.h index 5b3a18d21079a..56f20bbd23d3b 100644 --- a/include/lldb/Host/freebsd/HostInfoFreeBSD.h +++ b/include/lldb/Host/freebsd/HostInfoFreeBSD.h @@ -1,9 +1,8 @@ //===-- HostInfoFreeBSD.h ---------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// diff --git a/include/lldb/Host/netbsd/HostInfoNetBSD.h b/include/lldb/Host/netbsd/HostInfoNetBSD.h index 0d4de79d03b1f..f9ad66eb2b2af 100644 --- a/include/lldb/Host/netbsd/HostInfoNetBSD.h +++ b/include/lldb/Host/netbsd/HostInfoNetBSD.h @@ -1,9 +1,8 @@ //===-- HostInfoNetBSD.h ---------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// diff --git a/include/lldb/Host/openbsd/HostInfoOpenBSD.h b/include/lldb/Host/openbsd/HostInfoOpenBSD.h index 5a0388ffdd977..7ec1d5fc3606d 100644 --- a/include/lldb/Host/openbsd/HostInfoOpenBSD.h +++ b/include/lldb/Host/openbsd/HostInfoOpenBSD.h @@ -1,9 +1,8 @@ //===-- HostInfoOpenBSD.h --------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -12,12 +11,13 @@ #include "lldb/Host/posix/HostInfoPosix.h" #include "lldb/Utility/FileSpec.h" +#include "llvm/Support/VersionTuple.h" namespace lldb_private { class HostInfoOpenBSD : 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 e44737e481e62..b25fc47c56b6a 100644 --- a/include/lldb/Host/posix/ConnectionFileDescriptorPosix.h +++ b/include/lldb/Host/posix/ConnectionFileDescriptorPosix.h @@ -1,9 +1,8 @@ //===-- ConnectionFileDescriptorPosix.h -------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// diff --git a/include/lldb/Host/posix/DomainSocket.h b/include/lldb/Host/posix/DomainSocket.h index e66b3f971fafb..e407ce16bbcbb 100644 --- a/include/lldb/Host/posix/DomainSocket.h +++ b/include/lldb/Host/posix/DomainSocket.h @@ -1,9 +1,8 @@ //===-- DomainSocket.h ------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -21,11 +20,14 @@ public: Status Listen(llvm::StringRef name, int backlog) override; Status Accept(Socket *&socket) override; + std::string GetRemoteConnectionURI() const override; + protected: DomainSocket(SocketProtocol protocol, bool child_processes_inherit); virtual size_t GetNameOffset() const; virtual void DeleteSocketFile(llvm::StringRef name); + std::string GetSocketName() const; private: DomainSocket(NativeSocket socket, const DomainSocket &listen_socket); diff --git a/include/lldb/Host/posix/Fcntl.h b/include/lldb/Host/posix/Fcntl.h index 833a905841412..31cc293dd37a6 100644 --- a/include/lldb/Host/posix/Fcntl.h +++ b/include/lldb/Host/posix/Fcntl.h @@ -1,9 +1,8 @@ //===-- Fcntl.h -------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// diff --git a/include/lldb/Host/posix/HostInfoPosix.h b/include/lldb/Host/posix/HostInfoPosix.h index dda70f9f5a96a..26910132f3c83 100644 --- a/include/lldb/Host/posix/HostInfoPosix.h +++ b/include/lldb/Host/posix/HostInfoPosix.h @@ -1,9 +1,8 @@ //===-- HostInfoPosix.h -----------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -15,14 +14,14 @@ namespace lldb_private { +class UserIDResolver; + class HostInfoPosix : public HostInfoBase { friend class HostInfoBase; public: static size_t GetPageSize(); static bool GetHostname(std::string &s); - static const char *LookupUserName(uint32_t uid, std::string &user_name); - static const char *LookupGroupName(uint32_t gid, std::string &group_name); static uint32_t GetUserID(); static uint32_t GetGroupID(); @@ -33,8 +32,7 @@ public: static bool GetEnvironmentVar(const std::string &var_name, std::string &var); - static bool ComputePathRelativeToLibrary(FileSpec &file_spec, - llvm::StringRef dir); + static UserIDResolver &GetUserIDResolver(); protected: static bool ComputeSupportExeDirectory(FileSpec &file_spec); diff --git a/include/lldb/Host/posix/HostProcessPosix.h b/include/lldb/Host/posix/HostProcessPosix.h index 2cbd4871dd6a2..a313358631b5e 100644 --- a/include/lldb/Host/posix/HostProcessPosix.h +++ b/include/lldb/Host/posix/HostProcessPosix.h @@ -1,9 +1,8 @@ //===-- HostProcessPosix.h --------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -33,8 +32,9 @@ public: lldb::pid_t GetProcessId() const override; bool IsRunning() const override; - HostThread StartMonitoring(const Host::MonitorChildProcessCallback &callback, - bool monitor_signals) override; + llvm::Expected<HostThread> + StartMonitoring(const Host::MonitorChildProcessCallback &callback, + bool monitor_signals) override; }; } // namespace lldb_private diff --git a/include/lldb/Host/posix/HostThreadPosix.h b/include/lldb/Host/posix/HostThreadPosix.h index c230a61bc5752..54012e15ad992 100644 --- a/include/lldb/Host/posix/HostThreadPosix.h +++ b/include/lldb/Host/posix/HostThreadPosix.h @@ -1,9 +1,8 @@ //===-- HostThreadPosix.h -------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// diff --git a/include/lldb/Host/posix/LockFilePosix.h b/include/lldb/Host/posix/LockFilePosix.h index a59a7fe3e7290..63333bff4cd3f 100644 --- a/include/lldb/Host/posix/LockFilePosix.h +++ b/include/lldb/Host/posix/LockFilePosix.h @@ -1,9 +1,8 @@ //===-- LockFilePosix.h -----------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// diff --git a/include/lldb/Host/posix/PipePosix.h b/include/lldb/Host/posix/PipePosix.h index 30d19d97152b3..df341f2fc8951 100644 --- a/include/lldb/Host/posix/PipePosix.h +++ b/include/lldb/Host/posix/PipePosix.h @@ -1,9 +1,8 @@ //===-- PipePosix.h ---------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -15,13 +14,11 @@ namespace lldb_private { -//---------------------------------------------------------------------- -/// @class PipePosix PipePosix.h "lldb/Host/posix/PipePosix.h" +/// \class PipePosix PipePosix.h "lldb/Host/posix/PipePosix.h" /// A posix-based implementation of Pipe, a class that abtracts /// unix style pipes. /// /// A class that abstracts the LLDB core from host pipe functionality. -//---------------------------------------------------------------------- class PipePosix : public PipeBase { public: static int kInvalidDescriptor; diff --git a/include/lldb/Host/posix/ProcessLauncherPosixFork.h b/include/lldb/Host/posix/ProcessLauncherPosixFork.h index 1193a20b4d36b..15e2d6d23b8ea 100644 --- a/include/lldb/Host/posix/ProcessLauncherPosixFork.h +++ b/include/lldb/Host/posix/ProcessLauncherPosixFork.h @@ -1,9 +1,8 @@ //===-- ProcessLauncherPosixFork.h ------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// diff --git a/include/lldb/Initialization/SystemInitializer.h b/include/lldb/Initialization/SystemInitializer.h index b665b99972144..e616ad1ee811d 100644 --- a/include/lldb/Initialization/SystemInitializer.h +++ b/include/lldb/Initialization/SystemInitializer.h @@ -1,9 +1,8 @@ //===-- SystemInitializer.h -------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -16,18 +15,12 @@ namespace lldb_private { -struct InitializerOptions { - bool reproducer_capture = false; - bool reproducer_replay = false; - std::string reproducer_path; -}; - class SystemInitializer { public: SystemInitializer(); virtual ~SystemInitializer(); - virtual llvm::Error Initialize(const InitializerOptions &options) = 0; + virtual llvm::Error Initialize() = 0; virtual void Terminate() = 0; }; } diff --git a/include/lldb/Initialization/SystemInitializerCommon.h b/include/lldb/Initialization/SystemInitializerCommon.h index f33acaf404663..ad7e58e50bbe5 100644 --- a/include/lldb/Initialization/SystemInitializerCommon.h +++ b/include/lldb/Initialization/SystemInitializerCommon.h @@ -1,9 +1,8 @@ //===-- SystemInitializerCommon.h -------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -13,7 +12,6 @@ #include "SystemInitializer.h" namespace lldb_private { -//------------------------------------------------------------------ /// Initializes common lldb functionality. /// /// This class is responsible for initializing a subset of lldb @@ -22,13 +20,12 @@ namespace lldb_private { /// functionality is separate. This class is used by constructing /// an instance of SystemLifetimeManager with this class passed to /// the constructor. -//------------------------------------------------------------------ class SystemInitializerCommon : public SystemInitializer { public: SystemInitializerCommon(); ~SystemInitializerCommon() override; - llvm::Error Initialize(const InitializerOptions &options) override; + llvm::Error Initialize() override; void Terminate() override; }; diff --git a/include/lldb/Initialization/SystemLifetimeManager.h b/include/lldb/Initialization/SystemLifetimeManager.h index 0839856f21e25..2e99b86dbdbd0 100644 --- a/include/lldb/Initialization/SystemLifetimeManager.h +++ b/include/lldb/Initialization/SystemLifetimeManager.h @@ -1,9 +1,8 @@ //===-- SystemLifetimeManager.h -------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -25,7 +24,6 @@ public: ~SystemLifetimeManager(); llvm::Error Initialize(std::unique_ptr<SystemInitializer> initializer, - const InitializerOptions &options, LoadPluginCallbackType plugin_callback); void Terminate(); diff --git a/include/lldb/Interpreter/CommandAlias.h b/include/lldb/Interpreter/CommandAlias.h index c865ad7ff2c92..c2a7a383f35a2 100644 --- a/include/lldb/Interpreter/CommandAlias.h +++ b/include/lldb/Interpreter/CommandAlias.h @@ -1,9 +1,8 @@ //===-- CommandAlias.h -----------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// diff --git a/include/lldb/Interpreter/CommandCompletions.h b/include/lldb/Interpreter/CommandCompletions.h index 71b0af3295b62..3d09db5ce5e79 100644 --- a/include/lldb/Interpreter/CommandCompletions.h +++ b/include/lldb/Interpreter/CommandCompletions.h @@ -1,9 +1,8 @@ //===-- CommandCompletions.h ------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -24,16 +23,14 @@ namespace lldb_private { class TildeExpressionResolver; 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. - //---------------------------------------------------------------------- typedef int (*CompletionCallback)(CommandInterpreter &interpreter, CompletionRequest &request, // A search filter to limit the search... lldb_private::SearchFilter *searcher); - typedef enum { + enum CommonCompletionTypes { eNoCompletion = 0u, eSourceFileCompletion = (1u << 0), eDiskFileCompletion = (1u << 1), @@ -48,7 +45,7 @@ public: // 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; + }; struct CommonCompletionElement { uint32_t type; @@ -59,9 +56,7 @@ public: CommandInterpreter &interpreter, uint32_t completion_mask, lldb_private::CompletionRequest &request, SearchFilter *searcher); - //---------------------------------------------------------------------- // These are the generic completer functions: - //---------------------------------------------------------------------- static int DiskFiles(CommandInterpreter &interpreter, CompletionRequest &request, SearchFilter *searcher); @@ -99,10 +94,8 @@ public: static int VariablePath(CommandInterpreter &interpreter, 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. - //---------------------------------------------------------------------- class Completer : public Searcher { public: Completer(CommandInterpreter &interpreter, CompletionRequest &request); @@ -124,9 +117,7 @@ public: DISALLOW_COPY_AND_ASSIGN(Completer); }; - //---------------------------------------------------------------------- // SourceFileCompleter implements the source file completer - //---------------------------------------------------------------------- class SourceFileCompleter : public Completer { public: SourceFileCompleter(CommandInterpreter &interpreter, @@ -150,9 +141,7 @@ public: DISALLOW_COPY_AND_ASSIGN(SourceFileCompleter); }; - //---------------------------------------------------------------------- // ModuleCompleter implements the module completer - //---------------------------------------------------------------------- class ModuleCompleter : public Completer { public: ModuleCompleter(CommandInterpreter &interpreter, @@ -174,9 +163,7 @@ public: DISALLOW_COPY_AND_ASSIGN(ModuleCompleter); }; - //---------------------------------------------------------------------- // SymbolCompleter implements the symbol completer - //---------------------------------------------------------------------- class SymbolCompleter : public Completer { public: SymbolCompleter(CommandInterpreter &interpreter, diff --git a/include/lldb/Interpreter/CommandHistory.h b/include/lldb/Interpreter/CommandHistory.h index f414c55e2d64c..c1386f84fe2e1 100644 --- a/include/lldb/Interpreter/CommandHistory.h +++ b/include/lldb/Interpreter/CommandHistory.h @@ -1,9 +1,8 @@ //===-- CommandHistory.h ----------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// diff --git a/include/lldb/Interpreter/CommandInterpreter.h b/include/lldb/Interpreter/CommandInterpreter.h index 558246037ad08..c3dd6606e0db9 100644 --- a/include/lldb/Interpreter/CommandInterpreter.h +++ b/include/lldb/Interpreter/CommandInterpreter.h @@ -1,9 +1,8 @@ //===-- CommandInterpreter.h ------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -30,45 +29,47 @@ namespace lldb_private { class CommandInterpreterRunOptions { public: - //------------------------------------------------------------------ /// Construct a CommandInterpreterRunOptions object. This class is used to /// control all the instances where we run multiple commands, e.g. /// HandleCommands, HandleCommandsFromFile, RunCommandInterpreter. /// /// The meanings of the options in this object are: /// - /// @param[in] stop_on_continue + /// \param[in] stop_on_continue /// If \b true, execution will end on the first command that causes the /// process in the execution context to continue. If \b false, we won't /// check the execution status. - /// @param[in] stop_on_error + /// \param[in] stop_on_error /// If \b true, execution will end on the first command that causes an /// error. - /// @param[in] stop_on_crash + /// \param[in] stop_on_crash /// If \b true, when a command causes the target to run, and the end of the /// run is a signal or exception, stop executing the commands. - /// @param[in] echo_commands + /// \param[in] echo_commands /// If \b true, echo the command before executing it. If \b false, execute /// silently. - /// @param[in] echo_comments + /// \param[in] echo_comments /// If \b true, echo command even if it is a pure comment line. If /// \b false, print no ouput in this case. This setting has an effect only /// if \param echo_commands is \b true. - /// @param[in] print_results - /// If \b true print the results of the command after executing it. If - /// \b false, execute silently. - /// @param[in] add_to_history + /// \param[in] print_results + /// If \b true and the command succeeds, print the results of the command + /// after executing it. If \b false, execute silently. + /// \param[in] print_errors + /// If \b true and the command fails, print the results of the command + /// after executing it. If \b false, execute silently. + /// \param[in] add_to_history /// If \b true add the commands to the command history. If \b false, don't /// add them. - //------------------------------------------------------------------ CommandInterpreterRunOptions(LazyBool stop_on_continue, LazyBool stop_on_error, LazyBool stop_on_crash, LazyBool echo_commands, LazyBool echo_comments, - LazyBool print_results, LazyBool add_to_history) + LazyBool print_results, LazyBool print_errors, + LazyBool add_to_history) : m_stop_on_continue(stop_on_continue), m_stop_on_error(stop_on_error), m_stop_on_crash(stop_on_crash), m_echo_commands(echo_commands), m_echo_comment_commands(echo_comments), m_print_results(print_results), - m_add_to_history(add_to_history) {} + m_print_errors(print_errors), m_add_to_history(add_to_history) {} CommandInterpreterRunOptions() : m_stop_on_continue(eLazyBoolCalculate), @@ -76,13 +77,14 @@ public: m_stop_on_crash(eLazyBoolCalculate), m_echo_commands(eLazyBoolCalculate), m_echo_comment_commands(eLazyBoolCalculate), - m_print_results(eLazyBoolCalculate), + m_print_results(eLazyBoolCalculate), m_print_errors(eLazyBoolCalculate), m_add_to_history(eLazyBoolCalculate) {} void SetSilent(bool silent) { LazyBool value = silent ? eLazyBoolNo : eLazyBoolYes; m_print_results = value; + m_print_errors = value; m_echo_commands = value; m_echo_comment_commands = value; m_add_to_history = value; @@ -130,6 +132,12 @@ public: m_print_results = print_results ? eLazyBoolYes : eLazyBoolNo; } + bool GetPrintErrors() const { return DefaultToYes(m_print_errors); } + + void SetPrintErrors(bool print_errors) { + m_print_errors = print_errors ? eLazyBoolYes : eLazyBoolNo; + } + bool GetAddToHistory() const { return DefaultToYes(m_add_to_history); } void SetAddToHistory(bool add_to_history) { @@ -142,6 +150,7 @@ public: LazyBool m_echo_commands; LazyBool m_echo_comment_commands; LazyBool m_print_results; + LazyBool m_print_errors; LazyBool m_add_to_history; private: @@ -191,8 +200,7 @@ public: eCommandTypesAllThem = 0xFFFF // all commands }; - CommandInterpreter(Debugger &debugger, lldb::ScriptLanguage script_language, - bool synchronous_execution); + CommandInterpreter(Debugger &debugger, bool synchronous_execution); ~CommandInterpreter() override; @@ -204,7 +212,8 @@ public: return GetStaticBroadcasterClass(); } - void SourceInitFile(bool in_cwd, CommandReturnObject &result); + void SourceInitFileCwd(CommandReturnObject &result); + void SourceInitFileHome(CommandReturnObject &result); bool AddCommand(llvm::StringRef name, const lldb::CommandObjectSP &cmd_sp, bool can_replace); @@ -255,48 +264,44 @@ public: bool WasInterrupted() const; - //------------------------------------------------------------------ /// Execute a list of commands in sequence. /// - /// @param[in] commands + /// \param[in] commands /// The list of commands to execute. - /// @param[in,out] context + /// \param[in,out] context /// The execution context in which to run the commands. Can be nullptr in /// which case the default /// context will be used. - /// @param[in] options + /// \param[in] options /// This object holds the options used to control when to stop, whether to /// execute commands, /// etc. - /// @param[out] result + /// \param[out] result /// This is marked as succeeding with no output if all commands execute /// safely, /// and failed with some explanation if we aborted executing the commands /// at some point. - //------------------------------------------------------------------ void HandleCommands(const StringList &commands, ExecutionContext *context, CommandInterpreterRunOptions &options, CommandReturnObject &result); - //------------------------------------------------------------------ /// Execute a list of commands from a file. /// - /// @param[in] file + /// \param[in] file /// The file from which to read in commands. - /// @param[in,out] context + /// \param[in,out] context /// The execution context in which to run the commands. Can be nullptr in /// which case the default /// context will be used. - /// @param[in] options + /// \param[in] options /// This object holds the options used to control when to stop, whether to /// execute commands, /// etc. - /// @param[out] result + /// \param[out] result /// This is marked as succeeding with no output if all commands execute /// safely, /// and failed with some explanation if we aborted executing the commands /// at some point. - //------------------------------------------------------------------ void HandleCommandsFromFile(FileSpec &file, ExecutionContext *context, CommandInterpreterRunOptions &options, CommandReturnObject &result); @@ -379,8 +384,6 @@ public: void Clear(); - void SetScriptLanguage(lldb::ScriptLanguage lang); - bool HasCommands() const; bool HasAliases() const; @@ -396,16 +399,12 @@ public: int GetOptionArgumentPosition(const char *in_string); - ScriptInterpreter *GetScriptInterpreter(bool can_create = true); - - void SetScriptInterpreter(); - void SkipLLDBInitFiles(bool skip_lldbinit_files) { m_skip_lldbinit_files = skip_lldbinit_files; } void SkipAppInitFiles(bool skip_app_init_files) { - m_skip_app_init_files = m_skip_lldbinit_files; + m_skip_app_init_files = skip_app_init_files; } bool GetSynchronous(); @@ -442,8 +441,6 @@ public: "the target.max-children-count setting.\n"; } - const CommandHistory &GetCommandHistory() const { return m_command_history; } - CommandHistory &GetCommandHistory() { return m_command_history; } bool IsActive(); @@ -460,9 +457,7 @@ public: const char *GetCommandPrefix(); - //------------------------------------------------------------------ // Properties - //------------------------------------------------------------------ bool GetExpandRegexAliases() const; bool GetPromptOnQuit() const; @@ -475,28 +470,22 @@ public: bool GetEchoCommentCommands() const; void SetEchoCommentCommands(bool b); - //------------------------------------------------------------------ /// Specify if the command interpreter should allow that the user can /// specify a custom exit code when calling 'quit'. - //------------------------------------------------------------------ void AllowExitCodeOnQuit(bool allow); - //------------------------------------------------------------------ /// Sets the exit code for the quit command. - /// @param[in] exit_code + /// \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 + /// \return True if the exit code was successfully set; false if the /// interpreter doesn't allow custom exit codes. - /// @see AllowExitCodeOnQuit - //------------------------------------------------------------------ + /// \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 + /// \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); @@ -518,9 +507,7 @@ public: protected: friend class Debugger; - //------------------------------------------------------------------ // IOHandlerDelegate functions - //------------------------------------------------------------------ void IOHandlerInputComplete(IOHandler &io_handler, std::string &line) override; @@ -545,6 +532,8 @@ protected: private: Status PreprocessCommand(std::string &command); + void SourceInitFile(FileSpec file, CommandReturnObject &result); + // Completely resolves aliases and abbreviations, returning a pointer to the // final command object and updating command_line to the fully substituted // and translated command. @@ -593,8 +582,6 @@ private: CommandHistory m_command_history; std::string m_repeat_command; // Stores the command that will be executed for // an empty command string. - lldb::ScriptInterpreterSP m_script_interpreter_sp; - std::recursive_mutex m_script_interpreter_mutex; lldb::IOHandlerSP m_command_io_handler_sp; char m_comment_char; bool m_batch_command_mode; diff --git a/include/lldb/Interpreter/CommandObject.h b/include/lldb/Interpreter/CommandObject.h index f72628b8a643c..31f7f126a9feb 100644 --- a/include/lldb/Interpreter/CommandObject.h +++ b/include/lldb/Interpreter/CommandObject.h @@ -1,9 +1,8 @@ //===-- CommandObject.h -----------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -122,6 +121,7 @@ public: GetArgumentDescriptionAsCString(const lldb::CommandArgumentType arg_type); CommandInterpreter &GetCommandInterpreter() { return m_interpreter; } + Debugger &GetDebugger(); virtual llvm::StringRef GetHelp(); @@ -221,25 +221,22 @@ public: void SetCommandName(llvm::StringRef name); - //------------------------------------------------------------------ /// 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/out] request + /// \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 /// total number of matches, and the window the user wants returned. /// - /// @return + /// \return /// \btrue if we were in an option, \bfalse otherwise. - //------------------------------------------------------------------ virtual int HandleCompletion(CompletionRequest &request); - //------------------------------------------------------------------ /// 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 @@ -247,16 +244,15 @@ public: /// We've constructed the map of options and their arguments as well if that /// is helpful for the completion. /// - /// @param[in/out] request + /// \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 /// total number of matches, and the window the user wants returned. /// - /// @return + /// \return /// The number of completions. - //------------------------------------------------------------------ virtual int HandleArgumentCompletion(CompletionRequest &request, OptionElementVector &opt_element_vector) { @@ -269,35 +265,29 @@ public: bool search_syntax = true, bool search_options = true); - //------------------------------------------------------------------ /// The flags accessor. /// - /// @return + /// \return /// A reference to the Flags member variable. - //------------------------------------------------------------------ Flags &GetFlags() { return m_flags; } - //------------------------------------------------------------------ /// The flags const accessor. /// - /// @return + /// \return /// A const reference to the Flags member variable. - //------------------------------------------------------------------ const Flags &GetFlags() const { return m_flags; } - //------------------------------------------------------------------ /// Get the command that appropriate for a "repeat" of the current command. /// - /// @param[in] current_command_line + /// \param[in] current_command_line /// The complete current command line. /// - /// @return + /// \return /// nullptr if there is no special repeat command - it will use the /// current command line. /// Otherwise a pointer to the command to be repeated. /// If the returned string is the empty string, the command won't be /// repeated. - //------------------------------------------------------------------ virtual const char *GetRepeatCommand(Args ¤t_command_args, uint32_t index) { return nullptr; @@ -368,17 +358,15 @@ protected: // insulates you from the details of this calculation. Thread *GetDefaultThread(); - //------------------------------------------------------------------ /// Check the command to make sure anything required by this /// command is available. /// - /// @param[out] result + /// \param[out] result /// A command result object, if it is not okay to run the command /// this will be filled in with a suitable error. /// - /// @return + /// \return /// \b true if it is okay to run this command, \b false otherwise. - //------------------------------------------------------------------ bool CheckRequirements(CommandReturnObject &result); void Cleanup(); diff --git a/include/lldb/Interpreter/CommandObjectMultiword.h b/include/lldb/Interpreter/CommandObjectMultiword.h index e1ea39f7ec34d..660e9d49d977f 100644 --- a/include/lldb/Interpreter/CommandObjectMultiword.h +++ b/include/lldb/Interpreter/CommandObjectMultiword.h @@ -1,9 +1,8 @@ //===-- CommandObjectMultiword.h --------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -15,9 +14,7 @@ namespace lldb_private { -//------------------------------------------------------------------------- // CommandObjectMultiword -//------------------------------------------------------------------------- class CommandObjectMultiword : public CommandObject { // These two want to iterate over the subcommand dictionary. diff --git a/include/lldb/Interpreter/CommandObjectRegexCommand.h b/include/lldb/Interpreter/CommandObjectRegexCommand.h index d50bc3ba9141c..7f06e269d64f7 100644 --- a/include/lldb/Interpreter/CommandObjectRegexCommand.h +++ b/include/lldb/Interpreter/CommandObjectRegexCommand.h @@ -1,9 +1,8 @@ //===-- CommandObjectRegexCommand.h -----------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -18,9 +17,7 @@ namespace lldb_private { -//------------------------------------------------------------------------- // CommandObjectRegexCommand -//------------------------------------------------------------------------- class CommandObjectRegexCommand : public CommandObjectRaw { public: diff --git a/include/lldb/Interpreter/CommandOptionValidators.h b/include/lldb/Interpreter/CommandOptionValidators.h index e0c8ddde6ecbd..5483c1509556b 100644 --- a/include/lldb/Interpreter/CommandOptionValidators.h +++ b/include/lldb/Interpreter/CommandOptionValidators.h @@ -1,9 +1,8 @@ //===-- CommandOptionValidators.h -------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// diff --git a/include/lldb/Interpreter/CommandReturnObject.h b/include/lldb/Interpreter/CommandReturnObject.h index 53a908f97ccb9..a5f61261455ee 100644 --- a/include/lldb/Interpreter/CommandReturnObject.h +++ b/include/lldb/Interpreter/CommandReturnObject.h @@ -1,9 +1,8 @@ //===-- CommandReturnObject.h -----------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// diff --git a/include/lldb/Interpreter/OptionArgParser.h b/include/lldb/Interpreter/OptionArgParser.h index b5a083929067c..ce901b0483b41 100644 --- a/include/lldb/Interpreter/OptionArgParser.h +++ b/include/lldb/Interpreter/OptionArgParser.h @@ -1,9 +1,8 @@ //===-- OptionArgParser.h ---------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// diff --git a/include/lldb/Interpreter/OptionGroupArchitecture.h b/include/lldb/Interpreter/OptionGroupArchitecture.h index 2cecaa65a0fdc..4b7f9fe92e359 100644 --- a/include/lldb/Interpreter/OptionGroupArchitecture.h +++ b/include/lldb/Interpreter/OptionGroupArchitecture.h @@ -1,9 +1,8 @@ //===-- OptionGroupArchitecture.h -------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -15,9 +14,7 @@ namespace lldb_private { -//------------------------------------------------------------------------- // OptionGroupArchitecture -//------------------------------------------------------------------------- class OptionGroupArchitecture : public OptionGroup { public: diff --git a/include/lldb/Interpreter/OptionGroupBoolean.h b/include/lldb/Interpreter/OptionGroupBoolean.h index 161c12a41f9f8..77490457528a9 100644 --- a/include/lldb/Interpreter/OptionGroupBoolean.h +++ b/include/lldb/Interpreter/OptionGroupBoolean.h @@ -1,9 +1,8 @@ //===-- OptionGroupBoolean.h ------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -14,9 +13,7 @@ #include "lldb/Interpreter/Options.h" namespace lldb_private { -//------------------------------------------------------------------------- // OptionGroupBoolean -//------------------------------------------------------------------------- class OptionGroupBoolean : public OptionGroup { public: diff --git a/include/lldb/Interpreter/OptionGroupFile.h b/include/lldb/Interpreter/OptionGroupFile.h index 4a56e4c742fdd..cce3714e98b93 100644 --- a/include/lldb/Interpreter/OptionGroupFile.h +++ b/include/lldb/Interpreter/OptionGroupFile.h @@ -1,9 +1,8 @@ //===-- OptionGroupFile.h ---------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -16,9 +15,7 @@ namespace lldb_private { -//------------------------------------------------------------------------- // OptionGroupFile -//------------------------------------------------------------------------- class OptionGroupFile : public OptionGroup { public: @@ -48,9 +45,7 @@ protected: OptionDefinition m_option_definition; }; -//------------------------------------------------------------------------- // OptionGroupFileList -//------------------------------------------------------------------------- class OptionGroupFileList : public OptionGroup { public: diff --git a/include/lldb/Interpreter/OptionGroupFormat.h b/include/lldb/Interpreter/OptionGroupFormat.h index 52113d8777f50..1b5020a392c5f 100644 --- a/include/lldb/Interpreter/OptionGroupFormat.h +++ b/include/lldb/Interpreter/OptionGroupFormat.h @@ -1,9 +1,8 @@ //===-- OptionGroupFormat.h -------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -17,9 +16,7 @@ namespace lldb_private { -//------------------------------------------------------------------------- // OptionGroupFormat -//------------------------------------------------------------------------- class OptionGroupFormat : public OptionGroup { public: diff --git a/include/lldb/Interpreter/OptionGroupOutputFile.h b/include/lldb/Interpreter/OptionGroupOutputFile.h index 88d45797358d3..82d68b7c164e4 100644 --- a/include/lldb/Interpreter/OptionGroupOutputFile.h +++ b/include/lldb/Interpreter/OptionGroupOutputFile.h @@ -1,9 +1,8 @@ //===-- OptionGroupOutputFile.h ---------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -15,9 +14,7 @@ #include "lldb/Interpreter/Options.h" namespace lldb_private { -//------------------------------------------------------------------------- // OptionGroupOutputFile -//------------------------------------------------------------------------- class OptionGroupOutputFile : public OptionGroup { public: diff --git a/include/lldb/Interpreter/OptionGroupPlatform.h b/include/lldb/Interpreter/OptionGroupPlatform.h index 9bc9588deab3c..ea5a3f39ef837 100644 --- a/include/lldb/Interpreter/OptionGroupPlatform.h +++ b/include/lldb/Interpreter/OptionGroupPlatform.h @@ -1,9 +1,8 @@ //===-- OptionGroupPlatform.h -----------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -16,11 +15,9 @@ namespace lldb_private { -//------------------------------------------------------------------------- // PlatformOptionGroup // // Make platform options available to any commands that need the settings. -//------------------------------------------------------------------------- class OptionGroupPlatform : public OptionGroup { public: OptionGroupPlatform(bool include_platform_option) @@ -51,15 +48,15 @@ public: m_platform_name.clear(); } - const ConstString &GetSDKRootDirectory() const { return m_sdk_sysroot; } + ConstString GetSDKRootDirectory() const { return m_sdk_sysroot; } - void SetSDKRootDirectory(const ConstString &sdk_root_directory) { + void SetSDKRootDirectory(ConstString sdk_root_directory) { m_sdk_sysroot = sdk_root_directory; } - const ConstString &GetSDKBuild() const { return m_sdk_build; } + ConstString GetSDKBuild() const { return m_sdk_build; } - void SetSDKBuild(const ConstString &sdk_build) { m_sdk_build = sdk_build; } + void SetSDKBuild(ConstString sdk_build) { m_sdk_build = sdk_build; } bool PlatformMatches(const lldb::PlatformSP &platform_sp) const; diff --git a/include/lldb/Interpreter/OptionGroupString.h b/include/lldb/Interpreter/OptionGroupString.h index 41889fe57d779..ce1058954054c 100644 --- a/include/lldb/Interpreter/OptionGroupString.h +++ b/include/lldb/Interpreter/OptionGroupString.h @@ -1,9 +1,8 @@ //===-- OptionGroupString.h -------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -14,9 +13,7 @@ #include "lldb/Interpreter/Options.h" namespace lldb_private { -//------------------------------------------------------------------------- // OptionGroupString -//------------------------------------------------------------------------- class OptionGroupString : public OptionGroup { public: diff --git a/include/lldb/Interpreter/OptionGroupUInt64.h b/include/lldb/Interpreter/OptionGroupUInt64.h index d6b06066b9641..12f08a38c5331 100644 --- a/include/lldb/Interpreter/OptionGroupUInt64.h +++ b/include/lldb/Interpreter/OptionGroupUInt64.h @@ -1,9 +1,8 @@ //===-- OptionGroupUInt64.h -------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -15,9 +14,7 @@ namespace lldb_private { -//------------------------------------------------------------------------- // OptionGroupUInt64 -//------------------------------------------------------------------------- class OptionGroupUInt64 : public OptionGroup { public: diff --git a/include/lldb/Interpreter/OptionGroupUUID.h b/include/lldb/Interpreter/OptionGroupUUID.h index 390f128a86184..22fc3a100c757 100644 --- a/include/lldb/Interpreter/OptionGroupUUID.h +++ b/include/lldb/Interpreter/OptionGroupUUID.h @@ -1,9 +1,8 @@ //===-- OptionGroupUUID.h ---------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -15,9 +14,7 @@ namespace lldb_private { -//------------------------------------------------------------------------- // OptionGroupUUID -//------------------------------------------------------------------------- class OptionGroupUUID : public OptionGroup { public: diff --git a/include/lldb/Interpreter/OptionGroupValueObjectDisplay.h b/include/lldb/Interpreter/OptionGroupValueObjectDisplay.h index 8684453d89c61..5a1bbc9e7b667 100644 --- a/include/lldb/Interpreter/OptionGroupValueObjectDisplay.h +++ b/include/lldb/Interpreter/OptionGroupValueObjectDisplay.h @@ -1,9 +1,8 @@ //===-- OptionGroupValueObjectDisplay.h -------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -15,9 +14,7 @@ namespace lldb_private { -//------------------------------------------------------------------------- // OptionGroupValueObjectDisplay -//------------------------------------------------------------------------- class OptionGroupValueObjectDisplay : public OptionGroup { public: diff --git a/include/lldb/Interpreter/OptionGroupVariable.h b/include/lldb/Interpreter/OptionGroupVariable.h index 663705acebbcc..0c042f4c1cdb3 100644 --- a/include/lldb/Interpreter/OptionGroupVariable.h +++ b/include/lldb/Interpreter/OptionGroupVariable.h @@ -1,9 +1,8 @@ //===-- OptionGroupVariable.h -----------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -15,9 +14,7 @@ namespace lldb_private { -//------------------------------------------------------------------------- // OptionGroupVariable -//------------------------------------------------------------------------- class OptionGroupVariable : public OptionGroup { public: diff --git a/include/lldb/Interpreter/OptionGroupWatchpoint.h b/include/lldb/Interpreter/OptionGroupWatchpoint.h index 2d4456ef31a9b..3729c000b8e07 100644 --- a/include/lldb/Interpreter/OptionGroupWatchpoint.h +++ b/include/lldb/Interpreter/OptionGroupWatchpoint.h @@ -1,9 +1,8 @@ //===-- OptionGroupWatchpoint.h ---------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -14,9 +13,7 @@ namespace lldb_private { -//------------------------------------------------------------------------- // OptionGroupWatchpoint -//------------------------------------------------------------------------- class OptionGroupWatchpoint : public OptionGroup { public: @@ -37,12 +34,12 @@ public: // Note: // eWatchRead == LLDB_WATCH_TYPE_READ; and // eWatchWrite == LLDB_WATCH_TYPE_WRITE - typedef enum WatchType { + enum WatchType { eWatchInvalid = 0, eWatchRead, eWatchWrite, eWatchReadWrite - } WatchType; + }; WatchType watch_type; uint32_t watch_size; diff --git a/include/lldb/Interpreter/OptionValue.h b/include/lldb/Interpreter/OptionValue.h index e90d7ed6d8ebd..0b85bc19dd2a5 100644 --- a/include/lldb/Interpreter/OptionValue.h +++ b/include/lldb/Interpreter/OptionValue.h @@ -1,9 +1,8 @@ //===-- OptionValue.h -------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -20,12 +19,10 @@ namespace lldb_private { -//--------------------------------------------------------------------- // OptionValue -//--------------------------------------------------------------------- class OptionValue { public: - typedef enum { + enum Type { eTypeInvalid = 0, eTypeArch, eTypeArgs, @@ -46,7 +43,7 @@ public: eTypeUInt64, eTypeUUID, eTypeFormatEntity - } Type; + }; enum { eDumpOptionName = (1u << 0), @@ -70,9 +67,7 @@ public: virtual ~OptionValue() = default; - //----------------------------------------------------------------- // Subclasses should override these functions - //----------------------------------------------------------------- virtual Type GetType() const = 0; // If this value is always hidden, the avoid showing any info on this value, @@ -101,9 +96,7 @@ public: virtual size_t AutoComplete(CommandInterpreter &interpreter, CompletionRequest &request); - //----------------------------------------------------------------- // Subclasses can override these functions - //----------------------------------------------------------------- virtual lldb::OptionValueSP GetSubValue(const ExecutionContext *exe_ctx, llvm::StringRef name, bool will_modify, @@ -122,10 +115,8 @@ public: virtual bool DumpQualifiedName(Stream &strm) const; - //----------------------------------------------------------------- // Subclasses should NOT override these functions as they use the above // functions to implement functionality - //----------------------------------------------------------------- uint32_t GetTypeAsMask() { return 1u << GetType(); } static uint32_t ConvertTypeToMask(OptionValue::Type type) { diff --git a/include/lldb/Interpreter/OptionValueArch.h b/include/lldb/Interpreter/OptionValueArch.h index 15b74ad178930..f8f406890841a 100644 --- a/include/lldb/Interpreter/OptionValueArch.h +++ b/include/lldb/Interpreter/OptionValueArch.h @@ -1,9 +1,8 @@ //===-- OptionValueArch.h -----------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -34,9 +33,7 @@ public: ~OptionValueArch() override {} - //--------------------------------------------------------------------- // Virtual subclass pure virtual overrides - //--------------------------------------------------------------------- OptionValue::Type GetType() const override { return eTypeArch; } @@ -61,9 +58,7 @@ public: size_t AutoComplete(CommandInterpreter &interpreter, lldb_private::CompletionRequest &request) override; - //--------------------------------------------------------------------- // Subclass specific functions - //--------------------------------------------------------------------- ArchSpec &GetCurrentValue() { return m_current_value; } diff --git a/include/lldb/Interpreter/OptionValueArgs.h b/include/lldb/Interpreter/OptionValueArgs.h index 41af1298c2cb4..0254b9aa7e141 100644 --- a/include/lldb/Interpreter/OptionValueArgs.h +++ b/include/lldb/Interpreter/OptionValueArgs.h @@ -1,9 +1,8 @@ //===-- OptionValueArgs.h --------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// diff --git a/include/lldb/Interpreter/OptionValueArray.h b/include/lldb/Interpreter/OptionValueArray.h index 06c4828402600..10f3bf5f729f8 100644 --- a/include/lldb/Interpreter/OptionValueArray.h +++ b/include/lldb/Interpreter/OptionValueArray.h @@ -1,9 +1,8 @@ //===-- OptionValueArray.h --------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -23,9 +22,7 @@ public: ~OptionValueArray() override {} - //--------------------------------------------------------------------- // Virtual subclass pure virtual overrides - //--------------------------------------------------------------------- OptionValue::Type GetType() const override { return eTypeArray; } @@ -53,9 +50,7 @@ public: llvm::StringRef name, bool will_modify, Status &error) const override; - //--------------------------------------------------------------------- // Subclass specific functions - //--------------------------------------------------------------------- size_t GetSize() const { return m_values.size(); } diff --git a/include/lldb/Interpreter/OptionValueBoolean.h b/include/lldb/Interpreter/OptionValueBoolean.h index 572e6b1861fb1..2fc97d4949886 100644 --- a/include/lldb/Interpreter/OptionValueBoolean.h +++ b/include/lldb/Interpreter/OptionValueBoolean.h @@ -1,9 +1,8 @@ //===-- OptionValueBoolean.h ------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -24,9 +23,7 @@ public: ~OptionValueBoolean() override {} - //--------------------------------------------------------------------- // Virtual subclass pure virtual overrides - //--------------------------------------------------------------------- OptionValue::Type GetType() const override { return eTypeBoolean; } @@ -49,25 +46,21 @@ public: size_t AutoComplete(CommandInterpreter &interpreter, CompletionRequest &request) override; - //--------------------------------------------------------------------- // Subclass specific functions - //--------------------------------------------------------------------- - //------------------------------------------------------------------ /// Convert to bool operator. /// /// This allows code to check a OptionValueBoolean in conditions. /// - /// @code + /// \code /// OptionValueBoolean bool_value(...); /// if (bool_value) /// { ... - /// @endcode + /// \endcode /// - /// @return + /// \return /// /b True this object contains a valid namespace decl, \b /// false otherwise. - //------------------------------------------------------------------ explicit operator bool() const { return m_current_value; } const bool &operator=(bool b) { diff --git a/include/lldb/Interpreter/OptionValueChar.h b/include/lldb/Interpreter/OptionValueChar.h index e73976fefccc1..d8661363751be 100644 --- a/include/lldb/Interpreter/OptionValueChar.h +++ b/include/lldb/Interpreter/OptionValueChar.h @@ -1,9 +1,8 @@ -//===-- OptionValueBoolean.h ------------------------------------*- C++ -*-===// +//===-- OptionValueChar.h ---------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -25,9 +24,7 @@ public: ~OptionValueChar() override {} - //--------------------------------------------------------------------- // Virtual subclass pure virtual overrides - //--------------------------------------------------------------------- OptionValue::Type GetType() const override { return eTypeChar; } @@ -47,9 +44,7 @@ public: return true; } - //--------------------------------------------------------------------- // Subclass specific functions - //--------------------------------------------------------------------- const char &operator=(char c) { m_current_value = c; diff --git a/include/lldb/Interpreter/OptionValueDictionary.h b/include/lldb/Interpreter/OptionValueDictionary.h index b6163e7a9a25b..8785d38f5423c 100644 --- a/include/lldb/Interpreter/OptionValueDictionary.h +++ b/include/lldb/Interpreter/OptionValueDictionary.h @@ -1,9 +1,8 @@ //===-- OptionValueDictionary.h ---------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -25,9 +24,7 @@ public: ~OptionValueDictionary() override {} - //--------------------------------------------------------------------- // Virtual subclass pure virtual overrides - //--------------------------------------------------------------------- OptionValue::Type GetType() const override { return eTypeDictionary; } @@ -52,13 +49,11 @@ public: return ConvertTypeMaskToType(m_type_mask) != eTypeInvalid; } - //--------------------------------------------------------------------- // Subclass specific functions - //--------------------------------------------------------------------- size_t GetNumValues() const { return m_values.size(); } - lldb::OptionValueSP GetValueForKey(const ConstString &key) const; + lldb::OptionValueSP GetValueForKey(ConstString key) const; lldb::OptionValueSP GetSubValue(const ExecutionContext *exe_ctx, llvm::StringRef name, bool will_modify, @@ -67,11 +62,11 @@ public: Status SetSubValue(const ExecutionContext *exe_ctx, VarSetOperationType op, llvm::StringRef name, llvm::StringRef value) override; - bool SetValueForKey(const ConstString &key, + bool SetValueForKey(ConstString key, const lldb::OptionValueSP &value_sp, bool can_replace = true); - bool DeleteValueForKey(const ConstString &key); + bool DeleteValueForKey(ConstString key); size_t GetArgs(Args &args) const; diff --git a/include/lldb/Interpreter/OptionValueEnumeration.h b/include/lldb/Interpreter/OptionValueEnumeration.h index 16c09c589a277..71f3ab53b2ff3 100644 --- a/include/lldb/Interpreter/OptionValueEnumeration.h +++ b/include/lldb/Interpreter/OptionValueEnumeration.h @@ -1,9 +1,8 @@ //===-- OptionValueEnumeration.h --------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -34,9 +33,7 @@ public: ~OptionValueEnumeration() override; - //--------------------------------------------------------------------- // Virtual subclass pure virtual overrides - //--------------------------------------------------------------------- OptionValue::Type GetType() const override { return eTypeEnum; } @@ -61,9 +58,7 @@ public: size_t AutoComplete(CommandInterpreter &interpreter, CompletionRequest &request) override; - //--------------------------------------------------------------------- // Subclass specific functions - //--------------------------------------------------------------------- enum_type operator=(enum_type value) { m_current_value = value; diff --git a/include/lldb/Interpreter/OptionValueFileSpec.h b/include/lldb/Interpreter/OptionValueFileSpec.h index 41a479e2fc9e4..aa1022a4fe2c1 100644 --- a/include/lldb/Interpreter/OptionValueFileSpec.h +++ b/include/lldb/Interpreter/OptionValueFileSpec.h @@ -1,9 +1,8 @@ //===-- OptionValueFileSpec.h -----------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -28,9 +27,7 @@ public: ~OptionValueFileSpec() override {} - //--------------------------------------------------------------------- // Virtual subclass pure virtual overrides - //--------------------------------------------------------------------- OptionValue::Type GetType() const override { return eTypeFileSpec; } @@ -57,9 +54,7 @@ public: size_t AutoComplete(CommandInterpreter &interpreter, CompletionRequest &request) override; - //--------------------------------------------------------------------- // Subclass specific functions - //--------------------------------------------------------------------- FileSpec &GetCurrentValue() { return m_current_value; } diff --git a/include/lldb/Interpreter/OptionValueFileSpecList.h b/include/lldb/Interpreter/OptionValueFileSpecList.h index 5c43b85bcea7b..5607437fd0dca 100644 --- a/include/lldb/Interpreter/OptionValueFileSpecList.h +++ b/include/lldb/Interpreter/OptionValueFileSpecList.h @@ -1,15 +1,16 @@ //===-- OptionValueFileSpecList.h -------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// #ifndef liblldb_OptionValueFileSpecList_h_ #define liblldb_OptionValueFileSpecList_h_ +#include <mutex> + #include "lldb/Core/FileSpecList.h" #include "lldb/Interpreter/OptionValue.h" @@ -24,9 +25,7 @@ public: ~OptionValueFileSpecList() override {} - //--------------------------------------------------------------------- // Virtual subclass pure virtual overrides - //--------------------------------------------------------------------- OptionValue::Type GetType() const override { return eTypeFileSpecList; } @@ -41,6 +40,7 @@ public: VarSetOperationType = eVarSetOperationAssign) = delete; bool Clear() override { + std::lock_guard<std::recursive_mutex> lock(m_mutex); m_current_value.Clear(); m_value_was_set = false; return true; @@ -50,17 +50,25 @@ public: bool IsAggregateValue() const override { return true; } - //--------------------------------------------------------------------- // Subclass specific functions - //--------------------------------------------------------------------- - FileSpecList &GetCurrentValue() { return m_current_value; } + FileSpecList GetCurrentValue() const { + std::lock_guard<std::recursive_mutex> lock(m_mutex); + return m_current_value; + } - const FileSpecList &GetCurrentValue() const { return m_current_value; } + void SetCurrentValue(const FileSpecList &value) { + std::lock_guard<std::recursive_mutex> lock(m_mutex); + m_current_value = value; + } - void SetCurrentValue(const FileSpecList &value) { m_current_value = value; } + void AppendCurrentValue(const FileSpec &value) { + std::lock_guard<std::recursive_mutex> lock(m_mutex); + m_current_value.Append(value); + } protected: + mutable std::recursive_mutex m_mutex; FileSpecList m_current_value; }; diff --git a/include/lldb/Interpreter/OptionValueFormat.h b/include/lldb/Interpreter/OptionValueFormat.h index 6d46957d26f76..020f4aeda17a7 100644 --- a/include/lldb/Interpreter/OptionValueFormat.h +++ b/include/lldb/Interpreter/OptionValueFormat.h @@ -1,9 +1,8 @@ //===-- OptionValueFormat.h -------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -25,9 +24,7 @@ public: ~OptionValueFormat() override {} - //--------------------------------------------------------------------- // Virtual subclass pure virtual overrides - //--------------------------------------------------------------------- OptionValue::Type GetType() const override { return eTypeFormat; } @@ -49,9 +46,7 @@ public: lldb::OptionValueSP DeepCopy() const override; - //--------------------------------------------------------------------- // Subclass specific functions - //--------------------------------------------------------------------- lldb::Format GetCurrentValue() const { return m_current_value; } diff --git a/include/lldb/Interpreter/OptionValueFormatEntity.h b/include/lldb/Interpreter/OptionValueFormatEntity.h index 5d5a8ca02c970..b05be959f3d4e 100644 --- a/include/lldb/Interpreter/OptionValueFormatEntity.h +++ b/include/lldb/Interpreter/OptionValueFormatEntity.h @@ -1,9 +1,8 @@ //===-- OptionValueFormatEntity.h --------------------------------*- C++-*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -21,9 +20,7 @@ public: ~OptionValueFormatEntity() override {} - //--------------------------------------------------------------------- // Virtual subclass pure virtual overrides - //--------------------------------------------------------------------- OptionValue::Type GetType() const override { return eTypeFormatEntity; } @@ -44,9 +41,7 @@ public: size_t AutoComplete(CommandInterpreter &interpreter, CompletionRequest &request) override; - //--------------------------------------------------------------------- // Subclass specific functions - //--------------------------------------------------------------------- FormatEntity::Entry &GetCurrentValue() { return m_current_entry; } diff --git a/include/lldb/Interpreter/OptionValueLanguage.h b/include/lldb/Interpreter/OptionValueLanguage.h index 9d4956c6d7896..505dc89e92082 100644 --- a/include/lldb/Interpreter/OptionValueLanguage.h +++ b/include/lldb/Interpreter/OptionValueLanguage.h @@ -1,10 +1,9 @@ //===-- OptionValueLanguage.h -------------------------------------*- C++ //-*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -28,9 +27,7 @@ public: ~OptionValueLanguage() override {} - //--------------------------------------------------------------------- // Virtual subclass pure virtual overrides - //--------------------------------------------------------------------- OptionValue::Type GetType() const override { return eTypeLanguage; } @@ -52,9 +49,7 @@ public: lldb::OptionValueSP DeepCopy() const override; - //--------------------------------------------------------------------- // Subclass specific functions - //--------------------------------------------------------------------- lldb::LanguageType GetCurrentValue() const { return m_current_value; } diff --git a/include/lldb/Interpreter/OptionValuePathMappings.h b/include/lldb/Interpreter/OptionValuePathMappings.h index 85f9926b21f80..35c2af45bc974 100644 --- a/include/lldb/Interpreter/OptionValuePathMappings.h +++ b/include/lldb/Interpreter/OptionValuePathMappings.h @@ -1,9 +1,8 @@ //===-- OptionValuePathMappings.h -------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -22,9 +21,7 @@ public: ~OptionValuePathMappings() override {} - //--------------------------------------------------------------------- // Virtual subclass pure virtual overrides - //--------------------------------------------------------------------- OptionValue::Type GetType() const override { return eTypePathMap; } @@ -48,9 +45,7 @@ public: bool IsAggregateValue() const override { return true; } - //--------------------------------------------------------------------- // Subclass specific functions - //--------------------------------------------------------------------- PathMappingList &GetCurrentValue() { return m_path_mappings; } diff --git a/include/lldb/Interpreter/OptionValueProperties.h b/include/lldb/Interpreter/OptionValueProperties.h index 941e48561f77f..bea2b3c91e009 100644 --- a/include/lldb/Interpreter/OptionValueProperties.h +++ b/include/lldb/Interpreter/OptionValueProperties.h @@ -1,9 +1,8 @@ //===-- OptionValueProperties.h ---------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -27,7 +26,7 @@ public: OptionValueProperties() : OptionValue(), m_name(), m_properties(), m_name_to_index() {} - OptionValueProperties(const ConstString &name); + OptionValueProperties(ConstString name); OptionValueProperties(const OptionValueProperties &global_properties); @@ -63,36 +62,28 @@ public: // bool // GetQualifiedName (Stream &strm); - //--------------------------------------------------------------------- // Subclass specific functions - //--------------------------------------------------------------------- virtual size_t GetNumProperties() const; - //--------------------------------------------------------------------- // 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 - //--------------------------------------------------------------------- - virtual uint32_t GetPropertyIndex(const ConstString &name) const; + virtual uint32_t GetPropertyIndex(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 - //--------------------------------------------------------------------- virtual const Property *GetProperty(const ExecutionContext *exe_ctx, bool will_modify, - const ConstString &name) const; + ConstString name) const; virtual const Property *GetPropertyAtIndex(const ExecutionContext *exe_ctx, bool will_modify, uint32_t idx) const; - //--------------------------------------------------------------------- // Property can be be a property path like // "target.process.extra-startup-command" - //--------------------------------------------------------------------- virtual const Property *GetPropertyAtPath(const ExecutionContext *exe_ctx, bool will_modify, llvm::StringRef property_path) const; @@ -102,7 +93,7 @@ public: uint32_t idx) const; virtual lldb::OptionValueSP GetValueForKey(const ExecutionContext *exe_ctx, - const ConstString &key, + ConstString key, bool value_will_be_modified) const; lldb::OptionValueSP GetSubValue(const ExecutionContext *exe_ctx, @@ -200,11 +191,11 @@ public: OptionValueFileSpecList *GetPropertyAtIndexAsOptionValueFileSpecList( const ExecutionContext *exe_ctx, bool will_modify, uint32_t idx) const; - void AppendProperty(const ConstString &name, const ConstString &desc, + void AppendProperty(ConstString name, ConstString desc, bool is_global, const lldb::OptionValueSP &value_sp); lldb::OptionValuePropertiesSP GetSubProperty(const ExecutionContext *exe_ctx, - const ConstString &name); + ConstString name); void SetValueChangedCallback(uint32_t property_idx, OptionValueChangedCallback callback, diff --git a/include/lldb/Interpreter/OptionValueRegex.h b/include/lldb/Interpreter/OptionValueRegex.h index a77eb5323f23d..f5b2557634dfb 100644 --- a/include/lldb/Interpreter/OptionValueRegex.h +++ b/include/lldb/Interpreter/OptionValueRegex.h @@ -1,9 +1,8 @@ //===-- OptionValueRegex.h --------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -22,9 +21,7 @@ public: ~OptionValueRegex() override = default; - //--------------------------------------------------------------------- // Virtual subclass pure virtual overrides - //--------------------------------------------------------------------- OptionValue::Type GetType() const override { return eTypeRegex; } @@ -46,9 +43,7 @@ public: lldb::OptionValueSP DeepCopy() const override; - //--------------------------------------------------------------------- // Subclass specific functions - //--------------------------------------------------------------------- const RegularExpression *GetCurrentValue() const { return (m_regex.IsValid() ? &m_regex : nullptr); } diff --git a/include/lldb/Interpreter/OptionValueSInt64.h b/include/lldb/Interpreter/OptionValueSInt64.h index f630cbb8e2837..c2e8ff43a99a0 100644 --- a/include/lldb/Interpreter/OptionValueSInt64.h +++ b/include/lldb/Interpreter/OptionValueSInt64.h @@ -1,10 +1,9 @@ //===-- OptionValueSInt64.h --------------------------------------*- C++ //-*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -37,9 +36,7 @@ public: ~OptionValueSInt64() override {} - //--------------------------------------------------------------------- // Virtual subclass pure virtual overrides - //--------------------------------------------------------------------- OptionValue::Type GetType() const override { return eTypeSInt64; } @@ -61,9 +58,7 @@ public: lldb::OptionValueSP DeepCopy() const override; - //--------------------------------------------------------------------- // Subclass specific functions - //--------------------------------------------------------------------- const int64_t &operator=(int64_t value) { m_current_value = value; diff --git a/include/lldb/Interpreter/OptionValueString.h b/include/lldb/Interpreter/OptionValueString.h index ab15595a08b4d..d9e76d8b58fea 100644 --- a/include/lldb/Interpreter/OptionValueString.h +++ b/include/lldb/Interpreter/OptionValueString.h @@ -1,9 +1,8 @@ //===-- OptionValueString.h -------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -72,9 +71,7 @@ public: ~OptionValueString() override = default; - //--------------------------------------------------------------------- // Virtual subclass pure virtual overrides - //--------------------------------------------------------------------- OptionValue::Type GetType() const override { return eTypeString; } @@ -96,9 +93,7 @@ public: lldb::OptionValueSP DeepCopy() const override; - //--------------------------------------------------------------------- // Subclass specific functions - //--------------------------------------------------------------------- Flags &GetOptions() { return m_options; } diff --git a/include/lldb/Interpreter/OptionValueUInt64.h b/include/lldb/Interpreter/OptionValueUInt64.h index 5cbcafdb6e58c..5978cdb4434f0 100644 --- a/include/lldb/Interpreter/OptionValueUInt64.h +++ b/include/lldb/Interpreter/OptionValueUInt64.h @@ -1,10 +1,9 @@ //===-- OptionValueUInt64.h --------------------------------------*- C++ //-*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -28,17 +27,13 @@ public: ~OptionValueUInt64() override {} - //--------------------------------------------------------------------- // 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. - //--------------------------------------------------------------------- static lldb::OptionValueSP Create(const char *, Status &) = delete; static lldb::OptionValueSP Create(llvm::StringRef value_str, Status &error); - //--------------------------------------------------------------------- // Virtual subclass pure virtual overrides - //--------------------------------------------------------------------- OptionValue::Type GetType() const override { return eTypeUInt64; } @@ -60,9 +55,7 @@ public: lldb::OptionValueSP DeepCopy() const override; - //--------------------------------------------------------------------- // Subclass specific functions - //--------------------------------------------------------------------- const uint64_t &operator=(uint64_t value) { m_current_value = value; diff --git a/include/lldb/Interpreter/OptionValueUUID.h b/include/lldb/Interpreter/OptionValueUUID.h index c2ee48962b42f..7273e35bd75b7 100644 --- a/include/lldb/Interpreter/OptionValueUUID.h +++ b/include/lldb/Interpreter/OptionValueUUID.h @@ -1,9 +1,8 @@ //===-- OptionValueUUID.h --------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -23,9 +22,7 @@ public: ~OptionValueUUID() override {} - //--------------------------------------------------------------------- // Virtual subclass pure virtual overrides - //--------------------------------------------------------------------- OptionValue::Type GetType() const override { return eTypeUUID; } @@ -47,9 +44,7 @@ public: lldb::OptionValueSP DeepCopy() const override; - //--------------------------------------------------------------------- // Subclass specific functions - //--------------------------------------------------------------------- UUID &GetCurrentValue() { return m_uuid; } diff --git a/include/lldb/Interpreter/OptionValues.h b/include/lldb/Interpreter/OptionValues.h index e177d743ff185..d90b2867a4b07 100644 --- a/include/lldb/Interpreter/OptionValues.h +++ b/include/lldb/Interpreter/OptionValues.h @@ -1,9 +1,8 @@ //===-- OptionValues.h ------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// diff --git a/include/lldb/Interpreter/Options.h b/include/lldb/Interpreter/Options.h index aa9e564083a90..a008d51d721ee 100644 --- a/include/lldb/Interpreter/Options.h +++ b/include/lldb/Interpreter/Options.h @@ -1,9 +1,8 @@ //===-- Options.h -----------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -47,8 +46,7 @@ static inline bool isprint8(int ch) { return isprint(ch); } -//---------------------------------------------------------------------- -/// @class Options Options.h "lldb/Interpreter/Options.h" +/// \class Options Options.h "lldb/Interpreter/Options.h" /// A command line option parsing protocol class. /// /// Options is designed to be subclassed to contain all needed options for a @@ -61,7 +59,6 @@ static inline bool isprint8(int ch) { /// *optstring, const struct option *longopts, int *longindex); /// \endcode /// -//---------------------------------------------------------------------- class Options { public: Options(); @@ -74,12 +71,10 @@ public: uint32_t NumCommandOptions(); - //------------------------------------------------------------------ /// Get the option definitions to use when parsing Args options. /// - /// @see Args::ParseOptions (Options&) - /// @see man getopt_long_only - //------------------------------------------------------------------ + /// \see Args::ParseOptions (Options&) + /// \see man getopt_long_only Option *GetLongOptions(); // This gets passed the short option as an integer... @@ -115,7 +110,6 @@ public: // 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 @@ -132,7 +126,6 @@ public: /// 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, @@ -147,66 +140,60 @@ public: Status NotifyOptionParsingFinished(ExecutionContext *execution_context); - //------------------------------------------------------------------ /// Set the value of an option. /// - /// @param[in] option_idx + /// \param[in] option_idx /// The index into the "struct option" array that was returned /// by Options::GetLongOptions(). /// - /// @param[in] option_arg + /// \param[in] option_arg /// The argument value for the option that the user entered, or /// nullptr if there is no argument for the current option. /// - /// @param[in] execution_context + /// \param[in] execution_context /// The execution context to use for evaluating the option. /// May be nullptr if the option is to be evaluated outside any /// particular context. /// - /// @see Args::ParseOptions (Options&) - /// @see man getopt_long_only - //------------------------------------------------------------------ + /// \see Args::ParseOptions (Options&) + /// \see man getopt_long_only virtual Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg, ExecutionContext *execution_context) = 0; - //------------------------------------------------------------------ /// Handles the generic bits of figuring out whether we are in an option, /// and if so completing it. /// - /// @param[in/out] request + /// \param[in/out] request /// The completion request that we need to act upon. /// - /// @param[in] interpreter + /// \param[in] interpreter /// The interpreter that's doing the completing. /// /// 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. /// - /// @return + /// \return /// \btrue if we were in an option, \bfalse otherwise. - //------------------------------------------------------------------ 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. /// - /// @param[in/out] request + /// \param[in/out] request /// The completion request that we need to act upon. /// - /// @param[in] interpreter + /// \param[in] interpreter /// 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. /// - /// @return + /// \return /// \btrue if we were in an option, \bfalse otherwise. - //------------------------------------------------------------------ virtual bool HandleOptionArgumentCompletion(lldb_private::CompletionRequest &request, OptionElementVector &opt_element_vector, @@ -284,40 +271,36 @@ public: ~OptionGroupOptions() override = default; - //---------------------------------------------------------------------- /// Append options from a OptionGroup class. /// /// Append all options from \a group using the exact same option groups that /// each option is defined with. /// - /// @param[in] group + /// \param[in] group /// A group of options to take option values from and copy their /// definitions into this class. - //---------------------------------------------------------------------- void Append(OptionGroup *group); - //---------------------------------------------------------------------- /// 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". /// - /// @param[in] group + /// \param[in] group /// A group of options to take option values from and copy their /// definitions into this class. /// - /// @param[in] src_mask + /// \param[in] src_mask /// When copying options from \a group, you might only want some of /// the options to be appended to this group. This mask allows you /// to control which options from \a group get added. It also allows /// you to specify the same options from \a group multiple times /// for different option sets. /// - /// @param[in] dst_mask + /// \param[in] dst_mask /// Set the usage mask for any copied options to \a dst_mask after /// copying the option definition. - //---------------------------------------------------------------------- void Append(OptionGroup *group, uint32_t src_mask, uint32_t dst_mask); void Finalize(); diff --git a/include/lldb/Interpreter/Property.h b/include/lldb/Interpreter/Property.h index a7515e9903a49..797aee4be8159 100644 --- a/include/lldb/Interpreter/Property.h +++ b/include/lldb/Interpreter/Property.h @@ -1,9 +1,8 @@ //===-- Property.h ----------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -38,7 +37,7 @@ class Property { public: Property(const PropertyDefinition &definition); - Property(const ConstString &name, const ConstString &desc, bool is_global, + Property(ConstString name, ConstString desc, bool is_global, const lldb::OptionValueSP &value_sp); llvm::StringRef GetName() const { return m_name.GetStringRef(); } diff --git a/include/lldb/Interpreter/ScriptInterpreter.h b/include/lldb/Interpreter/ScriptInterpreter.h index 640d9d34c617d..c8fa3901350d7 100644 --- a/include/lldb/Interpreter/ScriptInterpreter.h +++ b/include/lldb/Interpreter/ScriptInterpreter.h @@ -1,9 +1,8 @@ //===-- ScriptInterpreter.h -------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -35,7 +34,7 @@ private: class ScriptInterpreter : public PluginInterface { public: - typedef enum { + enum ScriptReturnType { eScriptReturnTypeCharPtr, eScriptReturnTypeBool, eScriptReturnTypeShortInt, @@ -51,10 +50,9 @@ public: eScriptReturnTypeChar, eScriptReturnTypeCharStrOrNone, eScriptReturnTypeOpaqueObject - } ScriptReturnType; + }; - ScriptInterpreter(CommandInterpreter &interpreter, - lldb::ScriptLanguage script_lang); + ScriptInterpreter(Debugger &debugger, lldb::ScriptLanguage script_lang); ~ScriptInterpreter() override; @@ -248,7 +246,7 @@ public: lldb::BreakpointSP &bkpt_sp) { return StructuredData::GenericSP(); } - + virtual bool ScriptedBreakpointResolverSearchCallback(StructuredData::GenericSP implementor_sp, SymbolContext *sym_ctx) @@ -461,8 +459,6 @@ public: int GetMasterFileDescriptor(); - CommandInterpreter &GetCommandInterpreter(); - static std::string LanguageToString(lldb::ScriptLanguage language); static lldb::ScriptLanguage StringToLanguage(const llvm::StringRef &string); @@ -472,7 +468,7 @@ public: lldb::ScriptLanguage GetLanguage() { return m_script_lang; } protected: - CommandInterpreter &m_interpreter; + Debugger &m_debugger; lldb::ScriptLanguage m_script_lang; }; diff --git a/include/lldb/Symbol/ArmUnwindInfo.h b/include/lldb/Symbol/ArmUnwindInfo.h index 422408b034c6e..a74b4442df144 100644 --- a/include/lldb/Symbol/ArmUnwindInfo.h +++ b/include/lldb/Symbol/ArmUnwindInfo.h @@ -1,21 +1,19 @@ //===-- ArmUnwindInfo.h -----------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// #ifndef liblldb_ArmUnwindInfo_h_ #define liblldb_ArmUnwindInfo_h_ -#include <vector> - -#include "lldb/Core/RangeMap.h" #include "lldb/Symbol/ObjectFile.h" #include "lldb/Utility/DataExtractor.h" +#include "lldb/Utility/RangeMap.h" #include "lldb/lldb-private.h" +#include <vector> /* * Unwind information reader and parser for the ARM exception handling ABI diff --git a/include/lldb/Symbol/Block.h b/include/lldb/Symbol/Block.h index 2428a1d3ffca0..36d0944f12b04 100644 --- a/include/lldb/Symbol/Block.h +++ b/include/lldb/Symbol/Block.h @@ -1,31 +1,28 @@ //===-- Block.h -------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// #ifndef liblldb_Block_h_ #define liblldb_Block_h_ -#include <vector> - #include "lldb/Core/AddressRange.h" -#include "lldb/Core/RangeMap.h" #include "lldb/Symbol/CompilerType.h" #include "lldb/Symbol/LineEntry.h" #include "lldb/Symbol/SymbolContext.h" #include "lldb/Symbol/SymbolContextScope.h" +#include "lldb/Utility/RangeMap.h" #include "lldb/Utility/Stream.h" #include "lldb/Utility/UserID.h" #include "lldb/lldb-private.h" +#include <vector> namespace lldb_private { -//---------------------------------------------------------------------- -/// @class Block Block.h "lldb/Symbol/Block.h" +/// \class Block Block.h "lldb/Symbol/Block.h" /// A class that describes a single lexical block. /// /// A Function object owns a BlockList object which owns one or more @@ -41,20 +38,18 @@ namespace lldb_private { /// 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: typedef RangeArray<uint32_t, uint32_t, 1> RangeList; typedef RangeList::Entry Range; - //------------------------------------------------------------------ /// 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. /// - /// @param[in] uid + /// \param[in] uid /// The UID for a given block. This value is given by the /// SymbolFile plug-in and can be any value that helps the /// SymbolFile plug-in to match this block back to the debug @@ -62,50 +57,41 @@ public: /// depth parsing. Common values would be the index into a /// table, or an offset into the debug information. /// - /// @param[in] depth + /// \param[in] depth /// The integer depth of this block in the block list hierarchy. /// - /// @param[in] block_list + /// \param[in] block_list /// The block list that this object belongs to. /// - /// @see BlockList - //------------------------------------------------------------------ + /// \see BlockList Block(lldb::user_id_t uid); - //------------------------------------------------------------------ /// Destructor. - //------------------------------------------------------------------ ~Block() override; - //------------------------------------------------------------------ /// Add a child to this object. /// - /// @param[in] child_block_sp + /// \param[in] child_block_sp /// A shared pointer to a child block that will get added to /// this block. - //------------------------------------------------------------------ void AddChild(const lldb::BlockSP &child_block_sp); - //------------------------------------------------------------------ /// Add a new offset range to this block. /// - /// @param[in] start_offset + /// \param[in] start_offset /// An offset into this Function's address range that /// describes the start address of a range for this block. /// - /// @param[in] end_offset + /// \param[in] end_offset /// An offset into this Function's address range that /// describes the end address of a range for this block. - //------------------------------------------------------------------ void AddRange(const Range &range); void FinalizeRanges(); - //------------------------------------------------------------------ - /// @copydoc SymbolContextScope::CalculateSymbolContext(SymbolContext*) + /// \copydoc SymbolContextScope::CalculateSymbolContext(SymbolContext*) /// - /// @see SymbolContextScope - //------------------------------------------------------------------ + /// \see SymbolContextScope void CalculateSymbolContext(SymbolContext *sc) override; lldb::ModuleSP CalculateSymbolContextModule() override; @@ -116,69 +102,59 @@ public: Block *CalculateSymbolContextBlock() override; - //------------------------------------------------------------------ /// Check if an offset is in one of the block offset ranges. /// - /// @param[in] range_offset + /// \param[in] range_offset /// An offset into the Function's address range. /// - /// @return + /// \return /// Returns \b true if \a range_offset falls in one of this /// block's ranges, \b false otherwise. - //------------------------------------------------------------------ bool Contains(lldb::addr_t range_offset) const; - //------------------------------------------------------------------ /// Check if a offset range is in one of the block offset ranges. /// - /// @param[in] range + /// \param[in] range /// An offset range into the Function's address range. /// - /// @return + /// \return /// Returns \b true if \a range falls in one of this /// block's ranges, \b false otherwise. - //------------------------------------------------------------------ bool Contains(const Range &range) const; - //------------------------------------------------------------------ /// Check if this object contains "block" as a child block at any depth. /// - /// @param[in] block + /// \param[in] block /// A potential child block. /// - /// @return + /// \return /// Returns \b true if \a block is a child of this block, \b /// false otherwise. - //------------------------------------------------------------------ bool Contains(const Block *block) const; - //------------------------------------------------------------------ /// Dump the block contents. /// - /// @param[in] s + /// \param[in] s /// The stream to which to dump the object description. /// - /// @param[in] base_addr + /// \param[in] base_addr /// The resolved start address of the Function's address /// range. This should be resolved as the file or load address /// prior to passing the value into this function for dumping. /// - /// @param[in] depth + /// \param[in] depth /// Limit the number of levels deep that this function should /// print as this block can contain child blocks. Specify /// INT_MAX to dump all child blocks. /// - /// @param[in] show_context + /// \param[in] show_context /// If \b true, variables will dump their context information. - //------------------------------------------------------------------ void Dump(Stream *s, lldb::addr_t base_addr, int32_t depth, bool show_context) const; - //------------------------------------------------------------------ - /// @copydoc SymbolContextScope::DumpSymbolContext(Stream*) + /// \copydoc SymbolContextScope::DumpSymbolContext(Stream*) /// - /// @see SymbolContextScope - //------------------------------------------------------------------ + /// \see SymbolContextScope void DumpSymbolContext(Stream *s) override; void DumpAddressRanges(Stream *s, lldb::addr_t base_addr); @@ -186,185 +162,177 @@ public: void GetDescription(Stream *s, Function *function, lldb::DescriptionLevel level, Target *target) const; - //------------------------------------------------------------------ /// Get the parent block. /// - /// @return + /// \return /// The parent block pointer, or nullptr if this block has no /// parent. - //------------------------------------------------------------------ Block *GetParent() const; - //------------------------------------------------------------------ /// Get the inlined block that contains this block. /// - /// @return + /// \return /// If this block contains inlined function info, it will return /// this block, else parent blocks will be searched to see if /// any contain this block. nullptr will be returned if this block /// nor any parent blocks are inlined function blocks. - //------------------------------------------------------------------ Block *GetContainingInlinedBlock(); - //------------------------------------------------------------------ /// Get the inlined parent block for this block. /// - /// @return + /// \return /// The parent block pointer, or nullptr if this block has no /// parent. - //------------------------------------------------------------------ Block *GetInlinedParent(); //------------------------------------------------------------------ - /// Get the sibling block for this block. + /// Get the inlined block at the given call site that contains this block. + /// + /// @param[in] find_call_site + /// a declaration with the file and line of the call site to find. /// /// @return + /// If this block contains inlined function info and is at the call + /// site given by the file and line at the given \b declaration, then + /// it will return this block, otherwise the parent blocks will be + /// searched to see if any is at the call site. nullptr will be returned + /// if no block is found at the call site. + //------------------------------------------------------------------ + Block * + GetContainingInlinedBlockWithCallSite(const Declaration &find_call_site); + + /// Get the sibling block for this block. + /// + /// \return /// The sibling block pointer, or nullptr if this block has no /// sibling. - //------------------------------------------------------------------ Block *GetSibling() const; - //------------------------------------------------------------------ /// Get the first child block. /// - /// @return + /// \return /// The first child block pointer, or nullptr if this block has no /// children. - //------------------------------------------------------------------ Block *GetFirstChild() const { return (m_children.empty() ? nullptr : m_children.front().get()); } - //------------------------------------------------------------------ /// Get the variable list for this block only. /// - /// @param[in] can_create + /// \param[in] can_create /// If \b true, the variables can be parsed if they already /// haven't been, else the current state of the block will be /// returned. /// - /// @return + /// \return /// A variable list shared pointer that contains all variables /// for this block. - //------------------------------------------------------------------ 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. /// - /// @param[in] get_child_variables + /// \param[in] get_child_variables /// If \b true, all variables from all child blocks will be /// added to the variable list. /// - /// @param[in] can_create + /// \param[in] can_create /// If \b true, the variables can be parsed if they already /// haven't been, else the current state of the block will be /// returned. Passing \b true for this parameter can be used /// to see the current state of what has been parsed up to this /// point. /// - /// @param[in] add_inline_child_block_variables + /// \param[in] add_inline_child_block_variables /// If this is \b false, no child variables of child blocks /// that are inlined functions will be gotten. If \b true then /// all child variables will be added regardless of whether they /// come from inlined functions or not. /// - /// @return + /// \return /// A variable list shared pointer that contains all variables /// for this block. - //------------------------------------------------------------------ uint32_t AppendBlockVariables(bool can_create, bool get_child_block_variables, bool stop_if_child_block_is_inlined_function, const std::function<bool(Variable *)> &filter, VariableList *variable_list); - //------------------------------------------------------------------ /// Appends the variables from this block, and optionally from all parent /// blocks, to \a variable_list. /// - /// @param[in] can_create + /// \param[in] can_create /// If \b true, the variables can be parsed if they already /// haven't been, else the current state of the block will be /// returned. Passing \b true for this parameter can be used /// to see the current state of what has been parsed up to this /// point. /// - /// @param[in] get_parent_variables + /// \param[in] get_parent_variables /// If \b true, all variables from all parent blocks will be /// added to the variable list. /// - /// @param[in] stop_if_block_is_inlined_function + /// \param[in] stop_if_block_is_inlined_function /// If \b true, all variables from all parent blocks will be /// added to the variable list until there are no parent blocks /// or the parent block has inlined function info. /// - /// @param[in,out] variable_list + /// \param[in,out] variable_list /// All variables in this block, and optionally all parent /// blocks will be added to this list. /// - /// @return + /// \return /// The number of variable that were appended to \a /// variable_list. - //------------------------------------------------------------------ uint32_t AppendVariables(bool can_create, bool get_parent_variables, bool stop_if_block_is_inlined_function, const std::function<bool(Variable *)> &filter, VariableList *variable_list); - //------------------------------------------------------------------ /// Get const accessor for any inlined function information. /// - /// @return + /// \return /// A const pointer to any inlined function information, or nullptr /// if this is a regular block. - //------------------------------------------------------------------ const InlineFunctionInfo *GetInlinedFunctionInfo() const { return m_inlineInfoSP.get(); } - //------------------------------------------------------------------ /// Get the symbol file which contains debug info for this block's /// symbol context module. /// - /// @return A pointer to the symbol file or nullptr. - //------------------------------------------------------------------ + /// \return A pointer to the symbol file or nullptr. SymbolFile *GetSymbolFile(); CompilerDeclContext GetDeclContext(); - //------------------------------------------------------------------ /// 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. /// - /// @return + /// \return /// The number of bytes that this object occupies in memory. - //------------------------------------------------------------------ size_t MemorySize() const; - //------------------------------------------------------------------ /// Set accessor for any inlined function information. /// - /// @param[in] name + /// \param[in] name /// The method name for the inlined function. This value should /// not be nullptr. /// - /// @param[in] mangled + /// \param[in] mangled /// The mangled method name for the inlined function. This can /// be nullptr if there is no mangled name for an inlined function /// or if the name is the same as \a name. /// - /// @param[in] decl_ptr + /// \param[in] decl_ptr /// A optional pointer to declaration information for the /// inlined function information. This value can be nullptr to /// indicate that no declaration information is available. /// - /// @param[in] call_decl_ptr + /// \param[in] call_decl_ptr /// Optional calling location declaration information that /// describes from where this inlined function was called. - //------------------------------------------------------------------ void SetInlinedFunctionInfo(const char *name, const char *mangled, const Declaration *decl_ptr, const Declaration *call_decl_ptr); @@ -373,15 +341,13 @@ public: m_parent_scope = parent_scope; } - //------------------------------------------------------------------ /// 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. /// - /// @param[in] variable_list_sp + /// \param[in] variable_list_sp /// A shared pointer to a VariableList. - //------------------------------------------------------------------ void SetVariableList(lldb::VariableListSP &variable_list_sp) { m_variable_list_sp = variable_list_sp; } @@ -403,10 +369,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. - //------------------------------------------------------------------ bool GetRangeAtIndex(uint32_t range_idx, AddressRange &range); bool GetStartAddress(Address &addr); @@ -415,9 +379,7 @@ public: protected: typedef std::vector<lldb::BlockSP> collection; - //------------------------------------------------------------------ // Member variables. - //------------------------------------------------------------------ SymbolContextScope *m_parent_scope; collection m_children; RangeList m_ranges; diff --git a/include/lldb/Symbol/ClangASTContext.h b/include/lldb/Symbol/ClangASTContext.h index 4cff9b2565709..d0a834e01f3aa 100644 --- a/include/lldb/Symbol/ClangASTContext.h +++ b/include/lldb/Symbol/ClangASTContext.h @@ -1,9 +1,8 @@ //===-- ClangASTContext.h ---------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -47,25 +46,19 @@ public: typedef void (*CompleteObjCInterfaceDeclCallback)(void *baton, clang::ObjCInterfaceDecl *); - //------------------------------------------------------------------ // llvm casting support - //------------------------------------------------------------------ static bool classof(const TypeSystem *ts) { return ts->getKind() == TypeSystem::eKindClang; } - //------------------------------------------------------------------ // Constructors and Destructors - //------------------------------------------------------------------ ClangASTContext(const char *triple = nullptr); ~ClangASTContext() override; void Finalize() override; - //------------------------------------------------------------------ // PluginInterface functions - //------------------------------------------------------------------ ConstString GetPluginName() override; uint32_t GetPluginVersion() override; @@ -111,6 +104,9 @@ public: clang::TargetInfo *getTargetInfo(); + void setSema(clang::Sema *s); + clang::Sema *getSema() { return m_sema; } + void Clear(); const char *GetTargetTriple(); @@ -122,7 +118,7 @@ public: bool HasExternalSource(); void SetExternalSource( - llvm::IntrusiveRefCntPtr<clang::ExternalASTSource> &ast_source_ap); + llvm::IntrusiveRefCntPtr<clang::ExternalASTSource> &ast_source_up); void RemoveExternalSource(); @@ -154,9 +150,7 @@ public: static ClangASTMetadata *GetMetadata(clang::ASTContext *ast, const void *object); - //------------------------------------------------------------------ // Basic Types - //------------------------------------------------------------------ CompilerType GetBuiltinTypeForEncodingAndBitSize(lldb::Encoding encoding, size_t bit_size) override; @@ -169,9 +163,9 @@ public: lldb::BasicType type); static CompilerType GetBasicType(clang::ASTContext *ast, - const ConstString &name); + ConstString name); - static lldb::BasicType GetBasicTypeEnumeration(const ConstString &name); + static lldb::BasicType GetBasicTypeEnumeration(ConstString name); CompilerType GetBuiltinTypeForDWARFEncodingAndBitSize(const char *type_name, uint32_t dw_ate, @@ -212,7 +206,7 @@ public: template <typename RecordDeclType> CompilerType - GetTypeForIdentifier(const ConstString &type_name, + GetTypeForIdentifier(ConstString type_name, clang::DeclContext *decl_context = nullptr) { CompilerType compiler_type; @@ -244,13 +238,13 @@ public: } CompilerType CreateStructForIdentifier( - const ConstString &type_name, + ConstString type_name, const std::initializer_list<std::pair<const char *, CompilerType>> &type_fields, bool packed = false); CompilerType GetOrCreateStructForIdentifier( - const ConstString &type_name, + ConstString type_name, const std::initializer_list<std::pair<const char *, CompilerType>> &type_fields, bool packed = false); @@ -258,9 +252,7 @@ public: static bool IsOperator(const char *name, clang::OverloadedOperatorKind &op_kind); - //------------------------------------------------------------------ // Structure, Unions, Classes - //------------------------------------------------------------------ static clang::AccessSpecifier ConvertAccessTypeToAccessSpecifier(lldb::AccessType access); @@ -350,20 +342,18 @@ public: // Returns a mask containing bits from the ClangASTContext::eTypeXXX // enumerations - //------------------------------------------------------------------ // Namespace Declarations - //------------------------------------------------------------------ clang::NamespaceDecl * - GetUniqueNamespaceDeclaration(const char *name, clang::DeclContext *decl_ctx); + GetUniqueNamespaceDeclaration(const char *name, clang::DeclContext *decl_ctx, + bool is_inline = false); static clang::NamespaceDecl * GetUniqueNamespaceDeclaration(clang::ASTContext *ast, const char *name, - clang::DeclContext *decl_ctx); + clang::DeclContext *decl_ctx, + bool is_inline = false); - //------------------------------------------------------------------ // Function Types - //------------------------------------------------------------------ clang::FunctionDecl * CreateFunctionDeclaration(clang::DeclContext *decl_ctx, const char *name, @@ -412,25 +402,19 @@ public: CompilerType CreateBlockPointerType(const CompilerType &function_type); - //------------------------------------------------------------------ // Array Types - //------------------------------------------------------------------ CompilerType CreateArrayType(const CompilerType &element_type, size_t element_count, bool is_vector); - //------------------------------------------------------------------ // Enumeration Types - //------------------------------------------------------------------ CompilerType CreateEnumerationType(const char *name, clang::DeclContext *decl_ctx, const Declaration &decl, const CompilerType &integer_qual_type, bool is_scoped); - //------------------------------------------------------------------ // Integer type functions - //------------------------------------------------------------------ static CompilerType GetIntTypeFromBitSize(clang::ASTContext *ast, size_t bit_size, bool is_signed); @@ -442,22 +426,16 @@ public: static CompilerType GetPointerSizedIntType(clang::ASTContext *ast, bool is_signed); - //------------------------------------------------------------------ // Floating point functions - //------------------------------------------------------------------ static CompilerType GetFloatTypeFromBitSize(clang::ASTContext *ast, size_t bit_size); - //------------------------------------------------------------------ // TypeSystem methods - //------------------------------------------------------------------ DWARFASTParser *GetDWARFParser() override; - PDBASTParser *GetPDBParser(); + PDBASTParser *GetPDBParser() override; - //------------------------------------------------------------------ // ClangASTContext callbacks for external source lookups. - //------------------------------------------------------------------ static void CompleteTagDecl(void *baton, clang::TagDecl *); static void CompleteObjCInterfaceDecl(void *baton, @@ -472,9 +450,7 @@ public: llvm::DenseMap<const clang::CXXRecordDecl *, clang::CharUnits> &vbase_offsets); - //---------------------------------------------------------------------- // CompilerDecl override functions - //---------------------------------------------------------------------- ConstString DeclGetName(void *opaque_decl) override; ConstString DeclGetMangledName(void *opaque_decl) override; @@ -488,9 +464,7 @@ public: CompilerType DeclGetFunctionArgumentType(void *opaque_decl, size_t arg_idx) override; - //---------------------------------------------------------------------- // CompilerDeclContext override functions - //---------------------------------------------------------------------- std::vector<CompilerDecl> DeclContextFindDeclByName(void *opaque_decl_ctx, ConstString name, @@ -507,9 +481,10 @@ public: bool *is_instance_method_ptr, ConstString *language_object_name_ptr) override; - //---------------------------------------------------------------------- + bool DeclContextIsContainedInLookup(void *opaque_decl_ctx, + void *other_opaque_decl_ctx) override; + // Clang specific clang::DeclContext functions - //---------------------------------------------------------------------- static clang::DeclContext * DeclContextGetAsDeclContext(const CompilerDeclContext &dc); @@ -532,9 +507,7 @@ public: static clang::ASTContext * DeclContextGetClangASTContext(const CompilerDeclContext &dc); - //---------------------------------------------------------------------- // Tests - //---------------------------------------------------------------------- bool IsArrayType(lldb::opaque_compiler_type_t type, CompilerType *element_type, uint64_t *size, @@ -625,6 +598,8 @@ public: bool IsVoidType(lldb::opaque_compiler_type_t type) override; + bool CanPassInRegisters(const CompilerType &type) override; + bool SupportsLanguage(lldb::LanguageType language) override; static bool GetCXXClassName(const CompilerType &type, @@ -633,15 +608,11 @@ public: static bool GetObjCClassName(const CompilerType &type, std::string &class_name); - //---------------------------------------------------------------------- // Type Completion - //---------------------------------------------------------------------- bool GetCompleteType(lldb::opaque_compiler_type_t type) override; - //---------------------------------------------------------------------- // Accessors - //---------------------------------------------------------------------- ConstString GetTypeName(lldb::opaque_compiler_type_t type) override; @@ -655,9 +626,7 @@ public: unsigned GetTypeQualifiers(lldb::opaque_compiler_type_t type) override; - //---------------------------------------------------------------------- // Creating related types - //---------------------------------------------------------------------- // Using the current type, create a new typedef to that type using // "typedef_name" as the name and "decl_ctx" as the decl context. @@ -717,22 +686,21 @@ public: // If the current object represents a typedef type, get the underlying type CompilerType GetTypedefedType(lldb::opaque_compiler_type_t type) override; - //---------------------------------------------------------------------- // Create related types using the current type's AST - //---------------------------------------------------------------------- CompilerType GetBasicTypeFromAST(lldb::BasicType basic_type) override; - //---------------------------------------------------------------------- // Exploring the type - //---------------------------------------------------------------------- - uint64_t GetByteSize(lldb::opaque_compiler_type_t type, + llvm::Optional<uint64_t> GetByteSize(lldb::opaque_compiler_type_t type, ExecutionContextScope *exe_scope) { - return (GetBitSize(type, exe_scope) + 7) / 8; + if (llvm::Optional<uint64_t> bit_size = GetBitSize(type, exe_scope)) + return (*bit_size + 7) / 8; + return llvm::None; } - uint64_t GetBitSize(lldb::opaque_compiler_type_t type, - ExecutionContextScope *exe_scope) override; + llvm::Optional<uint64_t> + GetBitSize(lldb::opaque_compiler_type_t type, + ExecutionContextScope *exe_scope) override; lldb::Encoding GetEncoding(lldb::opaque_compiler_type_t type, uint64_t &count) override; @@ -745,19 +713,19 @@ public: bool omit_empty_base_classes, const ExecutionContext *exe_ctx) override; - CompilerType GetBuiltinTypeByName(const ConstString &name) override; + CompilerType GetBuiltinTypeByName(ConstString name) override; lldb::BasicType GetBasicTypeEnumeration(lldb::opaque_compiler_type_t type) override; static lldb::BasicType GetBasicTypeEnumeration(lldb::opaque_compiler_type_t type, - const ConstString &name); + ConstString name); void ForEachEnumerator( lldb::opaque_compiler_type_t type, std::function<bool(const CompilerType &integer_type, - const ConstString &name, + ConstString name, const llvm::APSInt &value)> const &callback) override; uint32_t GetNumFields(lldb::opaque_compiler_type_t type) override; @@ -828,9 +796,7 @@ public: ConstString *child_name = nullptr, CompilerType *child_type = nullptr); - //---------------------------------------------------------------------- // Modifying RecordType - //---------------------------------------------------------------------- static clang::FieldDecl *AddFieldToRecordType(const CompilerType &type, llvm::StringRef name, const CompilerType &field_type, @@ -890,16 +856,12 @@ public: bool has_extern); static bool GetHasExternalStorage(const CompilerType &type); - //------------------------------------------------------------------ // Tag Declarations - //------------------------------------------------------------------ static bool StartTagDeclarationDefinition(const CompilerType &type); static bool CompleteTagDeclarationDefinition(const CompilerType &type); - //---------------------------------------------------------------------- // Modifying Enumeration types - //---------------------------------------------------------------------- clang::EnumConstantDecl *AddEnumerationValueToEnumerationType( const CompilerType &enum_type, const Declaration &decl, const char *name, int64_t enum_value, uint32_t enum_value_bit_size); @@ -909,9 +871,7 @@ public: CompilerType GetEnumerationIntegerType(lldb::opaque_compiler_type_t type); - //------------------------------------------------------------------ // Pointers & References - //------------------------------------------------------------------ // Call this function using the class type when you want to make a member // pointer type to pointee_type. @@ -924,9 +884,14 @@ public: const char *s, uint8_t *dst, size_t dst_size) override; - //---------------------------------------------------------------------- // Dumping types - //---------------------------------------------------------------------- +#ifndef NDEBUG + /// Convenience LLVM-style dump method for use in the debugger only. + /// In contrast to the other \p Dump() methods this directly invokes + /// \p clang::QualType::dump(). + LLVM_DUMP_METHOD void dump(lldb::opaque_compiler_type_t type) const override; +#endif + void Dump(Stream &s); void DumpValue(lldb::opaque_compiler_type_t type, ExecutionContext *exe_ctx, @@ -1011,39 +976,37 @@ protected: const clang::ClassTemplateSpecializationDecl * GetAsTemplateSpecialization(lldb::opaque_compiler_type_t type); - //------------------------------------------------------------------ // Classes that inherit from ClangASTContext can see and modify these - //------------------------------------------------------------------ // clang-format off std::string m_target_triple; - std::unique_ptr<clang::ASTContext> m_ast_ap; - std::unique_ptr<clang::LangOptions> m_language_options_ap; - std::unique_ptr<clang::FileManager> m_file_manager_ap; - std::unique_ptr<clang::FileSystemOptions> m_file_system_options_ap; - std::unique_ptr<clang::SourceManager> m_source_manager_ap; - std::unique_ptr<clang::DiagnosticsEngine> m_diagnostics_engine_ap; - std::unique_ptr<clang::DiagnosticConsumer> m_diagnostic_consumer_ap; + std::unique_ptr<clang::ASTContext> m_ast_up; + std::unique_ptr<clang::LangOptions> m_language_options_up; + std::unique_ptr<clang::FileManager> m_file_manager_up; + std::unique_ptr<clang::SourceManager> m_source_manager_up; + std::unique_ptr<clang::DiagnosticsEngine> m_diagnostics_engine_up; + std::unique_ptr<clang::DiagnosticConsumer> m_diagnostic_consumer_up; std::shared_ptr<clang::TargetOptions> m_target_options_rp; - std::unique_ptr<clang::TargetInfo> m_target_info_ap; - std::unique_ptr<clang::IdentifierTable> m_identifier_table_ap; - std::unique_ptr<clang::SelectorTable> m_selector_table_ap; - std::unique_ptr<clang::Builtin::Context> m_builtins_ap; - std::unique_ptr<DWARFASTParserClang> m_dwarf_ast_parser_ap; - std::unique_ptr<PDBASTParser> m_pdb_ast_parser_ap; - std::unique_ptr<ClangASTSource> m_scratch_ast_source_ap; - std::unique_ptr<clang::MangleContext> m_mangle_ctx_ap; + std::unique_ptr<clang::TargetInfo> m_target_info_up; + std::unique_ptr<clang::IdentifierTable> m_identifier_table_up; + std::unique_ptr<clang::SelectorTable> m_selector_table_up; + std::unique_ptr<clang::Builtin::Context> m_builtins_up; + std::unique_ptr<DWARFASTParserClang> m_dwarf_ast_parser_up; + std::unique_ptr<PDBASTParser> m_pdb_ast_parser_up; + std::unique_ptr<ClangASTSource> m_scratch_ast_source_up; + std::unique_ptr<clang::MangleContext> m_mangle_ctx_up; CompleteTagDeclCallback m_callback_tag_decl; CompleteObjCInterfaceDeclCallback m_callback_objc_decl; void * m_callback_baton; clang::ExternalASTMerger::OriginMap m_origins; uint32_t m_pointer_byte_size; bool m_ast_owned; - bool m_can_evaluate_expressions; + /// The sema associated that is currently used to build this ASTContext. + /// May be null if we are already done parsing this ASTContext or the + /// ASTContext wasn't created by parsing source code. + clang::Sema * m_sema = nullptr; // clang-format on private: - //------------------------------------------------------------------ // For ClangASTContext only - //------------------------------------------------------------------ ClangASTContext(const ClangASTContext &); const ClangASTContext &operator=(const ClangASTContext &); }; @@ -1058,7 +1021,8 @@ public: GetUserExpression(llvm::StringRef expr, llvm::StringRef prefix, lldb::LanguageType language, Expression::ResultType desired_type, - const EvaluateExpressionOptions &options) override; + const EvaluateExpressionOptions &options, + ValueObject *ctx_obj) override; FunctionCaller *GetFunctionCaller(const CompilerType &return_type, const Address &function_address, diff --git a/include/lldb/Symbol/ClangASTImporter.h b/include/lldb/Symbol/ClangASTImporter.h index 465d7e24a1e71..353b1232d9404 100644 --- a/include/lldb/Symbol/ClangASTImporter.h +++ b/include/lldb/Symbol/ClangASTImporter.h @@ -1,9 +1,8 @@ //===-- ClangASTImporter.h --------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -22,7 +21,9 @@ #include "clang/Basic/FileManager.h" #include "clang/Basic/FileSystemOptions.h" +#include "lldb/Host/FileSystem.h" #include "lldb/Symbol/CompilerDeclContext.h" +#include "lldb/Symbol/CxxModuleHandler.h" #include "lldb/lldb-types.h" #include "llvm/ADT/DenseMap.h" @@ -94,7 +95,9 @@ public: vbase_offsets; }; - ClangASTImporter() : m_file_manager(clang::FileSystemOptions()) {} + ClangASTImporter() + : m_file_manager(clang::FileSystemOptions(), + FileSystem::Instance().GetVirtualFileSystem()) {} clang::QualType CopyType(clang::ASTContext *dst_ctx, clang::ASTContext *src_ctx, clang::QualType type); @@ -185,7 +188,7 @@ public: virtual ~MapCompleter(); virtual void CompleteNamespaceMap(NamespaceMapSP &namespace_map, - const ConstString &name, + ConstString name, NamespaceMapSP &parent_map) const = 0; }; @@ -232,16 +235,61 @@ private: typedef std::map<const clang::Decl *, DeclOrigin> OriginMap; - class Minion : public clang::ASTImporter { + /// ASTImporter that intercepts and records the import process of the + /// underlying ASTImporter. + /// + /// This class updates the map from declarations to their original + /// declarations and can record and complete declarations that have been + /// imported in a certain interval. + /// + /// When intercepting a declaration import, the ASTImporterDelegate uses the + /// CxxModuleHandler to replace any missing or malformed declarations with + /// their counterpart from a C++ module. + class ASTImporterDelegate : public clang::ASTImporter { public: - Minion(ClangASTImporter &master, clang::ASTContext *target_ctx, - clang::ASTContext *source_ctx) + ASTImporterDelegate(ClangASTImporter &master, clang::ASTContext *target_ctx, + clang::ASTContext *source_ctx) : clang::ASTImporter(*target_ctx, master.m_file_manager, *source_ctx, master.m_file_manager, true /*minimal*/), m_decls_to_deport(nullptr), m_decls_already_deported(nullptr), m_master(master), m_source_ctx(source_ctx) {} - // A call to "InitDeportWorkQueues" puts the minion into deport mode. + /// Scope guard that attaches a CxxModuleHandler to an ASTImporterDelegate + /// and deattaches it at the end of the scope. Supports being used multiple + /// times on the same ASTImporterDelegate instance in nested scopes. + class CxxModuleScope { + /// The handler we attach to the ASTImporterDelegate. + CxxModuleHandler m_handler; + /// The ASTImporterDelegate we are supposed to attach the handler to. + ASTImporterDelegate &m_delegate; + /// True iff we attached the handler to the ASTImporterDelegate. + bool m_valid = false; + + public: + CxxModuleScope(ASTImporterDelegate &delegate, clang::ASTContext *dst_ctx) + : m_delegate(delegate) { + // If the delegate doesn't have a CxxModuleHandler yet, create one + // and attach it. + if (!delegate.m_std_handler) { + m_handler = CxxModuleHandler(delegate, dst_ctx); + m_valid = true; + delegate.m_std_handler = &m_handler; + } + } + ~CxxModuleScope() { + if (m_valid) { + // Make sure no one messed with the handler we placed. + assert(m_delegate.m_std_handler == &m_handler); + m_delegate.m_std_handler = nullptr; + } + } + }; + + protected: + llvm::Expected<clang::Decl *> ImportImpl(clang::Decl *From) override; + + public: + // A call to "InitDeportWorkQueues" puts the delegate into deport mode. // In deport mode, every copied Decl that could require completion is // recorded and placed into the decls_to_deport set. // @@ -249,8 +297,8 @@ private: // 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 + // These calls must be paired. Leaving a delegate in deport mode or trying + // to start deport delegate with a new pair of queues will result in an // assertion failure. void @@ -260,28 +308,34 @@ private: void ImportDefinitionTo(clang::Decl *to, clang::Decl *from); - clang::Decl *Imported(clang::Decl *from, clang::Decl *to) override; + void Imported(clang::Decl *from, clang::Decl *to) override; clang::Decl *GetOriginalDecl(clang::Decl *To) override; + /// Decls we should ignore when mapping decls back to their original + /// ASTContext. Used by the CxxModuleHandler to mark declarations that + /// were created from the 'std' C++ module to prevent that the Importer + /// tries to sync them with the broken equivalent in the debug info AST. + std::set<clang::Decl *> m_decls_to_ignore; std::set<clang::NamedDecl *> *m_decls_to_deport; std::set<clang::NamedDecl *> *m_decls_already_deported; ClangASTImporter &m_master; clang::ASTContext *m_source_ctx; + CxxModuleHandler *m_std_handler = nullptr; }; - typedef std::shared_ptr<Minion> MinionSP; - typedef std::map<clang::ASTContext *, MinionSP> MinionMap; + typedef std::shared_ptr<ASTImporterDelegate> ImporterDelegateSP; + typedef std::map<clang::ASTContext *, ImporterDelegateSP> DelegateMap; typedef std::map<const clang::NamespaceDecl *, NamespaceMapSP> NamespaceMetaMap; struct ASTContextMetadata { ASTContextMetadata(clang::ASTContext *dst_ctx) - : m_dst_ctx(dst_ctx), m_minions(), m_origins(), m_namespace_maps(), + : m_dst_ctx(dst_ctx), m_delegates(), m_origins(), m_namespace_maps(), m_map_completer(nullptr) {} clang::ASTContext *m_dst_ctx; - MinionMap m_minions; + DelegateMap m_delegates; OriginMap m_origins; NamespaceMetaMap m_namespace_maps; @@ -316,18 +370,20 @@ private: return ASTContextMetadataSP(); } - MinionSP GetMinion(clang::ASTContext *dst_ctx, clang::ASTContext *src_ctx) { + ImporterDelegateSP GetDelegate(clang::ASTContext *dst_ctx, + clang::ASTContext *src_ctx) { ASTContextMetadataSP context_md = GetContextMetadata(dst_ctx); - MinionMap &minions = context_md->m_minions; - MinionMap::iterator minion_iter = minions.find(src_ctx); + DelegateMap &delegates = context_md->m_delegates; + DelegateMap::iterator delegate_iter = delegates.find(src_ctx); - if (minion_iter == minions.end()) { - MinionSP minion = MinionSP(new Minion(*this, dst_ctx, src_ctx)); - minions[src_ctx] = minion; - return minion; + if (delegate_iter == delegates.end()) { + ImporterDelegateSP delegate = + ImporterDelegateSP(new ASTImporterDelegate(*this, dst_ctx, src_ctx)); + delegates[src_ctx] = delegate; + return delegate; } else { - return minion_iter->second; + return delegate_iter->second; } } diff --git a/include/lldb/Symbol/ClangExternalASTSourceCallbacks.h b/include/lldb/Symbol/ClangExternalASTSourceCallbacks.h index c077665e51eeb..a2d4f8137a054 100644 --- a/include/lldb/Symbol/ClangExternalASTSourceCallbacks.h +++ b/include/lldb/Symbol/ClangExternalASTSourceCallbacks.h @@ -1,9 +1,8 @@ //===-- ClangExternalASTSourceCallbacks.h -----------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -51,9 +50,7 @@ public: m_callback_layout_record_type(layout_record_type_callback), m_callback_baton(callback_baton) {} - //------------------------------------------------------------------ // clang::ExternalASTSource - //------------------------------------------------------------------ clang::Decl *GetExternalDecl(uint32_t ID) override { // This method only needs to be implemented if the AST source ever passes @@ -127,10 +124,8 @@ public: } protected: - //------------------------------------------------------------------ // Classes that inherit from ClangExternalASTSourceCallbacks can see and // modify these - //------------------------------------------------------------------ CompleteTagDeclCallback m_callback_tag_decl; CompleteObjCInterfaceDeclCallback m_callback_objc_decl; FindExternalVisibleDeclsByNameCallback m_callback_find_by_name; diff --git a/include/lldb/Symbol/ClangExternalASTSourceCommon.h b/include/lldb/Symbol/ClangExternalASTSourceCommon.h index 894c91f157da3..8e69f6d3e4eb2 100644 --- a/include/lldb/Symbol/ClangExternalASTSourceCommon.h +++ b/include/lldb/Symbol/ClangExternalASTSourceCommon.h @@ -1,9 +1,8 @@ //===-- ClangExternalASTSourceCommon.h --------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// diff --git a/include/lldb/Symbol/ClangUtil.h b/include/lldb/Symbol/ClangUtil.h index c8638f782548d..d6106032190cc 100644 --- a/include/lldb/Symbol/ClangUtil.h +++ b/include/lldb/Symbol/ClangUtil.h @@ -1,9 +1,8 @@ //===-- ClangUtil.h ---------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // // A collection of helper methods and data structures for manipulating clang // types and decls. diff --git a/include/lldb/Symbol/CompactUnwindInfo.h b/include/lldb/Symbol/CompactUnwindInfo.h index 711420f66a465..2646661ec2375 100644 --- a/include/lldb/Symbol/CompactUnwindInfo.h +++ b/include/lldb/Symbol/CompactUnwindInfo.h @@ -1,23 +1,21 @@ //===-- CompactUnwindInfo.h -------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// #ifndef liblldb_CompactUnwindInfo_h_ #define liblldb_CompactUnwindInfo_h_ -#include <mutex> -#include <vector> - -#include "lldb/Core/RangeMap.h" #include "lldb/Symbol/ObjectFile.h" #include "lldb/Symbol/UnwindPlan.h" #include "lldb/Utility/DataExtractor.h" +#include "lldb/Utility/RangeMap.h" #include "lldb/lldb-private.h" +#include <mutex> +#include <vector> namespace lldb_private { diff --git a/include/lldb/Symbol/CompileUnit.h b/include/lldb/Symbol/CompileUnit.h index a4d19cd3d8ae9..c3ba2e2176e7a 100644 --- a/include/lldb/Symbol/CompileUnit.h +++ b/include/lldb/Symbol/CompileUnit.h @@ -1,9 +1,8 @@ //===-- CompileUnit.h -------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -14,6 +13,7 @@ #include "lldb/Core/ModuleChild.h" #include "lldb/Symbol/DebugMacros.h" #include "lldb/Symbol/Function.h" +#include "lldb/Symbol/SourceModule.h" #include "lldb/Utility/Stream.h" #include "lldb/Utility/UserID.h" #include "lldb/lldb-enumerations.h" @@ -21,8 +21,7 @@ #include "llvm/ADT/DenseMap.h" namespace lldb_private { -//---------------------------------------------------------------------- -/// @class CompileUnit CompileUnit.h "lldb/Symbol/CompileUnit.h" +/// \class CompileUnit CompileUnit.h "lldb/Symbol/CompileUnit.h" /// A class that describes a compilation unit. /// /// A representation of a compilation unit, or compiled source file. @@ -33,126 +32,113 @@ namespace lldb_private { /// 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, public FileSpec, public UserID, public SymbolContextScope { 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. /// - /// @param[in] module + /// \param[in] module /// The parent module that owns this compile unit. This value /// must be a valid pointer value. /// - /// @param[in] user_data + /// \param[in] user_data /// User data where the SymbolFile parser can store data. /// - /// @param[in] pathname + /// \param[in] pathname /// The path to the source file for this compile unit. /// - /// @param[in] uid + /// \param[in] uid /// The user ID of the compile unit. This value is supplied by /// the SymbolFile plug-in and should be a value that allows /// the SymbolFile plug-in to easily locate and parse additional /// information for the compile unit. /// - /// @param[in] language + /// \param[in] language /// A language enumeration type that describes the main language /// of this compile unit. /// - /// @param[in] is_optimized + /// \param[in] is_optimized /// A value that can initialized with eLazyBoolYes, eLazyBoolNo /// or eLazyBoolCalculate. If set to eLazyBoolCalculate, then /// an extra call into SymbolVendor will be made to calculate if /// the compile unit is optimized will be made when /// CompileUnit::GetIsOptimized() is called. /// - /// @see lldb::LanguageType - //------------------------------------------------------------------ + /// \see lldb::LanguageType CompileUnit(const lldb::ModuleSP &module_sp, void *user_data, const char *pathname, lldb::user_id_t uid, lldb::LanguageType language, lldb_private::LazyBool is_optimized); - //------------------------------------------------------------------ /// 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. /// - /// @param[in] module + /// \param[in] module /// The parent module that owns this compile unit. This value /// must be a valid pointer value. /// - /// @param[in] user_data + /// \param[in] user_data /// User data where the SymbolFile parser can store data. /// - /// @param[in] file_spec + /// \param[in] file_spec /// The file specification for the source file of this compile /// unit. /// - /// @param[in] uid + /// \param[in] uid /// The user ID of the compile unit. This value is supplied by /// the SymbolFile plug-in and should be a value that allows /// the plug-in to easily locate and parse /// additional information for the compile unit. /// - /// @param[in] language + /// \param[in] language /// A language enumeration type that describes the main language /// of this compile unit. /// - /// @param[in] is_optimized + /// \param[in] is_optimized /// A value that can initialized with eLazyBoolYes, eLazyBoolNo /// or eLazyBoolCalculate. If set to eLazyBoolCalculate, then /// an extra call into SymbolVendor will be made to calculate if /// the compile unit is optimized will be made when /// CompileUnit::GetIsOptimized() is called. /// - /// @see lldb::LanguageType - //------------------------------------------------------------------ + /// \see lldb::LanguageType CompileUnit(const lldb::ModuleSP &module_sp, void *user_data, const FileSpec &file_spec, lldb::user_id_t uid, lldb::LanguageType language, lldb_private::LazyBool is_optimized); - //------------------------------------------------------------------ /// Destructor - //------------------------------------------------------------------ ~CompileUnit() override; - //------------------------------------------------------------------ /// Add a function to this compile unit. /// /// Typically called by the SymbolFile plug-ins as they partially parse the /// debug information. /// - /// @param[in] function_sp + /// \param[in] function_sp /// A shared pointer to the Function object. - //------------------------------------------------------------------ void AddFunction(lldb::FunctionSP &function_sp); - //------------------------------------------------------------------ - /// @copydoc SymbolContextScope::CalculateSymbolContext(SymbolContext*) + /// \copydoc SymbolContextScope::CalculateSymbolContext(SymbolContext*) /// - /// @see SymbolContextScope - //------------------------------------------------------------------ + /// \see SymbolContextScope void CalculateSymbolContext(SymbolContext *sc) override; lldb::ModuleSP CalculateSymbolContextModule() override; CompileUnit *CalculateSymbolContextCompileUnit() override; - //------------------------------------------------------------------ - /// @copydoc SymbolContextScope::DumpSymbolContext(Stream*) + /// \copydoc SymbolContextScope::DumpSymbolContext(Stream*) /// - /// @see SymbolContextScope - //------------------------------------------------------------------ + /// \see SymbolContextScope void DumpSymbolContext(Stream *s) override; lldb::LanguageType GetLanguage(); @@ -164,34 +150,29 @@ public: void GetDescription(Stream *s, lldb::DescriptionLevel level) const; - //------------------------------------------------------------------ /// Apply a lambda to each function in this compile unit. /// /// This provides raw access to the function shared pointer list and will not /// cause the SymbolFile plug-in to parse any unparsed functions. /// - /// @note Prefer using FindFunctionByUID over this if possible. + /// \note Prefer using FindFunctionByUID over this if possible. /// - /// @param[in] lambda + /// \param[in] lambda /// The lambda that should be applied to every function. The lambda can /// return true if the iteration should be aborted earlier. - //------------------------------------------------------------------ void ForeachFunction( llvm::function_ref<bool(const lldb::FunctionSP &)> lambda) const; - //------------------------------------------------------------------ /// Dump the compile unit contents to the stream \a s. /// - /// @param[in] s + /// \param[in] s /// The stream to which to dump the object description. /// - /// @param[in] show_context + /// \param[in] show_context /// If \b true, variables will dump their symbol context /// information. - //------------------------------------------------------------------ void Dump(Stream *s, bool show_context) const; - //------------------------------------------------------------------ /// 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 @@ -204,175 +185,157 @@ public: /// 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 + /// \param[in] start_idx /// The zero based index at which to start looking for matches. /// - /// @param[in] line + /// \param[in] line /// The line number to search for. /// - /// @param[in] file_spec_ptr + /// \param[in] file_spec_ptr /// If non-NULL search for entries that match this file spec, /// else if NULL, search for line entries that match the compile /// unit file. /// - /// @param[in] exact + /// \param[in] exact /// If \btrue match only if there is a line table entry for this line /// number. /// If \bfalse, find the line table entry equal to or after this line /// number. /// - /// @param[out] line_entry + /// \param[out] line_entry /// If non-NULL, a copy of the line entry that was found. /// - /// @return + /// \return /// The zero based index of a matching line entry, or UINT32_MAX /// if no matching line entry is found. - //------------------------------------------------------------------ uint32_t FindLineEntry(uint32_t start_idx, uint32_t line, const FileSpec *file_spec_ptr, bool exact, LineEntry *line_entry); - //------------------------------------------------------------------ /// 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. /// - /// @return + /// \return /// The line table object pointer, or NULL if this line table /// hasn't been parsed yet. - //------------------------------------------------------------------ LineTable *GetLineTable(); DebugMacros *GetDebugMacros(); - //------------------------------------------------------------------ /// 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. /// - /// @return + /// \return /// A support file list object. - //------------------------------------------------------------------ - FileSpecList &GetSupportFiles(); + const FileSpecList &GetSupportFiles(); - //------------------------------------------------------------------ /// Get the compile unit's imported module list. /// /// This reports all the imports that the compile unit made, including the /// current module. /// - /// @return - /// A list of imported module names. - //------------------------------------------------------------------ - const std::vector<ConstString> &GetImportedModules(); + /// \return + /// A list of imported modules. + const std::vector<SourceModule> &GetImportedModules(); - //------------------------------------------------------------------ /// 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. /// - /// @return + /// \return /// The user data stored with the CompileUnit when it was /// constructed. - //------------------------------------------------------------------ void *GetUserData() const; - //------------------------------------------------------------------ /// 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. /// - /// @param[in] can_create + /// \param[in] can_create /// If \b true, the variable list will be parsed on demand. If /// \b false, the current variable list will be returned even /// if it contains a NULL VariableList object (typically /// called by dumping routines that want to display only what /// has currently been parsed). /// - /// @return + /// \return /// A shared pointer to a variable list, that can contain NULL /// VariableList pointer if there are no global or static /// variables. - //------------------------------------------------------------------ lldb::VariableListSP GetVariableList(bool can_create); - //------------------------------------------------------------------ /// 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. /// - /// @param[in] uid + /// \param[in] uid /// The user ID of the function to find. This value is supplied /// by the SymbolFile plug-in and should be a value that /// allows the plug-in to easily locate and parse additional /// information in the function. /// - /// @return + /// \return /// A shared pointer to the function object that might contain /// a NULL Function pointer. - //------------------------------------------------------------------ lldb::FunctionSP FindFunctionByUID(lldb::user_id_t uid); - //------------------------------------------------------------------ /// 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. /// - /// @param[in] line_table + /// \param[in] line_table /// A line table object pointer that this object now owns. - //------------------------------------------------------------------ void SetLineTable(LineTable *line_table); void SetDebugMacros(const DebugMacrosSP &debug_macros); - //------------------------------------------------------------------ /// 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. /// - /// @param[in] variable_list_sp + /// \param[in] variable_list_sp /// A shared pointer to a VariableList. - //------------------------------------------------------------------ void SetVariableList(lldb::VariableListSP &variable_list_sp); - //------------------------------------------------------------------ /// 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. /// - /// @param[in] file_spec + /// \param[in] file_spec /// A file specification. If \a file_spec contains no directory /// information, only the basename will be used when matching /// contexts. If the directory in \a file_spec is valid, a /// complete file specification match will be performed. /// - /// @param[in] line + /// \param[in] line /// The line number to match against the compile unit's line /// tables. /// - /// @param[in] check_inlines + /// \param[in] check_inlines /// If \b true this function will also match any inline /// file and line matches. If \b false, the compile unit's /// file specification must match \a file_spec for any matches /// to be returned. /// - /// @param[in] exact + /// \param[in] exact /// If true, only resolve the context if \a line exists in the line table. /// If false, resolve the context to the closest line greater than \a line /// in the line table. /// - /// @param[in] resolve_scope + /// \param[in] resolve_scope /// For each matching line entry, this bitfield indicates what /// values within each SymbolContext that gets added to \a /// sc_list will be resolved. See the SymbolContext::Scope @@ -380,21 +343,19 @@ public: /// resolved. Only SymbolContext entries that can be resolved /// using a LineEntry base address will be able to be resolved. /// - /// @param[out] sc_list + /// \param[out] sc_list /// A SymbolContext list class that will get any matching /// entries appended to. /// - /// @return + /// \return /// The number of new matches that were added to \a sc_list. /// - /// @see enum SymbolContext::Scope - //------------------------------------------------------------------ + /// \see enum SymbolContext::Scope uint32_t ResolveSymbolContext(const FileSpec &file_spec, uint32_t line, bool check_inlines, bool exact, lldb::SymbolContextItem resolve_scope, SymbolContextList &sc_list); - //------------------------------------------------------------------ /// Get whether compiler optimizations were enabled for this compile unit /// /// "optimized" means that the debug experience may be difficult for the @@ -402,41 +363,39 @@ public: /// would expect them, stepping through the source lines in the function may /// appear strange, etc. /// - /// @return + /// \return /// Returns 'true' if this compile unit was compiled with /// optimization. 'false' indicates that either the optimization /// is unknown, or this compile unit was built without optimization. - //------------------------------------------------------------------ bool GetIsOptimized(); - //------------------------------------------------------------------ /// Returns the number of functions in this compile unit - //------------------------------------------------------------------ size_t GetNumFunctions() const { return m_functions_by_uid.size(); } protected: - void *m_user_data; ///< User data for the SymbolFile parser to store - ///information into. - lldb::LanguageType - m_language; ///< The programming language enumeration value. - Flags m_flags; ///< Compile unit flags that help with partial parsing. - + /// User data for the SymbolFile parser to store information into. + void *m_user_data; + /// The programming language enumeration value. + lldb::LanguageType m_language; + /// Compile unit flags that help with partial parsing. + Flags m_flags; /// Maps UIDs to functions. llvm::DenseMap<lldb::user_id_t, lldb::FunctionSP> m_functions_by_uid; - std::vector<ConstString> m_imported_modules; ///< All modules, including the - ///current module, imported by - ///this - ///< compile unit. - FileSpecList m_support_files; ///< Files associated with this compile unit's - ///line table and declarations. - std::unique_ptr<LineTable> - m_line_table_ap; ///< Line table that will get parsed on demand. - DebugMacrosSP - m_debug_macros_sp; ///< Debug macros that will get parsed on demand. - lldb::VariableListSP m_variables; ///< Global and static variable list that - ///will get parsed on demand. - lldb_private::LazyBool m_is_optimized; /// eLazyBoolYes if this compile unit - /// was compiled with optimization. + /// All modules, including the current module, imported by this + /// compile unit. + std::vector<SourceModule> m_imported_modules; + /// Files associated with this compile unit's line table and + /// declarations. + FileSpecList m_support_files; + /// Line table that will get parsed on demand. + std::unique_ptr<LineTable> m_line_table_up; + /// Debug macros that will get parsed on demand. + DebugMacrosSP m_debug_macros_sp; + /// Global and static variable list that will get parsed on demand. + lldb::VariableListSP m_variables; + /// eLazyBoolYes if this compile unit was compiled with + /// optimization. + lldb_private::LazyBool m_is_optimized; private: enum { diff --git a/include/lldb/Symbol/CompilerDecl.h b/include/lldb/Symbol/CompilerDecl.h index 5d744d999bea9..4817ec4b22670 100644 --- a/include/lldb/Symbol/CompilerDecl.h +++ b/include/lldb/Symbol/CompilerDecl.h @@ -1,9 +1,8 @@ //===-- CompilerDecl.h ------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -18,9 +17,7 @@ namespace lldb_private { class CompilerDecl { public: - //---------------------------------------------------------------------- // Constructors and Destructors - //---------------------------------------------------------------------- CompilerDecl() : m_type_system(nullptr), m_opaque_decl(nullptr) {} CompilerDecl(TypeSystem *type_system, void *decl) @@ -28,9 +25,7 @@ public: ~CompilerDecl() {} - //---------------------------------------------------------------------- // Tests - //---------------------------------------------------------------------- explicit operator bool() const { return IsValid(); } @@ -46,9 +41,7 @@ public: bool IsClang() const; - //---------------------------------------------------------------------- // Accessors - //---------------------------------------------------------------------- TypeSystem *GetTypeSystem() const { return m_type_system; } diff --git a/include/lldb/Symbol/CompilerDeclContext.h b/include/lldb/Symbol/CompilerDeclContext.h index 179a1be0248b9..e7958c08d8334 100644 --- a/include/lldb/Symbol/CompilerDeclContext.h +++ b/include/lldb/Symbol/CompilerDeclContext.h @@ -1,9 +1,8 @@ //===-- CompilerDeclContext.h -----------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -19,9 +18,7 @@ namespace lldb_private { class CompilerDeclContext { public: - //---------------------------------------------------------------------- // Constructors and Destructors - //---------------------------------------------------------------------- CompilerDeclContext() : m_type_system(nullptr), m_opaque_decl_ctx(nullptr) {} CompilerDeclContext(TypeSystem *type_system, void *decl_ctx) @@ -29,9 +26,7 @@ public: ~CompilerDeclContext() {} - //---------------------------------------------------------------------- // Tests - //---------------------------------------------------------------------- explicit operator bool() const { return IsValid(); } @@ -50,35 +45,44 @@ public: std::vector<CompilerDecl> FindDeclByName(ConstString name, const bool ignore_using_decls); - //---------------------------------------------------------------------- /// Checks if this decl context represents a method of a class. /// - /// @param[out] language_ptr + /// \param[out] language_ptr /// If non NULL and \b true is returned from this function, /// this will indicate if the language that respresents the method. /// - /// @param[out] is_instance_method_ptr + /// \param[out] is_instance_method_ptr /// If non NULL and \b true is returned from this function, /// this will indicate if the method is an instance function (true) /// or a class method (false indicating the function is static, or /// doesn't require an instance of the class to be called). /// - /// @param[out] language_object_name_ptr + /// \param[out] language_object_name_ptr /// If non NULL and \b true is returned from this function, /// this will indicate if implicit object name for the language /// like "this" for C++, and "self" for Objective C. /// - /// @return + /// \return /// Returns true if this is a decl context that represents a method /// in a struct, union or class. - //---------------------------------------------------------------------- bool IsClassMethod(lldb::LanguageType *language_ptr, bool *is_instance_method_ptr, ConstString *language_object_name_ptr); - //---------------------------------------------------------------------- + /// Check if the given other decl context is contained in the lookup + /// of this decl context (for example because the other context is a nested + /// inline namespace). + /// + /// @param[in] other + /// The other decl context for which we should check if it is contained + /// in the lookoup of this context. + /// + /// @return + /// Returns true iff the other decl context is contained in the lookup + /// of this decl context. + bool IsContainedInLookup(CompilerDeclContext other) const; + // Accessors - //---------------------------------------------------------------------- TypeSystem *GetTypeSystem() const { return m_type_system; } diff --git a/include/lldb/Symbol/CompilerType.h b/include/lldb/Symbol/CompilerType.h index 353313d8e2a38..98d916597f42c 100644 --- a/include/lldb/Symbol/CompilerType.h +++ b/include/lldb/Symbol/CompilerType.h @@ -1,9 +1,8 @@ //===-- CompilerType.h ------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -22,7 +21,6 @@ namespace lldb_private { 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 @@ -30,12 +28,9 @@ class DataExtractor; // 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: - //---------------------------------------------------------------------- // Constructors and Destructors - //---------------------------------------------------------------------- CompilerType(TypeSystem *type_system, lldb::opaque_compiler_type_t type); CompilerType(clang::ASTContext *ast_context, clang::QualType qual_type); @@ -46,9 +41,7 @@ public: ~CompilerType(); - //---------------------------------------------------------------------- // Operators - //---------------------------------------------------------------------- const CompilerType &operator=(const CompilerType &rhs) { m_type = rhs.m_type; @@ -56,9 +49,7 @@ public: return *this; } - //---------------------------------------------------------------------- // Tests - //---------------------------------------------------------------------- explicit operator bool() const { return m_type != nullptr && m_type_system != nullptr; @@ -146,21 +137,15 @@ public: bool IsVoidType() const; - //---------------------------------------------------------------------- // Type Completion - //---------------------------------------------------------------------- bool GetCompleteType() const; - //---------------------------------------------------------------------- // AST related queries - //---------------------------------------------------------------------- size_t GetPointerByteSize() const; - //---------------------------------------------------------------------- // Accessors - //---------------------------------------------------------------------- TypeSystem *GetTypeSystem() const { return m_type_system; } @@ -188,9 +173,7 @@ public: unsigned GetTypeQualifiers() const; - //---------------------------------------------------------------------- // Creating related types - //---------------------------------------------------------------------- CompilerType GetArrayElementType(uint64_t *stride = nullptr) const; @@ -212,78 +195,56 @@ public: TypeMemberFunctionImpl GetMemberFunctionAtIndex(size_t idx); - //---------------------------------------------------------------------- // 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. - //---------------------------------------------------------------------- CompilerType GetNonReferenceType() const; - //---------------------------------------------------------------------- // If this type is a pointer type, return the type that the pointer points // to, else return an invalid type. - //---------------------------------------------------------------------- CompilerType GetPointeeType() const; - //---------------------------------------------------------------------- // Return a new CompilerType that is a pointer to this type - //---------------------------------------------------------------------- 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. - //---------------------------------------------------------------------- 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. - //---------------------------------------------------------------------- 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. - //---------------------------------------------------------------------- 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. - //---------------------------------------------------------------------- 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. - //---------------------------------------------------------------------- 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. - //---------------------------------------------------------------------- CompilerType CreateTypedef(const char *name, const CompilerDeclContext &decl_ctx) const; // If the current object represents a typedef type, get the underlying type CompilerType GetTypedefedType() const; - //---------------------------------------------------------------------- // Create related types using the current type's AST - //---------------------------------------------------------------------- CompilerType GetBasicTypeFromAST(lldb::BasicType basic_type) const; - //---------------------------------------------------------------------- // Exploring the type - //---------------------------------------------------------------------- struct IntegralTemplateArgument; @@ -303,16 +264,14 @@ public: lldb::BasicType GetBasicTypeEnumeration() const; - static lldb::BasicType GetBasicTypeEnumeration(const ConstString &name); + static lldb::BasicType GetBasicTypeEnumeration(ConstString name); - //---------------------------------------------------------------------- // 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. - //---------------------------------------------------------------------- void ForEachEnumerator( std::function<bool(const CompilerType &integer_type, - const ConstString &name, + ConstString name, const llvm::APSInt &value)> const &callback) const; uint32_t GetNumFields() const; @@ -377,18 +336,21 @@ public: bool IsMeaninglessWithoutDynamicResolution() const; - //------------------------------------------------------------------ // Pointers & References - //------------------------------------------------------------------ // 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; - //---------------------------------------------------------------------- // Dumping types - //---------------------------------------------------------------------- + +#ifndef NDEBUG + /// Convenience LLVM-style dump method for use in the debugger only. + /// Don't call this function from actual code. + LLVM_DUMP_METHOD void dump() const; +#endif + void DumpValue(ExecutionContext *exe_ctx, Stream *s, lldb::Format format, const DataExtractor &data, lldb::offset_t data_offset, size_t data_byte_size, uint32_t bitfield_bit_size, diff --git a/include/lldb/Symbol/CxxModuleHandler.h b/include/lldb/Symbol/CxxModuleHandler.h new file mode 100644 index 0000000000000..f4aef3666ece7 --- /dev/null +++ b/include/lldb/Symbol/CxxModuleHandler.h @@ -0,0 +1,65 @@ +//===-- CxxModuleHandler.h --------------------------------------*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef liblldb_CxxModuleHandler_h_ +#define liblldb_CxxModuleHandler_h_ + +#include "clang/AST/ASTImporter.h" +#include "clang/Sema/Sema.h" +#include "llvm/ADT/StringSet.h" + +namespace lldb_private { + +/// Handles importing decls into an ASTContext with an attached C++ module. +/// +/// This class searches a C++ module (which must be attached to the target +/// ASTContext) for an equivalent decl to the one that should be imported. +/// If the decl that is found in the module is a suitable replacement +/// for the decl that should be imported, the module decl will be treated as +/// the result of the import process. +/// +/// If the Decl that should be imported is a template specialization +/// that doesn't exist yet in the target ASTContext (e.g. `std::vector<int>`), +/// then this class tries to create the template specialization in the target +/// ASTContext. This is only possible if the CxxModuleHandler can determine +/// that instantiating this template is safe to do, e.g. because the target +/// decl is a container class from the STL. +class CxxModuleHandler { + /// The ASTImporter that should be used to import any Decls which aren't + /// directly handled by this class itself. + clang::ASTImporter *m_importer = nullptr; + + /// The Sema instance of the target ASTContext. + clang::Sema *m_sema = nullptr; + + /// List of template names this class currently supports. These are the + /// template names inside the 'std' namespace such as 'vector' or 'list'. + llvm::StringSet<> m_supported_templates; + + /// Tries to manually instantiate the given foreign template in the target + /// context (designated by m_sema). + llvm::Optional<clang::Decl *> tryInstantiateStdTemplate(clang::Decl *d); + +public: + CxxModuleHandler() = default; + CxxModuleHandler(clang::ASTImporter &importer, clang::ASTContext *target); + + /// Attempts to import the given decl into the target ASTContext by + /// deserializing it from the 'std' module. This function returns a Decl if a + /// Decl has been deserialized from the 'std' module. Otherwise this function + /// returns nothing. + llvm::Optional<clang::Decl *> Import(clang::Decl *d); + + /// Returns true iff this instance is capable of importing any declarations + /// in the target ASTContext. + bool isValid() const { return m_sema != nullptr; } +}; + +} // namespace lldb_private + +#endif // liblldb_CxxModuleHandler_h_ diff --git a/include/lldb/Symbol/DWARFCallFrameInfo.h b/include/lldb/Symbol/DWARFCallFrameInfo.h index 133c66d4ae4f0..104075f28df39 100644 --- a/include/lldb/Symbol/DWARFCallFrameInfo.h +++ b/include/lldb/Symbol/DWARFCallFrameInfo.h @@ -1,9 +1,8 @@ //===-- DWARFCallFrameInfo.h ------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -14,12 +13,11 @@ #include <mutex> #include "lldb/Core/AddressRange.h" -#include "lldb/Utility/Flags.h" - -#include "lldb/Core/RangeMap.h" #include "lldb/Core/dwarf.h" #include "lldb/Symbol/ObjectFile.h" #include "lldb/Symbol/UnwindPlan.h" +#include "lldb/Utility/Flags.h" +#include "lldb/Utility/RangeMap.h" #include "lldb/Utility/VMRange.h" #include "lldb/lldb-private.h" @@ -45,13 +43,18 @@ public: // address. bool GetAddressRange(Address addr, AddressRange &range); - // Return an UnwindPlan based on the call frame information encoded in the - // FDE of this DWARFCallFrameInfo section. - bool GetUnwindPlan(Address addr, UnwindPlan &unwind_plan); + /// Return an UnwindPlan based on the call frame information encoded in the + /// FDE of this DWARFCallFrameInfo section. The returned plan will be valid + /// (at least) for the given address. + bool GetUnwindPlan(const Address &addr, UnwindPlan &unwind_plan); + + /// Return an UnwindPlan based on the call frame information encoded in the + /// FDE of this DWARFCallFrameInfo section. The returned plan will be valid + /// (at least) for some address in the given range. + bool GetUnwindPlan(const AddressRange &range, UnwindPlan &unwind_plan); typedef RangeVector<lldb::addr_t, uint32_t> FunctionAddressAndSizeVector; - //------------------------------------------------------------------ // Build a vector of file address and size for all functions in this Module // based on the eh_frame FDE entries. // @@ -61,7 +64,7 @@ public: // functions in the Module. But the eh_frame can help to give the addresses // of these stripped symbols, at least. // - // @param[out] function_info + // \param[out] function_info // A vector provided by the caller is filled out. May be empty if no // FDEs/no eh_frame // is present in this Module. @@ -118,8 +121,8 @@ private: bool IsEHFrame() const; - bool GetFDEEntryByFileAddress(lldb::addr_t file_offset, - FDEEntryMap::Entry &fde_entry); + llvm::Optional<FDEEntryMap::Entry> + GetFirstFDEEntryInRange(const AddressRange &range); void GetFDEIndex(); diff --git a/include/lldb/Symbol/DebugMacros.h b/include/lldb/Symbol/DebugMacros.h index 86700994fbcce..d364299ef4902 100644 --- a/include/lldb/Symbol/DebugMacros.h +++ b/include/lldb/Symbol/DebugMacros.h @@ -1,9 +1,8 @@ //===-- DebugMacros.h -------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// diff --git a/include/lldb/Symbol/DeclVendor.h b/include/lldb/Symbol/DeclVendor.h index d1ccb4191cbc6..9c10fe1177fba 100644 --- a/include/lldb/Symbol/DeclVendor.h +++ b/include/lldb/Symbol/DeclVendor.h @@ -1,9 +1,8 @@ //===-- DeclVendor.h --------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -19,54 +18,57 @@ 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. -//---------------------------------------------------------------------- class DeclVendor { public: - //------------------------------------------------------------------ // Constructors and Destructors - //------------------------------------------------------------------ DeclVendor() {} virtual ~DeclVendor() {} - //------------------------------------------------------------------ /// Look up the set of Decls that the DeclVendor currently knows about /// matching a given name. /// - /// @param[in] name + /// \param[in] name /// The name to look for. /// - /// @param[in] append + /// \param[in] append /// If true, FindDecls will clear "decls" when it starts. /// - /// @param[in] max_matches + /// \param[in] max_matches /// The maximum number of Decls to return. UINT32_MAX means "as /// many as possible." /// - /// @return + /// \return /// The number of Decls added to decls; will not exceed /// max_matches. - //------------------------------------------------------------------ - virtual uint32_t FindDecls(const ConstString &name, bool append, + virtual uint32_t FindDecls(ConstString name, bool append, uint32_t max_matches, std::vector<clang::NamedDecl *> &decls) = 0; - //------------------------------------------------------------------ + /// Look up the types that the DeclVendor currently knows about matching a + /// given name. + /// + /// \param[in] name + /// The name to look for. + /// + /// \param[in] max_matches + // The maximum number of matches. UINT32_MAX means "as many as possible". + /// + /// \return + /// The vector of CompilerTypes that was found. + std::vector<CompilerType> FindTypes(ConstString name, uint32_t max_matches); + /// Interface for ExternalASTMerger. Returns an ImporterSource /// allowing type completion. /// - /// @return + /// \return /// An ImporterSource for this DeclVendor. - //------------------------------------------------------------------ virtual clang::ExternalASTMerger::ImporterSource GetImporterSource() = 0; private: - //------------------------------------------------------------------ // For DeclVendor only - //------------------------------------------------------------------ DISALLOW_COPY_AND_ASSIGN(DeclVendor); }; diff --git a/include/lldb/Symbol/Declaration.h b/include/lldb/Symbol/Declaration.h index b654988bccd28..63798f883e5f5 100644 --- a/include/lldb/Symbol/Declaration.h +++ b/include/lldb/Symbol/Declaration.h @@ -1,9 +1,8 @@ //===-- Declaration.h -------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -15,20 +14,16 @@ namespace lldb_private { -//---------------------------------------------------------------------- -/// @class Declaration Declaration.h "lldb/Symbol/Declaration.h" +/// \class Declaration Declaration.h "lldb/Symbol/Declaration.h" /// 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. -//---------------------------------------------------------------------- class Declaration { public: - //------------------------------------------------------------------ /// Default constructor. - //------------------------------------------------------------------ Declaration() : m_file(), m_line(0) #ifdef LLDB_ENABLE_DECLARATION_COLUMNS @@ -38,21 +33,19 @@ public: { } - //------------------------------------------------------------------ /// Construct with file specification, and optional line and column. /// - /// @param[in] file_spec + /// \param[in] file_spec /// The file specification that describes where this was /// declared. /// - /// @param[in] line + /// \param[in] line /// The line number that describes where this was declared. Set /// to zero if there is no line number information. /// - /// @param[in] column + /// \param[in] column /// The column number that describes where this was declared. /// Set to zero if there is no column number information. - //------------------------------------------------------------------ Declaration(const FileSpec &file_spec, uint32_t line = 0, uint32_t column = 0) : m_file(file_spec), m_line(line) #ifdef LLDB_ENABLE_DECLARATION_COLUMNS @@ -62,9 +55,7 @@ public: { } - //------------------------------------------------------------------ /// Construct with a reference to another Declaration object. - //------------------------------------------------------------------ Declaration(const Declaration &rhs) : m_file(rhs.m_file), m_line(rhs.m_line) #ifdef LLDB_ENABLE_DECLARATION_COLUMNS @@ -74,9 +65,7 @@ public: { } - //------------------------------------------------------------------ /// Construct with a pointer to another Declaration object. - //------------------------------------------------------------------ Declaration(const Declaration *decl_ptr) : m_file(), m_line(0) #ifdef LLDB_ENABLE_DECLARATION_COLUMNS @@ -88,12 +77,10 @@ public: *this = *decl_ptr; } - //------------------------------------------------------------------ /// Clear the object's state. /// /// Sets the file specification to be empty, and the line and column to /// zero. - //------------------------------------------------------------------ void Clear() { m_file.Clear(); m_line = 0; @@ -102,45 +89,50 @@ public: #endif } - //------------------------------------------------------------------ /// 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. /// - /// @param[in] lhs + /// \param[in] lhs /// The Left Hand Side const Declaration object reference. /// - /// @param[in] rhs + /// \param[in] rhs /// The Right Hand Side const Declaration object reference. /// - /// @return - /// @li -1 if lhs < rhs - /// @li 0 if lhs == rhs - /// @li 1 if lhs > rhs - //------------------------------------------------------------------ + /// \return + /// \li -1 if lhs < rhs + /// \li 0 if lhs == rhs + /// \li 1 if lhs > rhs static int Compare(const Declaration &lhs, const Declaration &rhs); - //------------------------------------------------------------------ + /// Checks if this object has the same file and line as another declaration + /// object. + /// + /// \param[in] declaration + /// The const Declaration object to compare with. + /// + /// \return + /// Returns \b true if \b declaration is at the same file and + /// line, \b false otherwise. + bool FileAndLineEqual(const Declaration &declaration) const; + /// Dump a description of this object to a Stream. /// /// Dump a description of the contents of this object to the supplied stream /// \a s. /// - /// @param[in] s + /// \param[in] s /// The stream to which to dump the object description. - //------------------------------------------------------------------ void Dump(Stream *s, bool show_fullpaths) const; bool DumpStopContext(Stream *s, bool show_fullpaths) const; - //------------------------------------------------------------------ /// Get accessor for the declaration column number. /// - /// @return + /// \return /// Non-zero indicates a valid column number, zero indicates no /// column information is available. - //------------------------------------------------------------------ uint32_t GetColumn() const { #ifdef LLDB_ENABLE_DECLARATION_COLUMNS return m_column; @@ -149,79 +141,63 @@ public: #endif } - //------------------------------------------------------------------ /// Get accessor for file specification. /// - /// @return + /// \return /// A reference to the file specification object. - //------------------------------------------------------------------ FileSpec &GetFile() { return m_file; } - //------------------------------------------------------------------ /// Get const accessor for file specification. /// - /// @return + /// \return /// A const reference to the file specification object. - //------------------------------------------------------------------ const FileSpec &GetFile() const { return m_file; } - //------------------------------------------------------------------ /// Get accessor for the declaration line number. /// - /// @return + /// \return /// Non-zero indicates a valid line number, zero indicates no /// line information is available. - //------------------------------------------------------------------ uint32_t GetLine() const { return m_line; } bool IsValid() const { return m_file && m_line != 0; } - //------------------------------------------------------------------ /// Get the memory cost of this object. /// - /// @return + /// \return /// The number of bytes that this object occupies in memory. /// The returned value does not include the bytes for any /// shared string values. /// - /// @see ConstString::StaticMemorySize () - //------------------------------------------------------------------ + /// \see ConstString::StaticMemorySize () size_t MemorySize() const; - //------------------------------------------------------------------ /// Set accessor for the declaration column number. /// - /// @param[in] column + /// \param[in] column /// Non-zero indicates a valid column number, zero indicates no /// column information is available. - //------------------------------------------------------------------ void SetColumn(uint32_t column) { #ifdef LLDB_ENABLE_DECLARATION_COLUMNS m_column = col; #endif } - //------------------------------------------------------------------ /// Set accessor for the declaration file specification. /// - /// @param[in] file_spec + /// \param[in] file_spec /// The new declaration file specification. - //------------------------------------------------------------------ void SetFile(const FileSpec &file_spec) { m_file = file_spec; } - //------------------------------------------------------------------ /// Set accessor for the declaration line number. /// - /// @param[in] line + /// \param[in] line /// Non-zero indicates a valid line number, zero indicates no /// line information is available. - //------------------------------------------------------------------ void SetLine(uint32_t line) { m_line = line; } protected: - //------------------------------------------------------------------ /// Member variables. - //------------------------------------------------------------------ FileSpec m_file; ///< The file specification that points to the ///< source file where the declaration occurred. uint32_t m_line; ///< Non-zero values indicates a valid line number, diff --git a/include/lldb/Symbol/FuncUnwinders.h b/include/lldb/Symbol/FuncUnwinders.h index ae8bcc892ce43..cc767d4e1e82f 100644 --- a/include/lldb/Symbol/FuncUnwinders.h +++ b/include/lldb/Symbol/FuncUnwinders.h @@ -35,17 +35,10 @@ public: ~FuncUnwinders(); - // 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. - lldb::UnwindPlanSP GetUnwindPlanAtCallSite(Target &target, - int current_offset); + lldb::UnwindPlanSP GetUnwindPlanAtCallSite(Target &target, Thread &thread); lldb::UnwindPlanSP GetUnwindPlanAtNonCallSite(Target &target, - lldb_private::Thread &thread, - int current_offset); + lldb_private::Thread &thread); lldb::UnwindPlanSP GetUnwindPlanFastUnwind(Target &target, lldb_private::Thread &thread); @@ -81,26 +74,23 @@ public: // 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); + lldb::UnwindPlanSP GetAssemblyUnwindPlan(Target &target, Thread &thread); - lldb::UnwindPlanSP GetEHFrameUnwindPlan(Target &target, int current_offset); + lldb::UnwindPlanSP GetEHFrameUnwindPlan(Target &target); lldb::UnwindPlanSP GetEHFrameAugmentedUnwindPlan(Target &target, - Thread &thread, - int current_offset); + Thread &thread); - lldb::UnwindPlanSP GetDebugFrameUnwindPlan(Target &target, - int current_offset); + lldb::UnwindPlanSP GetDebugFrameUnwindPlan(Target &target); lldb::UnwindPlanSP GetDebugFrameAugmentedUnwindPlan(Target &target, - Thread &thread, - int current_offset); + Thread &thread); - lldb::UnwindPlanSP GetCompactUnwindUnwindPlan(Target &target, - int current_offset); + lldb::UnwindPlanSP GetCompactUnwindUnwindPlan(Target &target); - lldb::UnwindPlanSP GetArmUnwindUnwindPlan(Target &target, int current_offset); + lldb::UnwindPlanSP GetArmUnwindUnwindPlan(Target &target); + + lldb::UnwindPlanSP GetSymbolFileUnwindPlan(Thread &thread); lldb::UnwindPlanSP GetArchDefaultUnwindPlan(Thread &thread); @@ -132,6 +122,7 @@ private: std::vector<lldb::UnwindPlanSP> m_unwind_plan_compact_unwind; lldb::UnwindPlanSP m_unwind_plan_arm_unwind_sp; + lldb::UnwindPlanSP m_unwind_plan_symbol_file_sp; lldb::UnwindPlanSP m_unwind_plan_fast_sp; lldb::UnwindPlanSP m_unwind_plan_arch_default_sp; lldb::UnwindPlanSP m_unwind_plan_arch_default_at_func_entry_sp; @@ -143,8 +134,8 @@ private: m_tried_unwind_plan_eh_frame_augmented : 1, m_tried_unwind_plan_debug_frame_augmented : 1, m_tried_unwind_plan_compact_unwind : 1, - m_tried_unwind_plan_arm_unwind : 1, m_tried_unwind_fast : 1, - m_tried_unwind_arch_default : 1, + m_tried_unwind_plan_arm_unwind : 1, m_tried_unwind_plan_symbol_file : 1, + m_tried_unwind_fast : 1, m_tried_unwind_arch_default : 1, m_tried_unwind_arch_default_at_func_entry : 1; Address m_first_non_prologue_insn; diff --git a/include/lldb/Symbol/Function.h b/include/lldb/Symbol/Function.h index 447abd2e6f78c..f68a16705d935 100644 --- a/include/lldb/Symbol/Function.h +++ b/include/lldb/Symbol/Function.h @@ -1,9 +1,8 @@ //===-- Function.h ----------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -20,216 +19,182 @@ namespace lldb_private { -//---------------------------------------------------------------------- -/// @class FunctionInfo Function.h "lldb/Symbol/Function.h" +/// \class FunctionInfo Function.h "lldb/Symbol/Function.h" /// A class that contains generic function information. /// /// This provides generic function information that gets reused between inline /// functions and function types. -//---------------------------------------------------------------------- class FunctionInfo { public: - //------------------------------------------------------------------ /// Construct with the function method name and optional declaration /// information. /// - /// @param[in] name + /// \param[in] name /// A C string name for the method name for this function. This /// value should not be the mangled named, but the simple method /// name. /// - /// @param[in] decl_ptr + /// \param[in] decl_ptr /// Optional declaration information that describes where the /// function was declared. This can be NULL. - //------------------------------------------------------------------ FunctionInfo(const char *name, const Declaration *decl_ptr); - //------------------------------------------------------------------ /// Construct with the function method name and optional declaration /// information. /// - /// @param[in] name + /// \param[in] name /// A name for the method name for this function. This value /// should not be the mangled named, but the simple method name. /// - /// @param[in] decl_ptr + /// \param[in] decl_ptr /// Optional declaration information that describes where the /// function was declared. This can be NULL. - //------------------------------------------------------------------ - FunctionInfo(const ConstString &name, const Declaration *decl_ptr); + FunctionInfo(ConstString name, const Declaration *decl_ptr); - //------------------------------------------------------------------ /// Destructor. /// /// The destructor is virtual since classes inherit from this class. - //------------------------------------------------------------------ virtual ~FunctionInfo(); - //------------------------------------------------------------------ /// Compare two function information objects. /// /// First compares the method names, and if equal, then compares the /// declaration information. /// - /// @param[in] lhs + /// \param[in] lhs /// The Left Hand Side const FunctionInfo object reference. /// - /// @param[in] rhs + /// \param[in] rhs /// The Right Hand Side const FunctionInfo object reference. /// - /// @return - /// @li -1 if lhs < rhs - /// @li 0 if lhs == rhs - /// @li 1 if lhs > rhs - //------------------------------------------------------------------ + /// \return + /// \li -1 if lhs < rhs + /// \li 0 if lhs == rhs + /// \li 1 if lhs > rhs static int Compare(const FunctionInfo &lhs, const FunctionInfo &rhs); - //------------------------------------------------------------------ /// Dump a description of this object to a Stream. /// /// Dump a description of the contents of this object to the supplied stream /// \a s. /// - /// @param[in] s + /// \param[in] s /// The stream to which to dump the object description. - //------------------------------------------------------------------ void Dump(Stream *s, bool show_fullpaths) const; - //------------------------------------------------------------------ /// Get accessor for the declaration information. /// - /// @return + /// \return /// A reference to the declaration object. - //------------------------------------------------------------------ Declaration &GetDeclaration(); - //------------------------------------------------------------------ /// Get const accessor for the declaration information. /// - /// @return + /// \return /// A const reference to the declaration object. - //------------------------------------------------------------------ const Declaration &GetDeclaration() const; - //------------------------------------------------------------------ /// Get accessor for the method name. /// - /// @return + /// \return /// A const reference to the method name object. - //------------------------------------------------------------------ ConstString GetName() const; - //------------------------------------------------------------------ /// Get the memory cost of this object. /// - /// @return + /// \return /// The number of bytes that this object occupies in memory. /// The returned value does not include the bytes for any /// shared string values. /// - /// @see ConstString::StaticMemorySize () - //------------------------------------------------------------------ + /// \see ConstString::StaticMemorySize () virtual size_t MemorySize() const; protected: - //------------------------------------------------------------------ // Member variables. - //------------------------------------------------------------------ ConstString m_name; ///< Function method name (not a mangled name). Declaration m_declaration; ///< Information describing where this function ///information was defined. }; -//---------------------------------------------------------------------- -/// @class InlineFunctionInfo Function.h "lldb/Symbol/Function.h" +/// \class InlineFunctionInfo Function.h "lldb/Symbol/Function.h" /// 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. /// - /// @param[in] name + /// \param[in] name /// A C string name for the method name for this function. This /// value should not be the mangled named, but the simple method /// name. /// - /// @param[in] mangled + /// \param[in] mangled /// A C string name for the mangled name for this function. This /// value can be NULL if there is no mangled information. /// - /// @param[in] decl_ptr + /// \param[in] decl_ptr /// Optional declaration information that describes where the /// function was declared. This can be NULL. /// - /// @param[in] call_decl_ptr + /// \param[in] call_decl_ptr /// Optional calling location declaration information that /// describes from where this inlined function was called. - //------------------------------------------------------------------ InlineFunctionInfo(const char *name, const char *mangled, const Declaration *decl_ptr, const Declaration *call_decl_ptr); - //------------------------------------------------------------------ /// Construct with the function method name, mangled name, and optional /// declaration information. /// - /// @param[in] name + /// \param[in] name /// A name for the method name for this function. This value /// should not be the mangled named, but the simple method name. /// - /// @param[in] mangled + /// \param[in] mangled /// A name for the mangled name for this function. This value /// can be empty if there is no mangled information. /// - /// @param[in] decl_ptr + /// \param[in] decl_ptr /// Optional declaration information that describes where the /// function was declared. This can be NULL. /// - /// @param[in] call_decl_ptr + /// \param[in] call_decl_ptr /// Optional calling location declaration information that /// describes from where this inlined function was called. - //------------------------------------------------------------------ - InlineFunctionInfo(const ConstString &name, const Mangled &mangled, + InlineFunctionInfo(ConstString name, const Mangled &mangled, const Declaration *decl_ptr, const Declaration *call_decl_ptr); - //------------------------------------------------------------------ /// Destructor. - //------------------------------------------------------------------ ~InlineFunctionInfo() override; - //------------------------------------------------------------------ /// Compare two inlined function information objects. /// /// First compares the FunctionInfo objects, and if equal, compares the /// mangled names. /// - /// @param[in] lhs + /// \param[in] lhs /// The Left Hand Side const InlineFunctionInfo object /// reference. /// - /// @param[in] rhs + /// \param[in] rhs /// The Right Hand Side const InlineFunctionInfo object /// reference. /// - /// @return - /// @li -1 if lhs < rhs - /// @li 0 if lhs == rhs - /// @li 1 if lhs > rhs - //------------------------------------------------------------------ + /// \return + /// \li -1 if lhs < rhs + /// \li 0 if lhs == rhs + /// \li 1 if lhs > rhs int Compare(const InlineFunctionInfo &lhs, const InlineFunctionInfo &rhs); - //------------------------------------------------------------------ /// Dump a description of this object to a Stream. /// /// Dump a description of the contents of this object to the supplied stream /// \a s. /// - /// @param[in] s + /// \param[in] s /// The stream to which to dump the object description. - //------------------------------------------------------------------ void Dump(Stream *s, bool show_fullpaths) const; void DumpStopContext(Stream *s, lldb::LanguageType language) const; @@ -238,54 +203,42 @@ public: ConstString GetDisplayName(lldb::LanguageType language) const; - //------------------------------------------------------------------ /// Get accessor for the call site declaration information. /// - /// @return + /// \return /// A reference to the declaration object. - //------------------------------------------------------------------ Declaration &GetCallSite(); - //------------------------------------------------------------------ /// Get const accessor for the call site declaration information. /// - /// @return + /// \return /// A const reference to the declaration object. - //------------------------------------------------------------------ const Declaration &GetCallSite() const; - //------------------------------------------------------------------ /// Get accessor for the mangled name object. /// - /// @return + /// \return /// A reference to the mangled name object. - //------------------------------------------------------------------ Mangled &GetMangled(); - //------------------------------------------------------------------ /// Get const accessor for the mangled name object. /// - /// @return + /// \return /// A const reference to the mangled name object. - //------------------------------------------------------------------ const Mangled &GetMangled() const; - //------------------------------------------------------------------ /// Get the memory cost of this object. /// - /// @return + /// \return /// The number of bytes that this object occupies in memory. /// The returned value does not include the bytes for any /// shared string values. /// - /// @see ConstString::StaticMemorySize () - //------------------------------------------------------------------ + /// \see ConstString::StaticMemorySize () size_t MemorySize() const override; private: - //------------------------------------------------------------------ // Member variables. - //------------------------------------------------------------------ Mangled m_mangled; ///< Mangled inlined function name (can be empty if there ///is no mangled information). Declaration m_call_decl; @@ -293,12 +246,10 @@ private: class Function; -//---------------------------------------------------------------------- -/// @class CallEdge Function.h "lldb/Symbol/Function.h" +/// \class CallEdge Function.h "lldb/Symbol/Function.h" /// /// Represent a call made within a Function. This can be used to find a path /// in the call graph between two functions. -//---------------------------------------------------------------------- class CallEdge { public: /// Construct a call edge using a symbol name to identify the calling @@ -349,8 +300,7 @@ private: DISALLOW_COPY_AND_ASSIGN(CallEdge); }; -//---------------------------------------------------------------------- -/// @class Function Function.h "lldb/Symbol/Function.h" +/// \class Function Function.h "lldb/Symbol/Function.h" /// A class that describes a function. /// /// Functions belong to CompileUnit objects (Function::m_comp_unit), have @@ -362,61 +312,54 @@ private: /// (Function::m_type), and contains lexical blocks (Function::m_blocks). /// /// The function information is split into a few pieces: -/// @li The concrete instance information -/// @li The abstract information +/// \li The concrete instance information +/// \li The abstract information /// /// 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. -//---------------------------------------------------------------------- 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. /// - /// @param[in] comp_unit + /// \param[in] comp_unit /// The compile unit to which this function belongs. /// - /// @param[in] func_uid + /// \param[in] func_uid /// The UID for this function. This value is provided by the /// SymbolFile plug-in and can be any value that allows /// the plug-in to quickly find and parse more detailed /// information when and if more information is needed. /// - /// @param[in] func_type_uid + /// \param[in] func_type_uid /// The type UID for the function Type to allow for lazy type /// parsing from the debug information. /// - /// @param[in] mangled + /// \param[in] mangled /// The optional mangled name for this function. If empty, there /// is no mangled information. /// - /// @param[in] func_type + /// \param[in] func_type /// The optional function type. If NULL, the function type will /// be parsed on demand when accessed using the /// Function::GetType() function by asking the SymbolFile /// plug-in to get the type for \a func_type_uid. /// - /// @param[in] range + /// \param[in] range /// The section offset based address for this function. - //------------------------------------------------------------------ Function(CompileUnit *comp_unit, lldb::user_id_t func_uid, lldb::user_id_t func_type_uid, const Mangled &mangled, Type *func_type, const AddressRange &range); - //------------------------------------------------------------------ /// Destructor. - //------------------------------------------------------------------ ~Function() override; - //------------------------------------------------------------------ - /// @copydoc SymbolContextScope::CalculateSymbolContext(SymbolContext*) + /// \copydoc SymbolContextScope::CalculateSymbolContext(SymbolContext*) /// - /// @see SymbolContextScope - //------------------------------------------------------------------ + /// \see SymbolContextScope void CalculateSymbolContext(SymbolContext *sc) override; lldb::ModuleSP CalculateSymbolContextModule() override; @@ -428,89 +371,71 @@ public: const AddressRange &GetAddressRange() { return m_range; } 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. /// - /// @param[out] source_file + /// \param[out] source_file /// The source file. /// - /// @param[out] line_no + /// \param[out] line_no /// The line number. - //------------------------------------------------------------------ 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. /// /// - /// @param[out] source_file + /// \param[out] source_file /// The source file. /// - /// @param[out] line_no + /// \param[out] line_no /// The line number. - //------------------------------------------------------------------ void GetEndLineSourceInfo(FileSpec &source_file, uint32_t &line_no); - //------------------------------------------------------------------ /// Get the outgoing call edges from this function, sorted by their return /// PC addresses (in increasing order). - //------------------------------------------------------------------ llvm::MutableArrayRef<CallEdge> GetCallEdges(); - //------------------------------------------------------------------ /// Get the outgoing tail-calling edges from this function. If none exist, /// return None. - //------------------------------------------------------------------ llvm::MutableArrayRef<CallEdge> GetTailCallingEdges(); - //------------------------------------------------------------------ /// Get accessor for the block list. /// - /// @return + /// \return /// The block list object that describes all lexical blocks /// in the function. /// - /// @see BlockList - //------------------------------------------------------------------ + /// \see BlockList Block &GetBlock(bool can_create); - //------------------------------------------------------------------ /// Get accessor for the compile unit that owns this function. /// - /// @return + /// \return /// A compile unit object pointer. - //------------------------------------------------------------------ CompileUnit *GetCompileUnit(); - //------------------------------------------------------------------ /// Get const accessor for the compile unit that owns this function. /// - /// @return + /// \return /// A const compile unit object pointer. - //------------------------------------------------------------------ const CompileUnit *GetCompileUnit() const; void GetDescription(Stream *s, lldb::DescriptionLevel level, Target *target); - //------------------------------------------------------------------ /// Get accessor for the frame base location. /// - /// @return + /// \return /// A location expression that describes the function frame /// base. - //------------------------------------------------------------------ DWARFExpression &GetFrameBaseExpression() { return m_frame_base; } - //------------------------------------------------------------------ /// Get const accessor for the frame base location. /// - /// @return + /// \return /// A const compile unit object pointer. - //------------------------------------------------------------------ const DWARFExpression &GetFrameBaseExpression() const { return m_frame_base; } ConstString GetName() const; @@ -521,79 +446,64 @@ public: const Mangled &GetMangled() const { return m_mangled; } - //------------------------------------------------------------------ /// Get the DeclContext for this function, if available. /// - /// @return + /// \return /// The DeclContext, or NULL if none exists. - //------------------------------------------------------------------ CompilerDeclContext GetDeclContext(); - //------------------------------------------------------------------ /// Get accessor for the type that describes the function return value type, /// and parameter types. /// - /// @return + /// \return /// A type object pointer. - //------------------------------------------------------------------ Type *GetType(); - //------------------------------------------------------------------ /// Get const accessor for the type that describes the function return value /// type, and parameter types. /// - /// @return + /// \return /// A const type object pointer. - //------------------------------------------------------------------ const Type *GetType() const; CompilerType GetCompilerType(); - //------------------------------------------------------------------ /// 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. /// - /// @return + /// \return /// The size of the prologue. - //------------------------------------------------------------------ uint32_t GetPrologueByteSize(); - //------------------------------------------------------------------ /// Dump a description of this object to a Stream. /// /// Dump a description of the contents of this object to the supplied stream /// \a s. /// - /// @param[in] s + /// \param[in] s /// The stream to which to dump the object description. /// - /// @param[in] show_context + /// \param[in] show_context /// If \b true, variables will dump their symbol context /// information. - //------------------------------------------------------------------ void Dump(Stream *s, bool show_context) const; - //------------------------------------------------------------------ - /// @copydoc SymbolContextScope::DumpSymbolContext(Stream*) + /// \copydoc SymbolContextScope::DumpSymbolContext(Stream*) /// - /// @see SymbolContextScope - //------------------------------------------------------------------ + /// \see SymbolContextScope void DumpSymbolContext(Stream *s) override; - //------------------------------------------------------------------ /// Get the memory cost of this object. /// - /// @return + /// \return /// The number of bytes that this object occupies in memory. /// The returned value does not include the bytes for any /// shared string values. /// - /// @see ConstString::StaticMemorySize () - //------------------------------------------------------------------ + /// \see ConstString::StaticMemorySize () size_t MemorySize() const; - //------------------------------------------------------------------ /// Get whether compiler optimizations were enabled for this function /// /// The debug information may provide information about whether this @@ -603,14 +513,12 @@ public: /// would expect them, stepping through the source lines in the function may /// appear strange, etc. /// - /// @return + /// \return /// Returns 'true' if this function was compiled with /// optimization. 'false' indicates that either the optimization /// is unknown, or this function was built without optimization. - //------------------------------------------------------------------ bool GetIsOptimized(); - //------------------------------------------------------------------ /// Get whether this function represents a 'top-level' function /// /// The concept of a top-level function is language-specific, mostly meant @@ -621,10 +529,9 @@ public: /// If stopped in a top-level function, LLDB will expose global variables /// as-if locals in the 'frame variable' command /// - /// @return + /// \return /// Returns 'true' if this function is a top-level function, /// 'false' otherwise. - //------------------------------------------------------------------ bool IsTopLevelFunction(); lldb::DisassemblerSP GetInstructions(const ExecutionContext &exe_ctx, @@ -640,9 +547,7 @@ protected: (1 << 0) ///< Have we already tried to calculate the prologue size? }; - //------------------------------------------------------------------ // Member variables. - //------------------------------------------------------------------ CompileUnit *m_comp_unit; ///< The compile unit that owns this function. lldb::user_id_t m_type_uid; ///< The user ID of for the prototype Type for this function. diff --git a/include/lldb/Symbol/LineEntry.h b/include/lldb/Symbol/LineEntry.h index c1ce614609c11..fe97a78e3ed4a 100644 --- a/include/lldb/Symbol/LineEntry.h +++ b/include/lldb/Symbol/LineEntry.h @@ -1,9 +1,8 @@ //===-- LineEntry.h ---------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -16,16 +15,12 @@ namespace lldb_private { -//---------------------------------------------------------------------- -/// @class LineEntry LineEntry.h "lldb/Symbol/LineEntry.h" +/// \class LineEntry LineEntry.h "lldb/Symbol/LineEntry.h" /// A line table entry class. -//---------------------------------------------------------------------- struct LineEntry { - //------------------------------------------------------------------ /// Default constructor. /// /// Initialize all member variables to invalid values. - //------------------------------------------------------------------ LineEntry(); LineEntry(const lldb::SectionSP §ion_sp, lldb::addr_t section_offset, @@ -34,95 +29,84 @@ struct LineEntry { bool _is_start_of_basic_block, bool _is_prologue_end, bool _is_epilogue_begin, bool _is_terminal_entry); - //------------------------------------------------------------------ /// Clear the object's state. /// /// Clears all member variables to invalid values. - //------------------------------------------------------------------ void Clear(); - //------------------------------------------------------------------ /// Dump a description of this object to a Stream. /// /// Dump a description of the contents of this object to the supplied stream /// \a s. /// - /// @param[in] s + /// \param[in] s /// The stream to which to dump the object description. /// - /// @param[in] comp_unit + /// \param[in] comp_unit /// The compile unit object that contains the support file /// list so the line entry can dump the file name (since this /// object contains a file index into the support file list). /// - /// @param[in] show_file + /// \param[in] show_file /// If \b true, display the filename with the line entry which /// requires that the compile unit object \a comp_unit be a /// valid pointer. /// - /// @param[in] style + /// \param[in] style /// The display style for the section offset address. /// - /// @return + /// \return /// Returns \b true if the address was able to be displayed /// using \a style. File and load addresses may be unresolved /// and it may not be possible to display a valid address value. /// Returns \b false if the address was not able to be properly /// dumped. /// - /// @see Address::DumpStyle - //------------------------------------------------------------------ + /// \see Address::DumpStyle bool Dump(Stream *s, Target *target, bool show_file, Address::DumpStyle style, Address::DumpStyle fallback_style, bool show_range) const; bool GetDescription(Stream *s, lldb::DescriptionLevel level, CompileUnit *cu, 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. /// - /// @param[in] s + /// \param[in] s /// The stream to which to dump the object description. /// - /// @param[in] comp_unit + /// \param[in] comp_unit /// The compile unit object that contains the support file /// list so the line entry can dump the file name (since this /// object contains a file index into the support file list). /// - /// @return + /// \return /// Returns \b true if the file and line were properly dumped, /// \b false otherwise. - //------------------------------------------------------------------ bool DumpStopContext(Stream *s, bool show_fullpaths) const; - //------------------------------------------------------------------ /// Check if a line entry object is valid. /// - /// @return + /// \return /// Returns \b true if the line entry contains a valid section /// offset address, file index, and line number, \b false /// otherwise. - //------------------------------------------------------------------ bool IsValid() const; - //------------------------------------------------------------------ /// Compare two LineEntry objects. /// - /// @param[in] lhs + /// \param[in] lhs /// The Left Hand Side const LineEntry object reference. /// - /// @param[in] rhs + /// \param[in] rhs /// The Right Hand Side const LineEntry object reference. /// - /// @return - /// @li -1 if lhs < rhs - /// @li 0 if lhs == rhs - /// @li 1 if lhs > rhs - //------------------------------------------------------------------ + /// \return + /// \li -1 if lhs < rhs + /// \li 0 if lhs == rhs + /// \li 1 if lhs > rhs 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. /// @@ -139,27 +123,30 @@ struct LineEntry { /// LineEntry (and it will include the range of the following LineEntries /// that match either 32 or 0.) /// + /// When \b include_inlined_functions is \b true inlined functions with + /// a call site at this LineEntry will also 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 + /// @param[in] include_inlined_functions + /// Whether to include inlined functions at the same line or not. + /// + /// \return /// The contiguous AddressRange for this source line. - //------------------------------------------------------------------ - AddressRange GetSameLineContiguousAddressRange() const; + AddressRange + GetSameLineContiguousAddressRange(bool include_inlined_functions) const; - //------------------------------------------------------------------ /// Apply file mappings from target.source-map to the LineEntry's file. /// - /// @param[in] target_sp + /// \param[in] target_sp /// Shared pointer to the target this LineEntry belongs to. - //------------------------------------------------------------------ void ApplyFileMappings(lldb::TargetSP target_sp); - //------------------------------------------------------------------ // Member variables. - //------------------------------------------------------------------ AddressRange range; ///< The section offset address range for this line entry. FileSpec file; ///< The source file, possibly mapped by the target.source-map ///setting @@ -183,18 +170,16 @@ struct LineEntry { ///instructions. }; -//------------------------------------------------------------------ /// Less than operator. /// -/// @param[in] lhs +/// \param[in] lhs /// The Left Hand Side const LineEntry object reference. /// -/// @param[in] rhs +/// \param[in] rhs /// The Right Hand Side const LineEntry object reference. /// -/// @return +/// \return /// Returns \b true if lhs < rhs, false otherwise. -//------------------------------------------------------------------ bool operator<(const LineEntry &lhs, const LineEntry &rhs); } // namespace lldb_private diff --git a/include/lldb/Symbol/LineTable.h b/include/lldb/Symbol/LineTable.h index 684972d507893..d24cc35e10f36 100644 --- a/include/lldb/Symbol/LineTable.h +++ b/include/lldb/Symbol/LineTable.h @@ -1,29 +1,25 @@ //===-- LineTable.h ---------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// #ifndef liblldb_LineTable_h_ #define liblldb_LineTable_h_ -#include <vector> - #include "lldb/Core/ModuleChild.h" -#include "lldb/Core/RangeMap.h" #include "lldb/Core/Section.h" #include "lldb/Symbol/LineEntry.h" +#include "lldb/Utility/RangeMap.h" #include "lldb/lldb-private.h" +#include <vector> namespace lldb_private { -//---------------------------------------------------------------------- -/// @class LineSequence LineTable.h "lldb/Symbol/LineTable.h" An abstract base +/// \class LineSequence LineTable.h "lldb/Symbol/LineTable.h" An abstract base /// class used during symbol table creation. -//---------------------------------------------------------------------- class LineSequence { public: LineSequence(); @@ -36,36 +32,28 @@ private: DISALLOW_COPY_AND_ASSIGN(LineSequence); }; -//---------------------------------------------------------------------- -/// @class LineTable LineTable.h "lldb/Symbol/LineTable.h" +/// \class LineTable LineTable.h "lldb/Symbol/LineTable.h" /// A line table class. -//---------------------------------------------------------------------- class LineTable { public: - //------------------------------------------------------------------ /// Construct with compile unit. /// - /// @param[in] comp_unit + /// \param[in] comp_unit /// The compile unit to which this line table belongs. - //------------------------------------------------------------------ LineTable(CompileUnit *comp_unit); - //------------------------------------------------------------------ /// Destructor. - //------------------------------------------------------------------ ~LineTable(); - //------------------------------------------------------------------ /// Adds a new line entry to this line table. /// /// All line entries are maintained in file address order. /// - /// @param[in] line_entry + /// \param[in] line_entry /// A const reference to a new line_entry to add to this line /// table. /// - /// @see Address::DumpStyle - //------------------------------------------------------------------ + /// \see Address::DumpStyle // void // AddLineEntry (const LineEntry& line_entry); @@ -90,45 +78,40 @@ public: // Insert a sequence of entries into this line table. void InsertSequence(LineSequence *sequence); - //------------------------------------------------------------------ /// Dump all line entries in this line table to the stream \a s. /// - /// @param[in] s + /// \param[in] s /// The stream to which to dump the object description. /// - /// @param[in] style + /// \param[in] style /// The display style for the address. /// - /// @see Address::DumpStyle - //------------------------------------------------------------------ + /// \see Address::DumpStyle void Dump(Stream *s, Target *target, Address::DumpStyle style, Address::DumpStyle fallback_style, bool show_line_ranges); void GetDescription(Stream *s, Target *target, lldb::DescriptionLevel level); - //------------------------------------------------------------------ /// Find a line entry that contains the section offset address \a so_addr. /// - /// @param[in] so_addr + /// \param[in] so_addr /// A section offset address object containing the address we /// are searching for. /// - /// @param[out] line_entry + /// \param[out] line_entry /// A copy of the line entry that was found if \b true is /// returned, otherwise \a entry is left unmodified. /// - /// @param[out] index_ptr + /// \param[out] index_ptr /// A pointer to a 32 bit integer that will get the actual line /// entry index if it is not nullptr. /// - /// @return + /// \return /// Returns \b true if \a so_addr is contained in a line entry /// in this line table, \b false otherwise. - //------------------------------------------------------------------ bool FindLineEntryByAddress(const Address &so_addr, LineEntry &line_entry, uint32_t *index_ptr = nullptr); - //------------------------------------------------------------------ /// Find a line entry index that has a matching file index and source line /// number. /// @@ -136,34 +119,33 @@ public: /// line number \a line starting at the \a start_idx entries into the line /// entry collection. /// - /// @param[in] start_idx + /// \param[in] start_idx /// The number of entries to skip when starting the search. /// - /// @param[out] file_idx + /// \param[out] file_idx /// The file index to search for that should be found prior /// to calling this function using the following functions: /// CompileUnit::GetSupportFiles() /// FileSpecList::FindFileIndex (uint32_t, const FileSpec &) const /// - /// @param[in] line + /// \param[in] line /// The source line to match. /// - /// @param[in] exact + /// \param[in] exact /// If true, match only if you find a line entry exactly matching \a line. /// If false, return the closest line entry greater than \a line. /// - /// @param[out] line_entry + /// \param[out] line_entry /// A reference to a line entry object that will get a copy of /// the line entry if \b true is returned, otherwise \a /// line_entry is left untouched. /// - /// @return + /// \return /// Returns \b true if a matching line entry is found in this /// line table, \b false otherwise. /// - /// @see CompileUnit::GetSupportFiles() - /// @see FileSpecList::FindFileIndex (uint32_t, const FileSpec &) const - //------------------------------------------------------------------ + /// \see CompileUnit::GetSupportFiles() + /// \see FileSpecList::FindFileIndex (uint32_t, const FileSpec &) const uint32_t FindLineEntryIndexByFileIndex(uint32_t start_idx, uint32_t file_idx, uint32_t line, bool exact, LineEntry *line_entry_ptr); @@ -175,61 +157,53 @@ public: size_t FineLineEntriesForFileIndex(uint32_t file_idx, bool append, SymbolContextList &sc_list); - //------------------------------------------------------------------ /// Get the line entry from the line table at index \a idx. /// - /// @param[in] idx + /// \param[in] idx /// An index into the line table entry collection. /// - /// @return + /// \return /// A valid line entry if \a idx is a valid index, or an invalid /// line entry if \a idx is not valid. /// - /// @see LineTable::GetSize() - /// @see LineEntry::IsValid() const - //------------------------------------------------------------------ + /// \see LineTable::GetSize() + /// \see LineEntry::IsValid() const bool GetLineEntryAtIndex(uint32_t idx, LineEntry &line_entry); - //------------------------------------------------------------------ /// Gets the size of the line table in number of line table entries. /// - /// @return + /// \return /// The number of line table entries in this line table. - //------------------------------------------------------------------ uint32_t GetSize() const; typedef lldb_private::RangeArray<lldb::addr_t, lldb::addr_t, 32> FileAddressRanges; - //------------------------------------------------------------------ /// Gets all contiguous file address ranges for the entire line table. /// - /// @param[out] file_ranges + /// \param[out] file_ranges /// A collection of file address ranges that will be filled in /// by this function. /// - /// @param[out] append + /// \param[out] append /// If \b true, then append to \a file_ranges, otherwise clear /// \a file_ranges prior to adding any ranges. /// - /// @return + /// \return /// The number of address ranges added to \a file_ranges - //------------------------------------------------------------------ size_t GetContiguousFileAddressRanges(FileAddressRanges &file_ranges, bool append); - //------------------------------------------------------------------ /// Given a file range link map, relink the current line table and return a /// fixed up line table. /// - /// @param[out] file_range_map + /// \param[out] file_range_map /// A collection of file ranges that maps to new file ranges /// that will be used when linking the line table. /// - /// @return + /// \return /// A new line table if at least one line table entry was able /// to be mapped. - //------------------------------------------------------------------ typedef RangeDataVector<lldb::addr_t, lldb::addr_t, lldb::addr_t> FileRangeMap; @@ -304,9 +278,7 @@ protected: return lhs.file_addr < rhs.file_addr; } - //------------------------------------------------------------------ // Member variables. - //------------------------------------------------------------------ /// The file address for this line entry. lldb::addr_t file_addr; /// The source line number, or zero if there is no line number @@ -339,24 +311,18 @@ protected: Entry *a_entry; }; - //------------------------------------------------------------------ // Types - //------------------------------------------------------------------ typedef std::vector<lldb_private::Section *> section_collection; ///< The collection type for the sections. typedef std::vector<Entry> entry_collection; ///< The collection type for the line entries. - //------------------------------------------------------------------ // Member variables. - //------------------------------------------------------------------ CompileUnit *m_comp_unit; ///< The compile unit that this line table belongs to. entry_collection m_entries; ///< The collection of line entries in this line table. - //------------------------------------------------------------------ // Helper class - //------------------------------------------------------------------ class LineSequenceImpl : public LineSequence { public: LineSequenceImpl() = default; diff --git a/include/lldb/Host/Symbols.h b/include/lldb/Symbol/LocateSymbolFile.h index 8b00900d33215..0ff834df9c409 100644 --- a/include/lldb/Host/Symbols.h +++ b/include/lldb/Symbol/LocateSymbolFile.h @@ -1,9 +1,8 @@ -//===-- Symbols.h -----------------------------------------------*- C++ -*-===// +//===-- LocateSymbolFile.h --------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -12,6 +11,7 @@ #include <stdint.h> +#include "lldb/Core/FileSpecList.h" #include "lldb/Utility/FileSpec.h" namespace lldb_private { @@ -22,27 +22,24 @@ class UUID; class Symbols { 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. - //---------------------------------------------------------------------- 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. - //---------------------------------------------------------------------- - static FileSpec LocateExecutableSymbolFile(const ModuleSpec &module_spec); + static FileSpec + LocateExecutableSymbolFile(const ModuleSpec &module_spec, + const FileSpecList &default_search_paths); static FileSpec FindSymbolFileInBundle(const FileSpec &dsym_bundle_fspec, const lldb_private::UUID *uuid, const ArchSpec *arch); - //---------------------------------------------------------------------- // Locate the object and symbol file given a module specification. // // Locating the file can try to download the file from a corporate build @@ -52,7 +49,6 @@ public: // 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, bool force_lookup = true); }; diff --git a/include/lldb/Symbol/ObjectContainer.h b/include/lldb/Symbol/ObjectContainer.h index 1e14856ea6ea6..9310fdc18d904 100644 --- a/include/lldb/Symbol/ObjectContainer.h +++ b/include/lldb/Symbol/ObjectContainer.h @@ -1,9 +1,8 @@ //===-- ObjectContainer.h ---------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -19,8 +18,7 @@ namespace lldb_private { -//---------------------------------------------------------------------- -/// @class ObjectContainer ObjectContainer.h "lldb/Symbol/ObjectContainer.h" +/// \class ObjectContainer ObjectContainer.h "lldb/Symbol/ObjectContainer.h" /// A plug-in interface definition class for object containers. /// /// Object containers contain object files from one or more architectures, and @@ -29,16 +27,13 @@ namespace lldb_private { /// 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. - //------------------------------------------------------------------ ObjectContainer(const lldb::ModuleSP &module_sp, const FileSpec *file, lldb::offset_t file_offset, lldb::offset_t length, lldb::DataBufferSP &data_sp, lldb::offset_t data_offset) @@ -51,72 +46,61 @@ public: m_data.SetData(data_sp, data_offset, length); } - //------------------------------------------------------------------ /// Destructor. /// /// 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. /// - /// @param[in] s + /// \param[in] s /// The stream to which to dump the object description. - //------------------------------------------------------------------ virtual void Dump(Stream *s) const = 0; - //------------------------------------------------------------------ /// Gets the architecture given an index. /// /// Copies the architecture specification for index \a idx. /// - /// @param[in] idx + /// \param[in] idx /// The architecture index to extract. /// - /// @param[out] arch + /// \param[out] arch /// A architecture object that will be filled in if \a idx is a /// architecture valid index. /// - /// @return + /// \return /// Returns \b true if \a idx is valid and \a arch has been /// filled in, \b false otherwise. /// - /// @see ObjectContainer::GetNumArchitectures() const - //------------------------------------------------------------------ + /// \see ObjectContainer::GetNumArchitectures() const virtual bool GetArchitectureAtIndex(uint32_t idx, ArchSpec &arch) const { return false; } - //------------------------------------------------------------------ /// 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. /// - /// @return + /// \return /// The offset in bytes into the file. Defaults to zero for /// simple object files that a represented by an entire file. - //------------------------------------------------------------------ virtual lldb::addr_t GetOffset() const { return m_offset; } virtual lldb::addr_t GetByteSize() const { return m_length; } - //------------------------------------------------------------------ /// Get the number of objects within this object file (archives). /// - /// @return + /// \return /// Zero for object files that are not archives, or the number /// of objects contained in the archive. - //------------------------------------------------------------------ virtual size_t GetNumObjects() const { return 0; } - //------------------------------------------------------------------ /// Get the number of architectures in this object file. /// /// The default implementation returns 1 as for object files that contain a @@ -124,12 +108,10 @@ public: /// one architecture should override this function and return an appropriate /// value. /// - /// @return + /// \return /// The number of architectures contained in this object file. - //------------------------------------------------------------------ virtual size_t GetNumArchitectures() const { return 0; } - //------------------------------------------------------------------ /// Attempts to parse the object header. /// /// This function is used as a test to see if a given plug-in instance can @@ -138,13 +120,11 @@ public: /// false should be returned and the next plug-in can attempt to parse an /// object file. /// - /// @return + /// \return /// Returns \b true if the header was parsed successfully, \b /// false otherwise. - //------------------------------------------------------------------ virtual bool ParseHeader() = 0; - //------------------------------------------------------------------ /// Selects an architecture in an object file. /// /// Object files that contain a single architecture should verify that the @@ -156,11 +136,10 @@ public: /// state from any previously selected architecture and prepare to return /// information for the new architecture. /// - /// @return + /// \return /// Returns a pointer to the object file of the requested \a /// arch and optional \a name. Returns nullptr of no such object /// file exists in the container. - //------------------------------------------------------------------ virtual lldb::ObjectFileSP GetObjectFile(const FileSpec *file) = 0; virtual bool ObjectAtIndexIsContainer(uint32_t object_idx) { return false; } @@ -178,9 +157,7 @@ public: } protected: - //------------------------------------------------------------------ // Member variables. - //------------------------------------------------------------------ FileSpec m_file; ///< The file that represents this container objects (which ///can be different from the module's file). lldb::addr_t diff --git a/include/lldb/Symbol/ObjectFile.h b/include/lldb/Symbol/ObjectFile.h index c6bafcecb6f6d..84683e3f2a3f5 100644 --- a/include/lldb/Symbol/ObjectFile.h +++ b/include/lldb/Symbol/ObjectFile.h @@ -1,9 +1,8 @@ //===-- ObjectFile.h --------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -43,8 +42,7 @@ public: virtual ArchSpec GetArchitecture() = 0; }; -//---------------------------------------------------------------------- -/// @class ObjectFile ObjectFile.h "lldb/Symbol/ObjectFile.h" +/// \class ObjectFile ObjectFile.h "lldb/Symbol/ObjectFile.h" /// A plug-in interface definition class for object file parsers. /// /// Object files belong to Module objects and know how to extract information @@ -57,14 +55,13 @@ public: /// /// Once an architecture is selected the object file information can be /// extracted from this abstract class. -//---------------------------------------------------------------------- class ObjectFile : public std::enable_shared_from_this<ObjectFile>, public PluginInterface, public ModuleChild { friend class lldb_private::Module; public: - typedef enum { + enum Type { eTypeInvalid = 0, eTypeCoreFile, /// A core file that has a checkpoint of a program's /// execution state @@ -77,29 +74,27 @@ public: /// execution eTypeJIT, /// JIT code that has symbols, sections and possibly debug info eTypeUnknown - } Type; + }; - typedef enum { + enum Strata { eStrataInvalid = 0, eStrataUnknown, eStrataUser, eStrataKernel, eStrataRawImage, 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. - //------------------------------------------------------------------ ObjectFile(const lldb::ModuleSP &module_sp, const FileSpec *file_spec_ptr, lldb::offset_t file_offset, lldb::offset_t length, const lldb::DataBufferSP &data_sp, lldb::offset_t data_offset); @@ -107,73 +102,65 @@ public: ObjectFile(const lldb::ModuleSP &module_sp, const lldb::ProcessSP &process_sp, lldb::addr_t header_addr, lldb::DataBufferSP &data_sp); - //------------------------------------------------------------------ /// Destructor. /// /// 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. /// - /// @param[in] s + /// \param[in] s /// The stream to which to dump the object description. - //------------------------------------------------------------------ virtual void Dump(Stream *s) = 0; - //------------------------------------------------------------------ /// 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. /// - /// @param[in] module + /// \param[in] module /// The parent module that owns this object file. /// - /// @param[in] file_spec + /// \param[in] file_spec /// A file specification that indicates which file to use as the /// object file. /// - /// @param[in] file_offset + /// \param[in] file_offset /// The offset into the file at which to start parsing the /// object. This is for files that contain multiple /// architectures or objects. /// - /// @param[in] file_size + /// \param[in] file_size /// The size of the current object file if it can be determined /// or if it is known. This can be zero. /// - /// @see ObjectFile::ParseHeader() - //------------------------------------------------------------------ + /// \see ObjectFile::ParseHeader() static lldb::ObjectFileSP FindPlugin(const lldb::ModuleSP &module_sp, const FileSpec *file_spec, lldb::offset_t file_offset, lldb::offset_t file_size, lldb::DataBufferSP &data_sp, lldb::offset_t &data_offset); - //------------------------------------------------------------------ /// 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. /// - /// @param[in] module + /// \param[in] module /// The parent module that owns this object file. /// - /// @param[in] process_sp + /// \param[in] process_sp /// A shared pointer to the process whose memory space contains /// an object file. This will be stored as a std::weak_ptr. /// - /// @param[in] header_addr + /// \param[in] header_addr /// The address of the header for the object file in memory. - //------------------------------------------------------------------ static lldb::ObjectFileSP FindPlugin(const lldb::ModuleSP &module_sp, const lldb::ProcessSP &process_sp, lldb::addr_t header_addr, @@ -190,60 +177,53 @@ public: lldb::offset_t file_offset, lldb::offset_t file_size, lldb_private::ModuleSpecList &specs); - //------------------------------------------------------------------ /// 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. /// - /// @param[in] path_with_object + /// \param[in] path_with_object /// A path that might contain an archive path with a .o file /// specified in parens in the basename of the path. /// - /// @param[out] archive_file + /// \param[out] archive_file /// If \b true is returned, \a file_spec will be filled in with /// the path to the archive. /// - /// @param[out] archive_object + /// \param[out] archive_object /// If \b true is returned, \a object will be filled in with /// the name of the object inside the archive. /// - /// @return + /// \return /// \b true if the path matches the pattern of archive + object /// and \a archive_file and \a archive_object are modified, /// \b false otherwise and \a archive_file and \a archive_object /// are guaranteed to be remain unchanged. - //------------------------------------------------------------------ static bool SplitArchivePathWithObject( const char *path_with_object, lldb_private::FileSpec &archive_file, lldb_private::ConstString &archive_object, bool must_exist); - //------------------------------------------------------------------ /// Gets the address size in bytes for the current object file. /// - /// @return + /// \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 uint32_t GetAddressByteSize() const = 0; - //------------------------------------------------------------------ /// 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 + /// 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 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 @@ -252,106 +232,86 @@ public: /// 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 + /// \param[out] file_list /// A list of file specification objects that gets dependent /// files appended to. /// - /// @return + /// \return /// The number of new files that were appended to \a file_list. /// - /// @see FileSpecList::AppendIfUnique(const FileSpec &) - //------------------------------------------------------------------ + /// \see FileSpecList::AppendIfUnique(const FileSpec &) virtual uint32_t GetDependentModules(FileSpecList &file_list) = 0; - //------------------------------------------------------------------ /// Tells whether this object file is capable of being the main executable /// for a process. /// - /// @return + /// \return /// \b true if it is, \b false otherwise. - //------------------------------------------------------------------ virtual bool IsExecutable() const = 0; - //------------------------------------------------------------------ /// 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. /// - /// @return + /// \return /// The offset in bytes into the file. Defaults to zero for /// simple object files that a represented by an entire file. - //------------------------------------------------------------------ virtual lldb::addr_t GetFileOffset() const { return m_file_offset; } virtual lldb::addr_t GetByteSize() const { return m_length; } - //------------------------------------------------------------------ /// Get accessor to the object file specification. /// - /// @return + /// \return /// The file specification object pointer if there is one, or /// NULL if this object is only from memory. - //------------------------------------------------------------------ virtual FileSpec &GetFileSpec() { return m_file; } - //------------------------------------------------------------------ /// Get const accessor to the object file specification. /// - /// @return + /// \return /// The const file specification object pointer if there is one, /// or NULL if this object is only from memory. - //------------------------------------------------------------------ virtual const FileSpec &GetFileSpec() const { return m_file; } - //------------------------------------------------------------------ /// Get the ArchSpec for this object file. /// - /// @return + /// \return /// The ArchSpec of this object file. In case of error, an invalid /// ArchSpec object is returned. - //------------------------------------------------------------------ virtual ArchSpec GetArchitecture() = 0; - //------------------------------------------------------------------ /// 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. /// - /// @return + /// \return /// The list of sections contained in this object file. - //------------------------------------------------------------------ virtual SectionList *GetSectionList(bool update_module_section_list = true); virtual void CreateSections(SectionList &unified_section_list) = 0; - //------------------------------------------------------------------ /// 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). /// /// Symbol table parsing can be deferred by ObjectFile instances until this /// accessor is called the first time. /// - /// @return + /// \return /// The symbol table for this object file. - //------------------------------------------------------------------ virtual Symtab *GetSymtab() = 0; - //------------------------------------------------------------------ /// Perform relocations on the section if necessary. /// - //------------------------------------------------------------------ virtual void RelocateSection(lldb_private::Section *section); - //------------------------------------------------------------------ /// 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 @@ -360,10 +320,9 @@ public: /// the first match in the SymbolTable and appends a Symbol only if /// required/found. /// - /// @return + /// \return /// The resolved symbol or nullptr. Returns nullptr if a /// a Symbol could not be found for the specified so_addr. - //------------------------------------------------------------------ virtual Symbol *ResolveSymbolForAddress(const Address &so_addr, bool verify_unique) { // Typically overridden to lazily add stripped symbols recoverable from the @@ -376,94 +335,78 @@ public: return nullptr; } - //------------------------------------------------------------------ /// Detect if this object file has been stripped of local symbols. - //------------------------------------------------------------------ /// Detect if this object file has been stripped of local symbols. /// - /// @return + /// \return /// Return \b true if the object file has been stripped of local /// symbols. - //------------------------------------------------------------------ virtual bool IsStripped() = 0; - //------------------------------------------------------------------ /// Frees the symbol table. /// /// This function should only be used when an object file is /// - /// @param[in] flags + /// \param[in] flags /// eSymtabFromUnifiedSectionList: Whether to clear symbol table /// for unified module section list, or object file. /// - /// @return + /// \return /// The symbol table for this object file. - //------------------------------------------------------------------ virtual void ClearSymtab(); - //------------------------------------------------------------------ /// 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). /// - /// @return - /// Returns \b true if a UUID was successfully extracted into - /// \a uuid, \b false otherwise. - //------------------------------------------------------------------ - virtual bool GetUUID(lldb_private::UUID *uuid) = 0; + /// \return + /// The object file's UUID. In case of an error, an empty UUID is + /// returned. + virtual UUID GetUUID() = 0; - //------------------------------------------------------------------ /// 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. /// - /// @return + /// \return /// Returns filespeclist. - //------------------------------------------------------------------ virtual lldb_private::FileSpecList GetDebugSymbolFilePaths() { return FileSpecList(); } - //------------------------------------------------------------------ /// 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. /// - /// @return + /// \return /// Returns filespeclist. - //------------------------------------------------------------------ virtual lldb_private::FileSpecList GetReExportedLibraries() { return FileSpecList(); } - //------------------------------------------------------------------ /// Sets the load address for an entire module, assuming a rigid slide of /// sections, if possible in the implementation. /// - /// @return + /// \return /// Returns true iff any section's load address changed. - //------------------------------------------------------------------ virtual bool SetLoadAddress(Target &target, lldb::addr_t value, bool value_is_offset) { return false; } - //------------------------------------------------------------------ /// Gets whether endian swapping should occur when extracting data from this /// object file. /// - /// @return + /// \return /// Returns \b true if endian swapping is needed, \b false /// otherwise. - //------------------------------------------------------------------ virtual lldb::ByteOrder GetByteOrder() const = 0; - //------------------------------------------------------------------ /// Attempts to parse the object header. /// /// This function is used as a test to see if a given plug-in instance can @@ -472,27 +415,11 @@ public: /// false should be returned and the next plug-in can attempt to parse an /// object file. /// - /// @return + /// \return /// Returns \b true if the header was parsed successfully, \b /// false otherwise. - //------------------------------------------------------------------ virtual bool ParseHeader() = 0; - //------------------------------------------------------------------ - /// 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. - /// - /// @return - /// Returns the unwind table for this object file. - //------------------------------------------------------------------ - virtual lldb_private::UnwindTable &GetUnwindTable() { return m_unwind_table; } - - //------------------------------------------------------------------ /// Returns if the function bounds for symbols in this symbol file are /// likely accurate. /// @@ -509,15 +436,13 @@ public: /// that symbol start addresses are unavailable before false is returned. /// If it is unclear, this should return true. /// - /// @return + /// \return /// Returns true if assembly emulation should be used for this /// module. /// Only returns false if the ObjectFile is sure that symbol /// addresses are insufficient for accurate assembly emulation. - //------------------------------------------------------------------ virtual bool AllowAssemblyEmulationUnwindPlans() { return true; } - //------------------------------------------------------------------ /// Similar to Process::GetImageInfoAddress(). /// /// Some platforms embed auxiliary structures useful to debuggers in the @@ -527,24 +452,21 @@ public: /// runtime linker so that a debugger may monitor the loading and unloading /// of shared libraries. /// - /// @return + /// \return /// The address of any auxiliary tables, or an invalid address if this /// object file format does not support or contain such information. virtual lldb_private::Address GetImageInfoAddress(Target *target) { return Address(); } - //------------------------------------------------------------------ /// 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 + /// \return /// Returns the entry address for this module. - //------------------------------------------------------------------ virtual lldb_private::Address GetEntryPointAddress() { return Address(); } - //------------------------------------------------------------------ /// Returns base address of this object file. /// /// This also sometimes referred to as the "preferred load address" or the @@ -553,46 +475,41 @@ public: /// (usually the first byte of the first section) then the returned address /// will have this section set. Otherwise, the address will just have the /// offset member filled in, indicating that this represents a file address. - //------------------------------------------------------------------ virtual lldb_private::Address GetBaseAddress() { return Address(m_memory_addr); } 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) /// - /// @return + /// \return /// Returns the identifier string if one exists, else an empty /// string. - //------------------------------------------------------------------ virtual std::string GetIdentifierString () { return std::string(); } - //------------------------------------------------------------------ /// 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 + /// \param[out] address /// If the address of the binary is specified, this will be set. /// This is an address is the virtual address space of the core file /// memory segments; it is not an offset into the object file. /// If no address is available, will be set to LLDB_INVALID_ADDRESS. /// - /// @param[out] uuid + /// \param[out] uuid /// If the uuid of the binary is specified, this will be set. /// If no UUID is available, will be cleared. /// - /// @return + /// \return /// Returns true if either address or uuid has been set. - //------------------------------------------------------------------ virtual bool GetCorefileMainBinaryInfo (lldb::addr_t &address, UUID &uuid) { address = LLDB_INVALID_ADDRESS; uuid.Clear(); @@ -604,7 +521,6 @@ public: return lldb::RegisterContextSP(); } - //------------------------------------------------------------------ /// 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- @@ -612,18 +528,15 @@ public: /// eTypeXXX definitions do not match up with the type of file you are /// loading, please feel free to add a new enumeration value. /// - /// @return + /// \return /// The calculated file type for the current object file. - //------------------------------------------------------------------ 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. virtual void SetType(Type type) { m_type = type; } - //------------------------------------------------------------------ /// The object file should be able to calculate the strata of the object /// file. /// @@ -632,13 +545,11 @@ public: /// out, it will help with debugger plug-in selection when it comes time to /// debug. /// - /// @return + /// \return /// The calculated object file strata for the current object /// file. - //------------------------------------------------------------------ virtual Strata CalculateStrata() = 0; - //------------------------------------------------------------------ /// Get the object file version numbers. /// /// Many object files have a set of version numbers that describe the @@ -646,43 +557,33 @@ public: /// minor and build, but there may be more. This function will extract the /// versions from object files if they are available. /// - /// @return + /// \return /// This function returns extracted version numbers as a /// llvm::VersionTuple. In case of error an empty VersionTuple is /// returned. - //------------------------------------------------------------------ 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. /// - /// @return + /// \return /// This function returns extracted version numbers as a /// llvm::VersionTuple. In case of error an empty VersionTuple is /// returned. - //------------------------------------------------------------------ virtual llvm::VersionTuple GetMinimumOSVersion() { return llvm::VersionTuple(); } - //------------------------------------------------------------------ /// Get the SDK OS version this object file was built with. /// - /// The versions arguments and returns values are the same as the - /// GetMinimumOSVersion() - //------------------------------------------------------------------ - virtual uint32_t GetSDKVersion(uint32_t *versions, uint32_t num_versions) { - if (versions && num_versions) { - for (uint32_t i = 0; i < num_versions; ++i) - versions[i] = UINT32_MAX; - } - return 0; - } + /// \return + /// This function returns extracted version numbers as a + /// llvm::VersionTuple. In case of error an empty VersionTuple is + /// returned. + virtual llvm::VersionTuple GetSDKVersion() { return llvm::VersionTuple(); } - //------------------------------------------------------------------ /// Return true if this file is a dynamic link editor (dyld) /// /// Often times dyld has symbols that mirror symbols in libc and other @@ -690,12 +591,9 @@ public: /// 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; } - //------------------------------------------------------------------ // Member Functions - //------------------------------------------------------------------ Type GetType() { if (m_type == eTypeInvalid) m_type = CalculateType(); @@ -747,24 +645,20 @@ public: llvm::StringRef name, lldb::SymbolType symbol_type_hint = lldb::eSymbolTypeUndefined); - //------------------------------------------------------------------ /// 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. /// - /// @param[in] target + /// \param[in] target /// Target where to load. /// - /// @return - //------------------------------------------------------------------ + /// \return virtual std::vector<LoadableData> GetLoadableData(Target &target); protected: - //------------------------------------------------------------------ // Member variables. - //------------------------------------------------------------------ FileSpec m_file; Type m_type; Strata m_strata; @@ -775,27 +669,22 @@ protected: ///determined). DataExtractor m_data; ///< The data for this object file so things can be parsed lazily. - lldb_private::UnwindTable m_unwind_table; /// < Table of FuncUnwinders objects - /// created for this ObjectFile's - /// functions lldb::ProcessWP m_process_wp; const lldb::addr_t m_memory_addr; - std::unique_ptr<lldb_private::SectionList> m_sections_ap; - std::unique_ptr<lldb_private::Symtab> m_symtab_ap; + std::unique_ptr<lldb_private::SectionList> m_sections_up; + std::unique_ptr<lldb_private::Symtab> m_symtab_up; 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. /// - /// @param[in] new_arch + /// \param[in] new_arch /// The architecture this module will be set to. /// - /// @return + /// \return /// Returns \b true if the architecture was changed, \b /// false otherwise. - //------------------------------------------------------------------ bool SetModulesArchitecture(const ArchSpec &new_arch); ConstString GetNextSyntheticSymbolName(); diff --git a/include/lldb/Symbol/PostfixExpression.h b/include/lldb/Symbol/PostfixExpression.h new file mode 100644 index 0000000000000..e3a8587a5f849 --- /dev/null +++ b/include/lldb/Symbol/PostfixExpression.h @@ -0,0 +1,226 @@ +//===-- PostfixExpression.h -------------------------------------*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// +// +// This file implements support for postfix expressions found in several symbol +// file formats, and their conversion to DWARF. +// +//===----------------------------------------------------------------------===// + +#ifndef LLDB_SYMBOL_POSTFIXEXPRESSION_H +#define LLDB_SYMBOL_POSTFIXEXPRESSION_H + +#include "llvm/ADT/StringRef.h" +#include "llvm/Support/Allocator.h" +#include "llvm/Support/Casting.h" + +namespace lldb_private { + +class Stream; + +namespace postfix { + +/// The base class for all nodes in the parsed postfix tree. +class Node { +public: + enum Kind { + BinaryOp, + InitialValue, + Integer, + Register, + Symbol, + UnaryOp, + }; + +protected: + Node(Kind kind) : m_kind(kind) {} + +public: + Kind GetKind() const { return m_kind; } + +private: + Kind m_kind; +}; + +/// A node representing a binary expression. +class BinaryOpNode : public Node { +public: + enum OpType { + Align, // alignDown(a, b) + Minus, // a - b + Plus, // a + b + }; + + BinaryOpNode(OpType op_type, Node &left, Node &right) + : Node(BinaryOp), m_op_type(op_type), m_left(&left), m_right(&right) {} + + OpType GetOpType() const { return m_op_type; } + + const Node *Left() const { return m_left; } + Node *&Left() { return m_left; } + + const Node *Right() const { return m_right; } + Node *&Right() { return m_right; } + + static bool classof(const Node *node) { return node->GetKind() == BinaryOp; } + +private: + OpType m_op_type; + Node *m_left; + Node *m_right; +}; + +/// A node representing the canonical frame address. +class InitialValueNode: public Node { +public: + InitialValueNode() : Node(InitialValue) {} + + static bool classof(const Node *node) { + return node->GetKind() == InitialValue; + } +}; + +/// A node representing an integer literal. +class IntegerNode : public Node { +public: + IntegerNode(int64_t value) : Node(Integer), m_value(value) {} + + int64_t GetValue() const { return m_value; } + + static bool classof(const Node *node) { return node->GetKind() == Integer; } + +private: + int64_t m_value; +}; + +/// A node representing the value of a register with the given register number. +/// The register kind (RegisterKind enum) used for the specifying the register +/// number is implicit and assumed to be the same for all Register nodes in a +/// given tree. +class RegisterNode : public Node { +public: + RegisterNode(uint32_t reg_num) : Node(Register), m_reg_num(reg_num) {} + + uint32_t GetRegNum() const { return m_reg_num; } + + static bool classof(const Node *node) { return node->GetKind() == Register; } + +private: + uint32_t m_reg_num; +}; + +/// A node representing a symbolic reference to a named entity. This may be a +/// register, which hasn't yet been resolved to a RegisterNode. +class SymbolNode : public Node { +public: + SymbolNode(llvm::StringRef name) : Node(Symbol), m_name(name) {} + + llvm::StringRef GetName() const { return m_name; } + + static bool classof(const Node *node) { return node->GetKind() == Symbol; } + +private: + llvm::StringRef m_name; +}; + +/// A node representing a unary operation. +class UnaryOpNode : public Node { +public: + enum OpType { + Deref, // *a + }; + + UnaryOpNode(OpType op_type, Node &operand) + : Node(UnaryOp), m_op_type(op_type), m_operand(&operand) {} + + OpType GetOpType() const { return m_op_type; } + + const Node *Operand() const { return m_operand; } + Node *&Operand() { return m_operand; } + + static bool classof(const Node *node) { return node->GetKind() == UnaryOp; } + +private: + OpType m_op_type; + Node *m_operand; +}; + +/// A template class implementing a visitor pattern, but with a couple of +/// twists: +/// - It uses type switch instead of virtual double dispatch. This allows the +// node classes to be vtable-free and trivially destructible. +/// - The Visit functions get an extra Node *& parameter, which refers to the +/// child pointer of the parent of the node we are currently visiting. This +/// allows mutating algorithms, which replace the currently visited node with +/// a different one. +/// - The class is templatized on the return type of the Visit functions, which +/// means it's possible to return values from them. +template <typename ResultT = void> class Visitor { +protected: + virtual ~Visitor() = default; + + virtual ResultT Visit(BinaryOpNode &binary, Node *&ref) = 0; + virtual ResultT Visit(InitialValueNode &val, Node *&ref) = 0; + virtual ResultT Visit(IntegerNode &integer, Node *&) = 0; + virtual ResultT Visit(RegisterNode ®, Node *&) = 0; + virtual ResultT Visit(SymbolNode &symbol, Node *&ref) = 0; + virtual ResultT Visit(UnaryOpNode &unary, Node *&ref) = 0; + + /// Invoke the correct Visit function based on the dynamic type of the given + /// node. + ResultT Dispatch(Node *&node) { + switch (node->GetKind()) { + case Node::BinaryOp: + return Visit(llvm::cast<BinaryOpNode>(*node), node); + case Node::InitialValue: + return Visit(llvm::cast<InitialValueNode>(*node), node); + case Node::Integer: + return Visit(llvm::cast<IntegerNode>(*node), node); + case Node::Register: + return Visit(llvm::cast<RegisterNode>(*node), node); + case Node::Symbol: + return Visit(llvm::cast<SymbolNode>(*node), node); + case Node::UnaryOp: + return Visit(llvm::cast<UnaryOpNode>(*node), node); + } + llvm_unreachable("Fully covered switch!"); + } +}; + +/// A utility function for "resolving" SymbolNodes. It traverses a tree and +/// calls the callback function for all SymbolNodes it encountered. The +/// replacement function should return the node it wished to replace the current +/// SymbolNode with (this can also be the original node), or nullptr in case of +/// an error. The nodes returned by the callback are inspected and replaced +/// recursively, *except* for the case when the function returns the exact same +/// node as the input one. It returns true if all SymbolNodes were replaced +/// successfully. +bool ResolveSymbols(Node *&node, + llvm::function_ref<Node *(SymbolNode &symbol)> replacer); + +template <typename T, typename... Args> +inline T *MakeNode(llvm::BumpPtrAllocator &alloc, Args &&... args) { + static_assert(std::is_trivially_destructible<T>::value, + "This object will not be destroyed!"); + return new (alloc.Allocate<T>()) T(std::forward<Args>(args)...); +} + +/// Parse the given postfix expression. The parsed nodes are placed into the +/// provided allocator. +Node *Parse(llvm::StringRef expr, llvm::BumpPtrAllocator &alloc); + +/// Serialize the given expression tree as DWARF. The result is written into the +/// given stream. The AST should not contain any SymbolNodes. If the expression +/// contains InitialValueNodes, the generated expression will assume that their +/// value will be provided as the top value of the initial evaluation stack (as +/// is the case with the CFA value in register eh_unwind rules). +void ToDWARF(Node &node, Stream &stream); + +} // namespace postfix +} // namespace lldb_private + +#endif // LLDB_SYMBOL_POSTFIXEXPRESSION_H diff --git a/include/lldb/Symbol/SourceModule.h b/include/lldb/Symbol/SourceModule.h new file mode 100644 index 0000000000000..b12ff01a5198d --- /dev/null +++ b/include/lldb/Symbol/SourceModule.h @@ -0,0 +1,27 @@ +//===-- SourceModule.h ------------------------------------------*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef liblldb_SourceModule_h_ +#define liblldb_SourceModule_h_ + +#include "lldb/Utility/ConstString.h" +#include <vector> + +namespace lldb_private { + +/// Information needed to import a source-language module. +struct SourceModule { + /// Something like "Module.Submodule". + std::vector<ConstString> path; + ConstString search_path; + ConstString sysroot; +}; + +} // namespace lldb_private + +#endif diff --git a/include/lldb/Symbol/Symbol.h b/include/lldb/Symbol/Symbol.h index 9523158e0780d..1cbc2f5492f4e 100644 --- a/include/lldb/Symbol/Symbol.h +++ b/include/lldb/Symbol/Symbol.h @@ -1,9 +1,8 @@ //===-- Symbol.h ------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -43,41 +42,33 @@ public: void Clear(); - bool Compare(const ConstString &name, lldb::SymbolType type) const; + bool Compare(ConstString name, lldb::SymbolType type) const; void Dump(Stream *s, Target *target, uint32_t index) const; 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. - //------------------------------------------------------------------ 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. - //------------------------------------------------------------------ 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. - //------------------------------------------------------------------ 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(). - //------------------------------------------------------------------ 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 @@ -134,7 +125,7 @@ public: FileSpec GetReExportedSymbolSharedLibrary() const; - void SetReExportedSymbolName(const ConstString &name); + void SetReExportedSymbolName(ConstString name); bool SetReExportedSymbolSharedLibrary(const FileSpec &fspec); @@ -174,6 +165,10 @@ public: bool IsTrampoline() const; bool IsIndirect() const; + + bool IsWeak() const { return m_is_weak; } + + void SetIsWeak (bool b) { m_is_weak = b; } bool GetByteSizeIsValid() const { return m_size_is_valid; } @@ -204,22 +199,18 @@ public: void SetContainsLinkerAnnotations(bool b) { m_contains_linker_annotations = b; } - //------------------------------------------------------------------ - /// @copydoc SymbolContextScope::CalculateSymbolContext(SymbolContext*) + /// \copydoc SymbolContextScope::CalculateSymbolContext(SymbolContext*) /// - /// @see SymbolContextScope - //------------------------------------------------------------------ + /// \see SymbolContextScope void CalculateSymbolContext(SymbolContext *sc) override; lldb::ModuleSP CalculateSymbolContextModule() override; Symbol *CalculateSymbolContextSymbol() override; - //------------------------------------------------------------------ - /// @copydoc SymbolContextScope::DumpSymbolContext(Stream*) + /// \copydoc SymbolContextScope::DumpSymbolContext(Stream*) /// - /// @see SymbolContextScope - //------------------------------------------------------------------ + /// \see SymbolContextScope void DumpSymbolContext(Stream *s) override; lldb::DisassemblerSP GetInstructions(const ExecutionContext &exe_ctx, @@ -263,7 +254,8 @@ protected: m_contains_linker_annotations : 1, // The symbol name contains linker // annotations, which are optional when // doing name lookups - m_type : 7; + m_is_weak : 1, + m_type : 6; // Values from the lldb::SymbolType enum. Mangled m_mangled; // uniqued symbol name/mangled name pair AddressRange m_addr_range; // Contains the value, or the section offset // address when the value is an address in a diff --git a/include/lldb/Symbol/SymbolContext.h b/include/lldb/Symbol/SymbolContext.h index a7afffb705d2b..55a3454893581 100644 --- a/include/lldb/Symbol/SymbolContext.h +++ b/include/lldb/Symbol/SymbolContext.h @@ -1,9 +1,8 @@ //===-- SymbolContext.h -----------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -24,59 +23,51 @@ namespace lldb_private { class SymbolContextScope; -//---------------------------------------------------------------------- -/// @class SymbolContext SymbolContext.h "lldb/Symbol/SymbolContext.h" Defines +/// \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 -/// @li Looking up a load address. -//---------------------------------------------------------------------- +/// \li Looking up a load address. class SymbolContext { public: - //------------------------------------------------------------------ /// Default constructor. /// /// 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. /// - /// @param[in] sc_scope + /// \param[in] sc_scope /// A symbol context scope object that knows how to reconstruct /// it's context. - //------------------------------------------------------------------ explicit SymbolContext(SymbolContextScope *sc_scope); - //------------------------------------------------------------------ /// Construct with module, and optional compile unit, function, block, line /// table, line entry and symbol. /// /// Initialize all pointer to the specified values. /// - /// @param[in] module + /// \param[in] module /// A Module pointer to the module for this context. /// - /// @param[in] comp_unit + /// \param[in] comp_unit /// A CompileUnit pointer to the compile unit for this context. /// - /// @param[in] function + /// \param[in] function /// A Function pointer to the function for this context. /// - /// @param[in] block + /// \param[in] block /// A Block pointer to the deepest block for this context. /// - /// @param[in] line_entry + /// \param[in] line_entry /// A LineEntry pointer to the line entry for this context. /// - /// @param[in] symbol + /// \param[in] symbol /// A Symbol pointer to the symbol for this context. - //------------------------------------------------------------------ explicit SymbolContext(const lldb::TargetSP &target_sp, const lldb::ModuleSP &module_sp, CompileUnit *comp_unit = nullptr, @@ -91,52 +82,35 @@ public: LineEntry *line_entry = nullptr, Symbol *symbol = nullptr); - //------------------------------------------------------------------ - /// Copy constructor - /// - /// Makes a copy of the another SymbolContext object \a rhs. - /// - /// @param[in] rhs - /// A const SymbolContext object reference to copy. - //------------------------------------------------------------------ - SymbolContext(const SymbolContext &rhs); - ~SymbolContext(); - //------------------------------------------------------------------ /// Assignment operator. /// /// Copies the address value from another SymbolContext object \a rhs into /// \a this object. /// - /// @param[in] rhs + /// \param[in] rhs /// A const SymbolContext object reference to copy. /// - /// @return + /// \return /// A const SymbolContext object reference to \a this. - //------------------------------------------------------------------ const SymbolContext &operator=(const SymbolContext &rhs); - //------------------------------------------------------------------ /// Clear the object's 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. /// - /// @param[in] s + /// \param[in] s /// The stream to which to dump the object description. - //------------------------------------------------------------------ void Dump(Stream *s, Target *target) const; - //------------------------------------------------------------------ /// Dump the stop context in this object to a Stream. /// /// Dump the best description of this object to the stream. The information @@ -146,45 +120,43 @@ public: /// is available, that will be output. Else just the address at which the /// target was stopped will be displayed. /// - /// @param[in] s + /// \param[in] s /// The stream to which to dump the object description. /// - /// @param[in] so_addr + /// \param[in] so_addr /// The resolved section offset address. /// - /// @param[in] show_fullpaths + /// \param[in] show_fullpaths /// When printing file paths (with the Module), whether the /// base name of the Module should be printed or the full path. /// - /// @param[in] show_module + /// \param[in] show_module /// Whether the module name should be printed followed by a /// grave accent "`" character. /// - /// @param[in] show_inlined_frames + /// \param[in] show_inlined_frames /// If a given pc is in inlined function(s), whether the inlined /// functions should be printed on separate lines in addition to /// the concrete function containing the pc. /// - /// @param[in] show_function_arguments + /// \param[in] show_function_arguments /// If false, this method will try to elide the function argument /// types when printing the function name. This may be ambiguous /// for languages that have function overloading - but it may /// make the "function name" too long to include all the argument /// types. /// - /// @param[in] show_function_name + /// \param[in] show_function_name /// Normally this should be true - the function/symbol name should /// be printed. In disassembly formatting, where we want a format /// like "<*+36>", this should be false and "*" will be printed /// instead. - //------------------------------------------------------------------ bool DumpStopContext(Stream *s, ExecutionContextScope *exe_scope, const Address &so_addr, bool show_fullpaths, bool show_module, bool show_inlined_frames, bool show_function_arguments, bool show_function_name) const; - //------------------------------------------------------------------ /// Get the address range contained within a symbol context. /// /// Address range priority is as follows: @@ -197,17 +169,17 @@ public: /// - symbol address range if symbol is not nullptr and /// eSymbolContextSymbol is set in \a scope /// - /// @param[in] scope + /// \param[in] scope /// A mask of symbol context bits telling this function which /// address ranges it can use when trying to extract one from /// the valid (non-nullptr) symbol context classes. /// - /// @param[in] range_idx + /// \param[in] range_idx /// The address range index to grab. Since many functions and /// blocks are not always contiguous, they may have more than /// one address range. /// - /// @param[in] use_inline_block_range + /// \param[in] use_inline_block_range /// If \a scope has the eSymbolContextBlock bit set, and there /// is a valid block in the symbol context, return the block /// address range for the containing inline function block, not @@ -215,21 +187,19 @@ public: /// for the address range of the inlined function block, not /// the deepest lexical block. /// - /// @param[out] range + /// \param[out] range /// An address range object that will be filled in if \b true /// is returned. /// - /// @return + /// \return /// \b True if this symbol context contains items that describe /// an address range, \b false otherwise. - //------------------------------------------------------------------ bool GetAddressRange(uint32_t scope, uint32_t range_idx, bool use_inline_block_range, AddressRange &range) const; bool GetAddressRangeFromHereToEndLine(uint32_t end_line, AddressRange &range, Status &error); - //------------------------------------------------------------------ /// Find the best global data symbol visible from this context. /// /// Symbol priority is: @@ -239,18 +209,17 @@ public: /// - non-extern symbol in the target /// It is an error if the highest-priority result is ambiguous. /// - /// @param[in] name + /// \param[in] name /// The name of the symbol to search for. /// - /// @param[out] error + /// \param[out] error /// An error that will be populated with a message if there was an /// ambiguous result. The error will not be populated if no result /// was found. /// - /// @return + /// \return /// The symbol that was found, or \b nullptr if none was found. - //------------------------------------------------------------------ - const Symbol *FindBestGlobalDataSymbol(const ConstString &name, Status &error); + const Symbol *FindBestGlobalDataSymbol(ConstString name, Status &error); void GetDescription(Stream *s, lldb::DescriptionLevel level, Target *target) const; @@ -259,7 +228,6 @@ public: lldb::LanguageType GetLanguage() const; - //------------------------------------------------------------------ /// Find a block that defines the function represented by this symbol /// context. /// @@ -276,59 +244,51 @@ public: /// represented by this symbol context (whether the function is an inline /// function or not). /// - /// @return + /// \return /// The block object pointer that defines the function that is /// represented by this symbol context object, nullptr otherwise. - //------------------------------------------------------------------ Block *GetFunctionBlock(); - //------------------------------------------------------------------ /// If this symbol context represents a function that is a method, return /// true and provide information about the method. /// - /// @param[out] language + /// \param[out] language /// If \b true is returned, the language for the method. /// - /// @param[out] is_instance_method + /// \param[out] is_instance_method /// If \b true is returned, \b true if this is a instance method, /// \b false if this is a static/class function. /// - /// @param[out] language_object_name + /// \param[out] language_object_name /// If \b true is returned, the name of the artificial variable /// for the language ("this" for C++, "self" for ObjC). /// - /// @return + /// \return /// \b True if this symbol context represents a function that /// is a method of a class, \b false otherwise. - //------------------------------------------------------------------ bool GetFunctionMethodInfo(lldb::LanguageType &language, bool &is_instance_method, ConstString &language_object_name); - //------------------------------------------------------------------ /// Sorts the types in TypeMap according to SymbolContext to TypeList /// - //------------------------------------------------------------------ void SortTypeList(TypeMap &type_map, TypeList &type_list) const; - //------------------------------------------------------------------ /// 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. /// - /// @param[in] prefer_mangled + /// \param[in] prefer_mangled /// if \btrue, then the mangled name will be returned if there /// is one. Otherwise the unmangled name will be returned if it /// is available. /// - /// @return + /// \return /// The name of the function represented by this symbol context. - //------------------------------------------------------------------ ConstString GetFunctionName( Mangled::NamePreference preference = Mangled::ePreferDemangled) const; - //------------------------------------------------------------------ /// Get the line entry that corresponds to the function. /// /// If the symbol context contains an inlined block, the line entry for the @@ -339,43 +299,38 @@ public: /// table information for the symbol context. it will return the inlined /// function name. /// - /// @param[in] prefer_mangled + /// \param[in] prefer_mangled /// if \btrue, then the mangled name will be returned if there /// is one. Otherwise the unmangled name will be returned if it /// is available. /// - /// @return + /// \return /// The name of the function represented by this symbol context. - //------------------------------------------------------------------ LineEntry GetFunctionStartLineEntry() const; - //------------------------------------------------------------------ /// 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. /// - /// @param[in] curr_frame_pc + /// \param[in] curr_frame_pc /// The address within the block of this object. /// - /// @param[out] next_frame_sc + /// \param[out] next_frame_sc /// A new symbol context that does what the title says it does. /// - /// @param[out] next_frame_addr + /// \param[out] next_frame_addr /// This is what you should report as the PC in \a next_frame_sc. /// - /// @return + /// \return /// \b true if this SymbolContext specifies a block contained in an /// inlined block. If this returns \b true, \a next_frame_sc and /// \a next_frame_addr will be filled in correctly. - //------------------------------------------------------------------ bool GetParentOfInlinedScope(const Address &curr_frame_pc, SymbolContext &next_frame_sc, Address &inlined_frame_addr) const; - //------------------------------------------------------------------ // Member variables - //------------------------------------------------------------------ lldb::TargetSP target_sp; ///< The Target for a given query lldb::ModuleSP module_sp; ///< The Module for a given query CompileUnit *comp_unit; ///< The CompileUnit for a given query @@ -388,7 +343,7 @@ public: class SymbolContextSpecifier { public: - typedef enum SpecificationType { + enum SpecificationType { eNothingSpecified = 0, eModuleSpecified = 1 << 0, eFileSpecified = 1 << 1, @@ -397,7 +352,7 @@ public: eFunctionSpecified = 1 << 4, eClassOrNamespaceSpecified = 1 << 5, eAddressRangeSpecified = 1 << 6 - } SpecificationType; + }; // This one produces a specifier that matches everything... SymbolContextSpecifier(const lldb::TargetSP &target_sp); @@ -420,45 +375,37 @@ private: lldb::TargetSP m_target_sp; std::string m_module_spec; lldb::ModuleSP m_module_sp; - std::unique_ptr<FileSpec> m_file_spec_ap; + std::unique_ptr<FileSpec> m_file_spec_up; size_t m_start_line; size_t m_end_line; std::string m_function_spec; std::string m_class_name; - std::unique_ptr<AddressRange> m_address_range_ap; + std::unique_ptr<AddressRange> m_address_range_up; uint32_t m_type; // Or'ed bits from SpecificationType }; -//---------------------------------------------------------------------- -/// @class SymbolContextList SymbolContext.h "lldb/Symbol/SymbolContext.h" +/// \class SymbolContextList SymbolContext.h "lldb/Symbol/SymbolContext.h" /// 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: -/// @li Looking up a function by name. -/// @li Finding all addresses for a specified file and line number. -//---------------------------------------------------------------------- +/// \li Looking up a function by name. +/// \li Finding all addresses for a specified file and line number. class SymbolContextList { public: - //------------------------------------------------------------------ /// Default constructor. /// /// Initialize with an empty list. - //------------------------------------------------------------------ SymbolContextList(); - //------------------------------------------------------------------ /// Destructor. - //------------------------------------------------------------------ ~SymbolContextList(); - //------------------------------------------------------------------ /// Append a new symbol context to the list. /// - /// @param[in] sc + /// \param[in] sc /// A symbol context to append to the list. - //------------------------------------------------------------------ void Append(const SymbolContext &sc); void Append(const SymbolContextList &sc_list); @@ -468,55 +415,47 @@ public: uint32_t AppendIfUnique(const SymbolContextList &sc_list, bool merge_symbol_into_function); - //------------------------------------------------------------------ /// Clear the object's state. /// /// Clears the symbol context list. - //------------------------------------------------------------------ void Clear(); - //------------------------------------------------------------------ /// 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. /// - /// @param[in] s + /// \param[in] s /// The stream to which to dump the object description. - //------------------------------------------------------------------ void Dump(Stream *s, Target *target) const; - //------------------------------------------------------------------ /// 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. /// - /// @param[in] idx + /// \param[in] idx /// The zero based index into the symbol context list. /// - /// @param[out] sc + /// \param[out] sc /// A reference to the symbol context to fill in. /// - /// @return + /// \return /// Returns \b true if \a idx was a valid index into this /// symbol context list and \a sc was filled in, \b false /// otherwise. - //------------------------------------------------------------------ bool GetContextAtIndex(size_t idx, SymbolContext &sc) const; - //------------------------------------------------------------------ /// 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. /// - /// @param[in] idx + /// \param[in] idx /// The zero based index into the symbol context list. /// - /// @return + /// \return /// A const reference to the symbol context to fill in. - //------------------------------------------------------------------ SymbolContext &operator[](size_t idx) { return m_symbol_contexts[idx]; } const SymbolContext &operator[](size_t idx) const { @@ -525,12 +464,10 @@ public: bool RemoveContextAtIndex(size_t idx); - //------------------------------------------------------------------ /// Get accessor for a symbol context list size. /// - /// @return + /// \return /// Returns the number of symbol context objects in the list. - //------------------------------------------------------------------ uint32_t GetSize() const; uint32_t NumLineEntriesWithLine(uint32_t line) const; @@ -542,9 +479,7 @@ protected: typedef std::vector<SymbolContext> collection; ///< The collection type for the list. - //------------------------------------------------------------------ // Member variables. - //------------------------------------------------------------------ collection m_symbol_contexts; ///< The list of symbol contexts. public: diff --git a/include/lldb/Symbol/SymbolContextScope.h b/include/lldb/Symbol/SymbolContextScope.h index 85718b9bba4f1..a626302053df1 100644 --- a/include/lldb/Symbol/SymbolContextScope.h +++ b/include/lldb/Symbol/SymbolContextScope.h @@ -1,9 +1,8 @@ //===-- SymbolContextScope.h ------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -14,8 +13,7 @@ namespace lldb_private { -//---------------------------------------------------------------------- -/// @class SymbolContextScope SymbolContextScope.h +/// \class SymbolContextScope SymbolContextScope.h /// "lldb/Symbol/SymbolContextScope.h" Inherit from this if your object is /// part of a symbol context /// and can reconstruct its symbol context. @@ -27,11 +25,11 @@ namespace lldb_private { /// complete SymbolContext object in the object. /// /// Examples of these objects include: -/// @li Module -/// @li CompileUnit -/// @li Function -/// @li Block -/// @li Symbol +/// \li Module +/// \li CompileUnit +/// \li Function +/// \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 @@ -41,7 +39,7 @@ namespace lldb_private { /// /// Example objects include that currently use "SymbolContextScope *" objects /// include: -/// @li Variable objects that can reconstruct where they are scoped +/// \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, /// the appropriate CompileUnit * will be used when creating the @@ -49,9 +47,9 @@ namespace lldb_private { /// in which the variable is defined. Function arguments can use /// the Function object as their scope. The SymbolFile parsers /// will set these correctly as the variables are parsed. -/// @li Type objects that know exactly in which scope they +/// \li Type objects that know exactly in which scope they /// originated much like the variables above. -/// @li StackID objects that are able to know that if the CFA +/// \li StackID objects that are able to know that if the CFA /// (stack pointer at the beginning of a function) and the /// start PC for the function/symbol and the SymbolContextScope /// pointer (a unique pointer that identifies a symbol context @@ -63,21 +61,18 @@ namespace lldb_private { /// 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: virtual ~SymbolContextScope() = default; - //------------------------------------------------------------------ /// 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. /// - /// @param[out] sc + /// \param[out] sc /// A symbol context object pointer that gets filled in. - //------------------------------------------------------------------ virtual void CalculateSymbolContext(SymbolContext *sc) = 0; virtual lldb::ModuleSP CalculateSymbolContextModule() { @@ -92,16 +87,14 @@ public: virtual Symbol *CalculateSymbolContextSymbol() { return nullptr; } - //------------------------------------------------------------------ /// 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. /// - /// @param[in] s + /// \param[in] s /// The stream to which to dump the object's symbol context. - //------------------------------------------------------------------ virtual void DumpSymbolContext(Stream *s) = 0; }; diff --git a/include/lldb/Symbol/SymbolFile.h b/include/lldb/Symbol/SymbolFile.h index 433c20da99e2e..dbb723e9d3693 100644 --- a/include/lldb/Symbol/SymbolFile.h +++ b/include/lldb/Symbol/SymbolFile.h @@ -1,9 +1,8 @@ //===-- SymbolFile.h --------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -15,6 +14,7 @@ #include "lldb/Symbol/CompilerDeclContext.h" #include "lldb/Symbol/CompilerType.h" #include "lldb/Symbol/Function.h" +#include "lldb/Symbol/SourceModule.h" #include "lldb/Symbol/Type.h" #include "lldb/lldb-private.h" @@ -32,14 +32,12 @@ namespace lldb_private { class SymbolFile : public PluginInterface { 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. - //------------------------------------------------------------------ enum Abilities { CompileUnits = (1u << 0), LineTables = (1u << 1), @@ -53,15 +51,12 @@ public: static SymbolFile *FindPlugin(ObjectFile *obj_file); - //------------------------------------------------------------------ // Constructors and Destructors - //------------------------------------------------------------------ SymbolFile(ObjectFile *obj_file) : m_obj_file(obj_file), m_abilities(0), m_calculated_abilities(false) {} ~SymbolFile() override {} - //------------------------------------------------------------------ /// Get a mask of what this symbol file supports for the object file /// that it was constructed with. /// @@ -85,11 +80,10 @@ public: /// for "void SymbolFile::InitializeObject()" which will get called /// on the SymbolFile object with the best set of abilities. /// - /// @return + /// \return /// A uint32_t mask containing bits from the SymbolFile::Abilities /// enumeration. Any bits that are set represent an ability that /// this symbol plug-in can parse from the object file. - ///------------------------------------------------------------------ uint32_t GetAbilities() { if (!m_calculated_abilities) { m_abilities = CalculateAbilities(); @@ -101,13 +95,10 @@ public: virtual uint32_t CalculateAbilities() = 0; - //------------------------------------------------------------------ /// Symbols file subclasses should override this to return the Module that /// owns the TypeSystem that this symbol file modifies type information in. - //------------------------------------------------------------------ virtual std::recursive_mutex &GetModuleMutex() const; - //------------------------------------------------------------------ /// Initialize the SymbolFile object. /// /// The SymbolFile object with the best set of abilities (detected @@ -115,12 +106,9 @@ public: /// called if it is chosen to parse an object file. More complete /// initialization can happen in this function which will get called /// prior to any other functions in the SymbolFile protocol. - //------------------------------------------------------------------ virtual void InitializeObject() {} - //------------------------------------------------------------------ // Compile Unit function calls - //------------------------------------------------------------------ // Approach 1 - iterator virtual uint32_t GetNumCompileUnits() = 0; virtual lldb::CompUnitSP ParseCompileUnitAtIndex(uint32_t index) = 0; @@ -136,7 +124,7 @@ public: virtual bool ParseImportedModules(const SymbolContext &sc, - std::vector<ConstString> &imported_modules) = 0; + std::vector<SourceModule> &imported_modules) = 0; virtual size_t ParseBlocksRecursive(Function &func) = 0; virtual size_t ParseVariablesForContext(const SymbolContext &sc) = 0; virtual Type *ResolveTypeUID(lldb::user_id_t type_uid) = 0; @@ -144,10 +132,10 @@ public: /// The characteristics of an array type. struct ArrayInfo { - int64_t first_index; + int64_t first_index = 0; llvm::SmallVector<uint64_t, 1> element_orders; - uint32_t byte_stride; - uint32_t bit_stride; + uint32_t byte_stride = 0; + uint32_t bit_stride = 0; }; /// If \c type_uid points to an array type, return its characteristics. /// To support variable-length array types, this function takes an @@ -178,13 +166,13 @@ public: virtual void DumpClangAST(Stream &s) {} virtual uint32_t - FindGlobalVariables(const ConstString &name, + FindGlobalVariables(ConstString name, const CompilerDeclContext *parent_decl_ctx, uint32_t max_matches, VariableList &variables); virtual uint32_t FindGlobalVariables(const RegularExpression ®ex, uint32_t max_matches, VariableList &variables); - virtual uint32_t FindFunctions(const ConstString &name, + virtual uint32_t FindFunctions(ConstString name, const CompilerDeclContext *parent_decl_ctx, lldb::FunctionNameType name_type_mask, bool include_inlines, bool append, @@ -193,7 +181,7 @@ public: bool include_inlines, bool append, SymbolContextList &sc_list); virtual uint32_t - FindTypes(const ConstString &name, const CompilerDeclContext *parent_decl_ctx, + FindTypes(ConstString name, const CompilerDeclContext *parent_decl_ctx, bool append, uint32_t max_matches, llvm::DenseSet<lldb_private::SymbolFile *> &searched_symbol_files, TypeMap &types); @@ -217,7 +205,7 @@ public: GetTypeSystemForLanguage(lldb::LanguageType language); virtual CompilerDeclContext - FindNamespace(const ConstString &name, + FindNamespace(ConstString name, const CompilerDeclContext *parent_decl_ctx) { return CompilerDeclContext(); } @@ -231,12 +219,22 @@ public: virtual void AddSymbols(Symtab &symtab) {} - //------------------------------------------------------------------ /// Notify the SymbolFile that the file addresses in the Sections /// for this module have been changed. - //------------------------------------------------------------------ virtual void SectionFileAddressesChanged() {} + struct RegisterInfoResolver { + virtual ~RegisterInfoResolver(); // anchor + + virtual const RegisterInfo *ResolveName(llvm::StringRef name) const = 0; + virtual const RegisterInfo *ResolveNumber(lldb::RegisterKind kind, + uint32_t number) const = 0; + }; + virtual lldb::UnwindPlanSP + GetUnwindPlan(const Address &address, const RegisterInfoResolver &resolver) { + return nullptr; + } + virtual void Dump(Stream &s) {} protected: diff --git a/include/lldb/Symbol/SymbolVendor.h b/include/lldb/Symbol/SymbolVendor.h index d48f646d52cd5..c4015ff034927 100644 --- a/include/lldb/Symbol/SymbolVendor.h +++ b/include/lldb/Symbol/SymbolVendor.h @@ -1,9 +1,8 @@ //===-- SymbolVendor.h ------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -14,6 +13,7 @@ #include "lldb/Core/ModuleChild.h" #include "lldb/Core/PluginInterface.h" +#include "lldb/Symbol/SourceModule.h" #include "lldb/Symbol/TypeList.h" #include "lldb/Symbol/TypeMap.h" #include "lldb/lldb-private.h" @@ -21,7 +21,6 @@ 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 @@ -29,15 +28,12 @@ namespace lldb_private { // 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: static SymbolVendor *FindPlugin(const lldb::ModuleSP &module_sp, Stream *feedback_strm); - //------------------------------------------------------------------ // Constructors and Destructors - //------------------------------------------------------------------ SymbolVendor(const lldb::ModuleSP &module_sp); ~SymbolVendor() override; @@ -61,8 +57,9 @@ public: virtual size_t ParseTypes(CompileUnit &comp_unit); - virtual bool ParseImportedModules(const SymbolContext &sc, - std::vector<ConstString> &imported_modules); + virtual bool + ParseImportedModules(const SymbolContext &sc, + std::vector<SourceModule> &imported_modules); virtual size_t ParseBlocksRecursive(Function &func); @@ -79,7 +76,7 @@ public: lldb::SymbolContextItem resolve_scope, SymbolContextList &sc_list); - virtual size_t FindGlobalVariables(const ConstString &name, + virtual size_t FindGlobalVariables(ConstString name, const CompilerDeclContext *parent_decl_ctx, size_t max_matches, VariableList &variables); @@ -88,7 +85,7 @@ public: size_t max_matches, VariableList &variables); - virtual size_t FindFunctions(const ConstString &name, + virtual size_t FindFunctions(ConstString name, const CompilerDeclContext *parent_decl_ctx, lldb::FunctionNameType name_type_mask, bool include_inlines, bool append, @@ -99,7 +96,7 @@ public: SymbolContextList &sc_list); virtual size_t - FindTypes(const ConstString &name, const CompilerDeclContext *parent_decl_ctx, + FindTypes(ConstString name, const CompilerDeclContext *parent_decl_ctx, bool append, size_t max_matches, llvm::DenseSet<lldb_private::SymbolFile *> &searched_symbol_files, TypeMap &types); @@ -108,7 +105,7 @@ public: bool append, TypeMap &types); virtual CompilerDeclContext - FindNamespace(const ConstString &name, + FindNamespace(ConstString name, const CompilerDeclContext *parent_decl_ctx); virtual size_t GetNumCompileUnits(); @@ -125,7 +122,7 @@ public: virtual size_t GetTypes(SymbolContextScope *sc_scope, lldb::TypeClass type_mask, TypeList &type_list); - SymbolFile *GetSymbolFile() { return m_sym_file_ap.get(); } + SymbolFile *GetSymbolFile() { return m_sym_file_up.get(); } FileSpec GetMainFileSpec() const; @@ -135,23 +132,17 @@ public: // Clear module unified section list symbol table. virtual void ClearSymtab(); - //------------------------------------------------------------------ /// Notify the SymbolVendor that the file addresses in the Sections /// for this module have been changed. - //------------------------------------------------------------------ virtual void SectionFileAddressesChanged(); - //------------------------------------------------------------------ // PluginInterface protocol - //------------------------------------------------------------------ ConstString GetPluginName() override; uint32_t GetPluginVersion() override; protected: - //------------------------------------------------------------------ // Classes that inherit from SymbolVendor can see and modify these - //------------------------------------------------------------------ typedef std::vector<lldb::CompUnitSP> CompileUnits; typedef CompileUnits::iterator CompileUnitIter; typedef CompileUnits::const_iterator CompileUnitConstIter; @@ -162,15 +153,13 @@ protected: // case it isn't the same as the module // object file (debug symbols in a separate // file) - std::unique_ptr<SymbolFile> m_sym_file_ap; // A single symbol file. Subclasses + std::unique_ptr<SymbolFile> m_sym_file_up; // A single symbol file. Subclasses // can add more of these if needed. Symtab *m_symtab; // Save a symtab once to not pass it through `AddSymbols` of // the symbol file each time when it is needed private: - //------------------------------------------------------------------ // For SymbolVendor only - //------------------------------------------------------------------ DISALLOW_COPY_AND_ASSIGN(SymbolVendor); }; diff --git a/include/lldb/Symbol/Symtab.h b/include/lldb/Symbol/Symtab.h index 286e4f48c2e8c..868edcdc9290e 100644 --- a/include/lldb/Symbol/Symtab.h +++ b/include/lldb/Symbol/Symtab.h @@ -1,22 +1,20 @@ //===-- Symtab.h ------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// #ifndef liblldb_Symtab_h_ #define liblldb_Symtab_h_ -#include <mutex> -#include <vector> - -#include "lldb/Core/RangeMap.h" #include "lldb/Core/UniqueCStringMap.h" #include "lldb/Symbol/Symbol.h" +#include "lldb/Utility/RangeMap.h" #include "lldb/lldb-private.h" +#include <mutex> +#include <vector> namespace lldb_private { @@ -25,17 +23,13 @@ public: typedef std::vector<uint32_t> IndexCollection; typedef UniqueCStringMap<uint32_t> NameToIndexMap; - typedef enum Debug { + enum Debug { eDebugNo, // Not a debug symbol eDebugYes, // A debug symbol eDebugAny - } Debug; + }; - typedef enum Visibility { - eVisibilityAny, - eVisibilityExtern, - eVisibilityPrivate - } Visibility; + enum Visibility { eVisibilityAny, eVisibilityExtern, eVisibilityPrivate }; Symtab(ObjectFile *objfile); ~Symtab(); @@ -56,13 +50,11 @@ public: Symbol *FindSymbolWithType(lldb::SymbolType symbol_type, Debug symbol_debug_type, Visibility symbol_visibility, uint32_t &start_idx); - //---------------------------------------------------------------------- /// Get the parent symbol for the given symbol. /// /// Many symbols in symbol tables are scoped by other symbols that /// contain one or more symbol. This function will look for such a /// containing symbol and return it if there is one. - //---------------------------------------------------------------------- const Symbol *GetParent(Symbol *symbol) const; uint32_t AppendSymbolIndexesWithType(lldb::SymbolType symbol_type, std::vector<uint32_t> &indexes, @@ -78,16 +70,16 @@ public: std::vector<uint32_t> &matches, uint32_t start_idx = 0, uint32_t end_index = UINT32_MAX) const; - uint32_t AppendSymbolIndexesWithName(const ConstString &symbol_name, + uint32_t AppendSymbolIndexesWithName(ConstString symbol_name, std::vector<uint32_t> &matches); - uint32_t AppendSymbolIndexesWithName(const ConstString &symbol_name, + uint32_t AppendSymbolIndexesWithName(ConstString symbol_name, Debug symbol_debug_type, Visibility symbol_visibility, std::vector<uint32_t> &matches); - uint32_t AppendSymbolIndexesWithNameAndType(const ConstString &symbol_name, + uint32_t AppendSymbolIndexesWithNameAndType(ConstString symbol_name, lldb::SymbolType symbol_type, std::vector<uint32_t> &matches); - uint32_t AppendSymbolIndexesWithNameAndType(const ConstString &symbol_name, + uint32_t AppendSymbolIndexesWithNameAndType(ConstString symbol_name, lldb::SymbolType symbol_type, Debug symbol_debug_type, Visibility symbol_visibility, @@ -100,10 +92,10 @@ public: const RegularExpression ®ex, lldb::SymbolType symbol_type, Debug symbol_debug_type, Visibility symbol_visibility, std::vector<uint32_t> &indexes); - size_t FindAllSymbolsWithNameAndType(const ConstString &name, + size_t FindAllSymbolsWithNameAndType(ConstString name, lldb::SymbolType symbol_type, std::vector<uint32_t> &symbol_indexes); - size_t FindAllSymbolsWithNameAndType(const ConstString &name, + size_t FindAllSymbolsWithNameAndType(ConstString name, lldb::SymbolType symbol_type, Debug symbol_debug_type, Visibility symbol_visibility, @@ -112,7 +104,7 @@ public: const RegularExpression ®ex, lldb::SymbolType symbol_type, Debug symbol_debug_type, Visibility symbol_visibility, std::vector<uint32_t> &symbol_indexes); - Symbol *FindFirstSymbolWithNameAndType(const ConstString &name, + Symbol *FindFirstSymbolWithNameAndType(ConstString name, lldb::SymbolType symbol_type, Debug symbol_debug_type, Visibility symbol_visibility); @@ -120,7 +112,7 @@ public: Symbol *FindSymbolContainingFileAddress(lldb::addr_t file_addr); void ForEachSymbolContainingFileAddress( lldb::addr_t file_addr, std::function<bool(Symbol *)> const &callback); - size_t FindFunctionSymbols(const ConstString &name, uint32_t name_type_mask, + size_t FindFunctionSymbols(ConstString name, uint32_t name_type_mask, SymbolContextList &sc_list); void CalculateSymbolSizes(); @@ -198,7 +190,7 @@ private: SymbolContextList &sc_list); void RegisterMangledNameEntry( - NameToIndexMap::Entry &entry, std::set<const char *> &class_contexts, + uint32_t value, std::set<const char *> &class_contexts, std::vector<std::pair<NameToIndexMap::Entry, const char *>> &backlog, RichManglingContext &rmc); diff --git a/include/lldb/Symbol/TaggedASTType.h b/include/lldb/Symbol/TaggedASTType.h index eabd41ebbf293..043a9138e07b0 100644 --- a/include/lldb/Symbol/TaggedASTType.h +++ b/include/lldb/Symbol/TaggedASTType.h @@ -1,9 +1,8 @@ //===-- TaggedASTType.h -----------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// diff --git a/include/lldb/Symbol/Type.h b/include/lldb/Symbol/Type.h index fec2578c9fec7..efc9bf049a35a 100644 --- a/include/lldb/Symbol/Type.h +++ b/include/lldb/Symbol/Type.h @@ -1,9 +1,8 @@ //===-- Type.h --------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -23,12 +22,10 @@ #include <set> namespace lldb_private { -//---------------------------------------------------------------------- // 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) + CompilerContext(CompilerContextKind t, ConstString n) : type(t), name(n) {} bool operator==(const CompilerContext &rhs) const { @@ -62,25 +59,25 @@ protected: class Type : public std::enable_shared_from_this<Type>, public UserID { public: - typedef enum EncodingDataTypeTag { + enum EncodingDataType { eEncodingInvalid, eEncodingIsUID, ///< This type is the type whose UID is m_encoding_uid eEncodingIsConstUID, ///< This type is the type whose UID is m_encoding_uid - ///with the const qualifier added + /// with the const qualifier added eEncodingIsRestrictUID, ///< This type is the type whose UID is - ///m_encoding_uid with the restrict qualifier added + /// m_encoding_uid with the restrict qualifier added eEncodingIsVolatileUID, ///< This type is the type whose UID is - ///m_encoding_uid with the volatile qualifier added + /// m_encoding_uid with the volatile qualifier added eEncodingIsTypedefUID, ///< This type is pointer to a type whose UID is - ///m_encoding_uid + /// m_encoding_uid eEncodingIsPointerUID, ///< This type is pointer to a type whose UID is - ///m_encoding_uid + /// m_encoding_uid eEncodingIsLValueReferenceUID, ///< This type is L value reference to a type - ///whose UID is m_encoding_uid + /// whose UID is m_encoding_uid eEncodingIsRValueReferenceUID, ///< This type is R value reference to a type - ///whose UID is m_encoding_uid + /// whose UID is m_encoding_uid 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 @@ -95,8 +92,8 @@ public: eResolveStateFull = 3 } ResolveState; - Type(lldb::user_id_t uid, SymbolFile *symbol_file, const ConstString &name, - uint64_t byte_size, SymbolContextScope *context, + Type(lldb::user_id_t uid, SymbolFile *symbol_file, ConstString name, + llvm::Optional<uint64_t> byte_size, SymbolContextScope *context, lldb::user_id_t encoding_uid, EncodingDataType encoding_uid_type, const Declaration &decl, const CompilerType &compiler_qual_type, ResolveState compiler_type_resolve_state); @@ -105,10 +102,6 @@ public: // they get an error. Type(); - Type(const Type &rhs); - - const Type &operator=(const Type &rhs); - void Dump(Stream *s, bool show_context); void DumpTypeName(Stream *s); @@ -126,9 +119,9 @@ public: TypeList *GetTypeList(); - const ConstString &GetName(); + ConstString GetName(); - uint64_t GetByteSize(); + llvm::Optional<uint64_t> GetByteSize(); uint32_t GetNumChildren(bool omit_empty_base_classes); @@ -140,7 +133,7 @@ public: lldb::TypeSP GetTypedefType(); - const ConstString &GetName() const { return m_name; } + ConstString GetName() const { return m_name; } ConstString GetQualifiedName(); @@ -218,7 +211,8 @@ protected: Type *m_encoding_type; lldb::user_id_t m_encoding_uid; EncodingDataType m_encoding_uid_type; - uint64_t m_byte_size; + uint64_t m_byte_size : 63; + uint64_t m_byte_size_has_value : 1; Declaration m_decl; CompilerType m_compiler_type; @@ -237,142 +231,15 @@ protected: bool ResolveClangType(ResolveState compiler_type_resolve_state); }; -// these classes are used to back the SBType* objects - -class TypePair { -public: - TypePair() : compiler_type(), type_sp() {} - - TypePair(CompilerType type) : compiler_type(type), type_sp() {} - - TypePair(lldb::TypeSP type) : compiler_type(), type_sp(type) { - compiler_type = type_sp->GetForwardCompilerType(); - } - - bool IsValid() const { - return compiler_type.IsValid() || (type_sp.get() != nullptr); - } - - explicit operator bool() const { return IsValid(); } - - bool operator==(const TypePair &rhs) const { - return compiler_type == rhs.compiler_type && - type_sp.get() == rhs.type_sp.get(); - } - - bool operator!=(const TypePair &rhs) const { - return compiler_type != rhs.compiler_type || - type_sp.get() != rhs.type_sp.get(); - } - - void Clear() { - compiler_type.Clear(); - type_sp.reset(); - } - - ConstString GetName() const { - if (type_sp) - return type_sp->GetName(); - if (compiler_type) - return compiler_type.GetTypeName(); - return ConstString(); - } - - ConstString GetDisplayTypeName() const { - if (type_sp) - return type_sp->GetForwardCompilerType().GetDisplayTypeName(); - if (compiler_type) - return compiler_type.GetDisplayTypeName(); - return ConstString(); - } - - void SetType(CompilerType type) { - type_sp.reset(); - compiler_type = type; - } - - void SetType(lldb::TypeSP type) { - type_sp = type; - if (type_sp) - compiler_type = type_sp->GetForwardCompilerType(); - else - compiler_type.Clear(); - } - - lldb::TypeSP GetTypeSP() const { return type_sp; } - - CompilerType GetCompilerType() const { return compiler_type; } - - CompilerType GetPointerType() const { - if (type_sp) - return type_sp->GetForwardCompilerType().GetPointerType(); - return compiler_type.GetPointerType(); - } - - CompilerType GetPointeeType() const { - if (type_sp) - return type_sp->GetForwardCompilerType().GetPointeeType(); - return compiler_type.GetPointeeType(); - } - - CompilerType GetReferenceType() const { - if (type_sp) - return type_sp->GetForwardCompilerType().GetLValueReferenceType(); - else - return compiler_type.GetLValueReferenceType(); - } - - CompilerType GetTypedefedType() const { - if (type_sp) - return type_sp->GetForwardCompilerType().GetTypedefedType(); - else - return compiler_type.GetTypedefedType(); - } - - CompilerType GetDereferencedType() const { - if (type_sp) - return type_sp->GetForwardCompilerType().GetNonReferenceType(); - else - return compiler_type.GetNonReferenceType(); - } - - CompilerType GetUnqualifiedType() const { - if (type_sp) - return type_sp->GetForwardCompilerType().GetFullyUnqualifiedType(); - else - return compiler_type.GetFullyUnqualifiedType(); - } - - CompilerType GetCanonicalType() const { - if (type_sp) - return type_sp->GetForwardCompilerType().GetCanonicalType(); - return compiler_type.GetCanonicalType(); - } - - TypeSystem *GetTypeSystem() const { return compiler_type.GetTypeSystem(); } - - lldb::ModuleSP GetModule() const { - if (type_sp) - return type_sp->GetModule(); - return lldb::ModuleSP(); - } - -protected: - CompilerType compiler_type; - lldb::TypeSP type_sp; -}; - // the two classes here are used by the public API as a backend to the SBType // and SBTypeList classes class TypeImpl { public: - TypeImpl(); + TypeImpl() = default; ~TypeImpl() {} - TypeImpl(const TypeImpl &rhs); - TypeImpl(const lldb::TypeSP &type_sp); TypeImpl(const CompilerType &compiler_type); @@ -381,8 +248,6 @@ public: TypeImpl(const CompilerType &compiler_type, const CompilerType &dynamic); - TypeImpl(const TypePair &pair, const CompilerType &dynamic); - void SetType(const lldb::TypeSP &type_sp); void SetType(const CompilerType &compiler_type); @@ -391,10 +256,6 @@ public: void SetType(const CompilerType &compiler_type, const CompilerType &dynamic); - void SetType(const TypePair &pair, const CompilerType &dynamic); - - TypeImpl &operator=(const TypeImpl &rhs); - bool operator==(const TypeImpl &rhs) const; bool operator!=(const TypeImpl &rhs) const; @@ -434,7 +295,7 @@ private: bool CheckModule(lldb::ModuleSP &module_sp) const; lldb::ModuleWP m_module_wp; - TypePair m_static_type; + CompilerType m_static_type; CompilerType m_dynamic_type; }; @@ -478,7 +339,7 @@ public: {} TypeMemberImpl(const lldb::TypeImplSP &type_impl_sp, uint64_t bit_offset, - const ConstString &name, uint32_t bitfield_bit_size = 0, + ConstString name, uint32_t bitfield_bit_size = 0, bool is_bitfield = false) : m_type_impl_sp(type_impl_sp), m_bit_offset(bit_offset), m_name(name), m_bitfield_bit_size(bitfield_bit_size), m_is_bitfield(is_bitfield) {} @@ -492,7 +353,7 @@ public: const lldb::TypeImplSP &GetTypeImpl() { return m_type_impl_sp; } - const ConstString &GetName() const { return m_name; } + ConstString GetName() const { return m_name; } uint64_t GetBitOffset() const { return m_bit_offset; } @@ -526,26 +387,21 @@ protected: class TypeAndOrName { public: - TypeAndOrName(); + TypeAndOrName() = default; TypeAndOrName(lldb::TypeSP &type_sp); TypeAndOrName(const CompilerType &compiler_type); TypeAndOrName(const char *type_str); - TypeAndOrName(const TypeAndOrName &rhs); TypeAndOrName(ConstString &type_const_string); - TypeAndOrName &operator=(const TypeAndOrName &rhs); - bool operator==(const TypeAndOrName &other) const; bool operator!=(const TypeAndOrName &other) const; ConstString GetName() const; - lldb::TypeSP GetTypeSP() const { return m_type_pair.GetTypeSP(); } + CompilerType GetCompilerType() const { return m_compiler_type; } - CompilerType GetCompilerType() const { return m_type_pair.GetCompilerType(); } - - void SetName(const ConstString &type_name); + void SetName(ConstString type_name); void SetName(const char *type_name_cstr); @@ -557,18 +413,16 @@ public: bool HasName() const; - bool HasTypeSP() const; - bool HasCompilerType() const; - bool HasType() const { return HasTypeSP() || HasCompilerType(); } + bool HasType() const { return HasCompilerType(); } void Clear(); explicit operator bool() { return !IsEmpty(); } private: - TypePair m_type_pair; + CompilerType m_compiler_type; ConstString m_type_name; }; @@ -617,17 +471,15 @@ public: : m_integer_type_sp(), m_name("<invalid>"), m_value(), m_valid(false) {} TypeEnumMemberImpl(const lldb::TypeImplSP &integer_type_sp, - const ConstString &name, const llvm::APSInt &value); + ConstString name, const llvm::APSInt &value); - TypeEnumMemberImpl(const TypeEnumMemberImpl &rhs) - : m_integer_type_sp(rhs.m_integer_type_sp), m_name(rhs.m_name), - m_value(rhs.m_value), m_valid(rhs.m_valid) {} + TypeEnumMemberImpl(const TypeEnumMemberImpl &rhs) = default; TypeEnumMemberImpl &operator=(const TypeEnumMemberImpl &rhs); bool IsValid() { return m_valid; } - const ConstString &GetName() const { return m_name; } + ConstString GetName() const { return m_name; } const lldb::TypeImplSP &GetIntegerType() const { return m_integer_type_sp; } diff --git a/include/lldb/Symbol/TypeList.h b/include/lldb/Symbol/TypeList.h index b6a4e41ff3015..982f673fff6e6 100644 --- a/include/lldb/Symbol/TypeList.h +++ b/include/lldb/Symbol/TypeList.h @@ -1,9 +1,8 @@ //===-- TypeList.h ----------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -20,9 +19,7 @@ namespace lldb_private { class TypeList { public: - //------------------------------------------------------------------ // Constructors and Destructors - //------------------------------------------------------------------ TypeList(); virtual ~TypeList(); @@ -34,7 +31,7 @@ public: // lldb::TypeSP // FindType(lldb::user_id_t uid); - TypeList FindTypes(const ConstString &name); + TypeList FindTypes(ConstString name); void Insert(const lldb::TypeSP &type); diff --git a/include/lldb/Symbol/TypeMap.h b/include/lldb/Symbol/TypeMap.h index 6bf9831c1389b..e7d2b254cbf32 100644 --- a/include/lldb/Symbol/TypeMap.h +++ b/include/lldb/Symbol/TypeMap.h @@ -1,9 +1,8 @@ //===-- TypeMap.h ----------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -20,9 +19,7 @@ namespace lldb_private { class TypeMap { public: - //------------------------------------------------------------------ // Constructors and Destructors - //------------------------------------------------------------------ TypeMap(); virtual ~TypeMap(); @@ -31,7 +28,7 @@ public: void Dump(Stream *s, bool show_context); - TypeMap FindTypes(const ConstString &name); + TypeMap FindTypes(ConstString name); void Insert(const lldb::TypeSP &type); diff --git a/include/lldb/Symbol/TypeSystem.h b/include/lldb/Symbol/TypeSystem.h index 6afbd188a2342..4bef2a4446ebd 100644 --- a/include/lldb/Symbol/TypeSystem.h +++ b/include/lldb/Symbol/TypeSystem.h @@ -1,9 +1,8 @@ //===-- TypeSystem.h ------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -26,15 +25,13 @@ class DWARFDIE; class DWARFASTParser; +class PDBASTParser; namespace lldb_private { -//---------------------------------------------------------------------- // Interface for representing the Type Systems in different languages. -//---------------------------------------------------------------------- class TypeSystem : public PluginInterface { public: - //---------------------------------------------------------------------- // Intrusive type system that allows us to use llvm casting. // // To add a new type system: @@ -64,7 +61,6 @@ public: // // Then you can use the llvm casting on any "TypeSystem *" to get an instance // of your subclass. - //---------------------------------------------------------------------- enum LLVMCastKind { eKindClang, eKindSwift, @@ -72,9 +68,7 @@ public: kNumKinds }; - //---------------------------------------------------------------------- // Constructors and Destructors - //---------------------------------------------------------------------- TypeSystem(LLVMCastKind kind); ~TypeSystem() override; @@ -92,15 +86,14 @@ public: virtual void Finalize() {} virtual DWARFASTParser *GetDWARFParser() { return nullptr; } + virtual PDBASTParser *GetPDBParser() { return nullptr; } virtual SymbolFile *GetSymbolFile() const { return m_sym_file; } // Returns true if the symbol file changed during the set accessor. virtual void SetSymbolFile(SymbolFile *sym_file) { m_sym_file = sym_file; } - //---------------------------------------------------------------------- // CompilerDecl functions - //---------------------------------------------------------------------- virtual ConstString DeclGetName(void *opaque_decl) = 0; virtual ConstString DeclGetMangledName(void *opaque_decl); @@ -114,9 +107,7 @@ public: virtual CompilerType DeclGetFunctionArgumentType(void *opaque_decl, size_t arg_idx); - //---------------------------------------------------------------------- // CompilerDeclContext functions - //---------------------------------------------------------------------- virtual std::vector<CompilerDecl> DeclContextFindDeclByName(void *opaque_decl_ctx, ConstString name, @@ -133,9 +124,10 @@ public: void *opaque_decl_ctx, lldb::LanguageType *language_ptr, bool *is_instance_method_ptr, ConstString *language_object_name_ptr) = 0; - //---------------------------------------------------------------------- + virtual bool DeclContextIsContainedInLookup(void *opaque_decl_ctx, + void *other_opaque_decl_ctx) = 0; + // Tests - //---------------------------------------------------------------------- virtual bool IsArrayType(lldb::opaque_compiler_type_t type, CompilerType *element_type, uint64_t *size, @@ -189,24 +181,20 @@ public: virtual bool IsVoidType(lldb::opaque_compiler_type_t type) = 0; + virtual bool CanPassInRegisters(const CompilerType &type) = 0; + // TypeSystems can support more than one language virtual bool SupportsLanguage(lldb::LanguageType language) = 0; - //---------------------------------------------------------------------- // Type Completion - //---------------------------------------------------------------------- virtual bool GetCompleteType(lldb::opaque_compiler_type_t type) = 0; - //---------------------------------------------------------------------- // AST related queries - //---------------------------------------------------------------------- virtual uint32_t GetPointerByteSize() = 0; - //---------------------------------------------------------------------- // Accessors - //---------------------------------------------------------------------- virtual ConstString GetTypeName(lldb::opaque_compiler_type_t type) = 0; @@ -219,9 +207,7 @@ public: virtual lldb::TypeClass GetTypeClass(lldb::opaque_compiler_type_t type) = 0; - //---------------------------------------------------------------------- // Creating related types - //---------------------------------------------------------------------- virtual CompilerType GetArrayElementType(lldb::opaque_compiler_type_t type, uint64_t *stride) = 0; @@ -267,12 +253,11 @@ public: const char *name, const CompilerDeclContext &decl_ctx); - //---------------------------------------------------------------------- // Exploring the type - //---------------------------------------------------------------------- - virtual uint64_t GetBitSize(lldb::opaque_compiler_type_t type, - ExecutionContextScope *exe_scope) = 0; + virtual llvm::Optional<uint64_t> + GetBitSize(lldb::opaque_compiler_type_t type, + ExecutionContextScope *exe_scope) = 0; virtual lldb::Encoding GetEncoding(lldb::opaque_compiler_type_t type, uint64_t &count) = 0; @@ -283,7 +268,7 @@ public: bool omit_empty_base_classes, const ExecutionContext *exe_ctx) = 0; - virtual CompilerType GetBuiltinTypeByName(const ConstString &name); + virtual CompilerType GetBuiltinTypeByName(ConstString name); virtual lldb::BasicType GetBasicTypeEnumeration(lldb::opaque_compiler_type_t type) = 0; @@ -291,7 +276,7 @@ public: virtual void ForEachEnumerator( lldb::opaque_compiler_type_t type, std::function<bool(const CompilerType &integer_type, - const ConstString &name, + ConstString name, const llvm::APSInt &value)> const &callback) {} virtual uint32_t GetNumFields(lldb::opaque_compiler_type_t type) = 0; @@ -351,10 +336,14 @@ public: virtual llvm::Optional<CompilerType::IntegralTemplateArgument> GetIntegralTemplateArgument(lldb::opaque_compiler_type_t type, size_t idx); - //---------------------------------------------------------------------- // Dumping types - //---------------------------------------------------------------------- +#ifndef NDEBUG + /// Convenience LLVM-style dump method for use in the debugger only. + LLVM_DUMP_METHOD virtual void + dump(lldb::opaque_compiler_type_t type) const = 0; +#endif + virtual void DumpValue(lldb::opaque_compiler_type_t type, ExecutionContext *exe_ctx, Stream *s, lldb::Format format, const DataExtractor &data, @@ -376,9 +365,7 @@ public: virtual void DumpTypeDescription(lldb::opaque_compiler_type_t type, Stream *s) = 0; - //---------------------------------------------------------------------- // TODO: These methods appear unused. Should they be removed? - //---------------------------------------------------------------------- virtual bool IsRuntimeGeneratedType(lldb::opaque_compiler_type_t type) = 0; @@ -394,9 +381,7 @@ public: const char *s, uint8_t *dst, size_t dst_size) = 0; - //---------------------------------------------------------------------- // TODO: Determine if these methods should move to ClangASTContext. - //---------------------------------------------------------------------- virtual bool IsPointerOrReferenceType(lldb::opaque_compiler_type_t type, CompilerType *pointee_type) = 0; @@ -449,7 +434,8 @@ public: GetUserExpression(llvm::StringRef expr, llvm::StringRef prefix, lldb::LanguageType language, Expression::ResultType desired_type, - const EvaluateExpressionOptions &options) { + const EvaluateExpressionOptions &options, + ValueObject *ctx_obj) { return nullptr; } diff --git a/include/lldb/Symbol/UnwindPlan.h b/include/lldb/Symbol/UnwindPlan.h index 7a5cf7f02a675..2b49acaafa041 100644 --- a/include/lldb/Symbol/UnwindPlan.h +++ b/include/lldb/Symbol/UnwindPlan.h @@ -1,9 +1,8 @@ //===-- UnwindPlan.h --------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// diff --git a/include/lldb/Symbol/UnwindTable.h b/include/lldb/Symbol/UnwindTable.h index 061e7ddc0f99a..b4d7f0661d5b1 100644 --- a/include/lldb/Symbol/UnwindTable.h +++ b/include/lldb/Symbol/UnwindTable.h @@ -1,9 +1,8 @@ -//===-- Symtab.h ------------------------------------------------*- C++ -*-===// +//===-- UnwindTable.h -------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -23,7 +22,9 @@ namespace lldb_private { class UnwindTable { public: - UnwindTable(ObjectFile &objfile); + /// Create an Unwind table using the data in the given module. + explicit UnwindTable(Module &module); + ~UnwindTable(); lldb_private::DWARFCallFrameInfo *GetEHFrameInfo(); @@ -32,6 +33,7 @@ public: lldb_private::CompactUnwindInfo *GetCompactUnwindInfo(); ArmUnwindInfo *GetArmUnwindInfo(); + SymbolFile *GetSymbolFile(); lldb::FuncUnwindersSP GetFuncUnwindersContainingAddress(const Address &addr, SymbolContext &sc); @@ -63,7 +65,7 @@ private: typedef collection::iterator iterator; typedef collection::const_iterator const_iterator; - ObjectFile &m_object_file; + Module &m_module; collection m_unwinds; bool m_initialized; // delay some initialization until ObjectFile is set up diff --git a/include/lldb/Symbol/Variable.h b/include/lldb/Symbol/Variable.h index 531312e635915..12daecfc04e63 100644 --- a/include/lldb/Symbol/Variable.h +++ b/include/lldb/Symbol/Variable.h @@ -1,26 +1,24 @@ //===-- Variable.h -----------------------------------------------*- C++-*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// #ifndef liblldb_Variable_h_ #define liblldb_Variable_h_ -#include <memory> -#include <vector> - #include "lldb/Core/Mangled.h" -#include "lldb/Core/RangeMap.h" #include "lldb/Expression/DWARFExpression.h" #include "lldb/Symbol/Declaration.h" #include "lldb/Utility/CompletionRequest.h" +#include "lldb/Utility/RangeMap.h" #include "lldb/Utility/UserID.h" #include "lldb/lldb-enumerations.h" #include "lldb/lldb-private.h" +#include <memory> +#include <vector> namespace lldb_private { @@ -28,9 +26,7 @@ class Variable : public UserID, public std::enable_shared_from_this<Variable> { public: typedef RangeVector<lldb::addr_t, lldb::addr_t> RangeList; - //------------------------------------------------------------------ // Constructors and Destructors - //------------------------------------------------------------------ Variable(lldb::user_id_t uid, const char *name, const char *mangled, // The mangled or fully qualified name of the variable. @@ -59,7 +55,7 @@ public: // 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(ConstString name) const; bool NameMatches(const RegularExpression ®ex) const; @@ -132,8 +128,8 @@ protected: m_static_member : 1; // Non-zero if variable is static member of a class // or struct. private: - Variable(const Variable &rhs); - Variable &operator=(const Variable &rhs); + Variable(const Variable &rhs) = delete; + Variable &operator=(const Variable &rhs) = delete; }; } // namespace lldb_private diff --git a/include/lldb/Symbol/VariableList.h b/include/lldb/Symbol/VariableList.h index 6729a9c108a9b..54d27583cd7b2 100644 --- a/include/lldb/Symbol/VariableList.h +++ b/include/lldb/Symbol/VariableList.h @@ -1,9 +1,8 @@ //===-- VariableList.h ------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -18,9 +17,7 @@ namespace lldb_private { class VariableList { public: - //------------------------------------------------------------------ // Constructors and Destructors - //------------------------------------------------------------------ // VariableList(const SymbolContext &symbol_context); VariableList(); virtual ~VariableList(); @@ -39,10 +36,10 @@ public: lldb::VariableSP RemoveVariableAtIndex(size_t idx); - lldb::VariableSP FindVariable(const ConstString &name, + lldb::VariableSP FindVariable(ConstString name, bool include_static_members = true); - lldb::VariableSP FindVariable(const ConstString &name, + lldb::VariableSP FindVariable(ConstString name, lldb::ValueType value_type, bool include_static_members = true); @@ -76,9 +73,7 @@ protected: collection m_variables; private: - //------------------------------------------------------------------ // For VariableList only - //------------------------------------------------------------------ DISALLOW_COPY_AND_ASSIGN(VariableList); }; diff --git a/include/lldb/Symbol/VerifyDecl.h b/include/lldb/Symbol/VerifyDecl.h index f4b61e6355ced..f412b94a7859a 100644 --- a/include/lldb/Symbol/VerifyDecl.h +++ b/include/lldb/Symbol/VerifyDecl.h @@ -1,9 +1,8 @@ //===-- VerifyDecl.h --------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// diff --git a/include/lldb/Target/ABI.h b/include/lldb/Target/ABI.h index 24fff1caf6c48..f254839fc975a 100644 --- a/include/lldb/Target/ABI.h +++ b/include/lldb/Target/ABI.h @@ -1,9 +1,8 @@ //===-- ABI.h ---------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -35,7 +34,7 @@ public: size_t size; /* size in bytes of this argument */ lldb::addr_t value; /* literal value */ - std::unique_ptr<uint8_t[]> data_ap; /* host data pointer */ + std::unique_ptr<uint8_t[]> data_up; /* host data pointer */ }; ~ABI() override; @@ -87,14 +86,12 @@ protected: virtual lldb::ValueObjectSP GetReturnValueObjectImpl(Thread &thread, llvm::Type &ir_type) const; - //------------------------------------------------------------------ /// Request to get a Process shared pointer. /// /// This ABI object may not have been created with a Process object, /// or the Process object may no longer be alive. Be sure to handle /// the case where the shared pointer returned does not have an /// object inside it. - //------------------------------------------------------------------ lldb::ProcessSP GetProcessSP() const { return m_process_wp.lock(); } public: @@ -129,7 +126,7 @@ public: virtual const RegisterInfo *GetRegisterInfoArray(uint32_t &count) = 0; - bool GetRegisterInfoByName(const ConstString &name, RegisterInfo &info); + bool GetRegisterInfoByName(ConstString name, RegisterInfo &info); bool GetRegisterInfoByKind(lldb::RegisterKind reg_kind, uint32_t reg_num, RegisterInfo &info); @@ -139,9 +136,7 @@ public: static lldb::ABISP FindPlugin(lldb::ProcessSP process_sp, const ArchSpec &arch); protected: - //------------------------------------------------------------------ // Classes that inherit from ABI can see and modify these - //------------------------------------------------------------------ ABI(lldb::ProcessSP process_sp) { if (process_sp.get()) m_process_wp = process_sp; diff --git a/include/lldb/Target/CPPLanguageRuntime.h b/include/lldb/Target/CPPLanguageRuntime.h deleted file mode 100644 index e96ee168389b9..0000000000000 --- a/include/lldb/Target/CPPLanguageRuntime.h +++ /dev/null @@ -1,80 +0,0 @@ -//===-- CPPLanguageRuntime.h -//---------------------------------------------------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -#ifndef liblldb_CPPLanguageRuntime_h_ -#define liblldb_CPPLanguageRuntime_h_ - -#include <vector> -#include "lldb/Core/PluginInterface.h" -#include "lldb/Target/LanguageRuntime.h" -#include "lldb/lldb-private.h" - -namespace lldb_private { - -class CPPLanguageRuntime : public LanguageRuntime { -public: - enum class LibCppStdFunctionCallableCase { - Lambda = 0, - CallableObject, - FreeOrMemberFunction, - Invalid - }; - - struct LibCppStdFunctionCallableInfo { - Symbol callable_symbol; - Address callable_address; - LineEntry callable_line_entry; - lldb::addr_t member__f_pointer_value = 0u; - LibCppStdFunctionCallableCase callable_case = - LibCppStdFunctionCallableCase::Invalid; - }; - - LibCppStdFunctionCallableInfo - FindLibCppStdFunctionCallableInfo(lldb::ValueObjectSP &valobj_sp); - - ~CPPLanguageRuntime() override; - - lldb::LanguageType GetLanguageType() const override { - return lldb::eLanguageTypeC_plus_plus; - } - - virtual bool IsVTableName(const char *name) = 0; - - bool GetObjectDescription(Stream &str, ValueObject &object) override; - - bool GetObjectDescription(Stream &str, Value &value, - ExecutionContextScope *exe_scope) override; - - /// Obtain a ThreadPlan to get us into C++ constructs such as std::function. - /// - /// @param[in] thread - /// Curent thrad of execution. - /// - /// @param[in] stop_others - /// True if other threads should pause during execution. - /// - /// @return - /// A ThreadPlan Shared pointer - lldb::ThreadPlanSP GetStepThroughTrampolinePlan(Thread &thread, - bool stop_others); - -protected: - //------------------------------------------------------------------ - // Classes that inherit from CPPLanguageRuntime can see and modify these - //------------------------------------------------------------------ - CPPLanguageRuntime(Process *process); - -private: - DISALLOW_COPY_AND_ASSIGN(CPPLanguageRuntime); -}; - -} // namespace lldb_private - -#endif // liblldb_CPPLanguageRuntime_h_ diff --git a/include/lldb/Target/DynamicLoader.h b/include/lldb/Target/DynamicLoader.h index fe04f94aa31be..2bf3f32b5eef2 100644 --- a/include/lldb/Target/DynamicLoader.h +++ b/include/lldb/Target/DynamicLoader.h @@ -1,9 +1,8 @@ //===-- DynamicLoader.h -----------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -23,30 +22,17 @@ #include <stdint.h> namespace lldb_private { class ModuleList; -} -namespace lldb_private { class Process; -} -namespace lldb_private { class SectionList; -} -namespace lldb_private { class Symbol; -} -namespace lldb_private { class SymbolContext; -} -namespace lldb_private { class SymbolContextList; -} -namespace lldb_private { class Thread; } namespace lldb_private { -//---------------------------------------------------------------------- -/// @class DynamicLoader DynamicLoader.h "lldb/Target/DynamicLoader.h" +/// \class DynamicLoader DynamicLoader.h "lldb/Target/DynamicLoader.h" /// A plug-in interface definition class for dynamic loaders. /// /// Dynamic loader plug-ins track image (shared library) loading and @@ -63,64 +49,50 @@ namespace lldb_private { /// 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 { 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. /// - /// @param[in] process + /// \param[in] process /// The process for which to try and locate a dynamic loader /// plug-in instance. /// - /// @param[in] plugin_name + /// \param[in] plugin_name /// An optional name of a specific dynamic loader plug-in that /// should be used. If NULL, pick the best plug-in. - //------------------------------------------------------------------ static DynamicLoader *FindPlugin(Process *process, const char *plugin_name); - //------------------------------------------------------------------ /// Construct with a process. - //------------------------------------------------------------------ DynamicLoader(Process *process); - //------------------------------------------------------------------ /// Destructor. /// /// The destructor is virtual since this class is designed to be inherited /// from by the plug-in instance. - //------------------------------------------------------------------ - virtual ~DynamicLoader() override; + ~DynamicLoader() override; - //------------------------------------------------------------------ /// Called after attaching 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. - //------------------------------------------------------------------ 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. - //------------------------------------------------------------------ virtual bool ProcessDidExec() { return false; } - //------------------------------------------------------------------ /// Get whether the process should stop when images change. /// /// When images (executables and shared libraries) get loaded or unloaded, @@ -129,13 +101,11 @@ public: /// DynamicLoader plug-in instances should return this value to ensure /// consistent debug session behaviour. /// - /// @return + /// \return /// Returns \b true if the process should stop when images /// change, \b false if the process should resume. - //------------------------------------------------------------------ bool GetStopWhenImagesChange() const; - //------------------------------------------------------------------ /// Set whether the process should stop when images change. /// /// When images (executables and shared libraries) get loaded or unloaded, @@ -144,54 +114,48 @@ public: /// process stops when images change, but this can be overridden using this /// function callback. /// - /// @param[in] stop + /// \param[in] stop /// Boolean value that indicates whether the process should stop /// when images change. - //------------------------------------------------------------------ void SetStopWhenImagesChange(bool stop); - //------------------------------------------------------------------ /// Provides a plan to step through the dynamic loader trampoline for the /// current state of \a thread. /// /// - /// @param[in] stop_others + /// \param[in] stop_others /// Whether the plan should be set to stop other threads. /// - /// @return + /// \return /// A pointer to the plan (caller owned) or NULL if we are not at such /// a trampoline. - //------------------------------------------------------------------ virtual lldb::ThreadPlanSP GetStepThroughTrampolinePlan(Thread &thread, bool stop_others) = 0; - //------------------------------------------------------------------ /// 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. /// /// - /// @param[in] original_symbol + /// \param[in] original_symbol /// The symbol for which we are finding equivalences. /// - /// @param[in] module_list + /// \param[in] module_list /// The set of modules in which to search. /// - /// @param[out] equivalent_symbols + /// \param[out] equivalent_symbols /// The equivalent symbol list - any equivalent symbols found are appended /// to this list. /// - /// @return + /// \return /// Number of equivalent symbols found. - //------------------------------------------------------------------ virtual size_t FindEquivalentSymbols(Symbol *original_symbol, ModuleList &module_list, SymbolContextList &equivalent_symbols) { return 0; } - //------------------------------------------------------------------ /// 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 @@ -199,13 +163,11 @@ public: /// plug-ins to check any current dyld state to make sure it is an ok time /// to load a shared library. /// - /// @return + /// \return /// \b true if it is currently ok to try and load a shared /// library into the process, \b false otherwise. - //------------------------------------------------------------------ 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. /// @@ -221,44 +183,40 @@ public: /// not reliable enough -- we need to consult those function's hand-written /// eh_frame information. /// - /// @return + /// \return /// \b True if the symbol context should use eh_frame instructions /// unconditionally when unwinding from this frame. Else \b false, /// the normal lldb unwind behavior of only using eh_frame when the /// function appears in the middle of the stack. - //------------------------------------------------------------------ virtual bool AlwaysRelyOnEHUnwindInfo(SymbolContext &sym_ctx) { return false; } - //------------------------------------------------------------------ /// Retrieves the per-module TLS block for a given thread. /// - /// @param[in] module + /// \param[in] module /// The module to query TLS data for. /// - /// @param[in] thread + /// \param[in] thread /// The specific thread to query TLS data for. /// - /// @return + /// \return /// If the given thread has TLS data allocated for the /// module, the address of the TLS block. Otherwise /// LLDB_INVALID_ADDRESS is returned. - //------------------------------------------------------------------ virtual lldb::addr_t GetThreadLocalData(const lldb::ModuleSP module, const lldb::ThreadSP thread, lldb::addr_t tls_file_addr) { return LLDB_INVALID_ADDRESS; } - /// Locates or creates a module given by @p file and updates/loads the - /// resulting module at the virtual base address @p base_addr. + /// Locates or creates a module given by \p file and updates/loads the + /// resulting module at the virtual base address \p base_addr. virtual lldb::ModuleSP LoadModuleAtAddress(const lldb_private::FileSpec &file, lldb::addr_t link_map_addr, lldb::addr_t base_addr, bool base_addr_is_offset); - //------------------------------------------------------------------ /// 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 @@ -273,27 +231,26 @@ public: /// of the cache - or it may be able to return additional information about /// the cache. /// - /// @param[out] base_address + /// \param[out] base_address /// The base address (load address) of the shared cache. /// LLDB_INVALID_ADDRESS if it cannot be determined. /// - /// @param[out] uuid + /// \param[out] uuid /// The UUID of the shared cache, if it can be determined. /// If the UUID cannot be fetched, IsValid() will be false. /// - /// @param[out] using_shared_cache + /// \param[out] using_shared_cache /// If this process is using a shared cache. /// If unknown, eLazyBoolCalculate is returned. /// - /// @param[out] private_shared_cache + /// \param[out] private_shared_cache /// A LazyBool indicating whether this process is using a /// private shared cache. /// If this information cannot be fetched, eLazyBoolCalculate. /// - /// @return + /// \return /// Returns false if this DynamicLoader cannot gather information /// about the shared cache / has no concept of a shared cache. - //------------------------------------------------------------------ virtual bool GetSharedCacheInformation(lldb::addr_t &base_address, UUID &uuid, LazyBool &using_shared_cache, LazyBool &private_shared_cache) { @@ -305,22 +262,20 @@ public: } protected: - //------------------------------------------------------------------ // Utility methods for derived classes - //------------------------------------------------------------------ /// Checks to see if the target module has changed, updates the target /// accordingly and returns the target executable module. lldb::ModuleSP GetTargetExecutable(); - /// Updates the load address of every allocatable section in @p module. + /// Updates the load address of every allocatable section in \p module. /// - /// @param module The module to traverse. + /// \param module The module to traverse. /// - /// @param link_map_addr The virtual address of the link map for the @p + /// \param link_map_addr The virtual address of the link map for the @p /// module. /// - /// @param base_addr The virtual base address @p module is loaded at. + /// \param base_addr The virtual base address \p module is loaded at. virtual void UpdateLoadedSections(lldb::ModuleSP module, lldb::addr_t link_map_addr, lldb::addr_t base_addr, @@ -331,9 +286,9 @@ protected: void UpdateLoadedSectionsCommon(lldb::ModuleSP module, lldb::addr_t base_addr, bool base_addr_is_offset); - /// Removes the loaded sections from the target in @p module. + /// Removes the loaded sections from the target in \p module. /// - /// @param module The module to traverse. + /// \param module The module to traverse. virtual void UnloadSections(const lldb::ModuleSP module); // Utility method so base classes can share implementation of UnloadSections @@ -354,9 +309,7 @@ protected: void LoadOperatingSystemPlugin(bool flush); - //------------------------------------------------------------------ // Member variables. - //------------------------------------------------------------------ Process *m_process; ///< The process that this dynamic loader plug-in is tracking. diff --git a/include/lldb/Target/ExecutionContext.h b/include/lldb/Target/ExecutionContext.h index 167189c3a8375..0819357fab32d 100644 --- a/include/lldb/Target/ExecutionContext.h +++ b/include/lldb/Target/ExecutionContext.h @@ -1,9 +1,8 @@ //===-- ExecutionContext.h --------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -41,8 +40,7 @@ namespace lldb_private { /// a wide variety of functions that require execution contexts. //===----------------------------------------------------------------------===// -//---------------------------------------------------------------------- -/// @class ExecutionContextRef ExecutionContext.h +/// \class ExecutionContextRef ExecutionContext.h /// "lldb/Target/ExecutionContext.h" /// A class that holds a weak reference to an execution context. /// @@ -71,44 +69,32 @@ namespace lldb_private { /// 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: - //------------------------------------------------------------------ /// Default Constructor. - //------------------------------------------------------------------ ExecutionContextRef(); - //------------------------------------------------------------------ /// Copy Constructor. - //------------------------------------------------------------------ ExecutionContextRef(const ExecutionContextRef &rhs); - //------------------------------------------------------------------ /// 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. - //------------------------------------------------------------------ ExecutionContextRef(const ExecutionContext *exe_ctx_ptr); - //------------------------------------------------------------------ /// Construct using an ExecutionContext object. /// /// Make weak references to any valid objects in the ExecutionContext. - //------------------------------------------------------------------ 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. - //------------------------------------------------------------------ ExecutionContextRef(Target *target, bool adopt_selected); - //------------------------------------------------------------------ /// Construct using an execution context scope. /// /// If the ExecutionContextScope object is valid and refers to a frame, make @@ -119,10 +105,8 @@ public: /// 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 @@ -132,34 +116,26 @@ public: /// 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); ~ExecutionContextRef(); - //------------------------------------------------------------------ /// Assignment operator /// /// Copy all weak references in \a rhs. - //------------------------------------------------------------------ ExecutionContextRef &operator=(const ExecutionContextRef &rhs); - //------------------------------------------------------------------ /// Assignment operator from a ExecutionContext /// /// Make weak references to any strongly referenced objects in \a exe_ctx. - //------------------------------------------------------------------ ExecutionContextRef &operator=(const ExecutionContext &exe_ctx); - //------------------------------------------------------------------ /// Clear the object's state. /// /// Sets the process and thread to nullptr, and the frame index to an /// invalid value. - //------------------------------------------------------------------ void Clear(); - //------------------------------------------------------------------ /// Set accessor that creates a weak reference to the target referenced in /// \a target_sp. /// @@ -172,11 +148,9 @@ public: /// a weak reference to the target's process, use the /// ExecutionContextRef::SetContext() functions. /// - /// @see ExecutionContextRef::SetContext(const lldb::TargetSP &, bool) - //------------------------------------------------------------------ + /// \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. /// @@ -189,11 +163,9 @@ public: /// a weak reference to the target, use the /// ExecutionContextRef::SetContext() functions. /// - /// @see ExecutionContextRef::SetContext(const lldb::ProcessSP &) - //------------------------------------------------------------------ + /// \see ExecutionContextRef::SetContext(const lldb::ProcessSP &) void SetProcessSP(const lldb::ProcessSP &process_sp); - //------------------------------------------------------------------ /// Set accessor that creates a weak reference to the thread referenced in /// \a thread_sp. /// @@ -206,11 +178,9 @@ public: /// a weak reference to the thread's process and target, use the /// ExecutionContextRef::SetContext() functions. /// - /// @see ExecutionContextRef::SetContext(const lldb::ThreadSP &) - //------------------------------------------------------------------ + /// \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. /// @@ -223,8 +193,7 @@ public: /// a weak reference to the frame's thread, process and target, use the /// ExecutionContextRef::SetContext() functions. /// - /// @see ExecutionContextRef::SetContext(const lldb::StackFrameSP &) - //------------------------------------------------------------------ + /// \see ExecutionContextRef::SetContext(const lldb::StackFrameSP &) void SetFrameSP(const lldb::StackFrameSP &frame_sp); void SetTargetPtr(Target *target, bool adopt_selected); @@ -235,65 +204,51 @@ public: void SetFramePtr(StackFrame *frame); - //------------------------------------------------------------------ /// Get accessor that creates a strong reference from the weak target /// reference contained in this object. /// - /// @returns + /// \returns /// A shared pointer to a target that is not guaranteed to be valid. - //------------------------------------------------------------------ lldb::TargetSP GetTargetSP() const; - //------------------------------------------------------------------ /// Get accessor that creates a strong reference from the weak process /// reference contained in this object. /// - /// @returns + /// \returns /// A shared pointer to a process that is not guaranteed to be valid. - //------------------------------------------------------------------ lldb::ProcessSP GetProcessSP() const; - //------------------------------------------------------------------ /// Get accessor that creates a strong reference from the weak thread /// reference contained in this object. /// - /// @returns + /// \returns /// A shared pointer to a thread that is not guaranteed to be valid. - //------------------------------------------------------------------ lldb::ThreadSP GetThreadSP() const; - //------------------------------------------------------------------ /// Get accessor that creates a strong reference from the weak frame /// reference contained in this object. /// - /// @returns + /// \returns /// A shared pointer to a frame that is not guaranteed to be valid. - //------------------------------------------------------------------ lldb::StackFrameSP GetFrameSP() const; - //------------------------------------------------------------------ /// 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 + /// 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. - //------------------------------------------------------------------ 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. - //------------------------------------------------------------------ bool HasFrameRef() const { return m_stack_id.IsValid(); } void ClearThread() { @@ -304,9 +259,7 @@ public: void ClearFrame() { m_stack_id.Clear(); } protected: - //------------------------------------------------------------------ // Member variables - //------------------------------------------------------------------ lldb::TargetWP m_target_wp; ///< A weak reference to a target lldb::ProcessWP m_process_wp; ///< A weak reference to a process mutable lldb::ThreadWP m_thread_wp; ///< A weak reference to a thread @@ -316,8 +269,7 @@ protected: ///backing object changes }; -//---------------------------------------------------------------------- -/// @class ExecutionContext ExecutionContext.h +/// \class ExecutionContext ExecutionContext.h /// "lldb/Target/ExecutionContext.h" /// A class that contains an execution context. /// @@ -336,35 +288,24 @@ protected: /// 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: - //------------------------------------------------------------------ /// Default Constructor. - //------------------------------------------------------------------ ExecutionContext(); - //------------------------------------------------------------------ // Copy constructor - //------------------------------------------------------------------ ExecutionContext(const ExecutionContext &rhs); - //------------------------------------------------------------------ // Adopt the target and optionally its current context. - //------------------------------------------------------------------ ExecutionContext(Target *t, bool fill_current_process_thread_frame = true); - //------------------------------------------------------------------ // Create execution contexts from shared pointers - //------------------------------------------------------------------ ExecutionContext(const lldb::TargetSP &target_sp, bool get_process); ExecutionContext(const lldb::ProcessSP &process_sp); ExecutionContext(const lldb::ThreadSP &thread_sp); ExecutionContext(const lldb::StackFrameSP &frame_sp); - //------------------------------------------------------------------ // Create execution contexts from weak pointers - //------------------------------------------------------------------ ExecutionContext(const lldb::TargetWP &target_wp, bool get_process); ExecutionContext(const lldb::ProcessWP &process_wp); ExecutionContext(const lldb::ThreadWP &thread_wp); @@ -379,26 +320,22 @@ public: std::unique_lock<std::recursive_mutex> &locker); ExecutionContext(const ExecutionContextRef *exe_ctx_ref, std::unique_lock<std::recursive_mutex> &locker); - //------------------------------------------------------------------ // Create execution contexts from execution context scopes - //------------------------------------------------------------------ ExecutionContext(ExecutionContextScope *exe_scope); ExecutionContext(ExecutionContextScope &exe_scope); - //------------------------------------------------------------------ /// Construct with process, thread, and frame index. /// /// Initialize with process \a p, thread \a t, and frame index \a f. /// - /// @param[in] process + /// \param[in] process /// The process for this execution context. /// - /// @param[in] thread + /// \param[in] thread /// The thread for this execution context. /// - /// @param[in] frame + /// \param[in] frame /// The frame index for this execution context. - //------------------------------------------------------------------ ExecutionContext(Process *process, Thread *thread = nullptr, StackFrame *frame = nullptr); @@ -410,12 +347,10 @@ public: bool operator!=(const ExecutionContext &rhs) const; - //------------------------------------------------------------------ /// Clear the object's state. /// /// Sets the process and thread to nullptr, and the frame index to an /// invalid value. - //------------------------------------------------------------------ void Clear(); RegisterContext *GetRegisterContext() const; @@ -426,7 +361,6 @@ public: lldb::ByteOrder GetByteOrder() const; - //------------------------------------------------------------------ /// Returns a pointer to the target object. /// /// The returned pointer might be nullptr. Calling HasTargetScope(), @@ -434,14 +368,12 @@ public: /// validate this pointer so that this accessor can freely be used without /// having to check for nullptr each time. /// - /// @see ExecutionContext::HasTargetScope() const @see + /// \see ExecutionContext::HasTargetScope() const @see /// ExecutionContext::HasProcessScope() const @see /// ExecutionContext::HasThreadScope() const @see /// ExecutionContext::HasFrameScope() const - //------------------------------------------------------------------ Target *GetTargetPtr() const; - //------------------------------------------------------------------ /// Returns a pointer to the process object. /// /// The returned pointer might be nullptr. Calling HasProcessScope(), @@ -449,13 +381,11 @@ public: /// pointer so that this accessor can freely be used without having to check /// for nullptr each time. /// - /// @see ExecutionContext::HasProcessScope() const @see + /// \see ExecutionContext::HasProcessScope() const @see /// ExecutionContext::HasThreadScope() const @see /// ExecutionContext::HasFrameScope() const - //------------------------------------------------------------------ Process *GetProcessPtr() const; - //------------------------------------------------------------------ /// Returns a pointer to the thread object. /// /// The returned pointer might be nullptr. Calling HasThreadScope() or @@ -463,187 +393,141 @@ public: /// accessor can freely be used without having to check for nullptr each /// time. /// - /// @see ExecutionContext::HasThreadScope() const @see + /// \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. /// - /// @see ExecutionContext::HasFrameScope() const - //------------------------------------------------------------------ + /// \see ExecutionContext::HasFrameScope() const StackFrame *GetFramePtr() const { return m_frame_sp.get(); } - //------------------------------------------------------------------ /// 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. /// - /// @see ExecutionContext::HasTargetScope() const @see + /// \see ExecutionContext::HasTargetScope() const @see /// ExecutionContext::HasProcessScope() const @see /// ExecutionContext::HasThreadScope() const @see /// ExecutionContext::HasFrameScope() const - //------------------------------------------------------------------ Target &GetTargetRef() const; - //------------------------------------------------------------------ /// 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. /// - /// @see ExecutionContext::HasProcessScope() const @see + /// \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. /// - /// @see ExecutionContext::HasThreadScope() const @see + /// \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. /// - /// @see ExecutionContext::HasFrameScope() const - //------------------------------------------------------------------ + /// \see ExecutionContext::HasFrameScope() const StackFrame &GetFrameRef() const; - //------------------------------------------------------------------ /// Get accessor to get the target shared pointer. /// /// The returned shared pointer is not guaranteed to be valid. - //------------------------------------------------------------------ const lldb::TargetSP &GetTargetSP() const { return m_target_sp; } - //------------------------------------------------------------------ /// Get accessor to get the process shared pointer. /// /// The returned shared pointer is not guaranteed to be valid. - //------------------------------------------------------------------ const lldb::ProcessSP &GetProcessSP() const { return m_process_sp; } - //------------------------------------------------------------------ /// Get accessor to get the thread shared pointer. /// /// The returned shared pointer is not guaranteed to be valid. - //------------------------------------------------------------------ const lldb::ThreadSP &GetThreadSP() const { return m_thread_sp; } - //------------------------------------------------------------------ /// Get accessor to get the frame shared pointer. /// /// The returned shared pointer is not guaranteed to be valid. - //------------------------------------------------------------------ const lldb::StackFrameSP &GetFrameSP() const { return m_frame_sp; } - //------------------------------------------------------------------ /// Set accessor to set only the target shared pointer. - //------------------------------------------------------------------ void SetTargetSP(const lldb::TargetSP &target_sp); - //------------------------------------------------------------------ /// Set accessor to set only the process shared pointer. - //------------------------------------------------------------------ void SetProcessSP(const lldb::ProcessSP &process_sp); - //------------------------------------------------------------------ /// Set accessor to set only the thread shared pointer. - //------------------------------------------------------------------ void SetThreadSP(const lldb::ThreadSP &thread_sp); - //------------------------------------------------------------------ /// Set accessor to set only the frame shared pointer. - //------------------------------------------------------------------ void SetFrameSP(const lldb::StackFrameSP &frame_sp); - //------------------------------------------------------------------ /// Set accessor to set only the target shared pointer from a target /// pointer. - //------------------------------------------------------------------ void SetTargetPtr(Target *target); - //------------------------------------------------------------------ /// Set accessor to set only the process shared pointer from a process /// pointer. - //------------------------------------------------------------------ void SetProcessPtr(Process *process); - //------------------------------------------------------------------ /// Set accessor to set only the thread shared pointer from a thread /// pointer. - //------------------------------------------------------------------ void SetThreadPtr(Thread *thread); - //------------------------------------------------------------------ /// 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. - //------------------------------------------------------------------ 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. - //------------------------------------------------------------------ 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. - //------------------------------------------------------------------ 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. - //------------------------------------------------------------------ void SetContext(const lldb::StackFrameSP &frame_sp); - //------------------------------------------------------------------ /// 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 /// GetTargetRef() do not need to be checked for validity. - //------------------------------------------------------------------ bool HasTargetScope() const; - //------------------------------------------------------------------ /// Returns true the ExecutionContext object contains a valid target and /// process. /// @@ -651,10 +535,8 @@ public: /// object, and if it returns true, calls to GetTargetPtr() and /// 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. /// @@ -662,10 +544,8 @@ public: /// 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. /// @@ -673,13 +553,10 @@ public: /// 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; protected: - //------------------------------------------------------------------ // Member variables - //------------------------------------------------------------------ lldb::TargetSP m_target_sp; ///< The target that owns the process/thread/frame lldb::ProcessSP m_process_sp; ///< The process that owns the thread/frame lldb::ThreadSP m_thread_sp; ///< The thread that owns the frame diff --git a/include/lldb/Target/ExecutionContextScope.h b/include/lldb/Target/ExecutionContextScope.h index 3e787584be0b0..0121ce61a1d77 100644 --- a/include/lldb/Target/ExecutionContextScope.h +++ b/include/lldb/Target/ExecutionContextScope.h @@ -1,9 +1,8 @@ //===-- ExecutionContextScope.h ---------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -14,9 +13,8 @@ namespace lldb_private { -//---------------------------------------------------------------------- /// @class ExecutionContextScope ExecutionContextScope.h -/// "lldb/Symbol/ExecutionContextScope.h" Inherit from this if your object can +/// "lldb/Target/ExecutionContextScope.h" Inherit from this if your object can /// reconstruct its /// execution context. /// @@ -31,7 +29,6 @@ namespace lldb_private { /// /// 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: virtual ~ExecutionContextScope() {} @@ -44,17 +41,15 @@ public: virtual lldb::StackFrameSP CalculateStackFrame() = 0; - //------------------------------------------------------------------ /// 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. /// - /// @param[out] exe_ctx + /// \param[out] exe_ctx /// A reference to an execution context object that gets filled /// in. - //------------------------------------------------------------------ virtual void CalculateExecutionContext(ExecutionContext &exe_ctx) = 0; }; diff --git a/include/lldb/Target/InstrumentationRuntime.h b/include/lldb/Target/InstrumentationRuntime.h index ba905cb8535df..4cee76d657bb8 100644 --- a/include/lldb/Target/InstrumentationRuntime.h +++ b/include/lldb/Target/InstrumentationRuntime.h @@ -1,9 +1,8 @@ //===-- InstrumentationRuntime.h --------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// diff --git a/include/lldb/Target/InstrumentationRuntimeStopInfo.h b/include/lldb/Target/InstrumentationRuntimeStopInfo.h index 7c72c9524ecac..6c2a8ad87418a 100644 --- a/include/lldb/Target/InstrumentationRuntimeStopInfo.h +++ b/include/lldb/Target/InstrumentationRuntimeStopInfo.h @@ -1,9 +1,8 @@ //===-- InstrumentationRuntimeStopInfo.h ------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// diff --git a/include/lldb/Target/JITLoader.h b/include/lldb/Target/JITLoader.h index 56f1417eddb0e..1bafd828f78e4 100644 --- a/include/lldb/Target/JITLoader.h +++ b/include/lldb/Target/JITLoader.h @@ -1,9 +1,8 @@ //===-- JITLoader.h ---------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -17,8 +16,7 @@ namespace lldb_private { -//---------------------------------------------------------------------- -/// @class JITLoader JITLoader.h "lldb/Target/JITLoader.h" +/// \class JITLoader JITLoader.h "lldb/Target/JITLoader.h" /// A plug-in interface definition class for JIT loaders. /// /// Plugins of this kind listen for code generated at runtime in the target. @@ -26,55 +24,42 @@ namespace lldb_private { /// 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. /// - /// @param[in] process + /// \param[in] process /// The process for which to try and locate a JIT loader /// plug-in instance. /// - //------------------------------------------------------------------ static void LoadPlugins(Process *process, lldb_private::JITLoaderList &list); - //------------------------------------------------------------------ /// Construct with a process. - //------------------------------------------------------------------ JITLoader(Process *process); ~JITLoader() override; - //------------------------------------------------------------------ /// Called after attaching 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. - //------------------------------------------------------------------ virtual void DidLaunch() = 0; - //------------------------------------------------------------------ /// 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; protected: - //------------------------------------------------------------------ // Member variables. - //------------------------------------------------------------------ Process *m_process; }; diff --git a/include/lldb/Target/JITLoaderList.h b/include/lldb/Target/JITLoaderList.h index 4b9d79bbfcabb..4cc3a9ecb91d1 100644 --- a/include/lldb/Target/JITLoaderList.h +++ b/include/lldb/Target/JITLoaderList.h @@ -1,9 +1,8 @@ //===-- JITLoaderList.h -----------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -17,11 +16,9 @@ namespace lldb_private { -//---------------------------------------------------------------------- -/// @class JITLoaderList JITLoaderList.h "lldb/Target/JITLoaderList.h" +/// \class JITLoaderList JITLoaderList.h "lldb/Target/JITLoaderList.h" /// /// Class used by the Process to hold a list of its JITLoaders. -//---------------------------------------------------------------------- class JITLoaderList { public: JITLoaderList(); diff --git a/include/lldb/Target/Language.h b/include/lldb/Target/Language.h index 27f40fd1ba837..6ea6029bdace0 100644 --- a/include/lldb/Target/Language.h +++ b/include/lldb/Target/Language.h @@ -1,10 +1,9 @@ //===-- Language.h ---------------------------------------------------*- C++ //-*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -191,6 +190,14 @@ public: virtual const char *GetLanguageSpecificTypeLookupHelp(); + // If a language can have more than one possible name for a method, this + // function can be used to enumerate them. This is useful when doing name + // lookups. + virtual std::vector<ConstString> + GetMethodNameVariants(ConstString method_name) const { + return std::vector<ConstString>(); + }; + // 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 @@ -248,12 +255,17 @@ public: static bool LanguageIsC(lldb::LanguageType language); + /// Equivalent to \c LanguageIsC||LanguageIsObjC||LanguageIsCPlusPlus. + static bool LanguageIsCFamily(lldb::LanguageType language); + static bool LanguageIsPascal(lldb::LanguageType language); // return the primary language, so if LanguageIsC(l), return eLanguageTypeC, // etc. static lldb::LanguageType GetPrimaryLanguage(lldb::LanguageType language); + static std::set<lldb::LanguageType> GetSupportedLanguages(); + static void GetLanguagesSupportingTypeSystems( std::set<lldb::LanguageType> &languages, std::set<lldb::LanguageType> &languages_for_expressions); @@ -262,9 +274,7 @@ public: GetLanguagesSupportingREPLs(std::set<lldb::LanguageType> &languages); protected: - //------------------------------------------------------------------ // Classes that inherit from Language can see and modify these - //------------------------------------------------------------------ Language(); diff --git a/include/lldb/Target/LanguageRuntime.h b/include/lldb/Target/LanguageRuntime.h index 2a2f47b853591..73c8dfa3874db 100644 --- a/include/lldb/Target/LanguageRuntime.h +++ b/include/lldb/Target/LanguageRuntime.h @@ -1,10 +1,9 @@ //===-- LanguageRuntime.h ---------------------------------------------------*- // C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -17,6 +16,7 @@ #include "lldb/Core/Value.h" #include "lldb/Core/ValueObject.h" #include "lldb/Expression/LLVMUserExpression.h" +#include "lldb/Symbol/DeclVendor.h" #include "lldb/Target/ExecutionContextScope.h" #include "lldb/lldb-private.h" #include "lldb/lldb-public.h" @@ -116,9 +116,8 @@ public: bool catch_bp, bool throw_bp, bool is_internal = false); - static Breakpoint::BreakpointPreconditionSP - CreateExceptionPrecondition(lldb::LanguageType language, bool catch_bp, - bool throw_bp); + static lldb::BreakpointPreconditionSP + GetExceptionPrecondition(lldb::LanguageType language, bool throw_bp); virtual lldb::ValueObjectSP GetExceptionObjectForThread( lldb::ThreadSP thread_sp) { @@ -134,17 +133,32 @@ public: Target &GetTargetRef() { return m_process->GetTarget(); } + virtual DeclVendor *GetDeclVendor() { return nullptr; } + virtual lldb::BreakpointResolverSP CreateExceptionResolver(Breakpoint *bkpt, bool catch_bp, bool throw_bp) = 0; - virtual lldb::SearchFilterSP CreateExceptionSearchFilter(); + virtual lldb::SearchFilterSP CreateExceptionSearchFilter() { + return m_process->GetTarget().GetSearchFilterForModule(nullptr); + } virtual bool GetTypeBitSize(const CompilerType &compiler_type, uint64_t &size) { return false; } - virtual bool IsRuntimeSupportValue(ValueObject &valobj) { return false; } + virtual void SymbolsDidLoad(const ModuleList &module_list) { return; } + + virtual lldb::ThreadPlanSP GetStepThroughTrampolinePlan(Thread &thread, + bool stop_others) = 0; + + /// Identify whether a name is a runtime value that should not be hidden by + /// from the user interface. + virtual bool IsWhitelistedRuntimeValue(ConstString name) { return false; } + + virtual llvm::Optional<CompilerType> GetRuntimeType(CompilerType base_type) { + return llvm::None; + } virtual void ModulesDidLoad(const ModuleList &module_list) {} @@ -162,10 +176,18 @@ public: return false; } + // Given the name of a runtime symbol (e.g. in Objective-C, an 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(ConstString name) { + return LLDB_INVALID_ADDRESS; + } + + virtual bool isA(const void *ClassID) const { return ClassID == &ID; } + static char ID; + protected: - //------------------------------------------------------------------ // Classes that inherit from LanguageRuntime can see and modify these - //------------------------------------------------------------------ LanguageRuntime(Process *process); Process *m_process; diff --git a/include/lldb/Target/Memory.h b/include/lldb/Target/Memory.h index d5e6c105f76d3..e62b8ef9c773e 100644 --- a/include/lldb/Target/Memory.h +++ b/include/lldb/Target/Memory.h @@ -1,33 +1,26 @@ //===-- Memory.h ------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// #ifndef liblldb_Memory_h_ #define liblldb_Memory_h_ +#include "lldb/Utility/RangeMap.h" +#include "lldb/lldb-private.h" #include <map> #include <mutex> #include <vector> - -#include "lldb/Core/RangeMap.h" -#include "lldb/lldb-private.h" - namespace lldb_private { -//---------------------------------------------------------------------- // A class to track memory that was read from a live process between // runs. -//---------------------------------------------------------------------- class MemoryCache { public: - //------------------------------------------------------------------ // Constructors and Destructors - //------------------------------------------------------------------ MemoryCache(Process &process); ~MemoryCache(); @@ -54,9 +47,7 @@ protected: typedef std::map<lldb::addr_t, lldb::DataBufferSP> BlockMap; typedef RangeArray<lldb::addr_t, lldb::addr_t, 4> InvalidRanges; typedef Range<lldb::addr_t, lldb::addr_t> AddrRange; - //------------------------------------------------------------------ // Classes that inherit from MemoryCache can see and modify these - //------------------------------------------------------------------ std::recursive_mutex m_mutex; BlockMap m_L1_cache; // A first level memory cache whose chunk sizes vary that // will be used only if the memory read fits entirely in @@ -114,16 +105,12 @@ protected: RangeVector<lldb::addr_t, uint32_t> m_reserved_blocks; }; -//---------------------------------------------------------------------- // 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. -//---------------------------------------------------------------------- class AllocatedMemoryCache { public: - //------------------------------------------------------------------ // Constructors and Destructors - //------------------------------------------------------------------ AllocatedMemoryCache(Process &process); ~AllocatedMemoryCache(); @@ -141,9 +128,7 @@ protected: AllocatedBlockSP AllocatePage(uint32_t byte_size, uint32_t permissions, uint32_t chunk_size, Status &error); - //------------------------------------------------------------------ // Classes that inherit from MemoryCache can see and modify these - //------------------------------------------------------------------ Process &m_process; std::recursive_mutex m_mutex; typedef std::multimap<uint32_t, AllocatedBlockSP> PermissionsToBlockMap; diff --git a/include/lldb/Target/MemoryHistory.h b/include/lldb/Target/MemoryHistory.h index cb3e900533576..501751c55e80a 100644 --- a/include/lldb/Target/MemoryHistory.h +++ b/include/lldb/Target/MemoryHistory.h @@ -1,10 +1,9 @@ //===-- MemoryHistory.h ---------------------------------------------------*- //C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// diff --git a/include/lldb/Target/MemoryRegionInfo.h b/include/lldb/Target/MemoryRegionInfo.h index a57c4678bb370..5cab2efea77c9 100644 --- a/include/lldb/Target/MemoryRegionInfo.h +++ b/include/lldb/Target/MemoryRegionInfo.h @@ -1,19 +1,18 @@ //===-- MemoryRegionInfo.h ---------------------------------------*- C++ //-*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// #ifndef lldb_MemoryRegionInfo_h #define lldb_MemoryRegionInfo_h -#include "lldb/Core/RangeMap.h" -#include "llvm/Support/FormatProviders.h" #include "lldb/Utility/ConstString.h" +#include "lldb/Utility/RangeMap.h" +#include "llvm/Support/FormatProviders.h" namespace lldb_private { class MemoryRegionInfo { @@ -45,7 +44,7 @@ public: OptionalBool GetMapped() const { return m_mapped; } - const ConstString &GetName() const { return m_name; } + ConstString GetName() const { return m_name; } void SetReadable(OptionalBool val) { m_read = val; } @@ -65,10 +64,8 @@ public: 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 - //---------------------------------------------------------------------- uint32_t GetLLDBPermissions() const { uint32_t permissions = 0; if (m_read) @@ -80,10 +77,8 @@ public: return 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; m_write = (permissions & lldb::ePermissionsWritable) ? eYes : eNo; diff --git a/include/lldb/Target/ModuleCache.h b/include/lldb/Target/ModuleCache.h index a060937e0614a..1196169113936 100644 --- a/include/lldb/Target/ModuleCache.h +++ b/include/lldb/Target/ModuleCache.h @@ -1,9 +1,8 @@ //===-- ModuleCache.h -------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -26,8 +25,7 @@ namespace lldb_private { class Module; class UUID; -//---------------------------------------------------------------------- -/// @class ModuleCache ModuleCache.h "lldb/Target/ModuleCache.h" +/// \class ModuleCache ModuleCache.h "lldb/Target/ModuleCache.h" /// A module cache class. /// /// Caches locally modules that are downloaded from remote targets. Each @@ -45,7 +43,6 @@ class UUID; /// /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 -//---------------------------------------------------------------------- class ModuleCache { public: diff --git a/include/lldb/Target/ObjCLanguageRuntime.h b/include/lldb/Target/ObjCLanguageRuntime.h deleted file mode 100644 index 9eebf94630432..0000000000000 --- a/include/lldb/Target/ObjCLanguageRuntime.h +++ /dev/null @@ -1,419 +0,0 @@ -//===-- ObjCLanguageRuntime.h -----------------------------------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -#ifndef liblldb_ObjCLanguageRuntime_h_ -#define liblldb_ObjCLanguageRuntime_h_ - -#include <functional> -#include <map> -#include <memory> -#include <unordered_set> - -#include "llvm/Support/Casting.h" - -#include "lldb/Core/PluginInterface.h" -#include "lldb/Core/ThreadSafeDenseMap.h" -#include "lldb/Symbol/CompilerType.h" -#include "lldb/Symbol/DeclVendor.h" -#include "lldb/Symbol/Type.h" -#include "lldb/Target/LanguageRuntime.h" -#include "lldb/lldb-private.h" - -class CommandObjectObjC_ClassTable_Dump; - -namespace lldb_private { - -class UtilityFunction; - -class ObjCLanguageRuntime : public LanguageRuntime { -public: - enum class ObjCRuntimeVersions { - eObjC_VersionUnknown = 0, - eAppleObjC_V1 = 1, - eAppleObjC_V2 = 2 - }; - - typedef lldb::addr_t ObjCISA; - - 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 - class ClassDescriptor { - public: - ClassDescriptor() - : m_is_kvo(eLazyBoolCalculate), m_is_cf(eLazyBoolCalculate), - m_type_wp() {} - - virtual ~ClassDescriptor() = default; - - virtual ConstString GetClassName() = 0; - - virtual ClassDescriptorSP GetSuperclass() = 0; - - 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 bool IsKVO() { - if (m_is_kvo == eLazyBoolCalculate) { - const char *class_name = GetClassName().AsCString(); - if (class_name && *class_name) - m_is_kvo = - (LazyBool)(strstr(class_name, "NSKVONotifying_") == class_name); - } - 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 bool IsCFType() { - if (m_is_cf == eLazyBoolCalculate) { - const char *class_name = GetClassName().AsCString(); - if (class_name && *class_name) - m_is_cf = (LazyBool)(strcmp(class_name, "__NSCFType") == 0 || - strcmp(class_name, "NSCFType") == 0); - } - return (m_is_cf == eLazyBoolYes); - } - - virtual bool IsValid() = 0; - - virtual bool GetTaggedPointerInfo(uint64_t *info_bits = nullptr, - uint64_t *value_bits = nullptr, - uint64_t *payload = nullptr) = 0; - - virtual uint64_t GetInstanceSize() = 0; - - // use to implement version-specific additional constraints on pointers - virtual bool CheckPointer(lldb::addr_t value, uint32_t ptr_size) const { - return true; - } - - virtual ObjCISA GetISA() = 0; - - // This should return true iff the interface could be completed - virtual bool - Describe(std::function<void(ObjCISA)> const &superclass_func, - std::function<bool(const char *, const char *)> const - &instance_method_func, - std::function<bool(const char *, const char *)> const - &class_method_func, - std::function<bool(const char *, const char *, lldb::addr_t, - uint64_t)> const &ivar_func) const { - return false; - } - - lldb::TypeSP GetType() { return m_type_wp.lock(); } - - void SetType(const lldb::TypeSP &type_sp) { m_type_wp = type_sp; } - - struct iVarDescriptor { - ConstString m_name; - CompilerType m_type; - uint64_t m_size; - int32_t m_offset; - }; - - virtual size_t GetNumIVars() { return 0; } - - virtual iVarDescriptor GetIVarAtIndex(size_t idx) { - return iVarDescriptor(); - } - - protected: - bool IsPointerValid(lldb::addr_t value, uint32_t ptr_size, - bool allow_NULLs = false, bool allow_tagged = false, - bool check_version_specific = false) const; - - private: - LazyBool m_is_kvo; - LazyBool m_is_cf; - lldb::TypeWP m_type_wp; - }; - - class EncodingToType { - public: - virtual ~EncodingToType(); - - virtual CompilerType RealizeType(ClangASTContext &ast_ctx, const char *name, - bool for_expression); - virtual CompilerType RealizeType(const char *name, bool for_expression); - - virtual CompilerType RealizeType(clang::ASTContext &ast_ctx, - const char *name, bool for_expression) = 0; - - protected: - std::unique_ptr<ClangASTContext> m_scratch_ast_ctx_ap; - }; - - class ObjCExceptionPrecondition : public Breakpoint::BreakpointPrecondition { - public: - ObjCExceptionPrecondition(); - - ~ObjCExceptionPrecondition() override = default; - - bool EvaluatePrecondition(StoppointCallbackContext &context) override; - void GetDescription(Stream &stream, lldb::DescriptionLevel level) override; - Status ConfigurePrecondition(Args &args) override; - - protected: - void AddClassName(const char *class_name); - - private: - std::unordered_set<std::string> m_class_names; - }; - - class TaggedPointerVendor { - public: - virtual ~TaggedPointerVendor() = default; - - virtual bool IsPossibleTaggedPointer(lldb::addr_t ptr) = 0; - - virtual ObjCLanguageRuntime::ClassDescriptorSP - GetClassDescriptor(lldb::addr_t ptr) = 0; - - protected: - TaggedPointerVendor() = default; - - private: - DISALLOW_COPY_AND_ASSIGN(TaggedPointerVendor); - }; - - ~ObjCLanguageRuntime() override; - - virtual TaggedPointerVendor *GetTaggedPointerVendor() { return nullptr; } - - typedef std::shared_ptr<EncodingToType> EncodingToTypeSP; - - virtual EncodingToTypeSP GetEncodingToType(); - - virtual ClassDescriptorSP GetClassDescriptor(ValueObject &in_value); - - ClassDescriptorSP GetNonKVOClassDescriptor(ValueObject &in_value); - - virtual ClassDescriptorSP - GetClassDescriptorFromClassName(const ConstString &class_name); - - virtual ClassDescriptorSP GetClassDescriptorFromISA(ObjCISA isa); - - ClassDescriptorSP GetNonKVOClassDescriptor(ObjCISA isa); - - lldb::LanguageType GetLanguageType() const override { - return lldb::eLanguageTypeObjC; - } - - virtual bool IsModuleObjCLibrary(const lldb::ModuleSP &module_sp) = 0; - - virtual bool ReadObjCLibrary(const lldb::ModuleSP &module_sp) = 0; - - virtual bool HasReadObjCLibrary() = 0; - - virtual lldb::ThreadPlanSP GetStepThroughTrampolinePlan(Thread &thread, - bool stop_others) = 0; - - lldb::addr_t LookupInMethodCache(lldb::addr_t class_addr, lldb::addr_t sel); - - void AddToMethodCache(lldb::addr_t class_addr, lldb::addr_t sel, - lldb::addr_t impl_addr); - - TypeAndOrName LookupInClassNameCache(lldb::addr_t class_addr); - - void AddToClassNameCache(lldb::addr_t class_addr, const char *name, - lldb::TypeSP type_sp); - - void AddToClassNameCache(lldb::addr_t class_addr, - const TypeAndOrName &class_or_type_name); - - lldb::TypeSP LookupInCompleteClassCache(ConstString &name); - - virtual UtilityFunction *CreateObjectChecker(const char *) = 0; - - virtual ObjCRuntimeVersions GetRuntimeVersion() const { - return ObjCRuntimeVersions::eObjC_VersionUnknown; - } - - bool IsValidISA(ObjCISA isa) { - UpdateISAToDescriptorMap(); - return m_isa_to_descriptor.count(isa) > 0; - } - - virtual void UpdateISAToDescriptorMapIfNeeded() = 0; - - void UpdateISAToDescriptorMap() { - if (m_process && m_process->GetStopID() != m_isa_to_descriptor_stop_id) { - UpdateISAToDescriptorMapIfNeeded(); - } - } - - virtual ObjCISA GetISA(const ConstString &name); - - virtual ConstString GetActualTypeName(ObjCISA isa); - - virtual ObjCISA GetParentClass(ObjCISA isa); - - 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. - - 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. - virtual lldb::addr_t LookupRuntimeSymbol(const ConstString &name) { - return LLDB_INVALID_ADDRESS; - } - - bool HasNewLiteralsAndIndexing() { - if (m_has_new_literals_and_indexing == eLazyBoolCalculate) { - if (CalculateHasNewLiteralsAndIndexing()) - m_has_new_literals_and_indexing = eLazyBoolYes; - else - m_has_new_literals_and_indexing = eLazyBoolNo; - } - - return (m_has_new_literals_and_indexing == eLazyBoolYes); - } - - virtual void SymbolsDidLoad(const ModuleList &module_list) { - m_negative_complete_class_cache.clear(); - } - - bool GetTypeBitSize(const CompilerType &compiler_type, - uint64_t &size) override; - -protected: - //------------------------------------------------------------------ - // Classes that inherit from ObjCLanguageRuntime can see and modify these - //------------------------------------------------------------------ - ObjCLanguageRuntime(Process *process); - - virtual bool CalculateHasNewLiteralsAndIndexing() { return false; } - - bool ISAIsCached(ObjCISA isa) const { - return m_isa_to_descriptor.find(isa) != m_isa_to_descriptor.end(); - } - - bool AddClass(ObjCISA isa, const ClassDescriptorSP &descriptor_sp) { - if (isa != 0) { - m_isa_to_descriptor[isa] = descriptor_sp; - return true; - } - return false; - } - - bool AddClass(ObjCISA isa, const ClassDescriptorSP &descriptor_sp, - const char *class_name); - - bool AddClass(ObjCISA isa, const ClassDescriptorSP &descriptor_sp, - uint32_t class_name_hash) { - if (isa != 0) { - m_isa_to_descriptor[isa] = descriptor_sp; - m_hash_to_isa_map.insert(std::make_pair(class_name_hash, isa)); - return true; - } - return false; - } - -private: - // We keep a map of <Class,Selector>->Implementation so we don't have to call - // the resolver function over and over. - - // FIXME: We need to watch for the loading of Protocols, and flush the cache - // for any - // class that we see so changed. - - struct ClassAndSel { - ClassAndSel() { - sel_addr = LLDB_INVALID_ADDRESS; - class_addr = LLDB_INVALID_ADDRESS; - } - - ClassAndSel(lldb::addr_t in_sel_addr, lldb::addr_t in_class_addr) - : class_addr(in_class_addr), sel_addr(in_sel_addr) {} - - bool operator==(const ClassAndSel &rhs) { - if (class_addr == rhs.class_addr && sel_addr == rhs.sel_addr) - return true; - else - return false; - } - - bool operator<(const ClassAndSel &rhs) const { - if (class_addr < rhs.class_addr) - return true; - else if (class_addr > rhs.class_addr) - return false; - else { - if (sel_addr < rhs.sel_addr) - return true; - else - return false; - } - } - - lldb::addr_t class_addr; - lldb::addr_t sel_addr; - }; - - typedef std::map<ClassAndSel, lldb::addr_t> MsgImplMap; - typedef std::map<ObjCISA, ClassDescriptorSP> ISAToDescriptorMap; - typedef std::multimap<uint32_t, ObjCISA> HashToISAMap; - typedef ISAToDescriptorMap::iterator ISAToDescriptorIterator; - typedef HashToISAMap::iterator HashToISAIterator; - typedef ThreadSafeDenseMap<void *, uint64_t> TypeSizeCache; - - MsgImplMap m_impl_cache; - LazyBool m_has_new_literals_and_indexing; - ISAToDescriptorMap m_isa_to_descriptor; - HashToISAMap m_hash_to_isa_map; - TypeSizeCache m_type_size_cache; - -protected: - uint32_t m_isa_to_descriptor_stop_id; - - typedef std::map<ConstString, lldb::TypeWP> CompleteClassMap; - CompleteClassMap m_complete_class_cache; - - struct ConstStringSetHelpers { - size_t operator()(const ConstString &arg) const // for hashing - { - return (size_t)arg.GetCString(); - } - bool operator()(const ConstString &arg1, - const ConstString &arg2) const // for equality - { - return arg1.operator==(arg2); - } - }; - typedef std::unordered_set<ConstString, ConstStringSetHelpers, - ConstStringSetHelpers> - CompleteClassSet; - CompleteClassSet m_negative_complete_class_cache; - - ISAToDescriptorIterator GetDescriptorIterator(const ConstString &name); - - friend class ::CommandObjectObjC_ClassTable_Dump; - - std::pair<ISAToDescriptorIterator, ISAToDescriptorIterator> - GetDescriptorIteratorPair(bool update_if_needed = true); - - void ReadObjCLibraryIfNeeded(const ModuleList &module_list); - - DISALLOW_COPY_AND_ASSIGN(ObjCLanguageRuntime); -}; - -} // namespace lldb_private - -#endif // liblldb_ObjCLanguageRuntime_h_ diff --git a/include/lldb/Target/OperatingSystem.h b/include/lldb/Target/OperatingSystem.h index 4d73bb3906ee6..c75d1ca2e5f48 100644 --- a/include/lldb/Target/OperatingSystem.h +++ b/include/lldb/Target/OperatingSystem.h @@ -1,10 +1,9 @@ //===-- OperatingSystem.h ----------------------------------------------*- C++ //-*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -17,8 +16,7 @@ namespace lldb_private { -//---------------------------------------------------------------------- -/// @class OperatingSystem OperatingSystem.h "lldb/Target/OperatingSystem.h" +/// \class OperatingSystem OperatingSystem.h "lldb/Target/OperatingSystem.h" /// A plug-in interface definition class for halted OS helpers. /// /// Halted OS plug-ins can be used by any process to locate and create @@ -26,36 +24,29 @@ namespace lldb_private { /// 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. -//---------------------------------------------------------------------- class OperatingSystem : public PluginInterface { 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. /// - /// @param[in] process + /// \param[in] process /// The process for which to try and locate a halted OS /// plug-in instance. /// - /// @param[in] plugin_name + /// \param[in] plugin_name /// An optional name of a specific halted OS plug-in that /// should be used. If NULL, pick the best plug-in. - //------------------------------------------------------------------ static OperatingSystem *FindPlugin(Process *process, const char *plugin_name); - //------------------------------------------------------------------ // Class Methods - //------------------------------------------------------------------ OperatingSystem(Process *process); ~OperatingSystem() override; - //------------------------------------------------------------------ // Plug-in Methods - //------------------------------------------------------------------ virtual bool UpdateThreadList(ThreadList &old_thread_list, ThreadList &real_thread_list, ThreadList &new_thread_list) = 0; @@ -75,9 +66,7 @@ public: virtual bool IsOperatingSystemPluginThread(const lldb::ThreadSP &thread_sp); protected: - //------------------------------------------------------------------ // Member variables. - //------------------------------------------------------------------ Process *m_process; ///< The process that this dynamic loader plug-in is tracking. private: diff --git a/include/lldb/Target/PathMappingList.h b/include/lldb/Target/PathMappingList.h index 29e6ef191e275..d1759667f1f5d 100644 --- a/include/lldb/Target/PathMappingList.h +++ b/include/lldb/Target/PathMappingList.h @@ -1,9 +1,8 @@ //===-- PathMappingList.h ---------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -22,9 +21,7 @@ public: typedef void (*ChangedCallback)(const PathMappingList &path_list, void *baton); - //------------------------------------------------------------------ // Constructors and Destructors - //------------------------------------------------------------------ PathMappingList(); PathMappingList(ChangedCallback callback, void *callback_baton); @@ -35,7 +32,7 @@ public: const PathMappingList &operator=(const PathMappingList &rhs); - void Append(const ConstString &path, const ConstString &replacement, + void Append(ConstString path, ConstString replacement, bool notify); void Append(const PathMappingList &rhs, bool notify); @@ -52,43 +49,40 @@ public: bool GetPathsAtIndex(uint32_t idx, ConstString &path, ConstString &new_path) const; - void Insert(const ConstString &path, const ConstString &replacement, + void Insert(ConstString path, ConstString replacement, uint32_t insert_idx, bool notify); bool Remove(size_t index, bool notify); - bool Remove(const ConstString &path, bool notify); + bool Remove(ConstString path, bool notify); - bool Replace(const ConstString &path, const ConstString &replacement, + bool Replace(ConstString path, ConstString replacement, bool notify); - bool Replace(const ConstString &path, const ConstString &replacement, + bool Replace(ConstString path, ConstString replacement, uint32_t index, bool notify); - bool RemapPath(const ConstString &path, ConstString &new_path) const; + bool RemapPath(ConstString path, ConstString &new_path) const; - //------------------------------------------------------------------ /// 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. /// - /// @param[in] path + /// \param[in] path /// The original source file path to try and remap. /// - /// @param[out] new_path + /// \param[out] new_path /// The newly remapped filespec that is may or may not exist. /// - /// @return + /// \return /// /b true if \a path was successfully located and \a new_path /// is filled in with a new source path, \b false otherwise. - //------------------------------------------------------------------ bool RemapPath(llvm::StringRef path, std::string &new_path) const; bool RemapPath(const char *, std::string &) const = delete; bool ReverseRemapPath(const FileSpec &file, FileSpec &fixed) const; - //------------------------------------------------------------------ /// Finds a source file given a file spec using the path remappings. /// /// Tries to resolve \a orig_spec by checking the path remappings. @@ -97,20 +91,19 @@ public: /// or are even on the local file system, so use this function /// sparingly (not in a tight debug info parsing loop). /// - /// @param[in] orig_spec + /// \param[in] orig_spec /// The original source file path to try and remap. /// - /// @param[out] new_spec + /// \param[out] new_spec /// The newly remapped filespec that is guaranteed to exist. /// - /// @return + /// \return /// /b true if \a orig_spec was successfully located and /// \a new_spec is filled in with an existing file spec, /// \b false otherwise. - //------------------------------------------------------------------ bool FindFile(const FileSpec &orig_spec, FileSpec &new_spec) const; - uint32_t FindIndexForPath(const ConstString &path) const; + uint32_t FindIndexForPath(ConstString path) const; uint32_t GetModificationID() const { return m_mod_id; } @@ -120,9 +113,9 @@ protected: typedef collection::iterator iterator; typedef collection::const_iterator const_iterator; - iterator FindIteratorForPath(const ConstString &path); + iterator FindIteratorForPath(ConstString path); - const_iterator FindIteratorForPath(const ConstString &path) const; + const_iterator FindIteratorForPath(ConstString path) const; collection m_pairs; ChangedCallback m_callback; diff --git a/include/lldb/Target/Platform.h b/include/lldb/Target/Platform.h index 3dbeef73f0aba..3ba58c0ec741e 100644 --- a/include/lldb/Target/Platform.h +++ b/include/lldb/Target/Platform.h @@ -1,9 +1,8 @@ //===-- Platform.h ----------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -24,12 +23,17 @@ #include "lldb/Utility/ConstString.h" #include "lldb/Utility/FileSpec.h" #include "lldb/Utility/Timeout.h" +#include "lldb/Utility/UserIDResolver.h" #include "lldb/lldb-private-forward.h" #include "lldb/lldb-public.h" #include "llvm/Support/VersionTuple.h" namespace lldb_private { +class ProcessInstanceInfo; +class ProcessInstanceInfoList; +class ProcessInstanceInfoMatch; + class ModuleCache; enum MmapFlags { eMmapFlagsPrivate = 1, eMmapFlagsAnon = 2 }; @@ -49,32 +53,26 @@ public: typedef std::shared_ptr<PlatformProperties> PlatformPropertiesSP; typedef llvm::SmallVector<lldb::addr_t, 6> MmapArgList; -//---------------------------------------------------------------------- -/// @class Platform Platform.h "lldb/Target/Platform.h" +/// \class Platform Platform.h "lldb/Target/Platform.h" /// A plug-in interface definition class for debug platform that /// includes many platform abilities such as: -/// @li getting platform information such as supported architectures, +/// \li getting platform information such as supported architectures, /// supported binary file formats and more -/// @li launching new processes -/// @li attaching to existing processes -/// @li download/upload files -/// @li execute shell commands -/// @li listing and getting info for existing processes -/// @li attaching and possibly debugging the platform's kernel -//---------------------------------------------------------------------- +/// \li launching new processes +/// \li attaching to existing processes +/// \li download/upload files +/// \li execute shell commands +/// \li listing and getting info for existing processes +/// \li attaching and possibly debugging the platform's kernel class Platform : public PluginInterface { public: - //------------------------------------------------------------------ /// Default Constructor - //------------------------------------------------------------------ Platform(bool is_host_platform); - //------------------------------------------------------------------ /// Destructor. /// /// The destructor is virtual since this class is designed to be inherited /// from by the plug-in instance. - //------------------------------------------------------------------ ~Platform() override; static void Initialize(); @@ -83,7 +81,6 @@ public: static const PlatformPropertiesSP &GetGlobalPlatformProperties(); - //------------------------------------------------------------------ /// Get the native host platform plug-in. /// /// There should only be one of these for each host that LLDB runs upon that @@ -93,7 +90,6 @@ public: /// /// This platform will be used as the default platform when launching or /// attaching to processes unless another platform is specified. - //------------------------------------------------------------------ static lldb::PlatformSP GetHostPlatform(); static lldb::PlatformSP @@ -104,38 +100,33 @@ public: static void SetHostPlatform(const lldb::PlatformSP &platform_sp); // Find an existing platform plug-in by name - static lldb::PlatformSP Find(const ConstString &name); + static lldb::PlatformSP Find(ConstString name); - static lldb::PlatformSP Create(const ConstString &name, Status &error); + static lldb::PlatformSP Create(ConstString name, Status &error); static lldb::PlatformSP Create(const ArchSpec &arch, ArchSpec *platform_arch_ptr, Status &error); - //------------------------------------------------------------------------ /// Augments the triple either with information from platform or the host /// system (if platform is null). - //------------------------------------------------------------------------ static ArchSpec GetAugmentedArchSpec(Platform *platform, llvm::StringRef triple); - //------------------------------------------------------------------ /// 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 /// - /// @param[in] process + /// \param[in] process /// The process for which to try and locate a platform /// plug-in instance. /// - /// @param[in] plugin_name + /// \param[in] plugin_name /// An optional name of a specific platform plug-in that /// should be used. If nullptr, pick the best plug-in. - //------------------------------------------------------------------ // static lldb::PlatformSP - // FindPlugin (Process *process, const ConstString &plugin_name); + // FindPlugin (Process *process, 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. /// @@ -148,15 +139,13 @@ public: /// application bundles or executable wrappers can also be inspected for the /// actual application binary within the bundle that should be used. /// - /// @return + /// \return /// Returns \b true if this Platform plug-in was able to find /// a suitable executable, \b false otherwise. - //------------------------------------------------------------------ virtual Status ResolveExecutable(const ModuleSpec &module_spec, lldb::ModuleSP &module_sp, const FileSpecList *module_search_paths_ptr); - //------------------------------------------------------------------ /// Find a symbol file given a symbol file module specification. /// /// Each platform might have tricks to find symbol files for an executable @@ -164,7 +153,7 @@ public: /// support symbol files that are bundles and know how to extract the right /// symbol file given a bundle. /// - /// @param[in] target + /// \param[in] target /// The target in which we are trying to resolve the symbol file. /// The target has a list of modules that we might be able to /// use in order to help find the right symbol file. If the @@ -177,7 +166,7 @@ public: /// is specified, we can use a variety of tricks to locate the /// symbols in an SDK, PDK, or other development kit location. /// - /// @param[in] sym_spec + /// \param[in] sym_spec /// A module spec that describes some information about the /// symbol file we are trying to resolve. The ModuleSpec might /// contain the following: @@ -196,24 +185,20 @@ public: /// a symbol file, or resolve an symbol file in a /// symbol file bundle. /// - /// @param[out] sym_file + /// \param[out] sym_file /// The resolved symbol file spec if the returned error /// indicates success. /// - /// @return + /// \return /// Returns an error that describes success or failure. - //------------------------------------------------------------------ virtual Status ResolveSymbolFile(Target &target, const ModuleSpec &sym_spec, 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. - //------------------------------------------------------------------ virtual bool ResolveRemotePath(const FileSpec &platform_path, FileSpec &resolved_platform_path); - //------------------------------------------------------------------ /// Get the OS version from a connected platform. /// /// Some platforms might not be connected to a remote platform, but can @@ -221,7 +206,6 @@ public: /// 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 llvm::VersionTuple GetOSVersion(Process *process = nullptr); bool SetOSVersion(llvm::VersionTuple os_version); @@ -239,23 +223,19 @@ public: virtual const char *GetDescription() = 0; - //------------------------------------------------------------------ /// 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. - //------------------------------------------------------------------ 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(). - //------------------------------------------------------------------ virtual bool GetRemoteOSVersion() { return false; } virtual bool GetRemoteOSBuildString(std::string &s) { @@ -277,20 +257,30 @@ public: virtual bool SetRemoteWorkingDirectory(const FileSpec &working_dir); - virtual const char *GetUserName(uint32_t uid); + /// Retrieve the system include directories on this platform for the + /// given language. + /// + /// \param[in] lang + /// The language for which the include directories should be queried. + /// + /// \param[out] directories + /// The include directories for this system. + virtual std::vector<std::string> + GetSystemIncludeDirectories(lldb::LanguageType lang) { + return {}; + } - virtual const char *GetGroupName(uint32_t gid); + virtual UserIDResolver &GetUserIDResolver() = 0; - //------------------------------------------------------------------ /// 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. /// - /// @param[in] platform_file + /// \param[in] platform_file /// The platform file path to locate and cache locally. /// - /// @param[in] uuid_ptr + /// \param[in] uuid_ptr /// If we know the exact UUID of the file we are looking for, it /// can be specified. If it is not specified, we might now know /// the exact file. The UUID is usually some sort of MD5 checksum @@ -299,25 +289,22 @@ public: /// file queries to ensure we are finding the correct file, not /// just a file at the correct path. /// - /// @param[out] local_file + /// \param[out] local_file /// A locally cached version of the platform file. For platforms /// that describe the current host computer, this will just be /// the same file. For remote platforms, this file might come from /// and SDK directory, or might need to be sync'ed over to the /// current machine for efficient debugging access. /// - /// @return + /// \return /// An error object. - //------------------------------------------------------------------ virtual Status GetFileWithUUID(const FileSpec &platform_file, const UUID *uuid_ptr, FileSpec &local_file); - //---------------------------------------------------------------------- // 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. - //---------------------------------------------------------------------- virtual FileSpecList LocateExecutableScriptingResources(Target *target, Module &module, Stream *feedback_stream); @@ -335,70 +322,56 @@ public: virtual Status DisconnectRemote(); - //------------------------------------------------------------------ /// Get the platform's supported architectures in the order in which they /// should be searched. /// - /// @param[in] idx + /// \param[in] idx /// A zero based architecture index /// - /// @param[out] arch + /// \param[out] arch /// A copy of the architecture at index if the return value is /// \b true. /// - /// @return + /// \return /// \b true if \a arch was filled in and is valid, \b false /// otherwise. - //------------------------------------------------------------------ virtual bool GetSupportedArchitectureAtIndex(uint32_t idx, ArchSpec &arch) = 0; virtual size_t GetSoftwareBreakpointTrapOpcode(Target &target, BreakpointSite *bp_site); - //------------------------------------------------------------------ /// 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 - // environment variable replacement, and whatever other - // argument magic the platform defines as part of its typical - // user experience - //------------------------------------------------------------------ + /// environment variable replacement, and whatever other + /// argument magic the platform defines as part of its typical + /// user experience virtual Status ShellExpandArguments(ProcessLaunchInfo &launch_info); - //------------------------------------------------------------------ /// Kill process on a platform. - //------------------------------------------------------------------ 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. - //------------------------------------------------------------------ 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. - //------------------------------------------------------------------ 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. - //------------------------------------------------------------------ virtual lldb::ProcessSP DebugProcess(ProcessLaunchInfo &launch_info, Debugger &debugger, Target *target, // Can be nullptr, if nullptr create a new @@ -411,7 +384,6 @@ public: lldb_private::Target *target, lldb_private::Status &error); - //------------------------------------------------------------------ /// Attach to an existing process using a process ID. /// /// Each platform subclass needs to implement this function and attempt to @@ -420,15 +392,14 @@ public: /// attached to the process, or an empty shared pointer with an appropriate /// error. /// - /// @param[in] pid + /// \param[in] pid /// The process ID that we should attempt to attach to. /// - /// @return + /// \return /// An appropriate ProcessSP containing a valid shared pointer /// to the default Process subclass for the platform that is /// attached to the process, or an empty shared pointer with an /// appropriate error fill into the \a error object. - //------------------------------------------------------------------ virtual lldb::ProcessSP Attach(ProcessAttachInfo &attach_info, Debugger &debugger, Target *target, // Can be nullptr, if nullptr @@ -436,7 +407,6 @@ public: // use existing one Status &error) = 0; - //------------------------------------------------------------------ /// Attach to an existing process by process name. /// /// This function is not meant to be overridden by Process subclasses. It @@ -445,38 +415,31 @@ public: /// the attach. If DoAttach returns \b true, then Process::DidAttach() will /// be called. /// - /// @param[in] process_name + /// \param[in] process_name /// A process name to match against the current process list. /// - /// @return + /// \return /// Returns \a pid if attaching was successful, or /// LLDB_INVALID_PROCESS_ID if attaching fails. - //------------------------------------------------------------------ // virtual lldb::ProcessSP // Attach (const char *process_name, // bool wait_for_launch, // Status &error) = 0; - //------------------------------------------------------------------ // 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); 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. - //------------------------------------------------------------------ virtual lldb::BreakpointSP SetThreadCreationBreakpoint(Target &target); - //------------------------------------------------------------------ // Given a target, find the local SDK directory if one exists on the current // host. - //------------------------------------------------------------------ virtual lldb_private::ConstString GetSDKDirectory(lldb_private::Target &target) { return lldb_private::ConstString(); @@ -503,11 +466,9 @@ public: m_os_version_set_while_connected = m_system_arch.IsValid(); } - //--------------------------------------------------------------------------- /// 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); // Used for column widths @@ -516,13 +477,13 @@ public: // Used for column widths size_t GetMaxGroupIDNameLength() const { return m_max_gid_name_len; } - const ConstString &GetSDKRootDirectory() const { return m_sdk_sysroot; } + ConstString GetSDKRootDirectory() const { return m_sdk_sysroot; } - void SetSDKRootDirectory(const ConstString &dir) { m_sdk_sysroot = dir; } + void SetSDKRootDirectory(ConstString dir) { m_sdk_sysroot = dir; } - const ConstString &GetSDKBuild() const { return m_sdk_build; } + ConstString GetSDKBuild() const { return m_sdk_build; } - void SetSDKBuild(const ConstString &sdk_build) { m_sdk_build = sdk_build; } + void SetSDKBuild(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 @@ -579,7 +540,7 @@ public: virtual uint64_t WriteFile(lldb::user_id_t fd, uint64_t offset, const void *src, uint64_t src_len, Status &error) { error.SetErrorStringWithFormat( - "Platform::ReadFile() is not supported in the %s platform", + "Platform::WriteFile() is not supported in the %s platform", GetName().GetCString()); return -1; } @@ -593,7 +554,6 @@ public: CreateSymlink(const FileSpec &src, // The name of the link is in src const FileSpec &dst); // The symlink points to dst - //---------------------------------------------------------------------- /// Install a file or directory to the remote system. /// /// Install is similar to Platform::PutFile(), but it differs in that if an @@ -602,10 +562,10 @@ public: /// application/framework/shared library, then this extra registration can /// be done. /// - /// @param[in] src + /// \param[in] src /// The source file/directory to install on the remote system. /// - /// @param[in] dst + /// \param[in] dst /// The destination file/directory where \a src will be installed. /// If \a dst has no filename specified, then its filename will /// be set from \a src. It \a dst has no directory specified, it @@ -614,9 +574,8 @@ public: /// platform working directory will be prepended to the relative /// directory. /// - /// @return + /// \return /// An error object that describes anything that went wrong. - //---------------------------------------------------------------------- virtual Status Install(const FileSpec &src, const FileSpec &dst); virtual Environment GetEnvironment(); @@ -690,9 +649,8 @@ public: virtual const lldb::UnixSignalsSP &GetRemoteUnixSignals(); - const lldb::UnixSignalsSP &GetUnixSignals(); + lldb::UnixSignalsSP GetUnixSignals(); - //------------------------------------------------------------------ /// Locate a queue name given a thread's qaddr /// /// On a system using libdispatch ("Grand Central Dispatch") style queues, a @@ -702,23 +660,21 @@ public: /// dispatch_qaddr this Platform method will locate the queue name and /// provide that. /// - /// @param[in] process + /// \param[in] process /// A process is required for reading memory. /// - /// @param[in] dispatch_qaddr + /// \param[in] dispatch_qaddr /// The dispatch_qaddr for this thread. /// - /// @return + /// \return /// The name of the queue, if there is one. An empty string /// means that this thread is not associated with a dispatch /// queue. - //------------------------------------------------------------------ virtual std::string GetQueueNameForThreadQAddress(Process *process, lldb::addr_t dispatch_qaddr) { return ""; } - //------------------------------------------------------------------ /// Locate a queue ID given a thread's qaddr /// /// On a system using libdispatch ("Grand Central Dispatch") style queues, a @@ -728,22 +684,20 @@ public: /// dispatch_qaddr this Platform method will locate the queue ID and provide /// that. /// - /// @param[in] process + /// \param[in] process /// A process is required for reading memory. /// - /// @param[in] dispatch_qaddr + /// \param[in] dispatch_qaddr /// The dispatch_qaddr for this thread. /// - /// @return + /// \return /// The queue_id for this thread, if this thread is associated /// with a dispatch queue. Else LLDB_INVALID_QUEUE_ID is returned. - //------------------------------------------------------------------ virtual lldb::queue_id_t GetQueueIDForThreadQAddress(Process *process, lldb::addr_t dispatch_qaddr) { return LLDB_INVALID_QUEUE_ID; } - //------------------------------------------------------------------ /// Provide a list of trap handler function names for this platform /// /// The unwinder needs to treat trap handlers specially -- the stack frame @@ -761,105 +715,96 @@ public: /// signal handler routines as needed. For most Unix platforms, add /// _sigtramp. /// - /// @return + /// \return /// A list of symbol names. The list may be empty. - //------------------------------------------------------------------ virtual const std::vector<ConstString> &GetTrapHandlerSymbolNames(); - //------------------------------------------------------------------ /// 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. /// - /// @param[in] basename + /// \param[in] basename /// The basename of the executable to locate in the current /// platform. /// - /// @return + /// \return /// A FileSpec pointing to the executable on disk, or an invalid /// FileSpec if the executable cannot be found. - //------------------------------------------------------------------ virtual FileSpec LocateExecutable(const char *basename) { return FileSpec(); } - //------------------------------------------------------------------ /// 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. - //------------------------------------------------------------------ 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. /// - /// @param[in] process + /// \param[in] process /// The process to load the image. /// - /// @param[in] local_file + /// \param[in] local_file /// The file spec that points to the shared library that you want /// to load if the library is located on the host. The library will /// be copied over to the location specified by remote_file or into /// the current working directory with the same filename if the /// remote_file isn't specified. /// - /// @param[in] remote_file + /// \param[in] remote_file /// If local_file is specified then the location where the library /// should be copied over from the host. If local_file isn't /// specified, then the path for the shared library on the target /// what you want to load. /// - /// @param[out] error + /// \param[out] error /// An error object that gets filled in with any errors that /// might occur when trying to load the shared library. /// - /// @return + /// \return /// A token that represents the shared library that can be /// later used to unload the shared library. A value of /// LLDB_INVALID_IMAGE_TOKEN will be returned if the shared /// library can't be opened. - //------------------------------------------------------------------ uint32_t LoadImage(lldb_private::Process *process, const lldb_private::FileSpec &local_file, 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 + /// \param[in] process /// The process to load the image. /// - /// @param[in] library_name + /// \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 + /// \param[in] path_list /// The list of paths to use to search for the library. First /// match wins. /// - /// @param[out] error + /// \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 + /// \param[out] loaded_path /// If non-null, the path to the dylib that was successfully loaded /// is stored in this path. /// - /// @return + /// \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, @@ -875,22 +820,20 @@ public: virtual Status UnloadImage(lldb_private::Process *process, uint32_t image_token); - //------------------------------------------------------------------ /// 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. /// - /// @param[in] debugger + /// \param[in] debugger /// The debugger used for the connect. /// - /// @param[out] error + /// \param[out] error /// If an error occurred during the connect then this object will /// contain the error message. /// - /// @return + /// \return /// The number of processes we are successfully connected to. - //------------------------------------------------------------------ virtual size_t ConnectToWaitingProcesses(lldb_private::Debugger &debugger, lldb_private::Status &error); @@ -917,8 +860,6 @@ protected: // Mutex for modifying Platform data structures that should only be used for // non-reentrant code std::mutex m_mutex; - IDToNameMap m_uid_map; - IDToNameMap m_gid_map; size_t m_max_uid_name_len; size_t m_max_gid_name_len; bool m_supports_rsync; @@ -932,7 +873,6 @@ protected: bool m_calculated_trap_handlers; const std::unique_ptr<ModuleCache> m_module_cache; - //------------------------------------------------------------------ /// 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 @@ -944,71 +884,8 @@ protected: /// 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 - // trying) - const auto pos = m_uid_map.find(uid); - return ((pos != m_uid_map.end()) ? pos->second.AsCString("") : nullptr); - } - - const char *SetCachedUserName(uint32_t uid, const char *name, - size_t name_len) { - std::lock_guard<std::mutex> guard(m_mutex); - ConstString const_name(name); - m_uid_map[uid] = const_name; - if (m_max_uid_name_len < name_len) - m_max_uid_name_len = name_len; - // Const strings lives forever in our const string pool, so we can return - // the const char * - return const_name.GetCString(); - } - - void SetUserNameNotFound(uint32_t uid) { - std::lock_guard<std::mutex> guard(m_mutex); - m_uid_map[uid] = ConstString(); - } - - void ClearCachedUserNames() { - std::lock_guard<std::mutex> guard(m_mutex); - m_uid_map.clear(); - } - - 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 - // trying) - const auto pos = m_gid_map.find(gid); - return ((pos != m_gid_map.end()) ? pos->second.AsCString("") : nullptr); - } - - const char *SetCachedGroupName(uint32_t gid, const char *name, - size_t name_len) { - std::lock_guard<std::mutex> guard(m_mutex); - ConstString const_name(name); - m_gid_map[gid] = const_name; - if (m_max_gid_name_len < name_len) - m_max_gid_name_len = name_len; - // Const strings lives forever in our const string pool, so we can return - // the const char * - return const_name.GetCString(); - } - - void SetGroupNameNotFound(uint32_t gid) { - std::lock_guard<std::mutex> guard(m_mutex); - m_gid_map[gid] = ConstString(); - } - - void ClearCachedGroupNames() { - std::lock_guard<std::mutex> guard(m_mutex); - m_gid_map.clear(); - } - Status GetCachedExecutable(ModuleSpec &module_spec, lldb::ModuleSP &module_sp, const FileSpecList *module_search_paths_ptr, Platform &remote_platform); @@ -1072,14 +949,12 @@ public: return platform_sp; } - //------------------------------------------------------------------ /// 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. - //------------------------------------------------------------------ lldb::PlatformSP GetSelectedPlatform() { std::lock_guard<std::recursive_mutex> guard(m_mutex); if (!m_selected_platform_sp && !m_platforms.empty()) diff --git a/include/lldb/Target/Process.h b/include/lldb/Target/Process.h index be72b9a9c747a..f85069ea09067 100644 --- a/include/lldb/Target/Process.h +++ b/include/lldb/Target/Process.h @@ -1,9 +1,8 @@ //===-- Process.h -----------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -29,14 +28,13 @@ #include "lldb/Core/ThreadSafeValue.h" #include "lldb/Core/UserSettingsController.h" #include "lldb/Host/HostThread.h" +#include "lldb/Host/ProcessLaunchInfo.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" -#include "lldb/Target/ProcessInfo.h" -#include "lldb/Target/ProcessLaunchInfo.h" #include "lldb/Target/QueueList.h" #include "lldb/Target/ThreadList.h" #include "lldb/Utility/ArchSpec.h" @@ -44,9 +42,11 @@ #include "lldb/Utility/Event.h" #include "lldb/Utility/Listener.h" #include "lldb/Utility/NameMatches.h" +#include "lldb/Utility/ProcessInfo.h" #include "lldb/Utility/Status.h" #include "lldb/Utility/StructuredData.h" #include "lldb/Utility/TraceOptions.h" +#include "lldb/Utility/UserIDResolver.h" #include "lldb/lldb-private.h" #include "llvm/ADT/ArrayRef.h" @@ -56,9 +56,7 @@ namespace lldb_private { template <typename B, typename S> struct Range; -//---------------------------------------------------------------------- // ProcessProperties -//---------------------------------------------------------------------- class ProcessProperties : public Properties { public: // Pass nullptr for "process" if the ProcessProperties are to be the global @@ -68,36 +66,22 @@ public: ~ProcessProperties() override; bool GetDisableMemoryCache() const; - uint64_t GetMemoryCacheLineSize() const; - Args GetExtraStartupCommands() const; - void SetExtraStartupCommands(const Args &args); - FileSpec GetPythonOSPluginPath() const; - void SetPythonOSPluginPath(const FileSpec &file); - bool GetIgnoreBreakpointsInExpressions() const; - void SetIgnoreBreakpointsInExpressions(bool ignore); - bool GetUnwindOnErrorInExpressions() const; - void SetUnwindOnErrorInExpressions(bool ignore); - bool GetStopOnSharedLibraryEvents() const; - void SetStopOnSharedLibraryEvents(bool stop); - bool GetDetachKeepsStopped() const; - void SetDetachKeepsStopped(bool keep_stopped); - bool GetWarningsOptimization() const; - bool GetStopOnExec() const; + std::chrono::seconds GetUtilityExpressionTimeout() const; protected: static void OptionValueChangedCallback(void *baton, @@ -108,68 +92,9 @@ protected: typedef std::shared_ptr<ProcessProperties> ProcessPropertiesSP; -//---------------------------------------------------------------------- -// ProcessInstanceInfo -// -// Describes an existing process and any discoverable information that pertains -// to that process. -//---------------------------------------------------------------------- -class ProcessInstanceInfo : public ProcessInfo { -public: - ProcessInstanceInfo() - : ProcessInfo(), m_euid(UINT32_MAX), m_egid(UINT32_MAX), - m_parent_pid(LLDB_INVALID_PROCESS_ID) {} - - ProcessInstanceInfo(const char *name, const ArchSpec &arch, lldb::pid_t pid) - : ProcessInfo(name, arch, pid), m_euid(UINT32_MAX), m_egid(UINT32_MAX), - m_parent_pid(LLDB_INVALID_PROCESS_ID) {} - - void Clear() { - ProcessInfo::Clear(); - m_euid = UINT32_MAX; - m_egid = UINT32_MAX; - m_parent_pid = LLDB_INVALID_PROCESS_ID; - } - - uint32_t GetEffectiveUserID() const { return m_euid; } - - uint32_t GetEffectiveGroupID() const { return m_egid; } - - bool EffectiveUserIDIsValid() const { return m_euid != UINT32_MAX; } - - bool EffectiveGroupIDIsValid() const { return m_egid != UINT32_MAX; } - - void SetEffectiveUserID(uint32_t uid) { m_euid = uid; } - - void SetEffectiveGroupID(uint32_t gid) { m_egid = gid; } - - lldb::pid_t GetParentProcessID() const { return m_parent_pid; } - - void SetParentProcessID(lldb::pid_t pid) { m_parent_pid = pid; } - - bool ParentProcessIDIsValid() const { - return m_parent_pid != LLDB_INVALID_PROCESS_ID; - } - - void Dump(Stream &s, Platform *platform) const; - - static void DumpTableHeader(Stream &s, Platform *platform, bool show_args, - bool verbose); - - void DumpAsTableRow(Stream &s, Platform *platform, bool show_args, - bool verbose) const; - -protected: - uint32_t m_euid; - uint32_t m_egid; - lldb::pid_t m_parent_pid; -}; - -//---------------------------------------------------------------------- // ProcessAttachInfo // // Describes any information that is required to attach to a process. -//---------------------------------------------------------------------- class ProcessAttachInfo : public ProcessInstanceInfo { public: @@ -299,94 +224,6 @@ public: lldb_private::LazyBool disable_aslr; }; -//---------------------------------------------------------------------- -// ProcessInstanceInfoMatch -// -// A class to help matching one ProcessInstanceInfo to another. -//---------------------------------------------------------------------- - -class ProcessInstanceInfoMatch { -public: - ProcessInstanceInfoMatch() - : m_match_info(), m_name_match_type(NameMatch::Ignore), - m_match_all_users(false) {} - - ProcessInstanceInfoMatch(const char *process_name, - 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, - FileSpec::Style::native); - } - - ProcessInstanceInfo &GetProcessInfo() { return m_match_info; } - - const ProcessInstanceInfo &GetProcessInfo() const { return m_match_info; } - - bool GetMatchAllUsers() const { return m_match_all_users; } - - void SetMatchAllUsers(bool b) { m_match_all_users = b; } - - NameMatch GetNameMatchType() const { return m_name_match_type; } - - void SetNameMatchType(NameMatch name_match_type) { - m_name_match_type = name_match_type; - } - - bool NameMatches(const char *process_name) const; - - bool Matches(const ProcessInstanceInfo &proc_info) const; - - bool MatchAllProcesses() const; - void Clear(); - -protected: - ProcessInstanceInfo m_match_info; - NameMatch m_name_match_type; - bool m_match_all_users; -}; - -class ProcessInstanceInfoList { -public: - ProcessInstanceInfoList() = default; - - void Clear() { m_infos.clear(); } - - size_t GetSize() { return m_infos.size(); } - - void Append(const ProcessInstanceInfo &info) { m_infos.push_back(info); } - - const char *GetProcessNameAtIndex(size_t idx) { - return ((idx < m_infos.size()) ? m_infos[idx].GetName() : nullptr); - } - - size_t GetProcessNameLengthAtIndex(size_t idx) { - return ((idx < m_infos.size()) ? m_infos[idx].GetNameLength() : 0); - } - - lldb::pid_t GetProcessIDAtIndex(size_t idx) { - return ((idx < m_infos.size()) ? m_infos[idx].GetProcessID() : 0); - } - - bool GetInfoAtIndex(size_t idx, ProcessInstanceInfo &info) { - if (idx < m_infos.size()) { - info = m_infos[idx]; - return true; - } - return false; - } - - // You must ensure "idx" is valid before calling this function - const ProcessInstanceInfo &GetProcessInfoAtIndex(size_t idx) const { - assert(idx < m_infos.size()); - return m_infos[idx]; - } - -protected: - typedef std::vector<ProcessInstanceInfo> collection; - collection m_infos; -}; - // 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.) @@ -511,10 +348,8 @@ inline bool operator!=(const ProcessModID &lhs, const ProcessModID &rhs) { return (!lhs.StopIDEqual(rhs) || !lhs.MemoryIDEqual(rhs)); } -//---------------------------------------------------------------------- -/// @class Process Process.h "lldb/Target/Process.h" +/// \class Process Process.h "lldb/Target/Process.h" /// A plug-in interface definition class for debugging a process. -//---------------------------------------------------------------------- class Process : public std::enable_shared_from_this<Process>, public ProcessProperties, public UserID, @@ -530,9 +365,7 @@ class Process : public std::enable_shared_from_this<Process>, friend class ThreadList; public: - //------------------------------------------------------------------ /// Broadcaster event bits definitions. - //------------------------------------------------------------------ enum { eBroadcastBitStateChanged = (1 << 0), eBroadcastBitInterrupt = (1 << 1), @@ -548,9 +381,7 @@ public: eBroadcastInternalStateControlResume = (1 << 2) }; - //------------------------------------------------------------------ /// Process warning types. - //------------------------------------------------------------------ enum Warnings { eWarningsOptimization = 1 }; typedef Range<lldb::addr_t, lldb::addr_t> LoadRange; @@ -570,14 +401,11 @@ public: return GetStaticBroadcasterClass(); } -//------------------------------------------------------------------ /// A notification structure that can be used by clients to listen /// for changes in a process's lifetime. /// -/// @see RegisterNotificationCallbacks (const Notifications&) @see +/// \see RegisterNotificationCallbacks (const Notifications&) @see /// UnregisterNotificationCallbacks (const Notifications&) -//------------------------------------------------------------------ -#ifndef SWIG typedef struct { void *baton; void (*initialize)(void *baton, Process *process); @@ -594,9 +422,9 @@ public: ~ProcessEventData() override; - static const ConstString &GetFlavorString(); + static ConstString GetFlavorString(); - const ConstString &GetFlavor() const override; + ConstString GetFlavor() const override; lldb::ProcessSP GetProcessSP() const { return m_process_wp.lock(); } @@ -662,27 +490,20 @@ public: DISALLOW_COPY_AND_ASSIGN(ProcessEventData); }; -#endif // SWIG - //------------------------------------------------------------------ /// Construct with a shared pointer to a target, and the Process listener. /// Uses the Host UnixSignalsSP by default. - //------------------------------------------------------------------ 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. - //------------------------------------------------------------------ Process(lldb::TargetSP target_sp, lldb::ListenerSP listener_sp, const lldb::UnixSignalsSP &unix_signals_sp); - //------------------------------------------------------------------ /// Destructor. /// /// The destructor is virtual since this class is designed to be inherited /// from by the plug-in instance. - //------------------------------------------------------------------ ~Process() override; static void SettingsInitialize(); @@ -691,7 +512,6 @@ public: static const ProcessPropertiesSP &GetGlobalProperties(); - //------------------------------------------------------------------ /// Find a Process plug-in that can debug \a module using the currently /// selected architecture. /// @@ -699,22 +519,20 @@ public: /// Process plug-in interface and returns the first instance that can debug /// the file. /// - /// @param[in] module_sp + /// \param[in] module_sp /// The module shared pointer that this process will debug. /// - /// @param[in] plugin_name + /// \param[in] plugin_name /// If nullptr, select the best plug-in for the binary. If non-nullptr /// then look for a plugin whose PluginInfo's name matches /// this string. /// - /// @see Process::CanDebug () - //------------------------------------------------------------------ + /// \see Process::CanDebug () static lldb::ProcessSP FindPlugin(lldb::TargetSP target_sp, llvm::StringRef plugin_name, lldb::ListenerSP listener_sp, const FileSpec *crash_file_path); - //------------------------------------------------------------------ /// Static function that can be used with the \b host function /// Host::StartMonitoringChildProcess (). /// @@ -725,7 +543,6 @@ public: /// callback = Process::SetHostProcessExitStatus /// pid = Process::GetID() /// monitor_signals = false - //------------------------------------------------------------------ static bool SetProcessExitStatus(lldb::pid_t pid, // The process ID we want to monitor bool exited, @@ -738,38 +555,31 @@ public: uint32_t GetUniqueID() const { return m_process_unique_id; } - //------------------------------------------------------------------ /// 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. /// - /// @return + /// \return /// Returns \b true if this Process plug-in instance can /// debug the executable, \b false otherwise. - //------------------------------------------------------------------ virtual bool CanDebug(lldb::TargetSP target, bool plugin_specified_by_name) = 0; - //------------------------------------------------------------------ /// This object is about to be destroyed, do any necessary cleanup. /// /// Subclasses that override this method should always call this superclass /// method. - //------------------------------------------------------------------ virtual void Finalize(); - //------------------------------------------------------------------ /// Return whether this object is valid (i.e. has not been finalized.) /// - /// @return + /// \return /// Returns \b true if this Process has not been finalized /// and \b false otherwise. - //------------------------------------------------------------------ bool IsValid() const { return !m_finalize_called; } - //------------------------------------------------------------------ /// Return a multi-word command object that can be used to expose plug-in /// specific commands. /// @@ -778,14 +588,12 @@ public: /// /// (lldb) process command <args> /// - /// @return + /// \return /// A CommandObject which can be one of the concrete subclasses /// of CommandObject like CommandObjectRaw, CommandObjectParsed, /// or CommandObjectMultiword. - //------------------------------------------------------------------ virtual CommandObject *GetPluginCommandObject() { return nullptr; } - //------------------------------------------------------------------ /// Launch a new process. /// /// Launch a new process by spawning a new process using the target object's @@ -798,14 +606,13 @@ public: /// launching. If DoLaunch returns \b true, then Process::DidLaunch() will /// be called. /// - /// @param[in] launch_info + /// \param[in] launch_info /// Details regarding the environment, STDIN/STDOUT/STDERR /// redirection, working path, etc. related to the requested launch. /// - /// @return + /// \return /// An error object. Call GetID() to get the process ID if /// the error object is success. - //------------------------------------------------------------------ virtual Status Launch(ProcessLaunchInfo &launch_info); virtual Status LoadCore(); @@ -818,7 +625,6 @@ public: return error; } - //------------------------------------------------------------------ // 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 @@ -833,27 +639,23 @@ public: // 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 + /// \param[in] platform /// The platform fetching the UtilityFunction. - /// @param[in] factory + /// \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 + /// \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 @@ -861,29 +663,24 @@ public: /// 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(); - //------------------------------------------------------------------ // Returns AUXV structure found in many ELF-based environments. // // The default action is to return an empty data buffer. // - // @return - // A data buffer containing the contents of the AUXV data. - //------------------------------------------------------------------ - virtual const lldb::DataBufferSP GetAuxvData(); + // \return + // A data extractor containing the contents of the AUXV data. + virtual DataExtractor 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. /// - /// @return + /// \return /// The number of shared libraries that were loaded - //------------------------------------------------------------------ virtual size_t LoadModules() { return 0; } virtual size_t LoadModules(LoadedModuleInfoList &) { return 0; } @@ -892,16 +689,13 @@ protected: virtual JITLoaderList &GetJITLoaders(); public: - //------------------------------------------------------------------ /// Get the system runtime plug-in for this process. /// - /// @return + /// \return /// Returns a pointer to the SystemRuntime plugin for this Process /// if one is available. Else returns nullptr. - //------------------------------------------------------------------ virtual SystemRuntime *GetSystemRuntime(); - //------------------------------------------------------------------ /// Attach to an existing process using the process attach info. /// /// This function is not meant to be overridden by Process subclasses. It @@ -910,36 +704,32 @@ public: /// char *) will be called to actually do the attach. If DoAttach returns \b /// true, then Process::DidAttach() will be called. /// - /// @param[in] pid + /// \param[in] pid /// The process ID that we should attempt to attach to. /// - /// @return + /// \return /// Returns \a pid if attaching was successful, or /// LLDB_INVALID_PROCESS_ID if attaching fails. - //------------------------------------------------------------------ virtual Status Attach(ProcessAttachInfo &attach_info); - //------------------------------------------------------------------ /// Attach to a remote system via a URL /// - /// @param[in] strm + /// \param[in] strm /// A stream where output intended for the user /// (if the driver has a way to display that) generated during /// the connection. This may be nullptr if no output is needed.A /// - /// @param[in] remote_url + /// \param[in] remote_url /// The URL format that we are connecting to. /// - /// @return + /// \return /// Returns an error object. - //------------------------------------------------------------------ virtual Status ConnectRemote(Stream *strm, llvm::StringRef remote_url); bool GetShouldDetach() const { return m_should_detach; } void SetShouldDetach(bool b) { m_should_detach = b; } - //------------------------------------------------------------------ /// Get the image information address for the current process. /// /// Some runtimes have system functions that can help dynamic loaders locate @@ -948,14 +738,12 @@ public: /// opposed to the DynamicLoader interface) to ensure that remote debugging /// can take advantage of this functionality. /// - /// @return + /// \return /// The address of the dynamic loader information, or /// LLDB_INVALID_ADDRESS if this is not supported by this /// interface. - //------------------------------------------------------------------ virtual lldb::addr_t GetImageInfoAddress(); - //------------------------------------------------------------------ /// Called when the process is about to broadcast a public stop. /// /// There are public and private stops. Private stops are when the process @@ -968,49 +756,39 @@ public: /// 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() {} -//------------------------------------------------------------------ /// Register for process and thread notifications. /// /// Clients can register notification callbacks by filling out a /// Process::Notifications structure and calling this function. /// -/// @param[in] callbacks +/// \param[in] callbacks /// A structure that contains the notification baton and /// callback functions. /// -/// @see Process::Notifications -//------------------------------------------------------------------ -#ifndef SWIG +/// \see Process::Notifications void RegisterNotificationCallbacks(const Process::Notifications &callbacks); -#endif -//------------------------------------------------------------------ /// Unregister for process and thread notifications. /// /// Clients can unregister notification callbacks by passing a copy of the /// original baton and callbacks in \a callbacks. /// -/// @param[in] callbacks +/// \param[in] callbacks /// A structure that contains the notification baton and /// callback functions. /// -/// @return +/// \return /// Returns \b true if the notification callbacks were /// successfully removed from the process, \b false otherwise. /// -/// @see Process::Notifications -//------------------------------------------------------------------ -#ifndef SWIG +/// \see Process::Notifications bool UnregisterNotificationCallbacks(const Process::Notifications &callbacks); -#endif //================================================================== // Built in Process Control functions //================================================================== - //------------------------------------------------------------------ /// Resumes all of a process's threads as configured using the Thread run /// control functions. /// @@ -1030,18 +808,16 @@ public: /// use PrivateResume (though you should only do that from inside the /// Process class. /// - /// @return + /// \return /// Returns an error object. /// - /// @see Thread:Resume() - /// @see Thread:Step() - /// @see Thread:Suspend() - //------------------------------------------------------------------ + /// \see Thread:Resume() + /// \see Thread:Step() + /// \see Thread:Suspend() Status Resume(); Status ResumeSynchronous(Stream *stream); - //------------------------------------------------------------------ /// Halts a running process. /// /// This function is not meant to be overridden by Process subclasses. If @@ -1049,39 +825,35 @@ public: /// GetInterrupted will be broadcast. If false, we will halt the process /// with no events generated by the halt. /// - /// @param[in] clear_thread_plans + /// \param[in] clear_thread_plans /// If true, when the process stops, clear all thread plans. /// - /// @param[in] use_run_lock + /// \param[in] use_run_lock /// Whether to release the run lock after the stop. /// - /// @return + /// \return /// Returns an error object. If the error is empty, the process is /// halted. /// otherwise the halt has failed. - //------------------------------------------------------------------ Status Halt(bool clear_thread_plans = false, bool use_run_lock = true); - //------------------------------------------------------------------ /// Detaches from a running or stopped process. /// /// This function is not meant to be overridden by Process subclasses. /// - /// @param[in] keep_stopped + /// \param[in] keep_stopped /// If true, don't resume the process on detach. /// - /// @return + /// \return /// Returns an error object. - //------------------------------------------------------------------ Status Detach(bool keep_stopped); - //------------------------------------------------------------------ /// 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. /// - /// @param[in] force_kill + /// \param[in] force_kill /// Whether lldb should force a kill (instead of a detach) from /// the inferior process. Normally if lldb launched a binary and /// Destory is called, lldb kills it. If lldb attached to a @@ -1089,19 +861,16 @@ public: /// this behavior needs to be over-ridden, this is the bool that /// can be used. /// - /// @return + /// \return /// Returns an error object. - //------------------------------------------------------------------ Status Destroy(bool force_kill); - //------------------------------------------------------------------ /// Sends a process a UNIX signal \a signal. /// /// This function is not meant to be overridden by Process subclasses. /// - /// @return + /// \return /// Returns an error object. - //------------------------------------------------------------------ Status Signal(int signal); void SetUnixSignals(lldb::UnixSignalsSP &&signals_sp); @@ -1112,65 +881,57 @@ public: // Plug-in Process Control Overrides //================================================================== - //------------------------------------------------------------------ /// Called before attaching to a process. /// /// Allow Process plug-ins to execute some code before attaching a process. /// - /// @return + /// \return /// Returns an error object. - //------------------------------------------------------------------ virtual Status WillAttachToProcessWithID(lldb::pid_t pid) { return Status(); } - //------------------------------------------------------------------ /// Called before attaching to a process. /// /// Allow Process plug-ins to execute some code before attaching a process. /// - /// @return + /// \return /// Returns an error object. - //------------------------------------------------------------------ virtual Status WillAttachToProcessWithName(const char *process_name, bool wait_for_launch) { return Status(); } - //------------------------------------------------------------------ /// Attach to a remote system via a URL /// - /// @param[in] strm + /// \param[in] strm /// A stream where output intended for the user /// (if the driver has a way to display that) generated during /// the connection. This may be nullptr if no output is needed.A /// - /// @param[in] remote_url + /// \param[in] remote_url /// The URL format that we are connecting to. /// - /// @return + /// \return /// Returns an error object. - //------------------------------------------------------------------ virtual Status DoConnectRemote(Stream *strm, llvm::StringRef remote_url) { Status error; error.SetErrorString("remote connections are not supported"); return error; } - //------------------------------------------------------------------ /// Attach to an existing process using a process ID. /// - /// @param[in] pid + /// \param[in] pid /// The process ID that we should attempt to attach to. /// - /// @param[in] attach_info + /// \param[in] attach_info /// Information on how to do the attach. For example, GetUserID() /// will return the uid to attach as. /// - /// @return + /// \return /// Returns a successful Status attaching was successful, or /// an appropriate (possibly platform-specific) error code if /// attaching fails. /// hanming : need flag - //------------------------------------------------------------------ virtual Status DoAttachToProcessWithID(lldb::pid_t pid, const ProcessAttachInfo &attach_info) { Status error; @@ -1180,21 +941,19 @@ public: return error; } - //------------------------------------------------------------------ /// Attach to an existing process using a partial process name. /// - /// @param[in] process_name + /// \param[in] process_name /// The name of the process to attach to. /// - /// @param[in] attach_info + /// \param[in] attach_info /// Information on how to do the attach. For example, GetUserID() /// will return the uid to attach as. /// - /// @return + /// \return /// Returns a successful Status attaching was successful, or /// an appropriate (possibly platform-specific) error code if /// attaching fails. - //------------------------------------------------------------------ virtual Status DoAttachToProcessWithName(const char *process_name, const ProcessAttachInfo &attach_info) { @@ -1203,63 +962,53 @@ public: return error; } - //------------------------------------------------------------------ /// Called after attaching a process. /// - /// @param[in] process_arch + /// \param[in] process_arch /// 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. - //------------------------------------------------------------------ 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. - //------------------------------------------------------------------ virtual void DidExec(); - //------------------------------------------------------------------ /// 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. /// - /// @return + /// \return /// Returns an error object. - //------------------------------------------------------------------ virtual Status WillLaunch(Module *module) { return Status(); } - //------------------------------------------------------------------ /// 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. /// - /// @param[in] exe_module + /// \param[in] exe_module /// The module from which to extract the file specification and /// launch. /// - /// @param[in] launch_info + /// \param[in] launch_info /// Details (e.g. arguments, stdio redirection, etc.) for the /// requested launch. /// - /// @return + /// \return /// An Status instance indicating success or failure of the /// operation. - //------------------------------------------------------------------ virtual Status DoLaunch(Module *exe_module, ProcessLaunchInfo &launch_info) { Status error; error.SetErrorStringWithFormat( @@ -1268,24 +1017,19 @@ public: return error; } - //------------------------------------------------------------------ /// Called 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. /// - /// @return + /// \return /// Returns an error object. - //------------------------------------------------------------------ virtual Status WillResume() { return Status(); } - //------------------------------------------------------------------ /// Resumes all of a process's threads as configured using the Thread run /// control functions. /// @@ -1294,14 +1038,13 @@ public: /// process is resumed. If no run control action is given to a thread it /// will be resumed by default. /// - /// @return + /// \return /// Returns \b true if the process successfully resumes using /// the thread run control actions, \b false otherwise. /// - /// @see Thread:Resume() - /// @see Thread:Step() - /// @see Thread:Suspend() - //------------------------------------------------------------------ + /// \see Thread:Resume() + /// \see Thread:Step() + /// \see Thread:Suspend() virtual Status DoResume() { Status error; error.SetErrorStringWithFormat( @@ -1310,24 +1053,19 @@ public: return error; } - //------------------------------------------------------------------ /// Called 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. /// - /// @return + /// \return /// Returns an error object. - //------------------------------------------------------------------ virtual Status WillHalt() { return Status(); } - //------------------------------------------------------------------ /// Halts a running process. /// /// DoHalt must produce one and only one stop StateChanged event if it @@ -1336,14 +1074,13 @@ public: /// Otherwise, you must generate the event manually. This function is called /// from the context of the private state thread. /// - /// @param[out] caused_stop + /// \param[out] caused_stop /// If true, then this Halt caused the stop, otherwise, the /// process was already stopped. /// - /// @return + /// \return /// Returns \b true if the process successfully halts, \b false /// otherwise. - //------------------------------------------------------------------ virtual Status DoHalt(bool &caused_stop) { Status error; error.SetErrorStringWithFormat( @@ -1352,31 +1089,25 @@ public: return error; } - //------------------------------------------------------------------ /// Called 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. /// - /// @return + /// \return /// Returns an error object. - //------------------------------------------------------------------ virtual Status WillDetach() { return Status(); } - //------------------------------------------------------------------ /// Detaches from a running or stopped process. /// - /// @return + /// \return /// Returns \b true if the process successfully detaches, \b /// false otherwise. - //------------------------------------------------------------------ virtual Status DoDetach(bool keep_stopped) { Status error; error.SetErrorStringWithFormat( @@ -1385,35 +1116,29 @@ public: return error; } - //------------------------------------------------------------------ /// Called after detaching from a process. /// /// Allow Process plug-ins to execute some code after detaching from a /// process. - //------------------------------------------------------------------ virtual void DidDetach() {} virtual bool DetachRequiresHalt() { return false; } - //------------------------------------------------------------------ /// Called before sending a signal to a process. /// /// Allow Process plug-ins to execute some code before sending a signal to a /// process. /// - /// @return + /// \return /// Returns no error if it is safe to proceed with a call to /// Process::DoSignal(int), otherwise an error describing what /// prevents the signal from being sent. - //------------------------------------------------------------------ virtual Status WillSignal() { return Status(); } - //------------------------------------------------------------------ /// Sends a process a UNIX signal \a signal. /// - /// @return + /// \return /// Returns an error object. - //------------------------------------------------------------------ virtual Status DoSignal(int signal) { Status error; error.SetErrorStringWithFormat( @@ -1430,15 +1155,12 @@ public: virtual bool DestroyRequiresHalt() { return true; } - //------------------------------------------------------------------ /// Called 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() {} - //------------------------------------------------------------------ /// Currently called as part of ShouldStop. /// FIXME: Should really happen when the target stops before the /// event is taken from the queue... @@ -1449,10 +1171,8 @@ public: /// 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 @@ -1461,31 +1181,25 @@ public: /// platform that might itself be running natively, but have different /// heuristics for figuring out which OS is is emulating. /// - /// @return + /// \return /// Returns the version tuple of the host OS. In case of failure an empty /// VersionTuple is returner. - //------------------------------------------------------------------ virtual llvm::VersionTuple GetHostOSVersion() { return llvm::VersionTuple(); } - //------------------------------------------------------------------ /// Get the target object pointer for this module. /// - /// @return + /// \return /// A Target object pointer to the target that owns this /// module. - //------------------------------------------------------------------ Target &GetTarget() { return *m_target_wp.lock(); } - //------------------------------------------------------------------ /// Get the const target object pointer for this module. /// - /// @return + /// \return /// A const Target object pointer to the target that owns this /// module. - //------------------------------------------------------------------ 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 @@ -1494,17 +1208,14 @@ public: /// 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(); - //------------------------------------------------------------------ /// Get accessor for the current process state. /// - /// @return + /// \return /// The current state of the process. /// - /// @see lldb::StateType - //------------------------------------------------------------------ + /// \see lldb::StateType lldb::StateType GetState(); lldb::ExpressionResults @@ -1523,15 +1234,12 @@ public: void SendAsyncInterrupt(); - //------------------------------------------------------------------ // 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. - //------------------------------------------------------------------ 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 @@ -1544,21 +1252,20 @@ public: /// memory and return a concise summary sufficient for the DynamicLoader /// plugin. /// - /// @param [in] image_list_address + /// \param [in] image_list_address /// The address where the table of shared libraries is stored in memory, /// if that is appropriate for this platform. Else this may be /// passed as LLDB_INVALID_ADDRESS. /// - /// @param [in] image_count + /// \param [in] image_count /// The number of shared libraries that are present in this process, if /// that is appropriate for this platofrm Else this may be passed as /// LLDB_INVALID_ADDRESS. /// - /// @return + /// \return /// A StructureDataSP object which, if non-empty, will contain the /// information the DynamicLoader needs to get the initial scan of /// solibs resolved. - //------------------------------------------------------------------ virtual lldb_private::StructuredData::ObjectSP GetLoadedDynamicLibrariesInfos(lldb::addr_t image_list_address, lldb::addr_t image_count) { @@ -1579,60 +1286,50 @@ public: return StructuredData::ObjectSP(); } - //------------------------------------------------------------------ // 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. - //------------------------------------------------------------------ virtual lldb_private::StructuredData::ObjectSP GetSharedCacheInfo() { return StructuredData::ObjectSP(); } - //------------------------------------------------------------------ /// 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. /// - /// @param [in] sc + /// \param [in] sc /// A SymbolContext with eSymbolContextFunction and eSymbolContextModule /// pre-computed. - //------------------------------------------------------------------ void PrintWarningOptimization(const SymbolContext &sc); virtual bool GetProcessInfo(ProcessInstanceInfo &info); public: - //------------------------------------------------------------------ /// Get the exit status for a process. /// - /// @return + /// \return /// The process's return code, or -1 if the current process /// state is not eStateExited. - //------------------------------------------------------------------ int GetExitStatus(); - //------------------------------------------------------------------ /// Get a textual description of what the process exited. /// - /// @return + /// \return /// The textual description of why the process exited, or nullptr /// if there is no description available. - //------------------------------------------------------------------ const char *GetExitDescription(); virtual void DidExit() {} - //------------------------------------------------------------------ /// Get the Modification ID of the process. /// - /// @return + /// \return /// The modification ID of the process. - //------------------------------------------------------------------ ProcessModID GetModID() const { return m_mod_id; } const ProcessModID &GetModIDRef() const { return m_mod_id; } @@ -1653,7 +1350,6 @@ public: return m_mod_id.GetStopEventForStopID(stop_id); } - //------------------------------------------------------------------ /// Set accessor for the process exit status (return code). /// /// Sometimes a child exits and the exit can be detected by global functions @@ -1663,66 +1359,58 @@ public: /// Setting this will cause a eStateExited event to be posted to the process /// event queue. /// - /// @param[in] exit_status + /// \param[in] exit_status /// The value for the process's return code. /// - /// @see lldb::StateType - //------------------------------------------------------------------ + /// \see lldb::StateType virtual bool SetExitStatus(int exit_status, const char *cstr); - //------------------------------------------------------------------ /// Check if a process is still alive. /// - /// @return + /// \return /// Returns \b true if the process is still valid, \b false /// otherwise. - //------------------------------------------------------------------ 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 /// the core file. /// - /// @return + /// \return // true if the user should be warned about detaching from this process. - //------------------------------------------------------------------ virtual bool WarnBeforeDetach() const { return true; } - //------------------------------------------------------------------ /// 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. /// - /// @param[in] vm_addr + /// \param[in] vm_addr /// A virtual load address that indicates where to start reading /// memory from. /// - /// @param[in] size + /// \param[in] size /// The number of bytes to read. /// - /// @param[out] buf + /// \param[out] buf /// A byte buffer that is at least \a size bytes long that /// will receive the memory bytes. /// - /// @param[out] error + /// \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 + /// \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; - //------------------------------------------------------------------ /// Read of memory from a process. /// /// This function will read memory from the current process's address space @@ -1732,34 +1420,63 @@ public: /// subclasses should implement Process::DoReadMemory (lldb::addr_t, size_t, /// void *). /// - /// @param[in] vm_addr + /// \param[in] vm_addr /// A virtual load address that indicates where to start reading /// memory from. /// - /// @param[out] buf + /// \param[out] buf /// A byte buffer that is at least \a size bytes long that /// will receive the memory bytes. /// - /// @param[in] size + /// \param[in] size /// The number of bytes to read. /// - /// @param[out] error + /// \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 + /// \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 in the case of an error. - //------------------------------------------------------------------ virtual size_t ReadMemory(lldb::addr_t vm_addr, void *buf, size_t size, Status &error); - //------------------------------------------------------------------ + /// Read of memory from a process. + /// + /// This function has the same semantics of ReadMemory except that it + /// bypasses caching. + /// + /// \param[in] vm_addr + /// A virtual load address that indicates where to start reading + /// memory from. + /// + /// \param[out] buf + /// A byte buffer that is at least \a size bytes long that + /// will receive the memory bytes. + /// + /// \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 in the case of an error. + size_t ReadMemoryFromInferior(lldb::addr_t vm_addr, void *buf, size_t size, + Status &error); + /// Read a NULL terminated string from memory /// /// This function will read a cache page at a time until a NULL string @@ -1769,29 +1486,27 @@ public: /// terminated, and that no more than (max_bytes - type_width) bytes will be /// read. /// - /// @param[in] vm_addr + /// \param[in] vm_addr /// The virtual load address to start the memory read. /// - /// @param[in] str + /// \param[in] str /// A character buffer containing at least max_bytes. /// - /// @param[in] max_bytes + /// \param[in] max_bytes /// The maximum number of bytes to read. /// - /// @param[in] error + /// \param[in] error /// The error status of the read operation. /// - /// @param[in] type_width + /// \param[in] type_width /// The size of the null terminator (1 to 4 bytes per /// character). Defaults to 1. /// - /// @return + /// \return /// The error status or the number of bytes prior to the null terminator. - //------------------------------------------------------------------ size_t ReadStringFromMemory(lldb::addr_t vm_addr, char *str, size_t max_bytes, Status &error, size_t type_width = 1); - //------------------------------------------------------------------ /// Read a NULL terminated C string from memory /// /// This function will read a cache page at a time until the NULL @@ -1799,43 +1514,37 @@ public: /// 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); size_t ReadCStringFromMemory(lldb::addr_t vm_addr, std::string &out_str, Status &error); - size_t ReadMemoryFromInferior(lldb::addr_t vm_addr, void *buf, size_t size, - Status &error); - - //------------------------------------------------------------------ /// Reads an unsigned integer of the specified byte size from process /// memory. /// - /// @param[in] load_addr + /// \param[in] load_addr /// A load address of the integer to read. /// - /// @param[in] byte_size + /// \param[in] byte_size /// The size in byte of the integer to read. /// - /// @param[in] fail_value + /// \param[in] fail_value /// The value to return if we fail to read an integer. /// - /// @param[out] error + /// \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 + /// \return /// The unsigned integer that was read from the process memory /// space. If the integer was smaller than a uint64_t, any /// unused upper bytes will be zero filled. If the process /// byte order differs from the host byte order, the integer /// value will be appropriately byte swapped into host byte /// order. - //------------------------------------------------------------------ uint64_t ReadUnsignedIntegerFromMemory(lldb::addr_t load_addr, size_t byte_size, uint64_t fail_value, Status &error); @@ -1848,26 +1557,24 @@ public: bool WritePointerToMemory(lldb::addr_t vm_addr, lldb::addr_t ptr_value, Status &error); - //------------------------------------------------------------------ /// Actually do the writing of memory to a process. /// - /// @param[in] vm_addr + /// \param[in] vm_addr /// A virtual load address that indicates where to start writing /// memory to. /// - /// @param[in] buf + /// \param[in] buf /// A byte buffer that is at least \a size bytes long that /// contains the data to write. /// - /// @param[in] size + /// \param[in] size /// The number of bytes to write. /// - /// @param[out] error + /// \param[out] error /// An error value in case the memory write fails. /// - /// @return + /// \return /// The number of bytes that were actually written. - //------------------------------------------------------------------ virtual size_t DoWriteMemory(lldb::addr_t vm_addr, const void *buf, size_t size, Status &error) { error.SetErrorStringWithFormat( @@ -1876,7 +1583,6 @@ public: return 0; } - //------------------------------------------------------------------ /// Write all or part of a scalar value to memory. /// /// The value contained in \a scalar will be swapped to match the byte order @@ -1886,14 +1592,14 @@ public: /// 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 + /// \param[in] vm_addr /// A virtual load address that indicates where to start writing /// memory to. /// - /// @param[in] scalar + /// \param[in] scalar /// The scalar to write to the debugged process. /// - /// @param[in] size + /// \param[in] size /// This value can be smaller or larger than the scalar value /// itself. If \a size is smaller than the size of \a scalar, /// the least significant bytes in \a scalar will be used. If @@ -1901,12 +1607,11 @@ public: /// the extra space will be padded with zeros. If \a size is /// set to UINT32_MAX, then the size of \a scalar will be used. /// - /// @param[out] error + /// \param[out] error /// An error value in case the memory write fails. /// - /// @return + /// \return /// The number of bytes that were actually written. - //------------------------------------------------------------------ size_t WriteScalarToMemory(lldb::addr_t vm_addr, const Scalar &scalar, size_t size, Status &error); @@ -1914,7 +1619,6 @@ public: bool is_signed, Scalar &scalar, Status &error); - //------------------------------------------------------------------ /// Write memory to a process. /// /// This function will write memory to the current process's address space @@ -1925,38 +1629,35 @@ public: /// subclasses should implement Process::DoWriteMemory (lldb::addr_t, /// size_t, void *). /// - /// @param[in] vm_addr + /// \param[in] vm_addr /// A virtual load address that indicates where to start writing /// memory to. /// - /// @param[in] buf + /// \param[in] buf /// A byte buffer that is at least \a size bytes long that /// contains the data to write. /// - /// @param[in] size + /// \param[in] size /// The number of bytes to write. /// - /// @return + /// \return /// The number of bytes that were actually written. - //------------------------------------------------------------------ // TODO: change this to take an ArrayRef<uint8_t> size_t WriteMemory(lldb::addr_t vm_addr, const void *buf, size_t size, Status &error); - //------------------------------------------------------------------ /// 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. /// - /// @param[in] size + /// \param[in] size /// The size of the allocation requested. /// - /// @return + /// \return /// The address of the allocated buffer in the process, or /// LLDB_INVALID_ADDRESS if the allocation failed. - //------------------------------------------------------------------ virtual lldb::addr_t DoAllocateMemory(size_t size, uint32_t permissions, Status &error) { @@ -1968,32 +1669,29 @@ public: 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. /// - /// @param[in] size + /// \param[in] size /// The size of the allocation requested. /// - /// @param[in] permissions + /// \param[in] permissions /// Or together any of the lldb::Permissions bits. The permissions on /// a given memory allocation can't be changed after allocation. Note /// that a block that isn't set writable can still be written on from /// lldb, /// just not by the process itself. /// - /// @param[in,out] error + /// \param[in,out] error /// An error object to fill in if things go wrong. - /// @return + /// \return /// The address of the allocated buffer in the process, or /// LLDB_INVALID_ADDRESS if the allocation failed. - //------------------------------------------------------------------ lldb::addr_t AllocateMemory(size_t size, uint32_t permissions, Status &error); - //------------------------------------------------------------------ /// The public interface to allocating memory in the process, this also /// clears the allocated memory. /// @@ -2001,43 +1699,39 @@ public: /// can't rely on the generic function calling mechanism, since that /// requires this function. /// - /// @param[in] size + /// \param[in] size /// The size of the allocation requested. /// - /// @param[in] permissions + /// \param[in] permissions /// Or together any of the lldb::Permissions bits. The permissions on /// a given memory allocation can't be changed after allocation. Note /// that a block that isn't set writable can still be written on from /// lldb, /// just not by the process itself. /// - /// @param[in/out] error + /// \param[in/out] error /// An error object to fill in if things go wrong. - /// @return + /// \return /// The address of the allocated buffer in the process, or /// LLDB_INVALID_ADDRESS if the allocation failed. - //------------------------------------------------------------------ lldb::addr_t CallocateMemory(size_t size, uint32_t permissions, Status &error); - //------------------------------------------------------------------ /// Resolve dynamically loaded indirect functions. /// - /// @param[in] address + /// \param[in] address /// The load address of the indirect function to resolve. /// - /// @param[out] error + /// \param[out] error /// An error value in case the resolve fails. /// - /// @return + /// \return /// The address of the resolved function. /// LLDB_INVALID_ADDRESS if the resolution failed. - //------------------------------------------------------------------ virtual lldb::addr_t ResolveIndirectFunction(const Address *address, Status &error); - //------------------------------------------------------------------ /// Locate the memory region that contains load_addr. /// /// If load_addr is within the address space the process has mapped @@ -2054,15 +1748,14 @@ public: /// GetMemoryRegionInfo will only return an error if it is unimplemented for /// the current process. /// - /// @param[in] load_addr + /// \param[in] load_addr /// The load address to query the range_info for. /// - /// @param[out] range_info + /// \param[out] range_info /// An range_info value containing the details of the range. /// - /// @return + /// \return /// An error value. - //------------------------------------------------------------------ virtual Status GetMemoryRegionInfo(lldb::addr_t load_addr, MemoryRegionInfo &range_info) { Status error; @@ -2070,16 +1763,14 @@ public: return error; } - //------------------------------------------------------------------ /// Obtain all the mapped memory regions within this process. /// - /// @param[out] region_list + /// \param[out] region_list /// A vector to contain MemoryRegionInfo objects for all mapped /// ranges. /// - /// @return + /// \return /// An error value. - //------------------------------------------------------------------ virtual Status GetMemoryRegions(lldb_private::MemoryRegionInfos ®ion_list); @@ -2102,7 +1793,6 @@ public: lldb::addr_t header_addr, size_t size_to_read = 512); - //------------------------------------------------------------------ /// 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 @@ -2110,81 +1800,68 @@ public: /// of memory at a given address or whether that page is /// readable/writable/executable by the process. /// - /// @param[in] load_addr + /// \param[in] load_addr /// The address of interest in the process. /// - /// @param[out] permissions + /// \param[out] permissions /// If this call returns successfully, this bitmask will have /// its Permissions bits set to indicate whether the region is /// readable/writable/executable. If this call fails, the /// bitmask values are undefined. /// - /// @return + /// \return /// Returns true if it was able to determine the attributes of the /// memory region. False if not. - //------------------------------------------------------------------ virtual bool GetLoadAddressPermissions(lldb::addr_t load_addr, uint32_t &permissions); - //------------------------------------------------------------------ /// Determines whether executing JIT-compiled code in this process is /// possible. /// - /// @return + /// \return /// True if execution of JIT code is possible; false otherwise. - //------------------------------------------------------------------ bool CanJIT(); - //------------------------------------------------------------------ /// Sets whether executing JIT-compiled code in this process is possible. /// - /// @param[in] can_jit + /// \param[in] can_jit /// True if execution of JIT code is possible; false otherwise. - //------------------------------------------------------------------ void SetCanJIT(bool can_jit); - //------------------------------------------------------------------ /// Determines whether executing function calls using the interpreter is /// possible for this process. /// - /// @return + /// \return /// True if possible; false otherwise. - //------------------------------------------------------------------ bool CanInterpretFunctionCalls() { return m_can_interpret_function_calls; } - //------------------------------------------------------------------ /// Sets whether executing function calls using the interpreter is possible /// for this process. /// - /// @param[in] can_interpret_function_calls + /// \param[in] can_interpret_function_calls /// True if possible; false otherwise. - //------------------------------------------------------------------ void SetCanInterpretFunctionCalls(bool can_interpret_function_calls) { m_can_interpret_function_calls = can_interpret_function_calls; } - //------------------------------------------------------------------ /// Sets whether executing code in this process is possible. This could be /// either through JIT or interpreting. /// - /// @param[in] can_run_code + /// \param[in] can_run_code /// True if execution of code is possible; false otherwise. - //------------------------------------------------------------------ void SetCanRunCode(bool can_run_code); - //------------------------------------------------------------------ /// Actually deallocate memory in the process. /// /// This function will deallocate memory in the process's address space that /// was allocated with AllocateMemory. /// - /// @param[in] ptr + /// \param[in] ptr /// A return value from AllocateMemory, pointing to the memory you /// want to deallocate. /// - /// @return + /// \return /// \btrue if the memory was deallocated, \bfalse otherwise. - //------------------------------------------------------------------ virtual Status DoDeallocateMemory(lldb::addr_t ptr) { Status error; error.SetErrorStringWithFormat( @@ -2193,22 +1870,19 @@ public: return error; } - //------------------------------------------------------------------ /// 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. /// - /// @param[in] ptr + /// \param[in] ptr /// A return value from AllocateMemory, pointing to the memory you /// want to deallocate. /// - /// @return + /// \return /// \btrue if the memory was deallocated, \bfalse otherwise. - //------------------------------------------------------------------ Status DeallocateMemory(lldb::addr_t ptr); - //------------------------------------------------------------------ /// Get any available STDOUT. /// /// Calling this method is a valid operation only if all of the following @@ -2225,21 +1899,19 @@ public: /// Events will be queued indicating that there is STDOUT available that can /// be retrieved using this function. /// - /// @param[out] buf + /// \param[out] buf /// A buffer that will receive any STDOUT bytes that are /// currently available. /// - /// @param[in] buf_size + /// \param[in] buf_size /// The size in bytes for the buffer \a buf. /// - /// @return + /// \return /// The number of bytes written into \a buf. If this value is /// equal to \a buf_size, another call to this function should /// be made to retrieve more STDOUT data. - //------------------------------------------------------------------ virtual size_t GetSTDOUT(char *buf, size_t buf_size, Status &error); - //------------------------------------------------------------------ /// Get any available STDERR. /// /// Calling this method is a valid operation only if all of the following @@ -2256,21 +1928,19 @@ public: /// Events will be queued indicating that there is STDERR available that can /// be retrieved using this function. /// - /// @param[in] buf + /// \param[in] buf /// A buffer that will receive any STDERR bytes that are /// currently available. /// - /// @param[out] buf_size + /// \param[out] buf_size /// The size in bytes for the buffer \a buf. /// - /// @return + /// \return /// The number of bytes written into \a buf. If this value is /// equal to \a buf_size, another call to this function should /// be made to retrieve more STDERR data. - //------------------------------------------------------------------ virtual size_t GetSTDERR(char *buf, size_t buf_size, Status &error); - //------------------------------------------------------------------ /// Puts data into this process's STDIN. /// /// Calling this method is a valid operation only if all of the following @@ -2279,42 +1949,37 @@ public: /// process was launched without supplying a valid file path /// for STDIN. /// - /// @param[in] buf + /// \param[in] buf /// A buffer that contains the data to write to the process's STDIN. /// - /// @param[in] buf_size + /// \param[in] buf_size /// The size in bytes for the buffer \a buf. /// - /// @return + /// \return /// The number of bytes written into \a buf. If this value is /// less than \a buf_size, another call to this function should /// be made to write the rest of the data. - //------------------------------------------------------------------ virtual size_t PutSTDIN(const char *buf, size_t buf_size, Status &error) { error.SetErrorString("stdin unsupported"); return 0; } - //------------------------------------------------------------------ /// Get any available profile data. /// - /// @param[out] buf + /// \param[out] buf /// A buffer that will receive any profile data bytes that are /// currently available. /// - /// @param[out] buf_size + /// \param[out] buf_size /// The size in bytes for the buffer \a buf. /// - /// @return + /// \return /// The number of bytes written into \a buf. If this value is /// equal to \a buf_size, another call to this function should /// be made to retrieve more profile data. - //------------------------------------------------------------------ virtual size_t GetAsyncProfileData(char *buf, size_t buf_size, Status &error); - //---------------------------------------------------------------------- // Process Breakpoints - //---------------------------------------------------------------------- size_t GetSoftwareBreakpointTrapOpcode(BreakpointSite *bp_site); virtual Status EnableBreakpointSite(BreakpointSite *bp_site) { @@ -2366,16 +2031,12 @@ public: lldb::user_id_t owner_loc_id, lldb::BreakpointSiteSP &bp_site_sp); - //---------------------------------------------------------------------- // Process Watchpoints (optional) - //---------------------------------------------------------------------- virtual Status EnableWatchpoint(Watchpoint *wp, bool notify = true); virtual Status DisableWatchpoint(Watchpoint *wp, bool notify = true); - //------------------------------------------------------------------ // Thread Queries - //------------------------------------------------------------------ virtual bool UpdateThreadList(ThreadList &old_thread_list, ThreadList &new_thread_list) = 0; @@ -2403,9 +2064,7 @@ public: // id will be used. uint32_t AssignIndexIDToThread(uint64_t thread_id); - //------------------------------------------------------------------ // Queue Queries - //------------------------------------------------------------------ void UpdateQueueListIfNeeded(); @@ -2419,9 +2078,7 @@ public: return m_queue_list.Queues(); } - //------------------------------------------------------------------ // Event Handling - //------------------------------------------------------------------ lldb::StateType GetNextEvent(lldb::EventSP &event_sp); // Returns the process state when it is stopped. If specified, event_sp_ptr @@ -2439,16 +2096,14 @@ public: uint32_t GetIOHandlerID() const { return m_iohandler_sync.GetValue(); } - //-------------------------------------------------------------------------------------- /// 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. /// - /// @param[in] timeout + /// \param[in] timeout /// The maximum time length to wait for the process to transition to the /// eStateRunning state. - //-------------------------------------------------------------------------------------- void SyncIOHandler(uint32_t iohandler_id, const Timeout<std::micro> &timeout); lldb::StateType GetStateChangedEvents( @@ -2456,27 +2111,25 @@ public: lldb::ListenerSP hijack_listener); // Pass an empty ListenerSP to use builtin listener - //-------------------------------------------------------------------------------------- /// Centralize the code that handles and prints descriptions for process /// state changes. /// - /// @param[in] event_sp + /// \param[in] event_sp /// The process state changed event /// - /// @param[in] stream + /// \param[in] stream /// The output stream to get the state change description /// - /// @param[in,out] pop_process_io_handler + /// \param[in,out] pop_process_io_handler /// If this value comes in set to \b true, then pop the Process IOHandler /// if needed. /// Else this variable will be set to \b true or \b false to indicate if /// the process /// needs to have its process IOHandler popped. /// - /// @return + /// \return /// \b true if the event describes a process state changed event, \b false /// otherwise. - //-------------------------------------------------------------------------------------- static bool HandleProcessStateChangedEvent(const lldb::EventSP &event_sp, Stream *stream, bool &pop_process_io_handler); @@ -2498,7 +2151,6 @@ public: friend class ProcessEventHijacker; friend class ProcessProperties; - //------------------------------------------------------------------ /// If you need to ensure that you and only you will hear about some 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 @@ -2506,44 +2158,42 @@ public: /// WaitFor* calls above. Be sure to call RestoreProcessEvents when you are /// done. /// - /// @param[in] listener + /// \param[in] listener /// This is the new listener to whom all process events will be delivered. /// - /// @return + /// \return /// Returns \b true if the new listener could be installed, /// \b false otherwise. - //------------------------------------------------------------------ bool HijackProcessEvents(lldb::ListenerSP listener_sp); - //------------------------------------------------------------------ /// Restores the process event broadcasting to its normal state. /// - //------------------------------------------------------------------ void RestoreProcessEvents(); - const lldb::ABISP &GetABI(); + bool StateChangedIsHijackedForSynchronousResume(); - OperatingSystem *GetOperatingSystem() { return m_os_ap.get(); } + bool StateChangedIsExternallyHijacked(); - virtual LanguageRuntime *GetLanguageRuntime(lldb::LanguageType language, - bool retry_if_null = true); + const lldb::ABISP &GetABI(); - virtual CPPLanguageRuntime *GetCPPLanguageRuntime(bool retry_if_null = true); + OperatingSystem *GetOperatingSystem() { return m_os_up.get(); } - virtual ObjCLanguageRuntime * - GetObjCLanguageRuntime(bool retry_if_null = true); + std::vector<LanguageRuntime *> + GetLanguageRuntimes(bool retry_if_null = true); + + LanguageRuntime *GetLanguageRuntime(lldb::LanguageType language, + bool retry_if_null = true); bool IsPossibleDynamicValue(ValueObject &in_value); bool IsRunning() const; DynamicCheckerFunctions *GetDynamicCheckers() { - return m_dynamic_checkers_ap.get(); + return m_dynamic_checkers_up.get(); } void SetDynamicCheckers(DynamicCheckerFunctions *dynamic_checkers); - //------------------------------------------------------------------ /// Call this to set the lldb in the mode where it breaks on new thread /// creations, and then auto-restarts. This is useful when you are trying /// to run only one thread, but either that thread or the kernel is creating @@ -2551,27 +2201,22 @@ public: /// can immediately suspend it, and keep executing only the one thread you /// intend. /// - /// @return + /// \return /// Returns \b true if we were able to start up the notification /// \b false otherwise. - //------------------------------------------------------------------ virtual bool StartNoticingNewThreads() { return true; } - //------------------------------------------------------------------ /// Call this to turn off the stop & notice new threads mode. /// - /// @return + /// \return /// Returns \b true if we were able to start up the notification /// \b false otherwise. - //------------------------------------------------------------------ virtual bool StopNoticingNewThreads() { return true; } void SetRunningUserExpression(bool on); void SetRunningUtilityFunction(bool on); - //------------------------------------------------------------------ // lldb::ExecutionContextScope pure virtual functions - //------------------------------------------------------------------ lldb::TargetSP CalculateTarget() override; lldb::ProcessSP CalculateProcess() override { return shared_from_this(); } @@ -2586,28 +2231,22 @@ 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. - //------------------------------------------------------------------ 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. - //------------------------------------------------------------------ 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. - //------------------------------------------------------------------ typedef bool(PreResumeActionCallback)(void *); @@ -2631,48 +2270,44 @@ public: lldb::InstrumentationRuntimeSP 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. /// - /// @param[in] module_file_spec + /// \param[in] module_file_spec /// The file name of the module to get specification for. /// - /// @param[in] arch + /// \param[in] arch /// The architecture of the module to get specification for. /// - /// @param[out] module_spec + /// \param[out] module_spec /// The fetched module specification if the return value is /// \b true, unchanged otherwise. /// - /// @return + /// \return /// Returns \b true if the module spec fetched successfully, /// \b false otherwise. - //------------------------------------------------------------------ virtual bool GetModuleSpec(const FileSpec &module_file_spec, const ArchSpec &arch, ModuleSpec &module_spec); virtual void PrefetchModuleSpecs(llvm::ArrayRef<FileSpec> module_file_specs, const llvm::Triple &triple) {} - //------------------------------------------------------------------ /// 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. /// - /// @param[in] file + /// \param[in] file /// The name of the file whose load address we are looking for /// - /// @param[out] is_loaded + /// \param[out] is_loaded /// \b True if the file is loaded into the memory and false /// otherwise. /// - /// @param[out] load_addr + /// \param[out] load_addr /// The load address of the file if it is loaded into the /// processes address space, LLDB_INVALID_ADDRESS otherwise. - //------------------------------------------------------------------ virtual Status GetFileLoadAddress(const FileSpec &file, bool &is_loaded, lldb::addr_t &load_addr) { return Status("Not supported"); @@ -2684,7 +2319,6 @@ public: void ResetImageToken(size_t token); - //------------------------------------------------------------------ /// Find the next branch instruction to set a breakpoint on /// /// When instruction stepping through a source line, instead of stepping @@ -2693,24 +2327,22 @@ public: /// and continue the process to there, yielding significant performance /// benefits over instruction stepping. /// - /// @param[in] default_stop_addr + /// \param[in] default_stop_addr /// The address of the instruction where lldb would put a /// breakpoint normally. /// - /// @param[in] range_bounds + /// \param[in] range_bounds /// The range which the breakpoint must be contained within. /// Typically a source line. /// - /// @return + /// \return /// The address of the next branch instruction, or the end of /// the range provided in range_bounds. If there are any /// problems with the disassembly or getting the instructions, /// the original default_stop_addr will be returned. - //------------------------------------------------------------------ Address AdvanceAddressToNextBranchInstruction(Address default_stop_addr, AddressRange range_bounds); - //------------------------------------------------------------------ /// Configure asynchronous structured data feature. /// /// Each Process type that supports using an asynchronous StructuredData @@ -2721,11 +2353,11 @@ public: /// StructuredDataPlugin implementations will call this to configure a /// feature that has been reported as being supported. /// - /// @param[in] type_name + /// \param[in] type_name /// The StructuredData type name as previously discovered by /// the Process-derived instance. /// - /// @param[in] config + /// \param[in] config /// Configuration data for the feature being enabled. This config /// data, which may be null, will be passed along to the feature /// to process. The feature will dictate whether this is a dictionary, @@ -2733,14 +2365,12 @@ public: /// set up properly before it can be enabled, then the config should /// also take an enable/disable flag. /// - /// @return + /// \return /// Returns the result of attempting to configure the feature. - //------------------------------------------------------------------ virtual Status - ConfigureStructuredData(const ConstString &type_name, + ConfigureStructuredData(ConstString type_name, const StructuredData::ObjectSP &config_sp); - //------------------------------------------------------------------ /// Broadcasts the given structured data object from the given plugin. /// /// StructuredDataPlugin instances can use this to optionally broadcast any @@ -2748,17 +2378,15 @@ public: /// will come in on the structured data event bit /// (eBroadcastBitStructuredData). /// - /// @param[in] object_sp + /// \param[in] object_sp /// The structured data object to broadcast. /// - /// @param[in] plugin_sp + /// \param[in] plugin_sp /// The plugin that will be reported in the event's plugin /// parameter. - //------------------------------------------------------------------ void BroadcastStructuredData(const StructuredData::ObjectSP &object_sp, const lldb::StructuredDataPluginSP &plugin_sp); - //------------------------------------------------------------------ /// Returns the StructuredDataPlugin associated with a given type name, if /// there is one. /// @@ -2766,14 +2394,12 @@ public: /// debugged process monitor claims that the feature is supported. This is /// one way to tell whether a feature is available. /// - /// @return + /// \return /// The plugin if one is available for the specified feature; /// otherwise, returns an empty shared pointer. - //------------------------------------------------------------------ lldb::StructuredDataPluginSP - GetStructuredDataPlugin(const ConstString &type_name) const; + GetStructuredDataPlugin(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 @@ -2782,48 +2408,40 @@ public: /// 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) { error.SetErrorString("Not implemented"); return LLDB_INVALID_UID; } - //------------------------------------------------------------------ /// 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. - //------------------------------------------------------------------ virtual Status GetData(lldb::user_id_t uid, lldb::tid_t thread_id, llvm::MutableArrayRef<uint8_t> &buffer, size_t offset = 0) { return Status("Not implemented"); } - //------------------------------------------------------------------ /// Similar API as above except for obtaining meta data - //------------------------------------------------------------------ virtual Status GetMetaData(lldb::user_id_t uid, lldb::tid_t thread_id, llvm::MutableArrayRef<uint8_t> &buffer, size_t offset = 0) { return Status("Not implemented"); } - //------------------------------------------------------------------ /// 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 @@ -2831,7 +2449,6 @@ public: /// 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"); } @@ -2841,21 +2458,16 @@ 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. /// - /// @return + /// \return /// An Status object describing the success or failure of the resume. - //------------------------------------------------------------------ Status PrivateResume(); - //------------------------------------------------------------------ // Called internally - //------------------------------------------------------------------ void CompleteAttach(); - //------------------------------------------------------------------ /// Print a user-visible warning one time per Process /// /// A facility for printing a warning to the user once per repeat_key. @@ -2872,21 +2484,19 @@ protected: /// that the warning strings are all centralized in Process, instead of /// calling PrintWarning() directly. /// - /// @param [in] warning_type + /// \param [in] warning_type /// One of the types defined in Process::Warnings. /// - /// @param [in] repeat_key + /// \param [in] repeat_key /// A pointer value used to ensure that the warning is only printed once. /// May be nullptr, indicating that the warning is printed unconditionally /// every time. /// - /// @param [in] fmt + /// \param [in] fmt /// printf style format string - //------------------------------------------------------------------ void PrintWarning(uint64_t warning_type, const void *repeat_key, 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 @@ -2895,14 +2505,13 @@ protected: // // If you want to resume the process as a result of a resume action, call // RequestResume, don't call Resume directly. - //------------------------------------------------------------------ class NextEventAction { public: - typedef enum EventActionResult { + enum EventActionResult { eEventActionSuccess, eEventActionRetry, eEventActionExit - } EventActionResult; + }; NextEventAction(Process *process) : m_process(process) {} @@ -2919,10 +2528,10 @@ protected: }; void SetNextEventAction(Process::NextEventAction *next_event_action) { - if (m_next_event_action_ap.get()) - m_next_event_action_ap->HandleBeingUnshipped(); + if (m_next_event_action_up.get()) + m_next_event_action_up->HandleBeingUnshipped(); - m_next_event_action_ap.reset(next_event_action); + m_next_event_action_up.reset(next_event_action); } // This is the completer for Attaching: @@ -2949,7 +2558,6 @@ 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. /// @@ -2962,22 +2570,20 @@ protected: /// 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 + /// \param[in] supported_type_names /// An array of zero or more type names. Each must be unique. /// For each entry in the list, a StructuredDataPlugin will be /// searched for that supports the structured data type name. - //------------------------------------------------------------------ void MapSupportedStructuredDataPlugins( const StructuredData::Array &supported_type_names); - //------------------------------------------------------------------ /// 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. /// - /// @param[in] object_sp + /// \param[in] object_sp /// When non-null and pointing to a dictionary, the 'type' /// key's string value is used to look up the plugin that /// was registered for that structured data type. It then @@ -2986,19 +2592,16 @@ protected: /// /// virtual void /// HandleArrivalOfStructuredData(Process &process, - /// const ConstString &type_name, + /// ConstString type_name, /// const StructuredData::ObjectSP /// &object_sp) /// - /// @return + /// \return /// True if the structured data was routed to a plugin; otherwise, /// false. - //------------------------------------------------------------------ bool RouteAsyncStructuredData(const StructuredData::ObjectSP object_sp); - //------------------------------------------------------------------ // Type definitions - //------------------------------------------------------------------ typedef std::map<lldb::LanguageType, lldb::LanguageRuntimeSP> LanguageRuntimeCollection; typedef std::unordered_set<const void *> WarningsPointerSet; @@ -3018,9 +2621,7 @@ protected: using StructuredDataPluginMap = std::map<ConstString, lldb::StructuredDataPluginSP>; - //------------------------------------------------------------------ // Member variables - //------------------------------------------------------------------ std::weak_ptr<Target> m_target_wp; ///< The target that owns this process. ThreadSafeValue<lldb::StateType> m_public_state; ThreadSafeValue<lldb::StateType> @@ -3071,15 +2672,15 @@ protected: BreakpointSiteList m_breakpoint_site_list; ///< This is the list of breakpoint ///locations we intend to insert in ///the target. - lldb::DynamicLoaderUP m_dyld_ap; - lldb::JITLoaderListUP m_jit_loaders_ap; - lldb::DynamicCheckerFunctionsUP m_dynamic_checkers_ap; ///< The functions used - ///by the expression - ///parser to validate - ///data that - ///expressions use. - lldb::OperatingSystemUP m_os_ap; - lldb::SystemRuntimeUP m_system_runtime_ap; + lldb::DynamicLoaderUP m_dyld_up; + lldb::JITLoaderListUP m_jit_loaders_up; + lldb::DynamicCheckerFunctionsUP m_dynamic_checkers_up; ///< The functions used + /// by the expression + /// parser to validate + /// data that + /// expressions use. + lldb::OperatingSystemUP m_os_up; + lldb::SystemRuntimeUP m_system_runtime_up; lldb::UnixSignalsSP m_unix_signals_sp; /// This is the current signal set for this process. lldb::ABISP m_abi_sp; @@ -3098,8 +2699,9 @@ protected: bool m_should_detach; /// Should we detach if the process object goes away /// with an explicit call to Kill or Detach? LanguageRuntimeCollection m_language_runtimes; + std::recursive_mutex m_language_runtimes_mutex; InstrumentationRuntimeCollection m_instrumentation_runtimes; - std::unique_ptr<NextEventAction> m_next_event_action_ap; + std::unique_ptr<NextEventAction> m_next_event_action_up; std::vector<PreResumeCallbackAndBaton> m_pre_resume_actions; ProcessRunLock m_public_run_lock; ProcessRunLock m_private_run_lock; @@ -3212,12 +2814,9 @@ protected: virtual Status UpdateAutomaticSignalFiltering(); - bool StateChangedIsExternallyHijacked(); - void LoadOperatingSystemPlugin(bool flush); 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 @@ -3225,13 +2824,12 @@ private: /// again. There is only one place where this call should be called, /// HandlePrivateEvent. Don't call it from anywhere else... /// - /// @param[in] event_ptr + /// \param[in] event_ptr /// This is the event we are handling. /// - /// @return + /// \return /// Returns \b true if the event should be reported to the /// user, \b false otherwise. - //------------------------------------------------------------------ bool ShouldBroadcastEvent(Event *event_ptr); void ControlPrivateStateThread(uint32_t signal); @@ -3239,10 +2837,8 @@ private: DISALLOW_COPY_AND_ASSIGN(Process); }; -//------------------------------------------------------------------ /// RAII guard that should be aquired when an utility function is called within /// a given process. -//------------------------------------------------------------------ class UtilityFunctionScope { Process *m_process; diff --git a/include/lldb/Target/ProcessInfo.h b/include/lldb/Target/ProcessInfo.h deleted file mode 100644 index 0e0d8548feb6f..0000000000000 --- a/include/lldb/Target/ProcessInfo.h +++ /dev/null @@ -1,102 +0,0 @@ -//===-- ProcessInfo.h -------------------------------------------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -#ifndef liblldb_ProcessInfo_h_ -#define liblldb_ProcessInfo_h_ - -// LLDB headers -#include "lldb/Utility/ArchSpec.h" -#include "lldb/Utility/Args.h" -#include "lldb/Utility/Environment.h" -#include "lldb/Utility/FileSpec.h" - -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. -//---------------------------------------------------------------------- -class ProcessInfo { -public: - ProcessInfo(); - - ProcessInfo(const char *name, const ArchSpec &arch, lldb::pid_t pid); - - void Clear(); - - const char *GetName() const; - - size_t GetNameLength() const; - - FileSpec &GetExecutableFile() { return m_executable; } - - void SetExecutableFile(const FileSpec &exe_file, - bool add_exe_file_as_first_arg); - - const FileSpec &GetExecutableFile() const { return m_executable; } - - uint32_t GetUserID() const { return m_uid; } - - uint32_t GetGroupID() const { return m_gid; } - - bool UserIDIsValid() const { return m_uid != UINT32_MAX; } - - bool GroupIDIsValid() const { return m_gid != UINT32_MAX; } - - void SetUserID(uint32_t uid) { m_uid = uid; } - - void SetGroupID(uint32_t gid) { m_gid = gid; } - - ArchSpec &GetArchitecture() { return m_arch; } - - const ArchSpec &GetArchitecture() const { return m_arch; } - - void SetArchitecture(const ArchSpec &arch) { m_arch = arch; } - - lldb::pid_t GetProcessID() const { return m_pid; } - - void SetProcessID(lldb::pid_t pid) { m_pid = pid; } - - bool ProcessIDIsValid() const { return m_pid != LLDB_INVALID_PROCESS_ID; } - - void Dump(Stream &s, Platform *platform) const; - - Args &GetArguments() { return m_arguments; } - - const Args &GetArguments() const { return m_arguments; } - - llvm::StringRef GetArg0() const; - - void SetArg0(llvm::StringRef arg); - - void SetArguments(const Args &args, bool first_arg_is_executable); - - void SetArguments(char const **argv, bool first_arg_is_executable); - - 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) - Args m_arguments; // All program arguments except argv[0] - Environment m_environment; - uint32_t m_uid; - uint32_t m_gid; - ArchSpec m_arch; - lldb::pid_t m_pid; -}; -} - -#endif // #ifndef liblldb_ProcessInfo_h_ diff --git a/include/lldb/Target/ProcessStructReader.h b/include/lldb/Target/ProcessStructReader.h index 79f0b4cccd455..ade29c0a7cf7f 100644 --- a/include/lldb/Target/ProcessStructReader.h +++ b/include/lldb/Target/ProcessStructReader.h @@ -1,9 +1,8 @@ //===---------------------ProcessStructReader.h ------------------*- C++-*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// diff --git a/include/lldb/Target/Queue.h b/include/lldb/Target/Queue.h index 62cc3ccf2e2fc..01e8994f24418 100644 --- a/include/lldb/Target/Queue.h +++ b/include/lldb/Target/Queue.h @@ -1,9 +1,8 @@ //===-- Queue.h ------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -20,7 +19,6 @@ namespace lldb_private { -//------------------------------------------------------------------ // Queue: // This class represents a libdispatch aka Grand Central Dispatch queue in the // process. @@ -30,7 +28,6 @@ namespace lldb_private { // 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> { public: @@ -39,7 +36,6 @@ public: ~Queue(); - //------------------------------------------------------------------ /// Get the QueueID for this Queue /// /// A 64-bit ID number that uniquely identifies a queue at this particular @@ -48,21 +44,17 @@ public: /// each queue. A serialnum is not reused for a different queue in the /// lifetime of that process execution. /// - /// @return + /// \return /// The QueueID for this Queue. - //------------------------------------------------------------------ lldb::queue_id_t GetID(); - //------------------------------------------------------------------ /// Get the name of this Queue /// - /// @return + /// \return /// The name of the queue, if one is available. /// A NULL pointer is returned if none is available. - //------------------------------------------------------------------ const char *GetName(); - //------------------------------------------------------------------ /// Get the IndexID for this Queue /// /// This is currently the same as GetID(). If it changes in the future, @@ -73,66 +65,55 @@ public: /// maintain similar API to the Thread class, and allow for the /// possibility of GetID changing to a different source in the future. /// - /// @return + /// \return /// The IndexID for this queue. - //------------------------------------------------------------------ uint32_t GetIndexID(); - //------------------------------------------------------------------ /// Return the threads currently associated with this queue /// /// Zero, one, or many threads may be executing code for a queue at /// a given point in time. This call returns the list of threads /// that are currently executing work for this queue. /// - /// @return + /// \return /// The threads currently performing work for this queue - //------------------------------------------------------------------ std::vector<lldb::ThreadSP> GetThreads(); - //------------------------------------------------------------------ /// Return the items that are currently enqueued /// /// "Enqueued" means that the item has been added to the queue to /// be done, but has not yet been done. When the item is going to /// be processed it is "dequeued". /// - /// @return + /// \return /// The vector of enqueued items for this queue - //------------------------------------------------------------------ const std::vector<lldb::QueueItemSP> &GetPendingItems(); lldb::ProcessSP GetProcess() const { return m_process_wp.lock(); } - //------------------------------------------------------------------ /// Get the number of work items that this queue is currently running /// - /// @return + /// \return /// The number of work items currently executing. For a serial /// queue, this will be 0 or 1. For a concurrent queue, this /// may be any number. - //------------------------------------------------------------------ uint32_t GetNumRunningWorkItems() const; - //------------------------------------------------------------------ /// Get the number of work items enqueued on this queue /// - /// @return + /// \return /// The number of work items currently enqueued, waiting to /// execute. - //------------------------------------------------------------------ uint32_t GetNumPendingWorkItems() const; - //------------------------------------------------------------------ /// Get the dispatch_queue_t structure address for this Queue /// /// Get the address in the inferior process' memory of this Queue's /// dispatch_queue_t structure. /// - /// @return + /// \return /// The address of the dispatch_queue_t structure, if known. /// LLDB_INVALID_ADDRESS will be returned if it is unavailable. - //------------------------------------------------------------------ lldb::addr_t GetLibdispatchQueueAddress() const; void SetNumRunningWorkItems(uint32_t count); @@ -145,20 +126,16 @@ public: m_pending_items.push_back(item); } - //------------------------------------------------------------------ /// Return the kind (serial, concurrent) of this queue /// - /// @return + /// \return // Whether this is a serial or a concurrent queue - //------------------------------------------------------------------ lldb::QueueKind GetKind(); void SetKind(lldb::QueueKind kind); private: - //------------------------------------------------------------------ // For Queue only - //------------------------------------------------------------------ lldb::ProcessWP m_process_wp; lldb::queue_id_t m_queue_id; diff --git a/include/lldb/Target/QueueItem.h b/include/lldb/Target/QueueItem.h index 3fd331ca525af..dfae3b8472633 100644 --- a/include/lldb/Target/QueueItem.h +++ b/include/lldb/Target/QueueItem.h @@ -1,9 +1,8 @@ //===-- QueueItem.h ---------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -23,14 +22,12 @@ 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. -//------------------------------------------------------------------ class QueueItem : public std::enable_shared_from_this<QueueItem> { public: @@ -39,71 +36,59 @@ public: ~QueueItem(); - //------------------------------------------------------------------ /// Get the kind of work item this is /// - /// @return + /// \return /// The type of work item that this QueueItem object /// represents. eQueueItemKindUnknown may be returned. - //------------------------------------------------------------------ lldb::QueueItemKind GetKind(); - //------------------------------------------------------------------ /// Set the type of work item this is /// - /// @param [in] item_kind + /// \param [in] item_kind /// Set the kind of this work item object. - //------------------------------------------------------------------ void SetKind(lldb::QueueItemKind item_kind); - //------------------------------------------------------------------ /// Get the code address that will be executed when this work item /// is executed. /// - /// @return + /// \return /// The address that will be invoked when this work item is /// executed. Not all types of QueueItems will have an /// address associated with them; check that the returned /// Address is valid, or check that the WorkItemKind is a /// kind that involves an address, such as eQueueItemKindFunction /// or eQueueItemKindBlock. - //------------------------------------------------------------------ lldb_private::Address &GetAddress(); - //------------------------------------------------------------------ /// Set the work item address for this object /// - /// @param [in] addr + /// \param [in] addr /// The address that will be invoked when this work item /// is executed. - //------------------------------------------------------------------ void SetAddress(lldb_private::Address addr); - //------------------------------------------------------------------ /// Check if this QueueItem object is valid /// /// If the weak pointer to the parent Queue cannot be revivified, /// it is invalid. /// - /// @return + /// \return /// True if this object is valid. - //------------------------------------------------------------------ bool IsValid() { return m_queue_wp.lock() != nullptr; } - //------------------------------------------------------------------ /// Get an extended backtrace thread for this queue item, if available /// /// If the backtrace/thread information was collected when this item /// was enqueued, this call will provide it. /// - /// @param [in] type + /// \param [in] type /// The type of extended backtrace being requested, e.g. "libdispatch" /// or "pthread". /// - /// @return + /// \return /// A thread shared pointer which will have a reference to an extended /// thread if one was available. - //------------------------------------------------------------------ lldb::ThreadSP GetExtendedBacktraceThread(ConstString type); void SetItemThatEnqueuedThis(lldb::addr_t address_of_item) { diff --git a/include/lldb/Target/QueueList.h b/include/lldb/Target/QueueList.h index b35de13aa1e54..761107e41def6 100644 --- a/include/lldb/Target/QueueList.h +++ b/include/lldb/Target/QueueList.h @@ -1,9 +1,8 @@ //===-- QueueList.h --------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -19,14 +18,12 @@ namespace lldb_private { -//------------------------------------------------------------------ // QueueList: // 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. -//------------------------------------------------------------------ class QueueList { friend class Process; @@ -36,22 +33,18 @@ public: ~QueueList(); - //------------------------------------------------------------------ /// Get the number of libdispatch queues that are available /// - /// @return + /// \return /// The number of queues that are stored in the QueueList. - //------------------------------------------------------------------ uint32_t GetSize(); - //------------------------------------------------------------------ /// Get the Queue at a given index number /// - /// @param [in] idx + /// \param [in] idx /// The index number (0-based) of the queue. - /// @return + /// \return /// The Queue at that index number. - //------------------------------------------------------------------ lldb::QueueSP GetQueueAtIndex(uint32_t idx); typedef std::vector<lldb::QueueSP> collection; @@ -59,61 +52,49 @@ public: std::mutex> QueueIterable; - //------------------------------------------------------------------ /// Iterate over the list of queues /// - /// @return + /// \return /// An Iterable object which can be used to loop over the queues /// that exist. - //------------------------------------------------------------------ QueueIterable Queues() { return QueueIterable(m_queues, m_mutex); } - //------------------------------------------------------------------ /// Clear out the list of queues from the QueueList - //------------------------------------------------------------------ void Clear(); - //------------------------------------------------------------------ /// Add a Queue to the QueueList /// - /// @param [in] queue + /// \param [in] queue /// Used by the SystemRuntime to populate the QueueList - //------------------------------------------------------------------ void AddQueue(lldb::QueueSP queue); - //------------------------------------------------------------------ /// Find a queue in the QueueList by QueueID /// - /// @param [in] qid + /// \param [in] qid /// The QueueID (same as returned by Thread::GetQueueID()) to find. /// - /// @return + /// \return /// A QueueSP to the queue requested, if it is present in the QueueList. /// An empty QueueSP will be returned if this queue was not found. - //------------------------------------------------------------------ lldb::QueueSP FindQueueByID(lldb::queue_id_t qid); - //------------------------------------------------------------------ /// Find a queue in the QueueList by IndexID /// - /// @param [in] index_id + /// \param [in] index_id /// Find a queue by IndexID. This is an integer associated with each /// unique queue seen during a debug session and will not be reused /// for a different queue. Unlike the QueueID, a 64-bit value, this /// will tend to be an integral value like 1 or 7. /// - /// @return + /// \return /// A QueueSP to the queue requested, if it is present in the QueueList. /// An empty QueueSP will be returned if this queue was not found. - //------------------------------------------------------------------ lldb::QueueSP FindQueueByIndexID(uint32_t index_id); std::mutex &GetMutex(); protected: - //------------------------------------------------------------------ // Classes that inherit from Process can see and modify these - //------------------------------------------------------------------ Process *m_process; ///< The process that manages this queue list. uint32_t m_stop_id; ///< The process stop ID that this queue list is valid for. @@ -121,7 +102,7 @@ protected: std::mutex m_mutex; private: - QueueList(); + QueueList() = delete; }; } // namespace lldb_private diff --git a/include/lldb/Target/RegisterCheckpoint.h b/include/lldb/Target/RegisterCheckpoint.h index e4b407124c9fc..4f9654f763437 100644 --- a/include/lldb/Target/RegisterCheckpoint.h +++ b/include/lldb/Target/RegisterCheckpoint.h @@ -1,9 +1,8 @@ //===-- RegisterCheckpoint.h ------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// diff --git a/include/lldb/Target/RegisterContext.h b/include/lldb/Target/RegisterContext.h index a24c270a1e5e9..d6212dd49dd6b 100644 --- a/include/lldb/Target/RegisterContext.h +++ b/include/lldb/Target/RegisterContext.h @@ -1,9 +1,8 @@ //===-- RegisterContext.h ---------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -18,18 +17,14 @@ namespace lldb_private { class RegisterContext : public std::enable_shared_from_this<RegisterContext>, public ExecutionContextScope { public: - //------------------------------------------------------------------ // Constructors and Destructors - //------------------------------------------------------------------ RegisterContext(Thread &thread, uint32_t concrete_frame_idx); ~RegisterContext() override; void InvalidateIfNeeded(bool force); - //------------------------------------------------------------------ // Subclasses must override these functions - //------------------------------------------------------------------ virtual void InvalidateAllRegisters() = 0; virtual size_t GetRegisterCount() = 0; @@ -76,7 +71,6 @@ public: bool CopyFromRegisterContext(lldb::RegisterContextSP context); - //------------------------------------------------------------------ /// Convert from a given register numbering scheme to the lldb register /// numbering scheme /// @@ -100,23 +94,20 @@ public: /// This method translates a given register kind + register number into /// the eRegisterKindLLDB register numbering. /// - /// @param [in] kind + /// \param [in] kind /// The register numbering scheme (RegisterKind) that the following /// register number is in. /// - /// @param [in] num + /// \param [in] num /// A register number in the 'kind' register numbering scheme. /// - /// @return + /// \return /// The equivalent register number in the eRegisterKindLLDB /// numbering scheme, if possible, else LLDB_INVALID_REGNUM. - //------------------------------------------------------------------ virtual uint32_t ConvertRegisterKindToRegisterNumber(lldb::RegisterKind kind, uint32_t num) = 0; - //------------------------------------------------------------------ // Subclasses can override these functions if desired - //------------------------------------------------------------------ virtual uint32_t NumSupportedHardwareBreakpoints(); virtual uint32_t SetHardwareBreakpoint(lldb::addr_t addr, size_t size); @@ -142,9 +133,7 @@ public: lldb::addr_t dst_addr, uint32_t dst_len, const RegisterValue ®_value); - //------------------------------------------------------------------ // Subclasses should not override these - //------------------------------------------------------------------ virtual lldb::tid_t GetThreadID() const; virtual Thread &GetThread() { return m_thread; } @@ -189,9 +178,7 @@ public: lldb::RegisterKind target_rk, uint32_t &target_regnum); - //------------------------------------------------------------------ // lldb::ExecutionContextScope pure virtual functions - //------------------------------------------------------------------ lldb::TargetSP CalculateTarget() override; lldb::ProcessSP CalculateProcess() override; @@ -207,17 +194,13 @@ public: void SetStopID(uint32_t stop_id) { m_stop_id = stop_id; } protected: - //------------------------------------------------------------------ // Classes that inherit from RegisterContext can see and modify these - //------------------------------------------------------------------ Thread &m_thread; // The thread that this register context belongs to. uint32_t m_concrete_frame_idx; // The concrete frame index for this register // context uint32_t m_stop_id; // The stop ID that any data in this context is valid for private: - //------------------------------------------------------------------ // For RegisterContext only - //------------------------------------------------------------------ DISALLOW_COPY_AND_ASSIGN(RegisterContext); }; diff --git a/include/lldb/Target/RegisterNumber.h b/include/lldb/Target/RegisterNumber.h index 1a0ab49bdce39..0bef0c13f3785 100644 --- a/include/lldb/Target/RegisterNumber.h +++ b/include/lldb/Target/RegisterNumber.h @@ -1,9 +1,8 @@ //===-- RegisterNumber.h ----------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -13,11 +12,9 @@ #include "lldb/lldb-private.h" #include <map> -//-------------------------------------------------------------------- /// A class to represent register numbers, and able to convert between /// different register numbering schemes that may be used in a single /// debug session. -//-------------------------------------------------------------------- class RegisterNumber { public: diff --git a/include/lldb/Target/RemoteAwarePlatform.h b/include/lldb/Target/RemoteAwarePlatform.h new file mode 100644 index 0000000000000..524332f948a54 --- /dev/null +++ b/include/lldb/Target/RemoteAwarePlatform.h @@ -0,0 +1,97 @@ +//===-- RemoteAwarePlatform.h -----------------------------------*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef LLDB_TARGET_REMOTEAWAREPLATFORM_H +#define LLDB_TARGET_REMOTEAWAREPLATFORM_H + +#include "lldb/Target/Platform.h" + +namespace lldb_private { + +/// A base class for platforms which automatically want to be able to forward +/// operations to a remote platform instance (such as PlatformRemoteGDBServer). +class RemoteAwarePlatform : public Platform { +public: + using Platform::Platform; + + bool GetModuleSpec(const FileSpec &module_file_spec, const ArchSpec &arch, + ModuleSpec &module_spec) override; + + lldb::user_id_t OpenFile(const FileSpec &file_spec, uint32_t flags, + uint32_t mode, Status &error) override; + + bool CloseFile(lldb::user_id_t fd, Status &error) override; + + uint64_t ReadFile(lldb::user_id_t fd, uint64_t offset, void *dst, + uint64_t dst_len, Status &error) override; + + uint64_t WriteFile(lldb::user_id_t fd, uint64_t offset, const void *src, + uint64_t src_len, Status &error) override; + + lldb::user_id_t GetFileSize(const FileSpec &file_spec) override; + + Status CreateSymlink(const FileSpec &src, const FileSpec &dst) override; + + bool GetFileExists(const FileSpec &file_spec) override; + + Status Unlink(const FileSpec &file_spec) override; + + FileSpec GetRemoteWorkingDirectory() override; + + bool SetRemoteWorkingDirectory(const FileSpec &working_dir) override; + + Status MakeDirectory(const FileSpec &file_spec, uint32_t mode) override; + + Status GetFilePermissions(const FileSpec &file_spec, + uint32_t &file_permissions) override; + + Status SetFilePermissions(const FileSpec &file_spec, + uint32_t file_permissions) override; + + bool CalculateMD5(const FileSpec &file_spec, uint64_t &low, + uint64_t &high) override; + + Status GetFileWithUUID(const FileSpec &platform_file, const UUID *uuid, + FileSpec &local_file) override; + + bool GetRemoteOSVersion() override; + bool GetRemoteOSBuildString(std::string &s) override; + bool GetRemoteOSKernelDescription(std::string &s) override; + ArchSpec GetRemoteSystemArchitecture() override; + + Status RunShellCommand(const char *command, const FileSpec &working_dir, + int *status_ptr, int *signo_ptr, + std::string *command_output, + const Timeout<std::micro> &timeout) override; + + const char *GetHostname() override; + UserIDResolver &GetUserIDResolver() override; + lldb_private::Environment GetEnvironment() override; + + bool IsConnected() const override; + + bool GetProcessInfo(lldb::pid_t pid, ProcessInstanceInfo &proc_info) override; + uint32_t FindProcesses(const ProcessInstanceInfoMatch &match_info, + ProcessInstanceInfoList &process_infos) override; + + lldb::ProcessSP ConnectProcess(llvm::StringRef connect_url, + llvm::StringRef plugin_name, + Debugger &debugger, Target *target, + Status &error) override; + + Status LaunchProcess(ProcessLaunchInfo &launch_info) override; + + Status KillProcess(const lldb::pid_t pid) override; + +protected: + lldb::PlatformSP m_remote_platform_sp; +}; + +} // namespace lldb_private + +#endif // LLDB_TARGET_REMOTEAWAREPLATFORM_H diff --git a/include/lldb/Target/SectionLoadHistory.h b/include/lldb/Target/SectionLoadHistory.h index 0a14fc05c458f..71b5d0c427463 100644 --- a/include/lldb/Target/SectionLoadHistory.h +++ b/include/lldb/Target/SectionLoadHistory.h @@ -1,9 +1,8 @@ //===-- SectionLoadHistory.h ------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -24,9 +23,7 @@ public: // value. eStopIDNow = UINT32_MAX }; - //------------------------------------------------------------------ // Constructors and Destructors - //------------------------------------------------------------------ SectionLoadHistory() : m_stop_id_to_section_load_list(), m_mutex() {} ~SectionLoadHistory() { diff --git a/include/lldb/Target/SectionLoadList.h b/include/lldb/Target/SectionLoadList.h index 2a321e7a25454..caefa00ec1daa 100644 --- a/include/lldb/Target/SectionLoadList.h +++ b/include/lldb/Target/SectionLoadList.h @@ -1,10 +1,9 @@ //===-- SectionLoadList.h -----------------------------------------------*- C++ //-*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -22,9 +21,7 @@ namespace lldb_private { class SectionLoadList { public: - //------------------------------------------------------------------ // Constructors and Destructors - //------------------------------------------------------------------ SectionLoadList() : m_addr_to_sect(), m_sect_to_addr(), m_mutex() {} SectionLoadList(const SectionLoadList &rhs); diff --git a/include/lldb/Target/StackFrame.h b/include/lldb/Target/StackFrame.h index a4e31a567440a..4e6e79befc6ab 100644 --- a/include/lldb/Target/StackFrame.h +++ b/include/lldb/Target/StackFrame.h @@ -1,9 +1,8 @@ //===-- StackFrame.h --------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -26,7 +25,7 @@ namespace lldb_private { -/// @class StackFrame StackFrame.h "lldb/Target/StackFrame.h" +/// \class StackFrame StackFrame.h "lldb/Target/StackFrame.h" /// /// This base class provides an interface to stack frames. /// @@ -64,7 +63,6 @@ public: Artificial }; - //------------------------------------------------------------------ /// Construct a StackFrame object without supplying a RegisterContextSP. /// /// This is the one constructor that doesn't take a RegisterContext @@ -73,19 +71,19 @@ public: /// point in the past. We may only have pc values. We may have a CFA, /// or more likely, we won't. /// - /// @param [in] thread_sp + /// \param [in] thread_sp /// The Thread that this frame belongs to. /// - /// @param [in] frame_idx + /// \param [in] frame_idx /// This StackFrame's frame index number in the Thread. If inlined stack /// frames are being created, this may differ from the concrete_frame_idx /// which is the frame index without any inlined stack frames. /// - /// @param [in] concrete_frame_idx + /// \param [in] concrete_frame_idx /// The StackFrame's frame index number in the Thread without any inlined /// stack frames being included in the index. /// - /// @param [in] cfa + /// \param [in] cfa /// The Canonical Frame Address (this terminology from DWARF) for this /// stack frame. The CFA for a stack frame does not change over the /// span of the stack frame's existence. It is often the value of the @@ -93,21 +91,20 @@ public: /// function. It is usually not the same as the frame pointer register's /// value. /// - /// @param [in] cfa_is_valid + /// \param [in] cfa_is_valid /// A history stack frame may not have a CFA value collected. We want to /// distinguish between "no CFA available" and a CFA of /// LLDB_INVALID_ADDRESS. /// - /// @param [in] pc + /// \param [in] pc /// The current pc value of this stack frame. /// - /// @param [in] frame_kind + /// \param [in] frame_kind /// - /// @param [in] sc_ptr + /// \param [in] sc_ptr /// Optionally seed the StackFrame with the SymbolContext information that /// has /// already been discovered. - //------------------------------------------------------------------ StackFrame(const lldb::ThreadSP &thread_sp, lldb::user_id_t frame_idx, lldb::user_id_t concrete_frame_idx, lldb::addr_t cfa, bool cfa_is_valid, lldb::addr_t pc, Kind frame_kind, @@ -129,31 +126,26 @@ public: StackID &GetStackID(); - //------------------------------------------------------------------ /// Get an Address for the current pc value in this StackFrame. /// /// May not be the same as the actual PC value for inlined stack frames. /// - /// @return + /// \return /// The Address object set to the current PC value. - //------------------------------------------------------------------ const Address &GetFrameCodeAddress(); - //------------------------------------------------------------------ /// Change the pc value for a given thread. /// /// Change the current pc value for the frame on this thread. /// - /// @param[in] pc + /// \param[in] pc /// The load address that the pc will be set to. /// - /// @return + /// \return /// true if the pc was changed. false if this failed -- possibly /// because this frame is not a live StackFrame. - //------------------------------------------------------------------ bool ChangePC(lldb::addr_t pc); - //------------------------------------------------------------------ /// Provide a SymbolContext for this StackFrame's current pc value. /// /// The StackFrame maintains this SymbolContext and adds additional @@ -161,17 +153,15 @@ public: /// functions looking up symbolic information for a given pc value multiple /// times. /// - /// @params [in] resolve_scope + /// \params [in] resolve_scope /// Flags from the SymbolContextItem enumerated type which specify what /// type of symbol context is needed by this caller. /// - /// @return + /// \return /// A SymbolContext reference which includes the types of information /// requested by resolve_scope, if they are available. - //------------------------------------------------------------------ const SymbolContext &GetSymbolContext(lldb::SymbolContextItem resolve_scope); - //------------------------------------------------------------------ /// Return the Canonical Frame Address (DWARF term) for this frame. /// /// The CFA is typically the value of the stack pointer register before the @@ -182,46 +172,40 @@ public: /// Live StackFrames will always have a CFA but other types of frames may /// not be able to supply one. /// - /// @param [out] value + /// \param [out] value /// The address of the CFA for this frame, if available. /// - /// @param [out] error_ptr + /// \param [out] error_ptr /// If there is an error determining the CFA address, this may contain a /// string explaining the failure. /// - /// @return + /// \return /// Returns true if the CFA value was successfully set in value. Some /// frames may be unable to provide this value; they will return false. - //------------------------------------------------------------------ bool GetFrameBaseValue(Scalar &value, Status *error_ptr); - //------------------------------------------------------------------ /// Get the DWARFExpression corresponding to the Canonical Frame Address. /// /// Often a register (bp), but sometimes a register + offset. /// - /// @param [out] error_ptr + /// \param [out] error_ptr /// If there is an error determining the CFA address, this may contain a /// string explaining the failure. /// - /// @return + /// \return /// Returns the corresponding DWARF expression, or NULL. - //------------------------------------------------------------------ DWARFExpression *GetFrameBaseExpression(Status *error_ptr); - //------------------------------------------------------------------ /// Get the current lexical scope block for this StackFrame, if possible. /// /// If debug information is available for this stack frame, return a pointer /// to the innermost lexical Block that the frame is currently executing. /// - /// @return + /// \return /// A pointer to the current Block. nullptr is returned if this can /// not be provided. - //------------------------------------------------------------------ Block *GetFrameBlock(); - //------------------------------------------------------------------ /// Get the RegisterContext for this frame, if possible. /// /// Returns a shared pointer to the RegisterContext for this stack frame. @@ -232,16 +216,14 @@ public: /// registers. Only the currently executing frame (frame 0) can reliably /// provide every register in the register context. /// - /// @return + /// \return /// The RegisterContext shared point for this frame. - //------------------------------------------------------------------ lldb::RegisterContextSP GetRegisterContext(); const lldb::RegisterContextSP &GetRegisterContextSP() const { return m_reg_context_sp; } - //------------------------------------------------------------------ /// Retrieve the list of variables that are in scope at this StackFrame's /// pc. /// @@ -249,17 +231,15 @@ public: /// pc value even though variables would be available at this point if it /// were a live stack frame. /// - /// @param[in] get_file_globals + /// \param[in] get_file_globals /// Whether to also retrieve compilation-unit scoped variables /// that are visible to the entire compilation unit (e.g. file /// static in C, globals that are homed in this CU). /// - /// @return + /// \return /// A pointer to a list of variables. - //------------------------------------------------------------------ VariableList *GetVariableList(bool get_file_globals); - //------------------------------------------------------------------ /// Retrieve the list of variables that are in scope at this StackFrame's /// pc. /// @@ -267,269 +247,230 @@ public: /// given pc value even though variables would be available at this point if /// it were a live stack frame. /// - /// @param[in] get_file_globals + /// \param[in] get_file_globals /// Whether to also retrieve compilation-unit scoped variables /// that are visible to the entire compilation unit (e.g. file /// static in C, globals that are homed in this CU). /// - /// @return + /// \return /// A pointer to a list of variables. - //------------------------------------------------------------------ lldb::VariableListSP GetInScopeVariableList(bool get_file_globals, bool must_have_valid_location = false); - //------------------------------------------------------------------ /// Create a ValueObject for a variable name / pathname, possibly including /// simple dereference/child selection syntax. /// - /// @param[in] var_expr + /// \param[in] var_expr /// The string specifying a variable to base the VariableObject off /// of. /// - /// @param[in] use_dynamic + /// \param[in] use_dynamic /// Whether the correct dynamic type of an object pointer should be /// determined before creating the object, or if the static type is /// sufficient. One of the DynamicValueType enumerated values. /// - /// @param[in] options + /// \param[in] options /// An unsigned integer of flags, values from /// StackFrame::ExpressionPathOption /// enum. - /// @param[in] var_sp + /// \param[in] var_sp /// A VariableSP that will be set to the variable described in the /// var_expr path. /// - /// @param[in] error + /// \param[in] error /// Record any errors encountered while evaluating var_expr. /// - /// @return + /// \return /// A shared pointer to the ValueObject described by var_expr. - //------------------------------------------------------------------ lldb::ValueObjectSP GetValueForVariableExpressionPath( llvm::StringRef var_expr, lldb::DynamicValueType use_dynamic, uint32_t options, lldb::VariableSP &var_sp, Status &error); - //------------------------------------------------------------------ /// Determine whether this StackFrame has debug information available or not /// - /// @return + /// \return // true if debug information is available for this frame (function, // compilation unit, block, etc.) - //------------------------------------------------------------------ bool HasDebugInformation(); - //------------------------------------------------------------------ /// Return the disassembly for the instructions of this StackFrame's /// function as a single C string. /// - /// @return + /// \return // C string with the assembly instructions for this function. - //------------------------------------------------------------------ const char *Disassemble(); - //------------------------------------------------------------------ /// Print a description for this frame using the frame-format formatter /// settings. /// - /// @param [in] strm + /// \param [in] strm /// The Stream to print the description to. /// - /// @param [in] show_unique + /// \param [in] show_unique /// Whether to print the function arguments or not for backtrace unique. /// - /// @param [in] frame_marker + /// \param [in] frame_marker /// Optional string that will be prepended to the frame output description. - //------------------------------------------------------------------ void DumpUsingSettingsFormat(Stream *strm, bool show_unique = false, const char *frame_marker = nullptr); - //------------------------------------------------------------------ /// Print a description for this frame using a default format. /// - /// @param [in] strm + /// \param [in] strm /// The Stream to print the description to. /// - /// @param [in] show_frame_index + /// \param [in] show_frame_index /// Whether to print the frame number or not. /// - /// @param [in] show_fullpaths + /// \param [in] show_fullpaths /// Whether to print the full source paths or just the file base name. - //------------------------------------------------------------------ void Dump(Stream *strm, bool show_frame_index, bool show_fullpaths); - //------------------------------------------------------------------ /// Print a description of this stack frame and/or the source /// context/assembly for this stack frame. /// - /// @param[in] strm + /// \param[in] strm /// The Stream to send the output to. /// - /// @param[in] show_frame_info + /// \param[in] show_frame_info /// If true, print the frame info by calling DumpUsingSettingsFormat(). /// - /// @param[in] show_source + /// \param[in] show_source /// If true, print source or disassembly as per the user's settings. /// - /// @param[in] show_unique + /// \param[in] show_unique /// If true, print using backtrace unique style, without function /// arguments as per the user's settings. /// - /// @param[in] frame_marker + /// \param[in] frame_marker /// Passed to DumpUsingSettingsFormat() for the frame info printing. /// - /// @return + /// \return /// Returns true if successful. - //------------------------------------------------------------------ bool GetStatus(Stream &strm, bool show_frame_info, bool show_source, 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. /// - /// @return + /// \return /// true if this is an inlined frame. - //------------------------------------------------------------------ bool IsInlined(); - //------------------------------------------------------------------ /// Query whether this frame is part of a historical backtrace. - //------------------------------------------------------------------ bool IsHistorical() const; - //------------------------------------------------------------------ /// Query whether this frame is artificial (e.g a synthesized result of /// inferring missing tail call frames from a backtrace). Artificial frames /// may have limited support for inspecting variables. - //------------------------------------------------------------------ bool IsArtificial() const; - //------------------------------------------------------------------ /// Query this frame to find what frame it is in this Thread's /// StackFrameList. /// - /// @return + /// \return /// StackFrame index 0 indicates the currently-executing function. Inline /// frames are included in this frame index count. - //------------------------------------------------------------------ uint32_t GetFrameIndex() const; - //------------------------------------------------------------------ /// Set this frame's synthetic frame index. - //------------------------------------------------------------------ void SetFrameIndex(uint32_t index) { m_frame_index = index; } - //------------------------------------------------------------------ /// Query this frame to find what frame it is in this Thread's /// StackFrameList, not counting inlined frames. /// - /// @return + /// \return /// StackFrame index 0 indicates the currently-executing function. Inline /// frames are not included in this frame index count; their concrete /// frame index will be the same as the concrete frame that they are /// derived from. - //------------------------------------------------------------------ uint32_t GetConcreteFrameIndex() const { return m_concrete_frame_index; } - //------------------------------------------------------------------ /// Create a ValueObject for a given Variable in this StackFrame. /// - /// @params [in] variable_sp + /// \params [in] variable_sp /// The Variable to base this ValueObject on /// - /// @params [in] use_dynamic + /// \params [in] use_dynamic /// Whether the correct dynamic type of the variable should be /// determined before creating the ValueObject, or if the static type /// is sufficient. One of the DynamicValueType enumerated values. /// - /// @return + /// \return // A ValueObject for this variable. - //------------------------------------------------------------------ lldb::ValueObjectSP GetValueObjectForFrameVariable(const lldb::VariableSP &variable_sp, lldb::DynamicValueType use_dynamic); - //------------------------------------------------------------------ /// Add an arbitrary Variable object (e.g. one that specifics a global or /// static) to a StackFrame's list of ValueObjects. /// - /// @params [in] variable_sp + /// \params [in] variable_sp /// The Variable to base this ValueObject on /// - /// @params [in] use_dynamic + /// \params [in] use_dynamic /// Whether the correct dynamic type of the variable should be /// determined before creating the ValueObject, or if the static type /// is sufficient. One of the DynamicValueType enumerated values. /// - /// @return + /// \return // A ValueObject for this variable. - //------------------------------------------------------------------ lldb::ValueObjectSP TrackGlobalVariable(const lldb::VariableSP &variable_sp, lldb::DynamicValueType use_dynamic); - //------------------------------------------------------------------ /// Query this frame to determine what the default language should be when /// parsing expressions given the execution context. /// - /// @return + /// \return /// The language of the frame if known, else lldb::eLanguageTypeUnknown. - //------------------------------------------------------------------ lldb::LanguageType GetLanguage(); // similar to GetLanguage(), but is allowed to take a potentially incorrect // guess if exact information is not available lldb::LanguageType GuessLanguage(); - //------------------------------------------------------------------ /// Attempt to econstruct the ValueObject for a given raw address touched by /// the current instruction. The ExpressionPath should indicate how to get /// to this value using "frame variable." /// - /// @params [in] addr + /// \params [in] addr /// The raw address. /// - /// @return + /// \return /// The ValueObject if found. If valid, it has a valid ExpressionPath. - //------------------------------------------------------------------ lldb::ValueObjectSP GuessValueForAddress(lldb::addr_t addr); - //------------------------------------------------------------------ /// 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." /// - /// @params [in] reg + /// \params [in] reg /// The name of the register. /// - /// @params [in] offset + /// \params [in] offset /// The offset from the register. Particularly important for sp... /// - /// @return + /// \return /// The ValueObject if found. If valid, it has a valid ExpressionPath. - //------------------------------------------------------------------ lldb::ValueObjectSP GuessValueForRegisterAndOffset(ConstString reg, int64_t offset); - //------------------------------------------------------------------ /// Attempt to reconstruct the ValueObject for a variable with a given \a name /// from within the current StackFrame, within the current block. The search /// for the variable starts in the deepest block corresponding to the current /// PC in the stack frame and traverse through all parent blocks stopping at /// inlined function boundaries. /// - /// @params [in] name + /// \params [in] name /// The name of the variable. /// - /// @return + /// \return /// The ValueObject if found. - //------------------------------------------------------------------ lldb::ValueObjectSP FindVariable(ConstString name); - //------------------------------------------------------------------ // lldb::ExecutionContextScope pure virtual functions - //------------------------------------------------------------------ lldb::TargetSP CalculateTarget() override; lldb::ProcessSP CalculateProcess() override; @@ -554,9 +495,7 @@ protected: bool HasCachedData() const; private: - //------------------------------------------------------------------ // For StackFrame only - //------------------------------------------------------------------ lldb::ThreadWP m_thread_wp; uint32_t m_frame_index; uint32_t m_concrete_frame_index; diff --git a/include/lldb/Target/StackFrameList.h b/include/lldb/Target/StackFrameList.h index 0de90b3ba4acb..5eb7919501722 100644 --- a/include/lldb/Target/StackFrameList.h +++ b/include/lldb/Target/StackFrameList.h @@ -1,9 +1,8 @@ //===-- StackFrameList.h ----------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -20,9 +19,7 @@ namespace lldb_private { class StackFrameList { public: - //------------------------------------------------------------------ // Constructors and Destructors - //------------------------------------------------------------------ StackFrameList(Thread &thread, const lldb::StackFrameListSP &prev_frames_sp, bool show_inline_frames); @@ -92,7 +89,7 @@ protected: bool SetFrameAtIndex(uint32_t idx, lldb::StackFrameSP &frame_sp); - static void Merge(std::unique_ptr<StackFrameList> &curr_ap, + static void Merge(std::unique_ptr<StackFrameList> &curr_up, lldb::StackFrameListSP &prev_sp); void GetFramesUpTo(uint32_t end_idx); diff --git a/include/lldb/Target/StackFrameRecognizer.h b/include/lldb/Target/StackFrameRecognizer.h index 35ec23b754f3a..2021ac5215f38 100644 --- a/include/lldb/Target/StackFrameRecognizer.h +++ b/include/lldb/Target/StackFrameRecognizer.h @@ -1,15 +1,15 @@ //===-- StackFrameRecognizer.h ----------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// #ifndef liblldb_StackFrameRecognizer_h_ #define liblldb_StackFrameRecognizer_h_ +#include "lldb/Core/ValueObject.h" #include "lldb/Core/ValueObjectList.h" #include "lldb/Symbol/VariableList.h" #include "lldb/Utility/StructuredData.h" @@ -18,7 +18,7 @@ namespace lldb_private { -/// @class RecognizedStackFrame +/// \class RecognizedStackFrame /// /// This class provides extra information about a stack frame that was /// provided by a specific stack frame recognizer. Right now, this class only @@ -39,7 +39,7 @@ protected: lldb::ValueObjectListSP m_arguments; }; -/// @class StackFrameRecognizer +/// \class StackFrameRecognizer /// /// A base class for frame recognizers. Subclasses (actual frame recognizers) /// should implement RecognizeFrame to provide a RecognizedStackFrame for a @@ -59,9 +59,7 @@ public: virtual ~StackFrameRecognizer(){}; }; -#ifndef LLDB_DISABLE_PYTHON - -/// @class ScriptedStackFrameRecognizer +/// \class ScriptedStackFrameRecognizer /// /// Python implementation for frame recognizers. An instance of this class /// tracks a particular Python classobject, which will be asked to recognize @@ -75,7 +73,7 @@ class ScriptedStackFrameRecognizer : public StackFrameRecognizer { public: ScriptedStackFrameRecognizer(lldb_private::ScriptInterpreter *interpreter, const char *pclass); - ~ScriptedStackFrameRecognizer() {} + ~ScriptedStackFrameRecognizer() override {} std::string GetName() override { return GetPythonClassName(); @@ -90,9 +88,7 @@ private: DISALLOW_COPY_AND_ASSIGN(ScriptedStackFrameRecognizer); }; -#endif - -/// @class StackFrameRecognizerManager +/// \class StackFrameRecognizerManager /// /// Static class that provides a registry of known stack frame recognizers. /// Has static methods to add, enumerate, remove, query and invoke recognizers. @@ -100,8 +96,8 @@ private: class StackFrameRecognizerManager { public: static void AddRecognizer(lldb::StackFrameRecognizerSP recognizer, - const ConstString &module, - const ConstString &symbol, + ConstString module, + ConstString symbol, bool first_instruction_only = true); static void AddRecognizer(lldb::StackFrameRecognizerSP recognizer, @@ -124,6 +120,42 @@ public: static lldb::RecognizedStackFrameSP RecognizeFrame(lldb::StackFrameSP frame); }; +/// \class ValueObjectRecognizerSynthesizedValue +/// +/// ValueObject subclass that presents the passed ValueObject as a recognized +/// value with the specified ValueType. Frame recognizers should return +/// instances of this class as the returned objects in GetRecognizedArguments(). + +class ValueObjectRecognizerSynthesizedValue : public ValueObject { + public: + static lldb::ValueObjectSP Create(ValueObject &parent, lldb::ValueType type) { + return (new ValueObjectRecognizerSynthesizedValue(parent, type))->GetSP(); + } + ValueObjectRecognizerSynthesizedValue(ValueObject &parent, + lldb::ValueType type) + : ValueObject(parent), m_type(type) { + SetName(parent.GetName()); + } + + uint64_t GetByteSize() override { return m_parent->GetByteSize(); } + lldb::ValueType GetValueType() const override { return m_type; } + bool UpdateValue() override { + if (!m_parent->UpdateValueIfNeeded()) return false; + m_value = m_parent->GetValue(); + return true; + } + size_t CalculateNumChildren(uint32_t max = UINT32_MAX) override { + return m_parent->GetNumChildren(max); + } + CompilerType GetCompilerTypeImpl() override { + return m_parent->GetCompilerType(); + } + bool IsSynthetic() override { return true; } + + private: + lldb::ValueType m_type; +}; + } // namespace lldb_private #endif // liblldb_StackFrameRecognizer_h_ diff --git a/include/lldb/Target/StackID.h b/include/lldb/Target/StackID.h index 871f39c463a95..a649a4faa9391 100644 --- a/include/lldb/Target/StackID.h +++ b/include/lldb/Target/StackID.h @@ -1,9 +1,8 @@ //===-- StackID.h -----------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -17,9 +16,7 @@ namespace lldb_private { class StackID { public: - //------------------------------------------------------------------ // Constructors and Destructors - //------------------------------------------------------------------ StackID() : m_pc(LLDB_INVALID_ADDRESS), m_cfa(LLDB_INVALID_ADDRESS), m_symbol_scope(nullptr) {} @@ -55,9 +52,7 @@ public: void Dump(Stream *s); - //------------------------------------------------------------------ // Operators - //------------------------------------------------------------------ const StackID &operator=(const StackID &rhs) { if (this != &rhs) { m_pc = rhs.m_pc; diff --git a/include/lldb/Target/StopInfo.h b/include/lldb/Target/StopInfo.h index 1a9f5b8480dbd..59033b1b64416 100644 --- a/include/lldb/Target/StopInfo.h +++ b/include/lldb/Target/StopInfo.h @@ -1,9 +1,8 @@ //===-- StopInfo.h ----------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -23,9 +22,7 @@ class StopInfo { friend class ThreadPlanBase; public: - //------------------------------------------------------------------ // Constructors and Destructors - //------------------------------------------------------------------ StopInfo(Thread &thread, uint64_t value); virtual ~StopInfo() {} @@ -157,9 +154,7 @@ protected: // to consult this later on. virtual bool ShouldStop(Event *event_ptr) { return true; } - //------------------------------------------------------------------ // Classes that inherit from StackID can see and modify these - //------------------------------------------------------------------ lldb::ThreadWP m_thread_wp; // The thread corresponding to the stop reason. uint32_t m_stop_id; // The process stop ID for which this stop info is valid uint32_t m_resume_id; // This is the resume ID when we made this stop ID. diff --git a/include/lldb/Target/StructuredDataPlugin.h b/include/lldb/Target/StructuredDataPlugin.h index 5ea265b054205..b20bdb3b263a3 100644 --- a/include/lldb/Target/StructuredDataPlugin.h +++ b/include/lldb/Target/StructuredDataPlugin.h @@ -1,9 +1,8 @@ //===-- StructuredDataPlugin.h ----------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -17,7 +16,6 @@ namespace lldb_private { class CommandObjectMultiword; -// ----------------------------------------------------------------------------- /// Plugin that supports process-related structured data sent asynchronously /// from the debug monitor (e.g. debugserver, lldb-server, etc.) /// @@ -38,21 +36,17 @@ class CommandObjectMultiword; /// and error streams such that the plugin can display something about the /// event, at a time when the debugger ensures it is safe to write to the /// output or error streams. -// ----------------------------------------------------------------------------- class StructuredDataPlugin : public PluginInterface, public std::enable_shared_from_this<StructuredDataPlugin> { public: - virtual ~StructuredDataPlugin(); + ~StructuredDataPlugin() override; lldb::ProcessSP GetProcess() const; - // ------------------------------------------------------------------------- // Public instance API - // ------------------------------------------------------------------------- - // ------------------------------------------------------------------------- /// Return whether this plugin supports the given StructuredData feature. /// /// When Process is informed of a list of process-monitor-supported @@ -64,16 +58,14 @@ public: /// features, and if that happens, there is a single plugin instance /// created covering all of the mapped features for a given process. /// - /// @param[in] type_name + /// \param[in] type_name /// The name of the feature tag supported by a process. /// e.g. "darwin-log". /// - /// @return + /// \return /// true if the plugin supports the feature; otherwise, false. - // ------------------------------------------------------------------------- - virtual bool SupportsStructuredDataType(const ConstString &type_name) = 0; + virtual bool SupportsStructuredDataType(ConstString type_name) = 0; - // ------------------------------------------------------------------------- /// Handle the arrival of asynchronous structured data from the process. /// /// When asynchronous structured data arrives from the process monitor, @@ -84,27 +76,25 @@ public: /// value. This is the manner in which the data is routed to the proper /// plugin instance. /// - /// @param[in] process + /// \param[in] process /// The process instance that just received the structured data. /// This will always be the same process for a given instance of /// a plugin. /// - /// @param[in] type_name + /// \param[in] type_name /// The name of the feature tag for the asynchronous structured data. /// Note this data will also be present in the \b object_sp dictionary /// under the string value with key "type". /// - /// @param[in] object_sp + /// \param[in] object_sp /// A shared pointer to the structured data that arrived. This must /// be a dictionary. The only key required is the aforementioned /// key named "type" that must be a string value containing the /// structured data type name. - // ------------------------------------------------------------------------- virtual void - HandleArrivalOfStructuredData(Process &process, const ConstString &type_name, + HandleArrivalOfStructuredData(Process &process, ConstString type_name, const StructuredData::ObjectSP &object_sp) = 0; - // ------------------------------------------------------------------------- /// Get a human-readable description of the contents of the data. /// /// In command-line LLDB, this method will be called by the Debugger @@ -113,33 +103,29 @@ public: /// nothing will be printed; otherwise, a newline will be added to the end /// when displayed. /// - /// @param[in] object_sp + /// \param[in] object_sp /// A shared pointer to the structured data to format. /// - /// @param[in] stream + /// \param[in] stream /// The stream where the structured data should be pretty printed. /// - /// @return + /// \return /// The error if formatting the object contents failed; otherwise, /// success. - // ------------------------------------------------------------------------- virtual Status GetDescription(const StructuredData::ObjectSP &object_sp, lldb_private::Stream &stream) = 0; - // ------------------------------------------------------------------------- /// Returns whether the plugin's features are enabled. /// /// This is a convenience method for plugins that can enable or disable /// their functionality. It allows retrieval of this state without /// requiring a cast. /// - /// @param[in] type_name + /// \param[in] type_name /// The name of the feature tag for the asynchronous structured data. /// This is needed for plugins that support more than one feature. - // ------------------------------------------------------------------------- - virtual bool GetEnabled(const ConstString &type_name) const; + virtual bool GetEnabled(ConstString type_name) const; - // ------------------------------------------------------------------------- /// Allow the plugin to do work related to modules that loaded in the /// the corresponding process. /// @@ -147,24 +133,20 @@ public: /// if they have any behavior they want to enable/modify based on loaded /// modules. /// - /// @param[in] process + /// \param[in] process /// The process that just was notified of modules having been loaded. /// This will always be the same process for a given instance of /// a plugin. /// - /// @param[in] module_list + /// \param[in] module_list /// The list of modules that the process registered as having just /// loaded. See \b Process::ModulesDidLoad(...). - // ------------------------------------------------------------------------- virtual void ModulesDidLoad(Process &process, ModuleList &module_list); protected: - // ------------------------------------------------------------------------- // Derived-class API - // ------------------------------------------------------------------------- StructuredDataPlugin(const lldb::ProcessWP &process_wp); - // ------------------------------------------------------------------------- /// Derived classes must call this before attempting to hook up commands /// to the 'plugin structured-data' tree. /// @@ -172,10 +154,9 @@ protected: /// StructuredDataPlugin derived classes are available for this debugger. /// If this has already happened, this call is a no-op. /// - /// @param[in] debugger + /// \param[in] debugger /// The Debugger instance for which we're creating the required shared /// components for the StructuredDataPlugin derived classes. - // ------------------------------------------------------------------------- static void InitializeBasePluginForDebugger(Debugger &debugger); private: diff --git a/include/lldb/Target/SystemRuntime.h b/include/lldb/Target/SystemRuntime.h index 328dbe2310783..b45f882d36b0e 100644 --- a/include/lldb/Target/SystemRuntime.h +++ b/include/lldb/Target/SystemRuntime.h @@ -1,9 +1,8 @@ //===-- SystemRuntime.h -----------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -23,8 +22,7 @@ namespace lldb_private { -//---------------------------------------------------------------------- -/// @class SystemRuntime SystemRuntime.h "lldb/Target/SystemRuntime.h" +/// \class SystemRuntime SystemRuntime.h "lldb/Target/SystemRuntime.h" /// A plug-in interface definition class for system runtimes. /// /// The system runtime plugins can collect information from the system @@ -40,68 +38,52 @@ namespace lldb_private { /// collecting information. Later when it comes time to augment a Thread, it /// can be asked to provide that information. /// -//---------------------------------------------------------------------- class SystemRuntime : public PluginInterface { public: - //------------------------------------------------------------------ /// Find a system runtime plugin for a given process. /// /// Scans the installed SystemRuntime plugins and tries to find an instance /// that can be used to track image changes in \a process. /// - /// @param[in] process + /// \param[in] process /// The process for which to try and locate a system runtime /// plugin instance. - //------------------------------------------------------------------ static SystemRuntime *FindPlugin(Process *process); - //------------------------------------------------------------------ /// Construct with a process. - // ----------------------------------------------------------------- SystemRuntime(lldb_private::Process *process); - //------------------------------------------------------------------ /// Destructor. /// /// The destructor is virtual since this class is designed to be inherited /// by the plug-in instance. - //------------------------------------------------------------------ ~SystemRuntime() override; - //------------------------------------------------------------------ /// Called after attaching to a process. /// /// Allow the SystemRuntime plugin to execute some code after attaching to a /// process. - //------------------------------------------------------------------ virtual void DidAttach(); - //------------------------------------------------------------------ /// Called after launching a process. /// /// Allow the SystemRuntime plugin to execute some code after launching a /// process. - //------------------------------------------------------------------ virtual void DidLaunch(); - //------------------------------------------------------------------ /// Called when modules have been loaded in the process. /// /// Allow the SystemRuntime plugin to enable logging features in the system /// runtime libraries. - //------------------------------------------------------------------ virtual void ModulesDidLoad(lldb_private::ModuleList &module_list); - //------------------------------------------------------------------ /// 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. - //------------------------------------------------------------------ virtual void Detach(); - //------------------------------------------------------------------ /// Return a list of thread origin extended backtraces that may be /// available. /// @@ -119,14 +101,12 @@ public: /// libdispatch queue origin. If there is none, then request the pthread /// origin. /// - /// @return + /// \return /// A vector of ConstStrings with names like "pthread" or "libdispatch". /// An empty vector may be returned if no thread origin extended /// backtrace capabilities are available. - //------------------------------------------------------------------ virtual const std::vector<ConstString> &GetExtendedBacktraceTypes(); - //------------------------------------------------------------------ /// Return a Thread which shows the origin of this thread's creation. /// /// This likely returns a HistoryThread which shows how thread was @@ -137,25 +117,23 @@ public: /// 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 + /// \param [in] thread /// The thread to examine. /// - /// @param [in] type + /// \param [in] type /// The type of thread origin being requested. The types supported /// are returned from SystemRuntime::GetExtendedBacktraceTypes. /// - /// @return + /// \return /// A ThreadSP which will have a StackList of frames. This Thread will /// not appear in the Process' list of current threads. Normal thread /// operations like stepping will not be available. This is a historical /// view thread and may be only useful for showing a backtrace. /// /// An empty ThreadSP will be returned if no thread origin is available. - //------------------------------------------------------------------ virtual lldb::ThreadSP GetExtendedBacktraceThread(lldb::ThreadSP thread, ConstString type); - //------------------------------------------------------------------ /// Get the extended backtrace thread for a QueueItem /// /// A QueueItem represents a function/block that will be executed on @@ -165,38 +143,34 @@ public: /// This method will report a thread backtrace of the function that enqueued /// it originally, if possible. /// - /// @param [in] queue_item_sp + /// \param [in] queue_item_sp /// The QueueItem that we are getting an extended backtrace for. /// - /// @param [in] type + /// \param [in] type /// The type of extended backtrace to fetch. The types supported /// are returned from SystemRuntime::GetExtendedBacktraceTypes. /// - /// @return + /// \return /// If an extended backtrace is available, it is returned. Else /// an empty ThreadSP is returned. - //------------------------------------------------------------------ virtual lldb::ThreadSP GetExtendedBacktraceForQueueItem(lldb::QueueItemSP queue_item_sp, ConstString type) { return lldb::ThreadSP(); } - //------------------------------------------------------------------ /// 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. /// - /// @param [out] queue_list + /// \param [out] queue_list /// This QueueList will be cleared, and any queues that currently exist /// will be added. An empty QueueList will be returned if no queues /// exist or if this Systemruntime does not support libdispatch queues. - //------------------------------------------------------------------ virtual void PopulateQueueList(lldb_private::QueueList &queue_list) {} - //------------------------------------------------------------------ /// 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 @@ -205,19 +179,17 @@ public: /// 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 + /// \param [in] dispatch_qaddr /// The address of the dispatch_qaddr pointer for this thread. /// - /// @return + /// \return /// The string of this queue's name. An empty string is returned if the /// name could not be found. - //------------------------------------------------------------------ virtual std::string GetQueueNameFromThreadQAddress(lldb::addr_t dispatch_qaddr) { return ""; } - //------------------------------------------------------------------ /// Get the QueueID for the libdispatch queue given the thread's /// dispatch_qaddr. /// @@ -227,18 +199,16 @@ public: /// 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 + /// \param [in] dispatch_qaddr /// The address of the dispatch_qaddr pointer for this thread. /// - /// @return + /// \return /// The queue ID, or if it could not be retrieved, LLDB_INVALID_QUEUE_ID. - //------------------------------------------------------------------ virtual lldb::queue_id_t GetQueueIDFromThreadQAddress(lldb::addr_t dispatch_qaddr) { return LLDB_INVALID_QUEUE_ID; } - //------------------------------------------------------------------ /// Get the libdispatch_queue_t address for the queue given the thread's /// dispatch_qaddr. /// @@ -247,71 +217,62 @@ public: /// the thread's dispatch_qaddr, find the libdispatch_queue_t address and /// return it. /// - /// @param [in] dispatch_qaddr + /// \param [in] dispatch_qaddr /// The address of the dispatch_qaddr pointer for this thread. /// - /// @return + /// \return /// The libdispatch_queue_t address, or LLDB_INVALID_ADDRESS if /// unavailable/not found. - //------------------------------------------------------------------ virtual lldb::addr_t GetLibdispatchQueueAddressFromThreadQAddress(lldb::addr_t dispatch_qaddr) { return LLDB_INVALID_ADDRESS; } - //------------------------------------------------------------------ /// 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. /// - /// @return + /// \return /// The Queue kind, if it could be read, else eQueueKindUnknown. - //------------------------------------------------------------------ virtual lldb::QueueKind GetQueueKind(lldb::addr_t dispatch_qaddr) { return lldb::eQueueKindUnknown; } - //------------------------------------------------------------------ /// 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. /// - /// @param [in] queue + /// \param [in] queue /// The queue of interest. - //------------------------------------------------------------------ virtual void PopulatePendingItemsForQueue(lldb_private::Queue *queue) {} - //------------------------------------------------------------------ /// 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. /// - /// @param [in] queue_item + /// \param [in] queue_item /// The QueueItem that we will be completing. /// - /// @param [in] item_ref + /// \param [in] item_ref /// The item_ref token that is needed to retrieve the rest of the /// information about the QueueItem. - //------------------------------------------------------------------ virtual void CompleteQueueItem(lldb_private::QueueItem *queue_item, lldb::addr_t item_ref) {} - //------------------------------------------------------------------ /// Add key-value pairs to the StructuredData dictionary object with /// information debugserver may need when constructing the /// jThreadExtendedInfo packet. /// - /// @param [out] dict + /// \param [out] dict /// Dictionary to which key-value pairs should be added; they will /// be sent to the remote gdb server stub as arguments in the /// jThreadExtendedInfo request. - //------------------------------------------------------------------ virtual void AddThreadExtendedInfoPacketHints( lldb_private::StructuredData::ObjectSP dict) {} @@ -321,22 +282,19 @@ public: /// this method gives a way for it to flag that the expression should not be /// run. /// - /// @param [in] thread_sp + /// \param [in] thread_sp /// The thread we want to run the expression on. /// - /// @return + /// \return /// True will be returned if there are no known problems with running an /// expression on this thread. False means that the inferior function /// call should not be made on this thread. - //------------------------------------------------------------------ virtual bool SafeToCallFunctionsOnThisThread(lldb::ThreadSP thread_sp) { return true; } protected: - //------------------------------------------------------------------ // Member variables. - //------------------------------------------------------------------ Process *m_process; std::vector<ConstString> m_types; diff --git a/include/lldb/Target/Target.h b/include/lldb/Target/Target.h index 90df1f4929b77..4ed11afc31ba6 100644 --- a/include/lldb/Target/Target.h +++ b/include/lldb/Target/Target.h @@ -1,9 +1,8 @@ //===-- Target.h ------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -24,10 +23,10 @@ #include "lldb/Core/ModuleList.h" #include "lldb/Core/UserSettingsController.h" #include "lldb/Expression/Expression.h" +#include "lldb/Host/ProcessLaunchInfo.h" #include "lldb/Symbol/TypeSystem.h" #include "lldb/Target/ExecutionContextScope.h" #include "lldb/Target/PathMappingList.h" -#include "lldb/Target/ProcessLaunchInfo.h" #include "lldb/Target/SectionLoadHistory.h" #include "lldb/Utility/ArchSpec.h" #include "lldb/Utility/Broadcaster.h" @@ -39,33 +38,31 @@ namespace lldb_private { OptionEnumValues GetDynamicValueTypes(); -typedef enum InlineStrategy { +enum InlineStrategy { eInlineBreakpointsNever = 0, eInlineBreakpointsHeaders, eInlineBreakpointsAlways -} InlineStrategy; +}; -typedef enum LoadScriptFromSymFile { +enum LoadScriptFromSymFile { eLoadScriptFromSymFileTrue, eLoadScriptFromSymFileFalse, eLoadScriptFromSymFileWarn -} LoadScriptFromSymFile; +}; -typedef enum LoadCWDlldbinitFile { +enum LoadCWDlldbinitFile { eLoadCWDlldbinitTrue, eLoadCWDlldbinitFalse, eLoadCWDlldbinitWarn -} LoadCWDlldbinitFile; +}; -typedef enum LoadDependentFiles { +enum LoadDependentFiles { eLoadDependentsDefault, eLoadDependentsYes, eLoadDependentsNo, -} LoadDependentFiles; +}; -//---------------------------------------------------------------------- // TargetProperties -//---------------------------------------------------------------------- class TargetExperimentalProperties : public Properties { public: TargetExperimentalProperties(); @@ -122,14 +119,18 @@ public: PathMappingList &GetSourcePathMap() const; - FileSpecList &GetExecutableSearchPaths(); + FileSpecList GetExecutableSearchPaths(); - FileSpecList &GetDebugFileSearchPaths(); + void AppendExecutableSearchPaths(const FileSpec&); - FileSpecList &GetClangModuleSearchPaths(); + FileSpecList GetDebugFileSearchPaths(); + + FileSpecList GetClangModuleSearchPaths(); bool GetEnableAutoImportClangModules() const; + bool GetEnableImportStdModule() const; + bool GetEnableAutoApplyFixIts() const; bool GetEnableNotifyAboutFixIts() const; @@ -207,9 +208,7 @@ public: bool GetRequireHardwareBreakpoints() const; private: - //------------------------------------------------------------------ // Callbacks for m_launch_info. - //------------------------------------------------------------------ static void Arg0ValueChangedCallback(void *target_property_ptr, OptionValue *); static void RunArgsValueChangedCallback(void *target_property_ptr, @@ -231,9 +230,7 @@ private: static void DisableSTDIOValueChangedCallback(void *target_property_ptr, OptionValue *); - //------------------------------------------------------------------ // Member variables. - //------------------------------------------------------------------ ProcessLaunchInfo m_launch_info; std::unique_ptr<TargetExperimentalProperties> m_experimental_properties_up; }; @@ -422,9 +419,7 @@ private: mutable uint32_t m_pound_line_line; }; -//---------------------------------------------------------------------- // Target -//---------------------------------------------------------------------- class Target : public std::enable_shared_from_this<Target>, public TargetProperties, public Broadcaster, @@ -433,9 +428,7 @@ class Target : public std::enable_shared_from_this<Target>, public: friend class TargetList; - //------------------------------------------------------------------ /// Broadcaster event bits definitions. - //------------------------------------------------------------------ enum { eBroadcastBitBreakpointChanged = (1 << 0), eBroadcastBitModulesLoaded = (1 << 1), @@ -463,9 +456,9 @@ public: ~TargetEventData() override; - static const ConstString &GetFlavorString(); + static ConstString GetFlavorString(); - const ConstString &GetFlavor() const override { + ConstString GetFlavor() const override { return TargetEventData::GetFlavorString(); } @@ -498,18 +491,46 @@ public: static FileSpecList GetDefaultDebugFileSearchPaths(); - static FileSpecList GetDefaultClangModuleSearchPaths(); - static ArchSpec GetDefaultArchitecture(); static void SetDefaultArchitecture(const ArchSpec &arch); - lldb::ModuleSP GetSharedModule(const ModuleSpec &module_spec, - Status *error_ptr = nullptr); + /// Find a binary on the system and return its Module, + /// or return an existing Module that is already in the Target. + /// + /// Given a ModuleSpec, find a binary satisifying that specification, + /// or identify a matching Module already present in the Target, + /// and return a shared pointer to it. + /// + /// \param[in] module_spec + /// The criteria that must be matched for the binary being loaded. + /// e.g. UUID, architecture, file path. + /// + /// \param[in] notify + /// If notify is true, and the Module is new to this Target, + /// Target::ModulesDidLoad will be called. + /// If notify is false, it is assumed that the caller is adding + /// multiple Modules and will call ModulesDidLoad with the + /// full list at the end. + /// ModulesDidLoad must be called when a Module/Modules have + /// been added to the target, one way or the other. + /// + /// \param[out] error_ptr + /// Optional argument, pointing to a Status object to fill in + /// with any results / messages while attempting to find/load + /// this binary. Many callers will be internal functions that + /// will handle / summarize the failures in a custom way and + /// don't use these messages. + /// + /// \return + /// An empty ModuleSP will be returned if no matching file + /// was found. If error_ptr was non-nullptr, an error message + /// will likely be provided. + lldb::ModuleSP GetOrCreateModule(const ModuleSpec &module_spec, + bool notify, + Status *error_ptr = nullptr); - //---------------------------------------------------------------------- // Settings accessors - //---------------------------------------------------------------------- static const lldb::TargetPropertiesSP &GetGlobalProperties(); @@ -519,7 +540,6 @@ public: void CleanupProcess(); - //------------------------------------------------------------------ /// Dump a description of this object to a Stream. /// /// Dump a description of the contents of this object to the @@ -528,9 +548,8 @@ public: /// is called, so this is a good way to see what has been parsed /// in a target. /// - /// @param[in] s + /// \param[in] s /// The stream to which to dump the object description. - //------------------------------------------------------------------ void Dump(Stream *s, lldb::DescriptionLevel description_level); // If listener_sp is null, the listener of the owning Debugger object will be @@ -551,9 +570,7 @@ public: Status Attach(ProcessAttachInfo &attach_info, Stream *stream); // Optional stream to receive first stop info - //------------------------------------------------------------------ // This part handles the breakpoints. - //------------------------------------------------------------------ BreakpointList &GetBreakpointList(bool internal = false); @@ -681,12 +698,12 @@ public: Status &error); void RemoveNameFromBreakpoint(lldb::BreakpointSP &bp_sp, - const ConstString &name); + ConstString name); - BreakpointName *FindBreakpointName(const ConstString &name, bool can_create, + BreakpointName *FindBreakpointName(ConstString name, bool can_create, Status &error); - void DeleteBreakpointName(const ConstString &name); + void DeleteBreakpointName(ConstString name); void ConfigureBreakpointName(BreakpointName &bp_name, const BreakpointOptions &options, @@ -752,7 +769,6 @@ public: std::vector<std::string> &names, BreakpointIDList &new_bps); - //------------------------------------------------------------------ /// Get \a load_addr as a callable code load address for this target /// /// Take \a load_addr and potentially add any address bits that are @@ -762,12 +778,10 @@ public: /// 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, AddressClass addr_class = AddressClass::eInvalid) const; - //------------------------------------------------------------------ /// Get \a load_addr as an opcode for this target. /// /// Take \a load_addr and potentially strip any address bits that are @@ -778,7 +792,6 @@ public: /// 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, AddressClass addr_class = AddressClass::eInvalid) const; @@ -798,7 +811,6 @@ public: void ClearModules(bool delete_locations); - //------------------------------------------------------------------ /// Called as the last function in Process::DidExec(). /// /// Process::DidExec() will clear a lot of state in the process, @@ -808,10 +820,8 @@ public: /// has been figured out. It can remove breakpoints that no longer /// make sense as the exec might have changed the target /// architecture, and unloaded some modules that might get deleted. - //------------------------------------------------------------------ void DidExec(); - //------------------------------------------------------------------ /// Gets the module for the main executable. /// /// Each process has a notion of a main executable that is the file @@ -819,20 +829,18 @@ public: /// dependent modules that are discovered from the object files, or /// discovered at runtime as things are dynamically loaded. /// - /// @return + /// \return /// The shared pointer to the executable module which can /// contains a nullptr Module object if no executable has been /// set. /// - /// @see DynamicLoader - /// @see ObjectFile::GetDependentModules (FileSpecList&) - /// @see Process::SetExecutableModule(lldb::ModuleSP&) - //------------------------------------------------------------------ + /// \see DynamicLoader + /// \see ObjectFile::GetDependentModules (FileSpecList&) + /// \see Process::SetExecutableModule(lldb::ModuleSP&) lldb::ModuleSP GetExecutableModule(); Module *GetExecutableModulePointer(); - //------------------------------------------------------------------ /// Set the main executable module. /// /// Each process has a notion of a main executable that is the file @@ -848,17 +856,16 @@ public: /// Process::GetImages() will return the newly found images that /// were obtained from all of the object files. /// - /// @param[in] module_sp + /// \param[in] module_sp /// A shared pointer reference to the module that will become /// the main executable for this process. /// - /// @param[in] load_dependent_files + /// \param[in] load_dependent_files /// If \b true then ask the object files to track down any /// known dependent files. /// - /// @see ObjectFile::GetDependentModules (FileSpecList&) - /// @see Process::GetImages() - //------------------------------------------------------------------ + /// \see ObjectFile::GetDependentModules (FileSpecList&) + /// \see Process::GetImages() void SetExecutableModule( lldb::ModuleSP &module_sp, LoadDependentFiles load_dependent_files = eLoadDependentsDefault); @@ -870,7 +877,6 @@ public: this, errors, feedback_stream, continue_on_error); } - //------------------------------------------------------------------ /// Get accessor for the images for this process. /// /// Each process has a notion of a main executable that is the file @@ -886,14 +892,12 @@ public: /// addresses is each image, and also in images that are loaded by /// code. /// - /// @return + /// \return /// A list of Module objects in a module list. - //------------------------------------------------------------------ const ModuleList &GetImages() const { return m_images; } ModuleList &GetImages() { return m_images; } - //------------------------------------------------------------------ /// Return whether this FileSpec corresponds to a module that should be /// considered for general searches. /// @@ -905,14 +909,12 @@ public: /// The target call at present just consults the Platform's call of the /// same name. /// - /// @param[in] module_sp + /// \param[in] module_sp /// A shared pointer reference to the module that checked. /// - /// @return \b true if the module should be excluded, \b false otherwise. - //------------------------------------------------------------------ + /// \return \b true if the module should be excluded, \b false otherwise. bool ModuleIsExcludedForUnconstrainedSearches(const FileSpec &module_spec); - //------------------------------------------------------------------ /// Return whether this module should be considered for general searches. /// /// This API will be consulted by the SearchFilterForUnconstrainedSearches @@ -927,17 +929,15 @@ public: /// that they /// don't want searched, in addition to or instead of the platform ones. /// - /// @param[in] module_sp + /// \param[in] module_sp /// A shared pointer reference to the module that checked. /// - /// @return \b true if the module should be excluded, \b false otherwise. - //------------------------------------------------------------------ + /// \return \b true if the module should be excluded, \b false otherwise. bool ModuleIsExcludedForUnconstrainedSearches(const lldb::ModuleSP &module_sp); const ArchSpec &GetArchitecture() const { return m_arch.GetSpec(); } - //------------------------------------------------------------------ /// Set the architecture for this target. /// /// If the current target has no Images read in, then this just sets the @@ -951,19 +951,18 @@ public: /// won't be changed. If the input arch_spec is the same as the already set /// architecture, this is a no-op. /// - /// @param[in] arch_spec + /// \param[in] arch_spec /// The new architecture. /// - /// @param[in] set_platform + /// \param[in] set_platform /// If \b true, then the platform will be adjusted if the currently /// selected platform is not compatible with the archicture being set. /// If \b false, then just the architecture will be set even if the /// currently selected platform isn't compatible (in case it might be /// manually set following this function call). /// - /// @return + /// \return /// \b true if the architecture was successfully set, \bfalse otherwise. - //------------------------------------------------------------------ bool SetArchitecture(const ArchSpec &arch_spec, bool set_platform = false); bool MergeArchitecture(const ArchSpec &arch_spec); @@ -1015,9 +1014,7 @@ public: static Target *GetTargetFromContexts(const ExecutionContext *exe_ctx_ptr, const SymbolContext *sc_ptr); - //------------------------------------------------------------------ // lldb::ExecutionContextScope pure virtual functions - //------------------------------------------------------------------ lldb::TargetSP CalculateTarget() override; lldb::ProcessSP CalculateProcess() override; @@ -1044,7 +1041,8 @@ public: UserExpression *GetUserExpressionForLanguage( llvm::StringRef expr, llvm::StringRef prefix, lldb::LanguageType language, Expression::ResultType desired_type, - const EvaluateExpressionOptions &options, Status &error); + const EvaluateExpressionOptions &options, + ValueObject *ctx_obj, Status &error); // Creates a FunctionCaller for the given language, the rest of the // parameters have the same meaning as for the FunctionCaller constructor. @@ -1073,10 +1071,8 @@ public: lldb::ClangASTImporterSP GetClangASTImporter(); - //---------------------------------------------------------------------- // Install any files through the platform that need be to installed prior to // launching or attaching. - //---------------------------------------------------------------------- Status Install(ProcessLaunchInfo *launch_info); bool ResolveFileAddress(lldb::addr_t load_addr, Address &so_addr); @@ -1103,25 +1099,24 @@ public: // 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. + // the execution context. lldb::ExpressionResults EvaluateExpression( llvm::StringRef expression, ExecutionContextScope *exe_scope, lldb::ValueObjectSP &result_valobj_sp, const EvaluateExpressionOptions &options = EvaluateExpressionOptions(), - std::string *fixed_expression = nullptr); + std::string *fixed_expression = nullptr, + ValueObject *ctx_obj = nullptr); - lldb::ExpressionVariableSP GetPersistentVariable(const ConstString &name); + lldb::ExpressionVariableSP GetPersistentVariable(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); + lldb::addr_t GetPersistentSymbol(ConstString name); - //------------------------------------------------------------------ // Target Stop Hooks - //------------------------------------------------------------------ class StopHook : public UserID { public: StopHook(const StopHook &rhs); @@ -1146,20 +1141,25 @@ public: // and is responsible for deleting it when we're done. void SetThreadSpecifier(ThreadSpec *specifier); - ThreadSpec *GetThreadSpecifier() { return m_thread_spec_ap.get(); } + ThreadSpec *GetThreadSpecifier() { return m_thread_spec_up.get(); } bool IsActive() { return m_active; } void SetIsActive(bool is_active) { m_active = is_active; } + void SetAutoContinue(bool auto_continue) {m_auto_continue = auto_continue;} + + bool GetAutoContinue() const { return m_auto_continue; } + void GetDescription(Stream *s, lldb::DescriptionLevel level) const; private: lldb::TargetSP m_target_sp; StringList m_commands; lldb::SymbolContextSpecifierSP m_specifier_sp; - std::unique_ptr<ThreadSpec> m_thread_spec_ap; - bool m_active; + std::unique_ptr<ThreadSpec> m_thread_spec_up; + bool m_active = true; + bool m_auto_continue = false; // Use CreateStopHook to make a new empty stop hook. The GetCommandPointer // and fill it with commands, and SetSpecifier to set the specifier shared @@ -1219,9 +1219,7 @@ public: ClangModulesDeclVendor *GetClangModulesDeclVendor(); - //------------------------------------------------------------------ // Methods. - //------------------------------------------------------------------ lldb::SearchFilterSP GetSearchFilterForModule(const FileSpec *containingModule); @@ -1238,20 +1236,21 @@ public: void SetREPL(lldb::LanguageType language, lldb::REPLSP repl_sp); protected: - //------------------------------------------------------------------ /// Implementing of ModuleList::Notifier. - //------------------------------------------------------------------ - void ModuleAdded(const ModuleList &module_list, - const lldb::ModuleSP &module_sp) override; + void NotifyModuleAdded(const ModuleList &module_list, + const lldb::ModuleSP &module_sp) override; + + void NotifyModuleRemoved(const ModuleList &module_list, + const lldb::ModuleSP &module_sp) override; + + void NotifyModuleUpdated(const ModuleList &module_list, + const lldb::ModuleSP &old_module_sp, + const lldb::ModuleSP &new_module_sp) override; - void ModuleRemoved(const ModuleList &module_list, - const lldb::ModuleSP &module_sp) override; + void NotifyWillClearList(const ModuleList &module_list) override; - void ModuleUpdated(const ModuleList &module_list, - const lldb::ModuleSP &old_module_sp, - const lldb::ModuleSP &new_module_sp) override; - void WillClearList(const ModuleList &module_list) override; + void NotifyModulesRemoved(lldb_private::ModuleList &module_list) override; class Arch { public: @@ -1265,9 +1264,7 @@ protected: ArchSpec m_spec; std::unique_ptr<Architecture> m_plugin_up; }; - //------------------------------------------------------------------ // Member variables. - //------------------------------------------------------------------ Debugger &m_debugger; lldb::PlatformSP m_platform_sp; ///< The platform for this target. std::recursive_mutex m_mutex; ///< An API mutex that is used by the lldb::SB* @@ -1296,9 +1293,9 @@ protected: REPLMap m_repl_map; lldb::ClangASTImporterSP m_ast_importer_sp; - lldb::ClangModulesDeclVendorUP m_clang_modules_decl_vendor_ap; + lldb::ClangModulesDeclVendorUP m_clang_modules_decl_vendor_up; - lldb::SourceManagerUP m_source_manager_ap; + lldb::SourceManagerUP m_source_manager_up; typedef std::map<lldb::user_id_t, StopHookSP> StopHookCollection; StopHookCollection m_stop_hooks; @@ -1311,9 +1308,7 @@ protected: 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; @@ -1334,15 +1329,13 @@ public: std::vector<uint32_t> GetStatistics() { return m_stats_storage; } private: - //------------------------------------------------------------------ /// Construct with optional file and arch. /// /// This member is private. Clients must use /// TargetList::CreateTarget(const FileSpec*, const ArchSpec*) /// so all targets can be tracked from the central target list. /// - /// @see TargetList::CreateTarget(const FileSpec*, const ArchSpec*) - //------------------------------------------------------------------ + /// \see TargetList::CreateTarget(const FileSpec*, const ArchSpec*) Target(Debugger &debugger, const ArchSpec &target_arch, const lldb::PlatformSP &platform_sp, bool is_dummy_target); diff --git a/include/lldb/Target/TargetList.h b/include/lldb/Target/TargetList.h index 90c480745a0cb..ece0705ae71c0 100644 --- a/include/lldb/Target/TargetList.h +++ b/include/lldb/Target/TargetList.h @@ -1,9 +1,8 @@ //===-- TargetList.h --------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -22,21 +21,17 @@ class TargetList : public Broadcaster { private: friend class Debugger; - //------------------------------------------------------------------ /// Constructor /// /// The constructor for the target list is private. Clients can /// get ahold of of the one and only target list through the /// lldb_private::Debugger::GetSharedInstance().GetTargetList(). /// - /// @see static TargetList& lldb_private::Debugger::GetTargetList(). - //------------------------------------------------------------------ + /// \see static TargetList& lldb_private::Debugger::GetTargetList(). TargetList(Debugger &debugger); public: - //------------------------------------------------------------------ /// Broadcaster event bits definitions. - //------------------------------------------------------------------ enum { eBroadcastBitInterrupt = (1 << 0) }; // These two functions fill out the Broadcaster interface: @@ -49,7 +44,6 @@ public: ~TargetList() override; - //------------------------------------------------------------------ /// Create a new Target. /// /// Clients must use this function to create a Target. This allows @@ -58,68 +52,63 @@ public: /// locate an appropriate target to deliver asynchronous information /// to. /// - /// @param[in] debugger + /// \param[in] debugger /// The debugger to associate this target with /// - /// @param[in] file_spec + /// \param[in] file_spec /// The main executable file for a debug target. This value /// can be nullptr and the file can be set later using: /// Target::SetExecutableModule (ModuleSP&) /// - /// @param[in] triple_cstr + /// \param[in] triple_cstr /// A target triple string to be used for the target. This can /// be nullptr if the triple is not known or when attaching to a /// process. /// - /// @param[in] get_dependent_modules + /// \param[in] get_dependent_modules /// Track down the dependent modules for an executable and /// load those into the module list. /// - /// @param[in] platform_options + /// \param[in] platform_options /// A pointer to the platform options to use when creating this /// target. If this value is nullptr, then the currently selected /// platform will be used. /// - /// @param[out] target_sp + /// \param[out] target_sp /// A shared pointer to a target that will be filled in if /// this call is successful. /// - /// @return + /// \return /// An error object that indicates success or failure - //------------------------------------------------------------------ Status CreateTarget(Debugger &debugger, llvm::StringRef user_exe_path, llvm::StringRef triple_str, LoadDependentFiles get_dependent_modules, const OptionGroupPlatform *platform_options, lldb::TargetSP &target_sp); - //------------------------------------------------------------------ /// Create a new Target. /// /// Same as the function above, but used when you already know the /// platform you will be using - //------------------------------------------------------------------ Status CreateTarget(Debugger &debugger, llvm::StringRef user_exe_path, const ArchSpec &arch, LoadDependentFiles get_dependent_modules, lldb::PlatformSP &platform_sp, lldb::TargetSP &target_sp); - //------------------------------------------------------------------ /// Delete a Target object from the list. /// /// When clients are done with the Target objects, this function /// should be called to release the memory associated with a target /// object. /// - /// @param[in] target_sp + /// \param[in] target_sp /// The shared pointer to a target. /// - /// @return + /// \return /// Returns \b true if the target was successfully removed from /// from this target list, \b false otherwise. The client will /// be left with the last remaining shared pointer to the target /// in \a target_sp which can then be properly released. - //------------------------------------------------------------------ bool DeleteTarget(lldb::TargetSP &target_sp); int GetNumTargets() const; @@ -128,12 +117,11 @@ public: uint32_t GetIndexOfTarget(lldb::TargetSP target_sp) const; - //------------------------------------------------------------------ /// Find the target that contains has an executable whose path /// matches \a exe_file_spec, and whose architecture matches /// \a arch_ptr if arch_ptr is not nullptr. /// - /// @param[in] exe_file_spec + /// \param[in] exe_file_spec /// A file spec containing a basename, or a full path (directory /// and basename). If \a exe_file_spec contains only a filename /// (empty GetDirectory() value) then matching will be done @@ -141,53 +129,48 @@ public: /// compared. If \a exe_file_spec contains a filename and a /// directory, then both must match. /// - /// @param[in] exe_arch_ptr + /// \param[in] exe_arch_ptr /// If not nullptr then the architecture also needs to match, else /// the architectures will be compared. /// - /// @return + /// \return /// A shared pointer to a target object. The returned shared /// pointer will contain nullptr if no target objects have a /// executable whose full or partial path matches /// with a matching process ID. - //------------------------------------------------------------------ lldb::TargetSP FindTargetWithExecutableAndArchitecture( const FileSpec &exe_file_spec, const ArchSpec *exe_arch_ptr = nullptr) const; - //------------------------------------------------------------------ /// Find the target that contains a process with process ID \a /// pid. /// - /// @param[in] pid + /// \param[in] pid /// The process ID to search our target list for. /// - /// @return + /// \return /// A shared pointer to a target object. The returned shared /// pointer will contain nullptr if no target objects own a process /// with a matching process ID. - //------------------------------------------------------------------ lldb::TargetSP FindTargetWithProcessID(lldb::pid_t pid) const; lldb::TargetSP FindTargetWithProcess(lldb_private::Process *process) const; lldb::TargetSP GetTargetSP(Target *target) const; - //------------------------------------------------------------------ /// Send an async interrupt to one or all processes. /// /// Find the target that contains the process with process ID \a /// pid and send a LLDB_EVENT_ASYNC_INTERRUPT event to the process's /// event queue. /// - /// @param[in] pid + /// \param[in] pid /// The process ID to search our target list for, if \a pid is /// LLDB_INVALID_PROCESS_ID, then the interrupt will be sent to /// all processes. /// - /// @return + /// \return /// The number of async interrupts sent. - //------------------------------------------------------------------ uint32_t SendAsyncInterrupt(lldb::pid_t pid = LLDB_INVALID_PROCESS_ID); uint32_t SignalIfRunning(lldb::pid_t pid, int signo); @@ -198,9 +181,7 @@ public: protected: typedef std::vector<lldb::TargetSP> collection; - //------------------------------------------------------------------ // Member variables. - //------------------------------------------------------------------ collection m_target_list; lldb::TargetSP m_dummy_target_sp; mutable std::recursive_mutex m_target_list_mutex; diff --git a/include/lldb/Target/Thread.h b/include/lldb/Target/Thread.h index 0d14b10c651f1..7aeaece5b5d51 100644 --- a/include/lldb/Target/Thread.h +++ b/include/lldb/Target/Thread.h @@ -1,9 +1,8 @@ //===-- Thread.h ------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -35,18 +34,16 @@ public: ~ThreadProperties() override; - //------------------------------------------------------------------ /// The regular expression returned determines symbols that this /// thread won't stop in during "step-in" operations. /// - /// @return + /// \return /// A pointer to a regular expression to compare against symbols, /// or nullptr if all symbols are allowed. /// - //------------------------------------------------------------------ const RegularExpression *GetSymbolsToAvoidRegexp(); - FileSpecList &GetLibrariesToAvoid() const; + FileSpecList GetLibrariesToAvoid() const; bool GetTraceEnabledState() const; @@ -65,9 +62,7 @@ class Thread : public std::enable_shared_from_this<Thread>, public ExecutionContextScope, public Broadcaster { public: - //------------------------------------------------------------------ /// Broadcaster event bits definitions. - //------------------------------------------------------------------ enum { eBroadcastBitStackChanged = (1 << 0), eBroadcastBitThreadSuspended = (1 << 1), @@ -92,9 +87,9 @@ public: ~ThreadEventData() override; - static const ConstString &GetFlavorString(); + static ConstString GetFlavorString(); - const ConstString &GetFlavor() const override { + ConstString GetFlavor() const override { return ThreadEventData::GetFlavorString(); } @@ -131,14 +126,13 @@ public: lldb::addr_t current_inlined_pc; }; - //------------------------------------------------------------------ /// Constructor /// - /// @param [in] process + /// \param [in] process /// - /// @param [in] tid + /// \param [in] tid /// - /// @param [in] use_invalid_index_id + /// \param [in] use_invalid_index_id /// Optional parameter, defaults to false. The only subclass that /// is likely to set use_invalid_index_id == true is the HistoryThread /// class. In that case, the Thread we are constructing represents @@ -147,7 +141,6 @@ public: /// to reuse the IndexID of that thread, or create a new one. If a /// client wants to know the original thread's IndexID, they should use /// Thread::GetExtendedBacktraceOriginatingIndexID(). - //------------------------------------------------------------------ Thread(Process &process, lldb::tid_t tid, bool use_invalid_index_id = false); ~Thread() override; @@ -168,7 +161,6 @@ public: void SetState(lldb::StateType state); - //------------------------------------------------------------------ /// Sets the USER resume state for this thread. If you set a thread to /// suspended with /// this API, it won't take part in any of the arbitration for ShouldResume, @@ -189,25 +181,22 @@ public: /// to force the thread to run (e.g. the "thread continue" command, or are /// resetting the state /// (e.g. in SBThread::Resume()), then pass true to override_suspend. - /// @return + /// \return /// The User resume state for this thread. - //------------------------------------------------------------------ void SetResumeState(lldb::StateType state, bool override_suspend = false) { if (m_resume_state == lldb::eStateSuspended && !override_suspend) return; m_resume_state = state; } - //------------------------------------------------------------------ /// Gets the USER resume state for this thread. This is not the same as what /// this thread is going to do for any particular step, however if this thread /// returns eStateSuspended, then the process control logic will never allow /// this /// thread to run. /// - /// @return + /// \return /// The User resume state for this thread. - //------------------------------------------------------------------ lldb::StateType GetResumeState() const { return m_resume_state; } // This function is called on all the threads before "ShouldResume" and @@ -267,7 +256,6 @@ public: virtual const char *GetInfo() { return nullptr; } - //------------------------------------------------------------------ /// Retrieve a dictionary of information about this thread /// /// On Mac OS X systems there may be voucher information. @@ -278,7 +266,6 @@ public: /// array /// being a dictionary (keys include "message" with the text of the trace /// message). - //------------------------------------------------------------------ StructuredData::ObjectSP GetExtendedInfo() { if (!m_extended_info_fetched) { m_extended_info = FetchThreadExtendedInfo(); @@ -291,7 +278,6 @@ public: virtual void SetName(const char *name) {} - //------------------------------------------------------------------ /// Whether this thread can be associated with a libdispatch queue /// /// The Thread may know if it is associated with a libdispatch queue, @@ -299,7 +285,7 @@ public: /// queue, or it may be unknown whether it is associated with a libdispatch /// queue. /// - /// @return + /// \return /// eLazyBoolNo if this thread is definitely not associated with a /// libdispatch queue (e.g. on a non-Darwin system where GCD aka /// libdispatch is not available). @@ -308,7 +294,6 @@ public: /// /// eLazyBoolCalculate this thread may be associated with a libdispatch /// queue but the thread doesn't know one way or the other. - //------------------------------------------------------------------ virtual lldb_private::LazyBool GetAssociatedWithLibdispatchQueue() { return eLazyBoolNo; } @@ -316,7 +301,6 @@ public: virtual void SetAssociatedWithLibdispatchQueue( lldb_private::LazyBool associated_with_libdispatch_queue) {} - //------------------------------------------------------------------ /// Retrieve the Queue ID for the queue currently using this Thread /// /// If this Thread is doing work on behalf of a libdispatch/GCD queue, @@ -327,29 +311,25 @@ public: /// queues and incrementing, a QueueID will not be reused for a /// different queue during the lifetime of a process. /// - /// @return + /// \return /// A QueueID if the Thread subclass implements this, else /// LLDB_INVALID_QUEUE_ID. - //------------------------------------------------------------------ virtual lldb::queue_id_t GetQueueID() { return LLDB_INVALID_QUEUE_ID; } virtual void SetQueueID(lldb::queue_id_t new_val) {} - //------------------------------------------------------------------ /// Retrieve the Queue name for the queue currently using this Thread /// /// If this Thread is doing work on behalf of a libdispatch/GCD queue, /// retrieve the Queue name. /// - /// @return + /// \return /// The Queue name, if the Thread subclass implements this, else /// nullptr. - //------------------------------------------------------------------ virtual const char *GetQueueName() { return nullptr; } virtual void SetQueueName(const char *name) {} - //------------------------------------------------------------------ /// Retrieve the Queue kind for the queue currently using this Thread /// /// If this Thread is doing work on behalf of a libdispatch/GCD queue, @@ -357,27 +337,23 @@ public: /// eQueueKindConcurrent, indicating that this queue processes work /// items serially or concurrently. /// - /// @return + /// \return /// The Queue kind, if the Thread subclass implements this, else /// eQueueKindUnknown. - //------------------------------------------------------------------ virtual lldb::QueueKind GetQueueKind() { return lldb::eQueueKindUnknown; } virtual void SetQueueKind(lldb::QueueKind kind) {} - //------------------------------------------------------------------ /// Retrieve the Queue for this thread, if any. /// - /// @return + /// \return /// A QueueSP for the queue that is currently associated with this /// thread. /// An empty shared pointer indicates that this thread is not /// associated with a queue, or libdispatch queues are not /// supported on this target. - //------------------------------------------------------------------ virtual lldb::QueueSP GetQueue() { return lldb::QueueSP(); } - //------------------------------------------------------------------ /// Retrieve the address of the libdispatch_queue_t struct for queue /// currently using this Thread /// @@ -389,17 +365,15 @@ public: /// lifetime and should not be used to identify a queue uniquely. Use /// the GetQueueID() call for that. /// - /// @return + /// \return /// The Queue's libdispatch_queue_t address if the Thread subclass /// implements this, else LLDB_INVALID_ADDRESS. - //------------------------------------------------------------------ virtual lldb::addr_t GetQueueLibdispatchQueueAddress() { return LLDB_INVALID_ADDRESS; } virtual void SetQueueLibdispatchQueueAddress(lldb::addr_t dispatch_queue_t) {} - //------------------------------------------------------------------ /// Whether this Thread already has all the Queue information cached or not /// /// A Thread may be associated with a libdispatch work Queue at a given @@ -412,7 +386,6 @@ public: /// This method allows the SystemRuntime to discover if a thread has this /// information already, instead of calling the thread to get the information /// and having the thread call the SystemRuntime again. - //------------------------------------------------------------------ virtual bool ThreadHasQueueInformation() const { return false; } virtual uint32_t GetStackFrameCount() { @@ -500,102 +473,89 @@ public: bool GetDescription(Stream &s, lldb::DescriptionLevel level, bool print_json_thread, bool print_json_stopinfo); - //------------------------------------------------------------------ /// Default implementation for stepping into. /// /// This function is designed to be used by commands where the /// process is publicly stopped. /// - /// @param[in] source_step + /// \param[in] source_step /// If true and the frame has debug info, then do a source level /// step in, else do a single instruction step in. /// - /// @param[in] step_in_avoids_code_without_debug_info + /// \param[in] step_in_avoids_code_without_debug_info /// If \a true, then avoid stepping into code that doesn't have /// debug info, else step into any code regardless of whether it /// has debug info. /// - /// @param[in] step_out_avoids_code_without_debug_info + /// \param[in] step_out_avoids_code_without_debug_info /// If \a true, then if you step out to code with no debug info, keep /// stepping out till you get to code with debug info. /// - /// @return + /// \return /// An error that describes anything that went wrong - //------------------------------------------------------------------ virtual Status StepIn(bool source_step, LazyBool step_in_avoids_code_without_debug_info = eLazyBoolCalculate, LazyBool step_out_avoids_code_without_debug_info = eLazyBoolCalculate); - //------------------------------------------------------------------ /// Default implementation for stepping over. /// /// This function is designed to be used by commands where the /// process is publicly stopped. /// - /// @param[in] source_step + /// \param[in] source_step /// If true and the frame has debug info, then do a source level /// step over, else do a single instruction step over. /// - /// @return + /// \return /// An error that describes anything that went wrong - //------------------------------------------------------------------ virtual Status StepOver( bool source_step, LazyBool step_out_avoids_code_without_debug_info = eLazyBoolCalculate); - //------------------------------------------------------------------ /// Default implementation for stepping out. /// /// This function is designed to be used by commands where the /// process is publicly stopped. /// - /// @return + /// \return /// An error that describes anything that went wrong - //------------------------------------------------------------------ virtual Status StepOut(); - //------------------------------------------------------------------ /// Retrieves the per-thread data area. /// Most OSs maintain a per-thread pointer (e.g. the FS register on /// x64), which we return the value of here. /// - /// @return + /// \return /// LLDB_INVALID_ADDRESS if not supported, otherwise the thread /// pointer value. - //------------------------------------------------------------------ virtual lldb::addr_t GetThreadPointer(); - //------------------------------------------------------------------ /// Retrieves the per-module TLS block for a thread. /// - /// @param[in] module + /// \param[in] module /// The module to query TLS data for. /// - /// @param[in] tls_file_addr + /// \param[in] tls_file_addr /// The thread local address in module - /// @return + /// \return /// If the thread has TLS data allocated for the /// module, the address of the TLS block. Otherwise /// LLDB_INVALID_ADDRESS is returned. - //------------------------------------------------------------------ virtual lldb::addr_t GetThreadLocalData(const lldb::ModuleSP module, lldb::addr_t tls_file_addr); - //------------------------------------------------------------------ /// Check whether this thread is safe to run functions /// /// The SystemRuntime may know of certain thread states (functions in /// process of execution, for instance) which can make it unsafe for /// functions to be called. /// - /// @return + /// \return /// True if it is safe to call functions on this thread. /// False if function calls should be avoided on this thread. - //------------------------------------------------------------------ virtual bool SafeToCallFunctions(); - //------------------------------------------------------------------ // 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 @@ -618,69 +578,63 @@ public: // annoying to do because there's no elegant way to friend a method to all // sub-classes of a given class. // - //------------------------------------------------------------------ - //------------------------------------------------------------------ /// Queues the base plan for a thread. /// The version returned by Process does some things that are useful, /// like handle breakpoints and signals, so if you return a plugin specific /// one you probably want to call through to the Process one for anything /// your plugin doesn't explicitly handle. /// - /// @param[in] abort_other_plans + /// \param[in] abort_other_plans /// \b true if we discard the currently queued plans and replace them with /// this one. /// Otherwise this plan will go on the end of the plan stack. /// - /// @return + /// \return /// A shared pointer to the newly queued thread plan, or nullptr if the /// plan could not be queued. - //------------------------------------------------------------------ virtual lldb::ThreadPlanSP QueueFundamentalPlan(bool abort_other_plans); - //------------------------------------------------------------------ /// Queues the plan used to step one instruction from the current PC of \a /// thread. /// - /// @param[in] step_over + /// \param[in] step_over /// \b true if we step over calls to functions, false if we step in. /// - /// @param[in] abort_other_plans + /// \param[in] abort_other_plans /// \b true if we discard the currently queued plans and replace them with /// this one. /// Otherwise this plan will go on the end of the plan stack. /// - /// @param[in] stop_other_threads + /// \param[in] stop_other_threads /// \b true if we will stop other threads while we single step this one. /// - /// @param[out] status + /// \param[out] status /// A status with an error if queuing failed. /// - /// @return + /// \return /// A shared pointer to the newly queued thread plan, or nullptr if the /// plan could not be queued. - //------------------------------------------------------------------ virtual lldb::ThreadPlanSP QueueThreadPlanForStepSingleInstruction( bool step_over, bool abort_other_plans, bool stop_other_threads, Status &status); - //------------------------------------------------------------------ /// Queues the plan used to step through an address range, stepping over /// function calls. /// - /// @param[in] abort_other_plans + /// \param[in] abort_other_plans /// \b true if we discard the currently queued plans and replace them with /// this one. /// Otherwise this plan will go on the end of the plan stack. /// - /// @param[in] type + /// \param[in] type /// Type of step to do, only eStepTypeInto and eStepTypeOver are supported /// by this plan. /// - /// @param[in] range + /// \param[in] range /// The address range to step through. /// - /// @param[in] addr_context + /// \param[in] addr_context /// When dealing with stepping through inlined functions the current PC is /// not enough information to know /// what "step" means. For instance a series of nested inline functions @@ -689,21 +643,20 @@ public: /// is supposed to be out of. // FIXME: Currently unused. /// - /// @param[in] stop_other_threads + /// \param[in] stop_other_threads /// \b true if we will stop other threads while we single step this one. /// - /// @param[out] status + /// \param[out] status /// A status with an error if queuing failed. /// - /// @param[in] step_out_avoids_code_without_debug_info + /// \param[in] step_out_avoids_code_without_debug_info /// If eLazyBoolYes, if the step over steps out it will continue to step /// out till it comes to a frame with debug info. /// If eLazyBoolCalculate, we will consult the default set in the thread. /// - /// @return + /// \return /// A shared pointer to the newly queued thread plan, or nullptr if the /// plan could not be queued. - //------------------------------------------------------------------ virtual lldb::ThreadPlanSP QueueThreadPlanForStepOverRange( bool abort_other_plans, const AddressRange &range, const SymbolContext &addr_context, lldb::RunMode stop_other_threads, @@ -719,23 +672,22 @@ public: Status &status, LazyBool step_out_avoids_code_without_debug_info = eLazyBoolCalculate); - //------------------------------------------------------------------ /// Queues the plan used to step through an address range, stepping into /// functions. /// - /// @param[in] abort_other_plans + /// \param[in] abort_other_plans /// \b true if we discard the currently queued plans and replace them with /// this one. /// Otherwise this plan will go on the end of the plan stack. /// - /// @param[in] type + /// \param[in] type /// Type of step to do, only eStepTypeInto and eStepTypeOver are supported /// by this plan. /// - /// @param[in] range + /// \param[in] range /// The address range to step through. /// - /// @param[in] addr_context + /// \param[in] addr_context /// When dealing with stepping through inlined functions the current PC is /// not enough information to know /// what "step" means. For instance a series of nested inline functions @@ -744,30 +696,29 @@ public: /// is supposed to be out of. // FIXME: Currently unused. /// - /// @param[in] step_in_target + /// \param[in] step_in_target /// Name if function we are trying to step into. We will step out if we /// don't land in that function. /// - /// @param[in] stop_other_threads + /// \param[in] stop_other_threads /// \b true if we will stop other threads while we single step this one. /// - /// @param[out] status + /// \param[out] status /// A status with an error if queuing failed. /// - /// @param[in] step_in_avoids_code_without_debug_info + /// \param[in] step_in_avoids_code_without_debug_info /// If eLazyBoolYes we will step out if we step into code with no debug /// info. /// If eLazyBoolCalculate we will consult the default set in the thread. /// - /// @param[in] step_out_avoids_code_without_debug_info + /// \param[in] step_out_avoids_code_without_debug_info /// If eLazyBoolYes, if the step over steps out it will continue to step /// out till it comes to a frame with debug info. /// If eLazyBoolCalculate, it will consult the default set in the thread. /// - /// @return + /// \return /// A shared pointer to the newly queued thread plan, or nullptr if the /// plan could not be queued. - //------------------------------------------------------------------ virtual lldb::ThreadPlanSP QueueThreadPlanForStepInRange( bool abort_other_plans, const AddressRange &range, const SymbolContext &addr_context, const char *step_in_target, @@ -785,16 +736,15 @@ public: LazyBool step_in_avoids_code_without_debug_info = eLazyBoolCalculate, LazyBool step_out_avoids_code_without_debug_info = eLazyBoolCalculate); - //------------------------------------------------------------------ /// Queue the plan used to step out of the function at the current PC of /// \a thread. /// - /// @param[in] abort_other_plans + /// \param[in] abort_other_plans /// \b true if we discard the currently queued plans and replace them with /// this one. /// Otherwise this plan will go on the end of the plan stack. /// - /// @param[in] addr_context + /// \param[in] addr_context /// When dealing with stepping through inlined functions the current PC is /// not enough information to know /// what "step" means. For instance a series of nested inline functions @@ -803,47 +753,45 @@ public: /// is supposed to be out of. // FIXME: Currently unused. /// - /// @param[in] first_insn + /// \param[in] first_insn /// \b true if this is the first instruction of a function. /// - /// @param[in] stop_other_threads + /// \param[in] stop_other_threads /// \b true if we will stop other threads while we single step this one. /// - /// @param[in] stop_vote - /// @param[in] run_vote + /// \param[in] stop_vote + /// \param[in] run_vote /// See standard meanings for the stop & run votes in ThreadPlan.h. /// - /// @param[out] status + /// \param[out] status /// A status with an error if queuing failed. /// - /// @param[in] step_out_avoids_code_without_debug_info + /// \param[in] step_out_avoids_code_without_debug_info /// If eLazyBoolYes, if the step over steps out it will continue to step /// out till it comes to a frame with debug info. /// If eLazyBoolCalculate, it will consult the default set in the thread. /// - /// @return + /// \return /// A shared pointer to the newly queued thread plan, or nullptr if the /// plan could not be queued. - //------------------------------------------------------------------ virtual lldb::ThreadPlanSP QueueThreadPlanForStepOut( bool abort_other_plans, SymbolContext *addr_context, bool first_insn, bool stop_other_threads, Vote stop_vote, Vote run_vote, uint32_t frame_idx, Status &status, LazyBool step_out_avoids_code_without_debug_info = eLazyBoolCalculate); - //------------------------------------------------------------------ /// Queue the plan used to step out of the function at the current PC of /// a thread. This version does not consult the should stop here callback, /// and should only /// be used by other thread plans when they need to retain control of the step /// out. /// - /// @param[in] abort_other_plans + /// \param[in] abort_other_plans /// \b true if we discard the currently queued plans and replace them with /// this one. /// Otherwise this plan will go on the end of the plan stack. /// - /// @param[in] addr_context + /// \param[in] addr_context /// When dealing with stepping through inlined functions the current PC is /// not enough information to know /// what "step" means. For instance a series of nested inline functions @@ -852,23 +800,23 @@ public: /// is supposed to be out of. // FIXME: Currently unused. /// - /// @param[in] first_insn + /// \param[in] first_insn /// \b true if this is the first instruction of a function. /// - /// @param[in] stop_other_threads + /// \param[in] stop_other_threads /// \b true if we will stop other threads while we single step this one. /// - /// @param[in] stop_vote + /// \param[in] stop_vote /// - /// @param[in] run_vote + /// \param[in] run_vote /// See standard meanings for the stop & run votes in ThreadPlan.h. /// - /// @param[in] frame_idx + /// \param[in] frame_idx /// - /// @param[out] status + /// \param[out] status /// A status with an error if queuing failed. /// - /// @param[in] continue_to_next_branch + /// \param[in] continue_to_next_branch /// Normally this will enqueue a plan that will put a breakpoint on the /// return address and continue /// to there. If continue_to_next_branch is true, this is an operation not @@ -885,67 +833,62 @@ public: /// registers which are overwritten /// before the next branch instruction. /// - /// @return + /// \return /// A shared pointer to the newly queued thread plan, or nullptr if the /// plan could not be queued. - //------------------------------------------------------------------ virtual lldb::ThreadPlanSP QueueThreadPlanForStepOutNoShouldStop( bool abort_other_plans, SymbolContext *addr_context, bool first_insn, bool stop_other_threads, Vote stop_vote, Vote run_vote, uint32_t frame_idx, Status &status, bool continue_to_next_branch = false); - //------------------------------------------------------------------ /// Gets the plan used to step through the code that steps from a function /// call site at the current PC into the actual function call. /// - /// @param[in] return_stack_id + /// \param[in] return_stack_id /// The stack id that we will return to (by setting backstop breakpoints on /// the return /// address to that frame) if we fail to step through. /// - /// @param[in] abort_other_plans + /// \param[in] abort_other_plans /// \b true if we discard the currently queued plans and replace them with /// this one. /// Otherwise this plan will go on the end of the plan stack. /// - /// @param[in] stop_other_threads + /// \param[in] stop_other_threads /// \b true if we will stop other threads while we single step this one. /// - /// @param[out] status + /// \param[out] status /// A status with an error if queuing failed. /// - /// @return + /// \return /// A shared pointer to the newly queued thread plan, or nullptr if the /// plan could not be queued. - //------------------------------------------------------------------ virtual lldb::ThreadPlanSP QueueThreadPlanForStepThrough(StackID &return_stack_id, bool abort_other_plans, bool stop_other_threads, Status &status); - //------------------------------------------------------------------ /// Gets the plan used to continue from the current PC. /// This is a simple plan, mostly useful as a backstop when you are continuing /// for some particular purpose. /// - /// @param[in] abort_other_plans + /// \param[in] abort_other_plans /// \b true if we discard the currently queued plans and replace them with /// this one. /// Otherwise this plan will go on the end of the plan stack. /// - /// @param[in] target_addr + /// \param[in] target_addr /// The address to which we're running. /// - /// @param[in] stop_other_threads + /// \param[in] stop_other_threads /// \b true if we will stop other threads while we single step this one. /// - /// @param[out] status + /// \param[out] status /// A status with an error if queuing failed. /// - /// @return + /// \return /// A shared pointer to the newly queued thread plan, or nullptr if the /// plan could not be queued. - //------------------------------------------------------------------ virtual lldb::ThreadPlanSP QueueThreadPlanForRunToAddress(bool abort_other_plans, Address &target_addr, bool stop_other_threads, Status &status); @@ -958,150 +901,122 @@ public: QueueThreadPlanForStepScripted(bool abort_other_plans, const char *class_name, bool stop_other_threads, Status &status); - //------------------------------------------------------------------ // Thread Plan accessors: - //------------------------------------------------------------------ - //------------------------------------------------------------------ /// Gets the plan which will execute next on the plan stack. /// - /// @return + /// \return /// A pointer to the next executed plan. - //------------------------------------------------------------------ ThreadPlan *GetCurrentPlan(); - //------------------------------------------------------------------ /// Unwinds the thread stack for the innermost expression plan currently /// on the thread plan stack. /// - /// @return + /// \return /// An error if the thread plan could not be unwound. - //------------------------------------------------------------------ Status UnwindInnermostExpression(); - //------------------------------------------------------------------ /// Gets the outer-most plan that was popped off the plan stack in the /// most recent stop. Useful for printing the stop reason accurately. /// - /// @return + /// \return /// A pointer to the last completed plan. - //------------------------------------------------------------------ lldb::ThreadPlanSP GetCompletedPlan(); - //------------------------------------------------------------------ /// Gets the outer-most return value from the completed plans /// - /// @return + /// \return /// A ValueObjectSP, either empty if there is no return value, /// or containing the return value. - //------------------------------------------------------------------ lldb::ValueObjectSP GetReturnValueObject(); - //------------------------------------------------------------------ /// Gets the outer-most expression variable from the completed plans /// - /// @return + /// \return /// A ExpressionVariableSP, either empty if there is no /// plan completed an expression during the current stop /// or the expression variable that was made for the completed expression. - //------------------------------------------------------------------ lldb::ExpressionVariableSP GetExpressionVariable(); - //------------------------------------------------------------------ /// Checks whether the given plan is in the completed plans for this /// stop. /// - /// @param[in] plan + /// \param[in] plan /// Pointer to the plan you're checking. /// - /// @return + /// \return /// Returns true if the input plan is in the completed plan stack, /// false otherwise. - //------------------------------------------------------------------ bool IsThreadPlanDone(ThreadPlan *plan); - //------------------------------------------------------------------ /// Checks whether the given plan is in the discarded plans for this /// stop. /// - /// @param[in] plan + /// \param[in] plan /// Pointer to the plan you're checking. /// - /// @return + /// \return /// Returns true if the input plan is in the discarded plan stack, /// false otherwise. - //------------------------------------------------------------------ bool WasThreadPlanDiscarded(ThreadPlan *plan); - //------------------------------------------------------------------ /// Check if we have completed plan to override breakpoint stop reason /// - /// @return + /// \return /// Returns true if completed plan stack is not empty /// false otherwise. - //------------------------------------------------------------------ bool CompletedPlanOverridesBreakpoint(); - //------------------------------------------------------------------ /// Queues a generic thread plan. /// - /// @param[in] plan_sp + /// \param[in] plan_sp /// The plan to queue. /// - /// @param[in] abort_other_plans + /// \param[in] abort_other_plans /// \b true if we discard the currently queued plans and replace them with /// this one. /// Otherwise this plan will go on the end of the plan stack. /// - /// @return + /// \return /// A pointer to the last completed plan. - //------------------------------------------------------------------ Status QueueThreadPlan(lldb::ThreadPlanSP &plan_sp, bool abort_other_plans); - //------------------------------------------------------------------ /// Discards the plans queued on the plan stack of the current thread. This /// is /// arbitrated by the "Master" ThreadPlans, using the "OkayToDiscard" call. // But if \a force is true, all thread plans are discarded. - //------------------------------------------------------------------ void DiscardThreadPlans(bool force); - //------------------------------------------------------------------ /// Discards the plans queued on the plan stack of the current thread up to /// and /// including up_to_plan_sp. // - // @param[in] up_to_plan_sp + // \param[in] up_to_plan_sp // Discard all plans up to and including this one. - //------------------------------------------------------------------ void DiscardThreadPlansUpToPlan(lldb::ThreadPlanSP &up_to_plan_sp); void DiscardThreadPlansUpToPlan(ThreadPlan *up_to_plan_ptr); - //------------------------------------------------------------------ /// Discards the plans queued on the plan stack of the current thread up to /// and /// including the plan in that matches \a thread_index counting only /// the non-Private plans. /// - /// @param[in] up_to_plan_sp + /// \param[in] up_to_plan_sp /// Discard all plans up to and including this user plan given by this /// index. /// - /// @return + /// \return /// \b true if there was a thread plan with that user index, \b false /// otherwise. - //------------------------------------------------------------------ bool DiscardUserThreadPlansUpToIndex(uint32_t thread_index); - //------------------------------------------------------------------ /// Prints the current plan stack. /// - /// @param[in] s + /// \param[in] s /// The stream to which to dump the plan stack info. /// - //------------------------------------------------------------------ void DumpThreadPlans( Stream *s, lldb::DescriptionLevel desc_level = lldb::eDescriptionLevelVerbose, @@ -1119,15 +1034,12 @@ 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. - //------------------------------------------------------------------ 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 @@ -1137,22 +1049,17 @@ public: // 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() { return GetIndexID(); } - //------------------------------------------------------------------ // 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(); } - //------------------------------------------------------------------ // lldb::ExecutionContextScope pure virtual functions - //------------------------------------------------------------------ lldb::TargetSP CalculateTarget() override; lldb::ProcessSP CalculateProcess() override; @@ -1195,18 +1102,15 @@ public: // with what you might have calculated. virtual lldb::StopInfoSP GetPrivateStopInfo(); - //---------------------------------------------------------------------- // Ask the thread subclass to set its stop info. // // Thread subclasses should call Thread::SetStopInfo(...) with the reason the // thread stopped. // - // @return + // \return // True if Thread::SetStopInfo(...) was called, false otherwise. - //---------------------------------------------------------------------- virtual bool CalculateStopInfo() = 0; - //---------------------------------------------------------------------- // Gets the temporary resume state for a thread. // // This value gets set in each thread by complex debugger logic in @@ -1220,7 +1124,6 @@ public: // is resumed // eStateSuspended - thread should not execute any instructions when // process is resumed - //---------------------------------------------------------------------- lldb::StateType GetTemporaryResumeState() const { return m_temporary_resume_state; } @@ -1231,26 +1134,22 @@ public: void SetShouldReportStop(Vote vote); - //---------------------------------------------------------------------- /// Sets the extended backtrace token for this thread /// /// Some Thread subclasses may maintain a token to help with providing /// an extended backtrace. The SystemRuntime plugin will set/request this. /// - /// @param [in] token - //---------------------------------------------------------------------- + /// \param [in] token virtual void SetExtendedBacktraceToken(uint64_t token) {} - //---------------------------------------------------------------------- /// Gets the extended backtrace token for this thread /// /// Some Thread subclasses may maintain a token to help with providing /// an extended backtrace. The SystemRuntime plugin will set/request this. /// - /// @return + /// \return /// The token needed by the SystemRuntime to create an extended backtrace. /// LLDB_INVALID_ADDRESS is returned if no token is available. - //---------------------------------------------------------------------- virtual uint64_t GetExtendedBacktraceToken() { return LLDB_INVALID_ADDRESS; } lldb::ValueObjectSP GetCurrentException(); @@ -1306,9 +1205,7 @@ protected: void FunctionOptimizationWarning(lldb_private::StackFrame *frame); - //------------------------------------------------------------------ // Classes that inherit from Process can see and modify these - //------------------------------------------------------------------ lldb::ProcessWP m_process_wp; ///< The process that owns this thread. 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 @@ -1348,7 +1245,7 @@ protected: ///thread plan logic for the current ///resume. /// It gets set in Thread::ShouldResume. - std::unique_ptr<lldb_private::Unwind> m_unwinder_ap; + std::unique_ptr<lldb_private::Unwind> m_unwinder_up; bool m_destroy_called; // This is used internally to make sure derived Thread // classes call DestroyThread. LazyBool m_override_should_notify; diff --git a/include/lldb/Target/ThreadCollection.h b/include/lldb/Target/ThreadCollection.h index dd5e81c1af480..29ea827203e5e 100644 --- a/include/lldb/Target/ThreadCollection.h +++ b/include/lldb/Target/ThreadCollection.h @@ -1,9 +1,8 @@ //===-- ThreadCollection.h --------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// diff --git a/include/lldb/Target/ThreadList.h b/include/lldb/Target/ThreadList.h index 6285cb1e0fb46..64ddf5aea504a 100644 --- a/include/lldb/Target/ThreadList.h +++ b/include/lldb/Target/ThreadList.h @@ -1,9 +1,8 @@ //===-- ThreadList.h --------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -111,19 +110,17 @@ public: void RefreshStateAfterStop(); - //------------------------------------------------------------------ /// The thread list asks tells all the threads it is about to resume. /// If a thread can "resume" without having to resume the target, it /// will return false for WillResume, and then the process will not be /// restarted. /// - /// @return + /// \return /// \b true instructs the process to resume normally, /// \b false means start & stopped events will be generated, but /// the process will not actually run. The thread must then return /// the correct StopInfo when asked. /// - //------------------------------------------------------------------ bool WillResume(); void DidResume(); @@ -145,9 +142,7 @@ protected: void NotifySelectedThreadChanged(lldb::tid_t tid); - //------------------------------------------------------------------ // Classes that inherit from Process can see and modify these - //------------------------------------------------------------------ Process *m_process; ///< The process that manages this thread list. uint32_t m_stop_id; ///< The process stop ID that this thread list is valid for. @@ -156,7 +151,7 @@ protected: std::vector<lldb::tid_t> m_expression_tid_stack; private: - ThreadList(); + ThreadList() = delete; }; } // namespace lldb_private diff --git a/include/lldb/Target/ThreadPlan.h b/include/lldb/Target/ThreadPlan.h index 15bc4c7656c38..ff87ed23cda54 100644 --- a/include/lldb/Target/ThreadPlan.h +++ b/include/lldb/Target/ThreadPlan.h @@ -1,9 +1,8 @@ //===-- ThreadPlan.h --------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -23,7 +22,6 @@ namespace lldb_private { -//------------------------------------------------------------------ // ThreadPlan: // This is the pure virtual base class for thread plans. // @@ -329,16 +327,15 @@ namespace lldb_private { // for a plan to instruct a sub-plan // on how to respond to ShouldReportStop. // -//------------------------------------------------------------------ class ThreadPlan : public std::enable_shared_from_this<ThreadPlan>, public UserID { public: - typedef enum { eAllThreads, eSomeThreads, eThisThread } ThreadScope; + enum ThreadScope { eAllThreads, eSomeThreads, eThisThread }; // 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 { + enum ThreadPlanKind { eKindGeneric, eKindNull, eKindBase, @@ -354,30 +351,24 @@ public: eKindStepUntil, eKindTestCondition - } ThreadPlanKind; + }; - //------------------------------------------------------------------ // Constructors and Destructors - //------------------------------------------------------------------ ThreadPlan(ThreadPlanKind kind, const char *name, Thread &thread, Vote stop_vote, Vote run_vote); virtual ~ThreadPlan(); - //------------------------------------------------------------------ /// Returns the name of this thread plan. /// - /// @return + /// \return /// A const char * pointer to the thread plan's name. - //------------------------------------------------------------------ const char *GetName() const { return m_name.c_str(); } - //------------------------------------------------------------------ /// Returns the Thread that is using this thread plan. /// - /// @return + /// \return /// A pointer to the thread plan's owning thread. - //------------------------------------------------------------------ Thread &GetThread() { return m_thread; } const Thread &GetThread() const { return m_thread; } @@ -386,30 +377,26 @@ public: const Target &GetTarget() const { return m_thread.GetProcess()->GetTarget(); } - //------------------------------------------------------------------ /// Print a description of this thread to the stream \a s. /// \a thread. /// - /// @param[in] s + /// \param[in] s /// The stream to which to print the description. /// - /// @param[in] level + /// \param[in] level /// The level of description desired. Note that eDescriptionLevelBrief /// will be used in the stop message printed when the plan is complete. - //------------------------------------------------------------------ virtual void GetDescription(Stream *s, lldb::DescriptionLevel level) = 0; - //------------------------------------------------------------------ /// Returns whether this plan could be successfully created. /// - /// @param[in] error + /// \param[in] error /// A stream to which to print some reason why the plan could not be /// created. /// Can be NULL. /// - /// @return + /// \return /// \b true if the plan should be queued, \b false otherwise. - //------------------------------------------------------------------ virtual bool ValidatePlan(Stream *error) = 0; bool TracerExplainsStop() { @@ -557,9 +544,7 @@ public: } protected: - //------------------------------------------------------------------ // Classes that inherit from ThreadPlan can see and modify these - //------------------------------------------------------------------ virtual bool DoWillResume(lldb::StateType resume_state, bool current_plan) { return true; @@ -605,9 +590,7 @@ protected: int32_t m_iteration_count = 1; private: - //------------------------------------------------------------------ // For ThreadPlan only - //------------------------------------------------------------------ static lldb::user_id_t GetNextID(); ThreadPlanKind m_kind; @@ -626,13 +609,11 @@ private: DISALLOW_COPY_AND_ASSIGN(ThreadPlan); }; -//---------------------------------------------------------------------- // 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. -//---------------------------------------------------------------------- class ThreadPlanNull : public ThreadPlan { public: diff --git a/include/lldb/Target/ThreadPlanBase.h b/include/lldb/Target/ThreadPlanBase.h index bcf20c5544bc4..bc92a06229a76 100644 --- a/include/lldb/Target/ThreadPlanBase.h +++ b/include/lldb/Target/ThreadPlanBase.h @@ -1,9 +1,8 @@ //===-- ThreadPlanBase.h ----------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -16,12 +15,10 @@ namespace lldb_private { -//------------------------------------------------------------------ // Base thread plans: // This is the generic version of the bottom most plan on the plan stack. It // should // be able to handle generic breakpoint hitting, and signals and exceptions. -//------------------------------------------------------------------ class ThreadPlanBase : public ThreadPlan { friend class Process; // RunThreadPlan manages "stopper" base plans. diff --git a/include/lldb/Target/ThreadPlanCallFunction.h b/include/lldb/Target/ThreadPlanCallFunction.h index 3bec86e370d18..685160a5678ae 100644 --- a/include/lldb/Target/ThreadPlanCallFunction.h +++ b/include/lldb/Target/ThreadPlanCallFunction.h @@ -1,9 +1,8 @@ //===-- ThreadPlanCallFunction.h --------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// diff --git a/include/lldb/Target/ThreadPlanCallFunctionUsingABI.h b/include/lldb/Target/ThreadPlanCallFunctionUsingABI.h index 9b75da5fd2f88..c21e4d3cf3f76 100644 --- a/include/lldb/Target/ThreadPlanCallFunctionUsingABI.h +++ b/include/lldb/Target/ThreadPlanCallFunctionUsingABI.h @@ -1,10 +1,9 @@ //===-- ThreadPlanCallFunctionUsingABI.h --------------------------------*- C++ //-*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// diff --git a/include/lldb/Target/ThreadPlanCallOnFunctionExit.h b/include/lldb/Target/ThreadPlanCallOnFunctionExit.h index c7ea368cca6ae..ad3ee6e0e8f9c 100644 --- a/include/lldb/Target/ThreadPlanCallOnFunctionExit.h +++ b/include/lldb/Target/ThreadPlanCallOnFunctionExit.h @@ -1,9 +1,8 @@ //===-- ThreadPlanCallOnFunctionExit.h --------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -30,9 +29,7 @@ public: void DidPush() override; - // ------------------------------------------------------------------------- // ThreadPlan API - // ------------------------------------------------------------------------- void GetDescription(Stream *s, lldb::DescriptionLevel level) override; diff --git a/include/lldb/Target/ThreadPlanCallUserExpression.h b/include/lldb/Target/ThreadPlanCallUserExpression.h index ba1001ce5e916..6372155824104 100644 --- a/include/lldb/Target/ThreadPlanCallUserExpression.h +++ b/include/lldb/Target/ThreadPlanCallUserExpression.h @@ -1,10 +1,9 @@ //===-- ThreadPlanCallUserExpression.h --------------------------------*- C++ //-*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// diff --git a/include/lldb/Target/ThreadPlanPython.h b/include/lldb/Target/ThreadPlanPython.h index fc4cfb3bf0b42..3825bf6ee4f31 100644 --- a/include/lldb/Target/ThreadPlanPython.h +++ b/include/lldb/Target/ThreadPlanPython.h @@ -1,10 +1,9 @@ //===-- ThreadPlanPython.h --------------------------------------------*- C++ //-*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -25,10 +24,8 @@ namespace lldb_private { -//------------------------------------------------------------------ // ThreadPlanPython: // -//------------------------------------------------------------------ class ThreadPlanPython : public ThreadPlan { public: diff --git a/include/lldb/Target/ThreadPlanRunToAddress.h b/include/lldb/Target/ThreadPlanRunToAddress.h index 58608864d4632..d82a9fad548a5 100644 --- a/include/lldb/Target/ThreadPlanRunToAddress.h +++ b/include/lldb/Target/ThreadPlanRunToAddress.h @@ -1,9 +1,8 @@ //===-- ThreadPlanRunToAddress.h --------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// diff --git a/include/lldb/Target/ThreadPlanShouldStopHere.h b/include/lldb/Target/ThreadPlanShouldStopHere.h index d3aca3e6f5c06..dfcbbb355c548 100644 --- a/include/lldb/Target/ThreadPlanShouldStopHere.h +++ b/include/lldb/Target/ThreadPlanShouldStopHere.h @@ -1,9 +1,8 @@ //===-- ThreadPlanShouldStopHere.h ------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -63,9 +62,7 @@ public: eStepOutAvoidNoDebug = (1 << 2) }; - //------------------------------------------------------------------ // Constructors and Destructors - //------------------------------------------------------------------ ThreadPlanShouldStopHere(ThreadPlan *owner); ThreadPlanShouldStopHere(ThreadPlan *owner, diff --git a/include/lldb/Target/ThreadPlanStepInRange.h b/include/lldb/Target/ThreadPlanStepInRange.h index c13b3533af1c9..a120c98fb36e1 100644 --- a/include/lldb/Target/ThreadPlanStepInRange.h +++ b/include/lldb/Target/ThreadPlanStepInRange.h @@ -1,9 +1,8 @@ //===-- ThreadPlanStepInRange.h ---------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -93,7 +92,7 @@ private: // for the ThreadPlanStepThrough. lldb::ThreadPlanSP m_sub_plan_sp; // Keep track of the last plan we were // running. If it fails, we should stop. - std::unique_ptr<RegularExpression> m_avoid_regexp_ap; + std::unique_ptr<RegularExpression> m_avoid_regexp_up; bool m_step_past_prologue; // FIXME: For now hard-coded to true, we could put // a switch in for this if there's // demand for that. diff --git a/include/lldb/Target/ThreadPlanStepInstruction.h b/include/lldb/Target/ThreadPlanStepInstruction.h index ea5d93fa4944d..127de417f6eb9 100644 --- a/include/lldb/Target/ThreadPlanStepInstruction.h +++ b/include/lldb/Target/ThreadPlanStepInstruction.h @@ -1,9 +1,8 @@ //===-- ThreadPlanStepInstruction.h -----------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// diff --git a/include/lldb/Target/ThreadPlanStepOut.h b/include/lldb/Target/ThreadPlanStepOut.h index 8ef9f95d4f967..00984db2dca97 100644 --- a/include/lldb/Target/ThreadPlanStepOut.h +++ b/include/lldb/Target/ThreadPlanStepOut.h @@ -1,9 +1,8 @@ //===-- ThreadPlanStepOut.h -------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// diff --git a/include/lldb/Target/ThreadPlanStepOverBreakpoint.h b/include/lldb/Target/ThreadPlanStepOverBreakpoint.h index 7aaf56ed7c0b2..7df7049b568a4 100644 --- a/include/lldb/Target/ThreadPlanStepOverBreakpoint.h +++ b/include/lldb/Target/ThreadPlanStepOverBreakpoint.h @@ -1,9 +1,8 @@ //===-- ThreadPlanStepOverBreakpoint.h --------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// diff --git a/include/lldb/Target/ThreadPlanStepOverRange.h b/include/lldb/Target/ThreadPlanStepOverRange.h index 2eeb2bb96022c..30763e3861fa1 100644 --- a/include/lldb/Target/ThreadPlanStepOverRange.h +++ b/include/lldb/Target/ThreadPlanStepOverRange.h @@ -1,9 +1,8 @@ //===-- ThreadPlanStepOverRange.h -------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// diff --git a/include/lldb/Target/ThreadPlanStepRange.h b/include/lldb/Target/ThreadPlanStepRange.h index b3e267a0827b4..93d54ad7dfd5a 100644 --- a/include/lldb/Target/ThreadPlanStepRange.h +++ b/include/lldb/Target/ThreadPlanStepRange.h @@ -1,9 +1,8 @@ //===-- ThreadPlanStepRange.h -----------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// diff --git a/include/lldb/Target/ThreadPlanStepThrough.h b/include/lldb/Target/ThreadPlanStepThrough.h index 1bff541e7df63..0d0621227b535 100644 --- a/include/lldb/Target/ThreadPlanStepThrough.h +++ b/include/lldb/Target/ThreadPlanStepThrough.h @@ -1,9 +1,8 @@ //===-- ThreadPlanStepThrough.h ---------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// diff --git a/include/lldb/Target/ThreadPlanStepUntil.h b/include/lldb/Target/ThreadPlanStepUntil.h index 33ccc0fa0d54e..9a5934a36d7d4 100644 --- a/include/lldb/Target/ThreadPlanStepUntil.h +++ b/include/lldb/Target/ThreadPlanStepUntil.h @@ -1,9 +1,8 @@ //===-- ThreadPlanStepUntil.h -----------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// diff --git a/include/lldb/Target/ThreadPlanTracer.h b/include/lldb/Target/ThreadPlanTracer.h index 21f9023f8d578..80b08078e975e 100644 --- a/include/lldb/Target/ThreadPlanTracer.h +++ b/include/lldb/Target/ThreadPlanTracer.h @@ -1,10 +1,9 @@ //===-- ThreadPlanTracer.h --------------------------------------------*- C++ //-*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -22,12 +21,12 @@ class ThreadPlanTracer { friend class ThreadPlan; public: - typedef enum ThreadPlanTracerStyle { + enum ThreadPlanTracerStyle { eLocation = 0, eStateChange, eCheckFrames, ePython - } ThreadPlanTracerStyle; + }; ThreadPlanTracer(Thread &thread, lldb::StreamSP &stream_sp); ThreadPlanTracer(Thread &thread); diff --git a/include/lldb/Target/ThreadSpec.h b/include/lldb/Target/ThreadSpec.h index 34baf80462618..05e7dcdb38d3c 100644 --- a/include/lldb/Target/ThreadSpec.h +++ b/include/lldb/Target/ThreadSpec.h @@ -1,9 +1,8 @@ //===-- ThreadSpec.h --------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -35,10 +34,6 @@ class ThreadSpec { public: ThreadSpec(); - ThreadSpec(const ThreadSpec &rhs); - - const ThreadSpec &operator=(const ThreadSpec &rhs); - static std::unique_ptr<ThreadSpec> CreateFromStructuredData(const StructuredData::Dictionary &data_dict, Status &error); diff --git a/include/lldb/Target/UnixSignals.h b/include/lldb/Target/UnixSignals.h index 8774139371f01..120ffdd7ae254 100644 --- a/include/lldb/Target/UnixSignals.h +++ b/include/lldb/Target/UnixSignals.h @@ -1,9 +1,8 @@ //===-- UnixSignals.h -------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -23,10 +22,9 @@ namespace lldb_private { class UnixSignals { public: static lldb::UnixSignalsSP Create(const ArchSpec &arch); + static lldb::UnixSignalsSP CreateForHost(); - //------------------------------------------------------------------ // Constructors and Destructors - //------------------------------------------------------------------ UnixSignals(); virtual ~UnixSignals(); @@ -95,9 +93,7 @@ public: llvm::Optional<bool> should_notify); protected: - //------------------------------------------------------------------ // Classes that inherit from UnixSignals can see and modify these - //------------------------------------------------------------------ struct Signal { ConstString m_name; diff --git a/include/lldb/Target/Unwind.h b/include/lldb/Target/Unwind.h index 9e0da9ed553b5..a648e063e34b2 100644 --- a/include/lldb/Target/Unwind.h +++ b/include/lldb/Target/Unwind.h @@ -1,9 +1,8 @@ //===-- Unwind.h ------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -18,9 +17,7 @@ namespace lldb_private { class Unwind { protected: - //------------------------------------------------------------------ // Classes that inherit from Unwind can see and modify these - //------------------------------------------------------------------ Unwind(Thread &thread) : m_thread(thread), m_unwind_mutex() {} public: @@ -63,9 +60,7 @@ public: Thread &GetThread() { return m_thread; } protected: - //------------------------------------------------------------------ // Classes that inherit from Unwind can see and modify these - //------------------------------------------------------------------ virtual void DoClear() = 0; virtual uint32_t DoGetFrameCount() = 0; diff --git a/include/lldb/Target/UnwindAssembly.h b/include/lldb/Target/UnwindAssembly.h index 3028ffeaa51d3..a70aef6e93c52 100644 --- a/include/lldb/Target/UnwindAssembly.h +++ b/include/lldb/Target/UnwindAssembly.h @@ -1,9 +1,8 @@ //===-- UnwindAssembly.h --------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -45,7 +44,7 @@ protected: ArchSpec m_arch; private: - UnwindAssembly(); // Outlaw default constructor + UnwindAssembly() = delete; DISALLOW_COPY_AND_ASSIGN(UnwindAssembly); }; diff --git a/include/lldb/Utility/AnsiTerminal.h b/include/lldb/Utility/AnsiTerminal.h index b5ff239f800d1..1473c60eeaf2b 100644 --- a/include/lldb/Utility/AnsiTerminal.h +++ b/include/lldb/Utility/AnsiTerminal.h @@ -1,9 +1,8 @@ //===---------------------AnsiTerminal.h ------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// diff --git a/include/lldb/Utility/ArchSpec.h b/include/lldb/Utility/ArchSpec.h index e84cbbbe5efad..7a32556310c43 100644 --- a/include/lldb/Utility/ArchSpec.h +++ b/include/lldb/Utility/ArchSpec.h @@ -1,9 +1,8 @@ //===-- ArchSpec.h ----------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -23,15 +22,13 @@ namespace lldb_private { -//---------------------------------------------------------------------- -/// @class ArchSpec ArchSpec.h "lldb/Utility/ArchSpec.h" An architecture +/// \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. -//---------------------------------------------------------------------- class ArchSpec { public: enum MIPSSubType { @@ -186,10 +183,6 @@ public: eCore_uknownMach32, eCore_uknownMach64, - eCore_kalimba3, - eCore_kalimba4, - eCore_kalimba5, - kNumCores, kCore_invalid, @@ -223,9 +216,6 @@ public: kCore_hexagon_first = eCore_hexagon_generic, kCore_hexagon_last = eCore_hexagon_hexagonv5, - kCore_kalimba_first = eCore_kalimba3, - kCore_kalimba_last = eCore_kalimba5, - kCore_mips32_first = eCore_mips32, kCore_mips32_last = eCore_mips32r6, @@ -243,131 +233,99 @@ public: }; - //------------------------------------------------------------------ /// Default constructor. /// /// 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. - //------------------------------------------------------------------ explicit ArchSpec(const llvm::Triple &triple); explicit ArchSpec(const char *triple_cstr); explicit ArchSpec(llvm::StringRef triple_str); - //------------------------------------------------------------------ /// Constructor over 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); - //------------------------------------------------------------------ /// Destructor. - //------------------------------------------------------------------ ~ArchSpec(); - //------------------------------------------------------------------ /// Assignment operator. /// - /// @param[in] rhs another ArchSpec object to copy. + /// \param[in] rhs another ArchSpec object to copy. /// - /// @return A const reference to this object. - //------------------------------------------------------------------ + /// \return A const reference to this object. const ArchSpec &operator=(const ArchSpec &rhs); - //--------------------------------------------------------------------------- /// Returns true if the OS, vendor and environment fields of the triple are /// unset. The triple is expected to be normalized /// (llvm::Triple::normalize). - //--------------------------------------------------------------------------- static bool ContainsOnlyArch(const llvm::Triple &normalized_triple); static void ListSupportedArchNames(StringList &list); static size_t AutoComplete(CompletionRequest &request); - //------------------------------------------------------------------ /// Returns a static string representing the current architecture. /// - /// @return A static string corresponding to the current + /// \return A static string corresponding to the current /// architecture. - //------------------------------------------------------------------ const char *GetArchitectureName() const; - //----------------------------------------------------------------- /// if MIPS architecture return true. /// - /// @return a boolean value. - //----------------------------------------------------------------- + /// \return a boolean value. bool IsMIPS() const; - //------------------------------------------------------------------ /// 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 + /// \return A string representing target CPU for the current /// architecture. - //------------------------------------------------------------------ std::string GetClangTargetCPU() const; - //------------------------------------------------------------------ /// Return a string representing target application ABI. /// - /// @return A string representing target application ABI. - //------------------------------------------------------------------ + /// \return A string representing target application ABI. std::string GetTargetABI() const; - //------------------------------------------------------------------ /// Clears the object state. /// /// Clears the object state back to a default invalid state. - //------------------------------------------------------------------ void Clear(); - //------------------------------------------------------------------ /// Returns the size in bytes of an address of the current architecture. /// - /// @return The byte size of an address of the current architecture. - //------------------------------------------------------------------ + /// \return The byte size of an address of the current architecture. uint32_t GetAddressByteSize() const; - //------------------------------------------------------------------ /// Returns a machine family for the current architecture. /// - /// @return An LLVM arch type. - //------------------------------------------------------------------ + /// \return An LLVM arch type. llvm::Triple::ArchType GetMachine() const; - //------------------------------------------------------------------ /// Returns the distribution id of the architecture. /// /// This will be something like "ubuntu", "fedora", etc. on Linux. /// - /// @return A ConstString ref containing the distribution id, + /// \return A ConstString ref containing the distribution id, /// potentially empty. - //------------------------------------------------------------------ - const ConstString &GetDistributionId() const; + ConstString GetDistributionId() const; - //------------------------------------------------------------------ /// 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 (). - ///------------------------------------------------------------------ void SetDistributionId(const char *distribution_id); - //------------------------------------------------------------------ /// Tests if this ArchSpec is valid. /// - /// @return True if the current architecture is valid, false + /// \return True if the current architecture is valid, false /// otherwise. - //------------------------------------------------------------------ bool IsValid() const { return m_core >= eCore_arm_generic && m_core < kNumCores; } @@ -377,23 +335,12 @@ public: return !m_triple.getVendorName().empty(); } - bool TripleVendorIsUnspecifiedUnknown() const { - return m_triple.getVendor() == llvm::Triple::UnknownVendor && - m_triple.getVendorName().empty(); - } - bool TripleOSWasSpecified() const { return !m_triple.getOSName().empty(); } bool TripleEnvironmentWasSpecified() const { - return !m_triple.getEnvironmentName().empty(); - } - - bool TripleOSIsUnspecifiedUnknown() const { - return m_triple.getOS() == llvm::Triple::UnknownOS && - m_triple.getOSName().empty(); + return m_triple.hasEnvironment(); } - //------------------------------------------------------------------ /// Merges fields from another ArchSpec into this ArchSpec. /// /// This will use the supplied ArchSpec to fill in any fields of the triple @@ -403,23 +350,21 @@ public: /// 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); - //------------------------------------------------------------------ /// Change the architecture object type, CPU type and OS type. /// - /// @param[in] arch_type The object type of this ArchSpec. + /// \param[in] arch_type The object type of this ArchSpec. /// - /// @param[in] cpu The required CPU type. + /// \param[in] cpu The required CPU type. /// - /// @param[in] os The optional OS type + /// \param[in] os The optional OS type /// The default value of 0 was chosen to from the ELF spec value /// ELFOSABI_NONE. ELF is the only one using this parameter. If another /// format uses this parameter and 0 does not work, use a value over /// 255 because in the ELF header this is value is only a byte. /// - /// @return True if the object, and CPU were successfully set. + /// \return True if the object, and CPU were successfully set. /// /// As a side effect, the vendor value is usually set to unknown. The /// exceptions are @@ -441,26 +386,21 @@ public: /// *-*-netbsd /// *-*-openbsd /// *-*-solaris - //------------------------------------------------------------------ bool SetArchitecture(ArchitectureType arch_type, uint32_t cpu, uint32_t sub, uint32_t os = 0); - //------------------------------------------------------------------ /// Returns the byte order for the architecture specification. /// - /// @return The endian enumeration for the current endianness of + /// \return The endian enumeration for the current endianness of /// the architecture specification - //------------------------------------------------------------------ lldb::ByteOrder GetByteOrder() const; - //------------------------------------------------------------------ /// 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. - //------------------------------------------------------------------ void SetByteOrder(lldb::ByteOrder byte_order) { m_byte_order = byte_order; } uint32_t GetMinimumOpcodeByteSize() const; @@ -473,39 +413,30 @@ public: uint32_t GetMachOCPUSubType() const; - //------------------------------------------------------------------ /// Architecture data byte width accessor /// - /// @return the size in 8-bit (host) bytes of a minimum addressable unit + /// \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 + /// \return the size in 8-bit (host) bytes of a minimum addressable unit /// from the Architecture's code bus - //------------------------------------------------------------------ uint32_t GetCodeByteSize() const; - //------------------------------------------------------------------ /// Architecture triple accessor. /// - /// @return A triple describing this ArchSpec. - //------------------------------------------------------------------ + /// \return A triple describing this ArchSpec. llvm::Triple &GetTriple() { return m_triple; } - //------------------------------------------------------------------ /// Architecture triple accessor. /// - /// @return A triple describing this ArchSpec. - //------------------------------------------------------------------ + /// \return A triple describing this ArchSpec. const llvm::Triple &GetTriple() const { return m_triple; } void DumpTriple(Stream &s) const; - //------------------------------------------------------------------ /// Architecture triple setter. /// /// Configures this ArchSpec according to the given triple. If the triple @@ -515,45 +446,36 @@ public: /// to further resolve the CPU type and subtype, endian characteristics, /// etc. /// - /// @return A triple describing this ArchSpec. - //------------------------------------------------------------------ + /// \return A triple describing this ArchSpec. bool SetTriple(const llvm::Triple &triple); bool SetTriple(llvm::StringRef triple_str); - //------------------------------------------------------------------ /// Returns the default endianness of the architecture. /// - /// @return The endian enumeration for the default endianness of + /// \return The endian enumeration for the default endianness of /// the architecture. - //------------------------------------------------------------------ lldb::ByteOrder GetDefaultEndian() const; - //------------------------------------------------------------------ /// 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 + /// \return True if 'char' is a signed type by default on the /// architecture and false otherwise. - //------------------------------------------------------------------ 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 /// - /// @return true if the two ArchSpecs match. - //------------------------------------------------------------------ + /// \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 /// - /// @return true if the two ArchSpecs are compatible - //------------------------------------------------------------------ + /// \return true if the two ArchSpecs are compatible bool IsCompatibleMatch(const ArchSpec &rhs) const; bool IsFullySpecifiedTriple() const; @@ -563,7 +485,6 @@ public: bool &os_version_different, bool &env_different) const; - //------------------------------------------------------------------ /// Detect whether this architecture uses thumb code exclusively /// /// Some embedded ARM chips (e.g. the ARM Cortex M0-7 line) can only execute @@ -573,9 +494,8 @@ public: /// (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 + /// \return true if this is an arm ArchSpec which can only execute Thumb /// instructions - //------------------------------------------------------------------ bool IsAlwaysThumbInstructions() const; uint32_t GetFlags() const { return m_flags; } @@ -603,17 +523,15 @@ protected: void CoreUpdated(bool update_triple); }; -//------------------------------------------------------------------ -/// @fn bool operator< (const ArchSpec& lhs, const ArchSpec& rhs) Less than +/// \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. /// -/// @param[in] lhs The Left Hand Side ArchSpec object to compare. @param[in] +/// \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 -//------------------------------------------------------------------ +/// \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); diff --git a/include/lldb/Utility/Args.h b/include/lldb/Utility/Args.h index dec3dfaa4785b..6f258498d5bae 100644 --- a/include/lldb/Utility/Args.h +++ b/include/lldb/Utility/Args.h @@ -1,9 +1,8 @@ //===-- Args.h --------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -21,8 +20,7 @@ namespace lldb_private { -//---------------------------------------------------------------------- -/// @class Args Args.h "lldb/Utility/Args.h" +/// \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 @@ -31,7 +29,6 @@ namespace lldb_private { /// 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: struct ArgEntry { @@ -49,21 +46,17 @@ public: 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'; } }; - //------------------------------------------------------------------ /// Construct with an option command string. /// - /// @param[in] command + /// \param[in] command /// A NULL terminated command that will be copied and split up /// into arguments. /// - /// @see Args::SetCommandString(llvm::StringRef) - //------------------------------------------------------------------ + /// \see Args::SetCommandString(llvm::StringRef) Args(llvm::StringRef command = llvm::StringRef()); Args(const Args &rhs); @@ -71,9 +64,7 @@ public: Args &operator=(const Args &rhs); - //------------------------------------------------------------------ /// Destructor. - //------------------------------------------------------------------ ~Args(); explicit Args(const Environment &env) : Args() { @@ -82,59 +73,51 @@ public: explicit operator Environment() const { return GetConstArgumentVector(); } - //------------------------------------------------------------------ /// Dump all entries to the stream \a s using label \a label_name. /// /// If label_name is nullptr, the dump operation is skipped. /// - /// @param[in] s + /// \param[in] s /// The stream to which to dump all arguments in the argument /// vector. - /// @param[in] label_name + /// \param[in] label_name /// The label_name to use as the label printed for each /// entry of the args like so: /// {label_name}[{index}]={value} - //------------------------------------------------------------------ void Dump(Stream &s, const char *label_name = "argv") const; - //------------------------------------------------------------------ /// 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. /// - /// @param[in] command + /// \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 + /// \see Args::GetArgumentCount() const + /// \see Args::GetArgumentAtIndex (size_t) const @see + /// Args::GetArgumentVector () \see Args::Shift () \see Args::Unshift (const /// char *) - //------------------------------------------------------------------ void SetCommandString(llvm::StringRef command); bool GetCommandString(std::string &command) const; bool GetQuotedCommandString(std::string &command) const; - //------------------------------------------------------------------ /// Gets the number of arguments left in this command object. /// - /// @return + /// \return /// The number or arguments in this object. - //------------------------------------------------------------------ size_t GetArgumentCount() const; bool empty() const { return GetArgumentCount() == 0; } - //------------------------------------------------------------------ /// Gets the NULL terminated C string argument pointer for the argument at /// index \a idx. /// - /// @return + /// \return /// The NULL terminated C string argument pointer if \a idx is a /// valid argument index, NULL otherwise. - //------------------------------------------------------------------ const char *GetArgumentAtIndex(size_t idx) const; llvm::ArrayRef<ArgEntry> entries() const { return m_entries; } @@ -148,7 +131,6 @@ public: size_t size() const { return GetArgumentCount(); } const ArgEntry &operator[](size_t n) const { return m_entries[n]; } - //------------------------------------------------------------------ /// Gets the argument vector. /// /// The value returned by this function can be used by any function that @@ -158,13 +140,11 @@ public: /// int main (int argc, const char **argv); /// \endcode /// - /// @return + /// \return /// An array of NULL terminated C string argument pointers that /// also has a terminating NULL C string pointer - //------------------------------------------------------------------ char **GetArgumentVector(); - //------------------------------------------------------------------ /// Gets the argument vector. /// /// The value returned by this function can be used by any function that @@ -174,81 +154,69 @@ public: /// int main (int argc, const char **argv); /// \endcode /// - /// @return + /// \return /// An array of NULL terminate C string argument pointers that /// also has a terminating NULL C string pointer - //------------------------------------------------------------------ const char **GetConstArgumentVector() const; - //------------------------------------------------------------------ /// Gets the argument as an ArrayRef. Note that the return value does *not* /// have a nullptr const char * at the end, as the size of the list is /// embedded in the ArrayRef object. - //------------------------------------------------------------------ llvm::ArrayRef<const char *> GetArgumentArrayRef() const { return llvm::makeArrayRef(m_argv).drop_back(); } - //------------------------------------------------------------------ /// Appends a new argument to the end of the list argument list. /// - /// @param[in] arg_cstr + /// \param[in] arg_cstr /// The new argument as a NULL terminated C string. /// - /// @param[in] quote_char + /// \param[in] quote_char /// If the argument was originally quoted, put in the quote char here. - //------------------------------------------------------------------ void AppendArgument(llvm::StringRef arg_str, char quote_char = '\0'); void AppendArguments(const Args &rhs); void AppendArguments(const char **argv); - //------------------------------------------------------------------ /// Insert the argument value at index \a idx to \a arg_cstr. /// - /// @param[in] idx + /// \param[in] idx /// The index of where to insert the argument. /// - /// @param[in] arg_cstr + /// \param[in] arg_cstr /// The new argument as a NULL terminated C string. /// - /// @param[in] quote_char + /// \param[in] quote_char /// If the argument was originally quoted, put in the quote char here. /// - /// @return + /// \return /// The NULL terminated C string of the copy of \a arg_cstr. - //------------------------------------------------------------------ void InsertArgumentAtIndex(size_t idx, llvm::StringRef arg_str, char quote_char = '\0'); - //------------------------------------------------------------------ /// Replaces the argument value at index \a idx to \a arg_cstr if \a idx is /// a valid argument index. /// - /// @param[in] idx + /// \param[in] idx /// The index of the argument that will have its value replaced. /// - /// @param[in] arg_cstr + /// \param[in] arg_cstr /// The new argument as a NULL terminated C string. /// - /// @param[in] quote_char + /// \param[in] quote_char /// If the argument was originally quoted, put in the quote char here. - //------------------------------------------------------------------ void ReplaceArgumentAtIndex(size_t idx, llvm::StringRef arg_str, char quote_char = '\0'); - //------------------------------------------------------------------ /// Deletes the argument value at index /// if \a idx is a valid argument index. /// - /// @param[in] idx + /// \param[in] idx /// The index of the argument that will have its value replaced. /// - //------------------------------------------------------------------ void DeleteArgumentAtIndex(size_t idx); - //------------------------------------------------------------------ /// Sets the argument vector value, optionally copying all arguments into an /// internal buffer. /// @@ -256,12 +224,10 @@ public: /// will be copied into an internal buffers. // // FIXME: Handle the quote character somehow. - //------------------------------------------------------------------ void SetArguments(size_t argc, const char **argv); void SetArguments(const char **argv); - //------------------------------------------------------------------ /// Shifts the first argument C string value of the array off the argument /// array. /// @@ -269,29 +235,24 @@ public: /// by calling Args::GetArgumentAtIndex (size_t) const first and copying the /// returned value before calling Args::Shift(). /// - /// @see Args::GetArgumentAtIndex (size_t) const - //------------------------------------------------------------------ + /// \see Args::GetArgumentAtIndex (size_t) const void Shift(); - //------------------------------------------------------------------ /// Inserts a class owned copy of \a arg_cstr at the beginning of the /// argument vector. /// /// A copy \a arg_cstr will be made. /// - /// @param[in] arg_cstr + /// \param[in] arg_cstr /// The argument to push on the front of the argument stack. /// - /// @param[in] quote_char + /// \param[in] quote_char /// If the argument was originally quoted, put in the quote char here. - //------------------------------------------------------------------ void Unshift(llvm::StringRef arg_str, char quote_char = '\0'); - //------------------------------------------------------------------ // Clear the arguments. // // For re-setting or blanking out the list of arguments. - //------------------------------------------------------------------ void Clear(); static const char *StripSpaces(std::string &s, bool leading = true, @@ -306,7 +267,9 @@ public: if (total_byte_size == 8) return true; - const uint64_t max = ((uint64_t)1 << (uint64_t)(total_byte_size * 8)) - 1; + const uint64_t max = (static_cast<uint64_t>(1) + << static_cast<uint64_t>(total_byte_size * 8)) - + 1; return uval64 <= max; } @@ -318,7 +281,9 @@ public: if (total_byte_size == 8) return true; - const int64_t max = ((int64_t)1 << (uint64_t)(total_byte_size * 8 - 1)) - 1; + const int64_t max = (static_cast<int64_t>(1) + << static_cast<uint64_t>(total_byte_size * 8 - 1)) - + 1; const int64_t min = ~(max); return min <= sval64 && sval64 <= max; } @@ -358,8 +323,7 @@ private: std::vector<char *> m_argv; }; -//---------------------------------------------------------------------- -/// @class OptionsWithRaw Args.h "lldb/Utility/Args.h" +/// \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 @@ -377,71 +341,56 @@ private: /// All strings not matching the above format as considered to be just a raw /// string without any options. /// -/// @see Args -//---------------------------------------------------------------------- +/// \see Args class OptionsWithRaw { public: - //------------------------------------------------------------------ /// Parse the given string as a list of optional arguments with a raw suffix. /// /// See the class description for a description of the input format. /// - /// @param[in] argument_string + /// \param[in] argument_string /// The string that should be parsed. - //------------------------------------------------------------------ explicit OptionsWithRaw(llvm::StringRef argument_string); - //------------------------------------------------------------------ /// Returns true if there are any arguments before the raw suffix. - //------------------------------------------------------------------ bool HasArgs() const { return m_has_args; } - //------------------------------------------------------------------ /// Returns the list of arguments. /// /// You can only call this method if HasArgs returns true. - //------------------------------------------------------------------ Args &GetArgs() { assert(m_has_args); return m_args; } - //------------------------------------------------------------------ /// Returns the list of arguments. /// /// 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. /// /// 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. /// /// You can only call this method if HasArgs returns true. - //------------------------------------------------------------------ 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: diff --git a/include/lldb/Utility/Baton.h b/include/lldb/Utility/Baton.h index 7477846be48bf..4050f2af2bf04 100644 --- a/include/lldb/Utility/Baton.h +++ b/include/lldb/Utility/Baton.h @@ -1,9 +1,8 @@ //===-- Baton.h -------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -21,8 +20,7 @@ class Stream; namespace lldb_private { -//---------------------------------------------------------------------- -/// @class Baton Baton.h "lldb/Core/Baton.h" +/// \class Baton Baton.h "lldb/Core/Baton.h" /// A class designed to wrap callback batons so they can cleanup /// any acquired resources /// @@ -32,7 +30,6 @@ namespace lldb_private { /// /// The default behavior is to not free anything. Subclasses can free any /// needed resources in their destructors. -//---------------------------------------------------------------------- class Baton { public: Baton() {} @@ -47,7 +44,7 @@ public: class UntypedBaton : public Baton { public: UntypedBaton(void *Data) : m_data(Data) {} - virtual ~UntypedBaton() { + ~UntypedBaton() override { // The default destructor for an untyped baton does NOT attempt to clean up // anything in m_data. } @@ -66,8 +63,7 @@ public: const T *getItem() const { return Item.get(); } void *data() override { return Item.get(); } - virtual void GetDescription(Stream *s, - lldb::DescriptionLevel level) const override {} + void GetDescription(Stream *s, lldb::DescriptionLevel level) const override {} protected: std::unique_ptr<T> Item; diff --git a/include/lldb/Utility/Broadcaster.h b/include/lldb/Utility/Broadcaster.h index 8763a63b0d5ea..fe4d1ca479b89 100644 --- a/include/lldb/Utility/Broadcaster.h +++ b/include/lldb/Utility/Broadcaster.h @@ -1,9 +1,8 @@ //===-- Broadcaster.h -------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -27,51 +26,41 @@ namespace lldb_private { class Broadcaster; -} -namespace lldb_private { class EventData; -} -namespace lldb_private { class Listener; -} -namespace lldb_private { class Stream; -} +} // namespace lldb_private namespace lldb_private { -//---------------------------------------------------------------------- -// lldb::BroadcastEventSpec -// -// This class is used to specify a kind of event to register for. The Debugger -// maintains a list of BroadcastEventSpec's and when it is made -//---------------------------------------------------------------------- +/// lldb::BroadcastEventSpec +/// +/// This class is used to specify a kind of event to register for. The +/// Debugger maintains a list of BroadcastEventSpec's and when it is made class BroadcastEventSpec { public: - BroadcastEventSpec(const ConstString &broadcaster_class, uint32_t event_bits) + BroadcastEventSpec(ConstString broadcaster_class, uint32_t event_bits) : m_broadcaster_class(broadcaster_class), m_event_bits(event_bits) {} - BroadcastEventSpec(const BroadcastEventSpec &rhs); - ~BroadcastEventSpec() = default; - const ConstString &GetBroadcasterClass() const { return m_broadcaster_class; } + ConstString GetBroadcasterClass() const { return m_broadcaster_class; } 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. - bool IsContainedIn(BroadcastEventSpec in_spec) const { + /// 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(const BroadcastEventSpec &in_spec) const { if (m_broadcaster_class != in_spec.GetBroadcasterClass()) return false; uint32_t in_bits = in_spec.GetEventBits(); if (in_bits == m_event_bits) return true; - else { - if ((m_event_bits & in_bits) != 0 && (m_event_bits & ~in_bits) == 0) - return true; - } + + if ((m_event_bits & in_bits) != 0 && (m_event_bits & ~in_bits) == 0) + return true; + return false; } @@ -92,21 +81,21 @@ protected: BroadcasterManager(); public: - // Listeners hold onto weak pointers to their broadcaster managers. So they - // must be made into shared pointers, which you do with - // MakeBroadcasterManager. - + /// Listeners hold onto weak pointers to their broadcaster managers. So they + /// must be made into shared pointers, which you do with + /// MakeBroadcasterManager. static lldb::BroadcasterManagerSP MakeBroadcasterManager(); ~BroadcasterManager() = default; uint32_t RegisterListenerForEvents(const lldb::ListenerSP &listener_sp, - BroadcastEventSpec event_spec); + const BroadcastEventSpec &event_spec); bool UnregisterListenerForEvents(const lldb::ListenerSP &listener_sp, - BroadcastEventSpec event_spec); + const BroadcastEventSpec &event_spec); - lldb::ListenerSP GetListenerForEventSpec(BroadcastEventSpec event_spec) const; + lldb::ListenerSP + GetListenerForEventSpec(const BroadcastEventSpec &event_spec) const; void SignUpListenersForBroadcaster(Broadcaster &broadcaster); @@ -129,12 +118,12 @@ private: class BroadcasterClassMatches { public: - BroadcasterClassMatches(const ConstString &broadcaster_class) + BroadcasterClassMatches(ConstString broadcaster_class) : m_broadcaster_class(broadcaster_class) {} ~BroadcasterClassMatches() = default; - bool operator()(const event_listener_key input) const { + bool operator()(const event_listener_key &input) const { return (input.first.GetBroadcasterClass() == m_broadcaster_class); } @@ -144,12 +133,12 @@ private: class BroadcastEventSpecMatches { public: - BroadcastEventSpecMatches(BroadcastEventSpec broadcaster_spec) + BroadcastEventSpecMatches(const BroadcastEventSpec &broadcaster_spec) : m_broadcaster_spec(broadcaster_spec) {} ~BroadcastEventSpecMatches() = default; - bool operator()(const event_listener_key input) const { + bool operator()(const event_listener_key &input) const { return (input.first.IsContainedIn(m_broadcaster_spec)); } @@ -159,13 +148,14 @@ private: class ListenerMatchesAndSharedBits { public: - explicit ListenerMatchesAndSharedBits(BroadcastEventSpec broadcaster_spec, - const lldb::ListenerSP listener_sp) + explicit ListenerMatchesAndSharedBits( + const BroadcastEventSpec &broadcaster_spec, + const lldb::ListenerSP &listener_sp) : m_broadcaster_spec(broadcaster_spec), m_listener_sp(listener_sp) {} ~ListenerMatchesAndSharedBits() = default; - bool operator()(const event_listener_key input) const { + bool operator()(const event_listener_key &input) const { return (input.first.GetBroadcasterClass() == m_broadcaster_spec.GetBroadcasterClass() && (input.first.GetEventBits() & @@ -180,16 +170,16 @@ private: class ListenerMatches { public: - explicit ListenerMatches(const lldb::ListenerSP in_listener_sp) + explicit ListenerMatches(const lldb::ListenerSP &in_listener_sp) : m_listener_sp(in_listener_sp) {} ~ListenerMatches() = default; - bool operator()(const event_listener_key input) const { + bool operator()(const event_listener_key &input) const { if (input.second == m_listener_sp) return true; - else - return false; + + return false; } private: @@ -203,18 +193,18 @@ private: ~ListenerMatchesPointer() = default; - bool operator()(const event_listener_key input) const { + bool operator()(const event_listener_key &input) const { if (input.second.get() == m_listener) return true; - else - return false; + + return false; } - bool operator()(const lldb::ListenerSP input) const { + bool operator()(const lldb::ListenerSP &input) const { if (input.get() == m_listener) return true; - else - return false; + + return false; } private: @@ -222,17 +212,16 @@ private: }; }; -//---------------------------------------------------------------------- -/// @class Broadcaster Broadcaster.h "lldb/Utility/Broadcaster.h" An event +/// \class Broadcaster Broadcaster.h "lldb/Utility/Broadcaster.h" An event /// broadcasting class. /// /// The Broadcaster class is designed to be subclassed by objects that wish to /// 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) +/// \see Broadcaster::SetEventBits(uint32_t) /// or cleared: -/// @see Broadcaster::ResetEventBits(uint32_t) +/// \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). /// @@ -242,9 +231,7 @@ private: /// class Foo : public Broadcaster /// { /// public: -/// //---------------------------------------------------------- /// // Broadcaster event bits definitions. -/// //---------------------------------------------------------- /// enum /// { /// eBroadcastBitOne = (1 << 0), @@ -253,46 +240,39 @@ private: /// ... /// }; /// \endcode -//---------------------------------------------------------------------- class Broadcaster { friend class Listener; friend class Event; public: - //------------------------------------------------------------------ /// Construct with a broadcaster with a name. /// - /// @param[in] name + /// \param[in] name /// A NULL terminated C string that contains the name of the /// broadcaster object. - //------------------------------------------------------------------ Broadcaster(lldb::BroadcasterManagerSP manager_sp, const char *name); - //------------------------------------------------------------------ /// Destructor. /// /// The destructor is virtual since this class gets subclassed. - //------------------------------------------------------------------ virtual ~Broadcaster(); void CheckInWithManager(); - //------------------------------------------------------------------ /// Broadcast an event which has no associated data. /// - /// @param[in] event_type + /// \param[in] event_type /// The element from the enum defining this broadcaster's events /// that is being broadcast. /// - /// @param[in] event_data + /// \param[in] event_data /// User event data that will be owned by the lldb::Event that /// is created internally. /// - /// @param[in] unique + /// \param[in] unique /// If true, then only add an event of this type if there isn't /// one already in the queue. /// - //------------------------------------------------------------------ void BroadcastEvent(lldb::EventSP &event_sp) { m_broadcaster_sp->BroadcastEvent(event_sp); } @@ -320,7 +300,6 @@ public: virtual void AddInitialEventsToListener(const lldb::ListenerSP &listener_sp, uint32_t requested_events); - //------------------------------------------------------------------ /// Listen for any events specified by \a event_mask. /// /// Only one listener can listen to each event bit in a given Broadcaster. @@ -330,55 +309,48 @@ public: /// 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 + /// \param[in] listener /// The Listener object that wants to monitor the events that /// get broadcast by this object. /// - /// @param[in] event_mask + /// \param[in] event_mask /// A bit mask that indicates which events the listener is /// asking to monitor. /// - /// @return + /// \return /// The actual event bits that were acquired by \a listener. - //------------------------------------------------------------------ uint32_t AddListener(const lldb::ListenerSP &listener_sp, uint32_t event_mask) { return m_broadcaster_sp->AddListener(listener_sp, event_mask); } - //------------------------------------------------------------------ /// Get the NULL terminated C string name of this Broadcaster object. /// - /// @return + /// \return /// The NULL terminated C string name of this Broadcaster. - //------------------------------------------------------------------ - const ConstString &GetBroadcasterName() { return m_broadcaster_name; } + ConstString GetBroadcasterName() { return m_broadcaster_name; } - //------------------------------------------------------------------ /// Get the event name(s) for one or more event bits. /// - /// @param[in] event_mask + /// \param[in] event_mask /// A bit mask that indicates which events to get names for. /// - /// @return + /// \return /// The NULL terminated C string name of this Broadcaster. - //------------------------------------------------------------------ bool GetEventNames(Stream &s, const uint32_t event_mask, bool prefix_with_broadcaster_name) const { return m_broadcaster_sp->GetEventNames(s, event_mask, prefix_with_broadcaster_name); } - //------------------------------------------------------------------ /// Set the name for an event bit. /// - /// @param[in] event_mask + /// \param[in] event_mask /// A bit mask that indicates which events the listener is /// asking to monitor. /// - /// @return + /// \return /// The NULL terminated C string name of this Broadcaster. - //------------------------------------------------------------------ void SetEventName(uint32_t event_mask, const char *name) { m_broadcaster_sp->SetEventName(event_mask, name); } @@ -391,49 +363,45 @@ public: return m_broadcaster_sp->EventTypeHasListeners(event_type); } - //------------------------------------------------------------------ /// 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 + /// \param[in] listener /// A Listener object that previously called AddListener. /// - /// @param[in] event_mask + /// \param[in] event_mask /// The event bits \a listener wishes to relinquish. /// - /// @return + /// \return /// \b True if the listener was listening to this broadcaster /// and was removed, \b false otherwise. /// - /// @see uint32_t Broadcaster::AddListener (Listener*, uint32_t) - //------------------------------------------------------------------ + /// \see uint32_t Broadcaster::AddListener (Listener*, uint32_t) bool RemoveListener(const lldb::ListenerSP &listener_sp, uint32_t event_mask = UINT32_MAX) { return m_broadcaster_sp->RemoveListener(listener_sp, event_mask); } - //------------------------------------------------------------------ /// 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. /// - /// @param[in] listener + /// \param[in] listener /// A Listener object. You do not need to call StartListeningForEvents /// for this broadcaster (that would fail anyway since the event bits /// would most likely be taken by the listener(s) you are usurping. /// - /// @param[in] event_mask + /// \param[in] event_mask /// The event bits \a listener wishes to hijack. /// - /// @return + /// \return /// \b True if the event mask could be hijacked, \b false otherwise. /// - /// @see uint32_t Broadcaster::AddListener (Listener*, uint32_t) - //------------------------------------------------------------------ + /// \see uint32_t Broadcaster::AddListener (Listener*, uint32_t) bool HijackBroadcaster(const lldb::ListenerSP &listener_sp, uint32_t event_mask = UINT32_MAX) { return m_broadcaster_sp->HijackBroadcaster(listener_sp, event_mask); @@ -443,35 +411,31 @@ public: return m_broadcaster_sp->IsHijackedForEvent(event_mask); } - //------------------------------------------------------------------ /// Restore the state of the Broadcaster from a previous hijack attempt. - /// - //------------------------------------------------------------------ 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. - // 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. + /// This needs to be filled in if you are going to register the broadcaster + /// 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. virtual ConstString &GetBroadcasterClass() const; lldb::BroadcasterManagerSP GetManager(); 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. - // - // For the most part, the Broadcaster functions dispatch to the - // BroadcasterImpl, and are documented in the public Broadcaster API above. - + /// 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. + /// + /// For the most part, the Broadcaster functions dispatch to the + /// BroadcasterImpl, and are documented in the public Broadcaster API above. class BroadcasterImpl { friend class Listener; friend class Broadcaster; @@ -538,9 +502,6 @@ protected: const char *GetHijackingListenerName(); - //------------------------------------------------------------------ - // - //------------------------------------------------------------------ typedef llvm::SmallVector<std::pair<lldb::ListenerWP, uint32_t>, 4> collection; typedef std::map<uint32_t, std::string> event_names_map; @@ -548,24 +509,28 @@ protected: llvm::SmallVector<std::pair<lldb::ListenerSP, uint32_t &>, 4> GetListeners(); - 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 - ///listening to this broadcaster. - std::recursive_mutex - m_listeners_mutex; ///< A mutex that protects \a m_listeners. - std::vector<lldb::ListenerSP> m_hijacking_listeners; // A simple mechanism - // to intercept events - // from a broadcaster - std::vector<uint32_t> m_hijacking_masks; // At some point we may want to - // have a stack or Listener - // collections, but for now this is just for private hijacking. + /// The broadcaster that this implements. + Broadcaster &m_broadcaster; + + /// Optionally define event names for readability and logging for each + /// event bit. + event_names_map m_event_names; + + /// A list of Listener / event_mask pairs that are listening to this + /// broadcaster. + collection m_listeners; + + /// A mutex that protects \a m_listeners. + std::recursive_mutex m_listeners_mutex; + + /// A simple mechanism to intercept events from a broadcaster + std::vector<lldb::ListenerSP> m_hijacking_listeners; + + /// At some point we may want to have a stack or Listener collections, but + /// for now this is just for private hijacking. + std::vector<uint32_t> m_hijacking_masks; private: - //------------------------------------------------------------------ - // For Broadcaster only - //------------------------------------------------------------------ DISALLOW_COPY_AND_ASSIGN(BroadcasterImpl); }; @@ -577,18 +542,13 @@ protected: const char *GetHijackingListenerName() { return m_broadcaster_sp->GetHijackingListenerName(); } - //------------------------------------------------------------------ - // Classes that inherit from Broadcaster can see and modify these - //------------------------------------------------------------------ private: - //------------------------------------------------------------------ - // For Broadcaster only - //------------------------------------------------------------------ BroadcasterImplSP m_broadcaster_sp; lldb::BroadcasterManagerSP m_manager_sp; - const ConstString - m_broadcaster_name; ///< The name of this broadcaster object. + + /// The name of this broadcaster object. + const ConstString m_broadcaster_name; DISALLOW_COPY_AND_ASSIGN(Broadcaster); }; diff --git a/include/lldb/Utility/CleanUp.h b/include/lldb/Utility/CleanUp.h index ef460ddd5e7fe..6cd5f332ef953 100644 --- a/include/lldb/Utility/CleanUp.h +++ b/include/lldb/Utility/CleanUp.h @@ -1,9 +1,8 @@ //===-- CleanUp.h -----------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// diff --git a/include/lldb/Utility/CompletionRequest.h b/include/lldb/Utility/CompletionRequest.h index 38d8d5c587e2a..f5ccb01ca16f9 100644 --- a/include/lldb/Utility/CompletionRequest.h +++ b/include/lldb/Utility/CompletionRequest.h @@ -1,9 +1,8 @@ //===-- CompletionRequest.h -------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -18,9 +17,7 @@ namespace lldb_private { class CompletionResult { - //---------------------------------------------------------- /// A single completion and all associated data. - //---------------------------------------------------------- struct Completion { Completion(llvm::StringRef completion, llvm::StringRef description) : m_completion(completion.str()), m_descripton(description.str()) {} @@ -39,56 +36,48 @@ class CompletionResult { public: void AddResult(llvm::StringRef completion, llvm::StringRef description); - //---------------------------------------------------------- /// Adds all collected completion matches to the given list. /// The list will be cleared before the results are added. The number of /// results here is guaranteed to be equal to GetNumberOfResults(). - //---------------------------------------------------------- void GetMatches(StringList &matches) const; - //---------------------------------------------------------- /// Adds all collected completion descriptions to the given list. /// The list will be cleared before the results are added. The number of /// results here is guaranteed to be equal to GetNumberOfResults(). - //---------------------------------------------------------- void GetDescriptions(StringList &descriptions) const; std::size_t GetNumberOfResults() const { return m_results.size(); } }; -//---------------------------------------------------------------------- -/// @class CompletionRequest CompletionRequest.h +/// \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 + /// \param [in] command_line /// The command line the user has typed at this point. /// - /// @param [in] raw_cursor_pos + /// \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 + /// \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] result + /// \param [out] result /// The CompletionResult that will be filled with the results after this /// request has been handled. - //---------------------------------------------------------- CompletionRequest(llvm::StringRef command_line, unsigned raw_cursor_pos, int match_start_point, int max_return_elements, CompletionResult &result); @@ -122,8 +111,8 @@ public: /// the suggested completion is stored, so the given string can be free'd /// afterwards. /// - /// @param match The suggested completion. - /// @param match An optional description of the completion string. The + /// \param match The suggested completion. + /// \param match An optional description of the completion string. The /// description will be displayed to the user alongside the completion. void AddCompletion(llvm::StringRef completion, llvm::StringRef description = "") { @@ -134,7 +123,7 @@ public: /// /// \param completions The list of completions. /// - /// @see AddCompletion + /// \see AddCompletion void AddCompletions(const StringList &completions) { for (std::size_t i = 0; i < completions.GetSize(); ++i) AddCompletion(completions.GetStringAtIndex(i)); @@ -147,7 +136,7 @@ public: /// \param completions The list of completions. /// \param completions The list of descriptions. /// - /// @see AddCompletion + /// \see AddCompletion void AddCompletions(const StringList &completions, const StringList &descriptions) { lldbassert(completions.GetSize() == descriptions.GetSize()); diff --git a/include/lldb/Utility/Connection.h b/include/lldb/Utility/Connection.h index 074b44b368658..77f3ef4a76ba7 100644 --- a/include/lldb/Utility/Connection.h +++ b/include/lldb/Utility/Connection.h @@ -1,9 +1,8 @@ //===-- Connection.h --------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -23,15 +22,12 @@ namespace lldb_private { class Status; -} -namespace lldb_private { template <typename Ratio> class Timeout; } namespace lldb_private { -//---------------------------------------------------------------------- -/// @class Connection Connection.h "lldb/Utility/Connection.h" +/// \class Connection Connection.h "lldb/Utility/Connection.h" /// A communication connection class. /// /// A class that implements that actual communication functions for @@ -42,136 +38,118 @@ namespace lldb_private { /// 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: - //------------------------------------------------------------------ /// Default constructor - //------------------------------------------------------------------ Connection() = default; - //------------------------------------------------------------------ /// Virtual destructor since this class gets subclassed and handed to a /// Communication object. - //------------------------------------------------------------------ virtual ~Connection(); - //------------------------------------------------------------------ /// Connect using the connect string \a url. /// - /// @param[in] url + /// \param[in] url /// A string that contains all information needed by the /// subclass to connect to another client. /// - /// @param[out] error_ptr + /// \param[out] error_ptr /// A pointer to an error object that should be given an /// appropriate error value if this method returns false. This /// value can be NULL if the error value should be ignored. /// - /// @return + /// \return /// \b True if the connect succeeded, \b false otherwise. The /// internal error object should be filled in with an /// appropriate value based on the result of this function. /// - /// @see Status& Communication::GetError (); - //------------------------------------------------------------------ + /// \see Status& Communication::GetError (); virtual lldb::ConnectionStatus Connect(llvm::StringRef url, Status *error_ptr) = 0; - //------------------------------------------------------------------ /// Disconnect the communications connection if one is currently connected. /// - /// @param[out] error_ptr + /// \param[out] error_ptr /// A pointer to an error object that should be given an /// appropriate error value if this method returns false. This /// value can be NULL if the error value should be ignored. /// - /// @return + /// \return /// \b True if the disconnect succeeded, \b false otherwise. The /// internal error object should be filled in with an /// appropriate value based on the result of this function. /// - /// @see Status& Communication::GetError (); - //------------------------------------------------------------------ + /// \see Status& Communication::GetError (); virtual lldb::ConnectionStatus Disconnect(Status *error_ptr) = 0; - //------------------------------------------------------------------ /// Check if the connection is valid. /// - /// @return + /// \return /// \b True if this object is currently connected, \b false /// otherwise. - //------------------------------------------------------------------ virtual bool IsConnected() const = 0; - //------------------------------------------------------------------ /// The read function that attempts to read from the connection. /// - /// @param[in] dst + /// \param[in] dst /// A destination buffer that must be at least \a dst_len bytes /// long. /// - /// @param[in] dst_len + /// \param[in] dst_len /// The number of bytes to attempt to read, and also the max /// number of bytes that can be placed into \a dst. /// - /// @param[in] timeout + /// \param[in] timeout /// The number of microseconds to wait for the data. /// - /// @param[out] status + /// \param[out] status /// On return, indicates whether the call was successful or terminated /// due to some error condition. /// - /// @param[out] error_ptr + /// \param[out] error_ptr /// A pointer to an error object that should be given an /// appropriate error value if this method returns zero. This /// value can be NULL if the error value should be ignored. /// - /// @return + /// \return /// The number of bytes actually read. /// - /// @see size_t Communication::Read (void *, size_t, uint32_t); - //------------------------------------------------------------------ + /// \see size_t Communication::Read (void *, size_t, uint32_t); virtual size_t Read(void *dst, size_t dst_len, const Timeout<std::micro> &timeout, lldb::ConnectionStatus &status, Status *error_ptr) = 0; - //------------------------------------------------------------------ /// The actual write function that attempts to write to the communications /// protocol. /// /// Subclasses must override this function. /// - /// @param[in] dst + /// \param[in] dst /// A desination buffer that must be at least \a dst_len bytes /// long. /// - /// @param[in] dst_len + /// \param[in] dst_len /// The number of bytes to attempt to write, and also the /// number of bytes are currently available in \a dst. /// - /// @param[out] error_ptr + /// \param[out] error_ptr /// A pointer to an error object that should be given an /// appropriate error value if this method returns zero. This /// value can be NULL if the error value should be ignored. /// - /// @return + /// \return /// The number of bytes actually Written. - //------------------------------------------------------------------ virtual size_t Write(const void *dst, size_t dst_len, lldb::ConnectionStatus &status, Status *error_ptr) = 0; - //------------------------------------------------------------------ /// Returns a URI that describes this connection object /// /// Subclasses may override this function. /// - /// @return + /// \return /// Returns URI or an empty string if disconnecteds - //------------------------------------------------------------------ virtual std::string GetURI() = 0; - //------------------------------------------------------------------ /// Interrupts an ongoing Read() operation. /// /// If there is an ongoing read operation in another thread, this operation @@ -181,27 +159,22 @@ public: /// interrupt request (which will remain queued for the next Read() /// operation). /// - /// @return + /// \return /// Returns true is the interrupt request was successful. - //------------------------------------------------------------------ virtual bool InterruptRead() = 0; - //------------------------------------------------------------------ /// 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. /// - /// @return + /// \return /// The underlying IOObject used for reading. - //------------------------------------------------------------------ virtual lldb::IOObjectSP GetReadObject() { return lldb::IOObjectSP(); } private: - //------------------------------------------------------------------ // For Connection only - //------------------------------------------------------------------ DISALLOW_COPY_AND_ASSIGN(Connection); }; diff --git a/include/lldb/Utility/ConstString.h b/include/lldb/Utility/ConstString.h index 41f6717edee98..8576c18ddcd81 100644 --- a/include/lldb/Utility/ConstString.h +++ b/include/lldb/Utility/ConstString.h @@ -1,9 +1,8 @@ //===-- ConstString.h -------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -24,8 +23,7 @@ class raw_ostream; namespace lldb_private { -//---------------------------------------------------------------------- -/// @class ConstString ConstString.h "lldb/Utility/ConstString.h" +/// \class ConstString ConstString.h "lldb/Utility/ConstString.h" /// A uniqued constant string class. /// /// Provides an efficient way to store strings as uniqued strings. After the @@ -37,41 +35,33 @@ namespace lldb_private { /// 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: - //------------------------------------------------------------------ /// Default constructor /// /// Initializes the string to an empty string. - //------------------------------------------------------------------ ConstString() : m_string(nullptr) {} - //------------------------------------------------------------------ /// Copy constructor /// /// Copies the string value in \a rhs into this object. /// - /// @param[in] rhs + /// \param[in] rhs /// Another string object to copy. - //------------------------------------------------------------------ ConstString(const ConstString &rhs) : m_string(rhs.m_string) {} explicit ConstString(const llvm::StringRef &s); - //------------------------------------------------------------------ /// Construct with C String value /// /// Constructs this object with a C string by looking to see if the /// C string already exists in the global string pool. If it doesn't /// exist, it is added to the string pool. /// - /// @param[in] cstr + /// \param[in] cstr /// A NULL terminated C string to add to the string pool. - //------------------------------------------------------------------ explicit ConstString(const char *cstr); - //------------------------------------------------------------------ /// Construct with C String value with max length /// /// Constructs this object with a C string with a length. If \a max_cstr_len @@ -79,125 +69,148 @@ public: /// 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 + /// \param[in] cstr /// A pointer to the first character in the C string. The C /// string can be NULL terminated in a buffer that contains /// more characters than the length of the string, or the /// string can be part of another string and a new substring /// can be created. /// - /// @param[in] max_cstr_len + /// \param[in] max_cstr_len /// The max length of \a cstr. If the string length of \a cstr /// is less than \a max_cstr_len, then the string will be /// truncated. If the string length of \a cstr is greater than /// \a max_cstr_len, then only max_cstr_len bytes will be used /// from \a cstr. - //------------------------------------------------------------------ explicit ConstString(const char *cstr, size_t max_cstr_len); - //------------------------------------------------------------------ /// Destructor /// /// Since constant string values are currently not reference counted, there /// isn't much to do here. - //------------------------------------------------------------------ ~ConstString() = default; - //---------------------------------------------------------------------- /// C string equality binary predicate function object for ConstString /// objects. - //---------------------------------------------------------------------- struct StringIsEqual { - //-------------------------------------------------------------- /// C equality test. /// /// Two C strings are equal when they are contained in ConstString objects /// when their pointer values are equal to each other. /// - /// @return + /// \return /// Returns \b true if the C string in \a lhs is equal to /// the C string value in \a rhs, \b false otherwise. - //-------------------------------------------------------------- bool operator()(const char *lhs, const char *rhs) const { return lhs == rhs; } }; - //------------------------------------------------------------------ /// Convert to bool operator. /// /// This allows code to check a ConstString object to see if it contains a /// valid string using code such as: /// - /// @code + /// \code /// ConstString str(...); /// if (str) /// { ... - /// @endcode + /// \endcode /// - /// @return + /// \return /// /b True this object contains a valid non-empty C string, \b /// false otherwise. - //------------------------------------------------------------------ explicit operator bool() const { return !IsEmpty(); } - //------------------------------------------------------------------ /// Assignment operator /// /// Assigns the string in this object with the value from \a rhs. /// - /// @param[in] rhs + /// \param[in] rhs /// Another string object to copy into this object. /// - /// @return + /// \return /// A const reference to this object. - //------------------------------------------------------------------ - const ConstString &operator=(const ConstString &rhs) { + ConstString operator=(ConstString rhs) { m_string = rhs.m_string; return *this; } - //------------------------------------------------------------------ /// 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. /// - /// @param[in] rhs + /// \param[in] rhs /// Another string object to compare this object to. /// - /// @return - /// @li \b true if this object is equal to \a rhs. - /// @li \b false if this object is not equal to \a rhs. - //------------------------------------------------------------------ - bool operator==(const ConstString &rhs) const { + /// \return + /// \li \b true if this object is equal to \a rhs. + /// \li \b false if this object is not equal to \a rhs. + bool operator==(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. return m_string == rhs.m_string; } - //------------------------------------------------------------------ + /// Equal to operator against a non-ConstString value. + /// + /// Returns true if this string is equal to the string in \a rhs. This + /// overload is usually slower than comparing against a ConstString value. + /// However, if the rhs string not already a ConstString and it is impractical + /// to turn it into a non-temporary variable, then this overload is faster. + /// + /// \param[in] rhs + /// Another string object to compare this object to. + /// + /// \return + /// \li \b true if this object is equal to \a rhs. + /// \li \b false if this object is not equal to \a rhs. + bool operator==(const char *rhs) const { + // ConstString differentiates between empty strings and nullptr strings, but + // StringRef doesn't. Therefore we have to do this check manually now. + if (m_string == nullptr && rhs != nullptr) + return false; + if (m_string != nullptr && rhs == nullptr) + return false; + + return GetStringRef() == rhs; + } + /// 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. /// - /// @param[in] rhs + /// \param[in] rhs /// Another string object to compare this object to. /// - /// @return - /// @li \b true if this object is not equal to \a rhs. - /// @li \b false if this object is equal to \a rhs. - //------------------------------------------------------------------ - bool operator!=(const ConstString &rhs) const { + /// \return + /// \li \b true if this object is not equal to \a rhs. + /// \li \b false if this object is equal to \a rhs. + bool operator!=(ConstString rhs) const { return m_string != rhs.m_string; } - bool operator<(const ConstString &rhs) const; + /// Not equal to operator against a non-ConstString value. + /// + /// Returns true if this string is not equal to the string in \a rhs. This + /// overload is usually slower than comparing against a ConstString value. + /// However, if the rhs string not already a ConstString and it is impractical + /// to turn it into a non-temporary variable, then this overload is faster. + /// + /// \param[in] rhs + /// Another string object to compare this object to. + /// + /// \return + /// \li \b true if this object is not equal to \a rhs. + /// \li \b false if this object is equal to \a rhs. + bool operator!=(const char *rhs) const { return !(*this == rhs); } + + bool operator<(ConstString rhs) const; - //------------------------------------------------------------------ /// Get the string value as a C string. /// /// Get the value of the contained string as a NULL terminated C string @@ -205,26 +218,22 @@ public: /// /// If \a value_if_empty is nullptr, then nullptr will be returned. /// - /// @return + /// \return /// Returns \a value_if_empty if the string is empty, otherwise /// the C string value contained in this object. - //------------------------------------------------------------------ const char *AsCString(const char *value_if_empty = nullptr) const { return (IsEmpty() ? value_if_empty : m_string); } - //------------------------------------------------------------------ /// Get the string value as a llvm::StringRef /// - /// @return + /// \return /// Returns a new llvm::StringRef object filled in with the /// needed data. - //------------------------------------------------------------------ llvm::StringRef GetStringRef() const { return llvm::StringRef(m_string, GetLength()); } - //------------------------------------------------------------------ /// Get the string value as a C string. /// /// Get the value of the contained string as a NULL terminated C string @@ -232,33 +241,27 @@ public: /// function will always return nullptr if the string is not valid. So this /// function is a direct accessor to the string pointer value. /// - /// @return + /// \return /// Returns nullptr the string is invalid, otherwise the C string /// value contained in this object. - //------------------------------------------------------------------ const char *GetCString() const { return m_string; } - //------------------------------------------------------------------ /// 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. /// - /// @return + /// \return /// Returns the number of bytes that this string occupies in /// memory, not including the NULL termination byte. - //------------------------------------------------------------------ size_t GetLength() const; - //------------------------------------------------------------------ /// Clear this object's state. /// /// Clear any contained string and reset the value to the 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 @@ -266,24 +269,22 @@ public: /// in a pointer comparison since all strings are in a uniqued in a global /// string pool. /// - /// @param[in] rhs + /// \param[in] rhs /// The Left Hand Side const ConstString object reference. /// - /// @param[in] rhs + /// \param[in] rhs /// The Right Hand Side const ConstString object reference. /// - /// @param[in] case_sensitive + /// \param[in] case_sensitive /// Case sensitivity. If true, case sensitive equality /// will be tested, otherwise character case will be ignored /// - /// @return - /// @li \b true if this object is equal to \a rhs. - /// @li \b false if this object is not equal to \a rhs. - //------------------------------------------------------------------ - static bool Equals(const ConstString &lhs, const ConstString &rhs, + /// \return + /// \li \b true if this object is equal to \a rhs. + /// \li \b false if this object is not equal to \a rhs. + static bool Equals(ConstString lhs, ConstString rhs, const bool case_sensitive = true); - //------------------------------------------------------------------ /// Compare two string objects. /// /// Compares the C string values contained in \a lhs and \a rhs and returns @@ -294,67 +295,57 @@ public: /// it is much more efficient. Also if you want string inequality, use the /// != operator for the same reasons. /// - /// @param[in] lhs + /// \param[in] lhs /// The Left Hand Side const ConstString object reference. /// - /// @param[in] rhs + /// \param[in] rhs /// The Right Hand Side const ConstString object reference. /// - /// @param[in] case_sensitive + /// \param[in] case_sensitive /// Case sensitivity of compare. If true, case sensitive compare /// will be performed, otherwise character case will be ignored /// - /// @return - /// @li -1 if lhs < rhs - /// @li 0 if lhs == rhs - /// @li 1 if lhs > rhs - //------------------------------------------------------------------ - static int Compare(const ConstString &lhs, const ConstString &rhs, + /// \return + /// \li -1 if lhs < rhs + /// \li 0 if lhs == rhs + /// \li 1 if lhs > rhs + static int Compare(ConstString lhs, ConstString rhs, const bool case_sensitive = true); - //------------------------------------------------------------------ /// 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. /// - /// @param[in] s + /// \param[in] s /// The stream that will be used to dump the object description. /// - /// @param[in] value_if_empty + /// \param[in] value_if_empty /// The value to dump if the string is empty. If nullptr, nothing /// will be output to the stream. - //------------------------------------------------------------------ void Dump(Stream *s, const char *value_if_empty = nullptr) const; - //------------------------------------------------------------------ /// Dump the object debug description to a stream. /// - /// @param[in] s + /// \param[in] s /// The stream that will be used to dump the object description. - //------------------------------------------------------------------ void DumpDebug(Stream *s) const; - //------------------------------------------------------------------ /// Test for empty string. /// - /// @return - /// @li \b true if the contained string is empty. - /// @li \b false if the contained string is not empty. - //------------------------------------------------------------------ + /// \return + /// \li \b true if the contained string is empty. + /// \li \b false if the contained string is not empty. bool IsEmpty() const { return m_string == nullptr || m_string[0] == '\0'; } - //------------------------------------------------------------------ /// Test for null string. /// - /// @return - /// @li \b true if there is no string associated with this instance. - /// @li \b false if there is a string associated with this instance. - //------------------------------------------------------------------ + /// \return + /// \li \b true if there is no string associated with this instance. + /// \li \b false if there is a string associated with this instance. bool IsNull() const { return m_string == nullptr; } - //------------------------------------------------------------------ /// Set the C string value. /// /// Set the string value in the object by uniquing the \a cstr string value @@ -364,14 +355,12 @@ public: /// current entry and returns the existing value. If it doesn't exist, it is /// added to the string pool. /// - /// @param[in] cstr + /// \param[in] cstr /// A NULL terminated C string to add to the string pool. - //------------------------------------------------------------------ void SetCString(const char *cstr); void SetString(const llvm::StringRef &s); - //------------------------------------------------------------------ /// Set the C string value and its mangled counterpart. /// /// Object files and debug symbols often use mangled string to represent the @@ -381,17 +370,15 @@ public: /// demangler over and over on the same strings and then trying to unique /// them. /// - /// @param[in] demangled + /// \param[in] demangled /// The demangled string to correlate with the \a mangled name. /// - /// @param[in] mangled + /// \param[in] mangled /// The already uniqued mangled ConstString to correlate the /// soon to be uniqued version of \a demangled. - //------------------------------------------------------------------ void SetStringWithMangledCounterpart(llvm::StringRef demangled, - const ConstString &mangled); + ConstString mangled); - //------------------------------------------------------------------ /// Retrieve the mangled or demangled counterpart for a mangled or demangled /// ConstString. /// @@ -402,17 +389,15 @@ public: /// demangler over and over on the same strings and then trying to unique /// them. /// - /// @param[in] counterpart + /// \param[in] counterpart /// A reference to a ConstString object that might get filled in /// with the demangled/mangled counterpart. /// - /// @return + /// \return /// /b True if \a counterpart was filled in with the counterpart /// /b false otherwise. - //------------------------------------------------------------------ bool GetMangledCounterpart(ConstString &counterpart) const; - //------------------------------------------------------------------ /// Set the C string value with length. /// /// Set the string value in the object by uniquing \a cstr_len bytes @@ -424,59 +409,48 @@ public: /// current entry and returns the existing value. If it doesn't exist, it is /// added to the string pool. /// - /// @param[in] cstr + /// \param[in] cstr /// A NULL terminated C string to add to the string pool. /// - /// @param[in] cstr_len + /// \param[in] cstr_len /// The maximum length of the C string. - //------------------------------------------------------------------ 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. - //------------------------------------------------------------------ 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 + /// \return /// The number of bytes that this object occupies in memory. /// - /// @see ConstString::StaticMemorySize () - //------------------------------------------------------------------ + /// \see ConstString::StaticMemorySize () size_t MemorySize() const { return sizeof(ConstString); } - //------------------------------------------------------------------ /// 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. /// - /// @return + /// \return /// The number of bytes that the global string pool occupies /// in memory. - //------------------------------------------------------------------ static size_t StaticMemorySize(); protected: - //------------------------------------------------------------------ // Member variables - //------------------------------------------------------------------ const char *m_string; }; -//------------------------------------------------------------------ /// Stream the string value \a str to the stream \a s -//------------------------------------------------------------------ -Stream &operator<<(Stream &s, const ConstString &str); +Stream &operator<<(Stream &s, ConstString str); } // namespace lldb_private diff --git a/include/lldb/Utility/DataBuffer.h b/include/lldb/Utility/DataBuffer.h index 05cb609207373..523569301e84a 100644 --- a/include/lldb/Utility/DataBuffer.h +++ b/include/lldb/Utility/DataBuffer.h @@ -1,9 +1,8 @@ //===-- DataBuffer.h --------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -20,8 +19,7 @@ namespace lldb_private { -//---------------------------------------------------------------------- -/// @class DataBuffer DataBuffer.h "lldb/Core/DataBuffer.h" +/// \class DataBuffer DataBuffer.h "lldb/Core/DataBuffer.h" /// A pure virtual protocol class for abstracted data buffers. /// /// DataBuffer is an abstract class that gets packaged into a shared pointer @@ -42,43 +40,34 @@ namespace lldb_private { /// 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. - //------------------------------------------------------------------ virtual ~DataBuffer() {} - //------------------------------------------------------------------ /// Get a pointer to the data. /// - /// @return + /// \return /// A pointer to the bytes owned by this object, or NULL if the /// object contains no bytes. - //------------------------------------------------------------------ virtual uint8_t *GetBytes() = 0; - //------------------------------------------------------------------ /// Get a const pointer to the data. /// - /// @return + /// \return /// A const pointer to the bytes owned by this object, or NULL /// if the object contains no bytes. - //------------------------------------------------------------------ virtual const uint8_t *GetBytes() const = 0; - //------------------------------------------------------------------ /// Get the number of bytes in the data buffer. /// - /// @return + /// \return /// The number of bytes this object currently contains. - //------------------------------------------------------------------ virtual lldb::offset_t GetByteSize() const = 0; llvm::ArrayRef<uint8_t> GetData() const { diff --git a/include/lldb/Utility/DataBufferHeap.h b/include/lldb/Utility/DataBufferHeap.h index 5a1e98803f0a7..2a64694d7f296 100644 --- a/include/lldb/Utility/DataBufferHeap.h +++ b/include/lldb/Utility/DataBufferHeap.h @@ -1,9 +1,8 @@ //===-- DataBufferHeap.h ----------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -19,8 +18,7 @@ namespace lldb_private { -//---------------------------------------------------------------------- -/// @class DataBufferHeap DataBufferHeap.h "lldb/Core/DataBufferHeap.h" +/// \class DataBufferHeap DataBufferHeap.h "lldb/Core/DataBufferHeap.h" /// 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 @@ -29,91 +27,72 @@ namespace lldb_private { /// 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: - //------------------------------------------------------------------ /// Default constructor /// /// Initializes the heap based buffer with no bytes. - //------------------------------------------------------------------ DataBufferHeap(); - //------------------------------------------------------------------ /// Construct with size \a n and fill with \a ch. /// /// Initialize this class with \a n bytes and fills the buffer with \a ch. /// - /// @param[in] n + /// \param[in] n /// The number of bytes that heap based buffer should contain. /// - /// @param[in] ch + /// \param[in] ch /// The character to use when filling the buffer initially. - //------------------------------------------------------------------ DataBufferHeap(lldb::offset_t n, uint8_t ch); - //------------------------------------------------------------------ /// Construct by making a copy of \a src_len bytes from \a src. /// - /// @param[in] src + /// \param[in] src /// A pointer to the data to copy. /// - /// @param[in] src_len + /// \param[in] src_len /// The number of bytes in \a src to copy. - //------------------------------------------------------------------ DataBufferHeap(const void *src, lldb::offset_t src_len); - //------------------------------------------------------------------ /// Destructor. /// /// Virtual destructor since this class inherits from a pure virtual base /// class #DataBuffer. - //------------------------------------------------------------------ ~DataBufferHeap() override; - //------------------------------------------------------------------ - /// @copydoc DataBuffer::GetBytes() - //------------------------------------------------------------------ + /// \copydoc DataBuffer::GetBytes() uint8_t *GetBytes() override; - //------------------------------------------------------------------ - /// @copydoc DataBuffer::GetBytes() const - //------------------------------------------------------------------ + /// \copydoc DataBuffer::GetBytes() const const uint8_t *GetBytes() const override; - //------------------------------------------------------------------ - /// @copydoc DataBuffer::GetByteSize() const - //------------------------------------------------------------------ + /// \copydoc DataBuffer::GetByteSize() const lldb::offset_t GetByteSize() const override; - //------------------------------------------------------------------ /// 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. Note that this /// zero-initializes up to \p byte_size bytes. /// - /// @param[in] byte_size + /// \param[in] byte_size /// The new size in bytes that this data buffer should attempt /// to resize itself to. /// - /// @return + /// \return /// The size in bytes after that this heap buffer was /// successfully resized to. - //------------------------------------------------------------------ lldb::offset_t SetByteSize(lldb::offset_t byte_size); - //------------------------------------------------------------------ /// Makes a copy of the \a src_len bytes in \a src. /// /// Copies the data in \a src into an internal buffer. /// - /// @param[in] src + /// \param[in] src /// A pointer to the data to copy. /// - /// @param[in] src_len + /// \param[in] src_len /// The number of bytes in \a src to copy. - //------------------------------------------------------------------ void CopyData(const void *src, lldb::offset_t src_len); void CopyData(llvm::StringRef src) { CopyData(src.data(), src.size()); } @@ -122,10 +101,8 @@ public: void Clear(); 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. - //------------------------------------------------------------------ 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 947ddb54da4a8..d4c1107430686 100644 --- a/include/lldb/Utility/DataBufferLLVM.h +++ b/include/lldb/Utility/DataBufferLLVM.h @@ -1,9 +1,8 @@ //===--- DataBufferLLVM.h ---------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -26,7 +25,7 @@ namespace lldb_private { class FileSystem; class DataBufferLLVM : public DataBuffer { public: - ~DataBufferLLVM(); + ~DataBufferLLVM() override; uint8_t *GetBytes() override; const uint8_t *GetBytes() const override; diff --git a/include/lldb/Utility/DataEncoder.h b/include/lldb/Utility/DataEncoder.h index b1ee5a5999833..19b7cef9f0ca3 100644 --- a/include/lldb/Utility/DataEncoder.h +++ b/include/lldb/Utility/DataEncoder.h @@ -1,9 +1,8 @@ //===-- DataEncoder.h -------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -22,47 +21,40 @@ namespace lldb_private { -//---------------------------------------------------------------------- -/// @class DataEncoder DataEncoder.h "lldb/Core/DataEncoder.h" An binary data +/// \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. /// -/// @see DataBuffer -//---------------------------------------------------------------------- +/// \see DataBuffer class DataEncoder { public: - //------------------------------------------------------------------ /// Default constructor. /// /// Initialize all members to a default empty state. - //------------------------------------------------------------------ DataEncoder(); - //------------------------------------------------------------------ /// 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. /// - /// @param[in] data + /// \param[in] data /// A pointer to caller owned data. /// - /// @param[in] data_length + /// \param[in] data_length /// The length in bytes of \a data. /// - /// @param[in] byte_order + /// \param[in] byte_order /// A byte order of the data that we are extracting from. /// - /// @param[in] addr_size + /// \param[in] addr_size /// A new address byte size value. - //------------------------------------------------------------------ DataEncoder(void *data, uint32_t data_length, lldb::ByteOrder byte_order, uint8_t addr_size); - //------------------------------------------------------------------ /// Construct with shared data. /// /// Copies the data shared pointer which adds a reference to the contained @@ -70,109 +62,90 @@ public: /// the data lives as long as anyone still has a valid shared pointer to the /// data in \a data_sp. /// - /// @param[in] data_sp + /// \param[in] data_sp /// A shared pointer to data. /// - /// @param[in] byte_order + /// \param[in] byte_order /// A byte order of the data that we are extracting from. /// - /// @param[in] addr_size + /// \param[in] addr_size /// A new address byte size value. - //------------------------------------------------------------------ DataEncoder(const lldb::DataBufferSP &data_sp, lldb::ByteOrder byte_order, uint8_t addr_size); - //------------------------------------------------------------------ /// 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. - //------------------------------------------------------------------ ~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. - //------------------------------------------------------------------ void Clear(); - //------------------------------------------------------------------ /// Get the current address size. /// /// Return the size in bytes of any address values this object will extract. /// - /// @return + /// \return /// The size in bytes of address values that will be extracted. - //------------------------------------------------------------------ uint8_t GetAddressByteSize() const { return m_addr_size; } - //------------------------------------------------------------------ /// Get the number of bytes contained in this object. /// - /// @return + /// \return /// The total number of bytes of data this object refers to. - //------------------------------------------------------------------ size_t GetByteSize() const { return m_end - m_start; } - //------------------------------------------------------------------ /// Get the data end pointer. /// - /// @return + /// \return /// Returns a pointer to the next byte contained in this /// object's data, or NULL of there is no data in this object. - //------------------------------------------------------------------ uint8_t *GetDataEnd() { return m_end; } const uint8_t *GetDataEnd() const { return m_end; } - //------------------------------------------------------------------ /// Get the shared data offset. /// /// Get the offset of the first byte of data in the shared data (if any). /// - /// @return + /// \return /// If this object contains shared data, this function returns /// the offset in bytes into that shared data, zero otherwise. - //------------------------------------------------------------------ size_t GetSharedDataOffset() const; - //------------------------------------------------------------------ /// Get the current byte order value. /// - /// @return + /// \return /// The current byte order value from this object's internal /// state. - //------------------------------------------------------------------ lldb::ByteOrder GetByteOrder() const { return m_byte_order; } - //------------------------------------------------------------------ /// Get the data start pointer. /// - /// @return + /// \return /// Returns a pointer to the first byte contained in this /// object's data, or NULL of there is no data in this object. - //------------------------------------------------------------------ uint8_t *GetDataStart() { return m_start; } const uint8_t *GetDataStart() const { return m_start; } - //------------------------------------------------------------------ /// Encode unsigned integer values into the data at \a offset. /// - /// @param[in] offset + /// \param[in] offset /// The offset within the contained data at which to put the /// data. /// - /// @param[in] value + /// \param[in] value /// The value to encode into the data. /// - /// @return + /// \return /// The next offset in the bytes of this data if the data /// was successfully encoded, UINT32_MAX if the encoding failed. - //------------------------------------------------------------------ uint32_t PutU8(uint32_t offset, uint8_t value); uint32_t PutU16(uint32_t offset, uint16_t value); @@ -181,7 +154,6 @@ public: uint32_t PutU64(uint32_t offset, uint64_t value); - //------------------------------------------------------------------ /// 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 @@ -189,44 +161,40 @@ public: /// 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 + /// \param[in] offset /// The offset within the contained data at which to put the /// encoded integer. /// - /// @param[in] byte_size + /// \param[in] byte_size /// The size in byte of the integer to encode. /// - /// @param[in] value + /// \param[in] value /// The integer value to write. The least significant bytes of /// the integer value will be written if the size is less than /// 8 bytes. /// - /// @return + /// \return /// The next offset in the bytes of this data if the integer /// was successfully encoded, UINT32_MAX if the encoding failed. - //------------------------------------------------------------------ uint32_t PutMaxU64(uint32_t offset, uint32_t byte_size, uint64_t value); - //------------------------------------------------------------------ /// Encode an arbitrary number of bytes. /// - /// @param[in] offset + /// \param[in] offset /// The offset in bytes into the contained data at which to /// start encoding. /// - /// @param[in] src + /// \param[in] src /// The buffer that contains the bytes to encode. /// - /// @param[in] src_len + /// \param[in] src_len /// The number of bytes to encode. /// - /// @return + /// \return /// The next valid offset within data if the put operation /// was successful, else UINT32_MAX to indicate the put failed. - //------------------------------------------------------------------ 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. /// @@ -236,53 +204,47 @@ public: /// m_addr_size member variable and should be set correctly prior to /// extracting any address values. /// - /// @param[in,out] offset_ptr + /// \param[in,out] offset_ptr /// A pointer to an offset within the data that will be advanced /// by the appropriate number of bytes if the value is extracted /// correctly. If the offset is out of bounds or there are not /// enough bytes to extract this value, the offset will be left /// unmodified. /// - /// @return + /// \return /// The next valid offset within data if the put operation /// was successful, else UINT32_MAX to indicate the put failed. - //------------------------------------------------------------------ uint32_t PutAddress(uint32_t offset, lldb::addr_t addr); - //------------------------------------------------------------------ /// Put a C string to \a offset. /// /// Encodes a C string into the existing data including the terminating /// - /// @param[in,out] offset_ptr + /// \param[in,out] offset_ptr /// A pointer to an offset within the data that will be advanced /// by the appropriate number of bytes if the value is extracted /// correctly. If the offset is out of bounds or there are not /// enough bytes to extract this value, the offset will be left /// unmodified. /// - /// @return + /// \return /// A pointer to the C string value in the data. If the offset /// pointed to by \a offset_ptr is out of bounds, or if the /// offset plus the length of the C string is out of bounds, /// NULL will be returned. - //------------------------------------------------------------------ uint32_t PutCString(uint32_t offset_ptr, const char *cstr); lldb::DataBufferSP &GetSharedDataBuffer() { return m_data_sp; } - //------------------------------------------------------------------ /// 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. /// - /// @param[in] addr_size + /// \param[in] addr_size /// The size in bytes to use when extracting addresses. - //------------------------------------------------------------------ void SetAddressByteSize(uint8_t addr_size) { m_addr_size = addr_size; } - //------------------------------------------------------------------ /// Set data with a buffer that is caller owned. /// /// Use data that is owned by the caller when extracting values. The data @@ -290,21 +252,19 @@ public: /// 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 + /// \param[in] bytes /// A pointer to caller owned data. /// - /// @param[in] length + /// \param[in] length /// The length in bytes of \a bytes. /// - /// @param[in] byte_order + /// \param[in] byte_order /// A byte order of the data that we are extracting from. /// - /// @return + /// \return /// The number of bytes that this object now contains. - //------------------------------------------------------------------ uint32_t SetData(void *bytes, uint32_t length, lldb::ByteOrder byte_order); - //------------------------------------------------------------------ /// Adopt a subset of shared data in \a data_sp. /// /// Copies the data shared pointer which adds a reference to the contained @@ -316,48 +276,41 @@ public: /// 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 + /// \param[in] data_sp /// A shared pointer to data. /// - /// @param[in] offset + /// \param[in] offset /// The offset into \a data_sp at which the subset starts. /// - /// @param[in] length + /// \param[in] length /// The length in bytes of the subset of \a data_sp. /// - /// @return + /// \return /// The number of bytes that this object now contains. - //------------------------------------------------------------------ uint32_t SetData(const lldb::DataBufferSP &data_sp, uint32_t offset = 0, uint32_t length = UINT32_MAX); - //------------------------------------------------------------------ /// Set the byte_order value. /// /// Sets the byte order of the data to extract. Extracted values will be /// swapped if necessary when decoding. /// - /// @param[in] byte_order + /// \param[in] byte_order /// The byte order value to use when extracting data. - //------------------------------------------------------------------ void SetByteOrder(lldb::ByteOrder byte_order) { m_byte_order = byte_order; } - //------------------------------------------------------------------ /// Test the validity of \a offset. /// - /// @return + /// \return /// \b true if \a offset is a valid offset into the data in this /// object, \b false otherwise. - //------------------------------------------------------------------ bool ValidOffset(uint32_t offset) const { return offset < GetByteSize(); } - //------------------------------------------------------------------ /// Test the availability of \a length bytes of data from \a offset. /// - /// @return + /// \return /// \b true if \a offset is a valid offset and there are \a /// length bytes available at that offset, \b false otherwise. - //------------------------------------------------------------------ bool ValidOffsetForDataOfSize(uint32_t offset, uint32_t length) const { return length <= BytesLeft(offset); } @@ -370,9 +323,7 @@ public: } protected: - //------------------------------------------------------------------ // Member variables - //------------------------------------------------------------------ uint8_t *m_start; ///< A pointer to the first byte of data. uint8_t *m_end; ///< A pointer to the byte that is past the end of the data. lldb::ByteOrder diff --git a/include/lldb/Utility/DataExtractor.h b/include/lldb/Utility/DataExtractor.h index f1e15e6d00e32..74174b34ce99b 100644 --- a/include/lldb/Utility/DataExtractor.h +++ b/include/lldb/Utility/DataExtractor.h @@ -1,9 +1,8 @@ //===-- DataExtractor.h -----------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -22,8 +21,6 @@ namespace lldb_private { class Log; -} -namespace lldb_private { class Stream; } namespace llvm { @@ -33,8 +30,7 @@ template <typename T> class SmallVectorImpl; namespace lldb_private { -//---------------------------------------------------------------------- -/// @class DataExtractor DataExtractor.h "lldb/Core/DataExtractor.h" An data +/// \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 @@ -45,15 +41,12 @@ namespace lldb_private { /// unique position in the shared data and extract data from different /// offsets. /// -/// @see DataBuffer -//---------------------------------------------------------------------- +/// \see DataBuffer class DataExtractor { public: - //------------------------------------------------------------------ - /// @typedef DataExtractor::Type + /// \typedef DataExtractor::Type /// Type enumerations used in the dump routines. - //------------------------------------------------------------------ - typedef enum { + enum Type { TypeUInt8, ///< Format output as unsigned 8 bit integers TypeChar, ///< Format output as characters TypeUInt16, ///< Format output as unsigned 16 bit integers @@ -62,41 +55,36 @@ public: TypePointer, ///< Format output as pointers TypeULEB128, ///< Format output as ULEB128 numbers TypeSLEB128 ///< Format output as SLEB128 numbers - } Type; + }; - //------------------------------------------------------------------ /// Default constructor. /// /// Initialize all members to a default empty state. - //------------------------------------------------------------------ DataExtractor(); - //------------------------------------------------------------------ /// 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. /// - /// @param[in] data + /// \param[in] data /// A pointer to caller owned data. /// - /// @param[in] data_length + /// \param[in] data_length /// The length in bytes of \a data. /// - /// @param[in] byte_order + /// \param[in] byte_order /// A byte order of the data that we are extracting from. /// - /// @param[in] addr_size + /// \param[in] addr_size /// A new address byte size value. /// - /// @param[in] target_byte_size + /// \param[in] target_byte_size /// A size of a target byte in 8-bit host bytes - //------------------------------------------------------------------ DataExtractor(const void *data, lldb::offset_t data_length, lldb::ByteOrder byte_order, uint32_t addr_size, uint32_t target_byte_size = 1); - //------------------------------------------------------------------ /// Construct with shared data. /// /// Copies the data shared pointer which adds a reference to the contained @@ -104,22 +92,20 @@ public: /// the data lives as long as anyone still has a valid shared pointer to the /// data in \a data_sp. /// - /// @param[in] data_sp + /// \param[in] data_sp /// A shared pointer to data. /// - /// @param[in] byte_order + /// \param[in] byte_order /// A byte order of the data that we are extracting from. /// - /// @param[in] addr_size + /// \param[in] addr_size /// A new address byte size value. /// - /// @param[in] target_byte_size + /// \param[in] target_byte_size /// A size of a target byte in 8-bit host bytes - //------------------------------------------------------------------ DataExtractor(const lldb::DataBufferSP &data_sp, lldb::ByteOrder byte_order, uint32_t addr_size, uint32_t target_byte_size = 1); - //------------------------------------------------------------------ /// Construct with a subset of \a data. /// /// Initialize this object with a subset of the data bytes in \a data. If \a @@ -131,128 +117,116 @@ public: /// 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 + /// \param[in] data /// Another DataExtractor object that contains data. /// - /// @param[in] offset + /// \param[in] offset /// The offset into \a data at which the subset starts. /// - /// @param[in] length + /// \param[in] length /// The length in bytes of the subset of data. /// - /// @param[in] target_byte_size + /// \param[in] target_byte_size /// A size of a target byte in 8-bit host bytes - //------------------------------------------------------------------ DataExtractor(const DataExtractor &data, lldb::offset_t offset, lldb::offset_t length, uint32_t target_byte_size = 1); DataExtractor(const DataExtractor &rhs); - //------------------------------------------------------------------ /// 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. /// - /// @param[in] rhs + /// \param[in] rhs /// Another DataExtractor object to copy. /// - /// @return + /// \return /// A const reference to this object. - //------------------------------------------------------------------ const DataExtractor &operator=(const DataExtractor &rhs); - //------------------------------------------------------------------ /// 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. - //------------------------------------------------------------------ virtual ~DataExtractor(); uint32_t getTargetByteSize() const { return m_target_byte_size; } - //------------------------------------------------------------------ /// 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. - //------------------------------------------------------------------ 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. /// - /// @param[in] s + /// \param[in] s /// The stream to dump the output to. If nullptr the output will /// be dumped to Log(). /// - /// @param[in] offset + /// \param[in] offset /// The offset into the data at which to start dumping. /// - /// @param[in] length + /// \param[in] length /// The number of bytes to dump. /// - /// @param[in] base_addr + /// \param[in] base_addr /// The base address that gets added to the offset displayed on /// each line. /// - /// @param[in] num_per_line + /// \param[in] num_per_line /// The number of \a type objects to display on each line. /// - /// @param[in] type + /// \param[in] type /// The type of objects to use when dumping data from this /// object. See DataExtractor::Type. /// - /// @param[in] type_format + /// \param[in] type_format /// The optional format to use for the \a type objects. If this /// is nullptr, the default format for the \a type will be used. /// - /// @return + /// \return /// The offset at which dumping ended. - //------------------------------------------------------------------ lldb::offset_t PutToLog(Log *log, lldb::offset_t offset, lldb::offset_t length, uint64_t base_addr, uint32_t num_per_line, Type type, const char *type_format = nullptr) 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. /// - /// @param[in] offset + /// \param[in] offset /// The offset in bytes into the contained data at which to /// start extracting. /// - /// @param[in] length + /// \param[in] length /// The number of bytes to extract. /// - /// @param[in] dst_byte_order + /// \param[in] dst_byte_order /// A byte order of the data that we want when the value in /// copied to \a dst. /// - /// @param[out] dst + /// \param[out] dst /// The buffer that will receive the extracted value if there /// are enough bytes available in the current data. /// - /// @return + /// \return /// The number of bytes that were extracted which will be \a /// length when the value is successfully extracted, or zero /// if there aren't enough bytes at the specified offset. - //------------------------------------------------------------------ size_t ExtractBytes(lldb::offset_t offset, lldb::offset_t length, lldb::ByteOrder dst_byte_order, void *dst) const; - //------------------------------------------------------------------ /// Extract an address from \a *offset_ptr. /// /// Extract a single address from the data and update the offset pointed to @@ -260,39 +234,33 @@ public: /// m_addr_size member variable and should be set correctly prior to /// extracting any address values. /// - /// @param[in,out] offset_ptr + /// \param[in,out] offset_ptr /// A pointer to an offset within the data that will be advanced /// by the appropriate number of bytes if the value is extracted /// correctly. If the offset is out of bounds or there are not /// enough bytes to extract this value, the offset will be left /// unmodified. /// - /// @return + /// \return /// The extracted address value. - //------------------------------------------------------------------ uint64_t GetAddress(lldb::offset_t *offset_ptr) const; uint64_t GetAddress_unchecked(lldb::offset_t *offset_ptr) const; - //------------------------------------------------------------------ /// Get the current address size. /// /// Return the size in bytes of any address values this object will extract. /// - /// @return + /// \return /// The size in bytes of address values that will be extracted. - //------------------------------------------------------------------ uint32_t GetAddressByteSize() const { return m_addr_size; } - //------------------------------------------------------------------ /// Get the number of bytes contained in this object. /// - /// @return + /// \return /// The total number of bytes of data this object refers to. - //------------------------------------------------------------------ uint64_t GetByteSize() const { return m_end - m_start; } - //------------------------------------------------------------------ /// Extract a C string from \a *offset_ptr. /// /// Returns a pointer to a C String from the data at the offset pointed to @@ -300,22 +268,20 @@ public: /// 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 + /// \param[in,out] offset_ptr /// A pointer to an offset within the data that will be advanced /// by the appropriate number of bytes if the value is extracted /// correctly. If the offset is out of bounds or there are not /// enough bytes to extract this value, the offset will be left /// unmodified. /// - /// @return + /// \return /// A pointer to the C string value in the data. If the offset /// pointed to by \a offset_ptr is out of bounds, or if the /// offset plus the length of the C string is out of bounds, /// nullptr will be returned. - //------------------------------------------------------------------ const char *GetCStr(lldb::offset_t *offset_ptr) const; - //------------------------------------------------------------------ /// 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 @@ -324,14 +290,14 @@ public: /// will be updated with the offset of the byte that follows the fixed /// length field. /// - /// @param[in,out] offset_ptr + /// \param[in,out] offset_ptr /// A pointer to an offset within the data that will be advanced /// by the appropriate number of bytes if the value is extracted /// correctly. If the offset is out of bounds or there are not /// enough bytes to extract this value, the offset will be left /// unmodified. /// - /// @return + /// \return /// A pointer to the C string value in the data. If the offset /// pointed to by \a offset_ptr is out of bounds, or if the /// offset plus the length of the field is out of bounds, or if @@ -339,7 +305,6 @@ public: /// be returned. const char *GetCStr(lldb::offset_t *offset_ptr, lldb::offset_t len) const; - //------------------------------------------------------------------ /// Extract \a length bytes from \a *offset_ptr. /// /// Returns a pointer to a bytes in this object's data at the offset pointed @@ -347,21 +312,20 @@ public: /// pointed to by \a offset_ptr will not be updated and nullptr will be /// returned. /// - /// @param[in,out] offset_ptr + /// \param[in,out] offset_ptr /// A pointer to an offset within the data that will be advanced /// by the appropriate number of bytes if the value is extracted /// correctly. If the offset is out of bounds or there are not /// enough bytes to extract this value, the offset will be left /// unmodified. /// - /// @param[in] length + /// \param[in] length /// The optional length of a string to extract. If the value is /// zero, a NULL terminated C string will be extracted. /// - /// @return + /// \return /// A pointer to the bytes in this object's data if the offset /// and length are valid, or nullptr otherwise. - //------------------------------------------------------------------ const void *GetData(lldb::offset_t *offset_ptr, lldb::offset_t length) const { const uint8_t *ptr = PeekData(*offset_ptr, length); if (ptr) @@ -369,26 +333,23 @@ public: return ptr; } - //------------------------------------------------------------------ /// Copy \a length bytes from \a *offset, without swapping bytes. /// - /// @param[in] offset + /// \param[in] offset /// The offset into this data from which to start copying /// - /// @param[in] length + /// \param[in] length /// The length of the data to copy from this object /// - /// @param[out] dst + /// \param[out] dst /// The buffer to place the output data. /// - /// @return + /// \return /// Returns the number of bytes that were copied, or zero if /// anything goes wrong. - //------------------------------------------------------------------ lldb::offset_t CopyData(lldb::offset_t offset, lldb::offset_t length, void *dst) const; - //------------------------------------------------------------------ /// Copy \a dst_len bytes from \a *offset_ptr and ensure the copied data is /// treated as a value that can be swapped to match the specified byte /// order. @@ -400,88 +361,78 @@ public: /// 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 + /// \param[in] src_offset /// The offset into this data from which to start copying an /// endian entity /// - /// @param[in] src_len + /// \param[in] src_len /// The length of the endian data to copy from this object /// into the \a dst object /// - /// @param[out] dst + /// \param[out] dst /// The buffer where to place the endian data. The data might /// need to be byte swapped (and appropriately padded with /// zeroes if \a src_len != \a dst_len) if \a dst_byte_order /// does not match the byte order in this object. /// - /// @param[in] dst_len + /// \param[in] dst_len /// The length number of bytes that the endian value will /// occupy is \a dst. /// - /// @param[in] byte_order + /// \param[in] byte_order /// The byte order that the endian value should be in the \a dst /// buffer. /// - /// @return + /// \return /// Returns the number of bytes that were copied, or zero if /// anything goes wrong. - //------------------------------------------------------------------ lldb::offset_t CopyByteOrderedData(lldb::offset_t src_offset, lldb::offset_t src_len, void *dst, lldb::offset_t dst_len, lldb::ByteOrder dst_byte_order) const; - //------------------------------------------------------------------ /// Get the data end pointer. /// - /// @return + /// \return /// Returns a pointer to the next byte contained in this /// object's data, or nullptr of there is no data in this object. - //------------------------------------------------------------------ const uint8_t *GetDataEnd() const { return m_end; } - //------------------------------------------------------------------ /// Get the shared data offset. /// /// Get the offset of the first byte of data in the shared data (if any). /// - /// @return + /// \return /// If this object contains shared data, this function returns /// the offset in bytes into that shared data, zero otherwise. - //------------------------------------------------------------------ size_t GetSharedDataOffset() const; - //------------------------------------------------------------------ /// Get the data start pointer. /// - /// @return + /// \return /// Returns a pointer to the first byte contained in this /// object's data, or nullptr of there is no data in this object. - //------------------------------------------------------------------ const uint8_t *GetDataStart() const { return m_start; } - //------------------------------------------------------------------ /// Extract a float from \a *offset_ptr. /// /// Extract a single float value. /// - /// @param[in,out] offset_ptr + /// \param[in,out] offset_ptr /// A pointer to an offset within the data that will be advanced /// by the appropriate number of bytes if the value is extracted /// correctly. If the offset is out of bounds or there are not /// enough bytes to extract this value, the offset will be left /// unmodified. /// - /// @return + /// \return /// The floating value that was extracted, or zero on failure. - //------------------------------------------------------------------ float GetFloat(lldb::offset_t *offset_ptr) const; double GetDouble(lldb::offset_t *offset_ptr) const; long double GetLongDouble(lldb::offset_t *offset_ptr) const; - //------------------------------------------------------------------ /// 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 @@ -489,22 +440,20 @@ public: /// 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 + /// \param[in,out] offset_ptr /// A pointer to an offset within the data that will be advanced /// by the appropriate number of bytes if the value is extracted /// correctly. If the offset is out of bounds or there are not /// enough bytes to extract this value, the offset will be left /// unmodified. /// - /// @param[in] byte_size + /// \param[in] byte_size /// The size in byte of the integer to extract. /// - /// @return + /// \return /// The integer value that was extracted, or zero on failure. - //------------------------------------------------------------------ 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 a single unsigned integer value and update the offset pointed to @@ -513,26 +462,24 @@ public: /// equal to one and less than or equal to eight since the return value is /// 64 bits wide. /// - /// @param[in,out] offset_ptr + /// \param[in,out] offset_ptr /// A pointer to an offset within the data that will be advanced /// by the appropriate number of bytes if the value is extracted /// correctly. If the offset is out of bounds or there are not /// enough bytes to extract this value, the offset will be left /// unmodified. /// - /// @param[in] byte_size + /// \param[in] byte_size /// The size in byte of the integer to extract. /// - /// @return + /// \return /// The unsigned integer value that was extracted, or zero on /// failure. - //------------------------------------------------------------------ uint64_t GetMaxU64(lldb::offset_t *offset_ptr, size_t byte_size) const; uint64_t GetMaxU64_unchecked(lldb::offset_t *offset_ptr, size_t byte_size) const; - //------------------------------------------------------------------ /// Extract an signed integer of size \a byte_size from \a *offset_ptr. /// /// Extract a single signed integer value (sign extending if required) and @@ -541,23 +488,21 @@ public: /// 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 + /// \param[in,out] offset_ptr /// A pointer to an offset within the data that will be advanced /// by the appropriate number of bytes if the value is extracted /// correctly. If the offset is out of bounds or there are not /// enough bytes to extract this value, the offset will be left /// unmodified. /// - /// @param[in] byte_size + /// \param[in] byte_size /// The size in byte of the integer to extract. /// - /// @return + /// \return /// The sign extended signed integer value that was extracted, /// or zero on failure. - //------------------------------------------------------------------ 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. @@ -568,36 +513,34 @@ public: /// equal to one and less than or equal to 8 since the return value is 64 /// bits wide. /// - /// @param[in,out] offset_ptr + /// \param[in,out] offset_ptr /// A pointer to an offset within the data that will be advanced /// by the appropriate number of bytes if the value is extracted /// correctly. If the offset is out of bounds or there are not /// enough bytes to extract this value, the offset will be left /// unmodified. /// - /// @param[in] byte_size + /// \param[in] byte_size /// The size in byte of the integer to extract. /// - /// @param[in] bitfield_bit_size + /// \param[in] bitfield_bit_size /// The size in bits of the bitfield value to extract, or zero /// to just extract the entire integer value. /// - /// @param[in] bitfield_bit_offset + /// \param[in] bitfield_bit_offset /// The bit offset of the bitfield value in the extracted /// integer. For little-endian data, this is the offset of /// the LSB of the bitfield from the LSB of the integer. /// For big-endian data, this is the offset of the MSB of the /// bitfield from the MSB of the integer. /// - /// @return + /// \return /// The unsigned bitfield integer value that was extracted, or /// zero on failure. - //------------------------------------------------------------------ uint64_t GetMaxU64Bitfield(lldb::offset_t *offset_ptr, size_t size, uint32_t bitfield_bit_size, 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. @@ -608,36 +551,34 @@ public: /// 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 + /// \param[in,out] offset_ptr /// A pointer to an offset within the data that will be advanced /// by the appropriate number of bytes if the value is extracted /// correctly. If the offset is out of bounds or there are not /// enough bytes to extract this value, the offset will be left /// unmodified. /// - /// @param[in] byte_size + /// \param[in] byte_size /// The size in bytes of the integer to extract. /// - /// @param[in] bitfield_bit_size + /// \param[in] bitfield_bit_size /// The size in bits of the bitfield value to extract, or zero /// to just extract the entire integer value. /// - /// @param[in] bitfield_bit_offset + /// \param[in] bitfield_bit_offset /// The bit offset of the bitfield value in the extracted /// integer. For little-endian data, this is the offset of /// the LSB of the bitfield from the LSB of the integer. /// For big-endian data, this is the offset of the MSB of the /// bitfield from the MSB of the integer. /// - /// @return + /// \return /// The signed bitfield integer value that was extracted, or /// zero on failure. - //------------------------------------------------------------------ int64_t GetMaxS64Bitfield(lldb::offset_t *offset_ptr, size_t size, uint32_t bitfield_bit_size, uint32_t bitfield_bit_offset) const; - //------------------------------------------------------------------ /// Extract an pointer from \a *offset_ptr. /// /// Extract a single pointer from the data and update the offset pointed to @@ -645,43 +586,38 @@ public: /// m_addr_size member variable and should be set correctly prior to /// extracting any pointer values. /// - /// @param[in,out] offset_ptr + /// \param[in,out] offset_ptr /// A pointer to an offset within the data that will be advanced /// by the appropriate number of bytes if the value is extracted /// correctly. If the offset is out of bounds or there are not /// enough bytes to extract this value, the offset will be left /// unmodified. /// - /// @return + /// \return /// The extracted pointer value as a 64 integer. - //------------------------------------------------------------------ uint64_t GetPointer(lldb::offset_t *offset_ptr) const; - //------------------------------------------------------------------ /// Get the current byte order value. /// - /// @return + /// \return /// The current byte order value from this object's internal /// state. - //------------------------------------------------------------------ lldb::ByteOrder GetByteOrder() const { return m_byte_order; } - //------------------------------------------------------------------ /// 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. /// - /// @param[in,out] offset_ptr + /// \param[in,out] offset_ptr /// A pointer to an offset within the data that will be advanced /// by the appropriate number of bytes if the value is extracted /// correctly. If the offset is out of bounds or there are not /// enough bytes to extract this value, the offset will be left /// unmodified. /// - /// @return + /// \return /// The extracted uint8_t value. - //------------------------------------------------------------------ uint8_t GetU8(lldb::offset_t *offset_ptr) const; uint8_t GetU8_unchecked(lldb::offset_t *offset_ptr) const { @@ -695,169 +631,154 @@ public: uint32_t GetU32_unchecked(lldb::offset_t *offset_ptr) const; uint64_t GetU64_unchecked(lldb::offset_t *offset_ptr) const; - //------------------------------------------------------------------ /// 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. /// - /// @param[in,out] offset_ptr + /// \param[in,out] offset_ptr /// A pointer to an offset within the data that will be advanced /// by the appropriate number of bytes if the value is extracted /// correctly. If the offset is out of bounds or there are not /// enough bytes to extract this value, the offset will be left /// unmodified. /// - /// @param[out] dst + /// \param[out] dst /// A buffer to copy \a count uint8_t values into. \a dst must /// be large enough to hold all requested data. /// - /// @param[in] count + /// \param[in] count /// The number of uint8_t values to extract. /// - /// @return + /// \return /// \a dst if all values were properly extracted and copied, /// nullptr otherwise. - //------------------------------------------------------------------ void *GetU8(lldb::offset_t *offset_ptr, void *dst, uint32_t count) const; - //------------------------------------------------------------------ /// 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. /// - /// @param[in,out] offset_ptr + /// \param[in,out] offset_ptr /// A pointer to an offset within the data that will be advanced /// by the appropriate number of bytes if the value is extracted /// correctly. If the offset is out of bounds or there are not /// enough bytes to extract this value, the offset will be left /// unmodified. /// - /// @return + /// \return /// The extracted uint16_t value. - //------------------------------------------------------------------ uint16_t GetU16(lldb::offset_t *offset_ptr) const; - //------------------------------------------------------------------ /// 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. /// - /// @param[in,out] offset_ptr + /// \param[in,out] offset_ptr /// A pointer to an offset within the data that will be advanced /// by the appropriate number of bytes if the value is extracted /// correctly. If the offset is out of bounds or there are not /// enough bytes to extract this value, the offset will be left /// unmodified. /// - /// @param[out] dst + /// \param[out] dst /// A buffer to copy \a count uint16_t values into. \a dst must /// be large enough to hold all requested data. /// - /// @param[in] count + /// \param[in] count /// The number of uint16_t values to extract. /// - /// @return + /// \return /// \a dst if all values were properly extracted and copied, /// nullptr otherwise. - //------------------------------------------------------------------ void *GetU16(lldb::offset_t *offset_ptr, void *dst, uint32_t count) const; - //------------------------------------------------------------------ /// 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. /// - /// @param[in,out] offset_ptr + /// \param[in,out] offset_ptr /// A pointer to an offset within the data that will be advanced /// by the appropriate number of bytes if the value is extracted /// correctly. If the offset is out of bounds or there are not /// enough bytes to extract this value, the offset will be left /// unmodified. /// - /// @return + /// \return /// The extracted uint32_t value. - //------------------------------------------------------------------ uint32_t GetU32(lldb::offset_t *offset_ptr) const; - //------------------------------------------------------------------ /// 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. /// - /// @param[in,out] offset_ptr + /// \param[in,out] offset_ptr /// A pointer to an offset within the data that will be advanced /// by the appropriate number of bytes if the value is extracted /// correctly. If the offset is out of bounds or there are not /// enough bytes to extract this value, the offset will be left /// unmodified. /// - /// @param[out] dst + /// \param[out] dst /// A buffer to copy \a count uint32_t values into. \a dst must /// be large enough to hold all requested data. /// - /// @param[in] count + /// \param[in] count /// The number of uint32_t values to extract. /// - /// @return + /// \return /// \a dst if all values were properly extracted and copied, /// nullptr otherwise. - //------------------------------------------------------------------ void *GetU32(lldb::offset_t *offset_ptr, void *dst, uint32_t count) const; - //------------------------------------------------------------------ /// 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. /// - /// @param[in,out] offset_ptr + /// \param[in,out] offset_ptr /// A pointer to an offset within the data that will be advanced /// by the appropriate number of bytes if the value is extracted /// correctly. If the offset is out of bounds or there are not /// enough bytes to extract this value, the offset will be left /// unmodified. /// - /// @return + /// \return /// The extracted uint64_t value. - //------------------------------------------------------------------ uint64_t GetU64(lldb::offset_t *offset_ptr) const; - //------------------------------------------------------------------ /// 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. /// - /// @param[in,out] offset_ptr + /// \param[in,out] offset_ptr /// A pointer to an offset within the data that will be advanced /// by the appropriate number of bytes if the value is extracted /// correctly. If the offset is out of bounds or there are not /// enough bytes to extract this value, the offset will be left /// unmodified. /// - /// @param[out] dst + /// \param[out] dst /// A buffer to copy \a count uint64_t values into. \a dst must /// be large enough to hold all requested data. /// - /// @param[in] count + /// \param[in] count /// The number of uint64_t values to extract. /// - /// @return + /// \return /// \a dst if all values were properly extracted and copied, /// nullptr otherwise. - //------------------------------------------------------------------ void *GetU64(lldb::offset_t *offset_ptr, void *dst, uint32_t count) const; - //------------------------------------------------------------------ /// Extract a signed LEB128 value from \a *offset_ptr. /// /// Extracts an signed LEB128 number from this object's data starting at the @@ -865,19 +786,17 @@ public: /// offset_ptr will be updated with the offset of the byte following the /// last extracted byte. /// - /// @param[in,out] offset_ptr + /// \param[in,out] offset_ptr /// A pointer to an offset within the data that will be advanced /// by the appropriate number of bytes if the value is extracted /// correctly. If the offset is out of bounds or there are not /// enough bytes to extract this value, the offset will be left /// unmodified. /// - /// @return + /// \return /// The extracted signed integer value. - //------------------------------------------------------------------ int64_t GetSLEB128(lldb::offset_t *offset_ptr) const; - //------------------------------------------------------------------ /// Extract a unsigned LEB128 value from \a *offset_ptr. /// /// Extracts an unsigned LEB128 number from this object's data starting at @@ -885,62 +804,55 @@ public: /// offset_ptr will be updated with the offset of the byte following the /// last extracted byte. /// - /// @param[in,out] offset_ptr + /// \param[in,out] offset_ptr /// A pointer to an offset within the data that will be advanced /// by the appropriate number of bytes if the value is extracted /// correctly. If the offset is out of bounds or there are not /// enough bytes to extract this value, the offset will be left /// unmodified. /// - /// @return + /// \return /// The extracted unsigned integer value. - //------------------------------------------------------------------ uint64_t GetULEB128(lldb::offset_t *offset_ptr) const; lldb::DataBufferSP &GetSharedDataBuffer() { return m_data_sp; } - //------------------------------------------------------------------ /// 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. /// - /// @param[in] offset + /// \param[in] offset /// An offset into the data. /// - /// @return + /// \return /// A non-nullptr C string pointer if \a offset is a valid offset, /// nullptr otherwise. - //------------------------------------------------------------------ const char *PeekCStr(lldb::offset_t offset) const; - //------------------------------------------------------------------ /// 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. /// - /// @return + /// \return /// A non-nullptr data pointer if \a offset is a valid offset and /// there are \a length bytes available at that offset, nullptr /// otherwise. - //------------------------------------------------------------------ const uint8_t *PeekData(lldb::offset_t offset, lldb::offset_t length) const { if (ValidOffsetForDataOfSize(offset, length)) return m_start + offset; return nullptr; } - //------------------------------------------------------------------ /// 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. /// - /// @param[in] addr_size + /// \param[in] addr_size /// The size in bytes to use when extracting addresses. - //------------------------------------------------------------------ void SetAddressByteSize(uint32_t addr_size) { #ifdef LLDB_CONFIGURATION_DEBUG assert(addr_size == 4 || addr_size == 8); @@ -948,7 +860,6 @@ public: m_addr_size = addr_size; } - //------------------------------------------------------------------ /// Set data with a buffer that is caller owned. /// /// Use data that is owned by the caller when extracting values. The data @@ -956,22 +867,20 @@ public: /// 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 + /// \param[in] bytes /// A pointer to caller owned data. /// - /// @param[in] length + /// \param[in] length /// The length in bytes of \a bytes. /// - /// @param[in] byte_order + /// \param[in] byte_order /// A byte order of the data that we are extracting from. /// - /// @return + /// \return /// The number of bytes that this object now contains. - //------------------------------------------------------------------ lldb::offset_t SetData(const void *bytes, lldb::offset_t length, lldb::ByteOrder byte_order); - //------------------------------------------------------------------ /// Adopt a subset of \a data. /// /// Set this object's data to be a subset of the data bytes in \a data. If @@ -983,22 +892,20 @@ public: /// 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 + /// \param[in] data /// Another DataExtractor object that contains data. /// - /// @param[in] offset + /// \param[in] offset /// The offset into \a data at which the subset starts. /// - /// @param[in] length + /// \param[in] length /// The length in bytes of the subset of \a data. /// - /// @return + /// \return /// The number of bytes that this object now contains. - //------------------------------------------------------------------ lldb::offset_t SetData(const DataExtractor &data, lldb::offset_t offset, lldb::offset_t length); - //------------------------------------------------------------------ /// Adopt a subset of shared data in \a data_sp. /// /// Copies the data shared pointer which adds a reference to the contained @@ -1010,34 +917,30 @@ public: /// 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 + /// \param[in] data_sp /// A shared pointer to data. /// - /// @param[in] offset + /// \param[in] offset /// The offset into \a data_sp at which the subset starts. /// - /// @param[in] length + /// \param[in] length /// The length in bytes of the subset of \a data_sp. /// - /// @return + /// \return /// The number of bytes that this object now contains. - //------------------------------------------------------------------ lldb::offset_t SetData(const lldb::DataBufferSP &data_sp, lldb::offset_t offset = 0, lldb::offset_t length = LLDB_INVALID_OFFSET); - //------------------------------------------------------------------ /// Set the byte_order value. /// /// Sets the byte order of the data to extract. Extracted values will be /// swapped if necessary when decoding. /// - /// @param[in] byte_order + /// \param[in] byte_order /// The byte order value to use when extracting data. - //------------------------------------------------------------------ void SetByteOrder(lldb::ByteOrder byte_order) { m_byte_order = byte_order; } - //------------------------------------------------------------------ /// Skip an LEB128 number at \a *offset_ptr. /// /// Skips a LEB128 number (signed or unsigned) from this object's data @@ -1045,36 +948,31 @@ public: /// to by \a offset_ptr will be updated with the offset of the byte /// following the last extracted byte. /// - /// @param[in,out] offset_ptr + /// \param[in,out] offset_ptr /// A pointer to an offset within the data that will be advanced /// by the appropriate number of bytes if the value is extracted /// correctly. If the offset is out of bounds or there are not /// enough bytes to extract this value, the offset will be left /// unmodified. /// - /// @return + /// \return // The number of bytes consumed during the extraction. - //------------------------------------------------------------------ uint32_t Skip_LEB128(lldb::offset_t *offset_ptr) const; - //------------------------------------------------------------------ /// Test the validity of \a offset. /// - /// @return + /// \return /// \b true if \a offset is a valid offset into the data in this /// object, \b false otherwise. - //------------------------------------------------------------------ bool ValidOffset(lldb::offset_t offset) const { return offset < GetByteSize(); } - //------------------------------------------------------------------ /// Test the availability of \a length bytes of data from \a offset. /// - /// @return + /// \return /// \b true if \a offset is a valid offset and there are \a /// length bytes available at that offset, \b false otherwise. - //------------------------------------------------------------------ bool ValidOffsetForDataOfSize(lldb::offset_t offset, lldb::offset_t length) const { return length <= BytesLeft(offset); @@ -1100,9 +998,7 @@ public: } protected: - //------------------------------------------------------------------ // Member variables - //------------------------------------------------------------------ const uint8_t *m_start; ///< A pointer to the first byte of data. const uint8_t *m_end; ///< A pointer to the byte that is past the end of the data. diff --git a/include/lldb/Utility/Endian.h b/include/lldb/Utility/Endian.h index 2a102b63aa106..cead5f8603d22 100644 --- a/include/lldb/Utility/Endian.h +++ b/include/lldb/Utility/Endian.h @@ -1,9 +1,8 @@ //===-- Endian.h ------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -24,7 +23,7 @@ static union EndianTest { } const endianTest = {0x01020304}; inline lldb::ByteOrder InlHostByteOrder() { - return (lldb::ByteOrder)endianTest.bytes[0]; + return static_cast<lldb::ByteOrder>(endianTest.bytes[0]); } // ByteOrder const InlHostByteOrder = (ByteOrder)endianTest.bytes[0]; diff --git a/include/lldb/Utility/Environment.h b/include/lldb/Utility/Environment.h index ed0a36d7b3aa5..398b3bae31066 100644 --- a/include/lldb/Utility/Environment.h +++ b/include/lldb/Utility/Environment.h @@ -1,9 +1,8 @@ //===-- Environment.h -------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// diff --git a/include/lldb/Utility/Event.h b/include/lldb/Utility/Event.h index d65043f564fb4..dd5d08024cef1 100644 --- a/include/lldb/Utility/Event.h +++ b/include/lldb/Utility/Event.h @@ -1,9 +1,8 @@ //===-- Event.h -------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -28,16 +27,12 @@ namespace lldb_private { class Event; -} -namespace lldb_private { class Stream; } namespace lldb_private { -//---------------------------------------------------------------------- // lldb::EventData -//---------------------------------------------------------------------- class EventData { friend class Event; @@ -46,7 +41,7 @@ public: virtual ~EventData(); - virtual const ConstString &GetFlavor() const = 0; + virtual ConstString GetFlavor() const = 0; virtual void Dump(Stream *s) const; @@ -56,14 +51,10 @@ private: DISALLOW_COPY_AND_ASSIGN(EventData); }; -//---------------------------------------------------------------------- // lldb::EventDataBytes -//---------------------------------------------------------------------- class EventDataBytes : public EventData { public: - //------------------------------------------------------------------ // Constructors - //------------------------------------------------------------------ EventDataBytes(); EventDataBytes(const char *cstr); @@ -74,10 +65,8 @@ public: ~EventDataBytes() override; - //------------------------------------------------------------------ // Member functions - //------------------------------------------------------------------ - const ConstString &GetFlavor() const override; + ConstString GetFlavor() const override; void Dump(Stream *s) const override; @@ -91,16 +80,14 @@ public: void SetBytesFromCString(const char *cstr); - //------------------------------------------------------------------ // Static functions - //------------------------------------------------------------------ static const EventDataBytes *GetEventDataFromEvent(const Event *event_ptr); static const void *GetBytesFromEvent(const Event *event_ptr); static size_t GetByteSizeFromEvent(const Event *event_ptr); - static const ConstString &GetFlavorString(); + static ConstString GetFlavorString(); private: std::string m_bytes; @@ -114,12 +101,12 @@ public: ~EventDataReceipt() override {} - static const ConstString &GetFlavorString() { + static ConstString GetFlavorString() { static ConstString g_flavor("Process::ProcessEventData"); return g_flavor; } - const ConstString &GetFlavor() const override { return GetFlavorString(); } + ConstString GetFlavor() const override { return GetFlavorString(); } bool WaitForEventReceived(const Timeout<std::micro> &timeout = llvm::None) { return m_predicate.WaitForValueEqualTo(true, timeout); @@ -133,16 +120,12 @@ private: } }; -//---------------------------------------------------------------------- /// This class handles one or more StructuredData::Dictionary entries /// that are raised for structured data events. -//---------------------------------------------------------------------- class EventDataStructuredData : public EventData { public: - //------------------------------------------------------------------ // Constructors - //------------------------------------------------------------------ EventDataStructuredData(); EventDataStructuredData(const lldb::ProcessSP &process_sp, @@ -151,10 +134,8 @@ public: ~EventDataStructuredData() override; - //------------------------------------------------------------------ // Member functions - //------------------------------------------------------------------ - const ConstString &GetFlavor() const override; + ConstString GetFlavor() const override; void Dump(Stream *s) const override; @@ -170,9 +151,7 @@ public: void SetStructuredDataPlugin(const lldb::StructuredDataPluginSP &plugin_sp); - //------------------------------------------------------------------ // Static functions - //------------------------------------------------------------------ static const EventDataStructuredData * GetEventDataFromEvent(const Event *event_ptr); @@ -183,7 +162,7 @@ public: static lldb::StructuredDataPluginSP GetPluginFromEvent(const Event *event_ptr); - static const ConstString &GetFlavorString(); + static ConstString GetFlavorString(); private: lldb::ProcessSP m_process_sp; @@ -193,9 +172,7 @@ private: DISALLOW_COPY_AND_ASSIGN(EventDataStructuredData); }; -//---------------------------------------------------------------------- // lldb::Event -//---------------------------------------------------------------------- class Event { friend class Listener; friend class EventData; @@ -266,7 +243,7 @@ private: lldb::EventDataSP m_data_sp; // User specific data for this event DISALLOW_COPY_AND_ASSIGN(Event); - Event(); // Disallow default constructor + Event() = delete; }; } // namespace lldb_private diff --git a/include/lldb/Utility/FileCollector.h b/include/lldb/Utility/FileCollector.h new file mode 100644 index 0000000000000..a89206747fe19 --- /dev/null +++ b/include/lldb/Utility/FileCollector.h @@ -0,0 +1,77 @@ +//===-- FileCollector.h -----------------------------------------*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef LLDB_UTILITY_FILE_COLLECTOR_H +#define LLDB_UTILITY_FILE_COLLECTOR_H + +#include "lldb/Utility/FileSpec.h" + +#include "llvm/ADT/SmallVector.h" +#include "llvm/ADT/StringMap.h" +#include "llvm/ADT/StringSet.h" +#include "llvm/ADT/Twine.h" +#include "llvm/Support/VirtualFileSystem.h" + +#include <mutex> + +namespace lldb_private { + +/// Collects files into a directory and generates a mapping that can be used by +/// the VFS. +class FileCollector { +public: + FileCollector(const FileSpec &root, const FileSpec &overlay); + + void AddFile(const llvm::Twine &file); + void AddFile(const FileSpec &file) { return AddFile(file.GetPath()); } + + /// Write the yaml mapping (for the VFS) to the given file. + std::error_code WriteMapping(const FileSpec &mapping_file); + + /// Copy the files into the root directory. + /// + /// When stop_on_error is true (the default) we abort as soon as one file + /// cannot be copied. This is relatively common, for example when a file was + /// removed after it was added to the mapping. + std::error_code CopyFiles(bool stop_on_error = true); + +protected: + void AddFileImpl(llvm::StringRef src_path); + + bool MarkAsSeen(llvm::StringRef path) { return m_seen.insert(path).second; } + + bool GetRealPath(llvm::StringRef src_path, + llvm::SmallVectorImpl<char> &result); + + void AddFileToMapping(llvm::StringRef virtual_path, + llvm::StringRef real_path) { + m_vfs_writer.addFileMapping(virtual_path, real_path); + } + + /// Synchronizes adding files. + std::mutex m_mutex; + + /// The root directory where files are copied. + FileSpec m_root; + + /// The root directory where the VFS overlay lives. + FileSpec m_overlay_root; + + /// Tracks already seen files so they can be skipped. + llvm::StringSet<> m_seen; + + /// The yaml mapping writer. + llvm::vfs::YAMLVFSWriter m_vfs_writer; + + /// Caches real_path calls when resolving symlinks. + llvm::StringMap<std::string> m_symlink_map; +}; + +} // namespace lldb_private + +#endif // LLDB_UTILITY_FILE_COLLECTOR_H diff --git a/include/lldb/Utility/FileSpec.h b/include/lldb/Utility/FileSpec.h index 0699ab7b5c900..f0bc5c89fec77 100644 --- a/include/lldb/Utility/FileSpec.h +++ b/include/lldb/Utility/FileSpec.h @@ -1,9 +1,8 @@ //===-- FileSpec.h ----------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -38,8 +37,7 @@ template <typename T> class SmallVectorImpl; namespace lldb_private { -//---------------------------------------------------------------------- -/// @class FileSpec FileSpec.h "lldb/Host/FileSpec.h" +/// \class FileSpec FileSpec.h "lldb/Host/FileSpec.h" /// A file utility class. /// /// A file specification class that divides paths up into a directory @@ -54,165 +52,133 @@ namespace lldb_private { /// 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: 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 /// FileSpec::SetFile (const char *path). /// - /// @param[in] path + /// \param[in] path /// The full or partial path to a file. /// - /// @param[in] style + /// \param[in] style /// The style of the path /// - /// @see FileSpec::SetFile (const char *path) - //------------------------------------------------------------------ + /// \see FileSpec::SetFile (const char *path) explicit FileSpec(llvm::StringRef path, Style style = Style::native); explicit FileSpec(llvm::StringRef path, const llvm::Triple &Triple); - //------------------------------------------------------------------ - /// Copy constructor - /// - /// Makes a copy of the uniqued directory and filename strings from \a rhs. - /// - /// @param[in] rhs - /// A const FileSpec object reference to copy. - //------------------------------------------------------------------ - FileSpec(const FileSpec &rhs); - - //------------------------------------------------------------------ /// Copy constructor /// /// Makes a copy of the uniqued directory and filename strings from \a rhs /// if it is not nullptr. /// - /// @param[in] rhs + /// \param[in] rhs /// A const FileSpec object pointer to copy if non-nullptr. - //------------------------------------------------------------------ FileSpec(const FileSpec *rhs); - //------------------------------------------------------------------ /// Destructor. - //------------------------------------------------------------------ ~FileSpec(); bool DirectoryEquals(const FileSpec &other) const; bool FileEquals(const FileSpec &other) const; - //------------------------------------------------------------------ /// Assignment operator. /// /// Makes a copy of the uniqued directory and filename strings from \a rhs. /// - /// @param[in] rhs + /// \param[in] rhs /// A const FileSpec object reference to assign to this object. /// - /// @return + /// \return /// A const reference to this object. - //------------------------------------------------------------------ const FileSpec &operator=(const FileSpec &rhs); - //------------------------------------------------------------------ /// Equal to operator /// /// Tests if this object is equal to \a rhs. /// - /// @param[in] rhs + /// \param[in] rhs /// A const FileSpec object reference to compare this object /// to. /// - /// @return + /// \return /// \b true if this object is equal to \a rhs, \b false /// otherwise. - //------------------------------------------------------------------ bool operator==(const FileSpec &rhs) const; - //------------------------------------------------------------------ /// Not equal to operator /// /// Tests if this object is not equal to \a rhs. /// - /// @param[in] rhs + /// \param[in] rhs /// A const FileSpec object reference to compare this object /// to. /// - /// @return + /// \return /// \b true if this object is equal to \a rhs, \b false /// otherwise. - //------------------------------------------------------------------ bool operator!=(const FileSpec &rhs) const; - //------------------------------------------------------------------ /// Less than to operator /// /// Tests if this object is less than \a rhs. /// - /// @param[in] rhs + /// \param[in] rhs /// A const FileSpec object reference to compare this object /// to. /// - /// @return + /// \return /// \b true if this object is less than \a rhs, \b false /// otherwise. - //------------------------------------------------------------------ bool operator<(const FileSpec &rhs) const; - //------------------------------------------------------------------ /// Convert to pointer operator. /// /// This allows code to check a FileSpec object to see if it contains /// anything valid using code such as: /// - /// @code + /// \code /// FileSpec file_spec(...); /// if (file_spec) /// { ... - /// @endcode + /// \endcode /// - /// @return + /// \return /// A pointer to this object if either the directory or filename /// is valid, nullptr otherwise. - //------------------------------------------------------------------ explicit operator bool() const; - //------------------------------------------------------------------ /// Logical NOT operator. /// /// This allows code to check a FileSpec object to see if it is invalid /// using code such as: /// - /// @code + /// \code /// FileSpec file_spec(...); /// if (!file_spec) /// { ... - /// @endcode + /// \endcode /// - /// @return + /// \return /// Returns \b true if the object has an empty directory and /// filename, \b false otherwise. - //------------------------------------------------------------------ bool operator!() const; - //------------------------------------------------------------------ /// Clears the object state. /// /// 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. @@ -221,163 +187,148 @@ public: /// to only contain a filename and it can match FileSpec objects that have /// matching filenames with different paths. /// - /// @param[in] lhs + /// \param[in] lhs /// A const reference to the Left Hand Side object to compare. /// - /// @param[in] rhs + /// \param[in] rhs /// A const reference to the Right Hand Side object to compare. /// - /// @param[in] full + /// \param[in] full /// If true, then both the directory and filenames will have to /// match for a compare to return zero (equal to). If false /// and either directory from \a lhs or \a rhs is empty, then /// only the filename will be compared, else a full comparison /// is done. /// - /// @return - /// @li -1 if \a lhs is less than \a rhs - /// @li 0 if \a lhs is equal to \a rhs - /// @li 1 if \a lhs is greater than \a rhs - //------------------------------------------------------------------ + /// \return + /// \li -1 if \a lhs is less than \a rhs + /// \li 0 if \a lhs is equal to \a rhs + /// \li 1 if \a lhs is greater than \a rhs static int Compare(const FileSpec &lhs, const FileSpec &rhs, bool full); static bool Equal(const FileSpec &a, const FileSpec &b, bool full); - //------------------------------------------------------------------ + /// Attempt to guess path style for a given path string. It returns a style, + /// if it was able to make a reasonable guess, or None if it wasn't. The guess + /// will be correct if the input path was a valid absolute path on the system + /// which produced it. On other paths the result of this function is + /// unreliable (e.g. "c:\foo.txt" is a valid relative posix path). + static llvm::Optional<Style> GuessPathStyle(llvm::StringRef absolute_path); + /// Case sensitivity of path. /// - /// @return + /// \return /// \b true if the file path is case sensitive (POSIX), false /// if case insensitive (Windows). - //------------------------------------------------------------------ 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. /// - /// @param[in] s + /// \param[in] s /// The stream to which to dump the object description. - //------------------------------------------------------------------ void Dump(Stream *s) const; Style GetPathStyle() const; - //------------------------------------------------------------------ /// Directory string get accessor. /// - /// @return + /// \return /// A reference to the directory string object. - //------------------------------------------------------------------ ConstString &GetDirectory(); - //------------------------------------------------------------------ /// Directory string const get accessor. /// - /// @return + /// \return /// A const reference to the directory string object. - //------------------------------------------------------------------ - const ConstString &GetDirectory() const; + ConstString GetDirectory() const; - //------------------------------------------------------------------ /// Filename string get accessor. /// - /// @return + /// \return /// A reference to the filename string object. - //------------------------------------------------------------------ ConstString &GetFilename(); - //------------------------------------------------------------------ /// Filename string const get accessor. /// - /// @return + /// \return /// A const reference to the filename string object. - //------------------------------------------------------------------ - const ConstString &GetFilename() const; + ConstString GetFilename() const; - //------------------------------------------------------------------ /// Returns true if the filespec represents an implementation source file /// (files with a ".c", ".cpp", ".m", ".mm" (many more) extension). /// - /// @return + /// \return /// \b true if the filespec represents an implementation source /// file, \b false otherwise. - //------------------------------------------------------------------ bool IsSourceImplementationFile() const; - //------------------------------------------------------------------ /// Returns true if the filespec represents a relative path. /// - /// @return + /// \return /// \b true if the filespec represents a relative path, /// \b false otherwise. - //------------------------------------------------------------------ bool IsRelative() const; - //------------------------------------------------------------------ /// Returns true if the filespec represents an absolute path. /// - /// @return + /// \return /// \b true if the filespec represents an absolute path, /// \b false otherwise. - //------------------------------------------------------------------ bool IsAbsolute() const; + /// Make the FileSpec absolute by treating it relative to \a dir. Absolute + /// FileSpecs are never changed by this function. + void MakeAbsolute(const FileSpec &dir); + /// Temporary helper for FileSystem change. void SetPath(llvm::StringRef p) { SetFile(p); } - //------------------------------------------------------------------ /// 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. /// - /// @param[out] path + /// \param[out] path /// The buffer in which to place the extracted full path. /// - /// @param[in] max_path_length + /// \param[in] max_path_length /// The maximum length of \a path. /// - /// @return + /// \return /// Returns the number of characters that would be needed to /// properly copy the full path into \a path. If the returned /// number is less than \a max_path_length, then the path is /// properly copied and terminated. If the return value is /// >= \a max_path_length, then the path was truncated (but is /// still NULL terminated). - //------------------------------------------------------------------ size_t GetPath(char *path, size_t max_path_length, bool denormalize = true) const; - //------------------------------------------------------------------ /// Extract the full path to the file. /// /// Extract the directory and path into a std::string, which is returned. /// - /// @return + /// \return /// Returns a std::string with the directory and filename /// concatenated. - //------------------------------------------------------------------ std::string GetPath(bool denormalize = true) const; const char *GetCString(bool denormalize = true) const; - //------------------------------------------------------------------ /// Extract the full path to the file. /// /// Extract the directory and path into an llvm::SmallVectorImpl<> /// - /// @return + /// \return /// Returns a std::string with the directory and filename /// concatenated. - //------------------------------------------------------------------ void GetPath(llvm::SmallVectorImpl<char> &path, bool denormalize = true) const; - //------------------------------------------------------------------ /// Extract the extension of the file. /// /// Returns a ConstString that represents the extension of the filename for @@ -385,59 +336,51 @@ public: /// filename has no extension, ConstString(nullptr) is returned. The dot /// ('.') character is not returned as part of the extension /// - /// @return + /// \return /// Returns the extension of the file as a ConstString object. - //------------------------------------------------------------------ ConstString GetFileNameExtension() const; - //------------------------------------------------------------------ /// 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) /// - /// @return + /// \return /// Returns the filename without extension /// as a ConstString object. - //------------------------------------------------------------------ ConstString GetFileNameStrippingExtension() const; - //------------------------------------------------------------------ /// 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 + /// \return /// The number of bytes that this object occupies in memory. /// - /// @see ConstString::StaticMemorySize () - //------------------------------------------------------------------ + /// \see ConstString::StaticMemorySize () size_t MemorySize() 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. /// - /// @param[in] path + /// \param[in] path /// A full, partial, or relative path to a file. /// - /// @param[in] resolve_path + /// \param[in] resolve_path /// If \b true, then we will try to resolve links the path using /// the static FileSpec::Resolve. - //------------------------------------------------------------------ void SetFile(llvm::StringRef path, Style style); void SetFile(llvm::StringRef path, const llvm::Triple &Triple); bool IsResolved() const { return m_is_resolved; } - //------------------------------------------------------------------ /// Set if the file path has been resolved or not. /// /// If you know a file path is already resolved and avoided passing a \b @@ -446,10 +389,9 @@ public: /// we don't try and resolve it later, or try and resolve a path that has /// already been resolved. /// - /// @param[in] is_resolved + /// \param[in] is_resolved /// A boolean value that will replace the current value that /// indicates if the paths in this object have been resolved. - //------------------------------------------------------------------ void SetIsResolved(bool is_resolved) { m_is_resolved = is_resolved; } FileSpec CopyByAppendingPathComponent(llvm::StringRef component) const; @@ -461,35 +403,27 @@ public: void AppendPathComponent(llvm::StringRef component); void AppendPathComponent(const FileSpec &new_path); - //------------------------------------------------------------------ /// 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 + /// \return /// A boolean value indicating whether the path was updated. - //------------------------------------------------------------------ bool RemoveLastPathComponent(); ConstString GetLastPathComponent() const; protected: - //------------------------------------------------------------------ // Convenience method for setting the file without changing the style. - //------------------------------------------------------------------ void SetFile(llvm::StringRef 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. Style m_style; ///< The syntax that this path uses (e.g. Windows / Posix) }; -//---------------------------------------------------------------------- /// Dump a FileSpec object to a stream -//---------------------------------------------------------------------- Stream &operator<<(Stream &s, const FileSpec &f); } // namespace lldb_private diff --git a/include/lldb/Utility/Flags.h b/include/lldb/Utility/Flags.h index 5ef6122d1146e..48b14e7d2a2ca 100644 --- a/include/lldb/Utility/Flags.h +++ b/include/lldb/Utility/Flags.h @@ -1,9 +1,8 @@ //===-- Flags.h -------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -15,149 +14,117 @@ namespace lldb_private { -//---------------------------------------------------------------------- -/// @class Flags Flags.h "lldb/Utility/Flags.h" +/// \class Flags Flags.h "lldb/Utility/Flags.h" /// A class to manage flags. /// /// The Flags class managed flag bits and allows testing and modification of /// individual or multiple flag bits. -//---------------------------------------------------------------------- class Flags { public: - //---------------------------------------------------------------------- /// The value type for flags is a 32 bit unsigned integer type. - //---------------------------------------------------------------------- typedef uint32_t ValueType; - //---------------------------------------------------------------------- /// Construct with initial flag bit values. /// /// Constructs this object with \a mask as the initial value for all of the /// flags. /// - /// @param[in] mask + /// \param[in] mask /// The initial value for all flags. - //---------------------------------------------------------------------- Flags(ValueType flags = 0) : m_flags(flags) {} - //---------------------------------------------------------------------- /// Copy constructor. /// /// Construct and copy the flags from \a rhs. /// - /// @param[in] rhs + /// \param[in] rhs /// A const Flags object reference to copy. - //---------------------------------------------------------------------- Flags(const Flags &rhs) : m_flags(rhs.m_flags) {} - //---------------------------------------------------------------------- /// Destructor. - //---------------------------------------------------------------------- ~Flags() {} - //---------------------------------------------------------------------- /// Get accessor for all flags. /// - /// @return + /// \return /// Returns all of the flags as a Flags::ValueType. - //---------------------------------------------------------------------- ValueType Get() const { return m_flags; } - //---------------------------------------------------------------------- /// Return the number of flags that can be represented in this object. /// - /// @return + /// \return /// The maximum number bits in this flag object. - //---------------------------------------------------------------------- size_t GetBitSize() const { return sizeof(ValueType) * 8; } - //---------------------------------------------------------------------- /// Set accessor for all flags. /// - /// @param[in] flags + /// \param[in] flags /// The bits with which to replace all of the current flags. - //---------------------------------------------------------------------- void Reset(ValueType flags) { m_flags = flags; } - //---------------------------------------------------------------------- /// Clear one or more flags. /// - /// @param[in] mask + /// \param[in] mask /// A bitfield containing one or more flags. /// - /// @return + /// \return /// The new flags after clearing all bits from \a mask. - //---------------------------------------------------------------------- - ValueType Clear(ValueType mask = ~(ValueType)0) { + ValueType Clear(ValueType mask = ~static_cast<ValueType>(0)) { m_flags &= ~mask; return m_flags; } - //---------------------------------------------------------------------- /// Set one or more flags by logical OR'ing \a mask with the current flags. /// - /// @param[in] mask + /// \param[in] mask /// A bitfield containing one or more flags. /// - /// @return + /// \return /// The new flags after setting all bits from \a mask. - //---------------------------------------------------------------------- ValueType Set(ValueType mask) { m_flags |= mask; return m_flags; } - //---------------------------------------------------------------------- /// Test if all bits in \a mask are 1 in the current flags /// - /// @return + /// \return /// \b true if all flags in \a mask are 1, \b false /// otherwise. - //---------------------------------------------------------------------- bool AllSet(ValueType mask) const { return (m_flags & mask) == mask; } - //---------------------------------------------------------------------- /// Test one or more flags. /// - /// @return + /// \return /// \b true if any flags in \a mask are 1, \b false /// otherwise. - //---------------------------------------------------------------------- bool AnySet(ValueType mask) const { return (m_flags & mask) != 0; } - //---------------------------------------------------------------------- /// Test a single flag bit. /// - /// @return + /// \return /// \b true if \a bit is set, \b false otherwise. - //---------------------------------------------------------------------- bool Test(ValueType bit) const { return (m_flags & bit) != 0; } - //---------------------------------------------------------------------- /// Test if all bits in \a mask are clear. /// - /// @return + /// \return /// \b true if \b all flags in \a mask are clear, \b false /// otherwise. - //---------------------------------------------------------------------- bool AllClear(ValueType mask) const { return (m_flags & mask) == 0; } bool AnyClear(ValueType mask) const { return (m_flags & mask) != mask; } - //---------------------------------------------------------------------- /// Test a single flag bit to see if it is clear (zero). /// - /// @return + /// \return /// \b true if \a bit is 0, \b false otherwise. - //---------------------------------------------------------------------- bool IsClear(ValueType bit) const { return (m_flags & bit) == 0; } - //---------------------------------------------------------------------- /// Get the number of zero bits in \a m_flags. /// - /// @return + /// \return /// The number of bits that are set to 0 in the current flags. - //---------------------------------------------------------------------- size_t ClearCount() const { size_t count = 0; for (ValueType shift = 0; shift < sizeof(ValueType) * 8; ++shift) { @@ -167,12 +134,10 @@ public: return count; } - //---------------------------------------------------------------------- /// Get the number of one bits in \a m_flags. /// - /// @return + /// \return /// The number of bits that are set to 1 in the current flags. - //---------------------------------------------------------------------- size_t SetCount() const { size_t count = 0; for (ValueType mask = m_flags; mask; mask >>= 1) { diff --git a/include/lldb/Utility/IOObject.h b/include/lldb/Utility/IOObject.h index 61f288183850b..1640200a01d98 100644 --- a/include/lldb/Utility/IOObject.h +++ b/include/lldb/Utility/IOObject.h @@ -1,9 +1,8 @@ //===-- IOObject.h ----------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -20,10 +19,10 @@ namespace lldb_private { class IOObject { public: - typedef enum { + enum FDType { eFDTypeFile, // Other FD requiring read/write eFDTypeSocket, // Socket requiring send/recv - } FDType; + }; // TODO: On Windows this should be a HANDLE, and wait should use // WaitForMultipleObjects diff --git a/include/lldb/Utility/Iterable.h b/include/lldb/Utility/Iterable.h index 1b7ec89d6cf57..d9c61aa958cca 100644 --- a/include/lldb/Utility/Iterable.h +++ b/include/lldb/Utility/Iterable.h @@ -1,9 +1,8 @@ //===-- Iterable.h ----------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// diff --git a/include/lldb/Utility/JSON.h b/include/lldb/Utility/JSON.h index 6fe1945ea227a..172f77afb01fe 100644 --- a/include/lldb/Utility/JSON.h +++ b/include/lldb/Utility/JSON.h @@ -1,9 +1,8 @@ //===---------------------JSON.h --------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -22,8 +21,6 @@ namespace lldb_private { class Stream; -} -namespace lldb_private { class JSONValue { public: diff --git a/include/lldb/Utility/LLDBAssert.h b/include/lldb/Utility/LLDBAssert.h index e7448cdac5454..7008dd82496d6 100644 --- a/include/lldb/Utility/LLDBAssert.h +++ b/include/lldb/Utility/LLDBAssert.h @@ -1,9 +1,8 @@ //===----------------- LLDBAssert.h ------------------------------*- C++-*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// diff --git a/include/lldb/Utility/Listener.h b/include/lldb/Utility/Listener.h index 11f89d7aeec28..17fc47880e8f8 100644 --- a/include/lldb/Utility/Listener.h +++ b/include/lldb/Utility/Listener.h @@ -1,9 +1,8 @@ //===-- Listener.h ----------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -29,8 +28,6 @@ namespace lldb_private { class ConstString; -} -namespace lldb_private { class Event; } @@ -43,9 +40,7 @@ public: friend class Broadcaster; friend class BroadcasterManager; - //------------------------------------------------------------------ // Constructors and Destructors - //------------------------------------------------------------------ // // Listeners have to be constructed into shared pointers - at least if you // want them to listen to Broadcasters, @@ -63,10 +58,11 @@ public: const char *GetName() { return m_name.c_str(); } - uint32_t StartListeningForEventSpec(lldb::BroadcasterManagerSP manager_sp, - const BroadcastEventSpec &event_spec); + uint32_t + StartListeningForEventSpec(const lldb::BroadcasterManagerSP &manager_sp, + const BroadcastEventSpec &event_spec); - bool StopListeningForEventSpec(lldb::BroadcasterManagerSP manager_sp, + bool StopListeningForEventSpec(const lldb::BroadcasterManagerSP &manager_sp, const BroadcastEventSpec &event_spec); uint32_t StartListeningForEvents(Broadcaster *broadcaster, @@ -100,9 +96,7 @@ public: size_t HandleBroadcastEvent(lldb::EventSP &event_sp); private: - //------------------------------------------------------------------ // Classes that inherit from Listener can see and modify these - //------------------------------------------------------------------ struct BroadcasterInfo { BroadcasterInfo(uint32_t mask, HandleBroadcastCallback cb = nullptr, void *ud = nullptr) @@ -150,9 +144,7 @@ private: // uint32_t event_mask, // bool exact); - //------------------------------------------------------------------ // For Listener only - //------------------------------------------------------------------ DISALLOW_COPY_AND_ASSIGN(Listener); }; diff --git a/include/lldb/Utility/Log.h b/include/lldb/Utility/Log.h index 30b97f0137ef4..949de69c8e5a9 100644 --- a/include/lldb/Utility/Log.h +++ b/include/lldb/Utility/Log.h @@ -1,9 +1,8 @@ //===-- Log.h ---------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -32,9 +31,7 @@ namespace llvm { class raw_ostream; } -//---------------------------------------------------------------------- // Logging Options -//---------------------------------------------------------------------- #define LLDB_LOG_OPTION_THREADSAFE (1u << 0) #define LLDB_LOG_OPTION_VERBOSE (1u << 1) #define LLDB_LOG_OPTION_PREPEND_SEQUENCE (1u << 3) @@ -45,9 +42,7 @@ class raw_ostream; #define LLDB_LOG_OPTION_APPEND (1U << 8) #define LLDB_LOG_OPTION_PREPEND_FILE_FUNCTION (1U << 9) -//---------------------------------------------------------------------- // Logging Functions -//---------------------------------------------------------------------- namespace lldb_private { class Log final { @@ -74,7 +69,7 @@ public: : log_ptr(nullptr), categories(categories), default_flags(default_flags) {} - // This function is safe to call at any time If the channel is disabled + // 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. @@ -85,7 +80,7 @@ public: return nullptr; } - // This function is safe to call at any time If the channel is disabled + // 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. @@ -100,9 +95,7 @@ public: static void Initialize(); - //------------------------------------------------------------------ // Static accessors for logging channels - //------------------------------------------------------------------ static void Register(llvm::StringRef name, Channel &channel); static void Unregister(llvm::StringRef name); @@ -116,19 +109,18 @@ public: llvm::ArrayRef<const char *> categories, llvm::raw_ostream &error_stream); - static bool ListChannelCategories(llvm::StringRef channel, llvm::raw_ostream &stream); + static bool ListChannelCategories(llvm::StringRef channel, + llvm::raw_ostream &stream); static void DisableAllLogChannels(); static void ListAllLogChannels(llvm::raw_ostream &stream); - //------------------------------------------------------------------ // Member functions // // These functions are safe to call at any time you have a Log* obtained from // the Channel class. If logging is disabled between you obtaining the Log // object and writing to it, the output will be silently discarded. - //------------------------------------------------------------------ Log(Channel &channel) : m_channel(channel) {} ~Log() = default; diff --git a/include/lldb/Utility/Logging.h b/include/lldb/Utility/Logging.h index 2c75a3bf218b5..41086fedf8c2d 100644 --- a/include/lldb/Utility/Logging.h +++ b/include/lldb/Utility/Logging.h @@ -1,9 +1,8 @@ //===-- Logging.h -----------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -12,9 +11,7 @@ #include <cstdint> -//---------------------------------------------------------------------- // Log Bits specific to logging in lldb -//---------------------------------------------------------------------- #define LIBLLDB_LOG_PROCESS (1u << 1) #define LIBLLDB_LOG_THREAD (1u << 2) #define LIBLLDB_LOG_DYNAMIC_LOADER (1u << 3) @@ -45,6 +42,7 @@ #define LIBLLDB_LOG_LANGUAGE (1u << 28) #define LIBLLDB_LOG_DATAFORMATTERS (1u << 29) #define LIBLLDB_LOG_DEMANGLE (1u << 30) +#define LIBLLDB_LOG_AST (1u << 31) #define LIBLLDB_LOG_ALL (UINT32_MAX) #define LIBLLDB_LOG_DEFAULT \ (LIBLLDB_LOG_PROCESS | LIBLLDB_LOG_THREAD | LIBLLDB_LOG_DYNAMIC_LOADER | \ diff --git a/include/lldb/Utility/NameMatches.h b/include/lldb/Utility/NameMatches.h index bc9ec703770a0..38900df2bd5d9 100644 --- a/include/lldb/Utility/NameMatches.h +++ b/include/lldb/Utility/NameMatches.h @@ -1,9 +1,8 @@ //===-- NameMatches.h -------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// #ifndef LLDB_UTILITY_NAMEMATCHES_H diff --git a/include/lldb/Utility/Predicate.h b/include/lldb/Utility/Predicate.h index d05f17131c684..f1539b5766868 100644 --- a/include/lldb/Utility/Predicate.h +++ b/include/lldb/Utility/Predicate.h @@ -1,9 +1,8 @@ //===-- Predicate.h ---------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -21,20 +20,17 @@ //#define DB_PTHREAD_LOG_EVENTS -//---------------------------------------------------------------------- /// Enumerations for broadcasting. -//---------------------------------------------------------------------- namespace lldb_private { -typedef enum { +enum PredicateBroadcastType { eBroadcastNever, ///< No broadcast will be sent when the value is modified. eBroadcastAlways, ///< Always send a broadcast when the value is modified. eBroadcastOnChange ///< Only broadcast if the value changes when the value is /// modified. -} PredicateBroadcastType; +}; -//---------------------------------------------------------------------- -/// @class Predicate Predicate.h "lldb/Utility/Predicate.h" +/// \class Predicate Predicate.h "lldb/Utility/Predicate.h" /// A C++ wrapper class for providing threaded access to a value of /// type T. /// @@ -42,66 +38,55 @@ typedef enum { /// of type T. Threads can efficiently wait for bits within T to be set /// or reset, or wait for T to be set to be equal/not equal to a /// specified values. -//---------------------------------------------------------------------- template <class T> class Predicate { public: - //------------------------------------------------------------------ /// Default constructor. /// /// Initializes the mutex, condition and value with their default /// constructors. - //------------------------------------------------------------------ Predicate() : m_value(), m_mutex(), m_condition() {} - //------------------------------------------------------------------ /// Construct with initial T value \a initial_value. /// /// Initializes the mutex and condition with their default /// constructors, and initializes the value with \a initial_value. /// - /// @param[in] initial_value + /// \param[in] initial_value /// The initial value for our T object. - //------------------------------------------------------------------ Predicate(T initial_value) : m_value(initial_value), m_mutex(), m_condition() {} - //------------------------------------------------------------------ /// Destructor. /// /// Destroy the condition, mutex, and T objects. - //------------------------------------------------------------------ ~Predicate() = default; - //------------------------------------------------------------------ /// Value get accessor. /// /// Copies the current \a m_value in a thread safe manor and returns /// the copied value. /// - /// @return + /// \return /// A copy of the current value. - //------------------------------------------------------------------ T GetValue() const { std::lock_guard<std::mutex> guard(m_mutex); T value = m_value; return value; } - //------------------------------------------------------------------ /// Value set accessor. /// /// Set the contained \a m_value to \a new_value in a thread safe /// way and broadcast if needed. /// - /// @param[in] value + /// \param[in] value /// The new value to set. /// - /// @param[in] broadcast_type + /// \param[in] broadcast_type /// A value indicating when and if to broadcast. See the /// PredicateBroadcastType enumeration for details. /// - /// @see Predicate::Broadcast() - //------------------------------------------------------------------ + /// \see Predicate::Broadcast() void SetValue(T value, PredicateBroadcastType broadcast_type) { std::lock_guard<std::mutex> guard(m_mutex); #ifdef DB_PTHREAD_LOG_EVENTS @@ -114,7 +99,6 @@ public: Broadcast(old_value, broadcast_type); } - //------------------------------------------------------------------ /// Wait for Cond(m_value) to be true. /// /// Waits in a thread safe way for Cond(m_value) to be true. If Cond(m_value) @@ -126,16 +110,15 @@ public: /// into a wait state. It may be necessary for the calling code to use /// additional thread synchronization methods to detect transitory states. /// - /// @param[in] Cond + /// \param[in] Cond /// The condition we want \a m_value satisfy. /// - /// @param[in] timeout + /// \param[in] timeout /// How long to wait for the condition to hold. /// - /// @return - /// @li m_value if Cond(m_value) is true. - /// @li None otherwise (timeout occurred). - //------------------------------------------------------------------ + /// \return + /// \li m_value if Cond(m_value) is true. + /// \li None otherwise (timeout occurred). template <typename C> llvm::Optional<T> WaitFor(C Cond, const Timeout<std::micro> &timeout) { std::unique_lock<std::mutex> lock(m_mutex); @@ -148,7 +131,6 @@ public: return m_value; return llvm::None; } - //------------------------------------------------------------------ /// Wait for \a m_value to be equal to \a value. /// /// Waits in a thread safe way for \a m_value to be equal to \a @@ -162,23 +144,21 @@ public: /// may be necessary for the calling code to use additional thread /// synchronization methods to detect transitory states. /// - /// @param[in] value + /// \param[in] value /// The value we want \a m_value to be equal to. /// - /// @param[in] timeout + /// \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 (timeout occurred) - //------------------------------------------------------------------ + /// \return + /// \li \b true if the \a m_value is equal to \a value + /// \li \b false otherwise (timeout occurred) bool WaitForValueEqualTo(T value, const Timeout<std::micro> &timeout = llvm::None) { return WaitFor([&value](T current) { return value == current; }, timeout) != llvm::None; } - //------------------------------------------------------------------ /// Wait for \a m_value to not be equal to \a value. /// /// Waits in a thread safe way for \a m_value to not be equal to \a @@ -192,16 +172,15 @@ public: /// necessary for the calling code to use additional thread /// synchronization methods to detect transitory states. /// - /// @param[in] value + /// \param[in] value /// The value we want \a m_value to not be equal to. /// - /// @param[in] timeout + /// \param[in] timeout /// How long to wait for the condition to hold. /// - /// @return - /// @li m_value if m_value != value - /// @li None otherwise (timeout occurred). - //------------------------------------------------------------------ + /// \return + /// \li m_value if m_value != value + /// \li None otherwise (timeout occurred). llvm::Optional<T> WaitForValueNotEqualTo(T value, const Timeout<std::micro> &timeout = llvm::None) { @@ -209,10 +188,8 @@ public: } protected: - //---------------------------------------------------------------------- // 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 std::condition_variable m_condition; ///< The pthread condition variable to @@ -220,7 +197,6 @@ protected: /// or changed. private: - //------------------------------------------------------------------ /// Broadcast if needed. /// /// Check to see if we need to broadcast to our condition variable @@ -234,7 +210,6 @@ private: /// /// If \a broadcast_type is eBroadcastOnChange, the condition /// variable be broadcast if the owned value changes. - //------------------------------------------------------------------ void Broadcast(T old_value, PredicateBroadcastType broadcast_type) { bool broadcast = (broadcast_type == eBroadcastAlways) || diff --git a/include/lldb/Utility/ProcessInfo.h b/include/lldb/Utility/ProcessInfo.h new file mode 100644 index 0000000000000..a25c06cabdf6c --- /dev/null +++ b/include/lldb/Utility/ProcessInfo.h @@ -0,0 +1,245 @@ +//===-- ProcessInfo.h -------------------------------------------*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef LLDB_UTILITY_PROCESSINFO_H +#define LLDB_UTILITY_PROCESSINFO_H + +// LLDB headers +#include "lldb/Utility/ArchSpec.h" +#include "lldb/Utility/Args.h" +#include "lldb/Utility/Environment.h" +#include "lldb/Utility/FileSpec.h" +#include "lldb/Utility/NameMatches.h" + +#include <vector> + +namespace lldb_private { + +class UserIDResolver; + +// 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. +class ProcessInfo { +public: + ProcessInfo(); + + ProcessInfo(const char *name, const ArchSpec &arch, lldb::pid_t pid); + + void Clear(); + + const char *GetName() const; + + size_t GetNameLength() const; + + FileSpec &GetExecutableFile() { return m_executable; } + + void SetExecutableFile(const FileSpec &exe_file, + bool add_exe_file_as_first_arg); + + const FileSpec &GetExecutableFile() const { return m_executable; } + + uint32_t GetUserID() const { return m_uid; } + + uint32_t GetGroupID() const { return m_gid; } + + bool UserIDIsValid() const { return m_uid != UINT32_MAX; } + + bool GroupIDIsValid() const { return m_gid != UINT32_MAX; } + + void SetUserID(uint32_t uid) { m_uid = uid; } + + void SetGroupID(uint32_t gid) { m_gid = gid; } + + ArchSpec &GetArchitecture() { return m_arch; } + + const ArchSpec &GetArchitecture() const { return m_arch; } + + void SetArchitecture(const ArchSpec &arch) { m_arch = arch; } + + lldb::pid_t GetProcessID() const { return m_pid; } + + void SetProcessID(lldb::pid_t pid) { m_pid = pid; } + + bool ProcessIDIsValid() const { return m_pid != LLDB_INVALID_PROCESS_ID; } + + void Dump(Stream &s, Platform *platform) const; + + Args &GetArguments() { return m_arguments; } + + const Args &GetArguments() const { return m_arguments; } + + llvm::StringRef GetArg0() const; + + void SetArg0(llvm::StringRef arg); + + void SetArguments(const Args &args, bool first_arg_is_executable); + + void SetArguments(char const **argv, bool first_arg_is_executable); + + 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) + Args m_arguments; // All program arguments except argv[0] + Environment m_environment; + uint32_t m_uid; + uint32_t m_gid; + ArchSpec m_arch; + lldb::pid_t m_pid; +}; + +// ProcessInstanceInfo +// +// Describes an existing process and any discoverable information that pertains +// to that process. +class ProcessInstanceInfo : public ProcessInfo { +public: + ProcessInstanceInfo() + : ProcessInfo(), m_euid(UINT32_MAX), m_egid(UINT32_MAX), + m_parent_pid(LLDB_INVALID_PROCESS_ID) {} + + ProcessInstanceInfo(const char *name, const ArchSpec &arch, lldb::pid_t pid) + : ProcessInfo(name, arch, pid), m_euid(UINT32_MAX), m_egid(UINT32_MAX), + m_parent_pid(LLDB_INVALID_PROCESS_ID) {} + + void Clear() { + ProcessInfo::Clear(); + m_euid = UINT32_MAX; + m_egid = UINT32_MAX; + m_parent_pid = LLDB_INVALID_PROCESS_ID; + } + + uint32_t GetEffectiveUserID() const { return m_euid; } + + uint32_t GetEffectiveGroupID() const { return m_egid; } + + bool EffectiveUserIDIsValid() const { return m_euid != UINT32_MAX; } + + bool EffectiveGroupIDIsValid() const { return m_egid != UINT32_MAX; } + + void SetEffectiveUserID(uint32_t uid) { m_euid = uid; } + + void SetEffectiveGroupID(uint32_t gid) { m_egid = gid; } + + lldb::pid_t GetParentProcessID() const { return m_parent_pid; } + + void SetParentProcessID(lldb::pid_t pid) { m_parent_pid = pid; } + + bool ParentProcessIDIsValid() const { + return m_parent_pid != LLDB_INVALID_PROCESS_ID; + } + + void Dump(Stream &s, UserIDResolver &resolver) const; + + static void DumpTableHeader(Stream &s, bool show_args, bool verbose); + + void DumpAsTableRow(Stream &s, UserIDResolver &resolver, bool show_args, + bool verbose) const; + +protected: + uint32_t m_euid; + uint32_t m_egid; + lldb::pid_t m_parent_pid; +}; + +class ProcessInstanceInfoList { +public: + ProcessInstanceInfoList() = default; + + void Clear() { m_infos.clear(); } + + size_t GetSize() { return m_infos.size(); } + + void Append(const ProcessInstanceInfo &info) { m_infos.push_back(info); } + + const char *GetProcessNameAtIndex(size_t idx) { + return ((idx < m_infos.size()) ? m_infos[idx].GetName() : nullptr); + } + + size_t GetProcessNameLengthAtIndex(size_t idx) { + return ((idx < m_infos.size()) ? m_infos[idx].GetNameLength() : 0); + } + + lldb::pid_t GetProcessIDAtIndex(size_t idx) { + return ((idx < m_infos.size()) ? m_infos[idx].GetProcessID() : 0); + } + + bool GetInfoAtIndex(size_t idx, ProcessInstanceInfo &info) { + if (idx < m_infos.size()) { + info = m_infos[idx]; + return true; + } + return false; + } + + // You must ensure "idx" is valid before calling this function + const ProcessInstanceInfo &GetProcessInfoAtIndex(size_t idx) const { + assert(idx < m_infos.size()); + return m_infos[idx]; + } + +protected: + std::vector<ProcessInstanceInfo> m_infos; +}; + +// ProcessInstanceInfoMatch +// +// A class to help matching one ProcessInstanceInfo to another. + +class ProcessInstanceInfoMatch { +public: + ProcessInstanceInfoMatch() + : m_match_info(), m_name_match_type(NameMatch::Ignore), + m_match_all_users(false) {} + + ProcessInstanceInfoMatch(const char *process_name, + 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, + FileSpec::Style::native); + } + + ProcessInstanceInfo &GetProcessInfo() { return m_match_info; } + + const ProcessInstanceInfo &GetProcessInfo() const { return m_match_info; } + + bool GetMatchAllUsers() const { return m_match_all_users; } + + void SetMatchAllUsers(bool b) { m_match_all_users = b; } + + NameMatch GetNameMatchType() const { return m_name_match_type; } + + void SetNameMatchType(NameMatch name_match_type) { + m_name_match_type = name_match_type; + } + + bool NameMatches(const char *process_name) const; + + bool Matches(const ProcessInstanceInfo &proc_info) const; + + bool MatchAllProcesses() const; + void Clear(); + +protected: + ProcessInstanceInfo m_match_info; + NameMatch m_name_match_type; + bool m_match_all_users; +}; + +} // namespace lldb_private + +#endif // #ifndef LLDB_UTILITY_PROCESSINFO_H diff --git a/include/lldb/Core/RangeMap.h b/include/lldb/Utility/RangeMap.h index 5a75a24f7f61c..36401f59d34f9 100644 --- a/include/lldb/Core/RangeMap.h +++ b/include/lldb/Utility/RangeMap.h @@ -1,14 +1,13 @@ //===-- RangeMap.h ----------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// -#ifndef liblldb_RangeMap_h_ -#define liblldb_RangeMap_h_ +#ifndef LLDB_UTILITY_RANGEMAP_H +#define LLDB_UTILITY_RANGEMAP_H #include <algorithm> #include <vector> @@ -22,15 +21,11 @@ namespace lldb_private { -//---------------------------------------------------------------------- // Templatized classes for dealing with generic ranges and also collections of // ranges, or collections of ranges that have associated data. -//---------------------------------------------------------------------- -//---------------------------------------------------------------------- // A simple range class where you get to define the type of the range // base "B", and the type used for the range byte size "S". -//---------------------------------------------------------------------- template <typename B, typename S> struct Range { typedef B BaseType; typedef S SizeType; @@ -54,10 +49,8 @@ template <typename B, typename S> struct Range { void Slide(BaseType slide) { base += slide; } - bool Union(const Range &rhs) - { - if (DoesAdjoinOrIntersect(rhs)) - { + bool Union(const Range &rhs) { + if (DoesAdjoinOrIntersect(rhs)) { auto new_end = std::max<BaseType>(GetRangeEnd(), rhs.GetRangeEnd()); base = std::min<BaseType>(base, rhs.base); size = new_end - base; @@ -129,10 +122,8 @@ template <typename B, typename S> struct Range { } }; -//---------------------------------------------------------------------- // A range array class where you get to define the type of the ranges // that the collection contains. -//---------------------------------------------------------------------- template <typename B, typename S, unsigned N> class RangeArray { public: @@ -570,7 +561,6 @@ public: } protected: - void CombinePrevAndNext(typename Collection::iterator pos) { // Check if the prev or next entries in case they need to be unioned with // the entry pointed to by "pos". @@ -580,7 +570,7 @@ protected: m_entries.erase(pos); pos = prev; } - + auto end = m_entries.end(); if (pos != end) { auto next = pos + 1; @@ -595,11 +585,9 @@ protected: Collection m_entries; }; -//---------------------------------------------------------------------- // 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". -//---------------------------------------------------------------------- template <typename B, typename S, typename T> struct RangeData : public Range<B, S> { typedef T DataType; @@ -636,6 +624,7 @@ struct RangeData : public Range<B, S> { template <typename B, typename S, typename T, unsigned N = 0> class RangeDataVector { public: + typedef lldb_private::Range<B, S> Range; typedef RangeData<B, S, T> Entry; typedef llvm::SmallVector<Entry, N> Collection; @@ -716,6 +705,7 @@ public: // Clients must ensure that "i" is a valid index prior to calling this // function + Entry &GetEntryRef(size_t i) { return m_entries[i]; } const Entry &GetEntryRef(size_t i) const { return m_entries[i]; } static bool BaseLessThan(const Entry &lhs, const Entry &rhs) { @@ -827,11 +817,9 @@ protected: Collection m_entries; }; -//---------------------------------------------------------------------- // 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". -//---------------------------------------------------------------------- template <typename B, typename T> struct AddressData { typedef B BaseType; typedef T DataType; @@ -947,4 +935,4 @@ protected: } // namespace lldb_private -#endif // liblldb_RangeMap_h_ +#endif // LLDB_UTILITY_RANGEMAP_H diff --git a/include/lldb/Utility/RegisterValue.h b/include/lldb/Utility/RegisterValue.h index c025a26fb25a9..eeb3ce52a82bf 100644 --- a/include/lldb/Utility/RegisterValue.h +++ b/include/lldb/Utility/RegisterValue.h @@ -1,9 +1,8 @@ //===-- RegisterValue.h -----------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -42,7 +41,8 @@ public: eTypeBytes }; - RegisterValue() : m_type(eTypeInvalid), m_scalar((unsigned long)0) {} + RegisterValue() + : m_type(eTypeInvalid), m_scalar(static_cast<unsigned long>(0)) {} explicit RegisterValue(uint8_t inst) : m_type(eTypeUInt8) { m_scalar = inst; } diff --git a/include/lldb/Utility/RegularExpression.h b/include/lldb/Utility/RegularExpression.h index b379c6e8bea14..54f3dd89c7a2a 100644 --- a/include/lldb/Utility/RegularExpression.h +++ b/include/lldb/Utility/RegularExpression.h @@ -1,9 +1,8 @@ //===-- RegularExpression.h -------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -49,15 +48,13 @@ class StringRef; namespace lldb_private { -//---------------------------------------------------------------------- -/// @class RegularExpression RegularExpression.h +/// \class RegularExpression RegularExpression.h /// "lldb/Utility/RegularExpression.h" /// 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. -//---------------------------------------------------------------------- class RegularExpression { public: class Match { @@ -95,29 +92,24 @@ public: m_matches; ///< Where parenthesized subexpressions results are stored }; - //------------------------------------------------------------------ /// Default constructor. /// /// The default constructor that initializes the object state such that it /// contains no compiled regular expression. - //------------------------------------------------------------------ RegularExpression(); explicit RegularExpression(llvm::StringRef string); - //------------------------------------------------------------------ /// Destructor. /// /// Any previously compiled regular expression contained in this object will /// be freed. - //------------------------------------------------------------------ ~RegularExpression(); RegularExpression(const RegularExpression &rhs); const RegularExpression &operator=(const RegularExpression &rhs); - //------------------------------------------------------------------ /// Compile a regular expression. /// /// Compile a regular expression using the supplied regular expression text. @@ -126,18 +118,16 @@ public: /// after the regular expression is compiled. Any previously compiled /// regular expression contained in this object will be freed. /// - /// @param[in] re + /// \param[in] re /// A NULL terminated C string that represents the regular /// expression to compile. /// - /// @return + /// \return /// \b true if the regular expression compiles successfully, /// \b false otherwise. - //------------------------------------------------------------------ bool Compile(llvm::StringRef string); bool Compile(const char *) = delete; - //------------------------------------------------------------------ /// Executes a regular expression. /// /// Execute a regular expression match using the compiled regular expression @@ -146,52 +136,45 @@ public: /// indicate the number of regmatch_t values that are present in \a /// match_ptr. /// - /// @param[in] string + /// \param[in] string /// The string to match against the compile regular expression. /// - /// @param[in] match + /// \param[in] match /// A pointer to a RegularExpression::Match structure that was /// properly initialized with the desired number of maximum /// matches, or nullptr if no parenthesized matching is needed. /// - /// @return + /// \return /// \b true if \a string matches the compiled regular /// expression, \b false otherwise. - //------------------------------------------------------------------ bool Execute(llvm::StringRef string, Match *match = nullptr) const; bool Execute(const char *, Match * = nullptr) = delete; size_t GetErrorAsCString(char *err_str, size_t err_str_max_len) const; - //------------------------------------------------------------------ /// Free the compiled regular expression. /// /// If this object contains a valid compiled regular expression, this /// function will free any resources it was consuming. - //------------------------------------------------------------------ void Free(); - //------------------------------------------------------------------ /// Access the regular expression text. /// /// Returns the text that was used to compile the current regular /// expression. /// - /// @return + /// \return /// The NULL terminated C string that was used to compile the /// current regular expression - //------------------------------------------------------------------ llvm::StringRef GetText() const; - //------------------------------------------------------------------ /// Test if valid. /// /// Test if this object contains a valid regular expression. /// - /// @return + /// \return /// \b true if the regular expression compiled and is ready /// for execution, \b false otherwise. - //------------------------------------------------------------------ bool IsValid() const; void Clear() { @@ -205,9 +188,7 @@ public: bool operator<(const RegularExpression &rhs) const; private: - //------------------------------------------------------------------ // Member variables - //------------------------------------------------------------------ std::string m_re; ///< A copy of the original regular expression text int m_comp_err; ///< Status code for the regular expression compilation regex_t m_preg; ///< The compiled regular expression diff --git a/include/lldb/Utility/Reproducer.h b/include/lldb/Utility/Reproducer.h index ea315ad771a61..670041d06bbac 100644 --- a/include/lldb/Utility/Reproducer.h +++ b/include/lldb/Utility/Reproducer.h @@ -1,15 +1,15 @@ //===-- Reproducer.h --------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// #ifndef LLDB_UTILITY_REPRODUCER_H #define LLDB_UTILITY_REPRODUCER_H +#include "lldb/Utility/FileCollector.h" #include "lldb/Utility/FileSpec.h" #include "llvm/ADT/DenseMap.h" @@ -31,24 +31,14 @@ enum class ReproducerMode { Off, }; -/// Abstraction for information associated with a provider. This information -/// is serialized into an index which is used by the loader. -struct ProviderInfo { - std::string name; - std::vector<std::string> files; -}; - /// The provider defines an interface for generating files needed for -/// reproducing. The provider must populate its ProviderInfo to communicate -/// its name and files to the index, before registering with the generator, -/// i.e. in the constructor. +/// reproducing. /// /// Different components will implement different providers. class ProviderBase { public: virtual ~ProviderBase() = default; - const ProviderInfo &GetInfo() const { return m_info; } const FileSpec &GetRoot() const { return m_root; } /// The Keep method is called when it is decided that we need to keep the @@ -65,11 +55,12 @@ public: // Returns the class ID for the dynamic type of this Provider instance. virtual const void *DynamicClassID() const = 0; + virtual llvm::StringRef GetName() const = 0; + virtual llvm::StringRef GetFile() const = 0; + protected: ProviderBase(const FileSpec &root) : m_root(root) {} - /// Every provider keeps track of its own files. - ProviderInfo m_info; private: /// Every provider knows where to dump its potential files. FileSpec m_root; @@ -84,10 +75,112 @@ public: const void *DynamicClassID() const override { return &ThisProviderT::ID; } + llvm::StringRef GetName() const override { return ThisProviderT::Info::name; } + llvm::StringRef GetFile() const override { return ThisProviderT::Info::file; } + protected: using ProviderBase::ProviderBase; // Inherit constructor. }; +class FileProvider : public Provider<FileProvider> { +public: + struct Info { + static const char *name; + static const char *file; + }; + + FileProvider(const FileSpec &directory) + : Provider(directory), + m_collector(directory.CopyByAppendingPathComponent("root"), directory) { + } + + FileCollector &GetFileCollector() { return m_collector; } + + void Keep() override { + auto mapping = GetRoot().CopyByAppendingPathComponent(Info::file); + // Temporary files that are removed during execution can cause copy errors. + if (auto ec = m_collector.CopyFiles(/*stop_on_error=*/false)) + return; + m_collector.WriteMapping(mapping); + } + + static char ID; + +private: + FileCollector m_collector; +}; + +/// Provider for the LLDB version number. +/// +/// When the reproducer is kept, it writes the lldb version to a file named +/// version.txt in the reproducer root. +class VersionProvider : public Provider<VersionProvider> { +public: + VersionProvider(const FileSpec &directory) : Provider(directory) {} + struct Info { + static const char *name; + static const char *file; + }; + void SetVersion(std::string version) { + assert(m_version.empty()); + m_version = std::move(version); + } + void Keep() override; + std::string m_version; + static char ID; +}; + +class DataRecorder { +public: + DataRecorder(const FileSpec &filename, std::error_code &ec) + : m_filename(filename.GetFilename().GetStringRef()), + m_os(filename.GetPath(), ec, llvm::sys::fs::F_Text), m_record(true) {} + + static llvm::Expected<std::unique_ptr<DataRecorder>> + Create(const FileSpec &filename); + + template <typename T> void Record(const T &t, bool newline = false) { + if (!m_record) + return; + m_os << t; + if (newline) + m_os << '\n'; + m_os.flush(); + } + + const FileSpec &GetFilename() { return m_filename; } + + void Stop() { + assert(m_record); + m_record = false; + } + +private: + FileSpec m_filename; + llvm::raw_fd_ostream m_os; + bool m_record; +}; + +class CommandProvider : public Provider<CommandProvider> { +public: + struct Info { + static const char *name; + static const char *file; + }; + + CommandProvider(const FileSpec &directory) : Provider(directory) {} + + DataRecorder *GetNewDataRecorder(); + + void Keep() override; + void Discard() override; + + static char ID; + +private: + std::vector<std::unique_ptr<DataRecorder>> m_data_recorders; +}; + /// The generator is responsible for the logic needed to generate a /// reproducer. For doing so it relies on providers, who serialize data that /// is necessary for reproducing a failure. @@ -152,14 +245,22 @@ class Loader final { public: Loader(const FileSpec &root); - llvm::Optional<ProviderInfo> GetProviderInfo(llvm::StringRef name); + template <typename T> FileSpec GetFile() { + if (!HasFile(T::file)) + return {}; + + return GetRoot().CopyByAppendingPathComponent(T::file); + } + llvm::Error LoadIndex(); const FileSpec &GetRoot() const { return m_root; } private: - llvm::StringMap<ProviderInfo> m_provider_info; + bool HasFile(llvm::StringRef file); + FileSpec m_root; + std::vector<std::string> m_files; bool m_loaded; }; @@ -170,6 +271,7 @@ public: static Reproducer &Instance(); static llvm::Error Initialize(ReproducerMode mode, llvm::Optional<FileSpec> root); + static bool Initialized(); static void Terminate(); Reproducer() = default; @@ -198,18 +300,4 @@ private: } // namespace repro } // namespace lldb_private -LLVM_YAML_IS_DOCUMENT_LIST_VECTOR(lldb_private::repro::ProviderInfo) - -namespace llvm { -namespace yaml { - -template <> struct MappingTraits<lldb_private::repro::ProviderInfo> { - static void mapping(IO &io, lldb_private::repro::ProviderInfo &info) { - io.mapRequired("name", info.name); - io.mapOptional("files", info.files); - } -}; -} // namespace yaml -} // namespace llvm - #endif // LLDB_UTILITY_REPRODUCER_H diff --git a/include/lldb/Utility/ReproducerInstrumentation.h b/include/lldb/Utility/ReproducerInstrumentation.h new file mode 100644 index 0000000000000..f90ce4bc767a3 --- /dev/null +++ b/include/lldb/Utility/ReproducerInstrumentation.h @@ -0,0 +1,717 @@ +//===-- ReproducerInstrumentation.h -----------------------------*- C++ -*-===// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef LLDB_UTILITY_REPRODUCER_INSTRUMENTATION_H +#define LLDB_UTILITY_REPRODUCER_INSTRUMENTATION_H + +#include "lldb/Utility/FileSpec.h" +#include "lldb/Utility/Log.h" +#include "lldb/Utility/Logging.h" + +#include "llvm/ADT/DenseMap.h" +#include "llvm/ADT/StringRef.h" +#include "llvm/Support/ErrorHandling.h" + +#include <iostream> +#include <map> +#include <type_traits> + +template <typename T, + typename std::enable_if<std::is_fundamental<T>::value, int>::type = 0> +inline void stringify_append(llvm::raw_string_ostream &ss, const T &t) { + ss << t; +} + +template <typename T, typename std::enable_if<!std::is_fundamental<T>::value, + int>::type = 0> +inline void stringify_append(llvm::raw_string_ostream &ss, const T &t) { + ss << &t; +} + +template <typename T> +inline void stringify_append(llvm::raw_string_ostream &ss, const T *t) { + ss << reinterpret_cast<const void *>(t); +} + +template <> +inline void stringify_append<char>(llvm::raw_string_ostream &ss, + const char *t) { + ss << t; +} + +template <typename Head> +inline void stringify_helper(llvm::raw_string_ostream &ss, const Head &head) { + stringify_append(ss, head); +} + +template <typename Head, typename... Tail> +inline void stringify_helper(llvm::raw_string_ostream &ss, const Head &head, + const Tail &... tail) { + stringify_append(ss, head); + ss << ", "; + stringify_helper(ss, tail...); +} + +template <typename... Ts> inline std::string stringify_args(const Ts &... ts) { + std::string buffer; + llvm::raw_string_ostream ss(buffer); + stringify_helper(ss, ts...); + return ss.str(); +} + +// Define LLDB_REPRO_INSTR_TRACE to trace to stderr instead of LLDB's log +// infrastructure. This is useful when you need to see traces before the logger +// is initialized or enabled. +// #define LLDB_REPRO_INSTR_TRACE + +#define LLDB_REGISTER_CONSTRUCTOR(Class, Signature) \ + R.Register<Class * Signature>(&construct<Class Signature>::doit, "", #Class, \ + #Class, #Signature) +#define LLDB_REGISTER_METHOD(Result, Class, Method, Signature) \ + R.Register( \ + &invoke<Result(Class::*) Signature>::method<(&Class::Method)>::doit, \ + #Result, #Class, #Method, #Signature) +#define LLDB_REGISTER_METHOD_CONST(Result, Class, Method, Signature) \ + R.Register(&invoke<Result(Class::*) Signature const>::method_const<( \ + &Class::Method)>::doit, \ + #Result, #Class, #Method, #Signature) +#define LLDB_REGISTER_STATIC_METHOD(Result, Class, Method, Signature) \ + R.Register<Result Signature>( \ + static_cast<Result(*) Signature>(&Class::Method), #Result, #Class, \ + #Method, #Signature) + +#define LLDB_RECORD_CONSTRUCTOR(Class, Signature, ...) \ + lldb_private::repro::Recorder sb_recorder(LLVM_PRETTY_FUNCTION, \ + stringify_args(__VA_ARGS__)); \ + if (lldb_private::repro::InstrumentationData data = \ + LLDB_GET_INSTRUMENTATION_DATA()) { \ + sb_recorder.Record(data.GetSerializer(), data.GetRegistry(), \ + &lldb_private::repro::construct<Class Signature>::doit, \ + __VA_ARGS__); \ + sb_recorder.RecordResult(this); \ + } + +#define LLDB_RECORD_CONSTRUCTOR_NO_ARGS(Class) \ + lldb_private::repro::Recorder sb_recorder(LLVM_PRETTY_FUNCTION); \ + if (lldb_private::repro::InstrumentationData data = \ + LLDB_GET_INSTRUMENTATION_DATA()) { \ + sb_recorder.Record(data.GetSerializer(), data.GetRegistry(), \ + &lldb_private::repro::construct<Class()>::doit); \ + sb_recorder.RecordResult(this); \ + } + +#define LLDB_RECORD_METHOD(Result, Class, Method, Signature, ...) \ + lldb_private::repro::Recorder sb_recorder(LLVM_PRETTY_FUNCTION, \ + stringify_args(__VA_ARGS__)); \ + if (lldb_private::repro::InstrumentationData data = \ + LLDB_GET_INSTRUMENTATION_DATA()) { \ + sb_recorder.Record( \ + data.GetSerializer(), data.GetRegistry(), \ + &lldb_private::repro::invoke<Result(Class::*) Signature>::method<( \ + &Class::Method)>::doit, \ + this, __VA_ARGS__); \ + } + +#define LLDB_RECORD_METHOD_CONST(Result, Class, Method, Signature, ...) \ + lldb_private::repro::Recorder sb_recorder(LLVM_PRETTY_FUNCTION, \ + stringify_args(__VA_ARGS__)); \ + if (lldb_private::repro::InstrumentationData data = \ + LLDB_GET_INSTRUMENTATION_DATA()) { \ + sb_recorder.Record( \ + data.GetSerializer(), data.GetRegistry(), \ + &lldb_private::repro::invoke<Result( \ + Class::*) Signature const>::method_const<(&Class::Method)>::doit, \ + this, __VA_ARGS__); \ + } + +#define LLDB_RECORD_METHOD_NO_ARGS(Result, Class, Method) \ + lldb_private::repro::Recorder sb_recorder(LLVM_PRETTY_FUNCTION); \ + if (lldb_private::repro::InstrumentationData data = \ + LLDB_GET_INSTRUMENTATION_DATA()) { \ + sb_recorder.Record(data.GetSerializer(), data.GetRegistry(), \ + &lldb_private::repro::invoke<Result ( \ + Class::*)()>::method<(&Class::Method)>::doit, \ + this); \ + } + +#define LLDB_RECORD_METHOD_CONST_NO_ARGS(Result, Class, Method) \ + lldb_private::repro::Recorder sb_recorder(LLVM_PRETTY_FUNCTION); \ + if (lldb_private::repro::InstrumentationData data = \ + LLDB_GET_INSTRUMENTATION_DATA()) { \ + sb_recorder.Record( \ + data.GetSerializer(), data.GetRegistry(), \ + &lldb_private::repro::invoke<Result ( \ + Class::*)() const>::method_const<(&Class::Method)>::doit, \ + this); \ + } + +#define LLDB_RECORD_STATIC_METHOD(Result, Class, Method, Signature, ...) \ + lldb_private::repro::Recorder sb_recorder(LLVM_PRETTY_FUNCTION, \ + stringify_args(__VA_ARGS__)); \ + if (lldb_private::repro::InstrumentationData data = \ + LLDB_GET_INSTRUMENTATION_DATA()) { \ + sb_recorder.Record(data.GetSerializer(), data.GetRegistry(), \ + static_cast<Result(*) Signature>(&Class::Method), \ + __VA_ARGS__); \ + } + +#define LLDB_RECORD_STATIC_METHOD_NO_ARGS(Result, Class, Method) \ + lldb_private::repro::Recorder sb_recorder(LLVM_PRETTY_FUNCTION); \ + if (lldb_private::repro::InstrumentationData data = \ + LLDB_GET_INSTRUMENTATION_DATA()) { \ + sb_recorder.Record(data.GetSerializer(), data.GetRegistry(), \ + static_cast<Result (*)()>(&Class::Method)); \ + } + +#define LLDB_RECORD_RESULT(Result) sb_recorder.RecordResult(Result); + +/// The LLDB_RECORD_DUMMY macro is special because it doesn't actually record +/// anything. It's used to track API boundaries when we cannot record for +/// technical reasons. +#define LLDB_RECORD_DUMMY(Result, Class, Method, Signature, ...) \ + lldb_private::repro::Recorder sb_recorder(LLVM_PRETTY_FUNCTION, \ + stringify_args(__VA_ARGS__)); + +namespace lldb_private { +namespace repro { + +/// Mapping between serialized indices and their corresponding objects. +/// +/// This class is used during replay to map indices back to in-memory objects. +/// +/// When objects are constructed, they are added to this mapping using +/// AddObjectForIndex. +/// +/// When an object is passed to a function, its index is deserialized and +/// AddObjectForIndex returns the corresponding object. If there is no object +/// for the given index, a nullptr is returend. The latter is valid when custom +/// replay code is in place and the actual object is ignored. +class IndexToObject { +public: + /// Returns an object as a pointer for the given index or nullptr if not + /// present in the map. + template <typename T> T *GetObjectForIndex(unsigned idx) { + assert(idx != 0 && "Cannot get object for sentinel"); + void *object = GetObjectForIndexImpl(idx); + return static_cast<T *>(object); + } + + /// Adds a pointer to an object to the mapping for the given index. + template <typename T> void AddObjectForIndex(unsigned idx, T *object) { + AddObjectForIndexImpl( + idx, static_cast<void *>( + const_cast<typename std::remove_const<T>::type *>(object))); + } + + /// Adds a reference to an object to the mapping for the given index. + template <typename T> void AddObjectForIndex(unsigned idx, T &object) { + AddObjectForIndexImpl( + idx, static_cast<void *>( + const_cast<typename std::remove_const<T>::type *>(&object))); + } + +private: + /// Helper method that does the actual lookup. The void* result is later cast + /// by the caller. + void *GetObjectForIndexImpl(unsigned idx); + + /// Helper method that does the actual insertion. + void AddObjectForIndexImpl(unsigned idx, void *object); + + /// Keeps a mapping between indices and their corresponding object. + llvm::DenseMap<unsigned, void *> m_mapping; +}; + +/// We need to differentiate between pointers to fundamental and +/// non-fundamental types. See the corresponding Deserializer::Read method +/// for the reason why. +struct PointerTag {}; +struct ReferenceTag {}; +struct ValueTag {}; +struct FundamentalPointerTag {}; +struct FundamentalReferenceTag {}; + +/// Return the deserialization tag for the given type T. +template <class T> struct serializer_tag { typedef ValueTag type; }; +template <class T> struct serializer_tag<T *> { + typedef + typename std::conditional<std::is_fundamental<T>::value, + FundamentalPointerTag, PointerTag>::type type; +}; +template <class T> struct serializer_tag<T &> { + typedef typename std::conditional<std::is_fundamental<T>::value, + FundamentalReferenceTag, ReferenceTag>::type + type; +}; + +/// Deserializes data from a buffer. It is used to deserialize function indices +/// to replay, their arguments and return values. +/// +/// Fundamental types and strings are read by value. Objects are read by their +/// index, which get translated by the IndexToObject mapping maintained in +/// this class. +/// +/// Additional bookkeeping with regards to the IndexToObject is required to +/// deserialize objects. When a constructor is run or an object is returned by +/// value, we need to capture the object and add it to the index together with +/// its index. This is the job of HandleReplayResult(Void). +class Deserializer { +public: + Deserializer(llvm::StringRef buffer) : m_buffer(buffer) {} + + /// Returns true when the buffer has unread data. + bool HasData(unsigned size) { return size <= m_buffer.size(); } + + /// Deserialize and interpret value as T. + template <typename T> T Deserialize() { +#ifdef LLDB_REPRO_INSTR_TRACE + llvm::errs() << "Deserializing with " << LLVM_PRETTY_FUNCTION << "\n"; +#endif + return Read<T>(typename serializer_tag<T>::type()); + } + + /// Store the returned value in the index-to-object mapping. + template <typename T> void HandleReplayResult(const T &t) { + unsigned result = Deserialize<unsigned>(); + if (std::is_fundamental<T>::value) + return; + // We need to make a copy as the original object might go out of scope. + m_index_to_object.AddObjectForIndex(result, new T(t)); + } + + /// Store the returned value in the index-to-object mapping. + template <typename T> void HandleReplayResult(T *t) { + unsigned result = Deserialize<unsigned>(); + if (std::is_fundamental<T>::value) + return; + m_index_to_object.AddObjectForIndex(result, t); + } + + /// All returned types are recorded, even when the function returns a void. + /// The latter requires special handling. + void HandleReplayResultVoid() { + unsigned result = Deserialize<unsigned>(); + assert(result == 0); + (void)result; + } + +private: + template <typename T> T Read(ValueTag) { + assert(HasData(sizeof(T))); + T t; + std::memcpy(reinterpret_cast<char *>(&t), m_buffer.data(), sizeof(T)); + m_buffer = m_buffer.drop_front(sizeof(T)); + return t; + } + + template <typename T> T Read(PointerTag) { + typedef typename std::remove_pointer<T>::type UnderlyingT; + return m_index_to_object.template GetObjectForIndex<UnderlyingT>( + Deserialize<unsigned>()); + } + + template <typename T> T Read(ReferenceTag) { + typedef typename std::remove_reference<T>::type UnderlyingT; + // If this is a reference to a fundamental type we just read its value. + return *m_index_to_object.template GetObjectForIndex<UnderlyingT>( + Deserialize<unsigned>()); + } + + /// This method is used to parse references to fundamental types. Because + /// they're not recorded in the object table we have serialized their value. + /// We read its value, allocate a copy on the heap, and return a pointer to + /// the copy. + template <typename T> T Read(FundamentalPointerTag) { + typedef typename std::remove_pointer<T>::type UnderlyingT; + return new UnderlyingT(Deserialize<UnderlyingT>()); + } + + /// This method is used to parse references to fundamental types. Because + /// they're not recorded in the object table we have serialized their value. + /// We read its value, allocate a copy on the heap, and return a reference to + /// the copy. + template <typename T> T Read(FundamentalReferenceTag) { + // If this is a reference to a fundamental type we just read its value. + typedef typename std::remove_reference<T>::type UnderlyingT; + return *(new UnderlyingT(Deserialize<UnderlyingT>())); + } + + /// Mapping of indices to objects. + IndexToObject m_index_to_object; + + /// Buffer containing the serialized data. + llvm::StringRef m_buffer; +}; + +/// Partial specialization for C-style strings. We read the string value +/// instead of treating it as pointer. +template <> const char *Deserializer::Deserialize<const char *>(); +template <> char *Deserializer::Deserialize<char *>(); + +/// Helpers to auto-synthesize function replay code. It deserializes the replay +/// function's arguments one by one and finally calls the corresponding +/// function. +template <typename... Remaining> struct DeserializationHelper; + +template <typename Head, typename... Tail> +struct DeserializationHelper<Head, Tail...> { + template <typename Result, typename... Deserialized> struct deserialized { + static Result doit(Deserializer &deserializer, + Result (*f)(Deserialized..., Head, Tail...), + Deserialized... d) { + return DeserializationHelper<Tail...>:: + template deserialized<Result, Deserialized..., Head>::doit( + deserializer, f, d..., deserializer.Deserialize<Head>()); + } + }; +}; + +template <> struct DeserializationHelper<> { + template <typename Result, typename... Deserialized> struct deserialized { + static Result doit(Deserializer &deserializer, Result (*f)(Deserialized...), + Deserialized... d) { + return f(d...); + } + }; +}; + +/// The replayer interface. +struct Replayer { + virtual ~Replayer() {} + virtual void operator()(Deserializer &deserializer) const = 0; +}; + +/// The default replayer deserializes the arguments and calls the function. +template <typename Signature> struct DefaultReplayer; +template <typename Result, typename... Args> +struct DefaultReplayer<Result(Args...)> : public Replayer { + DefaultReplayer(Result (*f)(Args...)) : Replayer(), f(f) {} + + void operator()(Deserializer &deserializer) const override { + deserializer.HandleReplayResult( + DeserializationHelper<Args...>::template deserialized<Result>::doit( + deserializer, f)); + } + + Result (*f)(Args...); +}; + +/// Partial specialization for function returning a void type. It ignores the +/// (absent) return value. +template <typename... Args> +struct DefaultReplayer<void(Args...)> : public Replayer { + DefaultReplayer(void (*f)(Args...)) : Replayer(), f(f) {} + + void operator()(Deserializer &deserializer) const override { + DeserializationHelper<Args...>::template deserialized<void>::doit( + deserializer, f); + deserializer.HandleReplayResultVoid(); + } + + void (*f)(Args...); +}; + +/// The registry contains a unique mapping between functions and their ID. The +/// IDs can be serialized and deserialized to replay a function. Functions need +/// to be registered with the registry for this to work. +class Registry { +private: + struct SignatureStr { + SignatureStr(llvm::StringRef result = {}, llvm::StringRef scope = {}, + llvm::StringRef name = {}, llvm::StringRef args = {}) + : result(result), scope(scope), name(name), args(args) {} + + std::string ToString() const; + + llvm::StringRef result; + llvm::StringRef scope; + llvm::StringRef name; + llvm::StringRef args; + }; + +public: + Registry() = default; + virtual ~Registry() = default; + + /// Register a default replayer for a function. + template <typename Signature> + void Register(Signature *f, llvm::StringRef result = {}, + llvm::StringRef scope = {}, llvm::StringRef name = {}, + llvm::StringRef args = {}) { + DoRegister(uintptr_t(f), llvm::make_unique<DefaultReplayer<Signature>>(f), + SignatureStr(result, scope, name, args)); + } + + /// Register a replayer that invokes a custom function with the same + /// signature as the replayed function. + template <typename Signature> + void Register(Signature *f, Signature *g, llvm::StringRef result = {}, + llvm::StringRef scope = {}, llvm::StringRef name = {}, + llvm::StringRef args = {}) { + DoRegister(uintptr_t(f), llvm::make_unique<DefaultReplayer<Signature>>(g), + SignatureStr(result, scope, name, args)); + } + + /// Replay functions from a file. + bool Replay(const FileSpec &file); + + /// Replay functions from a buffer. + bool Replay(llvm::StringRef buffer); + + /// Returns the ID for a given function address. + unsigned GetID(uintptr_t addr); + +protected: + /// Register the given replayer for a function (and the ID mapping). + void DoRegister(uintptr_t RunID, std::unique_ptr<Replayer> replayer, + SignatureStr signature); + +private: + std::string GetSignature(unsigned id); + Replayer *GetReplayer(unsigned id); + + /// Mapping of function addresses to replayers and their ID. + std::map<uintptr_t, std::pair<std::unique_ptr<Replayer>, unsigned>> + m_replayers; + + /// Mapping of IDs to replayer instances. + std::map<unsigned, std::pair<Replayer *, SignatureStr>> m_ids; +}; + +/// To be used as the "Runtime ID" of a constructor. It also invokes the +/// constructor when called. +template <typename Signature> struct construct; +template <typename Class, typename... Args> struct construct<Class(Args...)> { + static Class *doit(Args... args) { return new Class(args...); } +}; + +/// To be used as the "Runtime ID" of a member function. It also invokes the +/// member function when called. +template <typename Signature> struct invoke; +template <typename Result, typename Class, typename... Args> +struct invoke<Result (Class::*)(Args...)> { + template <Result (Class::*m)(Args...)> struct method { + static Result doit(Class *c, Args... args) { return (c->*m)(args...); } + }; +}; + +template <typename Result, typename Class, typename... Args> +struct invoke<Result (Class::*)(Args...) const> { + template <Result (Class::*m)(Args...) const> struct method_const { + static Result doit(Class *c, Args... args) { return (c->*m)(args...); } + }; +}; + +template <typename Class, typename... Args> +struct invoke<void (Class::*)(Args...)> { + template <void (Class::*m)(Args...)> struct method { + static void doit(Class *c, Args... args) { (c->*m)(args...); } + }; +}; + +/// Maps an object to an index for serialization. Indices are unique and +/// incremented for every new object. +/// +/// Indices start at 1 in order to differentiate with an invalid index (0) in +/// the serialized buffer. +class ObjectToIndex { +public: + template <typename T> unsigned GetIndexForObject(T *t) { + return GetIndexForObjectImpl(static_cast<const void *>(t)); + } + +private: + unsigned GetIndexForObjectImpl(const void *object); + + llvm::DenseMap<const void *, unsigned> m_mapping; +}; + +/// Serializes functions, their arguments and their return type to a stream. +class Serializer { +public: + Serializer(llvm::raw_ostream &stream = llvm::outs()) : m_stream(stream) {} + + /// Recursively serialize all the given arguments. + template <typename Head, typename... Tail> + void SerializeAll(const Head &head, const Tail &... tail) { + Serialize(head); + SerializeAll(tail...); + } + + void SerializeAll() { + m_stream.flush(); + } + +private: + /// Serialize pointers. We need to differentiate between pointers to + /// fundamental types (in which case we serialize its value) and pointer to + /// objects (in which case we serialize their index). + template <typename T> void Serialize(T *t) { + if (std::is_fundamental<T>::value) { + Serialize(*t); + } else { + unsigned idx = m_tracker.GetIndexForObject(t); + Serialize(idx); + } + } + + /// Serialize references. We need to differentiate between references to + /// fundamental types (in which case we serialize its value) and references + /// to objects (in which case we serialize their index). + template <typename T> void Serialize(T &t) { + if (std::is_fundamental<T>::value) { + m_stream.write(reinterpret_cast<const char *>(&t), sizeof(T)); + } else { + unsigned idx = m_tracker.GetIndexForObject(&t); + Serialize(idx); + } + } + + void Serialize(void *v) { + // FIXME: Support void* + llvm_unreachable("void* is currently unsupported."); + } + + void Serialize(const char *t) { + m_stream << t; + m_stream.write(0x0); + } + + /// Serialization stream. + llvm::raw_ostream &m_stream; + + /// Mapping of objects to indices. + ObjectToIndex m_tracker; +}; + +class InstrumentationData { +public: + InstrumentationData() : m_serializer(nullptr), m_registry(nullptr){}; + InstrumentationData(Serializer &serializer, Registry ®istry) + : m_serializer(&serializer), m_registry(®istry){}; + + Serializer &GetSerializer() { return *m_serializer; } + Registry &GetRegistry() { return *m_registry; } + + operator bool() { return m_serializer != nullptr && m_registry != nullptr; } + +private: + Serializer *m_serializer; + Registry *m_registry; +}; + +/// RAII object that records function invocations and their return value. +/// +/// API calls are only captured when the API boundary is crossed. Once we're in +/// the API layer, and another API function is called, it doesn't need to be +/// recorded. +/// +/// When a call is recored, its result is always recorded as well, even if the +/// function returns a void. For functions that return by value, RecordResult +/// should be used. Otherwise a sentinel value (0) will be serialized. +/// +/// Because of the functional overlap between logging and recording API calls, +/// this class is also used for logging. +class Recorder { +public: + Recorder(llvm::StringRef pretty_func = {}, std::string &&pretty_args = {}); + ~Recorder(); + + /// Records a single function call. + template <typename Result, typename... FArgs, typename... RArgs> + void Record(Serializer &serializer, Registry ®istry, Result (*f)(FArgs...), + const RArgs &... args) { + m_serializer = &serializer; + if (!ShouldCapture()) + return; + + unsigned id = registry.GetID(uintptr_t(f)); + +#ifdef LLDB_REPRO_INSTR_TRACE + Log(id); +#endif + + serializer.SerializeAll(id); + serializer.SerializeAll(args...); + + if (std::is_class<typename std::remove_pointer< + typename std::remove_reference<Result>::type>::type>::value) { + m_result_recorded = false; + } else { + serializer.SerializeAll(0); + m_result_recorded = true; + } + } + + /// Records a single function call. + template <typename... Args> + void Record(Serializer &serializer, Registry ®istry, void (*f)(Args...), + const Args &... args) { + m_serializer = &serializer; + if (!ShouldCapture()) + return; + + unsigned id = registry.GetID(uintptr_t(f)); + +#ifdef LLDB_REPRO_INSTR_TRACE + Log(id); +#endif + + serializer.SerializeAll(id); + serializer.SerializeAll(args...); + + // Record result. + serializer.SerializeAll(0); + m_result_recorded = true; + } + + /// Record the result of a function call. + template <typename Result> Result RecordResult(Result &&r) { + UpdateBoundary(); + if (m_serializer && ShouldCapture()) { + assert(!m_result_recorded); + m_serializer->SerializeAll(r); + m_result_recorded = true; + } + return std::forward<Result>(r); + } + +private: + void UpdateBoundary() { + if (m_local_boundary) + g_global_boundary = false; + } + + bool ShouldCapture() { return m_local_boundary; } + +#ifdef LLDB_REPRO_INSTR_TRACE + void Log(unsigned id) { + llvm::errs() << "Recording " << id << ": " << m_pretty_func << " (" + << m_pretty_args << ")\n"; + } +#endif + + Serializer *m_serializer; + + /// Pretty function for logging. + llvm::StringRef m_pretty_func; + std::string m_pretty_args; + + /// Whether this function call was the one crossing the API boundary. + bool m_local_boundary; + + /// Whether the return value was recorded explicitly. + bool m_result_recorded; + + /// Whether we're currently across the API boundary. + static bool g_global_boundary; +}; + +} // namespace repro +} // namespace lldb_private + +#endif // LLDB_UTILITY_REPRODUCER_INSTRUMENTATION_H diff --git a/include/lldb/Utility/Scalar.h b/include/lldb/Utility/Scalar.h index c23b2f8be25e2..62ee9f666e894 100644 --- a/include/lldb/Utility/Scalar.h +++ b/include/lldb/Utility/Scalar.h @@ -1,9 +1,8 @@ //===-- Scalar.h ------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -13,6 +12,7 @@ #include "lldb/Utility/Status.h" #include "lldb/lldb-enumerations.h" #include "lldb/lldb-private-types.h" +#include "lldb/Utility/LLDBAssert.h" #include "llvm/ADT/APFloat.h" #include "llvm/ADT/APInt.h" #include <cstddef> @@ -27,15 +27,15 @@ class Stream; #define BITWIDTH_INT128 128 #define NUM_OF_WORDS_INT256 4 #define BITWIDTH_INT256 256 +#define NUM_OF_WORDS_INT512 8 +#define BITWIDTH_INT512 512 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. -//---------------------------------------------------------------------- class Scalar { public: enum Type { @@ -50,31 +50,32 @@ public: e_uint128, e_sint256, e_uint256, + e_sint512, + e_uint512, e_float, e_double, e_long_double }; - //------------------------------------------------------------------ // Constructors and Destructors - //------------------------------------------------------------------ Scalar(); - Scalar(int v) : m_type(e_sint), m_float((float)0) { + Scalar(int v) : m_type(e_sint), m_float(static_cast<float>(0)) { m_integer = llvm::APInt(sizeof(int) * 8, v, true); } - Scalar(unsigned int v) : m_type(e_uint), m_float((float)0) { + Scalar(unsigned int v) : m_type(e_uint), m_float(static_cast<float>(0)) { m_integer = llvm::APInt(sizeof(int) * 8, v); } - Scalar(long v) : m_type(e_slong), m_float((float)0) { + Scalar(long v) : m_type(e_slong), m_float(static_cast<float>(0)) { m_integer = llvm::APInt(sizeof(long) * 8, v, true); } - Scalar(unsigned long v) : m_type(e_ulong), m_float((float)0) { + Scalar(unsigned long v) : m_type(e_ulong), m_float(static_cast<float>(0)) { m_integer = llvm::APInt(sizeof(long) * 8, v); } - Scalar(long long v) : m_type(e_slonglong), m_float((float)0) { + Scalar(long long v) : m_type(e_slonglong), m_float(static_cast<float>(0)) { m_integer = llvm::APInt(sizeof(long long) * 8, v, true); } - Scalar(unsigned long long v) : m_type(e_ulonglong), m_float((float)0) { + Scalar(unsigned long long v) + : m_type(e_ulonglong), m_float(static_cast<float>(0)) { m_integer = llvm::APInt(sizeof(long long) * 8, v); } Scalar(float v) : m_type(e_float), m_float(v) { m_float = llvm::APFloat(v); } @@ -82,48 +83,42 @@ public: m_float = llvm::APFloat(v); } Scalar(long double v, bool ieee_quad) - : m_type(e_long_double), m_float((float)0), m_ieee_quad(ieee_quad) { + : m_type(e_long_double), m_float(static_cast<float>(0)), + m_ieee_quad(ieee_quad) { if (ieee_quad) - m_float = llvm::APFloat(llvm::APFloat::IEEEquad(), - llvm::APInt(BITWIDTH_INT128, NUM_OF_WORDS_INT128, - ((type128 *)&v)->x)); + m_float = + llvm::APFloat(llvm::APFloat::IEEEquad(), + llvm::APInt(BITWIDTH_INT128, NUM_OF_WORDS_INT128, + (reinterpret_cast<type128 *>(&v))->x)); else - m_float = llvm::APFloat(llvm::APFloat::x87DoubleExtended(), - llvm::APInt(BITWIDTH_INT128, NUM_OF_WORDS_INT128, - ((type128 *)&v)->x)); + m_float = + llvm::APFloat(llvm::APFloat::x87DoubleExtended(), + llvm::APInt(BITWIDTH_INT128, NUM_OF_WORDS_INT128, + (reinterpret_cast<type128 *>(&v))->x)); } - Scalar(llvm::APInt v) : m_type(), m_float((float)0) { + Scalar(llvm::APInt v) : m_type(), m_float(static_cast<float>(0)) { m_integer = llvm::APInt(v); switch (m_integer.getBitWidth()) { case 8: case 16: case 32: - if (m_integer.isSignedIntN(sizeof(sint_t) * 8)) - m_type = e_sint; - else - m_type = e_uint; - break; + m_type = e_sint; + return; case 64: - if (m_integer.isSignedIntN(sizeof(slonglong_t) * 8)) - m_type = e_slonglong; - else - m_type = e_ulonglong; - break; + m_type = e_slonglong; + return; case 128: - if (m_integer.isSignedIntN(BITWIDTH_INT128)) - m_type = e_sint128; - else - m_type = e_uint128; - break; + m_type = e_sint128; + return; case 256: - if (m_integer.isSignedIntN(BITWIDTH_INT256)) - m_type = e_sint256; - else - m_type = e_uint256; - break; + m_type = e_sint256; + return; + case 512: + m_type = e_sint512; + return; } + lldbassert(false && "unsupported bitwidth"); } - Scalar(const Scalar &rhs); // Scalar(const RegisterValue& reg_value); virtual ~Scalar(); @@ -175,12 +170,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. - //---------------------------------------------------------------------- Scalar &operator=(const int i); Scalar &operator=(unsigned int v); Scalar &operator=(long v); @@ -197,41 +190,29 @@ public: Scalar &operator>>=(const Scalar &rhs); // Shift right (arithmetic) Scalar &operator&=(const Scalar &rhs); - //---------------------------------------------------------------------- // 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. - //---------------------------------------------------------------------- bool AbsoluteValue(); // Returns true on success - //---------------------------------------------------------------------- // 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. - //---------------------------------------------------------------------- bool OnesComplement(); // Returns true on success - //---------------------------------------------------------------------- // Access the type of the current value. - //---------------------------------------------------------------------- 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. - //---------------------------------------------------------------------- int SInt(int fail_value = 0) const; unsigned char UChar(unsigned char fail_value = 0) const; @@ -256,10 +237,6 @@ public: llvm::APInt UInt128(const llvm::APInt &fail_value) const; - llvm::APInt SInt256(llvm::APInt &fail_value) const; - - llvm::APInt UInt256(const llvm::APInt &fail_value) const; - float Float(float fail_value = 0.0f) const; double Double(double fail_value = 0.0) const; @@ -279,7 +256,9 @@ public: if (total_byte_size == 8) return true; - const uint64_t max = ((uint64_t)1 << (uint64_t)(total_byte_size * 8)) - 1; + const uint64_t max = (static_cast<uint64_t>(1) + << static_cast<uint64_t>(total_byte_size * 8)) - + 1; return uval64 <= max; } @@ -290,7 +269,9 @@ public: if (total_byte_size == 8) return true; - const int64_t max = ((int64_t)1 << (uint64_t)(total_byte_size * 8 - 1)) - 1; + const int64_t max = (static_cast<int64_t>(1) + << static_cast<uint64_t>(total_byte_size * 8 - 1)) - + 1; const int64_t min = ~(max); return min <= sval64 && sval64 <= max; } @@ -310,9 +291,7 @@ protected: typedef double double_t; typedef long double long_double_t; - //------------------------------------------------------------------ // Classes that inherit from Scalar can see and modify these - //------------------------------------------------------------------ Scalar::Type m_type; llvm::APInt m_integer; llvm::APFloat m_float; @@ -337,7 +316,6 @@ private: friend bool operator>=(const Scalar &lhs, const Scalar &rhs); }; -//---------------------------------------------------------------------- // Split out the operators into a format where the compiler will be able to // implicitly convert numbers into Scalar objects. // @@ -351,7 +329,6 @@ private: // Item 19 of "Effective C++ Second Edition" by Scott Meyers // Differentiate among members functions, non-member functions, and // friend functions -//---------------------------------------------------------------------- const Scalar operator+(const Scalar &lhs, const Scalar &rhs); const Scalar operator-(const Scalar &lhs, const Scalar &rhs); const Scalar operator/(const Scalar &lhs, const Scalar &rhs); @@ -369,6 +346,8 @@ bool operator<=(const Scalar &lhs, const Scalar &rhs); bool operator>(const Scalar &lhs, const Scalar &rhs); bool operator>=(const Scalar &lhs, const Scalar &rhs); +llvm::raw_ostream &operator<<(llvm::raw_ostream &os, const Scalar &scalar); + } // namespace lldb_private #endif // LLDB_UTILITY_SCALAR_H diff --git a/include/lldb/Utility/SelectHelper.h b/include/lldb/Utility/SelectHelper.h index f2dac7cf53daf..ec37f194d329b 100644 --- a/include/lldb/Utility/SelectHelper.h +++ b/include/lldb/Utility/SelectHelper.h @@ -1,9 +1,8 @@ //===-- SelectHelper.h ------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// diff --git a/include/lldb/Utility/SharedCluster.h b/include/lldb/Utility/SharedCluster.h index 61b9804ad3356..71bbb334cff38 100644 --- a/include/lldb/Utility/SharedCluster.h +++ b/include/lldb/Utility/SharedCluster.h @@ -1,9 +1,8 @@ //===------------------SharedCluster.h --------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// diff --git a/include/lldb/Utility/SharingPtr.h b/include/lldb/Utility/SharingPtr.h index 7eaa049f4d18b..e4ab3d27a69b7 100644 --- a/include/lldb/Utility/SharingPtr.h +++ b/include/lldb/Utility/SharingPtr.h @@ -1,9 +1,8 @@ //===---------------------SharingPtr.h --------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -36,8 +35,8 @@ namespace lldb_private { namespace imp { class shared_count { - shared_count(const shared_count &); - shared_count &operator=(const shared_count &); + shared_count(const shared_count &) = delete; + shared_count &operator=(const shared_count &) = delete; public: explicit shared_count(long refs = 0) : shared_owners_(refs) {} @@ -67,10 +66,8 @@ public: private: void on_zero_shared() override; - // Outlaw copy constructor and assignment operator to keep effective C++ - // warnings down to a minimum - shared_ptr_pointer(const shared_ptr_pointer &); - shared_ptr_pointer &operator=(const shared_ptr_pointer &); + shared_ptr_pointer(const shared_ptr_pointer &) = delete; + shared_ptr_pointer &operator=(const shared_ptr_pointer &) = delete; }; template <class T> void shared_ptr_pointer<T>::on_zero_shared() { @@ -456,8 +453,8 @@ protected: friend class IntrusiveSharingPtr<T>; private: - ReferenceCountedBase(const ReferenceCountedBase &); - ReferenceCountedBase &operator=(const ReferenceCountedBase &); + ReferenceCountedBase(const ReferenceCountedBase &) = delete; + ReferenceCountedBase &operator=(const ReferenceCountedBase &) = delete; }; template <class T> void lldb_private::ReferenceCountedBase<T>::add_shared() { diff --git a/include/lldb/Utility/State.h b/include/lldb/Utility/State.h index 7b3c0f1c17ab3..9ff755f14f635 100644 --- a/include/lldb/Utility/State.h +++ b/include/lldb/Utility/State.h @@ -1,9 +1,8 @@ //===-- State.h -------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -18,53 +17,47 @@ namespace lldb_private { -//------------------------------------------------------------------ /// Converts a StateType to a C string. /// -/// @param[in] state +/// \param[in] state /// The StateType object to convert. /// -/// @return +/// \return /// A NULL terminated C string that describes \a state. The /// returned string comes from constant string buffers and does /// not need to be freed. -//------------------------------------------------------------------ const char *StateAsCString(lldb::StateType state); -//------------------------------------------------------------------ /// Check if a state represents a state where the process or thread /// is running. /// -/// @param[in] state +/// \param[in] state /// The StateType enumeration value /// -/// @return +/// \return /// \b true if the state represents a process or thread state /// where the process or thread is running, \b false otherwise. -//------------------------------------------------------------------ bool StateIsRunningState(lldb::StateType state); -//------------------------------------------------------------------ /// Check if a state represents a state where the process or thread /// is stopped. Stopped can mean stopped when the process is still /// around, or stopped when the process has exited or doesn't exist /// yet. The \a must_exist argument tells us which of these cases is /// desired. /// -/// @param[in] state +/// \param[in] state /// The StateType enumeration value /// -/// @param[in] must_exist +/// \param[in] must_exist /// A boolean that indicates the thread must also be alive /// so states like unloaded or exited won't return true. /// -/// @return +/// \return /// \b true if the state represents a process or thread state /// where the process or thread is stopped. If \a must_exist is /// \b true, then the process can't be exited or unloaded, /// otherwise exited and unloaded or other states where the /// process no longer exists are considered to be stopped. -//------------------------------------------------------------------ bool StateIsStoppedState(lldb::StateType state, bool must_exist); const char *GetPermissionsAsCString(uint32_t permissions); diff --git a/include/lldb/Utility/Status.h b/include/lldb/Utility/Status.h index 9395ea86090bc..ae730b90dffe5 100644 --- a/include/lldb/Utility/Status.h +++ b/include/lldb/Utility/Status.h @@ -1,9 +1,8 @@ //===-- Status.h ------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -27,8 +26,7 @@ class raw_ostream; namespace lldb_private { -//---------------------------------------------------------------------- -/// @class Status Status.h "lldb/Utility/Status.h" 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 @@ -43,26 +41,21 @@ namespace lldb_private { /// 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. - //------------------------------------------------------------------ typedef uint32_t ValueType; - //------------------------------------------------------------------ /// Default constructor. /// /// Initialize the error object with a generic success value. /// - /// @param[in] err + /// \param[in] err /// An error code. /// - /// @param[in] type + /// \param[in] type /// The type for \a err. - //------------------------------------------------------------------ Status(); explicit Status(ValueType err, @@ -73,16 +66,13 @@ public: explicit Status(const char *format, ...) __attribute__((format(printf, 2, 3))); - Status(const Status &rhs); - //------------------------------------------------------------------ /// Assignment operator. /// - /// @param[in] err + /// \param[in] err /// An error code. /// - /// @return + /// \return /// A const reference to this object. - //------------------------------------------------------------------ const Status &operator=(const Status &rhs); ~Status(); @@ -92,7 +82,6 @@ public: const Status &operator=(llvm::Error error); llvm::Error ToError() const; - //------------------------------------------------------------------ /// Get the error string associated with the current error. // /// Gets the error value as a NULL terminated C string. The error string @@ -100,55 +89,44 @@ public: /// 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 + /// \return /// The error as a NULL terminated C string value if the error /// is valid and is able to be converted to a string value, /// NULL otherwise. - //------------------------------------------------------------------ const char *AsCString(const char *default_error_str = "unknown error") const; - //------------------------------------------------------------------ /// Clear the object state. /// /// Reverts the state of this object to contain a generic success value and /// frees any cached error string value. - //------------------------------------------------------------------ void Clear(); - //------------------------------------------------------------------ /// Test for error condition. /// - /// @return + /// \return /// \b true if this object contains an error, \b false /// otherwise. - //------------------------------------------------------------------ bool Fail() const; - //------------------------------------------------------------------ /// Access the error value. /// - /// @return + /// \return /// The error value. - //------------------------------------------------------------------ ValueType GetError() const; - //------------------------------------------------------------------ /// Access the error type. /// - /// @return + /// \return /// The error type enumeration value. - //------------------------------------------------------------------ lldb::ErrorType GetType() const; - //------------------------------------------------------------------ /// Set accessor from a kern_return_t. /// /// Set accesssor for the error value to \a err and the error type to \c /// MachKernel. /// - /// @param[in] err + /// \param[in] err /// A mach error code. - //------------------------------------------------------------------ void SetMachError(uint32_t err); void SetExpressionError(lldb::ExpressionResults, const char *mssg); @@ -156,37 +134,30 @@ public: int SetExpressionErrorWithFormat(lldb::ExpressionResults, const char *format, ...) __attribute__((format(printf, 3, 4))); - //------------------------------------------------------------------ /// Set accesssor with an error value and type. /// /// Set accesssor for the error value to \a err and the error type to \a /// type. /// - /// @param[in] err + /// \param[in] err /// A mach error code. /// - /// @param[in] type + /// \param[in] type /// The type for \a err. - //------------------------------------------------------------------ void SetError(ValueType err, lldb::ErrorType type); - //------------------------------------------------------------------ /// Set the current error to errno. /// /// 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. - //------------------------------------------------------------------ void SetErrorToGenericError(); - //------------------------------------------------------------------ /// Set the current error string to \a err_str. /// /// Set accessor for the error string value for a generic errors, or to @@ -196,17 +167,14 @@ public: /// will remain until the error value is cleared or a new error value/type /// is assigned. /// - /// @param err_str + /// \param err_str /// The new custom error string to copy and cache. - //------------------------------------------------------------------ void SetErrorString(llvm::StringRef err_str); - //------------------------------------------------------------------ /// Set the current error string to a formatted error string. /// - /// @param format + /// \param format /// A printf style format string - //------------------------------------------------------------------ int SetErrorStringWithFormat(const char *format, ...) __attribute__((format(printf, 2, 3))); @@ -217,34 +185,28 @@ public: SetErrorString(llvm::formatv(format, std::forward<Args>(args)...).str()); } - //------------------------------------------------------------------ /// Test for success condition. /// /// Returns true if the error code in this object is considered a successful /// return value. /// - /// @return + /// \return /// \b true if this object contains an value that describes /// success (non-erro), \b false otherwise. - //------------------------------------------------------------------ bool Success() const; - //------------------------------------------------------------------ /// 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. /// - /// @return + /// \return /// \b true if this object contains an value that describes /// failure due to interrupt, \b false otherwise. - //------------------------------------------------------------------ bool WasInterrupted() const; protected: - //------------------------------------------------------------------ /// Member variables - //------------------------------------------------------------------ ValueType m_code; ///< Status code as an integer value. lldb::ErrorType m_type; ///< The type of the above error code. mutable std::string m_string; ///< A string representation of the error code. diff --git a/include/lldb/Utility/Stream.h b/include/lldb/Utility/Stream.h index bd4283edf8a9e..b24d4e4571775 100644 --- a/include/lldb/Utility/Stream.h +++ b/include/lldb/Utility/Stream.h @@ -1,9 +1,8 @@ //===-- Stream.h ------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -24,15 +23,11 @@ namespace lldb_private { -//---------------------------------------------------------------------- -/// @class Stream Stream.h "lldb/Utility/Stream.h" +/// \class Stream Stream.h "lldb/Utility/Stream.h" /// A stream class that can stream formatted output to a file. -//---------------------------------------------------------------------- class Stream { public: - //------------------------------------------------------------------ /// \a m_flags bit values. - //------------------------------------------------------------------ enum { eBinary = (1 << 0) ///< Get and put data as binary instead of as the default /// string mode. @@ -40,11 +35,11 @@ public: /// Utility class for counting the bytes that were written to a stream in a /// certain time span. - /// @example + /// \example /// ByteDelta delta(*this); /// WriteDataToStream("foo"); /// return *delta; - /// @endcode + /// \endcode class ByteDelta { Stream *m_stream; /// Bytes we have written so far when ByteDelta was created. @@ -57,19 +52,15 @@ public: size_t operator*() const { return m_stream->GetWrittenBytes() - m_start; } }; - //------------------------------------------------------------------ /// 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. - //------------------------------------------------------------------ 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. /// - //------------------------------------------------------------------ Stream(); // FIXME: Streams should not be copyable. @@ -83,37 +74,29 @@ public: return *this; } - //------------------------------------------------------------------ /// Destructor - //------------------------------------------------------------------ virtual ~Stream(); - //------------------------------------------------------------------ // Subclasses must override these methods - //------------------------------------------------------------------ - //------------------------------------------------------------------ /// Flush the stream. /// /// 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. /// - /// @param[in] src + /// \param[in] src /// A buffer containing at least \a src_len bytes of data. /// - /// @param[in] src_len + /// \param[in] src_len /// A number of bytes to append to the stream. /// - /// @return + /// \return /// The number of bytes that were appended to the stream. - //------------------------------------------------------------------ size_t Write(const void *src, size_t src_len) { size_t appended_byte_count = WriteImpl(src, src_len); m_bytes_written += appended_byte_count; @@ -122,50 +105,42 @@ public: size_t GetWrittenBytes() const { return m_bytes_written; } - //------------------------------------------------------------------ // Member functions - //------------------------------------------------------------------ size_t PutChar(char ch); - //------------------------------------------------------------------ /// Set the byte_order value. /// /// Sets the byte order of the data to extract. Extracted values will be /// swapped if necessary when decoding. /// - /// @param[in] byte_order + /// \param[in] byte_order /// The byte order value to use when extracting data. /// - /// @return + /// \return /// The old byte order value. - //------------------------------------------------------------------ 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. /// - /// @param[in] format + /// \param[in] format /// A printf style format string. /// - /// @param[in] ... + /// \param[in] ... /// Any additional arguments needed for the printf format string. /// - /// @return + /// \return /// The number of bytes that were appended to the stream. - //------------------------------------------------------------------ size_t PrintfAsRawHex8(const char *format, ...) __attribute__((__format__(__printf__, 2, 3))); - //------------------------------------------------------------------ /// Append an uint8_t value in the hexadecimal format to the stream. /// - /// @param[in] uvalue + /// \param[in] uvalue /// The value to append. /// - /// @return + /// \return /// The number of bytes that were appended to the stream. - //------------------------------------------------------------------ size_t PutHex8(uint8_t uvalue); size_t PutNHex8(size_t n, uint8_t uvalue); @@ -204,292 +179,242 @@ public: lldb::ByteOrder src_byte_order = lldb::eByteOrderInvalid, lldb::ByteOrder dst_byte_order = lldb::eByteOrderInvalid); - size_t PutCStringAsRawHex8(const char *s); + size_t PutStringAsRawHex8(llvm::StringRef s); - //------------------------------------------------------------------ /// Output a NULL terminated C string \a cstr to the stream \a s. /// - /// @param[in] cstr + /// \param[in] cstr /// A NULL terminated C string. /// - /// @return + /// \return /// A reference to this class so multiple things can be streamed /// in one statement. - //------------------------------------------------------------------ Stream &operator<<(const char *cstr); Stream &operator<<(llvm::StringRef str); - //------------------------------------------------------------------ /// Output a pointer value \a p to the stream \a s. /// - /// @param[in] p + /// \param[in] p /// A void pointer. /// - /// @return + /// \return /// A reference to this class so multiple things can be streamed /// in one statement. - //------------------------------------------------------------------ Stream &operator<<(const void *p); - //------------------------------------------------------------------ /// Output a character \a ch to the stream \a s. /// - /// @param[in] ch + /// \param[in] ch /// A printable character value. /// - /// @return + /// \return /// A reference to this class so multiple things can be streamed /// in one statement. - //------------------------------------------------------------------ Stream &operator<<(char ch); - //------------------------------------------------------------------ /// Output a uint8_t \a uval to the stream \a s. /// - /// @param[in] uval + /// \param[in] uval /// A uint8_t value. /// - /// @return + /// \return /// A reference to this class so multiple things can be streamed /// in one statement. - //------------------------------------------------------------------ Stream &operator<<(uint8_t uval); - //------------------------------------------------------------------ /// Output a uint16_t \a uval to the stream \a s. /// - /// @param[in] uval + /// \param[in] uval /// A uint16_t value. /// - /// @return + /// \return /// A reference to this class so multiple things can be streamed /// in one statement. - //------------------------------------------------------------------ Stream &operator<<(uint16_t uval); - //------------------------------------------------------------------ /// Output a uint32_t \a uval to the stream \a s. /// - /// @param[in] uval + /// \param[in] uval /// A uint32_t value. /// - /// @return + /// \return /// A reference to this class so multiple things can be streamed /// in one statement. - //------------------------------------------------------------------ Stream &operator<<(uint32_t uval); - //------------------------------------------------------------------ /// Output a uint64_t \a uval to the stream \a s. /// - /// @param[in] uval + /// \param[in] uval /// A uint64_t value. /// - /// @return + /// \return /// A reference to this class so multiple things can be streamed /// in one statement. - //------------------------------------------------------------------ Stream &operator<<(uint64_t uval); - //------------------------------------------------------------------ /// Output a int8_t \a sval to the stream \a s. /// - /// @param[in] sval + /// \param[in] sval /// A int8_t value. /// - /// @return + /// \return /// A reference to this class so multiple things can be streamed /// in one statement. - //------------------------------------------------------------------ Stream &operator<<(int8_t sval); - //------------------------------------------------------------------ /// Output a int16_t \a sval to the stream \a s. /// - /// @param[in] sval + /// \param[in] sval /// A int16_t value. /// - /// @return + /// \return /// A reference to this class so multiple things can be streamed /// in one statement. - //------------------------------------------------------------------ Stream &operator<<(int16_t sval); - //------------------------------------------------------------------ /// Output a int32_t \a sval to the stream \a s. /// - /// @param[in] sval + /// \param[in] sval /// A int32_t value. /// - /// @return + /// \return /// A reference to this class so multiple things can be streamed /// in one statement. - //------------------------------------------------------------------ Stream &operator<<(int32_t sval); - //------------------------------------------------------------------ /// Output a int64_t \a sval to the stream \a s. /// - /// @param[in] sval + /// \param[in] sval /// A int64_t value. /// - /// @return + /// \return /// A reference to this class so multiple things can be streamed /// in one statement. - //------------------------------------------------------------------ Stream &operator<<(int64_t sval); - //------------------------------------------------------------------ /// Output an address value to this stream. /// /// Put an address \a addr out to the stream with optional \a prefix and \a /// suffix strings. /// - /// @param[in] addr + /// \param[in] addr /// An address value. /// - /// @param[in] addr_size + /// \param[in] addr_size /// Size in bytes of the address, used for formatting. /// - /// @param[in] prefix + /// \param[in] prefix /// A prefix C string. If nullptr, no prefix will be output. /// - /// @param[in] suffix + /// \param[in] suffix /// A suffix C string. If nullptr, no suffix will be output. - //------------------------------------------------------------------ void Address(uint64_t addr, uint32_t addr_size, const char *prefix = nullptr, const char *suffix = nullptr); - //------------------------------------------------------------------ /// 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. /// - /// @param[in] lo_addr + /// \param[in] lo_addr /// The start address of the address range. /// - /// @param[in] hi_addr + /// \param[in] hi_addr /// The end address of the address range. /// - /// @param[in] addr_size + /// \param[in] addr_size /// Size in bytes of the address, used for formatting. /// - /// @param[in] prefix + /// \param[in] prefix /// A prefix C string. If nullptr, no prefix will be output. /// - /// @param[in] suffix + /// \param[in] suffix /// A suffix C string. If nullptr, no suffix will be output. - //------------------------------------------------------------------ void AddressRange(uint64_t lo_addr, uint64_t hi_addr, uint32_t addr_size, const char *prefix = nullptr, const char *suffix = nullptr); - //------------------------------------------------------------------ /// Output a C string to the stream. /// /// Print a C string \a cstr to the stream. /// - /// @param[in] cstr + /// \param[in] cstr /// The string to be output to the stream. - //------------------------------------------------------------------ size_t PutCString(llvm::StringRef cstr); - //------------------------------------------------------------------ /// Output and End of Line character to the stream. - //------------------------------------------------------------------ size_t EOL(); - //------------------------------------------------------------------ /// Get the address size in bytes. /// - /// @return + /// \return /// The size of an address in bytes that is used when outputting /// address and pointer values to the stream. - //------------------------------------------------------------------ uint32_t GetAddressByteSize() const; - //------------------------------------------------------------------ /// The flags accessor. /// - /// @return + /// \return /// A reference to the Flags member variable. - //------------------------------------------------------------------ Flags &GetFlags(); - //------------------------------------------------------------------ /// The flags const accessor. /// - /// @return + /// \return /// A const reference to the Flags member variable. - //------------------------------------------------------------------ const Flags &GetFlags() const; - //------------------------------------------------------------------ //// The byte order accessor. //// - //// @return + //// \return //// The byte order. - //------------------------------------------------------------------ lldb::ByteOrder GetByteOrder() const; - //------------------------------------------------------------------ /// Get the current indentation level. /// - /// @return + /// \return /// The current indentation level as an integer. - //------------------------------------------------------------------ int GetIndentLevel() const; - //------------------------------------------------------------------ /// 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. /// - /// @param[in] s + /// \param[in] s /// A C string to print following the indentation. If nullptr, just /// output the indentation characters. - //------------------------------------------------------------------ size_t Indent(const char *s = nullptr); size_t Indent(llvm::StringRef s); - //------------------------------------------------------------------ /// Decrement the current indentation level. - //------------------------------------------------------------------ void IndentLess(int amount = 2); - //------------------------------------------------------------------ /// Increment the current indentation level. - //------------------------------------------------------------------ void IndentMore(int amount = 2); - //------------------------------------------------------------------ /// Output an offset value. /// /// Put an offset \a uval out to the stream using the printf format in \a /// format. /// - /// @param[in] offset + /// \param[in] offset /// The offset value. /// - /// @param[in] format + /// \param[in] format /// The printf style format to use when outputting the offset. - //------------------------------------------------------------------ void Offset(uint32_t offset, const char *format = "0x%8.8x: "); - //------------------------------------------------------------------ /// Output printf formatted output to the stream. /// /// Print some formatted output to the stream. /// - /// @param[in] format + /// \param[in] format /// A printf style format string. /// - /// @param[in] ... + /// \param[in] ... /// Variable arguments that are needed for the printf style /// format string \a format. - //------------------------------------------------------------------ size_t Printf(const char *format, ...) __attribute__((format(printf, 2, 3))); size_t PrintfVarArg(const char *format, va_list args); @@ -498,70 +423,56 @@ public: PutCString(llvm::formatv(format, std::forward<Args>(args)...).str()); } - //------------------------------------------------------------------ /// 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. /// - /// @param[in] cstr + /// \param[in] cstr /// A NULL terminated C string value. /// - /// @param[in] format + /// \param[in] format /// The optional C string format that can be overridden. - //------------------------------------------------------------------ void QuotedCString(const char *cstr, const char *format = "\"%s\""); - //------------------------------------------------------------------ /// Set the address size in bytes. /// - /// @param[in] addr_size + /// \param[in] addr_size /// The new size in bytes of an address to use when outputting /// address and pointer values. - //------------------------------------------------------------------ void SetAddressByteSize(uint32_t addr_size); - //------------------------------------------------------------------ /// Set the current indentation level. /// - /// @param[in] level + /// \param[in] level /// The new indentation level. - //------------------------------------------------------------------ void SetIndentLevel(int level); - //------------------------------------------------------------------ /// Output a SLEB128 number to the stream. /// /// Put an SLEB128 \a uval out to the stream using the printf format in \a /// format. /// - /// @param[in] uval + /// \param[in] uval /// A uint64_t value that was extracted as a SLEB128 value. - //------------------------------------------------------------------ size_t PutSLEB128(int64_t uval); - //------------------------------------------------------------------ /// Output a ULEB128 number to the stream. /// /// Put an ULEB128 \a uval out to the stream using the printf format in \a /// format. /// - /// @param[in] uval + /// \param[in] uval /// A uint64_t value that was extracted as a ULEB128 value. - //------------------------------------------------------------------ size_t PutULEB128(uint64_t uval); - //------------------------------------------------------------------ /// Returns a raw_ostream that forwards the data to this Stream object. - //------------------------------------------------------------------ llvm::raw_ostream &AsRawOstream() { return m_forwarder; } protected: - //------------------------------------------------------------------ // Member variables - //------------------------------------------------------------------ Flags m_flags; ///< Dump flags. uint32_t m_addr_size; ///< Size of an address in bytes. lldb::ByteOrder @@ -571,28 +482,24 @@ protected: void _PutHex8(uint8_t uvalue, bool add_prefix); - //------------------------------------------------------------------ /// Output character bytes to the stream. /// /// Appends \a src_len characters from the buffer \a src to the stream. /// - /// @param[in] src + /// \param[in] src /// A buffer containing at least \a src_len bytes of data. /// - /// @param[in] src_len + /// \param[in] src_len /// A number of bytes to append to the stream. /// - /// @return + /// \return /// The number of bytes that were appended to the stream. - //------------------------------------------------------------------ virtual size_t WriteImpl(const void *src, size_t src_len) = 0; - //---------------------------------------------------------------------- - /// @class RawOstreamForward Stream.h "lldb/Utility/Stream.h" + /// \class RawOstreamForward Stream.h "lldb/Utility/Stream.h" /// This is a wrapper class that exposes a raw_ostream interface that just /// forwards to an LLDB stream, allowing to reuse LLVM algorithms that take /// a raw_ostream within the LLDB code base. - //---------------------------------------------------------------------- class RawOstreamForward : public llvm::raw_ostream { // Note: This stream must *not* maintain its own buffer, but instead // directly write everything to the internal Stream class. Without this, diff --git a/include/lldb/Utility/StreamCallback.h b/include/lldb/Utility/StreamCallback.h index 63a86eeece731..6dbee67ecca27 100644 --- a/include/lldb/Utility/StreamCallback.h +++ b/include/lldb/Utility/StreamCallback.h @@ -1,9 +1,8 @@ //===-- StreamCallback.h -----------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// diff --git a/include/lldb/Utility/StreamGDBRemote.h b/include/lldb/Utility/StreamGDBRemote.h index dfc4a39de7912..dd0ea31126d93 100644 --- a/include/lldb/Utility/StreamGDBRemote.h +++ b/include/lldb/Utility/StreamGDBRemote.h @@ -1,9 +1,8 @@ //===-- StreamGDBRemote.h ----------------------------------------*- C++-*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -27,18 +26,16 @@ public: ~StreamGDBRemote() override; - //------------------------------------------------------------------ /// Output a block of data to the stream performing GDB-remote escaping. /// - /// @param[in] s + /// \param[in] s /// A block of data. /// - /// @param[in] src_len + /// \param[in] src_len /// The amount of data to write. /// - /// @return + /// \return /// Number of bytes written. - //------------------------------------------------------------------ // TODO: Convert this function to take ArrayRef<uint8_t> int PutEscapedBytes(const void *s, size_t src_len); }; diff --git a/include/lldb/Utility/StreamString.h b/include/lldb/Utility/StreamString.h index dd2f9f67466e0..581e102d4e80d 100644 --- a/include/lldb/Utility/StreamString.h +++ b/include/lldb/Utility/StreamString.h @@ -1,9 +1,8 @@ //===-- StreamString.h ------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// diff --git a/include/lldb/Utility/StreamTee.h b/include/lldb/Utility/StreamTee.h index 4f8e6ab1f0029..92e94d4494f6e 100644 --- a/include/lldb/Utility/StreamTee.h +++ b/include/lldb/Utility/StreamTee.h @@ -1,9 +1,8 @@ //===-- StreamTee.h ------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -50,8 +49,11 @@ public: StreamTee &operator=(const StreamTee &rhs) { if (this != &rhs) { Stream::operator=(rhs); - std::lock_guard<std::recursive_mutex> lhs_locker(m_streams_mutex); - std::lock_guard<std::recursive_mutex> rhs_locker(rhs.m_streams_mutex); + std::lock(m_streams_mutex, rhs.m_streams_mutex); + std::lock_guard<std::recursive_mutex> lhs_locker(m_streams_mutex, + std::adopt_lock); + std::lock_guard<std::recursive_mutex> rhs_locker(rhs.m_streams_mutex, + std::adopt_lock); m_streams = rhs.m_streams; } return *this; diff --git a/include/lldb/Utility/StringExtractor.h b/include/lldb/Utility/StringExtractor.h index bc24c153bae68..f20ec92199bb9 100644 --- a/include/lldb/Utility/StringExtractor.h +++ b/include/lldb/Utility/StringExtractor.h @@ -1,9 +1,8 @@ //===-- StringExtractor.h ---------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -20,20 +19,12 @@ class StringExtractor { public: enum { BigEndian = 0, LittleEndian = 1 }; - //------------------------------------------------------------------ // Constructors and Destructors - //------------------------------------------------------------------ StringExtractor(); StringExtractor(llvm::StringRef packet_str); StringExtractor(const char *packet_cstr); - StringExtractor(const StringExtractor &rhs); virtual ~StringExtractor(); - //------------------------------------------------------------------ - // Operators - //------------------------------------------------------------------ - const StringExtractor &operator=(const StringExtractor &rhs); - void Reset(llvm::StringRef str) { m_packet = str; m_index = 0; @@ -122,9 +113,7 @@ protected: m_index = UINT64_MAX; return false; } - //------------------------------------------------------------------ // For StringExtractor only - //------------------------------------------------------------------ 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 diff --git a/include/lldb/Utility/StringExtractorGDBRemote.h b/include/lldb/Utility/StringExtractorGDBRemote.h index 8c2eca898e64f..cbf6e0c29e8ee 100644 --- a/include/lldb/Utility/StringExtractorGDBRemote.h +++ b/include/lldb/Utility/StringExtractorGDBRemote.h @@ -1,9 +1,8 @@ //===-- StringExtractorGDBRemote.h ------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -35,7 +34,7 @@ public: StringExtractorGDBRemote(const StringExtractorGDBRemote &rhs) : StringExtractor(rhs), m_validator(rhs.m_validator) {} - virtual ~StringExtractorGDBRemote() {} + ~StringExtractorGDBRemote() override {} bool ValidateResponse() const; @@ -129,7 +128,7 @@ public: eServerPacketType_qVAttachOrWaitSupported, eServerPacketType_qWatchpointSupportInfo, eServerPacketType_qWatchpointSupportInfoSupported, - eServerPacketType_qXfer_auxv_read, + eServerPacketType_qXfer, eServerPacketType_jSignalsInfo, eServerPacketType_jModulesInfo, diff --git a/include/lldb/Utility/StringLexer.h b/include/lldb/Utility/StringLexer.h index 32cfa4e3f6f2a..d9806c1b37d79 100644 --- a/include/lldb/Utility/StringLexer.h +++ b/include/lldb/Utility/StringLexer.h @@ -1,9 +1,8 @@ //===--------------------- StringLexer.h ------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -25,8 +24,6 @@ public: StringLexer(std::string s); - StringLexer(const StringLexer &rhs); - // These APIs are not bounds-checked. Use HasAtLeast() if you're not sure. Character Peek(); diff --git a/include/lldb/Utility/StringList.h b/include/lldb/Utility/StringList.h index c080230249ddf..68c1f87510f63 100644 --- a/include/lldb/Utility/StringList.h +++ b/include/lldb/Utility/StringList.h @@ -1,9 +1,8 @@ //===-- StringList.h --------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -18,8 +17,6 @@ namespace lldb_private { class Log; -} -namespace lldb_private { class Stream; } diff --git a/include/lldb/Utility/StructuredData.h b/include/lldb/Utility/StructuredData.h index 100b4fa98ae1d..75eb2f7b7291e 100644 --- a/include/lldb/Utility/StructuredData.h +++ b/include/lldb/Utility/StructuredData.h @@ -1,9 +1,8 @@ //===-- StructuredData.h ----------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -29,15 +28,12 @@ namespace lldb_private { class Status; -} -namespace lldb_private { class Stream; } namespace lldb_private { -//---------------------------------------------------------------------- -/// @class StructuredData StructuredData.h "lldb/Utility/StructuredData.h" +/// \class StructuredData StructuredData.h "lldb/Utility/StructuredData.h" /// A class which can hold structured data /// /// The StructuredData class is designed to hold the data from a JSON or plist @@ -49,7 +45,6 @@ namespace lldb_private { /// 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 { public: diff --git a/include/lldb/Utility/TildeExpressionResolver.h b/include/lldb/Utility/TildeExpressionResolver.h index ae6b4073f6aa6..196fdfcf9ab46 100644 --- a/include/lldb/Utility/TildeExpressionResolver.h +++ b/include/lldb/Utility/TildeExpressionResolver.h @@ -1,9 +1,8 @@ //===--------------------- TildeExpressionResolver.h ------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// diff --git a/include/lldb/Utility/Timeout.h b/include/lldb/Utility/Timeout.h index ecb33b346e96a..202b747fd4804 100644 --- a/include/lldb/Utility/Timeout.h +++ b/include/lldb/Utility/Timeout.h @@ -1,9 +1,8 @@ //===-- Timeout.h -----------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// diff --git a/include/lldb/Utility/Timer.h b/include/lldb/Utility/Timer.h index 7c41c62572543..ad9421a75b15f 100644 --- a/include/lldb/Utility/Timer.h +++ b/include/lldb/Utility/Timer.h @@ -1,9 +1,8 @@ //===-- Timer.h -------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -18,10 +17,8 @@ namespace lldb_private { class Stream; -//---------------------------------------------------------------------- -/// @class Timer Timer.h "lldb/Utility/Timer.h" +/// \class Timer Timer.h "lldb/Utility/Timer.h" /// A timer class that simplifies common timing metrics. -//---------------------------------------------------------------------- class Timer { public: @@ -33,20 +30,18 @@ public: friend class Timer; const char *m_name; std::atomic<uint64_t> m_nanos; + std::atomic<uint64_t> m_nanos_total; + std::atomic<uint64_t> m_count; std::atomic<Category *> m_next; DISALLOW_COPY_AND_ASSIGN(Category); }; - //-------------------------------------------------------------- /// Default constructor. - //-------------------------------------------------------------- Timer(Category &category, const char *format, ...) __attribute__((format(printf, 3, 4))); - //-------------------------------------------------------------- /// Destructor - //-------------------------------------------------------------- ~Timer(); void Dump(); diff --git a/include/lldb/Utility/TraceOptions.h b/include/lldb/Utility/TraceOptions.h index 325ff74e6f556..d5e21ccd8ba35 100644 --- a/include/lldb/Utility/TraceOptions.h +++ b/include/lldb/Utility/TraceOptions.h @@ -1,9 +1,8 @@ //===-- TraceOptions.h ------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// diff --git a/include/lldb/Utility/UUID.h b/include/lldb/Utility/UUID.h index e082db572e463..dbeb9db611b25 100644 --- a/include/lldb/Utility/UUID.h +++ b/include/lldb/Utility/UUID.h @@ -1,9 +1,8 @@ //===-- UUID.h --------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -68,26 +67,29 @@ public: std::string GetAsString(llvm::StringRef separator = "-") const; size_t SetFromStringRef(llvm::StringRef str, uint32_t num_uuid_bytes = 16); + + // Same as SetFromStringRef, but if the resultant UUID is all 0 bytes, set the + // UUID to invalid. + size_t SetFromOptionalStringRef(llvm::StringRef 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 // typed in. It - //------------------------------------------------------------------ /// Decode as many UUID bytes (up to 16) as possible from the C /// string \a cstr. /// - /// @param[in] cstr + /// \param[in] cstr /// A NULL terminate C string that points at a UUID string value /// (no leading spaces). The string must contain only hex /// characters and optionally can contain the '-' sepearators. /// - /// @param[in] uuid_bytes + /// \param[in] uuid_bytes /// A buffer of bytes that will contain a full or patially /// decoded UUID. /// - /// @return + /// \return /// The original string, with all decoded bytes removed. - //------------------------------------------------------------------ static llvm::StringRef DecodeUUIDBytesFromString(llvm::StringRef str, llvm::SmallVectorImpl<uint8_t> &uuid_bytes, diff --git a/include/lldb/Utility/UriParser.h b/include/lldb/Utility/UriParser.h index db0049d9684ca..4a3f01230e1af 100644 --- a/include/lldb/Utility/UriParser.h +++ b/include/lldb/Utility/UriParser.h @@ -1,9 +1,8 @@ //===-- UriParser.h ---------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// diff --git a/include/lldb/Utility/UserID.h b/include/lldb/Utility/UserID.h index 8560274bdeac5..2dc5cdb23d0e9 100644 --- a/include/lldb/Utility/UserID.h +++ b/include/lldb/Utility/UserID.h @@ -1,9 +1,8 @@ //===-- UserID.h ------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -12,14 +11,11 @@ #include "lldb/lldb-defines.h" #include "lldb/lldb-types.h" -namespace lldb_private { -class Stream; -} namespace lldb_private { +class Stream; -//---------------------------------------------------------------------- -/// @class UserID UserID.h "lldb/Core/UserID.h" +/// \class UserID UserID.h "lldb/Core/UserID.h" /// A mix in class that contains a generic user ID. /// /// UserID is designed as a mix in class that can contain an integer based @@ -32,42 +28,30 @@ namespace lldb_private { /// 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 /// DWARF offset. -//---------------------------------------------------------------------- struct UserID { - //------------------------------------------------------------------ /// Construct with optional user ID. - //------------------------------------------------------------------ UserID(lldb::user_id_t uid = LLDB_INVALID_UID) : m_uid(uid) {} - //------------------------------------------------------------------ /// Destructor. - //------------------------------------------------------------------ ~UserID() {} - //------------------------------------------------------------------ /// Clears the object state. /// /// Clears the object contents back to a default invalid state. - //------------------------------------------------------------------ void Clear() { m_uid = LLDB_INVALID_UID; } - //------------------------------------------------------------------ /// Get accessor for the user ID. /// - /// @return + /// \return /// The user ID. - //------------------------------------------------------------------ lldb::user_id_t GetID() const { return m_uid; } - //------------------------------------------------------------------ /// Set accessor for the user ID. /// - /// @param[in] uid + /// \param[in] uid /// The new user ID. - //------------------------------------------------------------------ void SetID(lldb::user_id_t uid) { m_uid = uid; } - //------------------------------------------------------------------ /// 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: @@ -75,30 +59,21 @@ struct UserID { /// iterator pos; /// pos = std::find_if (coll.begin(), coll.end(), UserID::IDMatches(blockID)); /// \endcode - //------------------------------------------------------------------ class IDMatches { public: - //-------------------------------------------------------------- /// Construct with the user ID to look for. - //-------------------------------------------------------------- IDMatches(lldb::user_id_t uid) : m_uid(uid) {} - //-------------------------------------------------------------- /// Unary predicate function object callback. - //-------------------------------------------------------------- bool operator()(const UserID &rhs) const { return m_uid == rhs.GetID(); } private: - //-------------------------------------------------------------- // Member variables. - //-------------------------------------------------------------- const lldb::user_id_t m_uid; ///< The user ID we are looking for }; protected: - //------------------------------------------------------------------ // Member variables. - //------------------------------------------------------------------ lldb::user_id_t m_uid; ///< The user ID that uniquely identifies an object. }; @@ -110,9 +85,7 @@ inline bool operator!=(const UserID &lhs, const UserID &rhs) { return lhs.GetID() != rhs.GetID(); } -//-------------------------------------------------------------- /// Stream the UserID object to a Stream. -//-------------------------------------------------------------- Stream &operator<<(Stream &strm, const UserID &uid); } // namespace lldb_private diff --git a/include/lldb/Utility/UserIDResolver.h b/include/lldb/Utility/UserIDResolver.h new file mode 100644 index 0000000000000..bca82a11b6609 --- /dev/null +++ b/include/lldb/Utility/UserIDResolver.h @@ -0,0 +1,56 @@ +//===-- UserIDResolver.h ----------------------------------------*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef LLDB_UTILITY_USERIDRESOLVER_H +#define LLDB_UTILITY_USERIDRESOLVER_H + +#include "llvm/ADT/DenseMap.h" +#include "llvm/ADT/StringRef.h" +#include <mutex> + +namespace lldb_private { + +/// An abstract interface for things that know how to map numeric user/group IDs +/// into names. It caches the resolved names to avoid repeating expensive +/// queries. The cache is internally protected by a mutex, so concurrent queries +/// are safe. +class UserIDResolver { +public: + typedef uint32_t id_t; + virtual ~UserIDResolver(); // anchor + + llvm::Optional<llvm::StringRef> GetUserName(id_t uid) { + return Get(uid, m_uid_cache, &UserIDResolver::DoGetUserName); + } + llvm::Optional<llvm::StringRef> GetGroupName(id_t gid) { + return Get(gid, m_gid_cache, &UserIDResolver::DoGetGroupName); + } + + /// Returns a resolver which returns a failure value for each query. Useful as + /// a fallback value for the case when we know all lookups will fail. + static UserIDResolver &GetNoopResolver(); + +protected: + virtual llvm::Optional<std::string> DoGetUserName(id_t uid) = 0; + virtual llvm::Optional<std::string> DoGetGroupName(id_t gid) = 0; + +private: + using Map = llvm::DenseMap<id_t, llvm::Optional<std::string>>; + + llvm::Optional<llvm::StringRef> + Get(id_t id, Map &cache, + llvm::Optional<std::string> (UserIDResolver::*do_get)(id_t)); + + std::mutex m_mutex; + Map m_uid_cache; + Map m_gid_cache; +}; + +} // namespace lldb_private + +#endif // #ifndef LLDB_HOST_USERIDRESOLVER_H diff --git a/include/lldb/Utility/VASPrintf.h b/include/lldb/Utility/VASPrintf.h index 6e2404ecef93b..582645fd22929 100644 --- a/include/lldb/Utility/VASPrintf.h +++ b/include/lldb/Utility/VASPrintf.h @@ -1,9 +1,8 @@ //===-- VASPrintf.h ---------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// diff --git a/include/lldb/Utility/VMRange.h b/include/lldb/Utility/VMRange.h index a70b0cb6118ce..9c2f9d0909191 100644 --- a/include/lldb/Utility/VMRange.h +++ b/include/lldb/Utility/VMRange.h @@ -1,9 +1,8 @@ //===-- VMRange.h -----------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -22,10 +21,8 @@ class Stream; namespace lldb_private { -//---------------------------------------------------------------------- // A vm address range. These can represent offsets ranges or actual // addresses. -//---------------------------------------------------------------------- class VMRange { public: typedef std::vector<VMRange> collection; diff --git a/include/lldb/lldb-defines.h b/include/lldb/lldb-defines.h index 8a54b4c44364b..b87964403f7e2 100644 --- a/include/lldb/lldb-defines.h +++ b/include/lldb/lldb-defines.h @@ -1,9 +1,8 @@ //===-- lldb-defines.h ------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -36,31 +35,23 @@ #define UINT64_MAX 18446744073709551615ULL #endif -//---------------------------------------------------------------------- // LLDB version // // A build script phase can modify this version number if needed. -//---------------------------------------------------------------------- //#define LLDB_VERSION //#define LLDB_REVISION //#define LLDB_VERSION_STRING -//---------------------------------------------------------------------- // LLDB defines -//---------------------------------------------------------------------- #define LLDB_GENERIC_ERROR UINT32_MAX -//---------------------------------------------------------------------- // Breakpoints -//---------------------------------------------------------------------- #define LLDB_INVALID_BREAK_ID 0 #define LLDB_DEFAULT_BREAK_SIZE 0 #define LLDB_BREAK_ID_IS_VALID(bid) ((bid) != (LLDB_INVALID_BREAK_ID)) #define LLDB_BREAK_ID_IS_INTERNAL(bid) ((bid) < 0) -//---------------------------------------------------------------------- // Watchpoints -//---------------------------------------------------------------------- #define LLDB_INVALID_WATCH_ID 0 #define LLDB_WATCH_ID_IS_VALID(uid) ((uid) != (LLDB_INVALID_WATCH_ID)) #define LLDB_WATCH_TYPE_READ (1u << 0) @@ -68,9 +59,7 @@ #define LLDB_WATCH_TYPE_IS_VALID(type) \ ((type | LLDB_WATCH_TYPE_READ) || (type | LLDB_WATCH_TYPE_WRITE)) -//---------------------------------------------------------------------- // Generic Register Numbers -//---------------------------------------------------------------------- #define LLDB_REGNUM_GENERIC_PC 0 // Program Counter #define LLDB_REGNUM_GENERIC_SP 1 // Stack Pointer #define LLDB_REGNUM_GENERIC_FP 2 // Frame Pointer @@ -92,9 +81,7 @@ 11 // The register that would contain pointer size or less argument 7 (if any) #define LLDB_REGNUM_GENERIC_ARG8 \ 12 // The register that would contain pointer size or less argument 8 (if any) -//--------------------------------------------------------------------- /// Invalid value definitions -//---------------------------------------------------------------------- #define LLDB_INVALID_ADDRESS UINT64_MAX #define LLDB_INVALID_INDEX32 UINT32_MAX #define LLDB_INVALID_IVAR_OFFSET UINT32_MAX @@ -110,17 +97,13 @@ #define LLDB_INVALID_LINE_NUMBER UINT32_MAX #define LLDB_INVALID_QUEUE_ID 0 -//---------------------------------------------------------------------- /// CPU Type definitions -//---------------------------------------------------------------------- #define LLDB_ARCH_DEFAULT "systemArch" #define LLDB_ARCH_DEFAULT_32BIT "systemArch32" #define LLDB_ARCH_DEFAULT_64BIT "systemArch64" #define LLDB_INVALID_CPUTYPE (0xFFFFFFFEu) -//---------------------------------------------------------------------- /// Option Set definitions -//---------------------------------------------------------------------- // FIXME: I'm sure there's some #define magic that can create all 32 sets on the // fly. That would have the added benefit of making this unreadable. #define LLDB_MAX_NUM_OPTION_SETS 32 @@ -152,11 +135,9 @@ #if defined(__cplusplus) -//---------------------------------------------------------------------- -/// @def DISALLOW_COPY_AND_ASSIGN(TypeName) +/// \def DISALLOW_COPY_AND_ASSIGN(TypeName) /// Macro definition for easily disallowing copy constructor and /// assignment operators in C++ classes. -//---------------------------------------------------------------------- #define DISALLOW_COPY_AND_ASSIGN(TypeName) \ TypeName(const TypeName &) = delete; \ const TypeName &operator=(const TypeName &) = delete diff --git a/include/lldb/lldb-enumerations.h b/include/lldb/lldb-enumerations.h index 1c4d6f509a2a9..f9830c04bc39f 100644 --- a/include/lldb/lldb-enumerations.h +++ b/include/lldb/lldb-enumerations.h @@ -1,9 +1,8 @@ //===-- lldb-enumerations.h -------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -70,9 +69,7 @@ namespace lldb { -//---------------------------------------------------------------------- // Process and Thread States -//---------------------------------------------------------------------- enum StateType { eStateInvalid = 0, eStateUnloaded, ///< Process is object is valid, but not currently loaded @@ -96,9 +93,7 @@ enum StateType { kLastStateType = eStateSuspended }; -//---------------------------------------------------------------------- // Launch Flags -//---------------------------------------------------------------------- FLAGS_ENUM(LaunchFlags){ eLaunchFlagNone = 0u, eLaunchFlagExec = (1u << 0), ///< Exec when launching and turn the calling @@ -131,14 +126,10 @@ FLAGS_ENUM(LaunchFlags){ eLaunchFlagCloseTTYOnExit = (1u << 11), ///< Close the open TTY on exit }; -//---------------------------------------------------------------------- // Thread Run Modes -//---------------------------------------------------------------------- enum RunMode { eOnlyThisThread, eAllThreads, eOnlyDuringStepping }; -//---------------------------------------------------------------------- // Byte ordering definitions -//---------------------------------------------------------------------- enum ByteOrder { eByteOrderInvalid = 0, eByteOrderBig = 1, @@ -146,9 +137,7 @@ enum ByteOrder { eByteOrderLittle = 4 }; -//---------------------------------------------------------------------- // Register encoding definitions -//---------------------------------------------------------------------- enum Encoding { eEncodingInvalid = 0, eEncodingUint, // unsigned integer @@ -157,9 +146,7 @@ enum Encoding { eEncodingVector // vector registers }; -//---------------------------------------------------------------------- // Display format definitions -//---------------------------------------------------------------------- enum Format { eFormatDefault = 0, eFormatInvalid = 0, @@ -209,10 +196,8 @@ enum Format { kNumFormats }; -//---------------------------------------------------------------------- // Description levels for "void GetDescription(Stream *, DescriptionLevel)" // calls -//---------------------------------------------------------------------- enum DescriptionLevel { eDescriptionLevelBrief = 0, eDescriptionLevelFull, @@ -221,9 +206,7 @@ enum DescriptionLevel { kNumDescriptionLevels }; -//---------------------------------------------------------------------- // Script interpreter types -//---------------------------------------------------------------------- enum ScriptLanguage { eScriptLanguageNone, eScriptLanguagePython, @@ -231,11 +214,9 @@ enum ScriptLanguage { eScriptLanguageUnknown }; -//---------------------------------------------------------------------- // Register numbering types // 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 eRegisterKindDWARF, // the register numbers seen DWARF @@ -247,9 +228,7 @@ enum RegisterKind { kNumRegisterKinds }; -//---------------------------------------------------------------------- // Thread stop reasons -//---------------------------------------------------------------------- enum StopReason { eStopReasonInvalid = 0, eStopReasonNone, @@ -264,9 +243,7 @@ enum StopReason { eStopReasonInstrumentation }; -//---------------------------------------------------------------------- // Command Return Status Types -//---------------------------------------------------------------------- enum ReturnStatus { eReturnStatusInvalid, eReturnStatusSuccessFinishNoResult, @@ -278,9 +255,7 @@ enum ReturnStatus { eReturnStatusQuit }; -//---------------------------------------------------------------------- // The results of expression evaluation: -//---------------------------------------------------------------------- enum ExpressionResults { eExpressionCompleted = 0, eExpressionSetupError, @@ -304,9 +279,7 @@ enum SearchDepth { kLastSearchDepthKind = eSearchDepthAddress }; -//---------------------------------------------------------------------- // Connection Status Types -//---------------------------------------------------------------------- enum ConnectionStatus { eConnectionStatusSuccess, // Success eConnectionStatusEndOfFile, // End-of-file encountered @@ -339,9 +312,7 @@ enum ValueType { eValueTypeVariableThreadLocal = 8 // thread local storage variable }; -//---------------------------------------------------------------------- // Token size/granularities for Input Readers -//---------------------------------------------------------------------- enum InputReaderGranularity { eInputReaderGranularityInvalid = 0, @@ -351,7 +322,6 @@ enum InputReaderGranularity { eInputReaderGranularityAll }; -//------------------------------------------------------------------ /// These mask bits allow a common interface for queries that can /// limit the amount of information that gets parsed to only the /// information that is requested. These bits also can indicate what @@ -360,7 +330,6 @@ enum InputReaderGranularity { /// Each definition corresponds to a one of the member variables /// in this class, and requests that that item be resolved, or /// indicates that the member did get resolved. -//------------------------------------------------------------------ FLAGS_ENUM(SymbolContextItem){ eSymbolContextTarget = (1u << 0), ///< Set when \a target is requested from /// a query, or was located in query @@ -447,14 +416,12 @@ FLAGS_ENUM(WatchpointEventType){ eWatchpointEventTypeThreadChanged = (1u << 11), eWatchpointEventTypeTypeChanged = (1u << 12)}; -//---------------------------------------------------------------------- /// Programming language type. /// /// These enumerations use the same language enumerations as the DWARF /// specification for ease of use and consistency. /// The enum -> string code is in Language.cpp, don't change this /// table without updating that code as well. -//---------------------------------------------------------------------- enum LanguageType { eLanguageTypeUnknown = 0x0000, ///< Unknown or invalid language value. eLanguageTypeC89 = 0x0001, ///< ISO C:1989. @@ -624,9 +591,9 @@ enum CommandArgumentType { // enumeration!! }; -//---------------------------------------------------------------------- // Symbol types -//---------------------------------------------------------------------- +// Symbol holds the SymbolType in a 6-bit field (m_type), so if you get over 63 +// entries you will have to resize that field. enum SymbolType { eSymbolTypeAny = 0, eSymbolTypeInvalid = 0, @@ -719,6 +686,7 @@ enum SectionType { eSectionTypeDWARFDebugInfoDwo, eSectionTypeDWARFDebugStrDwo, eSectionTypeDWARFDebugStrOffsetsDwo, + eSectionTypeDWARFDebugTypesDwo, }; FLAGS_ENUM(EmulateInstructionOptions){ @@ -748,9 +716,7 @@ FLAGS_ENUM(FunctionNameType){ }; LLDB_MARK_AS_BITMASK_ENUM(FunctionNameType) -//---------------------------------------------------------------------- // Basic types enumeration for the public API SBType::GetBasicType() -//---------------------------------------------------------------------- enum BasicType { eBasicTypeInvalid = 0, eBasicTypeVoid = 1, @@ -835,10 +801,8 @@ enum TemplateArgumentKind { eTemplateArgumentKindNullPtr, }; -//---------------------------------------------------------------------- // 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), eTypeOptionSkipPointers = (1u << 1), @@ -852,7 +816,6 @@ FLAGS_ENUM(TypeOptions){eTypeOptionNone = (0u), 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 @@ -864,7 +827,6 @@ FLAGS_ENUM(TypeOptions){eTypeOptionNone = (0u), // 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. -//---------------------------------------------------------------------- enum FrameComparison { eFrameCompareInvalid, eFrameCompareUnknown, @@ -874,12 +836,10 @@ enum FrameComparison { eFrameCompareOlder }; -//---------------------------------------------------------------------- // 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. -//---------------------------------------------------------------------- FLAGS_ENUM(FilePermissions){ eFilePermissionsUserRead = (1u << 8), eFilePermissionsUserWrite = (1u << 7), eFilePermissionsUserExecute = (1u << 6), @@ -935,35 +895,29 @@ FLAGS_ENUM(FilePermissions){ eFilePermissionsDirectoryDefault = eFilePermissionsUserRWX, }; -//---------------------------------------------------------------------- // Queue work item types // // The different types of work that can be enqueued on a libdispatch aka Grand // Central Dispatch (GCD) queue. -//---------------------------------------------------------------------- enum QueueItemKind { eQueueItemKindUnknown = 0, eQueueItemKindFunction, eQueueItemKindBlock }; -//---------------------------------------------------------------------- // Queue type // libdispatch aka Grand Central Dispatch (GCD) queues can be either serial // (executing on one thread) or concurrent (executing on multiple threads). -//---------------------------------------------------------------------- enum QueueKind { eQueueKindUnknown = 0, eQueueKindSerial, eQueueKindConcurrent }; -//---------------------------------------------------------------------- // Expression Evaluation Stages // These are the cancellable stages of expression evaluation, passed to the // expression evaluation callback, so that you can interrupt expression // evaluation at the various points in its lifecycle. -//---------------------------------------------------------------------- enum ExpressionEvaluationPhase { eExpressionEvaluationParse = 0, eExpressionEvaluationIRGen, @@ -971,11 +925,9 @@ enum ExpressionEvaluationPhase { eExpressionEvaluationComplete }; -//---------------------------------------------------------------------- // Watchpoint Kind // 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)}; @@ -988,11 +940,9 @@ enum GdbSignal { eGdbSignalBreakpoint = 0x96 }; -//---------------------------------------------------------------------- // 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 // mach-o file in LLDB.framework (MacOSX) exists @@ -1009,10 +959,8 @@ enum PathType { ePathTypeClangDir // Find path to Clang builtin headers }; -//---------------------------------------------------------------------- // Kind of member function // Used by the type system -//---------------------------------------------------------------------- enum MemberFunctionKind { eMemberFunctionKindUnknown = 0, // Not sure what the type of this is eMemberFunctionKindConstructor, // A function used to create instances @@ -1024,14 +972,10 @@ enum MemberFunctionKind { // than any instance }; -//---------------------------------------------------------------------- // String matching algorithm used by SBTarget -//---------------------------------------------------------------------- enum MatchType { eMatchTypeNormal, eMatchTypeRegex, eMatchTypeStartsWith }; -//---------------------------------------------------------------------- // Bitmask that describes details about a type -//---------------------------------------------------------------------- FLAGS_ENUM(TypeFlags){ eTypeHasChildren = (1u << 0), eTypeHasValue = (1u << 1), eTypeIsArray = (1u << 2), eTypeIsBlock = (1u << 3), @@ -1047,7 +991,6 @@ FLAGS_ENUM(TypeFlags){ eTypeInstanceIsPointer = (1u << 22)}; FLAGS_ENUM(CommandFlags){ - //---------------------------------------------------------------------- // eCommandRequiresTarget // // Ensures a valid target is contained in m_exe_ctx prior to executing the @@ -1055,9 +998,7 @@ FLAGS_ENUM(CommandFlags){ // 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 @@ -1066,9 +1007,7 @@ FLAGS_ENUM(CommandFlags){ // 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 @@ -1076,9 +1015,7 @@ FLAGS_ENUM(CommandFlags){ // 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 @@ -1086,9 +1023,7 @@ FLAGS_ENUM(CommandFlags){ // 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 @@ -1098,34 +1033,25 @@ FLAGS_ENUM(CommandFlags){ // 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), - //---------------------------------------------------------------------- // eCommandTryTargetAPILock // // Attempts to acquire the target lock if a target is selected in the // command interpreter. If the command object fails to acquire the API // lock, the command will fail with an appropriate error message. - //---------------------------------------------------------------------- eCommandTryTargetAPILock = (1u << 5), - //---------------------------------------------------------------------- // 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. - //---------------------------------------------------------------------- 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. - //---------------------------------------------------------------------- eCommandProcessMustBePaused = (1u << 7)}; -//---------------------------------------------------------------------- // Whether a summary should cap how much data it returns to users or not -//---------------------------------------------------------------------- enum TypeSummaryCapping { eTypeSummaryCapped = true, eTypeSummaryUncapped = false diff --git a/include/lldb/lldb-forward.h b/include/lldb/lldb-forward.h index 92aa5bb611c3c..0cdaf1cf9bf81 100644 --- a/include/lldb/lldb-forward.h +++ b/include/lldb/lldb-forward.h @@ -1,9 +1,8 @@ //===-- lldb-forward.h ------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -14,14 +13,11 @@ #include "lldb/Utility/SharingPtr.h" -//---------------------------------------------------------------------- // lldb forward declarations -//---------------------------------------------------------------------- namespace lldb_private { class ABI; class Address; -class AddressImpl; class AddressRange; class AddressResolver; class ArchSpec; @@ -41,13 +37,13 @@ class BreakpointLocationList; class BreakpointName; class BreakpointOptionGroup; class BreakpointOptions; +class BreakpointPrecondition; class BreakpointResolver; class BreakpointSite; class BreakpointSiteList; class BroadcastEventSpec; class Broadcaster; class BroadcasterManager; -class CPPLanguageRuntime; class ClangASTContext; class ClangASTImporter; class ClangASTMetadata; @@ -55,7 +51,6 @@ class ClangASTSource; class ClangExpressionDeclMap; class ClangExpressionParser; class ClangExpressionVariable; -class ClangExpressionVariables; class ClangModulesDeclVendor; class ClangPersistentVariables; class CommandInterpreter; @@ -70,7 +65,6 @@ class CompilerDecl; class CompilerDeclContext; class CompilerType; class CompileUnit; -class Condition; class Connection; class ConnectionFileDescriptor; class ConstString; @@ -97,7 +91,6 @@ class EventData; class EventDataStructuredData; class ExecutionContext; class ExecutionContextRef; -class ExecutionContextRefLocker; class ExecutionContextScope; class Expression; class ExpressionVariable; @@ -137,10 +130,7 @@ class Module; class ModuleList; class ModuleSpec; class ModuleSpecList; -class Mutex; struct NameSearchContext; -class ObjCLanguageRuntime; -class ObjCRuntimeSyntheticProvider; class ObjectContainer; class OptionGroup; class OptionGroupOptions; @@ -169,7 +159,6 @@ class OptionValueSInt64; class OptionValueString; class OptionValueUInt64; class OptionValueUUID; -class NamedOption; class PathMappingList; class FunctionCaller; class PersistentExpressionState; @@ -187,8 +176,6 @@ struct PropertyDefinition; class RecognizedStackFrame; class RegisterCheckpoint; class RegisterContext; -class RegisterLocation; -class RegisterLocationList; class RegisterValue; class RegularExpression; class REPL; @@ -199,7 +186,6 @@ class ScriptInterpreterLocker; struct ScriptSummaryFormat; class SearchFilter; class Section; -class SectionImpl; class SectionList; class SectionLoadHistory; class SectionLoadList; @@ -207,7 +193,6 @@ class Settings; class SourceManager; class SourceManagerImpl; class StackFrame; -class StackFrameImpl; class StackFrameList; class StackFrameRecognizer; class StackFrameRecognizerManager; @@ -240,9 +225,7 @@ class SyntheticChildren; class SyntheticChildrenFrontEnd; class TypeFilterImpl; class TypeSystem; -#ifndef LLDB_DISABLE_PYTHON class ScriptedSyntheticChildren; -#endif class Queue; class QueueItem; class QueueImpl; @@ -276,7 +259,6 @@ class TypeEnumMemberImpl; class TypeEnumMemberListImpl; class TypeFormatImpl; class TypeNameSpecifierImpl; -class TypePair; class TypeValidatorImpl; class UUID; class UnixSignals; @@ -305,9 +287,7 @@ struct LineEntry; } // namespace lldb_private -//---------------------------------------------------------------------- // lldb forward declarations -//---------------------------------------------------------------------- namespace lldb { typedef std::shared_ptr<lldb_private::ABI> ABISP; @@ -319,6 +299,7 @@ typedef std::shared_ptr<lldb_private::BreakpointSite> BreakpointSiteSP; typedef std::weak_ptr<lldb_private::BreakpointSite> BreakpointSiteWP; typedef std::shared_ptr<lldb_private::BreakpointLocation> BreakpointLocationSP; typedef std::weak_ptr<lldb_private::BreakpointLocation> BreakpointLocationWP; +typedef std::shared_ptr<lldb_private::BreakpointPrecondition> BreakpointPreconditionSP; typedef std::shared_ptr<lldb_private::BreakpointResolver> BreakpointResolverSP; typedef std::shared_ptr<lldb_private::Broadcaster> BroadcasterSP; typedef std::shared_ptr<lldb_private::BroadcasterManager> BroadcasterManagerSP; @@ -479,10 +460,8 @@ typedef std::shared_ptr<lldb_private::TypeNameSpecifierImpl> typedef std::shared_ptr<lldb_private::TypeSummaryImpl> TypeSummaryImplSP; typedef std::shared_ptr<lldb_private::TypeSummaryOptions> TypeSummaryOptionsSP; typedef std::shared_ptr<lldb_private::TypeValidatorImpl> TypeValidatorImplSP; -#ifndef LLDB_DISABLE_PYTHON typedef std::shared_ptr<lldb_private::ScriptedSyntheticChildren> ScriptedSyntheticChildrenSP; -#endif typedef std::shared_ptr<lldb_private::UnixSignals> UnixSignalsSP; typedef std::weak_ptr<lldb_private::UnixSignals> UnixSignalsWP; typedef std::shared_ptr<lldb_private::UnwindAssembly> UnwindAssemblySP; @@ -498,9 +477,7 @@ typedef std::shared_ptr<lldb_private::Watchpoint> WatchpointSP; } // namespace lldb -//---------------------------------------------------------------------- // llvm forward declarations -//---------------------------------------------------------------------- namespace llvm { struct ItaniumPartialDemangler; diff --git a/include/lldb/lldb-private-defines.h b/include/lldb/lldb-private-defines.h index 9b6594422e827..737d9ef2434e1 100644 --- a/include/lldb/lldb-private-defines.h +++ b/include/lldb/lldb-private-defines.h @@ -1,9 +1,8 @@ //===-- lldb-private-defines.h ----------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// diff --git a/include/lldb/lldb-private-enumerations.h b/include/lldb/lldb-private-enumerations.h index c25f285c97133..3d8b360fb301e 100644 --- a/include/lldb/lldb-private-enumerations.h +++ b/include/lldb/lldb-private-enumerations.h @@ -1,9 +1,8 @@ //===-- lldb-private-enumerations.h -----------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -16,10 +15,8 @@ namespace lldb_private { -//---------------------------------------------------------------------- // Thread Step Types -//---------------------------------------------------------------------- -typedef enum StepType { +enum StepType { eStepTypeNone, eStepTypeTrace, ///< Single step one instruction. eStepTypeTraceOver, ///< Single step one instruction, stepping over. @@ -27,22 +24,19 @@ typedef enum StepType { eStepTypeOver, ///< Single step over a specified context. eStepTypeOut, ///< Single step out a specified context. eStepTypeScripted ///< A step type implemented by the script interpreter. -} StepType; +}; -//---------------------------------------------------------------------- // Address Types -//---------------------------------------------------------------------- -typedef enum AddressType { +enum AddressType { eAddressTypeInvalid = 0, eAddressTypeFile, ///< Address is an address as found in an object or symbol - ///file + /// file eAddressTypeLoad, ///< Address is an address as in the current target inferior - ///process + /// process eAddressTypeHost ///< Address is an address in the process that is running - ///this code -} AddressType; + /// this code +}; -//---------------------------------------------------------------------- // Address Class // // A way of classifying an address used for disassembling and setting @@ -51,7 +45,6 @@ typedef enum AddressType { // 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, @@ -62,23 +55,19 @@ enum class AddressClass { eRuntime }; -//---------------------------------------------------------------------- // Votes - Need a tri-state, yes, no, no opinion... -//---------------------------------------------------------------------- -typedef enum Vote { eVoteNo = -1, eVoteNoOpinion = 0, eVoteYes = 1 } Vote; +enum Vote { eVoteNo = -1, eVoteNoOpinion = 0, eVoteYes = 1 }; -typedef enum ArchitectureType { +enum ArchitectureType { eArchTypeInvalid, eArchTypeMachO, eArchTypeELF, eArchTypeCOFF, kNumArchTypes -} ArchitectureType; +}; -//---------------------------------------------------------------------- /// Settable state variable types. /// -//---------------------------------------------------------------------- // typedef enum SettableVariableType //{ @@ -91,7 +80,7 @@ typedef enum ArchitectureType { // eSetVarTypeNone //} SettableVariableType; -typedef enum VarSetOperationType { +enum VarSetOperationType { eVarSetOperationReplace, eVarSetOperationInsertBefore, eVarSetOperationInsertAfter, @@ -100,9 +89,9 @@ typedef enum VarSetOperationType { eVarSetOperationClear, eVarSetOperationAssign, eVarSetOperationInvalid -} VarSetOperationType; +}; -typedef enum ArgumentRepetitionType { +enum ArgumentRepetitionType { eArgRepeatPlain, // Exactly one occurrence eArgRepeatOptional, // At most one occurrence, but it's optional eArgRepeatPlus, // One or more occurrences @@ -116,29 +105,17 @@ typedef enum ArgumentRepetitionType { eArgRepeatPairRange, // A pair that repeats from 1 to n eArgRepeatPairRangeOptional // A pair that repeats from 1 to n, but is // optional -} ArgumentRepetitionType; +}; -typedef enum SortOrder { - eSortOrderNone, - eSortOrderByAddress, - eSortOrderByName -} SortOrder; +enum SortOrder { eSortOrderNone, eSortOrderByAddress, eSortOrderByName }; -//---------------------------------------------------------------------- // 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, - eLazyBoolNo = 0, - eLazyBoolYes = 1 -} LazyBool; +enum LazyBool { eLazyBoolCalculate = -1, eLazyBoolNo = 0, eLazyBoolYes = 1 }; -//------------------------------------------------------------------ /// Instruction types -//------------------------------------------------------------------ -typedef enum InstructionType { +enum InstructionType { eInstructionTypeAny, // Support for any instructions at all (at least one) eInstructionTypePrologueEpilogue, // All prologue and epilogue instructions // that push and pop register values and @@ -147,12 +124,10 @@ typedef enum InstructionType { // counter/instruction pointer eInstructionTypeAll // All instructions of any kind -} InstructionType; +}; -//------------------------------------------------------------------ /// Format category entry types -//------------------------------------------------------------------ -typedef enum FormatCategoryItem { +enum FormatCategoryItem { eFormatCategoryItemSummary = 0x0001, eFormatCategoryItemRegexSummary = 0x0002, eFormatCategoryItemFilter = 0x0004, @@ -163,22 +138,18 @@ typedef enum FormatCategoryItem { eFormatCategoryItemRegexValue = 0x0080, eFormatCategoryItemValidator = 0x0100, eFormatCategoryItemRegexValidator = 0x0200 -} FormatCategoryItem; +}; -//------------------------------------------------------------------ /// Expression execution policies -//------------------------------------------------------------------ -typedef enum { +enum ExecutionPolicy { eExecutionPolicyOnlyWhenNeeded, eExecutionPolicyNever, eExecutionPolicyAlways, eExecutionPolicyTopLevel // used for top-level code -} ExecutionPolicy; +}; -//---------------------------------------------------------------------- // Ways that the FormatManager picks a particular format for a type -//---------------------------------------------------------------------- -typedef enum FormatterChoiceCriterion { +enum FormatterChoiceCriterion { eFormatterChoiceCriterionDirectChoice = 0x00000000, eFormatterChoiceCriterionStrippedPointerReference = 0x00000001, eFormatterChoiceCriterionNavigatedTypedefs = 0x00000002, @@ -187,41 +158,33 @@ typedef enum FormatterChoiceCriterion { eFormatterChoiceCriterionLanguagePlugin = 0x00000008, eFormatterChoiceCriterionStrippedBitField = 0x00000010, eFormatterChoiceCriterionWentToStaticValue = 0x00000020 -} FormatterChoiceCriterion; +}; -//---------------------------------------------------------------------- // Synchronicity behavior of scripted commands -//---------------------------------------------------------------------- -typedef enum ScriptedCommandSynchronicity { +enum ScriptedCommandSynchronicity { eScriptedCommandSynchronicitySynchronous, eScriptedCommandSynchronicityAsynchronous, eScriptedCommandSynchronicityCurrentValue // use whatever the current // synchronicity is -} ScriptedCommandSynchronicity; +}; -//---------------------------------------------------------------------- // Verbosity mode of "po" output -//---------------------------------------------------------------------- -typedef enum LanguageRuntimeDescriptionDisplayVerbosity { +enum LanguageRuntimeDescriptionDisplayVerbosity { eLanguageRuntimeDescriptionDisplayVerbosityCompact, // only print the // description string, if // any eLanguageRuntimeDescriptionDisplayVerbosityFull, // print the full-blown // output -} LanguageRuntimeDescriptionDisplayVerbosity; +}; -//---------------------------------------------------------------------- // Loading modules from memory -//---------------------------------------------------------------------- -typedef enum MemoryModuleLoadLevel { +enum MemoryModuleLoadLevel { eMemoryModuleLoadLevelMinimal, // Load sections only eMemoryModuleLoadLevelPartial, // Load function bounds but no symbols eMemoryModuleLoadLevelComplete, // Load sections and all symbols -} MemoryModuleLoadLevel; +}; -//---------------------------------------------------------------------- // Result enums for when reading multiple lines from IOHandlers -//---------------------------------------------------------------------- enum class LineStatus { Success, // The line that was just edited if good and should be added to the // lines @@ -231,14 +194,10 @@ enum class LineStatus { Done // Lines are complete }; -//---------------------------------------------------------------------- // Boolean result of running a Type Validator -//---------------------------------------------------------------------- enum class TypeValidatorResult : bool { Success = true, Failure = false }; -//---------------------------------------------------------------------- // Enumerations that can be used to specify scopes types when looking up types. -//---------------------------------------------------------------------- enum class CompilerContextKind { Invalid = 0, TranslationUnit, @@ -253,10 +212,8 @@ 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, diff --git a/include/lldb/lldb-private-forward.h b/include/lldb/lldb-private-forward.h index 975d92d95727c..330070745adb7 100644 --- a/include/lldb/lldb-private-forward.h +++ b/include/lldb/lldb-private-forward.h @@ -1,9 +1,8 @@ //===-- lldb-private-forward.h ----------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -11,9 +10,7 @@ #define LLDB_lldb_private_forward_h_ namespace lldb_private { -// --------------------------------------------------------------- Class // forward decls. -// --------------------------------------------------------------- class NativeProcessProtocol; class NativeRegisterContext; class NativeThreadProtocol; diff --git a/include/lldb/lldb-private-interfaces.h b/include/lldb/lldb-private-interfaces.h index 76a9fad9f135a..3a9f78aae0fec 100644 --- a/include/lldb/lldb-private-interfaces.h +++ b/include/lldb/lldb-private-interfaces.h @@ -1,9 +1,8 @@ //===-- lldb-private-interfaces.h -------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -56,6 +55,9 @@ typedef LanguageRuntime *(*LanguageRuntimeCreateInstance)( Process *process, lldb::LanguageType language); typedef lldb::CommandObjectSP (*LanguageRuntimeGetCommandObject)( CommandInterpreter &interpreter); +typedef lldb::BreakpointPreconditionSP ( + *LanguageRuntimeGetExceptionPrecondition)(lldb::LanguageType language, + bool throw_bp); typedef lldb::StructuredDataPluginSP (*StructuredDataPluginCreateInstance)( Process &process); typedef Status (*StructuredDataFilterLaunchInfo)(ProcessLaunchInfo &launch_info, @@ -67,7 +69,7 @@ typedef lldb::ProcessSP (*ProcessCreateInstance)( lldb::TargetSP target_sp, lldb::ListenerSP listener_sp, const FileSpec *crash_file_path); typedef lldb::ScriptInterpreterSP (*ScriptInterpreterCreateInstance)( - CommandInterpreter &interpreter); + Debugger &debugger); typedef SymbolFile *(*SymbolFileCreateInstance)(ObjectFile *obj_file); typedef SymbolVendor *(*SymbolVendorCreateInstance)( const lldb::ModuleSP &module_sp, diff --git a/include/lldb/lldb-private-types.h b/include/lldb/lldb-private-types.h index e0f0e413cef40..bff471177214e 100644 --- a/include/lldb/lldb-private-types.h +++ b/include/lldb/lldb-private-types.h @@ -1,9 +1,8 @@ //===-- lldb-private-types.h ------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -29,10 +28,8 @@ class ExecutionContext; 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. -//---------------------------------------------------------------------- struct RegisterInfo { const char *name; // Name of this register, can't be NULL const char *alt_name; // Alternate name of this register, can be NULL @@ -74,9 +71,7 @@ struct RegisterInfo { } }; -//---------------------------------------------------------------------- // Registers are grouped into register sets -//---------------------------------------------------------------------- struct RegisterSet { const char *name; // Name of this register set const char *short_name; // A short name for this register set diff --git a/include/lldb/lldb-private.h b/include/lldb/lldb-private.h index 252ca09fae295..24954ad2a1f56 100644 --- a/include/lldb/lldb-private.h +++ b/include/lldb/lldb-private.h @@ -1,9 +1,8 @@ //===-- lldb-private.h ------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// diff --git a/include/lldb/lldb-public.h b/include/lldb/lldb-public.h index 290ff6e6d501f..449062f832f66 100644 --- a/include/lldb/lldb-public.h +++ b/include/lldb/lldb-public.h @@ -1,9 +1,8 @@ -//===-- lldb-include.h ------------------------------------------*- C++ -*-===// +//===-- lldb-public.h -------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// diff --git a/include/lldb/lldb-types.h b/include/lldb/lldb-types.h index 09dfc5c8a5ed9..414a9f3080522 100644 --- a/include/lldb/lldb-types.h +++ b/include/lldb/lldb-types.h @@ -1,9 +1,8 @@ //===-- lldb-types.h --------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -15,7 +14,6 @@ #include <stdint.h> -//---------------------------------------------------------------------- // All host systems must define: // lldb::thread_t The native thread type for spawned threads on the // system @@ -28,7 +26,6 @@ // #define LLDB_INVALID_PROCESS_ID ... // #define LLDB_INVALID_THREAD_ID ... // #define LLDB_INVALID_HOST_THREAD ... -//---------------------------------------------------------------------- // 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 @@ -55,9 +52,7 @@ typedef void *pipe_t; // Host pipe type is HANDLE #include <pthread.h> namespace lldb { -//---------------------------------------------------------------------- // MacOSX Types -//---------------------------------------------------------------------- typedef pthread_rwlock_t rwlock_t; typedef uint64_t process_t; // Process type is just a pid. typedef pthread_t thread_t; // Host thread type diff --git a/include/lldb/lldb-versioning.h b/include/lldb/lldb-versioning.h index 9d5fd164119e8..702ebd19a3ee2 100644 --- a/include/lldb/lldb-versioning.h +++ b/include/lldb/lldb-versioning.h @@ -1,19 +1,16 @@ //===-- lldb-versioning.h ----------------------------------------*- C++ //-*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// #ifndef LLDB_lldb_versioning_h_ #define LLDB_lldb_versioning_h_ -//---------------------------------------------------------------------- // LLDB API version -//---------------------------------------------------------------------- #define LLDB_API_MAJOR_VERSION 1 #define LLDB_API_MINOR_VERSION 0 diff --git a/include/lldb/module.modulemap b/include/lldb/module.modulemap index 9c7f3e6f58e5a..e040df8f913bd 100644 --- a/include/lldb/module.modulemap +++ b/include/lldb/module.modulemap @@ -2,6 +2,8 @@ module lldb_API { requires cplusplus + textual header "Utility/ReproducerInstrumentation.h" + umbrella "API" module * { export * } } @@ -17,6 +19,7 @@ module lldb_Host { module Editline { header "Host/Editline.h" export * } module FileCache { header "Host/FileCache.h" export * } module File { header "Host/File.h" export * } + module FileAction { header "Host/FileAction.h" export * } module FileSystem { header "Host/FileSystem.h" export * } module HostGetOpt { header "Host/HostGetOpt.h" export * } module Host { header "Host/Host.h" export * } @@ -39,13 +42,13 @@ module lldb_Host { module Pipe { header "Host/Pipe.h" export * } module PosixApi { header "Host/PosixApi.h" export * } module ProcessLauncher { header "Host/ProcessLauncher.h" export * } + module ProcessLaunchInfo { header "Host/ProcessLaunchInfo.h" export * } module ProcessRunLock { header "Host/ProcessRunLock.h" export * } module PseudoTerminal { header "Host/PseudoTerminal.h" export * } module SafeMachO { header "Host/SafeMachO.h" export * } module SocketAddress { header "Host/SocketAddress.h" export * } module Socket { header "Host/Socket.h" export * } - module StringConvert { header "Host/StringConvert.h" export * } - module Symbols { header "Host/Symbols.h" export * } + module StringConvert { textual header "Host/StringConvert.h" export * } module TaskPool { header "Host/TaskPool.h" export * } module Terminal { header "Host/Terminal.h" export * } module ThreadLauncher { header "Host/ThreadLauncher.h" export * } @@ -135,5 +138,4 @@ module lldb_Utility { module lldb_public { header "lldb-public.h" export * } module lldb_types { header "lldb-types.h" export * } module lldb_versioning { header "lldb-versioning.h" export * } - } |