diff options
Diffstat (limited to 'lldb/include/lldb')
464 files changed, 5079 insertions, 5576 deletions
diff --git a/lldb/include/lldb/API/LLDB.h b/lldb/include/lldb/API/LLDB.h index 75e2d70c0c39..83c38d3b6166 100644 --- a/lldb/include/lldb/API/LLDB.h +++ b/lldb/include/lldb/API/LLDB.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef LLDB_LLDB_h_ -#define LLDB_LLDB_h_ +#ifndef LLDB_API_LLDB_H +#define LLDB_API_LLDB_H #include "lldb/API/SBAddress.h" #include "lldb/API/SBAttachInfo.h" @@ -24,6 +24,7 @@ #include "lldb/API/SBDebugger.h" #include "lldb/API/SBDeclaration.h" #include "lldb/API/SBDefines.h" +#include "lldb/API/SBEnvironment.h" #include "lldb/API/SBError.h" #include "lldb/API/SBEvent.h" #include "lldb/API/SBExecutionContext.h" @@ -78,4 +79,4 @@ #include "lldb/API/SBVariablesOptions.h" #include "lldb/API/SBWatchpoint.h" -#endif // LLDB_LLDB_h_ +#endif // LLDB_API_LLDB_H diff --git a/lldb/include/lldb/API/SBAddress.h b/lldb/include/lldb/API/SBAddress.h index 2874a3602af2..cf7555dc2ee8 100644 --- a/lldb/include/lldb/API/SBAddress.h +++ b/lldb/include/lldb/API/SBAddress.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef LLDB_SBAddress_h_ -#define LLDB_SBAddress_h_ +#ifndef LLDB_API_SBADDRESS_H +#define LLDB_API_SBADDRESS_H #include "lldb/API/SBDefines.h" #include "lldb/API/SBModule.h" @@ -127,4 +127,4 @@ bool LLDB_API operator==(const SBAddress &lhs, const SBAddress &rhs); } // namespace lldb -#endif // LLDB_SBAddress_h_ +#endif // LLDB_API_SBADDRESS_H diff --git a/lldb/include/lldb/API/SBAttachInfo.h b/lldb/include/lldb/API/SBAttachInfo.h index 3c20a08cb4a9..9b211d0f74bd 100644 --- a/lldb/include/lldb/API/SBAttachInfo.h +++ b/lldb/include/lldb/API/SBAttachInfo.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef LLDB_SBAttachInfo_h_ -#define LLDB_SBAttachInfo_h_ +#ifndef LLDB_API_SBATTACHINFO_H +#define LLDB_API_SBATTACHINFO_H #include "lldb/API/SBDefines.h" @@ -174,4 +174,4 @@ protected: } // namespace lldb -#endif // LLDB_SBAttachInfo_h_ +#endif // LLDB_API_SBATTACHINFO_H diff --git a/lldb/include/lldb/API/SBBlock.h b/lldb/include/lldb/API/SBBlock.h index 0ca92ff0c6ac..be1ae18e9db5 100644 --- a/lldb/include/lldb/API/SBBlock.h +++ b/lldb/include/lldb/API/SBBlock.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef LLDB_SBBlock_h_ -#define LLDB_SBBlock_h_ +#ifndef LLDB_API_SBBLOCK_H +#define LLDB_API_SBBLOCK_H #include "lldb/API/SBDefines.h" #include "lldb/API/SBFrame.h" @@ -92,4 +92,4 @@ private: } // namespace lldb -#endif // LLDB_SBBlock_h_ +#endif // LLDB_API_SBBLOCK_H diff --git a/lldb/include/lldb/API/SBBreakpoint.h b/lldb/include/lldb/API/SBBreakpoint.h index a5ce91d95089..c9a52fcacf1a 100644 --- a/lldb/include/lldb/API/SBBreakpoint.h +++ b/lldb/include/lldb/API/SBBreakpoint.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef LLDB_SBBreakpoint_h_ -#define LLDB_SBBreakpoint_h_ +#ifndef LLDB_API_SBBREAKPOINT_H +#define LLDB_API_SBBREAKPOINT_H #include "lldb/API/SBDefines.h" @@ -105,6 +105,8 @@ public: bool AddName(const char *new_name); + SBError AddNameWithErrorHandling(const char *new_name); + void RemoveName(const char *name_to_remove); bool MatchesName(const char *name); @@ -181,4 +183,4 @@ private: } // namespace lldb -#endif // LLDB_SBBreakpoint_h_ +#endif // LLDB_API_SBBREAKPOINT_H diff --git a/lldb/include/lldb/API/SBBreakpointLocation.h b/lldb/include/lldb/API/SBBreakpointLocation.h index a9e2ef1dd1b8..a906727f938a 100644 --- a/lldb/include/lldb/API/SBBreakpointLocation.h +++ b/lldb/include/lldb/API/SBBreakpointLocation.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef LLDB_SBBreakpointLocation_h_ -#define LLDB_SBBreakpointLocation_h_ +#ifndef LLDB_API_SBBREAKPOINTLOCATION_H +#define LLDB_API_SBBREAKPOINTLOCATION_H #include "lldb/API/SBBreakpoint.h" #include "lldb/API/SBDefines.h" @@ -100,4 +100,4 @@ private: } // namespace lldb -#endif // LLDB_SBBreakpointLocation_h_ +#endif // LLDB_API_SBBREAKPOINTLOCATION_H diff --git a/lldb/include/lldb/API/SBBreakpointName.h b/lldb/include/lldb/API/SBBreakpointName.h index 3a5f1acf3e4a..8dd2c4e5ef34 100644 --- a/lldb/include/lldb/API/SBBreakpointName.h +++ b/lldb/include/lldb/API/SBBreakpointName.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef LLDB_SBBreakpointName_h_ -#define LLDB_SBBreakpointName_h_ +#ifndef LLDB_API_SBBREAKPOINTNAME_H +#define LLDB_API_SBBREAKPOINTNAME_H #include "lldb/API/SBDefines.h" @@ -119,4 +119,4 @@ private: } // namespace lldb -#endif // LLDB_SBBreakpointName_h_ +#endif // LLDB_API_SBBREAKPOINTNAME_H diff --git a/lldb/include/lldb/API/SBBroadcaster.h b/lldb/include/lldb/API/SBBroadcaster.h index fc5e8880e9f2..69a516a8bfb1 100644 --- a/lldb/include/lldb/API/SBBroadcaster.h +++ b/lldb/include/lldb/API/SBBroadcaster.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef LLDB_SBBroadcaster_h_ -#define LLDB_SBBroadcaster_h_ +#ifndef LLDB_API_SBBROADCASTER_H +#define LLDB_API_SBBROADCASTER_H #include "lldb/API/SBDefines.h" @@ -81,4 +81,4 @@ private: } // namespace lldb -#endif // LLDB_SBBroadcaster_h_ +#endif // LLDB_API_SBBROADCASTER_H diff --git a/lldb/include/lldb/API/SBCommandInterpreter.h b/lldb/include/lldb/API/SBCommandInterpreter.h index 6c80e8eb26dc..a70e060bec99 100644 --- a/lldb/include/lldb/API/SBCommandInterpreter.h +++ b/lldb/include/lldb/API/SBCommandInterpreter.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef LLDB_SBCommandInterpreter_h_ -#define LLDB_SBCommandInterpreter_h_ +#ifndef LLDB_API_SBCOMMANDINTERPRETER_H +#define LLDB_API_SBCOMMANDINTERPRETER_H #include <memory> @@ -16,52 +16,6 @@ namespace lldb { -class LLDB_API SBCommandInterpreterRunOptions { - friend class SBDebugger; - friend class SBCommandInterpreter; - -public: - SBCommandInterpreterRunOptions(); - ~SBCommandInterpreterRunOptions(); - - bool GetStopOnContinue() const; - - void SetStopOnContinue(bool); - - bool GetStopOnError() const; - - void SetStopOnError(bool); - - bool GetStopOnCrash() const; - - void SetStopOnCrash(bool); - - bool GetEchoCommands() const; - - void SetEchoCommands(bool); - - bool GetEchoCommentCommands() const; - - void SetEchoCommentCommands(bool echo); - - bool GetPrintResults() const; - - void SetPrintResults(bool); - - bool GetAddToHistory() const; - - void SetAddToHistory(bool); - -private: - lldb_private::CommandInterpreterRunOptions *get() const; - - lldb_private::CommandInterpreterRunOptions &ref() const; - - // This is set in the constructor and will always be valid. - mutable std::unique_ptr<lldb_private::CommandInterpreterRunOptions> - m_opaque_up; -}; - class SBCommandInterpreter { public: enum { @@ -111,14 +65,86 @@ public: lldb::SBCommand AddMultiwordCommand(const char *name, const char *help); + /// Add a new command to the lldb::CommandInterpreter. + /// + /// The new command won't support autorepeat. If you need this functionality, + /// use the override of this function that accepts the \a auto_repeat_command + /// parameter. + /// + /// \param[in] name + /// The name of the command. + /// + /// \param[in] impl + /// The handler of this command. + /// + /// \param[in] help + /// The general description to show as part of the help message of this + /// command. + /// + /// \return + /// A lldb::SBCommand representing the newly created command. lldb::SBCommand AddCommand(const char *name, lldb::SBCommandPluginInterface *impl, const char *help); + /// Add a new command to the lldb::CommandInterpreter. + /// + /// The new command won't support autorepeat. If you need this functionality, + /// use the override of this function that accepts the \a auto_repeat_command + /// parameter. + /// + /// \param[in] name + /// The name of the command. + /// + /// \param[in] impl + /// The handler of this command. + /// + /// \param[in] help + /// The general description to show as part of the help message of this + /// command. + /// + /// \param[in] syntax + /// The syntax to show as part of the help message of this command. This + /// could include a description of the different arguments and flags this + /// command accepts. + /// + /// \return + /// A lldb::SBCommand representing the newly created command. lldb::SBCommand AddCommand(const char *name, lldb::SBCommandPluginInterface *impl, const char *help, const char *syntax); + /// Add a new command to the lldb::CommandInterpreter. + /// + /// \param[in] name + /// The name of the command. + /// + /// \param[in] impl + /// The handler of this command. + /// + /// \param[in] help + /// The general description to show as part of the help message of this + /// command. + /// + /// \param[in] syntax + /// The syntax to show as part of the help message of this command. This + /// could include a description of the different arguments and flags this + /// command accepts. + /// + /// \param[in] auto_repeat_command + /// Autorepeating is triggered when the user presses Enter successively + /// after executing a command. If \b nullptr is provided, the previous + /// exact command will be repeated. If \b "" is provided, autorepeating + /// is disabled. Otherwise, the provided string is used as a repeat + /// command. + /// + /// \return + /// A lldb::SBCommand representing the newly created command. + lldb::SBCommand AddCommand(const char *name, + lldb::SBCommandPluginInterface *impl, + const char *help, const char *syntax, + const char *auto_repeat_command); + void SourceInitFileInHomeDirectory(lldb::SBCommandReturnObject &result); void @@ -283,14 +309,90 @@ public: lldb::SBCommand AddMultiwordCommand(const char *name, const char *help = nullptr); + /// Add a new subcommand to the lldb::SBCommand. + /// + /// The new command won't support autorepeat. If you need this functionality, + /// use the override of this function that accepts the \a auto_repeat + /// parameter. + /// + /// \param[in] name + /// The name of the command. + /// + /// \param[in] impl + /// The handler of this command. + /// + /// \param[in] help + /// The general description to show as part of the help message of this + /// command. + /// + /// \return + /// A lldb::SBCommand representing the newly created command. lldb::SBCommand AddCommand(const char *name, lldb::SBCommandPluginInterface *impl, const char *help = nullptr); + /// Add a new subcommand to the lldb::SBCommand. + /// + /// The new command won't support autorepeat. If you need this functionality, + /// use the override of this function that accepts the \a auto_repeat_command + /// parameter. + /// + /// \param[in] name + /// The name of the command. + /// + /// \param[in] impl + /// The handler of this command. + /// + /// \param[in] help + /// The general description to show as part of the help message of this + /// command. + /// + /// \param[in] syntax + /// The syntax to show as part of the help message of this command. This + /// could include a description of the different arguments and flags this + /// command accepts. + /// + /// \return + /// A lldb::SBCommand representing the newly created command. lldb::SBCommand AddCommand(const char *name, lldb::SBCommandPluginInterface *impl, const char *help, const char *syntax); + /// Add a new subcommand to the lldb::SBCommand. + /// + /// The new command won't support autorepeat. If you need this functionality, + /// use the override of this function that accepts the \a auto_repeat_command + /// parameter. + /// + /// \param[in] name + /// The name of the command. + /// + /// \param[in] impl + /// The handler of this command. + /// + /// \param[in] help + /// The general description to show as part of the help message of this + /// command. + /// + /// \param[in] syntax + /// The syntax to show as part of the help message of this command. This + /// could include a description of the different arguments and flags this + /// command accepts. + /// + /// \param[in] auto_repeat_command + /// Autorepeating is triggered when the user presses Enter successively + /// after executing a command. If \b nullptr is provided, the previous + /// exact command will be repeated. If \b "" is provided, autorepeating + /// is disabled. Otherwise, the provided string is used as a repeat + /// command. + /// + /// \return + /// A lldb::SBCommand representing the newly created command. + lldb::SBCommand AddCommand(const char *name, + lldb::SBCommandPluginInterface *impl, + const char *help, const char *syntax, + const char *auto_repeat_command); + private: friend class SBDebugger; friend class SBCommandInterpreter; @@ -302,4 +404,4 @@ private: } // namespace lldb -#endif // LLDB_SBCommandInterpreter_h_ +#endif // LLDB_API_SBCOMMANDINTERPRETER_H diff --git a/lldb/include/lldb/API/SBCommandInterpreterRunOptions.h b/lldb/include/lldb/API/SBCommandInterpreterRunOptions.h new file mode 100644 index 000000000000..82d6feedc02e --- /dev/null +++ b/lldb/include/lldb/API/SBCommandInterpreterRunOptions.h @@ -0,0 +1,102 @@ +//===-- SBCommandInterpreterRunOptions.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_SBCOMMANDINTERPRETERRUNOPTIONS_H +#define LLDB_API_SBCOMMANDINTERPRETERRUNOPTIONS_H + +#include <memory> + +#include "lldb/API/SBDefines.h" + +namespace lldb_private { +class CommandInterpreterRunOptions; +class CommandInterpreterRunResult; +} // namespace lldb_private + +namespace lldb { + +class LLDB_API SBCommandInterpreterRunOptions { + friend class SBDebugger; + friend class SBCommandInterpreter; + +public: + SBCommandInterpreterRunOptions(); + ~SBCommandInterpreterRunOptions(); + + bool GetStopOnContinue() const; + + void SetStopOnContinue(bool); + + bool GetStopOnError() const; + + void SetStopOnError(bool); + + bool GetStopOnCrash() const; + + void SetStopOnCrash(bool); + + bool GetEchoCommands() const; + + void SetEchoCommands(bool); + + bool GetEchoCommentCommands() const; + + void SetEchoCommentCommands(bool echo); + + bool GetPrintResults() const; + + void SetPrintResults(bool); + + bool GetAddToHistory() const; + + void SetAddToHistory(bool); + + bool GetAutoHandleEvents() const; + + void SetAutoHandleEvents(bool); + + bool GetSpawnThread() const; + + void SetSpawnThread(bool); + +private: + lldb_private::CommandInterpreterRunOptions *get() const; + + lldb_private::CommandInterpreterRunOptions &ref() const; + + // This is set in the constructor and will always be valid. + mutable std::unique_ptr<lldb_private::CommandInterpreterRunOptions> + m_opaque_up; +}; + +class LLDB_API SBCommandInterpreterRunResult { + friend class SBDebugger; + friend class SBCommandInterpreter; + +public: + SBCommandInterpreterRunResult(); + SBCommandInterpreterRunResult(const SBCommandInterpreterRunResult &rhs); + ~SBCommandInterpreterRunResult(); + + SBCommandInterpreterRunResult & + operator=(const SBCommandInterpreterRunResult &rhs); + + int GetNumberOfErrors() const; + lldb::CommandInterpreterResult GetResult() const; + +private: + SBCommandInterpreterRunResult( + const lldb_private::CommandInterpreterRunResult &rhs); + + // This is set in the constructor and will always be valid. + std::unique_ptr<lldb_private::CommandInterpreterRunResult> m_opaque_up; +}; + +} // namespace lldb + +#endif // LLDB_API_SBCOMMANDINTERPRETERRUNOPTIONS_H diff --git a/lldb/include/lldb/API/SBCommandReturnObject.h b/lldb/include/lldb/API/SBCommandReturnObject.h index e3fbacf85afc..4ee296eb1797 100644 --- a/lldb/include/lldb/API/SBCommandReturnObject.h +++ b/lldb/include/lldb/API/SBCommandReturnObject.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef LLDB_SBCommandReturnObject_h_ -#define LLDB_SBCommandReturnObject_h_ +#ifndef LLDB_API_SBCOMMANDRETURNOBJECT_H +#define LLDB_API_SBCOMMANDRETURNOBJECT_H #include <stdio.h> @@ -124,4 +124,4 @@ private: } // namespace lldb -#endif // LLDB_SBCommandReturnObject_h_ +#endif // LLDB_API_SBCOMMANDRETURNOBJECT_H diff --git a/lldb/include/lldb/API/SBCommunication.h b/lldb/include/lldb/API/SBCommunication.h index 5b803fc6017c..84c341c0dfef 100644 --- a/lldb/include/lldb/API/SBCommunication.h +++ b/lldb/include/lldb/API/SBCommunication.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef LLDB_SBCommunication_h_ -#define LLDB_SBCommunication_h_ +#ifndef LLDB_API_SBCOMMUNICATION_H +#define LLDB_API_SBCOMMUNICATION_H #include "lldb/API/SBDefines.h" #include "lldb/API/SBError.h" @@ -72,7 +72,8 @@ public: void *callback_baton); private: - DISALLOW_COPY_AND_ASSIGN(SBCommunication); + SBCommunication(const SBCommunication &) = delete; + const SBCommunication &operator=(const SBCommunication &) = delete; lldb_private::Communication *m_opaque; bool m_opaque_owned; @@ -80,4 +81,4 @@ private: } // namespace lldb -#endif // LLDB_SBCommunication_h_ +#endif // LLDB_API_SBCOMMUNICATION_H diff --git a/lldb/include/lldb/API/SBCompileUnit.h b/lldb/include/lldb/API/SBCompileUnit.h index b6b138207d60..0c05ef44e31c 100644 --- a/lldb/include/lldb/API/SBCompileUnit.h +++ b/lldb/include/lldb/API/SBCompileUnit.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef LLDB_SBCompileUnit_h_ -#define LLDB_SBCompileUnit_h_ +#ifndef LLDB_API_SBCOMPILEUNIT_H +#define LLDB_API_SBCOMPILEUNIT_H #include "lldb/API/SBDefines.h" #include "lldb/API/SBFileSpec.h" @@ -92,4 +92,4 @@ private: } // namespace lldb -#endif // LLDB_SBCompileUnit_h_ +#endif // LLDB_API_SBCOMPILEUNIT_H diff --git a/lldb/include/lldb/API/SBData.h b/lldb/include/lldb/API/SBData.h index 886fe829a469..95c8086d5d47 100644 --- a/lldb/include/lldb/API/SBData.h +++ b/lldb/include/lldb/API/SBData.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef LLDB_SBData_h_ -#define LLDB_SBData_h_ +#ifndef LLDB_API_SBDATA_H +#define LLDB_API_SBDATA_H #include "lldb/API/SBDefines.h" @@ -152,4 +152,4 @@ private: } // namespace lldb -#endif // LLDB_SBData_h_ +#endif // LLDB_API_SBDATA_H diff --git a/lldb/include/lldb/API/SBDebugger.h b/lldb/include/lldb/API/SBDebugger.h index 580f6281fbb6..b3bfa230139c 100644 --- a/lldb/include/lldb/API/SBDebugger.h +++ b/lldb/include/lldb/API/SBDebugger.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef LLDB_SBDebugger_h_ -#define LLDB_SBDebugger_h_ +#ifndef LLDB_API_SBDEBUGGER_H +#define LLDB_API_SBDEBUGGER_H #include <stdio.h> @@ -199,6 +199,10 @@ public: bool GetUseColor() const; + bool SetUseSourceCache(bool use_source_cache); + + bool GetUseSourceCache() const; + static bool GetDefaultArchitecture(char *arch_name, size_t arch_name_len); static bool SetDefaultArchitecture(const char *arch_name); @@ -286,13 +290,50 @@ public: SBTypeSynthetic GetSyntheticForType(SBTypeNameSpecifier); + /// Run the command interpreter. + /// + /// \param[in] auto_handle_events + /// If true, automatically handle resulting events. This takes precedence + /// and overrides the corresponding option in + /// SBCommandInterpreterRunOptions. + /// + /// \param[in] spawn_thread + /// If true, start a new thread for IO handling. This takes precedence + /// and overrides the corresponding option in + /// SBCommandInterpreterRunOptions. void RunCommandInterpreter(bool auto_handle_events, bool spawn_thread); + /// Run the command interpreter. + /// + /// \param[in] auto_handle_events + /// If true, automatically handle resulting events. This takes precedence + /// and overrides the corresponding option in + /// SBCommandInterpreterRunOptions. + /// + /// \param[in] spawn_thread + /// If true, start a new thread for IO handling. This takes precedence + /// and overrides the corresponding option in + /// SBCommandInterpreterRunOptions. + /// + /// \param[in] options + /// Parameter collection of type SBCommandInterpreterRunOptions. + /// + /// \param[out] num_errors + /// The number of errors. + /// + /// \param[out] quit_requested + /// Whether a quit was requested. + /// + /// \param[out] stopped_for_crash + /// Whether the interpreter stopped for a crash. void RunCommandInterpreter(bool auto_handle_events, bool spawn_thread, SBCommandInterpreterRunOptions &options, int &num_errors, bool &quit_requested, bool &stopped_for_crash); + SBCommandInterpreterRunResult + RunCommandInterpreter(const SBCommandInterpreterRunOptions &options); + SBError RunREPL(lldb::LanguageType language, const char *repl_options); private: @@ -319,4 +360,4 @@ private: } // namespace lldb -#endif // LLDB_SBDebugger_h_ +#endif // LLDB_API_SBDEBUGGER_H diff --git a/lldb/include/lldb/API/SBDeclaration.h b/lldb/include/lldb/API/SBDeclaration.h index d2b423e40fec..aeaa28e1cada 100644 --- a/lldb/include/lldb/API/SBDeclaration.h +++ b/lldb/include/lldb/API/SBDeclaration.h @@ -7,8 +7,8 @@ // //===----------------------------------------------------------------------===// -#ifndef LLDB_SBDeclaration_h_ -#define LLDB_SBDeclaration_h_ +#ifndef LLDB_API_SBDECLARATION_H +#define LLDB_API_SBDECLARATION_H #include "lldb/API/SBDefines.h" #include "lldb/API/SBFileSpec.h" @@ -68,4 +68,4 @@ private: } // namespace lldb -#endif // LLDB_SBDeclaration_h_ +#endif // LLDB_API_SBDECLARATION_H diff --git a/lldb/include/lldb/API/SBDefines.h b/lldb/include/lldb/API/SBDefines.h index 68aca930d199..a5b639c6dc73 100644 --- a/lldb/include/lldb/API/SBDefines.h +++ b/lldb/include/lldb/API/SBDefines.h @@ -6,9 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef LLDB_SBDefines_h_ -#define LLDB_SBDefines_h_ - +#ifndef LLDB_API_SBDEFINES_H +#define LLDB_API_SBDEFINES_H #include "lldb/lldb-defines.h" #include "lldb/lldb-enumerations.h" @@ -29,6 +28,7 @@ class LLDB_API SBBroadcaster; class LLDB_API SBCommand; class LLDB_API SBCommandInterpreter; class LLDB_API SBCommandInterpreterRunOptions; +class LLDB_API SBCommandInterpreterRunResult; class LLDB_API SBCommandPluginInterface; class LLDB_API SBCommandReturnObject; class LLDB_API SBCommunication; @@ -36,6 +36,7 @@ class LLDB_API SBCompileUnit; class LLDB_API SBData; class LLDB_API SBDebugger; class LLDB_API SBDeclaration; +class LLDB_API SBEnvironment; class LLDB_API SBError; class LLDB_API SBEvent; class LLDB_API SBEventList; @@ -99,4 +100,4 @@ typedef bool (*SBBreakpointHitCallback)(void *baton, SBProcess &process, lldb::SBBreakpointLocation &location); } -#endif // LLDB_SBDefines_h_ +#endif // LLDB_API_SBDEFINES_H diff --git a/lldb/include/lldb/API/SBEnvironment.h b/lldb/include/lldb/API/SBEnvironment.h new file mode 100644 index 000000000000..f40ee01a42ab --- /dev/null +++ b/lldb/include/lldb/API/SBEnvironment.h @@ -0,0 +1,137 @@ +//===-- SBEnvironment.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_SBENVIRONMENT_H +#define LLDB_API_SBENVIRONMENT_H + +#include "lldb/API/SBDefines.h" + +namespace lldb { + +class LLDB_API SBEnvironment { +public: + SBEnvironment(); + + SBEnvironment(const lldb::SBEnvironment &rhs); + + ~SBEnvironment(); + + const lldb::SBEnvironment &operator=(const lldb::SBEnvironment &rhs); + + /// Return the value of a given environment variable. + /// + /// \param [in] name + /// The name of the environment variable. + /// + /// \return + /// The value of the environment variable or null if not present. + /// If the environment variable has no value but is present, a valid + /// pointer to an empty string will be returned. + const char *Get(const char *name); + + /// \return + /// The number of environment variables. + size_t GetNumValues(); + + /// Return the name of the environment variable at a given index from the + /// internal list of environment variables. + /// + /// \param [in] index + /// The index of the environment variable in the internal list. + /// + /// \return + /// The name at the given index or null if the index is invalid. + const char *GetNameAtIndex(size_t index); + + /// Return the value of the environment variable at a given index from the + /// internal list of environment variables. + /// + /// \param [in] index + /// The index of the environment variable in the internal list. + /// + /// \return + /// The value at the given index or null if the index is invalid. + /// If the environment variable has no value but is present, a valid + /// pointer to an empty string will be returned. + const char *GetValueAtIndex(size_t index); + + /// Return all environment variables contained in this object. Each variable + /// is returned as a string with the following format + /// name=value + /// + /// \return + /// Return an lldb::SBStringList object with the environment variables. + SBStringList GetEntries(); + + /// Add or replace an existing environment variable. The input must be a + /// string with the format + /// name=value + /// + /// \param [in] name_and_value + /// The entry to set which conforms to the format mentioned above. + void PutEntry(const char *name_and_value); + + /// Update this object with the given environment variables. The input is a + /// list of entries with the same format required by SBEnvironment::PutEntry. + /// + /// If append is false, the provided environment will replace the existing + /// environment. Otherwise, existing values will be updated of left untouched + /// accordingly. + /// + /// \param [in] entries + /// The environment variable entries. + /// + /// \param [in] append + /// Flag that controls whether to replace the existing environment. + void SetEntries(const SBStringList &entries, bool append); + + /// Set the value of a given environment variable. + /// If the variable exists, its value is updated only if overwrite is true. + /// + /// \param [in] name + /// The name of the environment variable to set. + /// + /// \param [in] value + /// The value of the environment variable to set. + /// + /// \param [in] overwrite + /// Flag that indicates whether to overwrite an existing environment + /// variable. + /// + /// \return + /// Return whether the variable was added or modified. + bool Set(const char *name, const char *value, bool overwrite); + + /// Unset an environment variable if exists. + /// + /// \param [in] name + /// The name of the environment variable to unset. + /// + /// \return + /// Return whether a variable was actually unset. + bool Unset(const char *name); + + /// Delete all the environment variables. + void Clear(); + +protected: + friend class SBPlatform; + friend class SBTarget; + friend class SBLaunchInfo; + + SBEnvironment(lldb_private::Environment rhs); + + lldb_private::Environment &ref() const; + +private: + std::unique_ptr<lldb_private::Environment> m_opaque_up; +}; + +} // namespace lldb + +#endif // LLDB_API_SBENVIRONMENT_H diff --git a/lldb/include/lldb/API/SBError.h b/lldb/include/lldb/API/SBError.h index 3db2658d9fb7..e1960ef9a983 100644 --- a/lldb/include/lldb/API/SBError.h +++ b/lldb/include/lldb/API/SBError.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef LLDB_SBError_h_ -#define LLDB_SBError_h_ +#ifndef LLDB_API_SBERROR_H +#define LLDB_API_SBERROR_H #include "lldb/API/SBDefines.h" @@ -90,4 +90,4 @@ private: } // namespace lldb -#endif // LLDB_SBError_h_ +#endif // LLDB_API_SBERROR_H diff --git a/lldb/include/lldb/API/SBEvent.h b/lldb/include/lldb/API/SBEvent.h index d297cbeff671..a7975bf9abae 100644 --- a/lldb/include/lldb/API/SBEvent.h +++ b/lldb/include/lldb/API/SBEvent.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef LLDB_SBEvent_h_ -#define LLDB_SBEvent_h_ +#ifndef LLDB_API_SBEVENT_H +#define LLDB_API_SBEVENT_H #include "lldb/API/SBDefines.h" @@ -84,4 +84,4 @@ private: } // namespace lldb -#endif // LLDB_SBEvent_h_ +#endif // LLDB_API_SBEVENT_H diff --git a/lldb/include/lldb/API/SBExecutionContext.h b/lldb/include/lldb/API/SBExecutionContext.h index 45c0b1b7f97b..d8447aeb1a2f 100644 --- a/lldb/include/lldb/API/SBExecutionContext.h +++ b/lldb/include/lldb/API/SBExecutionContext.h @@ -7,8 +7,8 @@ // //===----------------------------------------------------------------------===// -#ifndef LLDB_SBExecutionContext_h_ -#define LLDB_SBExecutionContext_h_ +#ifndef LLDB_API_SBEXECUTIONCONTEXT_H +#define LLDB_API_SBEXECUTIONCONTEXT_H #include "lldb/API/SBDefines.h" @@ -60,4 +60,4 @@ private: } // namespace lldb -#endif // LLDB_SBExecutionContext_h_ +#endif // LLDB_API_SBEXECUTIONCONTEXT_H diff --git a/lldb/include/lldb/API/SBExpressionOptions.h b/lldb/include/lldb/API/SBExpressionOptions.h index 04cd74f730f2..9fc6e9ea957e 100644 --- a/lldb/include/lldb/API/SBExpressionOptions.h +++ b/lldb/include/lldb/API/SBExpressionOptions.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef LLDB_SBExpressionOptions_h_ -#define LLDB_SBExpressionOptions_h_ +#ifndef LLDB_API_SBEXPRESSIONOPTIONS_H +#define LLDB_API_SBEXPRESSIONOPTIONS_H #include "lldb/API/SBDefines.h" @@ -86,6 +86,10 @@ public: bool GetAutoApplyFixIts(); + void SetRetriesWithFixIts(uint64_t retries); + + uint64_t GetRetriesWithFixIts(); + bool GetTopLevel(); void SetTopLevel(bool b = true); @@ -112,4 +116,4 @@ private: } // namespace lldb -#endif // LLDB_SBExpressionOptions_h_ +#endif // LLDB_API_SBEXPRESSIONOPTIONS_H diff --git a/lldb/include/lldb/API/SBFile.h b/lldb/include/lldb/API/SBFile.h index 7d6c14809923..a8b16520332d 100644 --- a/lldb/include/lldb/API/SBFile.h +++ b/lldb/include/lldb/API/SBFile.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef LLDB_SBFile_h_ -#define LLDB_SBFile_h_ +#ifndef LLDB_API_SBFILE_H +#define LLDB_API_SBFILE_H #include "lldb/API/SBDefines.h" @@ -23,10 +23,13 @@ class LLDB_API SBFile { public: SBFile(); SBFile(FileSP file_sp); + SBFile(const SBFile &rhs); SBFile(FILE *file, bool transfer_ownership); SBFile(int fd, const char *mode, bool transfer_ownership); ~SBFile(); + SBFile &operator=(const SBFile &rhs); + SBError Read(uint8_t *buf, size_t num_bytes, size_t *bytes_read); SBError Write(const uint8_t *buf, size_t num_bytes, size_t *bytes_written); SBError Flush(); @@ -44,4 +47,4 @@ private: } // namespace lldb -#endif // LLDB_SBFile_h_ +#endif // LLDB_API_SBFILE_H diff --git a/lldb/include/lldb/API/SBFileSpec.h b/lldb/include/lldb/API/SBFileSpec.h index 27149775901e..a2f02ac78208 100644 --- a/lldb/include/lldb/API/SBFileSpec.h +++ b/lldb/include/lldb/API/SBFileSpec.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef LLDB_SBFileSpec_h_ -#define LLDB_SBFileSpec_h_ +#ifndef LLDB_API_SBFILESPEC_H +#define LLDB_API_SBFILESPEC_H #include "lldb/API/SBDefines.h" @@ -92,4 +92,4 @@ private: } // namespace lldb -#endif // LLDB_SBFileSpec_h_ +#endif // LLDB_API_SBFILESPEC_H diff --git a/lldb/include/lldb/API/SBFileSpecList.h b/lldb/include/lldb/API/SBFileSpecList.h index 5a131509d269..1a654865a307 100644 --- a/lldb/include/lldb/API/SBFileSpecList.h +++ b/lldb/include/lldb/API/SBFileSpecList.h @@ -7,8 +7,8 @@ // //===----------------------------------------------------------------------===// -#ifndef LLDB_SBFileSpecList_h_ -#define LLDB_SBFileSpecList_h_ +#ifndef LLDB_API_SBFILESPECLIST_H +#define LLDB_API_SBFILESPECLIST_H #include "lldb/API/SBDefines.h" @@ -54,4 +54,4 @@ private: } // namespace lldb -#endif // LLDB_SBFileSpecList_h_ +#endif // LLDB_API_SBFILESPECLIST_H diff --git a/lldb/include/lldb/API/SBFrame.h b/lldb/include/lldb/API/SBFrame.h index b213f8985510..2e368accbbb5 100644 --- a/lldb/include/lldb/API/SBFrame.h +++ b/lldb/include/lldb/API/SBFrame.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef LLDB_SBFrame_h_ -#define LLDB_SBFrame_h_ +#ifndef LLDB_API_SBFRAME_H +#define LLDB_API_SBFRAME_H #include "lldb/API/SBDefines.h" #include "lldb/API/SBValueList.h" @@ -202,4 +202,4 @@ protected: } // namespace lldb -#endif // LLDB_SBFrame_h_ +#endif // LLDB_API_SBFRAME_H diff --git a/lldb/include/lldb/API/SBFunction.h b/lldb/include/lldb/API/SBFunction.h index 43f01d7e57de..bd643a62206f 100644 --- a/lldb/include/lldb/API/SBFunction.h +++ b/lldb/include/lldb/API/SBFunction.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef LLDB_SBFunction_h_ -#define LLDB_SBFunction_h_ +#ifndef LLDB_API_SBFUNCTION_H +#define LLDB_API_SBFUNCTION_H #include "lldb/API/SBAddress.h" #include "lldb/API/SBDefines.h" @@ -79,4 +79,4 @@ private: } // namespace lldb -#endif // LLDB_SBFunction_h_ +#endif // LLDB_API_SBFUNCTION_H diff --git a/lldb/include/lldb/API/SBHostOS.h b/lldb/include/lldb/API/SBHostOS.h index ecd7920f2c14..b170f8d65810 100644 --- a/lldb/include/lldb/API/SBHostOS.h +++ b/lldb/include/lldb/API/SBHostOS.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef LLDB_SBHostOS_h_ -#define LLDB_SBHostOS_h_ +#ifndef LLDB_API_SBHOSTOS_H +#define LLDB_API_SBHOSTOS_H #include "lldb/API/SBDefines.h" #include "lldb/API/SBFileSpec.h" @@ -41,4 +41,4 @@ private: } // namespace lldb -#endif // LLDB_SBHostOS_h_ +#endif // LLDB_API_SBHOSTOS_H diff --git a/lldb/include/lldb/API/SBInstruction.h b/lldb/include/lldb/API/SBInstruction.h index 7d83a37ba5d6..7d07e168cf03 100644 --- a/lldb/include/lldb/API/SBInstruction.h +++ b/lldb/include/lldb/API/SBInstruction.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef LLDB_SBInstruction_h_ -#define LLDB_SBInstruction_h_ +#ifndef LLDB_API_SBINSTRUCTION_H +#define LLDB_API_SBINSTRUCTION_H #include "lldb/API/SBData.h" #include "lldb/API/SBDefines.h" @@ -86,4 +86,4 @@ private: } // namespace lldb -#endif // LLDB_SBInstruction_h_ +#endif // LLDB_API_SBINSTRUCTION_H diff --git a/lldb/include/lldb/API/SBInstructionList.h b/lldb/include/lldb/API/SBInstructionList.h index e203d0b80564..ae8988004e26 100644 --- a/lldb/include/lldb/API/SBInstructionList.h +++ b/lldb/include/lldb/API/SBInstructionList.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef LLDB_SBInstructionList_h_ -#define LLDB_SBInstructionList_h_ +#ifndef LLDB_API_SBINSTRUCTIONLIST_H +#define LLDB_API_SBINSTRUCTIONLIST_H #include "lldb/API/SBDefines.h" @@ -69,4 +69,4 @@ private: } // namespace lldb -#endif // LLDB_SBInstructionList_h_ +#endif // LLDB_API_SBINSTRUCTIONLIST_H diff --git a/lldb/include/lldb/API/SBLanguageRuntime.h b/lldb/include/lldb/API/SBLanguageRuntime.h index d28c441593ea..38aac05d490c 100644 --- a/lldb/include/lldb/API/SBLanguageRuntime.h +++ b/lldb/include/lldb/API/SBLanguageRuntime.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef LLDB_SBLanguageRuntime_h_ -#define LLDB_SBLanguageRuntime_h_ +#ifndef LLDB_API_SBLANGUAGERUNTIME_H +#define LLDB_API_SBLANGUAGERUNTIME_H #include "lldb/API/SBDefines.h" @@ -22,4 +22,4 @@ public: } // namespace lldb -#endif // LLDB_SBLanguageRuntime_h_ +#endif // LLDB_API_SBLANGUAGERUNTIME_H diff --git a/lldb/include/lldb/API/SBLaunchInfo.h b/lldb/include/lldb/API/SBLaunchInfo.h index c7b381ffdf97..04ebb5707688 100644 --- a/lldb/include/lldb/API/SBLaunchInfo.h +++ b/lldb/include/lldb/API/SBLaunchInfo.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef LLDB_SBLaunchInfo_h_ -#define LLDB_SBLaunchInfo_h_ +#ifndef LLDB_API_SBLAUNCHINFO_H +#define LLDB_API_SBLAUNCHINFO_H #include "lldb/API/SBDefines.h" @@ -26,6 +26,10 @@ public: ~SBLaunchInfo(); + SBLaunchInfo(const SBLaunchInfo &rhs); + + SBLaunchInfo &operator=(const SBLaunchInfo &rhs); + lldb::pid_t GetProcessID(); uint32_t GetUserID(); @@ -90,8 +94,41 @@ public: const char *GetEnvironmentEntryAtIndex(uint32_t idx); + /// Update this object with the given environment variables. + /// + /// If append is false, the provided environment will replace the existing + /// environment. Otherwise, existing values will be updated of left untouched + /// accordingly. + /// + /// \param [in] envp + /// The new environment variables as a list of strings with the following + /// format + /// name=value + /// + /// \param [in] append + /// Flag that controls whether to replace the existing environment. void SetEnvironmentEntries(const char **envp, bool append); + /// Update this object with the given environment variables. + /// + /// If append is false, the provided environment will replace the existing + /// environment. Otherwise, existing values will be updated of left untouched + /// accordingly. + /// + /// \param [in] env + /// The new environment variables. + /// + /// \param [in] append + /// Flag that controls whether to replace the existing environment. + void SetEnvironment(const SBEnvironment &env, bool append); + + /// Return the environment variables of this object. + /// + /// \return + /// An lldb::SBEnvironment object which is a copy of the SBLaunchInfo's + /// environment. + SBEnvironment GetEnvironment(); + void Clear(); const char *GetWorkingDirectory() const; @@ -146,4 +183,4 @@ protected: } // namespace lldb -#endif // LLDB_SBLaunchInfo_h_ +#endif // LLDB_API_SBLAUNCHINFO_H diff --git a/lldb/include/lldb/API/SBLineEntry.h b/lldb/include/lldb/API/SBLineEntry.h index 855c28d14b83..7c2431ba3c8a 100644 --- a/lldb/include/lldb/API/SBLineEntry.h +++ b/lldb/include/lldb/API/SBLineEntry.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef LLDB_SBLineEntry_h_ -#define LLDB_SBLineEntry_h_ +#ifndef LLDB_API_SBLINEENTRY_H +#define LLDB_API_SBLINEENTRY_H #include "lldb/API/SBAddress.h" #include "lldb/API/SBDefines.h" @@ -75,4 +75,4 @@ private: } // namespace lldb -#endif // LLDB_SBLineEntry_h_ +#endif // LLDB_API_SBLINEENTRY_H diff --git a/lldb/include/lldb/API/SBListener.h b/lldb/include/lldb/API/SBListener.h index 21aface97bd1..2144e7956b13 100644 --- a/lldb/include/lldb/API/SBListener.h +++ b/lldb/include/lldb/API/SBListener.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef LLDB_SBListener_h_ -#define LLDB_SBListener_h_ +#ifndef LLDB_API_SBLISTENER_H +#define LLDB_API_SBLISTENER_H #include "lldb/API/SBDefines.h" @@ -105,4 +105,4 @@ private: } // namespace lldb -#endif // LLDB_SBListener_h_ +#endif // LLDB_API_SBLISTENER_H diff --git a/lldb/include/lldb/API/SBMemoryRegionInfo.h b/lldb/include/lldb/API/SBMemoryRegionInfo.h index 2a9ae94218f2..d82c70606559 100644 --- a/lldb/include/lldb/API/SBMemoryRegionInfo.h +++ b/lldb/include/lldb/API/SBMemoryRegionInfo.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef LLDB_SBMemoryRegionInfo_h_ -#define LLDB_SBMemoryRegionInfo_h_ +#ifndef LLDB_API_SBMEMORYREGIONINFO_H +#define LLDB_API_SBMEMORYREGIONINFO_H #include "lldb/API/SBData.h" #include "lldb/API/SBDefines.h" @@ -95,4 +95,4 @@ private: } // namespace lldb -#endif // LLDB_SBMemoryRegionInfo_h_ +#endif // LLDB_API_SBMEMORYREGIONINFO_H diff --git a/lldb/include/lldb/API/SBMemoryRegionInfoList.h b/lldb/include/lldb/API/SBMemoryRegionInfoList.h index 5592efef4851..a7122ee9108a 100644 --- a/lldb/include/lldb/API/SBMemoryRegionInfoList.h +++ b/lldb/include/lldb/API/SBMemoryRegionInfoList.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef LLDB_SBMemoryRegionInfoList_h_ -#define LLDB_SBMemoryRegionInfoList_h_ +#ifndef LLDB_API_SBMEMORYREGIONINFOLIST_H +#define LLDB_API_SBMEMORYREGIONINFOLIST_H #include "lldb/API/SBDefines.h" @@ -52,4 +52,4 @@ private: } // namespace lldb -#endif // LLDB_SBMemoryRegionInfoList_h_ +#endif // LLDB_API_SBMEMORYREGIONINFOLIST_H diff --git a/lldb/include/lldb/API/SBModule.h b/lldb/include/lldb/API/SBModule.h index d2b6a18db84d..859eaffe89a0 100644 --- a/lldb/include/lldb/API/SBModule.h +++ b/lldb/include/lldb/API/SBModule.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef LLDB_SBModule_h_ -#define LLDB_SBModule_h_ +#ifndef LLDB_API_SBMODULE_H +#define LLDB_API_SBMODULE_H #include "lldb/API/SBDefines.h" #include "lldb/API/SBError.h" @@ -288,6 +288,9 @@ public: lldb::SBAddress GetObjectFileHeaderAddress() const; lldb::SBAddress GetObjectFileEntryPointAddress() const; + /// Get the number of global modules. + static uint32_t GetNumberAllocatedModules(); + private: friend class SBAddress; friend class SBFrame; @@ -306,4 +309,4 @@ private: } // namespace lldb -#endif // LLDB_SBModule_h_ +#endif // LLDB_API_SBMODULE_H diff --git a/lldb/include/lldb/API/SBModuleSpec.h b/lldb/include/lldb/API/SBModuleSpec.h index 29b3117a261d..7529879b78b5 100644 --- a/lldb/include/lldb/API/SBModuleSpec.h +++ b/lldb/include/lldb/API/SBModuleSpec.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef LLDB_SBModuleSpec_h_ -#define LLDB_SBModuleSpec_h_ +#ifndef LLDB_API_SBMODULESPEC_H +#define LLDB_API_SBMODULESPEC_H #include "lldb/API/SBDefines.h" #include "lldb/API/SBFileSpec.h" @@ -119,4 +119,4 @@ private: } // namespace lldb -#endif // LLDB_SBModuleSpec_h_ +#endif // LLDB_API_SBMODULESPEC_H diff --git a/lldb/include/lldb/API/SBPlatform.h b/lldb/include/lldb/API/SBPlatform.h index 7207b2e2a78d..4d251b129954 100644 --- a/lldb/include/lldb/API/SBPlatform.h +++ b/lldb/include/lldb/API/SBPlatform.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef LLDB_SBPlatform_h_ -#define LLDB_SBPlatform_h_ +#ifndef LLDB_API_SBPLATFORM_H +#define LLDB_API_SBPLATFORM_H #include "lldb/API/SBDefines.h" @@ -28,7 +28,7 @@ public: ~SBPlatformConnectOptions(); - void operator=(const SBPlatformConnectOptions &rhs); + SBPlatformConnectOptions &operator=(const SBPlatformConnectOptions &rhs); const char *GetURL(); @@ -55,6 +55,8 @@ public: SBPlatformShellCommand(const SBPlatformShellCommand &rhs); + SBPlatformShellCommand &operator=(const SBPlatformShellCommand &rhs); + ~SBPlatformShellCommand(); void Clear(); @@ -89,8 +91,14 @@ public: SBPlatform(const char *platform_name); + SBPlatform(const SBPlatform &rhs); + + SBPlatform &operator=(const SBPlatform &rhs); + ~SBPlatform(); + static SBPlatform GetHostPlatform(); + explicit operator bool() const; bool IsValid() const; @@ -146,6 +154,14 @@ public: SBUnixSignals GetUnixSignals() const; + /// Return the environment variables of the remote platform connection + /// process. + /// + /// \return + /// An lldb::SBEnvironment object which is a copy of the platform's + /// environment. + SBEnvironment GetEnvironment(); + protected: friend class SBDebugger; friend class SBTarget; @@ -163,4 +179,4 @@ protected: } // namespace lldb -#endif // LLDB_SBPlatform_h_ +#endif // LLDB_API_SBPLATFORM_H diff --git a/lldb/include/lldb/API/SBProcess.h b/lldb/include/lldb/API/SBProcess.h index 8ab8bfa3a93e..a90ec2a29a39 100644 --- a/lldb/include/lldb/API/SBProcess.h +++ b/lldb/include/lldb/API/SBProcess.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef LLDB_SBProcess_h_ -#define LLDB_SBProcess_h_ +#ifndef LLDB_API_SBPROCESS_H +#define LLDB_API_SBPROCESS_H #include "lldb/API/SBDefines.h" #include "lldb/API/SBError.h" @@ -222,6 +222,8 @@ public: bool GetDescription(lldb::SBStream &description); + SBStructuredData GetExtendedCrashInformation(); + /// Start Tracing with the given SBTraceOptions. /// /// \param[in] options @@ -416,4 +418,4 @@ protected: } // namespace lldb -#endif // LLDB_SBProcess_h_ +#endif // LLDB_API_SBPROCESS_H diff --git a/lldb/include/lldb/API/SBProcessInfo.h b/lldb/include/lldb/API/SBProcessInfo.h index 86dba9a8e116..0cc5f6a2f9f6 100644 --- a/lldb/include/lldb/API/SBProcessInfo.h +++ b/lldb/include/lldb/API/SBProcessInfo.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef LLDB_SBProcessInfo_h_ -#define LLDB_SBProcessInfo_h_ +#ifndef LLDB_API_SBPROCESSINFO_H +#define LLDB_API_SBPROCESSINFO_H #include "lldb/API/SBDefines.h" @@ -62,4 +62,4 @@ private: } // namespace lldb -#endif // LLDB_SBProcessInfo_h_ +#endif // LLDB_API_SBPROCESSINFO_H diff --git a/lldb/include/lldb/API/SBQueue.h b/lldb/include/lldb/API/SBQueue.h index 0124c1c90dd2..c563f3ee1c20 100644 --- a/lldb/include/lldb/API/SBQueue.h +++ b/lldb/include/lldb/API/SBQueue.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef LLDB_SBQueue_h_ -#define LLDB_SBQueue_h_ +#ifndef LLDB_API_SBQUEUE_H +#define LLDB_API_SBQUEUE_H #include <vector> @@ -66,4 +66,4 @@ private: } // namespace lldb -#endif // LLDB_SBQueue_h_ +#endif // LLDB_API_SBQUEUE_H diff --git a/lldb/include/lldb/API/SBQueueItem.h b/lldb/include/lldb/API/SBQueueItem.h index 455a1f98379a..435dafe534a6 100644 --- a/lldb/include/lldb/API/SBQueueItem.h +++ b/lldb/include/lldb/API/SBQueueItem.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef LLDB_SBQueueItem_h_ -#define LLDB_SBQueueItem_h_ +#ifndef LLDB_API_SBQUEUEITEM_H +#define LLDB_API_SBQUEUEITEM_H #include "lldb/API/SBAddress.h" #include "lldb/API/SBDefines.h" @@ -46,4 +46,4 @@ private: } // namespace lldb -#endif // LLDB_SBQueueItem_h_ +#endif // LLDB_API_SBQUEUEITEM_H diff --git a/lldb/include/lldb/API/SBReproducer.h b/lldb/include/lldb/API/SBReproducer.h index 93d78f55fd76..78044e9acbc3 100644 --- a/lldb/include/lldb/API/SBReproducer.h +++ b/lldb/include/lldb/API/SBReproducer.h @@ -22,8 +22,17 @@ public: static const char *Capture(const char *path); static const char *Replay(const char *path); static const char *Replay(const char *path, bool skip_version_check); + static const char *PassiveReplay(const char *path); static const char *GetPath(); + static bool SetAutoGenerate(bool b); static bool Generate(); + + /// The working directory is set to the current working directory when the + /// reproducers are initialized. This method allows setting a different + /// working directory. This is used by the API test suite which temporarily + /// changes the directory to where the test lives. This is a NO-OP in every + /// mode but capture. + static void SetWorkingDirectory(const char *path); }; } // namespace lldb diff --git a/lldb/include/lldb/API/SBSection.h b/lldb/include/lldb/API/SBSection.h index 06a195ee78df..d722dbe4ff1f 100644 --- a/lldb/include/lldb/API/SBSection.h +++ b/lldb/include/lldb/API/SBSection.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef LLDB_SBSection_h_ -#define LLDB_SBSection_h_ +#ifndef LLDB_API_SBSECTION_H +#define LLDB_API_SBSECTION_H #include "lldb/API/SBData.h" #include "lldb/API/SBDefines.h" @@ -98,4 +98,4 @@ private: } // namespace lldb -#endif // LLDB_SBSection_h_ +#endif // LLDB_API_SBSECTION_H diff --git a/lldb/include/lldb/API/SBSourceManager.h b/lldb/include/lldb/API/SBSourceManager.h index 3d69aa25a934..c8302dbda3c0 100644 --- a/lldb/include/lldb/API/SBSourceManager.h +++ b/lldb/include/lldb/API/SBSourceManager.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef LLDB_SBSourceManager_h_ -#define LLDB_SBSourceManager_h_ +#ifndef LLDB_API_SBSOURCEMANAGER_H +#define LLDB_API_SBSOURCEMANAGER_H #include "lldb/API/SBDefines.h" @@ -44,4 +44,4 @@ private: } // namespace lldb -#endif // LLDB_SBSourceManager_h_ +#endif // LLDB_API_SBSOURCEMANAGER_H diff --git a/lldb/include/lldb/API/SBStream.h b/lldb/include/lldb/API/SBStream.h index b78c498e5f3d..f44b87bb4c98 100644 --- a/lldb/include/lldb/API/SBStream.h +++ b/lldb/include/lldb/API/SBStream.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef LLDB_SBStream_h_ -#define LLDB_SBStream_h_ +#ifndef LLDB_API_SBSTREAM_H +#define LLDB_API_SBSTREAM_H #include <stdio.h> @@ -37,6 +37,8 @@ public: void Printf(const char *format, ...) __attribute__((format(printf, 2, 3))); + void Print(const char *str); + void RedirectToFile(const char *path, bool append); void RedirectToFile(lldb::SBFile file); @@ -99,11 +101,12 @@ protected: lldb_private::Stream &ref(); private: - DISALLOW_COPY_AND_ASSIGN(SBStream); + SBStream(const SBStream &) = delete; + const SBStream &operator=(const SBStream &) = delete; std::unique_ptr<lldb_private::Stream> m_opaque_up; bool m_is_file; }; } // namespace lldb -#endif // LLDB_SBStream_h_ +#endif // LLDB_API_SBSTREAM_H diff --git a/lldb/include/lldb/API/SBStringList.h b/lldb/include/lldb/API/SBStringList.h index 1df1e45f96fe..4842c162bd6e 100644 --- a/lldb/include/lldb/API/SBStringList.h +++ b/lldb/include/lldb/API/SBStringList.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef LLDB_SBStringList_h_ -#define LLDB_SBStringList_h_ +#ifndef LLDB_API_SBSTRINGLIST_H +#define LLDB_API_SBSTRINGLIST_H #include "lldb/API/SBDefines.h" @@ -62,4 +62,4 @@ private: } // namespace lldb -#endif // LLDB_SBStringList_h_ +#endif // LLDB_API_SBSTRINGLIST_H diff --git a/lldb/include/lldb/API/SBStructuredData.h b/lldb/include/lldb/API/SBStructuredData.h index 785e91047fdf..44a86bdabe25 100644 --- a/lldb/include/lldb/API/SBStructuredData.h +++ b/lldb/include/lldb/API/SBStructuredData.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef SBStructuredData_h -#define SBStructuredData_h +#ifndef LLDB_API_SBSTRUCTUREDDATA_H +#define LLDB_API_SBSTRUCTUREDDATA_H #include "lldb/API/SBDefines.h" #include "lldb/API/SBModule.h" @@ -91,6 +91,7 @@ protected: friend class SBTraceOptions; friend class SBDebugger; friend class SBTarget; + friend class SBProcess; friend class SBThread; friend class SBThreadPlan; friend class SBBreakpoint; @@ -101,4 +102,4 @@ protected: }; } // namespace lldb -#endif /* SBStructuredData_h */ +#endif // LLDB_API_SBSTRUCTUREDDATA_H diff --git a/lldb/include/lldb/API/SBSymbol.h b/lldb/include/lldb/API/SBSymbol.h index 52486b83d1a7..66f73c82a73a 100644 --- a/lldb/include/lldb/API/SBSymbol.h +++ b/lldb/include/lldb/API/SBSymbol.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef LLDB_SBSymbol_h_ -#define LLDB_SBSymbol_h_ +#ifndef LLDB_API_SBSYMBOL_H +#define LLDB_API_SBSYMBOL_H #include "lldb/API/SBAddress.h" #include "lldb/API/SBDefines.h" @@ -83,4 +83,4 @@ private: } // namespace lldb -#endif // LLDB_SBSymbol_h_ +#endif // LLDB_API_SBSYMBOL_H diff --git a/lldb/include/lldb/API/SBSymbolContext.h b/lldb/include/lldb/API/SBSymbolContext.h index 3d16d0989ca1..16ad29ea8730 100644 --- a/lldb/include/lldb/API/SBSymbolContext.h +++ b/lldb/include/lldb/API/SBSymbolContext.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef LLDB_SBSymbolContext_h_ -#define LLDB_SBSymbolContext_h_ +#ifndef LLDB_API_SBSYMBOLCONTEXT_H +#define LLDB_API_SBSYMBOLCONTEXT_H #include "lldb/API/SBBlock.h" #include "lldb/API/SBCompileUnit.h" @@ -80,4 +80,4 @@ private: } // namespace lldb -#endif // LLDB_SBSymbolContext_h_ +#endif // LLDB_API_SBSYMBOLCONTEXT_H diff --git a/lldb/include/lldb/API/SBSymbolContextList.h b/lldb/include/lldb/API/SBSymbolContextList.h index 577993ce96dd..4026afc21357 100644 --- a/lldb/include/lldb/API/SBSymbolContextList.h +++ b/lldb/include/lldb/API/SBSymbolContextList.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef LLDB_SBSymbolContextList_h_ -#define LLDB_SBSymbolContextList_h_ +#ifndef LLDB_API_SBSYMBOLCONTEXTLIST_H +#define LLDB_API_SBSYMBOLCONTEXTLIST_H #include "lldb/API/SBDefines.h" #include "lldb/API/SBSymbolContext.h" @@ -55,4 +55,4 @@ private: } // namespace lldb -#endif // LLDB_SBSymbolContextList_h_ +#endif // LLDB_API_SBSYMBOLCONTEXTLIST_H diff --git a/lldb/include/lldb/API/SBTarget.h b/lldb/include/lldb/API/SBTarget.h index 80a7fa00dbc5..fad842c9cb1c 100644 --- a/lldb/include/lldb/API/SBTarget.h +++ b/lldb/include/lldb/API/SBTarget.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef LLDB_SBTarget_h_ -#define LLDB_SBTarget_h_ +#ifndef LLDB_API_SBTARGET_H +#define LLDB_API_SBTARGET_H #include "lldb/API/SBAddress.h" #include "lldb/API/SBAttachInfo.h" @@ -94,6 +94,15 @@ public: /// A platform object. lldb::SBPlatform GetPlatform(); + /// Return the environment variables that would be used to launch a new + /// process. + /// + /// \return + /// An lldb::SBEnvironment object which is a copy of the target's + /// environment. + + SBEnvironment GetEnvironment(); + /// Install any binaries that need to be installed. /// /// This function does nothing when debugging on the host system. @@ -127,7 +136,9 @@ public: /// The argument array. /// /// \param[in] envp - /// The environment array. + /// The environment array. If this is null, the default + /// environment values (provided through `settings set + /// target.env-vars`) will be used. /// /// \param[in] stdin_path /// The path to use when re-directing the STDIN of the new @@ -175,7 +186,9 @@ public: /// The argument array. /// /// \param[in] envp - /// The environment array. + /// The environment array. If this isn't provided, the default + /// environment values (provided through `settings set + /// target.env-vars`) will be used. /// /// \param[in] working_directory /// The working directory to have the child process run in @@ -829,6 +842,7 @@ protected: friend class SBFunction; friend class SBInstruction; friend class SBModule; + friend class SBPlatform; friend class SBProcess; friend class SBSection; friend class SBSourceManager; @@ -849,4 +863,4 @@ private: } // namespace lldb -#endif // LLDB_SBTarget_h_ +#endif // LLDB_API_SBTARGET_H diff --git a/lldb/include/lldb/API/SBThread.h b/lldb/include/lldb/API/SBThread.h index b5f1794f9fe0..894120c6d986 100644 --- a/lldb/include/lldb/API/SBThread.h +++ b/lldb/include/lldb/API/SBThread.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef LLDB_SBThread_h_ -#define LLDB_SBThread_h_ +#ifndef LLDB_API_SBTHREAD_H +#define LLDB_API_SBTHREAD_H #include "lldb/API/SBDefines.h" @@ -232,4 +232,4 @@ private: } // namespace lldb -#endif // LLDB_SBThread_h_ +#endif // LLDB_API_SBTHREAD_H diff --git a/lldb/include/lldb/API/SBThreadCollection.h b/lldb/include/lldb/API/SBThreadCollection.h index 1c6b4639c6ef..fe57a6b95d90 100644 --- a/lldb/include/lldb/API/SBThreadCollection.h +++ b/lldb/include/lldb/API/SBThreadCollection.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef LLDB_SBThreadCollection_h_ -#define LLDB_SBThreadCollection_h_ +#ifndef LLDB_API_SBTHREADCOLLECTION_H +#define LLDB_API_SBTHREADCOLLECTION_H #include "lldb/API/SBDefines.h" @@ -54,4 +54,4 @@ private: } // namespace lldb -#endif // LLDB_SBThreadCollection_h_ +#endif // LLDB_API_SBTHREADCOLLECTION_H diff --git a/lldb/include/lldb/API/SBThreadPlan.h b/lldb/include/lldb/API/SBThreadPlan.h index dbe417e63749..8f16f4f5c4d2 100644 --- a/lldb/include/lldb/API/SBThreadPlan.h +++ b/lldb/include/lldb/API/SBThreadPlan.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef LLDB_SBThreadPlan_h_ -#define LLDB_SBThreadPlan_h_ +#ifndef LLDB_API_SBTHREADPLAN_H +#define LLDB_API_SBTHREADPLAN_H #include "lldb/API/SBDefines.h" @@ -125,4 +125,4 @@ private: } // namespace lldb -#endif // LLDB_SBThreadPlan_h_ +#endif // LLDB_API_SBTHREADPLAN_H diff --git a/lldb/include/lldb/API/SBTrace.h b/lldb/include/lldb/API/SBTrace.h index 87c67adac75b..053abaeada19 100644 --- a/lldb/include/lldb/API/SBTrace.h +++ b/lldb/include/lldb/API/SBTrace.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef LLDB_SBTrace_h_ -#define LLDB_SBTrace_h_ +#ifndef LLDB_API_SBTRACE_H +#define LLDB_API_SBTRACE_H #include "lldb/API/SBDefines.h" #include "lldb/API/SBError.h" @@ -113,4 +113,4 @@ protected: }; } // namespace lldb -#endif // LLDB_SBTrace_h_ +#endif // LLDB_API_SBTRACE_H diff --git a/lldb/include/lldb/API/SBTraceOptions.h b/lldb/include/lldb/API/SBTraceOptions.h index 4c586bfd55c4..22d71fbd3828 100644 --- a/lldb/include/lldb/API/SBTraceOptions.h +++ b/lldb/include/lldb/API/SBTraceOptions.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef SBTRACEOPTIONS_H_ -#define SBTRACEOPTIONS_H_ +#ifndef LLDB_API_SBTRACEOPTIONS_H +#define LLDB_API_SBTRACEOPTIONS_H #include "lldb/API/SBDefines.h" @@ -56,4 +56,4 @@ protected: }; } -#endif /* SBTRACEOPTIONS_H_ */ +#endif // LLDB_API_SBTRACEOPTIONS_H diff --git a/lldb/include/lldb/API/SBType.h b/lldb/include/lldb/API/SBType.h index b3f92b7bcd04..b0af43351192 100644 --- a/lldb/include/lldb/API/SBType.h +++ b/lldb/include/lldb/API/SBType.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef LLDB_SBType_h_ -#define LLDB_SBType_h_ +#ifndef LLDB_API_SBTYPE_H +#define LLDB_API_SBTYPE_H #include "lldb/API/SBDefines.h" @@ -259,4 +259,4 @@ private: } // namespace lldb -#endif // LLDB_SBType_h_ +#endif // LLDB_API_SBTYPE_H diff --git a/lldb/include/lldb/API/SBTypeCategory.h b/lldb/include/lldb/API/SBTypeCategory.h index c0f4cee1d268..ee1c0f6910ee 100644 --- a/lldb/include/lldb/API/SBTypeCategory.h +++ b/lldb/include/lldb/API/SBTypeCategory.h @@ -7,8 +7,8 @@ // //===----------------------------------------------------------------------===// -#ifndef LLDB_SBTypeCategory_h_ -#define LLDB_SBTypeCategory_h_ +#ifndef LLDB_API_SBTYPECATEGORY_H +#define LLDB_API_SBTYPECATEGORY_H #include "lldb/API/SBDefines.h" @@ -113,4 +113,4 @@ protected: } // namespace lldb -#endif // LLDB_SBTypeCategory_h_ +#endif // LLDB_API_SBTYPECATEGORY_H diff --git a/lldb/include/lldb/API/SBTypeEnumMember.h b/lldb/include/lldb/API/SBTypeEnumMember.h index 2410dbcc2125..45f8cc6638b4 100644 --- a/lldb/include/lldb/API/SBTypeEnumMember.h +++ b/lldb/include/lldb/API/SBTypeEnumMember.h @@ -7,8 +7,8 @@ // //===----------------------------------------------------------------------===// -#ifndef LLDB_SBTypeEnumMember_h_ -#define LLDB_SBTypeEnumMember_h_ +#ifndef LLDB_API_SBTYPEENUMMEMBER_H +#define LLDB_API_SBTYPEENUMMEMBER_H #include "lldb/API/SBDefines.h" @@ -80,4 +80,4 @@ private: } // namespace lldb -#endif // LLDB_SBTypeEnumMember_h_ +#endif // LLDB_API_SBTYPEENUMMEMBER_H diff --git a/lldb/include/lldb/API/SBTypeFilter.h b/lldb/include/lldb/API/SBTypeFilter.h index 4a0de11d19c4..5f02e231d12f 100644 --- a/lldb/include/lldb/API/SBTypeFilter.h +++ b/lldb/include/lldb/API/SBTypeFilter.h @@ -7,8 +7,8 @@ // //===----------------------------------------------------------------------===// -#ifndef LLDB_SBTypeFilter_h_ -#define LLDB_SBTypeFilter_h_ +#ifndef LLDB_API_SBTYPEFILTER_H +#define LLDB_API_SBTYPEFILTER_H #include "lldb/API/SBDefines.h" @@ -71,4 +71,4 @@ protected: } // namespace lldb -#endif // LLDB_SBTypeFilter_h_ +#endif // LLDB_API_SBTYPEFILTER_H diff --git a/lldb/include/lldb/API/SBTypeFormat.h b/lldb/include/lldb/API/SBTypeFormat.h index 8a0ac77a1e9d..b34045927032 100644 --- a/lldb/include/lldb/API/SBTypeFormat.h +++ b/lldb/include/lldb/API/SBTypeFormat.h @@ -7,8 +7,8 @@ // //===----------------------------------------------------------------------===// -#ifndef LLDB_SBTypeFormat_h_ -#define LLDB_SBTypeFormat_h_ +#ifndef LLDB_API_SBTYPEFORMAT_H +#define LLDB_API_SBTYPEFORMAT_H #include "lldb/API/SBDefines.h" @@ -75,4 +75,4 @@ protected: } // namespace lldb -#endif // LLDB_SBTypeFormat_h_ +#endif // LLDB_API_SBTYPEFORMAT_H diff --git a/lldb/include/lldb/API/SBTypeNameSpecifier.h b/lldb/include/lldb/API/SBTypeNameSpecifier.h index 9fe449d029c6..eee424c1710a 100644 --- a/lldb/include/lldb/API/SBTypeNameSpecifier.h +++ b/lldb/include/lldb/API/SBTypeNameSpecifier.h @@ -7,8 +7,8 @@ // //===----------------------------------------------------------------------===// -#ifndef LLDB_SBTypeNameSpecifier_h_ -#define LLDB_SBTypeNameSpecifier_h_ +#ifndef LLDB_API_SBTYPENAMESPECIFIER_H +#define LLDB_API_SBTYPENAMESPECIFIER_H #include "lldb/API/SBDefines.h" @@ -62,4 +62,4 @@ protected: } // namespace lldb -#endif // LLDB_SBTypeNameSpecifier_h_ +#endif // LLDB_API_SBTYPENAMESPECIFIER_H diff --git a/lldb/include/lldb/API/SBTypeSummary.h b/lldb/include/lldb/API/SBTypeSummary.h index bb7121f8ae40..929bfb6124b2 100644 --- a/lldb/include/lldb/API/SBTypeSummary.h +++ b/lldb/include/lldb/API/SBTypeSummary.h @@ -7,8 +7,8 @@ // //===----------------------------------------------------------------------===// -#ifndef LLDB_SBTypeSummary_h_ -#define LLDB_SBTypeSummary_h_ +#ifndef LLDB_API_SBTYPESUMMARY_H +#define LLDB_API_SBTYPESUMMARY_H #include "lldb/API/SBDefines.h" @@ -136,4 +136,4 @@ protected: } // namespace lldb -#endif // LLDB_SBTypeSummary_h_ +#endif // LLDB_API_SBTYPESUMMARY_H diff --git a/lldb/include/lldb/API/SBTypeSynthetic.h b/lldb/include/lldb/API/SBTypeSynthetic.h index c190643c1ebb..9dab9d851f08 100644 --- a/lldb/include/lldb/API/SBTypeSynthetic.h +++ b/lldb/include/lldb/API/SBTypeSynthetic.h @@ -7,8 +7,8 @@ // //===----------------------------------------------------------------------===// -#ifndef LLDB_SBTypeSynthetic_h_ -#define LLDB_SBTypeSynthetic_h_ +#ifndef LLDB_API_SBTYPESYNTHETIC_H +#define LLDB_API_SBTYPESYNTHETIC_H #include "lldb/API/SBDefines.h" @@ -77,4 +77,4 @@ protected: } // namespace lldb -#endif // LLDB_SBTypeSynthetic_h_ +#endif // LLDB_API_SBTYPESYNTHETIC_H diff --git a/lldb/include/lldb/API/SBUnixSignals.h b/lldb/include/lldb/API/SBUnixSignals.h index c7e99d1f63d1..9757eac7ee30 100644 --- a/lldb/include/lldb/API/SBUnixSignals.h +++ b/lldb/include/lldb/API/SBUnixSignals.h @@ -7,8 +7,8 @@ // //===----------------------------------------------------------------------===// -#ifndef LLDB_SBUnixSignals_h_ -#define LLDB_SBUnixSignals_h_ +#ifndef LLDB_API_SBUNIXSIGNALS_H +#define LLDB_API_SBUNIXSIGNALS_H #include "lldb/API/SBDefines.h" @@ -68,4 +68,4 @@ private: } // namespace lldb -#endif // LLDB_SBUnixSignals_h_ +#endif // LLDB_API_SBUNIXSIGNALS_H diff --git a/lldb/include/lldb/API/SBValue.h b/lldb/include/lldb/API/SBValue.h index 5f8d17f8642f..69be02545b35 100644 --- a/lldb/include/lldb/API/SBValue.h +++ b/lldb/include/lldb/API/SBValue.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef LLDB_SBValue_h_ -#define LLDB_SBValue_h_ +#ifndef LLDB_API_SBVALUE_H +#define LLDB_API_SBVALUE_H #include "lldb/API/SBData.h" #include "lldb/API/SBDefines.h" @@ -430,4 +430,4 @@ private: } // namespace lldb -#endif // LLDB_SBValue_h_ +#endif // LLDB_API_SBVALUE_H diff --git a/lldb/include/lldb/API/SBValueList.h b/lldb/include/lldb/API/SBValueList.h index d305b3564c2b..dc8389b75293 100644 --- a/lldb/include/lldb/API/SBValueList.h +++ b/lldb/include/lldb/API/SBValueList.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef LLDB_SBValueList_h_ -#define LLDB_SBValueList_h_ +#ifndef LLDB_API_SBVALUELIST_H +#define LLDB_API_SBVALUELIST_H #include "lldb/API/SBDefines.h" @@ -72,4 +72,4 @@ private: } // namespace lldb -#endif // LLDB_SBValueList_h_ +#endif // LLDB_API_SBVALUELIST_H diff --git a/lldb/include/lldb/API/SBVariablesOptions.h b/lldb/include/lldb/API/SBVariablesOptions.h index e226ce4ae13b..53ab4b7e14f2 100644 --- a/lldb/include/lldb/API/SBVariablesOptions.h +++ b/lldb/include/lldb/API/SBVariablesOptions.h @@ -7,8 +7,8 @@ // //===----------------------------------------------------------------------===// -#ifndef LLDB_SBVariablesOptions_h_ -#define LLDB_SBVariablesOptions_h_ +#ifndef LLDB_API_SBVARIABLESOPTIONS_H +#define LLDB_API_SBVARIABLESOPTIONS_H #include "lldb/API/SBDefines.h" @@ -79,4 +79,4 @@ private: } // namespace lldb -#endif // LLDB_SBValue_h_ +#endif // LLDB_API_SBVARIABLESOPTIONS_H diff --git a/lldb/include/lldb/API/SBWatchpoint.h b/lldb/include/lldb/API/SBWatchpoint.h index 05ff0ca7e443..08c5faa3a928 100644 --- a/lldb/include/lldb/API/SBWatchpoint.h +++ b/lldb/include/lldb/API/SBWatchpoint.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef LLDB_SBWatchpoint_h_ -#define LLDB_SBWatchpoint_h_ +#ifndef LLDB_API_SBWATCHPOINT_H +#define LLDB_API_SBWATCHPOINT_H #include "lldb/API/SBDefines.h" @@ -82,4 +82,4 @@ private: } // namespace lldb -#endif // LLDB_SBWatchpoint_h_ +#endif // LLDB_API_SBWATCHPOINT_H diff --git a/lldb/include/lldb/Breakpoint/Breakpoint.h b/lldb/include/lldb/Breakpoint/Breakpoint.h index 94411bd57a67..d29d21070fd7 100644 --- a/lldb/include/lldb/Breakpoint/Breakpoint.h +++ b/lldb/include/lldb/Breakpoint/Breakpoint.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef liblldb_Breakpoint_h_ -#define liblldb_Breakpoint_h_ +#ifndef LLDB_BREAKPOINT_BREAKPOINT_H +#define LLDB_BREAKPOINT_BREAKPOINT_H #include <memory> #include <string> @@ -137,12 +137,14 @@ public: lldb::BreakpointSP m_new_breakpoint_sp; BreakpointLocationCollection m_locations; - DISALLOW_COPY_AND_ASSIGN(BreakpointEventData); + BreakpointEventData(const BreakpointEventData &) = delete; + const BreakpointEventData &operator=(const BreakpointEventData &) = delete; }; // Saving & restoring breakpoints: static lldb::BreakpointSP CreateFromStructuredData( - Target &target, StructuredData::ObjectSP &data_object_sp, Status &error); + lldb::TargetSP target_sp, StructuredData::ObjectSP &data_object_sp, + Status &error); static bool SerializedBreakpointMatchesNames(StructuredData::ObjectSP &bkpt_object_sp, @@ -568,6 +570,11 @@ public: return GetPermissions().GetAllowDelete(); } + // This one should only be used by Target to copy breakpoints from target to + // target - primarily from the dummy target to prime new targets. + static lldb::BreakpointSP CopyFromBreakpoint(lldb::TargetSP new_target, + const Breakpoint &bp_to_copy_from); + protected: friend class Target; // Protected Methods @@ -625,9 +632,8 @@ protected: } private: - // This one should only be used by Target to copy breakpoints from target to - // target - primarily from the dummy target to prime new targets. - Breakpoint(Target &new_target, Breakpoint &bp_to_copy_from); + // To call from CopyFromBreakpoint. + Breakpoint(Target &new_target, const Breakpoint &bp_to_copy_from); // For Breakpoint only bool m_being_created; @@ -664,9 +670,10 @@ private: void SendBreakpointChangedEvent(BreakpointEventData *data); - DISALLOW_COPY_AND_ASSIGN(Breakpoint); + Breakpoint(const Breakpoint &) = delete; + const Breakpoint &operator=(const Breakpoint &) = delete; }; } // namespace lldb_private -#endif // liblldb_Breakpoint_h_ +#endif // LLDB_BREAKPOINT_BREAKPOINT_H diff --git a/lldb/include/lldb/Breakpoint/BreakpointID.h b/lldb/include/lldb/Breakpoint/BreakpointID.h index 9daa5b6c5e8d..64432f2d3cd5 100644 --- a/lldb/include/lldb/Breakpoint/BreakpointID.h +++ b/lldb/include/lldb/Breakpoint/BreakpointID.h @@ -6,9 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef liblldb_BreakpointID_h_ -#define liblldb_BreakpointID_h_ - +#ifndef LLDB_BREAKPOINT_BREAKPOINTID_H +#define LLDB_BREAKPOINT_BREAKPOINTID_H #include "lldb/lldb-private.h" @@ -95,4 +94,4 @@ protected: } // namespace lldb_private -#endif // liblldb_BreakpointID_h_ +#endif // LLDB_BREAKPOINT_BREAKPOINTID_H diff --git a/lldb/include/lldb/Breakpoint/BreakpointIDList.h b/lldb/include/lldb/Breakpoint/BreakpointIDList.h index c6429220c7ff..924cb1f26b8b 100644 --- a/lldb/include/lldb/Breakpoint/BreakpointIDList.h +++ b/lldb/include/lldb/Breakpoint/BreakpointIDList.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef liblldb_BreakpointIDList_h_ -#define liblldb_BreakpointIDList_h_ +#ifndef LLDB_BREAKPOINT_BREAKPOINTIDLIST_H +#define LLDB_BREAKPOINT_BREAKPOINTIDLIST_H #include <utility> #include <vector> @@ -68,9 +68,10 @@ private: BreakpointIDArray m_breakpoint_ids; BreakpointID m_invalid_id; - DISALLOW_COPY_AND_ASSIGN(BreakpointIDList); + BreakpointIDList(const BreakpointIDList &) = delete; + const BreakpointIDList &operator=(const BreakpointIDList &) = delete; }; } // namespace lldb_private -#endif // liblldb_BreakpointIDList_h_ +#endif // LLDB_BREAKPOINT_BREAKPOINTIDLIST_H diff --git a/lldb/include/lldb/Breakpoint/BreakpointList.h b/lldb/include/lldb/Breakpoint/BreakpointList.h index ad68151fefc7..346972ec3a1f 100644 --- a/lldb/include/lldb/Breakpoint/BreakpointList.h +++ b/lldb/include/lldb/Breakpoint/BreakpointList.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef liblldb_BreakpointList_h_ -#define liblldb_BreakpointList_h_ +#ifndef LLDB_BREAKPOINT_BREAKPOINTLIST_H +#define LLDB_BREAKPOINT_BREAKPOINTLIST_H #include <list> #include <mutex> @@ -168,9 +168,10 @@ public: } private: - DISALLOW_COPY_AND_ASSIGN(BreakpointList); + BreakpointList(const BreakpointList &) = delete; + const BreakpointList &operator=(const BreakpointList &) = delete; }; } // namespace lldb_private -#endif // liblldb_BreakpointList_h_ +#endif // LLDB_BREAKPOINT_BREAKPOINTLIST_H diff --git a/lldb/include/lldb/Breakpoint/BreakpointLocation.h b/lldb/include/lldb/Breakpoint/BreakpointLocation.h index 86bb164162c1..3fc571eaa292 100644 --- a/lldb/include/lldb/Breakpoint/BreakpointLocation.h +++ b/lldb/include/lldb/Breakpoint/BreakpointLocation.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef liblldb_BreakpointLocation_h_ -#define liblldb_BreakpointLocation_h_ +#ifndef LLDB_BREAKPOINT_BREAKPOINTLOCATION_H +#define LLDB_BREAKPOINT_BREAKPOINTLOCATION_H #include <memory> #include <mutex> @@ -345,9 +345,10 @@ private: void SendBreakpointLocationChangedEvent(lldb::BreakpointEventType eventKind); - DISALLOW_COPY_AND_ASSIGN(BreakpointLocation); + BreakpointLocation(const BreakpointLocation &) = delete; + const BreakpointLocation &operator=(const BreakpointLocation &) = delete; }; } // namespace lldb_private -#endif // liblldb_BreakpointLocation_h_ +#endif // LLDB_BREAKPOINT_BREAKPOINTLOCATION_H diff --git a/lldb/include/lldb/Breakpoint/BreakpointLocationCollection.h b/lldb/include/lldb/Breakpoint/BreakpointLocationCollection.h index be400636877e..ffdb81e363e0 100644 --- a/lldb/include/lldb/Breakpoint/BreakpointLocationCollection.h +++ b/lldb/include/lldb/Breakpoint/BreakpointLocationCollection.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef liblldb_BreakpointLocationCollection_h_ -#define liblldb_BreakpointLocationCollection_h_ +#ifndef LLDB_BREAKPOINT_BREAKPOINTLOCATIONCOLLECTION_H +#define LLDB_BREAKPOINT_BREAKPOINTLOCATIONCOLLECTION_H #include <mutex> #include <vector> @@ -175,4 +175,4 @@ public: } // namespace lldb_private -#endif // liblldb_BreakpointLocationCollection_h_ +#endif // LLDB_BREAKPOINT_BREAKPOINTLOCATIONCOLLECTION_H diff --git a/lldb/include/lldb/Breakpoint/BreakpointLocationList.h b/lldb/include/lldb/Breakpoint/BreakpointLocationList.h index 89ad2f54c923..4b36c919ee3c 100644 --- a/lldb/include/lldb/Breakpoint/BreakpointLocationList.h +++ b/lldb/include/lldb/Breakpoint/BreakpointLocationList.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef liblldb_BreakpointLocationList_h_ -#define liblldb_BreakpointLocationList_h_ +#ifndef LLDB_BREAKPOINT_BREAKPOINTLOCATIONLIST_H +#define LLDB_BREAKPOINT_BREAKPOINTLOCATIONLIST_H #include <map> #include <mutex> @@ -212,4 +212,4 @@ public: } // namespace lldb_private -#endif // liblldb_BreakpointLocationList_h_ +#endif // LLDB_BREAKPOINT_BREAKPOINTLOCATIONLIST_H diff --git a/lldb/include/lldb/Breakpoint/BreakpointName.h b/lldb/include/lldb/Breakpoint/BreakpointName.h index 61020a628070..8786dbc9a163 100644 --- a/lldb/include/lldb/Breakpoint/BreakpointName.h +++ b/lldb/include/lldb/Breakpoint/BreakpointName.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef liblldb_Breakpoint_Name_h_ -#define liblldb_Breakpoint_Name_h_ +#ifndef LLDB_BREAKPOINT_BREAKPOINTNAME_H +#define LLDB_BREAKPOINT_BREAKPOINTNAME_H #include <memory> #include <string> @@ -205,4 +205,4 @@ private: } // namespace lldb_private -#endif // liblldb_Breakpoint_Name_h_ +#endif // LLDB_BREAKPOINT_BREAKPOINTNAME_H diff --git a/lldb/include/lldb/Breakpoint/BreakpointOptions.h b/lldb/include/lldb/Breakpoint/BreakpointOptions.h index 2c52170eb9f6..615b4eb77be4 100644 --- a/lldb/include/lldb/Breakpoint/BreakpointOptions.h +++ b/lldb/include/lldb/Breakpoint/BreakpointOptions.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef liblldb_BreakpointOptions_h_ -#define liblldb_BreakpointOptions_h_ +#ifndef LLDB_BREAKPOINT_BREAKPOINTOPTIONS_H +#define LLDB_BREAKPOINT_BREAKPOINTOPTIONS_H #include <memory> #include <string> @@ -406,4 +406,4 @@ private: } // namespace lldb_private -#endif // liblldb_BreakpointOptions_h_ +#endif // LLDB_BREAKPOINT_BREAKPOINTOPTIONS_H diff --git a/lldb/include/lldb/Breakpoint/BreakpointPrecondition.h b/lldb/include/lldb/Breakpoint/BreakpointPrecondition.h index 2a9461b52fab..5f0c11b595bb 100644 --- a/lldb/include/lldb/Breakpoint/BreakpointPrecondition.h +++ b/lldb/include/lldb/Breakpoint/BreakpointPrecondition.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef liblldb_BreakpointPrecondition_h_ -#define liblldb_BreakpointPrecondition_h_ +#ifndef LLDB_BREAKPOINT_BREAKPOINTPRECONDITION_H +#define LLDB_BREAKPOINT_BREAKPOINTPRECONDITION_H #include "lldb/lldb-enumerations.h" diff --git a/lldb/include/lldb/Breakpoint/BreakpointResolver.h b/lldb/include/lldb/Breakpoint/BreakpointResolver.h index c1dbf9ac0aee..d067b1eea6ff 100644 --- a/lldb/include/lldb/Breakpoint/BreakpointResolver.h +++ b/lldb/include/lldb/Breakpoint/BreakpointResolver.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef liblldb_BreakpointResolver_h_ -#define liblldb_BreakpointResolver_h_ +#ifndef LLDB_BREAKPOINT_BREAKPOINTRESOLVER_H +#define LLDB_BREAKPOINT_BREAKPOINTRESOLVER_H #include "lldb/Breakpoint/Breakpoint.h" #include "lldb/Core/Address.h" @@ -44,7 +44,8 @@ public: /// The breakpoint that owns this resolver. /// \param[in] resolverType /// The concrete breakpoint resolver type for this breakpoint. - BreakpointResolver(Breakpoint *bkpt, unsigned char resolverType, + BreakpointResolver(const lldb::BreakpointSP &bkpt, + unsigned char resolverType, lldb::addr_t offset = 0); /// The Destructor is virtual, all significant breakpoint resolvers derive @@ -55,7 +56,15 @@ public: /// /// \param[in] bkpt /// The breakpoint that owns this resolver. - void SetBreakpoint(Breakpoint *bkpt); + void SetBreakpoint(const lldb::BreakpointSP &bkpt); + + /// This gets the breakpoint for this resolver. + lldb::BreakpointSP GetBreakpoint() const { + auto breakpoint_sp = m_breakpoint.expired() ? lldb::BreakpointSP() : + m_breakpoint.lock(); + assert(breakpoint_sp); + return breakpoint_sp; + } /// This updates the offset for this breakpoint. All the locations /// currently set for this breakpoint will have their offset adjusted when @@ -65,12 +74,6 @@ public: /// 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 - /// 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 @@ -155,7 +158,7 @@ public: static ResolverTy NameToResolverTy(llvm::StringRef name); virtual lldb::BreakpointResolverSP - CopyForBreakpoint(Breakpoint &breakpoint) = 0; + CopyForBreakpoint(lldb::BreakpointSP &breakpoint) = 0; protected: // Used for serializing resolver options: @@ -208,20 +211,21 @@ protected: lldb::BreakpointLocationSP AddLocation(Address loc_addr, 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 - // breakpoints we set. - private: /// Helper for \p SetSCMatchesByLine. void AddLocation(SearchFilter &filter, const SymbolContext &sc, bool skip_prologue, llvm::StringRef log_ident); + lldb::BreakpointWP 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 + // breakpoints we set. + // Subclass identifier (for llvm isa/dyn_cast) const unsigned char SubclassID; - DISALLOW_COPY_AND_ASSIGN(BreakpointResolver); + BreakpointResolver(const BreakpointResolver &) = delete; + const BreakpointResolver &operator=(const BreakpointResolver &) = delete; }; } // namespace lldb_private -#endif // liblldb_BreakpointResolver_h_ +#endif // LLDB_BREAKPOINT_BREAKPOINTRESOLVER_H diff --git a/lldb/include/lldb/Breakpoint/BreakpointResolverAddress.h b/lldb/include/lldb/Breakpoint/BreakpointResolverAddress.h index 3df89641c711..5454487e51a2 100644 --- a/lldb/include/lldb/Breakpoint/BreakpointResolverAddress.h +++ b/lldb/include/lldb/Breakpoint/BreakpointResolverAddress.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef liblldb_BreakpointResolverAddress_h_ -#define liblldb_BreakpointResolverAddress_h_ +#ifndef LLDB_BREAKPOINT_BREAKPOINTRESOLVERADDRESS_H +#define LLDB_BREAKPOINT_BREAKPOINTRESOLVERADDRESS_H #include "lldb/Breakpoint/BreakpointResolver.h" #include "lldb/Core/ModuleSpec.h" @@ -21,15 +21,17 @@ namespace lldb_private { class BreakpointResolverAddress : public BreakpointResolver { public: - BreakpointResolverAddress(Breakpoint *bkpt, const Address &addr); + BreakpointResolverAddress(const lldb::BreakpointSP &bkpt, + const Address &addr); - BreakpointResolverAddress(Breakpoint *bkpt, const Address &addr, + BreakpointResolverAddress(const lldb::BreakpointSP &bkpt, + const Address &addr, const FileSpec &module_spec); - ~BreakpointResolverAddress() override; + ~BreakpointResolverAddress() override = default; static BreakpointResolver * - CreateFromStructuredData(Breakpoint *bkpt, + CreateFromStructuredData(const lldb::BreakpointSP &bkpt, const StructuredData::Dictionary &options_dict, Status &error); @@ -56,11 +58,12 @@ public: return V->getResolverID() == BreakpointResolver::AddressResolver; } - lldb::BreakpointResolverSP CopyForBreakpoint(Breakpoint &breakpoint) override; + lldb::BreakpointResolverSP + CopyForBreakpoint(lldb::BreakpointSP &breakpoint) override; protected: - Address - m_addr; // The address - may be Section Offset or may be just an offset + Address m_addr; // The address - may be Section Offset or + // may be just an offset lldb::addr_t m_resolved_addr; // The current value of the resolved load // address for this breakpoint, FileSpec m_module_filespec; // If this filespec is Valid, and m_addr is an @@ -68,9 +71,11 @@ protected: // to a Section+Offset address in this module, whenever that module gets // around to being loaded. private: - DISALLOW_COPY_AND_ASSIGN(BreakpointResolverAddress); + BreakpointResolverAddress(const BreakpointResolverAddress &) = delete; + const BreakpointResolverAddress & + operator=(const BreakpointResolverAddress &) = delete; }; } // namespace lldb_private -#endif // liblldb_BreakpointResolverAddress_h_ +#endif // LLDB_BREAKPOINT_BREAKPOINTRESOLVERADDRESS_H diff --git a/lldb/include/lldb/Breakpoint/BreakpointResolverFileLine.h b/lldb/include/lldb/Breakpoint/BreakpointResolverFileLine.h index 9ca48ecf0dc0..222fc6fcd45d 100644 --- a/lldb/include/lldb/Breakpoint/BreakpointResolverFileLine.h +++ b/lldb/include/lldb/Breakpoint/BreakpointResolverFileLine.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef liblldb_BreakpointResolverFileLine_h_ -#define liblldb_BreakpointResolverFileLine_h_ +#ifndef LLDB_BREAKPOINT_BREAKPOINTRESOLVERFILELINE_H +#define LLDB_BREAKPOINT_BREAKPOINTRESOLVERFILELINE_H #include "lldb/Breakpoint/BreakpointResolver.h" @@ -20,19 +20,20 @@ namespace lldb_private { class BreakpointResolverFileLine : public BreakpointResolver { public: - BreakpointResolverFileLine(Breakpoint *bkpt, const FileSpec &resolver, + BreakpointResolverFileLine(const lldb::BreakpointSP &bkpt, + const FileSpec &resolver, uint32_t line_no, uint32_t column, lldb::addr_t m_offset, bool check_inlines, bool skip_prologue, bool exact_match); static BreakpointResolver * - CreateFromStructuredData(Breakpoint *bkpt, + CreateFromStructuredData(const lldb::BreakpointSP &bkpt, const StructuredData::Dictionary &data_dict, Status &error); StructuredData::ObjectSP SerializeToStructuredData() override; - ~BreakpointResolverFileLine() override; + ~BreakpointResolverFileLine() override = default; Searcher::CallbackReturn SearchCallback(SearchFilter &filter, SymbolContext &context, @@ -52,7 +53,8 @@ public: return V->getResolverID() == BreakpointResolver::FileLineResolver; } - lldb::BreakpointResolverSP CopyForBreakpoint(Breakpoint &breakpoint) override; + lldb::BreakpointResolverSP + CopyForBreakpoint(lldb::BreakpointSP &breakpoint) override; protected: void FilterContexts(SymbolContextList &sc_list, bool is_relative); @@ -67,9 +69,11 @@ protected: bool m_exact_match; private: - DISALLOW_COPY_AND_ASSIGN(BreakpointResolverFileLine); + BreakpointResolverFileLine(const BreakpointResolverFileLine &) = delete; + const BreakpointResolverFileLine & + operator=(const BreakpointResolverFileLine &) = delete; }; } // namespace lldb_private -#endif // liblldb_BreakpointResolverFileLine_h_ +#endif // LLDB_BREAKPOINT_BREAKPOINTRESOLVERFILELINE_H diff --git a/lldb/include/lldb/Breakpoint/BreakpointResolverFileRegex.h b/lldb/include/lldb/Breakpoint/BreakpointResolverFileRegex.h index df4c13ed59e2..138d555e2230 100644 --- a/lldb/include/lldb/Breakpoint/BreakpointResolverFileRegex.h +++ b/lldb/include/lldb/Breakpoint/BreakpointResolverFileRegex.h @@ -7,8 +7,8 @@ // //===----------------------------------------------------------------------===// -#ifndef liblldb_BreakpointResolverFileRegex_h_ -#define liblldb_BreakpointResolverFileRegex_h_ +#ifndef LLDB_BREAKPOINT_BREAKPOINTRESOLVERFILEREGEX_H +#define LLDB_BREAKPOINT_BREAKPOINTRESOLVERFILEREGEX_H #include <set> #include "lldb/Breakpoint/BreakpointResolver.h" @@ -24,17 +24,17 @@ namespace lldb_private { class BreakpointResolverFileRegex : public BreakpointResolver { public: BreakpointResolverFileRegex( - Breakpoint *bkpt, RegularExpression regex, + const lldb::BreakpointSP &bkpt, RegularExpression regex, const std::unordered_set<std::string> &func_name_set, bool exact_match); static BreakpointResolver * - CreateFromStructuredData(Breakpoint *bkpt, + CreateFromStructuredData(const lldb::BreakpointSP &bkpt, const StructuredData::Dictionary &options_dict, Status &error); StructuredData::ObjectSP SerializeToStructuredData() override; - ~BreakpointResolverFileRegex() override; + ~BreakpointResolverFileRegex() override = default; Searcher::CallbackReturn SearchCallback(SearchFilter &filter, SymbolContext &context, @@ -56,7 +56,8 @@ public: return V->getResolverID() == BreakpointResolver::FileRegexResolver; } - lldb::BreakpointResolverSP CopyForBreakpoint(Breakpoint &breakpoint) override; + lldb::BreakpointResolverSP + CopyForBreakpoint(lldb::BreakpointSP &breakpoint) override; protected: friend class Breakpoint; @@ -69,9 +70,11 @@ protected: // comp_unit passed in. private: - DISALLOW_COPY_AND_ASSIGN(BreakpointResolverFileRegex); + BreakpointResolverFileRegex(const BreakpointResolverFileRegex &) = delete; + const BreakpointResolverFileRegex & + operator=(const BreakpointResolverFileRegex &) = delete; }; } // namespace lldb_private -#endif // liblldb_BreakpointResolverFileRegex_h_ +#endif // LLDB_BREAKPOINT_BREAKPOINTRESOLVERFILEREGEX_H diff --git a/lldb/include/lldb/Breakpoint/BreakpointResolverName.h b/lldb/include/lldb/Breakpoint/BreakpointResolverName.h index 196d88db848c..7a9fc4660767 100644 --- a/lldb/include/lldb/Breakpoint/BreakpointResolverName.h +++ b/lldb/include/lldb/Breakpoint/BreakpointResolverName.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef liblldb_BreakpointResolverName_h_ -#define liblldb_BreakpointResolverName_h_ +#ifndef LLDB_BREAKPOINT_BREAKPOINTRESOLVERNAME_H +#define LLDB_BREAKPOINT_BREAKPOINTRESOLVERNAME_H #include <string> #include <vector> @@ -23,39 +23,41 @@ namespace lldb_private { class BreakpointResolverName : public BreakpointResolver { public: - BreakpointResolverName(Breakpoint *bkpt, const char *name, + BreakpointResolverName(const lldb::BreakpointSP &bkpt, const char *name, lldb::FunctionNameType name_type_mask, lldb::LanguageType language, Breakpoint::MatchType type, lldb::addr_t offset, bool skip_prologue); // This one takes an array of names. It is always MatchType = Exact. - BreakpointResolverName(Breakpoint *bkpt, const char *names[], + BreakpointResolverName(const lldb::BreakpointSP &bkpt, const char *names[], size_t num_names, lldb::FunctionNameType name_type_mask, lldb::LanguageType language, lldb::addr_t offset, bool skip_prologue); // This one takes a C++ array of names. It is always MatchType = Exact. - BreakpointResolverName(Breakpoint *bkpt, std::vector<std::string> names, + BreakpointResolverName(const lldb::BreakpointSP &bkpt, + std::vector<std::string> names, lldb::FunctionNameType name_type_mask, lldb::LanguageType language, lldb::addr_t offset, bool skip_prologue); // Creates a function breakpoint by regular expression. Takes over control // of the lifespan of func_regex. - BreakpointResolverName(Breakpoint *bkpt, RegularExpression func_regex, + BreakpointResolverName(const lldb::BreakpointSP &bkpt, + RegularExpression func_regex, lldb::LanguageType language, lldb::addr_t offset, bool skip_prologue); static BreakpointResolver * - CreateFromStructuredData(Breakpoint *bkpt, + CreateFromStructuredData(const lldb::BreakpointSP &bkpt, const StructuredData::Dictionary &data_dict, Status &error); StructuredData::ObjectSP SerializeToStructuredData() override; - ~BreakpointResolverName() override; + ~BreakpointResolverName() override = default; Searcher::CallbackReturn SearchCallback(SearchFilter &filter, SymbolContext &context, @@ -73,7 +75,8 @@ public: return V->getResolverID() == BreakpointResolver::NameResolver; } - lldb::BreakpointResolverSP CopyForBreakpoint(Breakpoint &breakpoint) override; + lldb::BreakpointResolverSP + CopyForBreakpoint(lldb::BreakpointSP &breakpoint) override; protected: BreakpointResolverName(const BreakpointResolverName &rhs); @@ -91,4 +94,4 @@ protected: } // namespace lldb_private -#endif // liblldb_BreakpointResolverName_h_ +#endif // LLDB_BREAKPOINT_BREAKPOINTRESOLVERNAME_H diff --git a/lldb/include/lldb/Breakpoint/BreakpointResolverScripted.h b/lldb/include/lldb/Breakpoint/BreakpointResolverScripted.h index 89a7d03ce93f..26fd6f2f04d7 100644 --- a/lldb/include/lldb/Breakpoint/BreakpointResolverScripted.h +++ b/lldb/include/lldb/Breakpoint/BreakpointResolverScripted.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef liblldb_BreakpointResolverScripted_h_ -#define liblldb_BreakpointResolverScripted_h_ +#ifndef LLDB_BREAKPOINT_BREAKPOINTRESOLVERSCRIPTED_H +#define LLDB_BREAKPOINT_BREAKPOINTRESOLVERSCRIPTED_H #include "lldb/lldb-forward.h" #include "lldb/Breakpoint/BreakpointResolver.h" @@ -23,15 +23,15 @@ namespace lldb_private { class BreakpointResolverScripted : public BreakpointResolver { public: - BreakpointResolverScripted(Breakpoint *bkpt, + BreakpointResolverScripted(const lldb::BreakpointSP &bkpt, const llvm::StringRef class_name, lldb::SearchDepth depth, StructuredDataImpl *args_data); - ~BreakpointResolverScripted() override; + ~BreakpointResolverScripted() override = default; static BreakpointResolver * - CreateFromStructuredData(Breakpoint *bkpt, + CreateFromStructuredData(const lldb::BreakpointSP &bkpt, const StructuredData::Dictionary &options_dict, Status &error); @@ -53,12 +53,13 @@ public: return V->getResolverID() == BreakpointResolver::PythonResolver; } - lldb::BreakpointResolverSP CopyForBreakpoint(Breakpoint &breakpoint) override; + lldb::BreakpointResolverSP + CopyForBreakpoint(lldb::BreakpointSP &breakpoint) override; protected: void NotifyBreakpointSet() override; private: - void CreateImplementationIfNeeded(); + void CreateImplementationIfNeeded(lldb::BreakpointSP bkpt); ScriptInterpreter *GetScriptInterpreter(); std::string m_class_name; @@ -69,9 +70,11 @@ private: // SBStructuredData). StructuredData::GenericSP m_implementation_sp; - DISALLOW_COPY_AND_ASSIGN(BreakpointResolverScripted); + BreakpointResolverScripted(const BreakpointResolverScripted &) = delete; + const BreakpointResolverScripted & + operator=(const BreakpointResolverScripted &) = delete; }; } // namespace lldb_private -#endif // liblldb_BreakpointResolverScripted_h_ +#endif // LLDB_BREAKPOINT_BREAKPOINTRESOLVERSCRIPTED_H diff --git a/lldb/include/lldb/Breakpoint/BreakpointSite.h b/lldb/include/lldb/Breakpoint/BreakpointSite.h index 5c9f79a9ab1c..5ce17f511db4 100644 --- a/lldb/include/lldb/Breakpoint/BreakpointSite.h +++ b/lldb/include/lldb/Breakpoint/BreakpointSite.h @@ -6,9 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef liblldb_BreakpointSite_h_ -#define liblldb_BreakpointSite_h_ - +#ifndef LLDB_BREAKPOINT_BREAKPOINTSITE_H +#define LLDB_BREAKPOINT_BREAKPOINTSITE_H #include <list> #include <mutex> @@ -61,6 +60,8 @@ public: /// Sets the trap opcode bool SetTrapOpcode(const uint8_t *trap_opcode, uint32_t trap_opcode_size); + void SetHardwareIndex(uint32_t index) override; + /// Gets the original instruction bytes that were overwritten by the trap uint8_t *GetSavedOpcodeBytes(); @@ -224,9 +225,10 @@ private: const lldb::BreakpointLocationSP &owner, lldb::addr_t m_addr, bool use_hardware); - DISALLOW_COPY_AND_ASSIGN(BreakpointSite); + BreakpointSite(const BreakpointSite &) = delete; + const BreakpointSite &operator=(const BreakpointSite &) = delete; }; } // namespace lldb_private -#endif // liblldb_BreakpointSite_h_ +#endif // LLDB_BREAKPOINT_BREAKPOINTSITE_H diff --git a/lldb/include/lldb/Breakpoint/BreakpointSiteList.h b/lldb/include/lldb/Breakpoint/BreakpointSiteList.h index b10d119fcce6..98091bbaeb05 100644 --- a/lldb/include/lldb/Breakpoint/BreakpointSiteList.h +++ b/lldb/include/lldb/Breakpoint/BreakpointSiteList.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef liblldb_BreakpointSiteList_h_ -#define liblldb_BreakpointSiteList_h_ +#ifndef LLDB_BREAKPOINT_BREAKPOINTSITELIST_H +#define LLDB_BREAKPOINT_BREAKPOINTSITELIST_H #include <functional> #include <map> @@ -170,4 +170,4 @@ protected: } // namespace lldb_private -#endif // liblldb_BreakpointSiteList_h_ +#endif // LLDB_BREAKPOINT_BREAKPOINTSITELIST_H diff --git a/lldb/include/lldb/Breakpoint/Stoppoint.h b/lldb/include/lldb/Breakpoint/Stoppoint.h index f20b10074051..36df77c4e91a 100644 --- a/lldb/include/lldb/Breakpoint/Stoppoint.h +++ b/lldb/include/lldb/Breakpoint/Stoppoint.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef liblldb_Stoppoint_h_ -#define liblldb_Stoppoint_h_ +#ifndef LLDB_BREAKPOINT_STOPPOINT_H +#define LLDB_BREAKPOINT_STOPPOINT_H #include "lldb/Utility/UserID.h" #include "lldb/lldb-private.h" @@ -37,9 +37,10 @@ protected: private: // For Stoppoint only - DISALLOW_COPY_AND_ASSIGN(Stoppoint); + Stoppoint(const Stoppoint &) = delete; + const Stoppoint &operator=(const Stoppoint &) = delete; }; } // namespace lldb_private -#endif // liblldb_Stoppoint_h_ +#endif // LLDB_BREAKPOINT_STOPPOINT_H diff --git a/lldb/include/lldb/Breakpoint/StoppointCallbackContext.h b/lldb/include/lldb/Breakpoint/StoppointCallbackContext.h index c1724a6b276f..db02ddd494fb 100644 --- a/lldb/include/lldb/Breakpoint/StoppointCallbackContext.h +++ b/lldb/include/lldb/Breakpoint/StoppointCallbackContext.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef liblldb_StoppointCallbackContext_h_ -#define liblldb_StoppointCallbackContext_h_ +#ifndef LLDB_BREAKPOINT_STOPPOINTCALLBACKCONTEXT_H +#define LLDB_BREAKPOINT_STOPPOINTCALLBACKCONTEXT_H #include "lldb/Target/ExecutionContext.h" #include "lldb/lldb-private.h" @@ -48,4 +48,4 @@ public: } // namespace lldb_private -#endif // liblldb_StoppointCallbackContext_h_ +#endif // LLDB_BREAKPOINT_STOPPOINTCALLBACKCONTEXT_H diff --git a/lldb/include/lldb/Breakpoint/StoppointLocation.h b/lldb/include/lldb/Breakpoint/StoppointLocation.h index 3926f452e564..4d6ca044ccc4 100644 --- a/lldb/include/lldb/Breakpoint/StoppointLocation.h +++ b/lldb/include/lldb/Breakpoint/StoppointLocation.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef liblldb_StoppointLocation_h_ -#define liblldb_StoppointLocation_h_ +#ifndef LLDB_BREAKPOINT_STOPPOINTLOCATION_H +#define LLDB_BREAKPOINT_STOPPOINTLOCATION_H #include "lldb/Utility/UserID.h" #include "lldb/lldb-private.h" @@ -48,7 +48,7 @@ public: virtual void Dump(Stream *stream) const {} - void SetHardwareIndex(uint32_t index) { m_hardware_index = index; } + virtual void SetHardwareIndex(uint32_t index) { m_hardware_index = index; } lldb::break_id_t GetID() const { return m_loc_id; } @@ -77,10 +77,11 @@ protected: private: // For StoppointLocation only - DISALLOW_COPY_AND_ASSIGN(StoppointLocation); + StoppointLocation(const StoppointLocation &) = delete; + const StoppointLocation &operator=(const StoppointLocation &) = delete; StoppointLocation() = delete; }; } // namespace lldb_private -#endif // liblldb_StoppointLocation_h_ +#endif // LLDB_BREAKPOINT_STOPPOINTLOCATION_H diff --git a/lldb/include/lldb/Breakpoint/Watchpoint.h b/lldb/include/lldb/Breakpoint/Watchpoint.h index 2cc74bb4c632..bce15f0a85dd 100644 --- a/lldb/include/lldb/Breakpoint/Watchpoint.h +++ b/lldb/include/lldb/Breakpoint/Watchpoint.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef liblldb_Watchpoint_h_ -#define liblldb_Watchpoint_h_ +#ifndef LLDB_BREAKPOINT_WATCHPOINT_H +#define LLDB_BREAKPOINT_WATCHPOINT_H #include <memory> #include <string> @@ -54,7 +54,8 @@ public: lldb::WatchpointEventType m_watchpoint_event; lldb::WatchpointSP m_new_watchpoint_sp; - DISALLOW_COPY_AND_ASSIGN(WatchpointEventData); + WatchpointEventData(const WatchpointEventData &) = delete; + const WatchpointEventData &operator=(const WatchpointEventData &) = delete; }; Watchpoint(Target &target, lldb::addr_t addr, uint32_t size, @@ -160,8 +161,8 @@ private: void ResetHitCount() { m_hit_count = 0; } void ResetHistoricValues() { - m_old_value_sp.reset(nullptr); - m_new_value_sp.reset(nullptr); + m_old_value_sp.reset(); + m_new_value_sp.reset(); } Target &m_target; @@ -204,9 +205,10 @@ private: void SendWatchpointChangedEvent(WatchpointEventData *data); - DISALLOW_COPY_AND_ASSIGN(Watchpoint); + Watchpoint(const Watchpoint &) = delete; + const Watchpoint &operator=(const Watchpoint &) = delete; }; } // namespace lldb_private -#endif // liblldb_Watchpoint_h_ +#endif // LLDB_BREAKPOINT_WATCHPOINT_H diff --git a/lldb/include/lldb/Breakpoint/WatchpointList.h b/lldb/include/lldb/Breakpoint/WatchpointList.h index bb73d4ab75da..283f991b178a 100644 --- a/lldb/include/lldb/Breakpoint/WatchpointList.h +++ b/lldb/include/lldb/Breakpoint/WatchpointList.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef liblldb_WatchpointList_h_ -#define liblldb_WatchpointList_h_ +#ifndef LLDB_BREAKPOINT_WATCHPOINTLIST_H +#define LLDB_BREAKPOINT_WATCHPOINTLIST_H #include <list> #include <mutex> @@ -203,4 +203,4 @@ protected: } // namespace lldb_private -#endif // liblldb_WatchpointList_h_ +#endif // LLDB_BREAKPOINT_WATCHPOINTLIST_H diff --git a/lldb/include/lldb/Breakpoint/WatchpointOptions.h b/lldb/include/lldb/Breakpoint/WatchpointOptions.h index 0dc34d4ebef7..0a18c52d36d0 100644 --- a/lldb/include/lldb/Breakpoint/WatchpointOptions.h +++ b/lldb/include/lldb/Breakpoint/WatchpointOptions.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef liblldb_WatchpointOptions_h_ -#define liblldb_WatchpointOptions_h_ +#ifndef LLDB_BREAKPOINT_WATCHPOINTOPTIONS_H +#define LLDB_BREAKPOINT_WATCHPOINTOPTIONS_H #include <memory> #include <string> @@ -198,4 +198,4 @@ private: } // namespace lldb_private -#endif // liblldb_WatchpointOptions_h_ +#endif // LLDB_BREAKPOINT_WATCHPOINTOPTIONS_H diff --git a/lldb/include/lldb/Core/Address.h b/lldb/include/lldb/Core/Address.h index 70a7f790e40d..71e50b91d68e 100644 --- a/lldb/include/lldb/Core/Address.h +++ b/lldb/include/lldb/Core/Address.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef liblldb_Address_h_ -#define liblldb_Address_h_ +#ifndef LLDB_CORE_ADDRESS_H +#define LLDB_CORE_ADDRESS_H #include "lldb/lldb-defines.h" #include "lldb/lldb-forward.h" @@ -515,4 +515,4 @@ bool operator!=(const Address &lhs, const Address &rhs); } // namespace lldb_private -#endif // liblldb_Address_h_ +#endif // LLDB_CORE_ADDRESS_H diff --git a/lldb/include/lldb/Core/AddressRange.h b/lldb/include/lldb/Core/AddressRange.h index ac748713a182..8ccf96a436a1 100644 --- a/lldb/include/lldb/Core/AddressRange.h +++ b/lldb/include/lldb/Core/AddressRange.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef liblldb_AddressRange_h_ -#define liblldb_AddressRange_h_ +#ifndef LLDB_CORE_ADDRESSRANGE_H +#define LLDB_CORE_ADDRESSRANGE_H #include "lldb/Core/Address.h" #include "lldb/lldb-forward.h" @@ -247,4 +247,4 @@ protected: } // namespace lldb_private -#endif // liblldb_AddressRange_h_ +#endif // LLDB_CORE_ADDRESSRANGE_H diff --git a/lldb/include/lldb/Core/AddressResolver.h b/lldb/include/lldb/Core/AddressResolver.h index cd95c7c31cd6..9ac058a97cd9 100644 --- a/lldb/include/lldb/Core/AddressResolver.h +++ b/lldb/include/lldb/Core/AddressResolver.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef liblldb_AddressResolver_h_ -#define liblldb_AddressResolver_h_ +#ifndef LLDB_CORE_ADDRESSRESOLVER_H +#define LLDB_CORE_ADDRESSRESOLVER_H #include "lldb/Core/AddressRange.h" #include "lldb/Core/SearchFilter.h" @@ -55,9 +55,10 @@ protected: std::vector<AddressRange> m_address_ranges; private: - DISALLOW_COPY_AND_ASSIGN(AddressResolver); + AddressResolver(const AddressResolver &) = delete; + const AddressResolver &operator=(const AddressResolver &) = delete; }; } // namespace lldb_private -#endif // liblldb_AddressResolver_h_ +#endif // LLDB_CORE_ADDRESSRESOLVER_H diff --git a/lldb/include/lldb/Core/AddressResolverFileLine.h b/lldb/include/lldb/Core/AddressResolverFileLine.h index efbe3de1f294..46bf4155e865 100644 --- a/lldb/include/lldb/Core/AddressResolverFileLine.h +++ b/lldb/include/lldb/Core/AddressResolverFileLine.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef liblldb_AddressResolverFileLine_h_ -#define liblldb_AddressResolverFileLine_h_ +#ifndef LLDB_CORE_ADDRESSRESOLVERFILELINE_H +#define LLDB_CORE_ADDRESSRESOLVERFILELINE_H #include "lldb/Core/AddressResolver.h" #include "lldb/Core/SearchFilter.h" @@ -48,9 +48,11 @@ protected: // functions or not. private: - DISALLOW_COPY_AND_ASSIGN(AddressResolverFileLine); + AddressResolverFileLine(const AddressResolverFileLine &) = delete; + const AddressResolverFileLine & + operator=(const AddressResolverFileLine &) = delete; }; } // namespace lldb_private -#endif // liblldb_AddressResolverFileLine_h_ +#endif // LLDB_CORE_ADDRESSRESOLVERFILELINE_H diff --git a/lldb/include/lldb/Core/AddressResolverName.h b/lldb/include/lldb/Core/AddressResolverName.h index 8a039f9e1d92..0ec1ef05b0ec 100644 --- a/lldb/include/lldb/Core/AddressResolverName.h +++ b/lldb/include/lldb/Core/AddressResolverName.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef liblldb_AddressResolverName_h_ -#define liblldb_AddressResolverName_h_ +#ifndef LLDB_CORE_ADDRESSRESOLVERNAME_H +#define LLDB_CORE_ADDRESSRESOLVERNAME_H #include "lldb/Core/AddressResolver.h" #include "lldb/Core/SearchFilter.h" @@ -54,9 +54,10 @@ protected: AddressResolver::MatchType m_match_type; private: - DISALLOW_COPY_AND_ASSIGN(AddressResolverName); + AddressResolverName(const AddressResolverName &) = delete; + const AddressResolverName &operator=(const AddressResolverName &) = delete; }; } // namespace lldb_private -#endif // liblldb_AddressResolverName_h_ +#endif // LLDB_CORE_ADDRESSRESOLVERNAME_H diff --git a/lldb/include/lldb/Core/ClangForward.h b/lldb/include/lldb/Core/ClangForward.h deleted file mode 100644 index 0bc331438e5c..000000000000 --- a/lldb/include/lldb/Core/ClangForward.h +++ /dev/null @@ -1,133 +0,0 @@ -//===-- ClangForward.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_ClangForward_h_ -#define liblldb_ClangForward_h_ - - -#if defined(__cplusplus) - -namespace clang { -namespace Builtin { -class Context; -} - -class ASTConsumer; -class ASTContext; -class ASTRecordLayout; -class AddrLabelExpr; -class AnalyzerOptions; -class BinaryOperator; -class ClassTemplateDecl; -class ClassTemplateSpecializationDecl; -class CodeGenOptions; -class CodeGenerator; -class CompilerInstance; -class CompoundStmt; -class CXXBaseSpecifier; -class CXXBoolLiteralExpr; -class CXXFunctionalCastExpr; -class CXXMethodDecl; -class CXXNamedCastExpr; -class CXXRecordDecl; -class CXXThisExpr; -class CharacterLiteral; -class CompoundAssignOperator; -class Decl; -class DeclarationName; -class DeclaratorDecl; -class DeclContext; -class DeclRefExpr; -class DeclStmt; -class DependencyOutputOptions; -class Diagnostic; -class DiagnosticConsumer; -class DiagnosticsEngine; -class DiagnosticOptions; -class EnumDecl; -class EnumConstantDecl; -class Expr; -class ExternalASTSource; -class ExtVectorElementExpr; -class FieldDecl; -class FileManager; -class FileSystemOptions; -class FloatingLiteral; -class FrontendOptions; -class FunctionDecl; -class FunctionTemplateDecl; -class FunctionTemplateSpecializationInfo; -class GotoStmt; -class HeaderSearchOptions; -class IdentifierInfo; -class IdentifierTable; -class IntegerLiteral; -class LabelStmt; -class LangOptions; -class MacroDirective; -class MemberExpr; -class Module; -class NamedDecl; -class NamespaceDecl; -class NonTypeTemplateParmDecl; -class ObjCEncodeExpr; -class ObjCImplicitSetterGetterRefExpr; -class ObjCInterfaceDecl; -class ObjCIvarDecl; -class ObjCIvarRefExpr; -class ObjCMessageExpr; -class ObjCMethodDecl; -class ObjCPropertyRefExpr; -class ObjCProtocolDecl; -class ObjCProtocolExpr; -class ObjCSelectorExpr; -class ObjCSuperExpr; -class ParenExpr; -class ParmVarDecl; -class PredefinedExpr; -class PreprocessorOptions; -class PreprocessorOutputOptions; -class QualType; -class QualifiedNameType; -class RecordDecl; -class SelectorTable; -class SizeOfAlignOfExpr; -class SourceLocation; -class SourceManager; -class Stmt; -class StmtIteratorBase; -class StringLiteral; -class TagDecl; -class TargetInfo; -class TargetOptions; -class TemplateArgument; -class TemplateDecl; -class TemplateParameterList; -class TemplateTemplateParmDecl; -class TemplateTypeParmDecl; -class TextDiagnosticBuffer; -class TranslationUnitDecl; -class Type; -class TypeDecl; -class TypedefDecl; -class TypesCompatibleExpr; -class UnaryOperator; -class ValueDecl; -class VarDecl; -struct PrintingPolicy; -} - -namespace llvm { -class APInt; -class APSInt; -class LLVMContext; -class ExecutionEngine; -} - -#endif // #if defined(__cplusplus) -#endif // liblldb_ClangForward_h_ diff --git a/lldb/include/lldb/Core/Communication.h b/lldb/include/lldb/Core/Communication.h index 901b8fdb8c8b..6b65974f9522 100644 --- a/lldb/include/lldb/Core/Communication.h +++ b/lldb/include/lldb/Core/Communication.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef liblldb_Communication_h_ -#define liblldb_Communication_h_ +#ifndef LLDB_CORE_COMMUNICATION_H +#define LLDB_CORE_COMMUNICATION_H #include "lldb/Host/HostThread.h" #include "lldb/Utility/Broadcaster.h" @@ -221,7 +221,7 @@ public: /// /// \see /// class Connection - void SetConnection(Connection *connection); + void SetConnection(std::unique_ptr<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: @@ -359,9 +359,10 @@ protected: size_t GetCachedBytes(void *dst, size_t dst_len); private: - DISALLOW_COPY_AND_ASSIGN(Communication); + Communication(const Communication &) = delete; + const Communication &operator=(const Communication &) = delete; }; } // namespace lldb_private -#endif // liblldb_Communication_h_ +#endif // LLDB_CORE_COMMUNICATION_H diff --git a/lldb/include/lldb/Core/Debugger.h b/lldb/include/lldb/Core/Debugger.h index a8048427c8f1..7bea0dbae082 100644 --- a/lldb/include/lldb/Core/Debugger.h +++ b/lldb/include/lldb/Core/Debugger.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef liblldb_Debugger_h_ -#define liblldb_Debugger_h_ +#ifndef LLDB_CORE_DEBUGGER_H +#define LLDB_CORE_DEBUGGER_H #include <stdint.h> @@ -190,13 +190,15 @@ public: lldb::StreamFileSP &out, lldb::StreamFileSP &err); - void PushIOHandler(const lldb::IOHandlerSP &reader_sp, - bool cancel_top_handler = true); + /// Run the given IO handler and return immediately. + void RunIOHandlerAsync(const lldb::IOHandlerSP &reader_sp, + bool cancel_top_handler = true); - bool PopIOHandler(const lldb::IOHandlerSP &reader_sp); + /// Run the given IO handler and block until it's complete. + void RunIOHandlerSync(const lldb::IOHandlerSP &reader_sp); - // Synchronously run an input reader until it is done - void RunIOHandler(const lldb::IOHandlerSP &reader_sp); + /// Remove the given IO handler if it's currently active. + bool RemoveIOHandler(const lldb::IOHandlerSP &reader_sp); bool IsTopIOHandler(const lldb::IOHandlerSP &reader_sp); @@ -271,6 +273,10 @@ public: bool SetUseColor(bool use_color); + bool GetUseSourceCache() const; + + bool SetUseSourceCache(bool use_source_cache); + bool GetHighlightSource() const; lldb::StopShowColumn GetStopShowColumn() const; @@ -285,6 +291,10 @@ public: uint32_t GetDisassemblyLineCount() const; + llvm::StringRef GetStopShowLineMarkerAnsiPrefix() const; + + llvm::StringRef GetStopShowLineMarkerAnsiSuffix() const; + bool GetAutoOneLineSummaries() const; bool GetAutoIndent() const; @@ -307,7 +317,7 @@ public: bool LoadPlugin(const FileSpec &spec, Status &error); - void ExecuteIOHandlers(); + void RunIOHandlers(); bool IsForwardingEvents(); @@ -339,6 +349,11 @@ protected: static lldb::thread_result_t EventHandlerThread(lldb::thread_arg_t arg); + void PushIOHandler(const lldb::IOHandlerSP &reader_sp, + bool cancel_top_handler = true); + + bool PopIOHandler(const lldb::IOHandlerSP &reader_sp); + bool HasIOHandlerThread(); bool StartIOHandlerThread(); @@ -402,7 +417,9 @@ protected: std::array<lldb::ScriptInterpreterSP, lldb::eScriptLanguageUnknown> m_script_interpreters; - IOHandlerStack m_input_reader_stack; + IOHandlerStack m_io_handler_stack; + std::recursive_mutex m_io_handler_synchronous_mutex; + llvm::StringMap<std::weak_ptr<llvm::raw_ostream>> m_log_streams; std::shared_ptr<llvm::raw_ostream> m_log_callback_stream_sp; ConstString m_instance_name; @@ -426,9 +443,10 @@ private: // object Debugger(lldb::LogOutputCallback m_log_callback, void *baton); - DISALLOW_COPY_AND_ASSIGN(Debugger); + Debugger(const Debugger &) = delete; + const Debugger &operator=(const Debugger &) = delete; }; } // namespace lldb_private -#endif // liblldb_Debugger_h_ +#endif // LLDB_CORE_DEBUGGER_H diff --git a/lldb/include/lldb/Core/Disassembler.h b/lldb/include/lldb/Core/Disassembler.h index 7ece0eeb708c..926a74b933ef 100644 --- a/lldb/include/lldb/Core/Disassembler.h +++ b/lldb/include/lldb/Core/Disassembler.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef liblldb_Disassembler_h_ -#define liblldb_Disassembler_h_ +#ifndef LLDB_CORE_DISASSEMBLER_H +#define LLDB_CORE_DISASSEMBLER_H #include "lldb/Core/Address.h" #include "lldb/Core/EmulateInstruction.h" @@ -349,7 +349,8 @@ public: protected: std::string m_description; - DISALLOW_COPY_AND_ASSIGN(PseudoInstruction); + PseudoInstruction(const PseudoInstruction &) = delete; + const PseudoInstruction &operator=(const PseudoInstruction &) = delete; }; class Disassembler : public std::enable_shared_from_this<Disassembler>, @@ -379,13 +380,19 @@ public: FindPlugin(const ArchSpec &arch, const char *flavor, const char *plugin_name); // This version will use the value in the Target settings if flavor is NULL; - static lldb::DisassemblerSP - FindPluginForTarget(const lldb::TargetSP target_sp, const ArchSpec &arch, - const char *flavor, const char *plugin_name); + static lldb::DisassemblerSP FindPluginForTarget(const Target &target, + const ArchSpec &arch, + const char *flavor, + const char *plugin_name); + + struct Limit { + enum { Bytes, Instructions } kind; + lldb::addr_t value; + }; static lldb::DisassemblerSP DisassembleRange(const ArchSpec &arch, const char *plugin_name, - const char *flavor, const ExecutionContext &exe_ctx, + const char *flavor, Target &target, const AddressRange &disasm_range, bool prefer_file_cache); static lldb::DisassemblerSP @@ -396,34 +403,11 @@ public: static bool Disassemble(Debugger &debugger, const ArchSpec &arch, const char *plugin_name, const char *flavor, - const ExecutionContext &exe_ctx, - const AddressRange &range, uint32_t num_instructions, - bool mixed_source_and_assembly, - uint32_t num_mixed_context_lines, uint32_t options, - Stream &strm); - - static bool Disassemble(Debugger &debugger, const ArchSpec &arch, - const char *plugin_name, const char *flavor, const ExecutionContext &exe_ctx, const Address &start, - uint32_t num_instructions, - bool mixed_source_and_assembly, + Limit limit, bool mixed_source_and_assembly, uint32_t num_mixed_context_lines, uint32_t options, Stream &strm); - static size_t - Disassemble(Debugger &debugger, const ArchSpec &arch, const char *plugin_name, - const char *flavor, const ExecutionContext &exe_ctx, - SymbolContextList &sc_list, uint32_t num_instructions, - bool mixed_source_and_assembly, uint32_t num_mixed_context_lines, - uint32_t options, Stream &strm); - - static bool - Disassemble(Debugger &debugger, const ArchSpec &arch, const char *plugin_name, - const char *flavor, const ExecutionContext &exe_ctx, - ConstString name, Module *module, - uint32_t num_instructions, bool mixed_source_and_assembly, - uint32_t num_mixed_context_lines, uint32_t options, Stream &strm); - static bool Disassemble(Debugger &debugger, const ArchSpec &arch, const char *plugin_name, const char *flavor, const ExecutionContext &exe_ctx, @@ -434,25 +418,14 @@ public: Disassembler(const ArchSpec &arch, const char *flavor); ~Disassembler() override; - typedef const char *(*SummaryCallback)(const Instruction &inst, - ExecutionContext *exe_context, - void *user_data); - - static bool PrintInstructions(Disassembler *disasm_ptr, Debugger &debugger, - const ArchSpec &arch, - const ExecutionContext &exe_ctx, - uint32_t num_instructions, - bool mixed_source_and_assembly, - uint32_t num_mixed_context_lines, - uint32_t options, Stream &strm); - - size_t ParseInstructions(const ExecutionContext *exe_ctx, - const AddressRange &range, Stream *error_strm_ptr, - bool prefer_file_cache); + void PrintInstructions(Debugger &debugger, const ArchSpec &arch, + const ExecutionContext &exe_ctx, + bool mixed_source_and_assembly, + uint32_t num_mixed_context_lines, uint32_t options, + Stream &strm); - size_t ParseInstructions(const ExecutionContext *exe_ctx, - const Address &range, uint32_t num_instructions, - bool prefer_file_cache); + size_t ParseInstructions(Target &target, Address address, Limit limit, + Stream *error_strm_ptr, bool prefer_file_cache); virtual size_t DecodeInstructions(const Address &base_addr, const DataExtractor &data, @@ -548,9 +521,10 @@ protected: private: // For Disassembler only - DISALLOW_COPY_AND_ASSIGN(Disassembler); + Disassembler(const Disassembler &) = delete; + const Disassembler &operator=(const Disassembler &) = delete; }; } // namespace lldb_private -#endif // liblldb_Disassembler_h_ +#endif // LLDB_CORE_DISASSEMBLER_H diff --git a/lldb/include/lldb/Core/EmulateInstruction.h b/lldb/include/lldb/Core/EmulateInstruction.h index 6b19c17e5491..a575488ba966 100644 --- a/lldb/include/lldb/Core/EmulateInstruction.h +++ b/lldb/include/lldb/Core/EmulateInstruction.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef lldb_EmulateInstruction_h_ -#define lldb_EmulateInstruction_h_ +#ifndef LLDB_CORE_EMULATEINSTRUCTION_H +#define LLDB_CORE_EMULATEINSTRUCTION_H #include <string> @@ -499,9 +499,10 @@ protected: private: // For EmulateInstruction only - DISALLOW_COPY_AND_ASSIGN(EmulateInstruction); + EmulateInstruction(const EmulateInstruction &) = delete; + const EmulateInstruction &operator=(const EmulateInstruction &) = delete; }; } // namespace lldb_private -#endif // lldb_EmulateInstruction_h_ +#endif // LLDB_CORE_EMULATEINSTRUCTION_H diff --git a/lldb/include/lldb/Core/FileLineResolver.h b/lldb/include/lldb/Core/FileLineResolver.h index d6525b71bfdf..68e252e93bc9 100644 --- a/lldb/include/lldb/Core/FileLineResolver.h +++ b/lldb/include/lldb/Core/FileLineResolver.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef liblldb_FileLineResolver_h_ -#define liblldb_FileLineResolver_h_ +#ifndef LLDB_CORE_FILELINERESOLVER_H +#define LLDB_CORE_FILELINERESOLVER_H #include "lldb/Core/SearchFilter.h" #include "lldb/Symbol/SymbolContext.h" @@ -58,9 +58,10 @@ protected: // functions or not. private: - DISALLOW_COPY_AND_ASSIGN(FileLineResolver); + FileLineResolver(const FileLineResolver &) = delete; + const FileLineResolver &operator=(const FileLineResolver &) = delete; }; } // namespace lldb_private -#endif // liblldb_FileLineResolver_h_ +#endif // LLDB_CORE_FILELINERESOLVER_H diff --git a/lldb/include/lldb/Core/FileSpecList.h b/lldb/include/lldb/Core/FileSpecList.h index 8edc3280b01b..3e412a7e1a32 100644 --- a/lldb/include/lldb/Core/FileSpecList.h +++ b/lldb/include/lldb/Core/FileSpecList.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef liblldb_FileSpecList_h_ -#define liblldb_FileSpecList_h_ +#ifndef LLDB_CORE_FILESPECLIST_H +#define LLDB_CORE_FILESPECLIST_H #if defined(__cplusplus) #include "lldb/Utility/FileSpec.h" @@ -204,4 +204,4 @@ protected: } // namespace lldb_private #endif // #if defined(__cplusplus) -#endif // liblldb_FileSpecList_h_ +#endif // LLDB_CORE_FILESPECLIST_H diff --git a/lldb/include/lldb/Core/FormatEntity.h b/lldb/include/lldb/Core/FormatEntity.h index 8ee320b0ebb1..91999f64ab5f 100644 --- a/lldb/include/lldb/Core/FormatEntity.h +++ b/lldb/include/lldb/Core/FormatEntity.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef liblldb_FormatEntity_h_ -#define liblldb_FormatEntity_h_ +#ifndef LLDB_CORE_FORMATENTITY_H +#define LLDB_CORE_FORMATENTITY_H #include "lldb/Utility/CompletionRequest.h" #include "lldb/Utility/FileSpec.h" @@ -61,6 +61,7 @@ public: ThreadName, ThreadQueue, ThreadStopReason, + ThreadStopReasonRaw, ThreadReturnValue, ThreadCompletedExpression, ScriptThread, @@ -218,4 +219,4 @@ protected: }; } // namespace lldb_private -#endif // liblldb_FormatEntity_h_ +#endif // LLDB_CORE_FORMATENTITY_H diff --git a/lldb/include/lldb/Core/Highlighter.h b/lldb/include/lldb/Core/Highlighter.h index 8a268ec1d6b1..b138e57af419 100644 --- a/lldb/include/lldb/Core/Highlighter.h +++ b/lldb/include/lldb/Core/Highlighter.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef liblldb_Highlighter_h_ -#define liblldb_Highlighter_h_ +#ifndef LLDB_CORE_HIGHLIGHTER_H +#define LLDB_CORE_HIGHLIGHTER_H #include <utility> #include <vector> @@ -91,7 +91,8 @@ class Highlighter { public: Highlighter() = default; virtual ~Highlighter() = default; - DISALLOW_COPY_AND_ASSIGN(Highlighter); + Highlighter(const Highlighter &) = delete; + const Highlighter &operator=(const Highlighter &) = delete; /// Returns a human readable name for the selected highlighter. virtual llvm::StringRef GetName() const = 0; @@ -152,4 +153,4 @@ public: } // namespace lldb_private -#endif // liblldb_Highlighter_h_ +#endif // LLDB_CORE_HIGHLIGHTER_H diff --git a/lldb/include/lldb/Core/IOHandler.h b/lldb/include/lldb/Core/IOHandler.h index 9ab5eaaecb66..51592afbbabe 100644 --- a/lldb/include/lldb/Core/IOHandler.h +++ b/lldb/include/lldb/Core/IOHandler.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef liblldb_IOHandler_h_ -#define liblldb_IOHandler_h_ +#ifndef LLDB_CORE_IOHANDLER_H +#define LLDB_CORE_IOHANDLER_H #include "lldb/Core/ValueObjectList.h" #include "lldb/Host/Config.h" @@ -95,6 +95,8 @@ public: virtual void Deactivate() { m_active = false; } + virtual void TerminalSizeChanged() {} + virtual const char *GetPrompt() { // Prompt support isn't mandatory return nullptr; @@ -178,7 +180,8 @@ protected: bool m_active; private: - DISALLOW_COPY_AND_ASSIGN(IOHandler); + IOHandler(const IOHandler &) = delete; + const IOHandler &operator=(const IOHandler &) = delete; }; /// A delegate class for use with IOHandler subclasses. @@ -369,6 +372,8 @@ public: void Deactivate() override; + void TerminalSizeChanged() override; + ConstString GetControlSequence(char ch) override { return m_delegate.IOHandlerGetControlSequence(ch); } @@ -540,9 +545,10 @@ protected: IOHandler *m_top = nullptr; private: - DISALLOW_COPY_AND_ASSIGN(IOHandlerStack); + IOHandlerStack(const IOHandlerStack &) = delete; + const IOHandlerStack &operator=(const IOHandlerStack &) = delete; }; } // namespace lldb_private -#endif // liblldb_IOHandler_h_ +#endif // LLDB_CORE_IOHANDLER_H diff --git a/lldb/include/lldb/Core/IOHandlerCursesGUI.h b/lldb/include/lldb/Core/IOHandlerCursesGUI.h index afa435269725..fe62eaea643e 100644 --- a/lldb/include/lldb/Core/IOHandlerCursesGUI.h +++ b/lldb/include/lldb/Core/IOHandlerCursesGUI.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef liblldb_IOHandlerCursesGUI_h_ -#define liblldb_IOHandlerCursesGUI_h_ +#ifndef LLDB_CORE_IOHANDLERCURSESGUI_H +#define LLDB_CORE_IOHANDLERCURSESGUI_H #include "lldb/Core/IOHandler.h" @@ -37,4 +37,4 @@ protected: } // namespace lldb_private -#endif // liblldb_IOHandlerCursesGUI_h_ +#endif // LLDB_CORE_IOHANDLERCURSESGUI_H diff --git a/lldb/include/lldb/Core/LoadedModuleInfoList.h b/lldb/include/lldb/Core/LoadedModuleInfoList.h index 04e58fcdf313..49400f7f4908 100644 --- a/lldb/include/lldb/Core/LoadedModuleInfoList.h +++ b/lldb/include/lldb/Core/LoadedModuleInfoList.h @@ -6,9 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef liblldb_LoadedModuleInfoList_h_ -#define liblldb_LoadedModuleInfoList_h_ - +#ifndef LLDB_CORE_LOADEDMODULEINFOLIST_H +#define LLDB_CORE_LOADEDMODULEINFOLIST_H #include <cassert> #include <string> @@ -113,4 +112,4 @@ public: }; } // namespace lldb_private -#endif // liblldb_LoadedModuleInfoList_h_ +#endif // LLDB_CORE_LOADEDMODULEINFOLIST_H diff --git a/lldb/include/lldb/Core/Mangled.h b/lldb/include/lldb/Core/Mangled.h index 6af68c3f5857..c03fc1eb7599 100644 --- a/lldb/include/lldb/Core/Mangled.h +++ b/lldb/include/lldb/Core/Mangled.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef liblldb_Mangled_h_ -#define liblldb_Mangled_h_ +#ifndef LLDB_CORE_MANGLED_H +#define LLDB_CORE_MANGLED_H #if defined(__cplusplus) #include "lldb/lldb-enumerations.h" @@ -132,13 +132,13 @@ public: /// /// \return /// A const reference to the demangled name string object. - ConstString GetDemangledName(lldb::LanguageType language) const; + ConstString GetDemangledName() const; /// Display demangled name get accessor. /// /// \return /// A const reference to the display demangled name string object. - ConstString GetDisplayDemangledName(lldb::LanguageType language) const; + ConstString GetDisplayDemangledName() const; void SetDemangledName(ConstString name) { m_demangled = name; } @@ -165,8 +165,7 @@ public: /// 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; + ConstString GetName(NamePreference preference = ePreferDemangled) const; /// Check if "name" matches either the mangled or demangled name. /// @@ -175,13 +174,12 @@ public: /// /// \return /// \b True if \a name matches either name, \b false otherwise. - bool NameMatches(ConstString name, lldb::LanguageType language) const { + bool NameMatches(ConstString name) const { if (m_mangled == name) return true; - return GetDemangledName(language) == name; + return GetDemangledName() == name; } - bool NameMatches(const RegularExpression ®ex, - lldb::LanguageType language) const; + bool NameMatches(const RegularExpression ®ex) const; /// Get the memory cost of this object. /// @@ -282,4 +280,4 @@ Stream &operator<<(Stream &s, const Mangled &obj); } // namespace lldb_private #endif // #if defined(__cplusplus) -#endif // liblldb_Mangled_h_ +#endif // LLDB_CORE_MANGLED_H diff --git a/lldb/include/lldb/Core/MappedHash.h b/lldb/include/lldb/Core/MappedHash.h index 7dc9b5be3465..a27ec82b9b86 100644 --- a/lldb/include/lldb/Core/MappedHash.h +++ b/lldb/include/lldb/Core/MappedHash.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef liblldb_MappedHash_h_ -#define liblldb_MappedHash_h_ +#ifndef LLDB_CORE_MAPPEDHASH_H +#define LLDB_CORE_MAPPEDHASH_H #include <assert.h> #include <stdint.h> @@ -307,4 +307,4 @@ public: }; }; -#endif // liblldb_MappedHash_h_ +#endif // LLDB_CORE_MAPPEDHASH_H diff --git a/lldb/include/lldb/Core/Module.h b/lldb/include/lldb/Core/Module.h index 2af18c83f23a..8bd70ab16b5a 100644 --- a/lldb/include/lldb/Core/Module.h +++ b/lldb/include/lldb/Core/Module.h @@ -6,10 +6,11 @@ // //===----------------------------------------------------------------------===// -#ifndef liblldb_Module_h_ -#define liblldb_Module_h_ +#ifndef LLDB_CORE_MODULE_H +#define LLDB_CORE_MODULE_H #include "lldb/Core/Address.h" +#include "lldb/Core/ModuleList.h" #include "lldb/Core/ModuleSpec.h" #include "lldb/Symbol/ObjectFile.h" #include "lldb/Symbol/SymbolContextScope.h" @@ -19,6 +20,7 @@ #include "lldb/Utility/ConstString.h" #include "lldb/Utility/FileSpec.h" #include "lldb/Utility/Status.h" +#include "lldb/Utility/XcodeSDK.h" #include "lldb/Utility/UUID.h" #include "lldb/lldb-defines.h" #include "lldb/lldb-enumerations.h" @@ -301,7 +303,7 @@ public: /// A symbol context list that gets filled in with all of the /// matches. void FindFunctions(ConstString name, - const CompilerDeclContext *parent_decl_ctx, + const CompilerDeclContext &parent_decl_ctx, lldb::FunctionNameType name_type_mask, bool symbols_ok, bool inlines_ok, SymbolContextList &sc_list); @@ -364,7 +366,7 @@ public: /// A list of variables that gets the matches appended to. /// void FindGlobalVariables(ConstString name, - const CompilerDeclContext *parent_decl_ctx, + const CompilerDeclContext &parent_decl_ctx, size_t max_matches, VariableList &variable_list); /// Find global and static variables by regular expression. @@ -443,7 +445,7 @@ public: /// \param[out] type_list /// A type list gets populated with any matches. void FindTypesInNamespace(ConstString type_name, - const CompilerDeclContext *parent_decl_ctx, + const CompilerDeclContext &parent_decl_ctx, size_t max_matches, TypeList &type_list); /// Get const accessor for the module architecture. @@ -508,6 +510,11 @@ public: m_mod_time = mod_time; } + /// This callback will be called by SymbolFile implementations when + /// parsing a compile unit that contains SDK information. + /// \param sysroot will be added to the path remapping dictionary. + void RegisterXcodeSDK(llvm::StringRef sdk, llvm::StringRef sysroot); + /// Tells whether this module is capable of being the main executable for a /// process. /// @@ -951,6 +958,12 @@ protected: ///by \a m_file. uint64_t m_object_offset; llvm::sys::TimePoint<> m_object_mod_time; + + /// DataBuffer containing the module image, if it was provided at + /// construction time. Otherwise the data will be retrieved by mapping + /// one of the FileSpec members above. + lldb::DataBufferSP m_data_sp; + 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 @@ -966,10 +979,11 @@ protected: ///references to them TypeSystemMap m_type_system_map; ///< A map of any type systems associated ///with this module - PathMappingList m_source_mappings; ///< Module specific source remappings for - ///when you have debug info for a module - ///that doesn't match where the sources - ///currently are + /// Module specific source remappings for when you have debug info for a + /// module that doesn't match where the sources currently are. + PathMappingList m_source_mappings = + ModuleList::GetGlobalModuleListProperties().GetSymlinkMappings(); + lldb::SectionListUP m_sections_up; ///< Unified section list for module that /// is used by the ObjectFile and and /// ObjectFile instances for the debug info @@ -1036,14 +1050,15 @@ private: Module(); // Only used internally by CreateJITModule () void FindTypes_Impl( - ConstString name, const CompilerDeclContext *parent_decl_ctx, + ConstString name, const CompilerDeclContext &parent_decl_ctx, size_t max_matches, llvm::DenseSet<lldb_private::SymbolFile *> &searched_symbol_files, TypeMap &types); - DISALLOW_COPY_AND_ASSIGN(Module); + Module(const Module &) = delete; + const Module &operator=(const Module &) = delete; }; } // namespace lldb_private -#endif // liblldb_Module_h_ +#endif // LLDB_CORE_MODULE_H diff --git a/lldb/include/lldb/Core/ModuleChild.h b/lldb/include/lldb/Core/ModuleChild.h index 0d59e4fb12ca..63eb1372ff68 100644 --- a/lldb/include/lldb/Core/ModuleChild.h +++ b/lldb/include/lldb/Core/ModuleChild.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef liblldb_ModuleChild_h_ -#define liblldb_ModuleChild_h_ +#ifndef LLDB_CORE_MODULECHILD_H +#define LLDB_CORE_MODULECHILD_H #include "lldb/lldb-forward.h" @@ -58,4 +58,4 @@ protected: } // namespace lldb_private -#endif // liblldb_ModuleChild_h_ +#endif // LLDB_CORE_MODULECHILD_H diff --git a/lldb/include/lldb/Core/ModuleList.h b/lldb/include/lldb/Core/ModuleList.h index a6e80ed75c76..ae1f6fdb20a2 100644 --- a/lldb/include/lldb/Core/ModuleList.h +++ b/lldb/include/lldb/Core/ModuleList.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef liblldb_ModuleList_h_ -#define liblldb_ModuleList_h_ +#ifndef LLDB_CORE_MODULELIST_H +#define LLDB_CORE_MODULELIST_H #include "lldb/Core/Address.h" #include "lldb/Core/ModuleSpec.h" @@ -20,6 +20,7 @@ #include "lldb/lldb-types.h" #include "llvm/ADT/DenseSet.h" +#include "llvm/Support/RWMutex.h" #include <functional> #include <list> @@ -46,6 +47,11 @@ class UUID; class VariableList; class ModuleListProperties : public Properties { + mutable llvm::sys::RWMutex m_symlink_paths_mutex; + PathMappingList m_symlink_paths; + + void UpdateSymlinkMappings(); + public: ModuleListProperties(); @@ -53,6 +59,8 @@ public: bool SetClangModulesCachePath(llvm::StringRef path); bool GetEnableExternalLookup() const; bool SetEnableExternalLookup(bool new_value); + + PathMappingList GetSymlinkMappings() const; }; /// \class ModuleList ModuleList.h "lldb/Core/ModuleList.h" @@ -489,4 +497,4 @@ public: } // namespace lldb_private -#endif // liblldb_ModuleList_h_ +#endif // LLDB_CORE_MODULELIST_H diff --git a/lldb/include/lldb/Core/ModuleSpec.h b/lldb/include/lldb/Core/ModuleSpec.h index 6d024fe3434b..9dd398a05291 100644 --- a/lldb/include/lldb/Core/ModuleSpec.h +++ b/lldb/include/lldb/Core/ModuleSpec.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef liblldb_ModuleSpec_h_ -#define liblldb_ModuleSpec_h_ +#ifndef LLDB_CORE_MODULESPEC_H +#define LLDB_CORE_MODULESPEC_H #include "lldb/Host/FileSystem.h" #include "lldb/Target/PathMappingList.h" @@ -30,11 +30,19 @@ public: m_object_name(), m_object_offset(0), m_object_size(0), m_source_mappings() {} - ModuleSpec(const FileSpec &file_spec, const UUID &uuid = UUID()) + /// If the \param data argument is passed, its contents will be used + /// as the module contents instead of trying to read them from + /// \param file_spec. + ModuleSpec(const FileSpec &file_spec, const UUID &uuid = UUID(), + lldb::DataBufferSP data = lldb::DataBufferSP()) : m_file(file_spec), m_platform_file(), m_symbol_file(), m_arch(), - m_uuid(uuid), m_object_name(), m_object_offset(0), - m_object_size(FileSystem::Instance().GetByteSize(file_spec)), - m_source_mappings() {} + m_uuid(uuid), m_object_name(), m_object_offset(0), m_source_mappings(), + m_data(data) { + if (data) + m_object_size = data->GetByteSize(); + else if (m_file) + m_object_size = FileSystem::Instance().GetByteSize(file_spec); + } ModuleSpec(const FileSpec &file_spec, const ArchSpec &arch) : m_file(file_spec), m_platform_file(), m_symbol_file(), m_arch(arch), @@ -42,30 +50,6 @@ public: m_object_size(FileSystem::Instance().GetByteSize(file_spec)), m_source_mappings() {} - ModuleSpec(const ModuleSpec &rhs) - : m_file(rhs.m_file), m_platform_file(rhs.m_platform_file), - m_symbol_file(rhs.m_symbol_file), m_arch(rhs.m_arch), - m_uuid(rhs.m_uuid), m_object_name(rhs.m_object_name), - m_object_offset(rhs.m_object_offset), m_object_size(rhs.m_object_size), - m_object_mod_time(rhs.m_object_mod_time), - m_source_mappings(rhs.m_source_mappings) {} - - ModuleSpec &operator=(const ModuleSpec &rhs) { - if (this != &rhs) { - m_file = rhs.m_file; - m_platform_file = rhs.m_platform_file; - m_symbol_file = rhs.m_symbol_file; - m_arch = rhs.m_arch; - m_uuid = rhs.m_uuid; - m_object_name = rhs.m_object_name; - m_object_offset = rhs.m_object_offset; - m_object_size = rhs.m_object_size; - m_object_mod_time = rhs.m_object_mod_time; - m_source_mappings = rhs.m_source_mappings; - } - return *this; - } - FileSpec *GetFileSpecPtr() { return (m_file ? &m_file : nullptr); } const FileSpec *GetFileSpecPtr() const { @@ -146,6 +130,8 @@ public: PathMappingList &GetSourceMappingList() const { return m_source_mappings; } + lldb::DataBufferSP GetData() const { return m_data; } + void Clear() { m_file.Clear(); m_platform_file.Clear(); @@ -289,6 +275,7 @@ protected: uint64_t m_object_size; llvm::sys::TimePoint<> m_object_mod_time; mutable PathMappingList m_source_mappings; + lldb::DataBufferSP m_data = {}; }; class ModuleSpecList { @@ -415,4 +402,4 @@ protected: } // namespace lldb_private -#endif // liblldb_ModuleSpec_h_ +#endif // LLDB_CORE_MODULESPEC_H diff --git a/lldb/include/lldb/Core/Opcode.h b/lldb/include/lldb/Core/Opcode.h index 1a30ce4834ac..a812ae23f6b7 100644 --- a/lldb/include/lldb/Core/Opcode.h +++ b/lldb/include/lldb/Core/Opcode.h @@ -6,13 +6,13 @@ // //===----------------------------------------------------------------------===// -#ifndef lldb_Opcode_h -#define lldb_Opcode_h +#ifndef LLDB_CORE_OPCODE_H +#define LLDB_CORE_OPCODE_H #include "lldb/Utility/Endian.h" #include "lldb/lldb-enumerations.h" -#include "llvm/Support/MathExtras.h" +#include "llvm/Support/SwapByteOrder.h" #include <assert.h> #include <stdint.h> @@ -270,4 +270,4 @@ protected: } // namespace lldb_private -#endif // lldb_Opcode_h +#endif // LLDB_CORE_OPCODE_H diff --git a/lldb/include/lldb/Core/PluginInterface.h b/lldb/include/lldb/Core/PluginInterface.h index 6e625a605917..17f6dc367155 100644 --- a/lldb/include/lldb/Core/PluginInterface.h +++ b/lldb/include/lldb/Core/PluginInterface.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef liblldb_PluginInterface_h_ -#define liblldb_PluginInterface_h_ +#ifndef LLDB_CORE_PLUGININTERFACE_H +#define LLDB_CORE_PLUGININTERFACE_H #include "lldb/lldb-private.h" @@ -24,4 +24,4 @@ public: } // namespace lldb_private -#endif // liblldb_PluginInterface_h_ +#endif // LLDB_CORE_PLUGININTERFACE_H diff --git a/lldb/include/lldb/Core/PluginManager.h b/lldb/include/lldb/Core/PluginManager.h index 5b859752b3c7..5e0c9395dae0 100644 --- a/lldb/include/lldb/Core/PluginManager.h +++ b/lldb/include/lldb/Core/PluginManager.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef liblldb_PluginManager_h_ -#define liblldb_PluginManager_h_ +#ifndef LLDB_CORE_PLUGINMANAGER_H +#define LLDB_CORE_PLUGINMANAGER_H #include "lldb/Core/Architecture.h" #include "lldb/Symbol/TypeSystem.h" @@ -22,6 +22,25 @@ #include <stddef.h> #include <stdint.h> +#define LLDB_PLUGIN_DEFINE_ADV(ClassName, PluginName) \ + namespace lldb_private { \ + void lldb_initialize_##PluginName() { ClassName::Initialize(); } \ + void lldb_terminate_##PluginName() { ClassName::Terminate(); } \ + } + +#define LLDB_PLUGIN_DEFINE(PluginName) \ + LLDB_PLUGIN_DEFINE_ADV(PluginName, PluginName) + +// FIXME: Generate me with CMake +#define LLDB_PLUGIN_DECLARE(PluginName) \ + namespace lldb_private { \ + extern void lldb_initialize_##PluginName(); \ + extern void lldb_terminate_##PluginName(); \ + } + +#define LLDB_PLUGIN_INITIALIZE(PluginName) lldb_initialize_##PluginName() +#define LLDB_PLUGIN_TERMINATE(PluginName) lldb_terminate_##PluginName() + namespace lldb_private { class CommandInterpreter; class ConstString; @@ -42,15 +61,8 @@ public: static ABICreateInstance GetABICreateCallbackAtIndex(uint32_t idx); - static ABICreateInstance - GetABICreateCallbackForPluginName(ConstString name); - // Architecture - using ArchitectureCreateInstance = - std::unique_ptr<Architecture> (*)(const ArchSpec &); - - static void RegisterPlugin(ConstString name, - llvm::StringRef description, + static void RegisterPlugin(ConstString name, llvm::StringRef description, ArchitectureCreateInstance create_callback); static void UnregisterPlugin(ArchitectureCreateInstance create_callback); @@ -95,9 +107,6 @@ public: static JITLoaderCreateInstance GetJITLoaderCreateCallbackAtIndex(uint32_t idx); - static JITLoaderCreateInstance - GetJITLoaderCreateCallbackForPluginName(ConstString name); - // EmulateInstruction static bool RegisterPlugin(ConstString name, const char *description, EmulateInstructionCreateInstance create_callback); @@ -132,9 +141,6 @@ public: static LanguageCreateInstance GetLanguageCreateCallbackAtIndex(uint32_t idx); - static LanguageCreateInstance - GetLanguageCreateCallbackForPluginName(ConstString name); - // LanguageRuntime static bool RegisterPlugin( ConstString name, const char *description, @@ -153,9 +159,6 @@ public: static LanguageRuntimeGetExceptionPrecondition GetLanguageRuntimeGetExceptionPreconditionAtIndex(uint32_t idx); - static LanguageRuntimeCreateInstance - GetLanguageRuntimeCreateCallbackForPluginName(ConstString name); - // SystemRuntime static bool RegisterPlugin(ConstString name, const char *description, SystemRuntimeCreateInstance create_callback); @@ -165,9 +168,6 @@ public: static SystemRuntimeCreateInstance GetSystemRuntimeCreateCallbackAtIndex(uint32_t idx); - static SystemRuntimeCreateInstance - GetSystemRuntimeCreateCallbackForPluginName(ConstString name); - // ObjectFile static bool RegisterPlugin(ConstString name, const char *description, @@ -187,9 +187,6 @@ public: static ObjectFileGetModuleSpecifications GetObjectFileGetModuleSpecificationsCallbackAtIndex(uint32_t idx); - static ObjectFileCreateInstance - GetObjectFileCreateCallbackForPluginName(ConstString name); - static ObjectFileCreateMemoryInstance GetObjectFileCreateMemoryCallbackForPluginName(ConstString name); @@ -207,9 +204,6 @@ public: static ObjectContainerCreateInstance GetObjectContainerCreateCallbackAtIndex(uint32_t idx); - static ObjectContainerCreateInstance - GetObjectContainerCreateCallbackForPluginName(ConstString name); - static ObjectFileGetModuleSpecifications GetObjectContainerGetModuleSpecificationsCallbackAtIndex(uint32_t idx); @@ -249,6 +243,9 @@ public: static const char *GetProcessPluginDescriptionAtIndex(uint32_t idx); + static void AutoCompleteProcessName(llvm::StringRef partial_name, + CompletionRequest &request); + // ScriptInterpreter static bool RegisterPlugin(ConstString name, const char *description, lldb::ScriptLanguage script_lang, @@ -309,9 +306,6 @@ public: static StructuredDataPluginCreateInstance GetStructuredDataPluginCreateCallbackAtIndex(uint32_t idx); - static StructuredDataPluginCreateInstance - GetStructuredDataPluginCreateCallbackForPluginName(ConstString name); - static StructuredDataFilterLaunchInfo GetStructuredDataFilterCallbackAtIndex(uint32_t idx, bool &iteration_complete); @@ -327,9 +321,6 @@ public: static SymbolFileCreateInstance GetSymbolFileCreateCallbackAtIndex(uint32_t idx); - static SymbolFileCreateInstance - GetSymbolFileCreateCallbackForPluginName(ConstString name); - // SymbolVendor static bool RegisterPlugin(ConstString name, const char *description, SymbolVendorCreateInstance create_callback); @@ -339,9 +330,6 @@ public: static SymbolVendorCreateInstance GetSymbolVendorCreateCallbackAtIndex(uint32_t idx); - static SymbolVendorCreateInstance - GetSymbolVendorCreateCallbackForPluginName(ConstString name); - // UnwindAssembly static bool RegisterPlugin(ConstString name, const char *description, UnwindAssemblyCreateInstance create_callback); @@ -351,9 +339,6 @@ public: static UnwindAssemblyCreateInstance GetUnwindAssemblyCreateCallbackAtIndex(uint32_t idx); - static UnwindAssemblyCreateInstance - GetUnwindAssemblyCreateCallbackForPluginName(ConstString name); - // MemoryHistory static bool RegisterPlugin(ConstString name, const char *description, MemoryHistoryCreateInstance create_callback); @@ -363,9 +348,6 @@ public: static MemoryHistoryCreateInstance GetMemoryHistoryCreateCallbackAtIndex(uint32_t idx); - static MemoryHistoryCreateInstance - GetMemoryHistoryCreateCallbackForPluginName(ConstString name); - // InstrumentationRuntime static bool RegisterPlugin(ConstString name, const char *description, @@ -381,9 +363,6 @@ public: static InstrumentationRuntimeCreateInstance GetInstrumentationRuntimeCreateCallbackAtIndex(uint32_t idx); - static InstrumentationRuntimeCreateInstance - GetInstrumentationRuntimeCreateCallbackForPluginName(ConstString name); - // TypeSystem static bool RegisterPlugin(ConstString name, const char *description, TypeSystemCreateInstance create_callback, @@ -395,9 +374,6 @@ public: static TypeSystemCreateInstance GetTypeSystemCreateCallbackAtIndex(uint32_t idx); - static TypeSystemCreateInstance - GetTypeSystemCreateCallbackForPluginName(ConstString name); - static LanguageSet GetAllTypeSystemSupportedLanguagesForTypes(); static LanguageSet GetAllTypeSystemSupportedLanguagesForExpressions(); @@ -411,9 +387,6 @@ public: static REPLCreateInstance GetREPLCreateCallbackAtIndex(uint32_t idx); - static REPLCreateInstance - GetREPLCreateCallbackForPluginName(ConstString name); - static LanguageSet GetREPLAllTypeSystemSupportedLanguages(); // Some plug-ins might register a DebuggerInitializeCallback callback when @@ -478,4 +451,4 @@ public: } // namespace lldb_private -#endif // liblldb_PluginManager_h_ +#endif // LLDB_CORE_PLUGINMANAGER_H diff --git a/lldb/include/lldb/Core/PropertiesBase.td b/lldb/include/lldb/Core/PropertiesBase.td index 6e95ceb779ba..1be3b908ed41 100644 --- a/lldb/include/lldb/Core/PropertiesBase.td +++ b/lldb/include/lldb/Core/PropertiesBase.td @@ -49,3 +49,9 @@ class DefaultUnsignedValue<int value> { class EnumValues<string enum> { string EnumValues = enum; } + +// Determines the element type for arrays and dictionaries. +class ElementType<string value> { + string ElementType = value; + bit HasElementType = 1; +} diff --git a/lldb/include/lldb/Core/RichManglingContext.h b/lldb/include/lldb/Core/RichManglingContext.h index e6fa2599e55a..68f80e73b724 100644 --- a/lldb/include/lldb/Core/RichManglingContext.h +++ b/lldb/include/lldb/Core/RichManglingContext.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef liblldb_RichManglingContext_h_ -#define liblldb_RichManglingContext_h_ +#ifndef LLDB_CORE_RICHMANGLINGCONTEXT_H +#define LLDB_CORE_RICHMANGLINGCONTEXT_H #include "lldb/lldb-forward.h" #include "lldb/lldb-private.h" diff --git a/lldb/include/lldb/Core/SearchFilter.h b/lldb/include/lldb/Core/SearchFilter.h index 74c4f3162a1c..54dc65e4410f 100644 --- a/lldb/include/lldb/Core/SearchFilter.h +++ b/lldb/include/lldb/Core/SearchFilter.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef liblldb_SearchFilter_h_ -#define liblldb_SearchFilter_h_ +#ifndef LLDB_CORE_SEARCHFILTER_H +#define LLDB_CORE_SEARCHFILTER_H #include "lldb/Core/FileSpecList.h" #include "lldb/Utility/StructuredData.h" @@ -98,6 +98,8 @@ public: /// The file spec to check against the filter. /// \return /// \b true if \a spec passes, and \b false otherwise. + /// + /// \note the default implementation always returns \c true. virtual bool ModulePasses(const FileSpec &spec); /// Call this method with a Module to see if that module passes the filter. @@ -107,6 +109,8 @@ public: /// /// \return /// \b true if \a module passes, and \b false otherwise. + /// + /// \note the default implementation always returns \c true. virtual bool ModulePasses(const lldb::ModuleSP &module_sp); /// Call this method with a Address to see if \a address passes the filter. @@ -116,6 +120,8 @@ public: /// /// \return /// \b true if \a address passes, and \b false otherwise. + /// + /// \note the default implementation always returns \c true. virtual bool AddressPasses(Address &addr); /// Call this method with a FileSpec to see if \a file spec passes the @@ -126,6 +132,8 @@ public: /// /// \return /// \b true if \a file spec passes, and \b false otherwise. + /// + /// \note the default implementation always returns \c true. virtual bool CompUnitPasses(FileSpec &fileSpec); /// Call this method with a CompileUnit to see if \a comp unit passes the @@ -136,6 +144,8 @@ public: /// /// \return /// \b true if \a Comp Unit passes, and \b false otherwise. + /// + /// \note the default implementation always returns \c true. virtual bool CompUnitPasses(CompileUnit &compUnit); /// Call this method with a Function to see if \a function passes the @@ -187,10 +197,10 @@ public: /// Standard "Dump" method. At present it does nothing. virtual void Dump(Stream *s) const; - lldb::SearchFilterSP CopyForBreakpoint(Breakpoint &breakpoint); + lldb::SearchFilterSP CreateCopy(lldb::TargetSP& target_sp); static lldb::SearchFilterSP - CreateFromStructuredData(Target &target, + CreateFromStructuredData(const lldb::TargetSP& target_sp, const StructuredData::Dictionary &data_dict, Status &error); @@ -261,13 +271,13 @@ protected: const SymbolContext &context, Searcher &searcher); - virtual lldb::SearchFilterSP DoCopyForBreakpoint(Breakpoint &breakpoint) = 0; + virtual lldb::SearchFilterSP DoCreateCopy() = 0; void SetTarget(lldb::TargetSP &target_sp) { m_target_sp = target_sp; } - lldb::TargetSP - m_target_sp; // Every filter has to be associated with a target for - // now since you need a starting place for the search. + lldb::TargetSP m_target_sp; // Every filter has to be associated with + // a target for now since you need a starting + // place for the search. private: unsigned char SubclassID; }; @@ -288,14 +298,14 @@ public: bool ModulePasses(const lldb::ModuleSP &module_sp) override; static lldb::SearchFilterSP - CreateFromStructuredData(Target &target, + CreateFromStructuredData(const lldb::TargetSP& target_sp, const StructuredData::Dictionary &data_dict, Status &error); StructuredData::ObjectSP SerializeToStructuredData() override; protected: - lldb::SearchFilterSP DoCopyForBreakpoint(Breakpoint &breakpoint) override; + lldb::SearchFilterSP DoCreateCopy() override; }; /// \class SearchFilterByModule SearchFilter.h "lldb/Core/SearchFilter.h" This @@ -321,10 +331,6 @@ public: bool AddressPasses(Address &address) override; - bool CompUnitPasses(FileSpec &fileSpec) override; - - bool CompUnitPasses(CompileUnit &compUnit) override; - void GetDescription(Stream *s) override; uint32_t GetFilterRequiredItems() override; @@ -334,14 +340,14 @@ public: void Search(Searcher &searcher) override; static lldb::SearchFilterSP - CreateFromStructuredData(Target &target, + CreateFromStructuredData(const lldb::TargetSP& target_sp, const StructuredData::Dictionary &data_dict, Status &error); StructuredData::ObjectSP SerializeToStructuredData() override; protected: - lldb::SearchFilterSP DoCopyForBreakpoint(Breakpoint &breakpoint) override; + lldb::SearchFilterSP DoCreateCopy() override; private: FileSpec m_module_spec; @@ -372,10 +378,6 @@ public: bool AddressPasses(Address &address) override; - bool CompUnitPasses(FileSpec &fileSpec) override; - - bool CompUnitPasses(CompileUnit &compUnit) override; - void GetDescription(Stream *s) override; uint32_t GetFilterRequiredItems() override; @@ -385,7 +387,7 @@ public: void Search(Searcher &searcher) override; static lldb::SearchFilterSP - CreateFromStructuredData(Target &target, + CreateFromStructuredData(const lldb::TargetSP& target_sp, const StructuredData::Dictionary &data_dict, Status &error); @@ -394,9 +396,8 @@ public: void SerializeUnwrapped(StructuredData::DictionarySP &options_dict_sp); protected: - lldb::SearchFilterSP DoCopyForBreakpoint(Breakpoint &breakpoint) override; + lldb::SearchFilterSP DoCreateCopy() override; -protected: FileSpecList m_module_spec_list; }; @@ -425,14 +426,14 @@ public: void Search(Searcher &searcher) override; static lldb::SearchFilterSP - CreateFromStructuredData(Target &target, + CreateFromStructuredData(const lldb::TargetSP& target_sp, const StructuredData::Dictionary &data_dict, Status &error); StructuredData::ObjectSP SerializeToStructuredData() override; protected: - lldb::SearchFilterSP DoCopyForBreakpoint(Breakpoint &breakpoint) override; + lldb::SearchFilterSP DoCreateCopy() override; private: FileSpecList m_cu_spec_list; @@ -440,4 +441,4 @@ private: } // namespace lldb_private -#endif // liblldb_SearchFilter_h_ +#endif // LLDB_CORE_SEARCHFILTER_H diff --git a/lldb/include/lldb/Core/Section.h b/lldb/include/lldb/Core/Section.h index 509a0767be1d..af2bb7896a5b 100644 --- a/lldb/include/lldb/Core/Section.h +++ b/lldb/include/lldb/Core/Section.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef liblldb_Section_h_ -#define liblldb_Section_h_ +#ifndef LLDB_CORE_SECTION_H +#define LLDB_CORE_SECTION_H #include "lldb/Core/ModuleChild.h" #include "lldb/Utility/ConstString.h" @@ -29,7 +29,6 @@ class Address; class DataExtractor; class ObjectFile; class Section; -class Stream; class Target; class SectionList { @@ -56,7 +55,8 @@ public: bool ContainsSection(lldb::user_id_t sect_id) const; - void Dump(Stream *s, Target *target, bool show_header, uint32_t depth) const; + void Dump(llvm::raw_ostream &s, unsigned indent, Target *target, + bool show_header, uint32_t depth) const; lldb::SectionSP FindSectionByName(ConstString section_dstr) const; @@ -127,9 +127,10 @@ public: const SectionList &GetChildren() const { return m_children; } - void Dump(Stream *s, Target *target, uint32_t depth) const; + void Dump(llvm::raw_ostream &s, unsigned indent, Target *target, + uint32_t depth) const; - void DumpName(Stream *s) const; + void DumpName(llvm::raw_ostream &s) const; lldb::addr_t GetLoadBaseAddress(Target *target) const; @@ -267,9 +268,10 @@ protected: // This is specified as // as a multiple number of a host bytes private: - DISALLOW_COPY_AND_ASSIGN(Section); + Section(const Section &) = delete; + const Section &operator=(const Section &) = delete; }; } // namespace lldb_private -#endif // liblldb_Section_h_ +#endif // LLDB_CORE_SECTION_H diff --git a/lldb/include/lldb/Core/SourceManager.h b/lldb/include/lldb/Core/SourceManager.h index f1f56d0886c3..7549c308f33a 100644 --- a/lldb/include/lldb/Core/SourceManager.h +++ b/lldb/include/lldb/Core/SourceManager.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef liblldb_SourceManager_h_ -#define liblldb_SourceManager_h_ +#ifndef LLDB_CORE_SOURCEMANAGER_H +#define LLDB_CORE_SOURCEMANAGER_H #include "lldb/Utility/FileSpec.h" #include "lldb/lldb-defines.h" @@ -101,6 +101,9 @@ public: void AddSourceFile(const FileSP &file_sp); FileSP FindSourceFile(const FileSpec &file_spec) const; + // Removes all elements from the cache. + void Clear() { m_file_cache.clear(); } + protected: typedef std::map<FileSpec, FileSP> FileCache; FileCache m_file_cache; @@ -116,7 +119,7 @@ public: ~SourceManager(); - FileSP GetLastFile() { return m_last_file_sp; } + FileSP GetLastFile() { return GetFile(m_last_file_spec); } size_t DisplaySourceLinesWithLineNumbers(const FileSpec &file, uint32_t line, @@ -138,7 +141,9 @@ public: bool GetDefaultFileAndLine(FileSpec &file_spec, uint32_t &line); - bool DefaultFileAndLineSet() { return (m_last_file_sp.get() != nullptr); } + bool DefaultFileAndLineSet() { + return (GetFile(m_last_file_spec).get() != nullptr); + } void FindLinesMatchingRegex(FileSpec &file_spec, RegularExpression ®ex, uint32_t start_line, uint32_t end_line, @@ -147,7 +152,7 @@ public: FileSP GetFile(const FileSpec &file_spec); protected: - FileSP m_last_file_sp; + FileSpec m_last_file_spec; uint32_t m_last_line; uint32_t m_last_count; bool m_default_set; @@ -155,11 +160,12 @@ protected: lldb::DebuggerWP m_debugger_wp; private: - DISALLOW_COPY_AND_ASSIGN(SourceManager); + SourceManager(const SourceManager &) = delete; + const SourceManager &operator=(const SourceManager &) = delete; }; bool operator==(const SourceManager::File &lhs, const SourceManager::File &rhs); } // namespace lldb_private -#endif // liblldb_SourceManager_h_ +#endif // LLDB_CORE_SOURCEMANAGER_H diff --git a/lldb/include/lldb/Core/StreamAsynchronousIO.h b/lldb/include/lldb/Core/StreamAsynchronousIO.h index 6237e12b7d1e..949a798955d1 100644 --- a/lldb/include/lldb/Core/StreamAsynchronousIO.h +++ b/lldb/include/lldb/Core/StreamAsynchronousIO.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef liblldb_StreamAsynchronousIO_h_ -#define liblldb_StreamAsynchronousIO_h_ +#ifndef LLDB_CORE_STREAMASYNCHRONOUSIO_H +#define LLDB_CORE_STREAMASYNCHRONOUSIO_H #include "lldb/Utility/Stream.h" @@ -37,4 +37,4 @@ private: } // namespace lldb_private -#endif // liblldb_StreamAsynchronousIO_h +#endif // LLDB_CORE_STREAMASYNCHRONOUSIO_H diff --git a/lldb/include/lldb/Core/StreamBuffer.h b/lldb/include/lldb/Core/StreamBuffer.h index 6c516519781f..9c48ddb44d71 100644 --- a/lldb/include/lldb/Core/StreamBuffer.h +++ b/lldb/include/lldb/Core/StreamBuffer.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef liblldb_StreamBuffer_h_ -#define liblldb_StreamBuffer_h_ +#ifndef LLDB_CORE_STREAMBUFFER_H +#define LLDB_CORE_STREAMBUFFER_H #include "lldb/Utility/Stream.h" #include "llvm/ADT/SmallVector.h" @@ -51,4 +51,4 @@ protected: } // namespace lldb_private -#endif // #ifndef liblldb_StreamBuffer_h_ +#endif // LLDB_CORE_STREAMBUFFER_H diff --git a/lldb/include/lldb/Core/StreamFile.h b/lldb/include/lldb/Core/StreamFile.h index bd7d6e8e6ad3..e71e31eb1d04 100644 --- a/lldb/include/lldb/Core/StreamFile.h +++ b/lldb/include/lldb/Core/StreamFile.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef liblldb_StreamFile_h_ -#define liblldb_StreamFile_h_ +#ifndef LLDB_CORE_STREAMFILE_H +#define LLDB_CORE_STREAMFILE_H #include "lldb/Host/File.h" #include "lldb/Utility/Stream.h" @@ -48,9 +48,10 @@ protected: size_t WriteImpl(const void *s, size_t length) override; private: - DISALLOW_COPY_AND_ASSIGN(StreamFile); + StreamFile(const StreamFile &) = delete; + const StreamFile &operator=(const StreamFile &) = delete; }; } // namespace lldb_private -#endif // liblldb_StreamFile_h_ +#endif // LLDB_CORE_STREAMFILE_H diff --git a/lldb/include/lldb/Core/StructuredDataImpl.h b/lldb/include/lldb/Core/StructuredDataImpl.h index c66e4736dc26..9aea645a3ea6 100644 --- a/lldb/include/lldb/Core/StructuredDataImpl.h +++ b/lldb/include/lldb/Core/StructuredDataImpl.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef liblldb_StructuredDataImpl_h_ -#define liblldb_StructuredDataImpl_h_ +#ifndef LLDB_CORE_STRUCTUREDDATAIMPL_H +#define LLDB_CORE_STRUCTUREDDATAIMPL_H #include "lldb/Target/StructuredDataPlugin.h" #include "lldb/Utility/Event.h" diff --git a/lldb/include/lldb/Core/ThreadSafeDenseMap.h b/lldb/include/lldb/Core/ThreadSafeDenseMap.h index 420cb5763586..2f6eb280e4a1 100644 --- a/lldb/include/lldb/Core/ThreadSafeDenseMap.h +++ b/lldb/include/lldb/Core/ThreadSafeDenseMap.h @@ -7,8 +7,8 @@ // //===----------------------------------------------------------------------===// -#ifndef liblldb_ThreadSafeDenseMap_h_ -#define liblldb_ThreadSafeDenseMap_h_ +#ifndef LLDB_CORE_THREADSAFEDENSEMAP_H +#define LLDB_CORE_THREADSAFEDENSEMAP_H #include <mutex> @@ -62,4 +62,4 @@ protected: } // namespace lldb_private -#endif // liblldb_ThreadSafeDenseMap_h_ +#endif // LLDB_CORE_THREADSAFEDENSEMAP_H diff --git a/lldb/include/lldb/Core/ThreadSafeValue.h b/lldb/include/lldb/Core/ThreadSafeValue.h index 91f96814363f..38b8034fad53 100644 --- a/lldb/include/lldb/Core/ThreadSafeValue.h +++ b/lldb/include/lldb/Core/ThreadSafeValue.h @@ -6,9 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef liblldb_ThreadSafeValue_h_ -#define liblldb_ThreadSafeValue_h_ - +#ifndef LLDB_CORE_THREADSAFEVALUE_H +#define LLDB_CORE_THREADSAFEVALUE_H #include <mutex> @@ -54,8 +53,9 @@ private: mutable std::recursive_mutex m_mutex; // For ThreadSafeValue only - DISALLOW_COPY_AND_ASSIGN(ThreadSafeValue); + ThreadSafeValue(const ThreadSafeValue &) = delete; + const ThreadSafeValue &operator=(const ThreadSafeValue &) = delete; }; } // namespace lldb_private -#endif // liblldb_ThreadSafeValue_h_ +#endif // LLDB_CORE_THREADSAFEVALUE_H diff --git a/lldb/include/lldb/Core/UniqueCStringMap.h b/lldb/include/lldb/Core/UniqueCStringMap.h index 9949bd45f4fa..e37027a0150a 100644 --- a/lldb/include/lldb/Core/UniqueCStringMap.h +++ b/lldb/include/lldb/Core/UniqueCStringMap.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef liblldb_UniqueCStringMap_h_ -#define liblldb_UniqueCStringMap_h_ +#ifndef LLDB_CORE_UNIQUECSTRINGMAP_H +#define LLDB_CORE_UNIQUECSTRINGMAP_H #include <algorithm> #include <vector> @@ -32,6 +32,10 @@ public: T value; }; + typedef std::vector<Entry> collection; + typedef typename collection::iterator iterator; + typedef typename collection::const_iterator const_iterator; + // 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. @@ -175,6 +179,18 @@ public: } } + iterator begin() { return m_map.begin(); } + iterator end() { return m_map.end(); } + const_iterator begin() const { return m_map.begin(); } + const_iterator end() const { return m_map.end(); } + + // Range-based for loop for all entries of the specified ConstString name. + llvm::iterator_range<const_iterator> + equal_range(ConstString unique_cstr) const { + return llvm::make_range( + std::equal_range(m_map.begin(), m_map.end(), unique_cstr, Compare())); + }; + protected: struct Compare { bool operator()(const Entry &lhs, const Entry &rhs) { @@ -196,12 +212,9 @@ protected: 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; collection m_map; }; } // namespace lldb_private -#endif // liblldb_UniqueCStringMap_h_ +#endif // LLDB_CORE_UNIQUECSTRINGMAP_H diff --git a/lldb/include/lldb/Core/UserSettingsController.h b/lldb/include/lldb/Core/UserSettingsController.h index 6ae3bdec1665..f40ad54ac4d6 100644 --- a/lldb/include/lldb/Core/UserSettingsController.h +++ b/lldb/include/lldb/Core/UserSettingsController.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef liblldb_UserSettingsController_h_ -#define liblldb_UserSettingsController_h_ +#ifndef LLDB_CORE_USERSETTINGSCONTROLLER_H +#define LLDB_CORE_USERSETTINGSCONTROLLER_H #include "lldb/Utility/Status.h" #include "lldb/lldb-forward.h" @@ -88,4 +88,4 @@ protected: } // namespace lldb_private -#endif // liblldb_UserSettingsController_h_ +#endif // LLDB_CORE_USERSETTINGSCONTROLLER_H diff --git a/lldb/include/lldb/Core/Value.h b/lldb/include/lldb/Core/Value.h index 7b4cc3b71c28..641a64a3bbbe 100644 --- a/lldb/include/lldb/Core/Value.h +++ b/lldb/include/lldb/Core/Value.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef liblldb_Value_h_ -#define liblldb_Value_h_ +#ifndef LLDB_CORE_VALUE_H +#define LLDB_CORE_VALUE_H #include "lldb/Symbol/CompilerType.h" #include "lldb/Utility/DataBufferHeap.h" @@ -258,4 +258,4 @@ private: } // namespace lldb_private -#endif // liblldb_Value_h_ +#endif // LLDB_CORE_VALUE_H diff --git a/lldb/include/lldb/Core/ValueObject.h b/lldb/include/lldb/Core/ValueObject.h index 1b000e617f0e..0080368fd996 100644 --- a/lldb/include/lldb/Core/ValueObject.h +++ b/lldb/include/lldb/Core/ValueObject.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef liblldb_ValueObject_h_ -#define liblldb_ValueObject_h_ +#ifndef LLDB_CORE_VALUEOBJECT_H +#define LLDB_CORE_VALUEOBJECT_H #include "lldb/Core/Value.h" #include "lldb/Symbol/CompilerType.h" @@ -396,10 +396,8 @@ public: bool IsIntegerType(bool &is_signed); - virtual bool GetBaseClassPath(Stream &s); - virtual void GetExpressionPath( - Stream &s, bool qualify_cxx_base_classes, + Stream &s, GetExpressionPathFormat = eGetExpressionPathFormatDereferencePointers); lldb::ValueObjectSP GetValueForExpressionPath( @@ -577,7 +575,7 @@ public: virtual lldb::ValueObjectSP GetNonSyntheticValue(); - lldb::ValueObjectSP GetSyntheticValue(bool use_synthetic = true); + lldb::ValueObjectSP GetSyntheticValue(); virtual bool HasSyntheticValue(); @@ -889,7 +887,6 @@ protected: m_is_synthetic_children_generated : 1; friend class ValueObjectChild; - friend class ClangExpressionDeclMap; // For GetValue friend class ExpressionVariable; // For SetName friend class Target; // For SetName friend class ValueObjectConstResultImpl; @@ -905,7 +902,7 @@ protected: // Use this constructor to create a "root variable object". The ValueObject // will be locked to this context through-out its lifespan. - ValueObject(ExecutionContextScope *exe_scope, + ValueObject(ExecutionContextScope *exe_scope, ValueObjectManager &manager, AddressType child_ptr_or_ref_addr_type = eAddressTypeLoad); // Use this constructor to create a ValueObject owned by another ValueObject. @@ -929,7 +926,7 @@ protected: virtual bool HasDynamicValueTypeInfo() { return false; } - virtual void CalculateSyntheticValue(bool use_synthetic = true); + virtual void CalculateSyntheticValue(); // Should only be called by ValueObject::GetChildAtIndex() Returns a // ValueObject managed by this ValueObject's manager. @@ -966,9 +963,14 @@ protected: void SetPreferredDisplayLanguageIfNeeded(lldb::LanguageType); +protected: + virtual void DoUpdateChildrenAddressType(ValueObject &valobj) { return; }; + private: virtual CompilerType MaybeCalculateCompleteType(); - void UpdateChildrenAddressType(); + void UpdateChildrenAddressType() { + GetRoot()->DoUpdateChildrenAddressType(*this); + } lldb::ValueObjectSP GetValueForExpressionPath_Impl( llvm::StringRef expression_cstr, @@ -977,7 +979,8 @@ private: const GetValueForExpressionPathOptions &options, ExpressionPathAftermath *final_task_on_target); - DISALLOW_COPY_AND_ASSIGN(ValueObject); + ValueObject(const ValueObject &) = delete; + const ValueObject &operator=(const ValueObject &) = delete; }; // A value object manager class that is seeded with the static variable value @@ -1023,4 +1026,4 @@ public: } // namespace lldb_private -#endif // liblldb_ValueObject_h_ +#endif // LLDB_CORE_VALUEOBJECT_H diff --git a/lldb/include/lldb/Core/ValueObjectCast.h b/lldb/include/lldb/Core/ValueObjectCast.h index feee493dfafb..d91ca6a92be8 100644 --- a/lldb/include/lldb/Core/ValueObjectCast.h +++ b/lldb/include/lldb/Core/ValueObjectCast.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef liblldb_ValueObjectCast_h_ -#define liblldb_ValueObjectCast_h_ +#ifndef LLDB_CORE_VALUEOBJECTCAST_H +#define LLDB_CORE_VALUEOBJECTCAST_H #include "lldb/Core/ValueObject.h" #include "lldb/Symbol/CompilerType.h" @@ -57,9 +57,10 @@ protected: CompilerType m_cast_type; private: - DISALLOW_COPY_AND_ASSIGN(ValueObjectCast); + ValueObjectCast(const ValueObjectCast &) = delete; + const ValueObjectCast &operator=(const ValueObjectCast &) = delete; }; } // namespace lldb_private -#endif // liblldb_ValueObjectCast_h_ +#endif // LLDB_CORE_VALUEOBJECTCAST_H diff --git a/lldb/include/lldb/Core/ValueObjectChild.h b/lldb/include/lldb/Core/ValueObjectChild.h index 76209a22ec20..c6f44a29b059 100644 --- a/lldb/include/lldb/Core/ValueObjectChild.h +++ b/lldb/include/lldb/Core/ValueObjectChild.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef liblldb_ValueObjectChild_h_ -#define liblldb_ValueObjectChild_h_ +#ifndef LLDB_CORE_VALUEOBJECTCHILD_H +#define LLDB_CORE_VALUEOBJECTCHILD_H #include "lldb/Core/ValueObject.h" @@ -75,7 +75,6 @@ protected: // void // ReadValueFromMemory (ValueObject* parent, lldb::addr_t address); -protected: friend class ValueObject; friend class ValueObjectConstResult; friend class ValueObjectConstResultImpl; @@ -88,9 +87,10 @@ protected: AddressType child_ptr_or_ref_addr_type, uint64_t language_flags); - DISALLOW_COPY_AND_ASSIGN(ValueObjectChild); + ValueObjectChild(const ValueObjectChild &) = delete; + const ValueObjectChild &operator=(const ValueObjectChild &) = delete; }; } // namespace lldb_private -#endif // liblldb_ValueObjectChild_h_ +#endif // LLDB_CORE_VALUEOBJECTCHILD_H diff --git a/lldb/include/lldb/Core/ValueObjectConstResult.h b/lldb/include/lldb/Core/ValueObjectConstResult.h index 3bc957ef2b84..0e868c687e93 100644 --- a/lldb/include/lldb/Core/ValueObjectConstResult.h +++ b/lldb/include/lldb/Core/ValueObjectConstResult.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef liblldb_ValueObjectConstResult_h_ -#define liblldb_ValueObjectConstResult_h_ +#ifndef LLDB_CORE_VALUEOBJECTCONSTRESULT_H +#define LLDB_CORE_VALUEOBJECTCONSTRESULT_H #include "lldb/Core/Value.h" #include "lldb/Core/ValueObject.h" @@ -121,34 +121,40 @@ private: friend class ValueObjectConstResultImpl; ValueObjectConstResult(ExecutionContextScope *exe_scope, + ValueObjectManager &manager, lldb::ByteOrder byte_order, uint32_t addr_byte_size, lldb::addr_t address); ValueObjectConstResult(ExecutionContextScope *exe_scope, - const CompilerType &compiler_type, - ConstString name, const DataExtractor &data, - lldb::addr_t address); + ValueObjectManager &manager, + const CompilerType &compiler_type, ConstString name, + const DataExtractor &data, lldb::addr_t address); ValueObjectConstResult(ExecutionContextScope *exe_scope, - const CompilerType &compiler_type, - ConstString name, + ValueObjectManager &manager, + const CompilerType &compiler_type, 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, - ConstString name, lldb::addr_t address, - AddressType address_type, uint32_t addr_byte_size); + ValueObjectManager &manager, + const CompilerType &compiler_type, ConstString name, + lldb::addr_t address, AddressType address_type, + uint32_t addr_byte_size); - ValueObjectConstResult(ExecutionContextScope *exe_scope, const Value &value, + ValueObjectConstResult(ExecutionContextScope *exe_scope, + ValueObjectManager &manager, const Value &value, ConstString name, Module *module = nullptr); - ValueObjectConstResult(ExecutionContextScope *exe_scope, const Status &error); + ValueObjectConstResult(ExecutionContextScope *exe_scope, + ValueObjectManager &manager, const Status &error); - DISALLOW_COPY_AND_ASSIGN(ValueObjectConstResult); + ValueObjectConstResult(const ValueObjectConstResult &) = delete; + const ValueObjectConstResult & + operator=(const ValueObjectConstResult &) = delete; }; } // namespace lldb_private -#endif // liblldb_ValueObjectConstResult_h_ +#endif // LLDB_CORE_VALUEOBJECTCONSTRESULT_H diff --git a/lldb/include/lldb/Core/ValueObjectConstResultCast.h b/lldb/include/lldb/Core/ValueObjectConstResultCast.h index be9b12b4b57c..ba81785866c3 100644 --- a/lldb/include/lldb/Core/ValueObjectConstResultCast.h +++ b/lldb/include/lldb/Core/ValueObjectConstResultCast.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef liblldb_ValueObjectConstResultCast_h_ -#define liblldb_ValueObjectConstResultCast_h_ +#ifndef LLDB_CORE_VALUEOBJECTCONSTRESULTCAST_H +#define LLDB_CORE_VALUEOBJECTCONSTRESULTCAST_H #include "lldb/Core/ValueObjectCast.h" #include "lldb/Core/ValueObjectConstResultImpl.h" @@ -61,9 +61,11 @@ private: friend class ValueObjectConstResult; friend class ValueObjectConstResultImpl; - DISALLOW_COPY_AND_ASSIGN(ValueObjectConstResultCast); + ValueObjectConstResultCast(const ValueObjectConstResultCast &) = delete; + const ValueObjectConstResultCast & + operator=(const ValueObjectConstResultCast &) = delete; }; } // namespace lldb_private -#endif // liblldb_ValueObjectConstResultCast_h_ +#endif // LLDB_CORE_VALUEOBJECTCONSTRESULTCAST_H diff --git a/lldb/include/lldb/Core/ValueObjectConstResultChild.h b/lldb/include/lldb/Core/ValueObjectConstResultChild.h index 16fa74f71ed5..b3606bfde0ef 100644 --- a/lldb/include/lldb/Core/ValueObjectConstResultChild.h +++ b/lldb/include/lldb/Core/ValueObjectConstResultChild.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef liblldb_ValueObjectConstResultChild_h_ -#define liblldb_ValueObjectConstResultChild_h_ +#ifndef LLDB_CORE_VALUEOBJECTCONSTRESULTCHILD_H +#define LLDB_CORE_VALUEOBJECTCONSTRESULTCHILD_H #include "lldb/Core/ValueObjectChild.h" #include "lldb/Core/ValueObjectConstResultImpl.h" @@ -70,9 +70,11 @@ private: friend class ValueObjectConstResult; friend class ValueObjectConstResultImpl; - DISALLOW_COPY_AND_ASSIGN(ValueObjectConstResultChild); + ValueObjectConstResultChild(const ValueObjectConstResultChild &) = delete; + const ValueObjectConstResultChild & + operator=(const ValueObjectConstResultChild &) = delete; }; } // namespace lldb_private -#endif // liblldb_ValueObjectConstResultChild_h_ +#endif // LLDB_CORE_VALUEOBJECTCONSTRESULTCHILD_H diff --git a/lldb/include/lldb/Core/ValueObjectConstResultImpl.h b/lldb/include/lldb/Core/ValueObjectConstResultImpl.h index ffac98e12e61..1316bf66dfdb 100644 --- a/lldb/include/lldb/Core/ValueObjectConstResultImpl.h +++ b/lldb/include/lldb/Core/ValueObjectConstResultImpl.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef liblldb_ValueObjectConstResultImpl_h_ -#define liblldb_ValueObjectConstResultImpl_h_ +#ifndef LLDB_CORE_VALUEOBJECTCONSTRESULTIMPL_H +#define LLDB_CORE_VALUEOBJECTCONSTRESULTIMPL_H #include "lldb/Utility/ConstString.h" #include "lldb/lldb-defines.h" @@ -71,9 +71,11 @@ private: lldb::ValueObjectSP m_load_addr_backend; lldb::ValueObjectSP m_address_of_backend; - DISALLOW_COPY_AND_ASSIGN(ValueObjectConstResultImpl); + ValueObjectConstResultImpl(const ValueObjectConstResultImpl &) = delete; + const ValueObjectConstResultImpl & + operator=(const ValueObjectConstResultImpl &) = delete; }; } // namespace lldb_private -#endif // liblldb_ValueObjectConstResultImpl_h_ +#endif // LLDB_CORE_VALUEOBJECTCONSTRESULTIMPL_H diff --git a/lldb/include/lldb/Core/ValueObjectDynamicValue.h b/lldb/include/lldb/Core/ValueObjectDynamicValue.h index f656d42e9a97..9f5304b55e93 100644 --- a/lldb/include/lldb/Core/ValueObjectDynamicValue.h +++ b/lldb/include/lldb/Core/ValueObjectDynamicValue.h @@ -6,15 +6,14 @@ // //===----------------------------------------------------------------------===// -#ifndef liblldb_ValueObjectDynamicValue_h_ -#define liblldb_ValueObjectDynamicValue_h_ +#ifndef LLDB_CORE_VALUEOBJECTDYNAMICVALUE_H +#define LLDB_CORE_VALUEOBJECTDYNAMICVALUE_H #include "lldb/Core/Address.h" #include "lldb/Core/ValueObject.h" #include "lldb/Symbol/CompilerType.h" #include "lldb/Symbol/Type.h" #include "lldb/Utility/ConstString.h" -#include "lldb/Utility/SharingPtr.h" #include "lldb/lldb-defines.h" #include "lldb/lldb-enumerations.h" #include "lldb/lldb-forward.h" @@ -128,9 +127,11 @@ private: ValueObjectDynamicValue(ValueObject &parent, lldb::DynamicValueType use_dynamic); - DISALLOW_COPY_AND_ASSIGN(ValueObjectDynamicValue); + ValueObjectDynamicValue(const ValueObjectDynamicValue &) = delete; + const ValueObjectDynamicValue & + operator=(const ValueObjectDynamicValue &) = delete; }; } // namespace lldb_private -#endif // liblldb_ValueObjectDynamicValue_h_ +#endif // LLDB_CORE_VALUEOBJECTDYNAMICVALUE_H diff --git a/lldb/include/lldb/Core/ValueObjectList.h b/lldb/include/lldb/Core/ValueObjectList.h index 42d19676d5d3..f99fba41aa26 100644 --- a/lldb/include/lldb/Core/ValueObjectList.h +++ b/lldb/include/lldb/Core/ValueObjectList.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef liblldb_ValueObjectList_h_ -#define liblldb_ValueObjectList_h_ +#ifndef LLDB_CORE_VALUEOBJECTLIST_H +#define LLDB_CORE_VALUEOBJECTLIST_H #include "lldb/lldb-forward.h" #include "lldb/lldb-types.h" @@ -59,4 +59,4 @@ protected: } // namespace lldb_private -#endif // liblldb_ValueObjectList_h_ +#endif // LLDB_CORE_VALUEOBJECTLIST_H diff --git a/lldb/include/lldb/Core/ValueObjectMemory.h b/lldb/include/lldb/Core/ValueObjectMemory.h index df3557f14989..d1cd6ae41445 100644 --- a/lldb/include/lldb/Core/ValueObjectMemory.h +++ b/lldb/include/lldb/Core/ValueObjectMemory.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef liblldb_ValueObjectMemory_h_ -#define liblldb_ValueObjectMemory_h_ +#ifndef LLDB_CORE_VALUEOBJECTMEMORY_H +#define LLDB_CORE_VALUEOBJECTMEMORY_H #include "lldb/Core/Address.h" #include "lldb/Core/ValueObject.h" @@ -64,15 +64,18 @@ protected: CompilerType m_compiler_type; private: - ValueObjectMemory(ExecutionContextScope *exe_scope, llvm::StringRef name, + ValueObjectMemory(ExecutionContextScope *exe_scope, + ValueObjectManager &manager, llvm::StringRef name, const Address &address, lldb::TypeSP &type_sp); - ValueObjectMemory(ExecutionContextScope *exe_scope, llvm::StringRef name, + ValueObjectMemory(ExecutionContextScope *exe_scope, + ValueObjectManager &manager, llvm::StringRef name, const Address &address, const CompilerType &ast_type); // For ValueObject only - DISALLOW_COPY_AND_ASSIGN(ValueObjectMemory); + ValueObjectMemory(const ValueObjectMemory &) = delete; + const ValueObjectMemory &operator=(const ValueObjectMemory &) = delete; }; } // namespace lldb_private -#endif // liblldb_ValueObjectMemory_h_ +#endif // LLDB_CORE_VALUEOBJECTMEMORY_H diff --git a/lldb/include/lldb/Core/ValueObjectRegister.h b/lldb/include/lldb/Core/ValueObjectRegister.h index e584be6e6057..41051d93b707 100644 --- a/lldb/include/lldb/Core/ValueObjectRegister.h +++ b/lldb/include/lldb/Core/ValueObjectRegister.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef liblldb_ValueObjectRegister_h_ -#define liblldb_ValueObjectRegister_h_ +#ifndef LLDB_CORE_VALUEOBJECTREGISTER_H +#define LLDB_CORE_VALUEOBJECTREGISTER_H #include "lldb/Core/ValueObject.h" #include "lldb/Symbol/CompilerType.h" @@ -28,43 +28,6 @@ class ExecutionContextScope; class Scalar; class Stream; -// A ValueObject that contains a root variable that may or may not -// have children. -class ValueObjectRegisterContext : public ValueObject { -public: - ~ValueObjectRegisterContext() override; - - uint64_t GetByteSize() override; - - lldb::ValueType GetValueType() const override { - return lldb::eValueTypeRegisterSet; - } - - ConstString GetTypeName() override; - - ConstString GetQualifiedTypeName() override; - - ConstString GetDisplayTypeName() override; - - size_t CalculateNumChildren(uint32_t max) override; - - ValueObject *CreateChildAtIndex(size_t idx, bool synthetic_array_member, - int32_t synthetic_index) override; - -protected: - bool UpdateValue() override; - - CompilerType GetCompilerTypeImpl() override; - - lldb::RegisterContextSP m_reg_ctx_sp; - -private: - ValueObjectRegisterContext(ValueObject &parent, - lldb::RegisterContextSP ®_ctx_sp); - // For ValueObject only - DISALLOW_COPY_AND_ASSIGN(ValueObjectRegisterContext); -}; - class ValueObjectRegisterSet : public ValueObject { public: ~ValueObjectRegisterSet() override; @@ -106,10 +69,13 @@ private: friend class ValueObjectRegisterContext; ValueObjectRegisterSet(ExecutionContextScope *exe_scope, + ValueObjectManager &manager, lldb::RegisterContextSP ®_ctx_sp, uint32_t set_idx); // For ValueObject only - DISALLOW_COPY_AND_ASSIGN(ValueObjectRegisterSet); + ValueObjectRegisterSet(const ValueObjectRegisterSet &) = delete; + const ValueObjectRegisterSet & + operator=(const ValueObjectRegisterSet &) = delete; }; class ValueObjectRegister : public ValueObject { @@ -137,7 +103,7 @@ public: bool ResolveValue(Scalar &scalar) override; void - GetExpressionPath(Stream &s, bool qualify_cxx_base_classes, + GetExpressionPath(Stream &s, GetExpressionPathFormat epformat = eGetExpressionPathFormatDereferencePointers) override; @@ -160,12 +126,14 @@ private: ValueObjectRegister(ValueObject &parent, lldb::RegisterContextSP ®_ctx_sp, uint32_t reg_num); ValueObjectRegister(ExecutionContextScope *exe_scope, + ValueObjectManager &manager, lldb::RegisterContextSP ®_ctx_sp, uint32_t reg_num); // For ValueObject only - DISALLOW_COPY_AND_ASSIGN(ValueObjectRegister); + ValueObjectRegister(const ValueObjectRegister &) = delete; + const ValueObjectRegister &operator=(const ValueObjectRegister &) = delete; }; } // namespace lldb_private -#endif // liblldb_ValueObjectRegister_h_ +#endif // LLDB_CORE_VALUEOBJECTREGISTER_H diff --git a/lldb/include/lldb/Core/ValueObjectSyntheticFilter.h b/lldb/include/lldb/Core/ValueObjectSyntheticFilter.h index ec395095351d..cb471657aec9 100644 --- a/lldb/include/lldb/Core/ValueObjectSyntheticFilter.h +++ b/lldb/include/lldb/Core/ValueObjectSyntheticFilter.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef liblldb_ValueObjectSyntheticFilter_h_ -#define liblldb_ValueObjectSyntheticFilter_h_ +#ifndef LLDB_CORE_VALUEOBJECTSYNTHETICFILTER_H +#define LLDB_CORE_VALUEOBJECTSYNTHETICFILTER_H #include "lldb/Core/ValueObject.h" #include "lldb/Symbol/CompilerType.h" @@ -66,7 +66,7 @@ public: bool IsSynthetic() override { return true; } - void CalculateSyntheticValue(bool use_synthetic) override {} + void CalculateSyntheticValue() override {} bool IsDynamic() override { return ((m_parent != nullptr) ? m_parent->IsDynamic() : false); @@ -164,9 +164,10 @@ private: void CopyValueData(ValueObject *source); - DISALLOW_COPY_AND_ASSIGN(ValueObjectSynthetic); + ValueObjectSynthetic(const ValueObjectSynthetic &) = delete; + const ValueObjectSynthetic &operator=(const ValueObjectSynthetic &) = delete; }; } // namespace lldb_private -#endif // liblldb_ValueObjectSyntheticFilter_h_ +#endif // LLDB_CORE_VALUEOBJECTSYNTHETICFILTER_H diff --git a/lldb/include/lldb/Core/ValueObjectVariable.h b/lldb/include/lldb/Core/ValueObjectVariable.h index 86bb8ef90070..b7e262574a14 100644 --- a/lldb/include/lldb/Core/ValueObjectVariable.h +++ b/lldb/include/lldb/Core/ValueObjectVariable.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef liblldb_ValueObjectVariable_h_ -#define liblldb_ValueObjectVariable_h_ +#ifndef LLDB_CORE_VALUEOBJECTVARIABLE_H +#define LLDB_CORE_VALUEOBJECTVARIABLE_H #include "lldb/Core/ValueObject.h" @@ -67,6 +67,8 @@ public: protected: bool UpdateValue() override; + + void DoUpdateChildrenAddressType(ValueObject &valobj) override; CompilerType GetCompilerTypeImpl() override; @@ -77,11 +79,13 @@ protected: private: ValueObjectVariable(ExecutionContextScope *exe_scope, + ValueObjectManager &manager, const lldb::VariableSP &var_sp); // For ValueObject only - DISALLOW_COPY_AND_ASSIGN(ValueObjectVariable); + ValueObjectVariable(const ValueObjectVariable &) = delete; + const ValueObjectVariable &operator=(const ValueObjectVariable &) = delete; }; } // namespace lldb_private -#endif // liblldb_ValueObjectVariable_h_ +#endif // LLDB_CORE_VALUEOBJECTVARIABLE_H diff --git a/lldb/include/lldb/Core/dwarf.h b/lldb/include/lldb/Core/dwarf.h index 832109e55c70..cd9cf249bc63 100644 --- a/lldb/include/lldb/Core/dwarf.h +++ b/lldb/include/lldb/Core/dwarf.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef DebugBase_dwarf_h_ -#define DebugBase_dwarf_h_ +#ifndef LLDB_CORE_DWARF_H +#define LLDB_CORE_DWARF_H #include "lldb/Utility/RangeMap.h" #include <stdint.h> @@ -71,6 +71,6 @@ typedef uint32_t dw_offset_t; // Dwarf Debug Information Entry offset for any //#define DW_OP_APPLE_error 0xFF // Stops expression evaluation and //returns an error (no args) -typedef lldb_private::RangeArray<dw_addr_t, dw_addr_t, 2> DWARFRangeList; +typedef lldb_private::RangeVector<dw_addr_t, dw_addr_t, 2> DWARFRangeList; -#endif // DebugBase_dwarf_h_ +#endif // LLDB_CORE_DWARF_H diff --git a/lldb/include/lldb/DataFormatters/CXXFunctionPointer.h b/lldb/include/lldb/DataFormatters/CXXFunctionPointer.h index b5417895f7bf..e9742bc31d8c 100644 --- a/lldb/include/lldb/DataFormatters/CXXFunctionPointer.h +++ b/lldb/include/lldb/DataFormatters/CXXFunctionPointer.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef liblldb_CXXFunctionPointer_h_ -#define liblldb_CXXFunctionPointer_h_ +#ifndef LLDB_DATAFORMATTERS_CXXFUNCTIONPOINTER_H +#define LLDB_DATAFORMATTERS_CXXFUNCTIONPOINTER_H #include "lldb/lldb-forward.h" @@ -18,4 +18,4 @@ bool CXXFunctionPointerSummaryProvider(ValueObject &valobj, Stream &stream, } // namespace formatters } // namespace lldb_private -#endif // liblldb_CXXFunctionPointer_h_ +#endif // LLDB_DATAFORMATTERS_CXXFUNCTIONPOINTER_H diff --git a/lldb/include/lldb/DataFormatters/DataVisualization.h b/lldb/include/lldb/DataFormatters/DataVisualization.h index f5c3487bcb3b..b053aa074d9e 100644 --- a/lldb/include/lldb/DataFormatters/DataVisualization.h +++ b/lldb/include/lldb/DataFormatters/DataVisualization.h @@ -6,9 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef lldb_DataVisualization_h_ -#define lldb_DataVisualization_h_ - +#ifndef LLDB_DATAFORMATTERS_DATAVISUALIZATION_H +#define LLDB_DATAFORMATTERS_DATAVISUALIZATION_H #include "lldb/DataFormatters/FormatClasses.h" #include "lldb/DataFormatters/FormatManager.h" @@ -122,4 +121,4 @@ public: } // namespace lldb_private -#endif // lldb_DataVisualization_h_ +#endif // LLDB_DATAFORMATTERS_DATAVISUALIZATION_H diff --git a/lldb/include/lldb/DataFormatters/DumpValueObjectOptions.h b/lldb/include/lldb/DataFormatters/DumpValueObjectOptions.h index c37411539de6..2f3bdf80a6f1 100644 --- a/lldb/include/lldb/DataFormatters/DumpValueObjectOptions.h +++ b/lldb/include/lldb/DataFormatters/DumpValueObjectOptions.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef lldb_DumpValueObjectOptions_h_ -#define lldb_DumpValueObjectOptions_h_ +#ifndef LLDB_DATAFORMATTERS_DUMPVALUEOBJECTOPTIONS_H +#define LLDB_DATAFORMATTERS_DUMPVALUEOBJECTOPTIONS_H #include <string> @@ -127,7 +127,6 @@ public: DumpValueObjectOptions & SetPointerAsArray(const PointerAsArraySettings &ptr_array); -public: uint32_t m_max_depth = UINT32_MAX; lldb::DynamicValueType m_use_dynamic = lldb::eNoDynamicValues; uint32_t m_omit_summary_depth = 0; @@ -157,4 +156,4 @@ public: } // namespace lldb_private -#endif // lldb_DumpValueObjectOptions_h_ +#endif // LLDB_DATAFORMATTERS_DUMPVALUEOBJECTOPTIONS_H diff --git a/lldb/include/lldb/DataFormatters/FormatCache.h b/lldb/include/lldb/DataFormatters/FormatCache.h index f9dbe414640d..e75aaee1a7bb 100644 --- a/lldb/include/lldb/DataFormatters/FormatCache.h +++ b/lldb/include/lldb/DataFormatters/FormatCache.h @@ -7,8 +7,8 @@ // //===----------------------------------------------------------------------===// -#ifndef lldb_FormatCache_h_ -#define lldb_FormatCache_h_ +#ifndef LLDB_DATAFORMATTERS_FORMATCACHE_H +#define LLDB_DATAFORMATTERS_FORMATCACHE_H #include <map> #include <mutex> @@ -49,13 +49,13 @@ private: CacheMap m_map; std::recursive_mutex m_mutex; - uint64_t m_cache_hits; - uint64_t m_cache_misses; + uint64_t m_cache_hits = 0; + uint64_t m_cache_misses = 0; Entry &GetEntry(ConstString type); public: - FormatCache(); + FormatCache() = default; template <typename ImplSP> bool Get(ConstString type, ImplSP &format_impl_sp); void Set(ConstString type, lldb::TypeFormatImplSP &format_sp); @@ -71,4 +71,4 @@ public: } // namespace lldb_private -#endif // lldb_FormatCache_h_ +#endif // LLDB_DATAFORMATTERS_FORMATCACHE_H diff --git a/lldb/include/lldb/DataFormatters/FormatClasses.h b/lldb/include/lldb/DataFormatters/FormatClasses.h index 91ce444244cc..e3989133a602 100644 --- a/lldb/include/lldb/DataFormatters/FormatClasses.h +++ b/lldb/include/lldb/DataFormatters/FormatClasses.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef lldb_FormatClasses_h_ -#define lldb_FormatClasses_h_ +#ifndef LLDB_DATAFORMATTERS_FORMATCLASSES_H +#define LLDB_DATAFORMATTERS_FORMATCLASSES_H #include <functional> #include <memory> @@ -43,17 +43,15 @@ public: class FormattersMatchCandidate { public: - FormattersMatchCandidate(ConstString name, uint32_t reason, bool strip_ptr, + FormattersMatchCandidate(ConstString name, bool strip_ptr, bool strip_ref, bool strip_tydef) - : m_type_name(name), m_reason(reason), m_stripped_pointer(strip_ptr), + : m_type_name(name), m_stripped_pointer(strip_ptr), m_stripped_reference(strip_ref), m_stripped_typedef(strip_tydef) {} ~FormattersMatchCandidate() = default; ConstString GetTypeName() const { return m_type_name; } - uint32_t GetReason() const { return m_reason; } - bool DidStripPointer() const { return m_stripped_pointer; } bool DidStripReference() const { return m_stripped_reference; } @@ -75,7 +73,6 @@ public: private: ConstString m_type_name; - uint32_t m_reason; bool m_stripped_pointer; bool m_stripped_reference; bool m_stripped_typedef; @@ -112,21 +109,21 @@ public: TypeNameSpecifierImpl(llvm::StringRef name, bool is_regex) : m_is_regex(is_regex), m_type() { - m_type.m_type_name = name; + m_type.m_type_name = std::string(name); } // if constructing with a given type, is_regex cannot be true since we are // giving an exact type to match TypeNameSpecifierImpl(lldb::TypeSP type) : m_is_regex(false), m_type() { if (type) { - m_type.m_type_name = type->GetName().GetStringRef(); + m_type.m_type_name = std::string(type->GetName().GetStringRef()); 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_name.assign(type.GetTypeName().GetCString()); m_type.m_compiler_type = type; } } @@ -154,10 +151,11 @@ private: }; TypeOrName m_type; -private: - DISALLOW_COPY_AND_ASSIGN(TypeNameSpecifierImpl); + TypeNameSpecifierImpl(const TypeNameSpecifierImpl &) = delete; + const TypeNameSpecifierImpl & + operator=(const TypeNameSpecifierImpl &) = delete; }; } // namespace lldb_private -#endif // lldb_FormatClasses_h_ +#endif // LLDB_DATAFORMATTERS_FORMATCLASSES_H diff --git a/lldb/include/lldb/DataFormatters/FormatManager.h b/lldb/include/lldb/DataFormatters/FormatManager.h index dd522c487c8f..56a0303f9b02 100644 --- a/lldb/include/lldb/DataFormatters/FormatManager.h +++ b/lldb/include/lldb/DataFormatters/FormatManager.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef lldb_FormatManager_h_ -#define lldb_FormatManager_h_ +#ifndef LLDB_DATAFORMATTERS_FORMATMANAGER_H +#define LLDB_DATAFORMATTERS_FORMATMANAGER_H #include <atomic> #include <initializer_list> @@ -170,7 +170,6 @@ public: GetPossibleMatches(ValueObject &valobj, lldb::DynamicValueType use_dynamic) { FormattersMatchVector matches; GetPossibleMatches(valobj, valobj.GetCompilerType(), - lldb_private::eFormatterChoiceCriterionDirectChoice, use_dynamic, matches, false, false, false, true); return matches; } @@ -184,7 +183,7 @@ public: private: static void GetPossibleMatches(ValueObject &valobj, - CompilerType compiler_type, uint32_t reason, + CompilerType compiler_type, lldb::DynamicValueType use_dynamic, FormattersMatchVector &entries, bool did_strip_ptr, bool did_strip_ref, @@ -224,4 +223,4 @@ private: } // namespace lldb_private -#endif // lldb_FormatManager_h_ +#endif // LLDB_DATAFORMATTERS_FORMATMANAGER_H diff --git a/lldb/include/lldb/DataFormatters/FormattersContainer.h b/lldb/include/lldb/DataFormatters/FormattersContainer.h index 86023dd9bf0b..d414882bae19 100644 --- a/lldb/include/lldb/DataFormatters/FormattersContainer.h +++ b/lldb/include/lldb/DataFormatters/FormattersContainer.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef lldb_FormattersContainer_h_ -#define lldb_FormattersContainer_h_ +#ifndef LLDB_DATAFORMATTERS_FORMATTERSCONTAINER_H +#define LLDB_DATAFORMATTERS_FORMATTERSCONTAINER_H #include <functional> #include <map> @@ -181,16 +181,13 @@ public: } bool Get(ValueObject &valobj, MapValueType &entry, - lldb::DynamicValueType use_dynamic, uint32_t *why = nullptr) { - uint32_t value = lldb_private::eFormatterChoiceCriterionDirectChoice; + lldb::DynamicValueType use_dynamic) { CompilerType ast_type(valobj.GetCompilerType()); - bool ret = Get(valobj, ast_type, entry, use_dynamic, value); + bool ret = Get(valobj, ast_type, entry, use_dynamic); if (ret) entry = MapValueType(entry); else entry = MapValueType(); - if (why) - *why = value; return ret; } @@ -221,7 +218,8 @@ protected: BackEndType m_format_map; std::string m_name; - DISALLOW_COPY_AND_ASSIGN(FormattersContainer); + FormattersContainer(const FormattersContainer &) = delete; + const FormattersContainer &operator=(const FormattersContainer &) = delete; void Add_Impl(MapKeyType type, const MapValueType &entry, RegularExpression *dummy) { @@ -266,7 +264,7 @@ protected: ConstString key = m_format_map.GetKeyAtIndex(index); if (key) return lldb::TypeNameSpecifierImplSP( - new TypeNameSpecifierImpl(key.AsCString(), false)); + new TypeNameSpecifierImpl(key.GetStringRef(), false)); else return lldb::TypeNameSpecifierImplSP(); } @@ -308,16 +306,13 @@ protected: return false; } - bool Get(const FormattersMatchVector &candidates, MapValueType &entry, - uint32_t *reason) { + bool Get(const FormattersMatchVector &candidates, MapValueType &entry) { for (const FormattersMatchCandidate &candidate : candidates) { if (Get(candidate.GetTypeName(), entry)) { if (candidate.IsMatch(entry) == false) { entry.reset(); continue; } else { - if (reason) - *reason = candidate.GetReason(); return true; } } @@ -328,4 +323,4 @@ protected: } // namespace lldb_private -#endif // lldb_FormattersContainer_h_ +#endif // LLDB_DATAFORMATTERS_FORMATTERSCONTAINER_H diff --git a/lldb/include/lldb/DataFormatters/FormattersHelpers.h b/lldb/include/lldb/DataFormatters/FormattersHelpers.h index 79bd376c76eb..a5b0da57e5d8 100644 --- a/lldb/include/lldb/DataFormatters/FormattersHelpers.h +++ b/lldb/include/lldb/DataFormatters/FormattersHelpers.h @@ -7,8 +7,8 @@ // //===----------------------------------------------------------------------===// -#ifndef lldb_FormattersHelpers_h_ -#define lldb_FormattersHelpers_h_ +#ifndef LLDB_DATAFORMATTERS_FORMATTERSHELPERS_H +#define LLDB_DATAFORMATTERS_FORMATTERSHELPERS_H #include "lldb/lldb-enumerations.h" #include "lldb/lldb-forward.h" @@ -56,6 +56,8 @@ size_t ExtractIndexFromString(const char *item_name); lldb::addr_t GetArrayAddressOrPointerValue(ValueObject &valobj); +lldb::ValueObjectSP GetValueOfLibCXXCompressedPair(ValueObject &pair); + time_t GetOSXEpoch(); struct InferiorSizedWord { @@ -184,4 +186,4 @@ private: } // namespace formatters } // namespace lldb_private -#endif // lldb_FormattersHelpers_h_ +#endif // LLDB_DATAFORMATTERS_FORMATTERSHELPERS_H diff --git a/lldb/include/lldb/DataFormatters/LanguageCategory.h b/lldb/include/lldb/DataFormatters/LanguageCategory.h index 1cffff91c197..d7676730fbd6 100644 --- a/lldb/include/lldb/DataFormatters/LanguageCategory.h +++ b/lldb/include/lldb/DataFormatters/LanguageCategory.h @@ -7,9 +7,8 @@ // //===----------------------------------------------------------------------===// -#ifndef lldb_LanguageCategory_h_ -#define lldb_LanguageCategory_h_ - +#ifndef LLDB_DATAFORMATTERS_LANGUAGECATEGORY_H +#define LLDB_DATAFORMATTERS_LANGUAGECATEGORY_H #include "lldb/DataFormatters/FormatCache.h" #include "lldb/DataFormatters/FormatClasses.h" @@ -58,4 +57,4 @@ private: } // namespace lldb_private -#endif // lldb_LanguageCategory_h_ +#endif // LLDB_DATAFORMATTERS_LANGUAGECATEGORY_H diff --git a/lldb/include/lldb/DataFormatters/StringPrinter.h b/lldb/include/lldb/DataFormatters/StringPrinter.h index 43b92019e6fd..17c645f8637a 100644 --- a/lldb/include/lldb/DataFormatters/StringPrinter.h +++ b/lldb/include/lldb/DataFormatters/StringPrinter.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef liblldb_StringPrinter_h_ -#define liblldb_StringPrinter_h_ +#ifndef LLDB_DATAFORMATTERS_STRINGPRINTER_H +#define LLDB_DATAFORMATTERS_STRINGPRINTER_H #include <functional> #include <string> @@ -24,6 +24,8 @@ public: enum class GetPrintableElementType { ASCII, UTF8 }; + enum class EscapeStyle { CXX, Swift }; + class DumpToStreamOptions { public: DumpToStreamOptions() = default; @@ -68,9 +70,9 @@ public: bool GetIgnoreMaxLength() const { return m_ignore_max_length; } - void SetLanguage(lldb::LanguageType l) { m_language_type = l; } + void SetEscapeStyle(EscapeStyle style) { m_escape_style = style; } - lldb::LanguageType GetLanguage() const { return m_language_type; } + EscapeStyle GetEscapeStyle() const { return m_escape_style; } private: /// The used output stream. @@ -93,12 +95,8 @@ public: /// True iff a zero bytes ('\0') should terminate the memory region that /// is being dumped. bool m_zero_is_terminator = true; - /// The language that the generated string literal is supposed to be valid - /// for. This changes for example what and how certain characters are - /// escaped. - /// For example, printing the a string containing only a quote (") char - /// with eLanguageTypeC would escape the quote character. - lldb::LanguageType m_language_type = lldb::eLanguageTypeUnknown; + /// The language-specific style for escaping special characters. + EscapeStyle m_escape_style = EscapeStyle::CXX; }; class ReadStringAndDumpToStreamOptions : public DumpToStreamOptions { @@ -115,9 +113,15 @@ public: lldb::ProcessSP GetProcessSP() const { return m_process_sp; } + void SetHasSourceSize(bool e) { m_has_source_size = e; } + + bool HasSourceSize() const { return m_has_source_size; } + private: uint64_t m_location = 0; lldb::ProcessSP m_process_sp; + /// True iff we know the source size of the string. + bool m_has_source_size = false; }; class ReadBufferAndDumpToStreamOptions : public DumpToStreamOptions { @@ -141,75 +145,6 @@ public: bool m_is_truncated = false; }; - // I can't use a std::unique_ptr for this because the Deleter is a template - // argument there - // and I want the same type to represent both pointers I want to free and - // pointers I don't need to free - which is what this class essentially is - // It's very specialized to the needs of this file, and not suggested for - // general use - template <typename T = uint8_t, typename U = char, typename S = size_t> - struct StringPrinterBufferPointer { - public: - typedef std::function<void(const T *)> Deleter; - - StringPrinterBufferPointer(std::nullptr_t ptr) - : m_data(nullptr), m_size(0), m_deleter() {} - - StringPrinterBufferPointer(const T *bytes, S size, - Deleter deleter = nullptr) - : m_data(bytes), m_size(size), m_deleter(deleter) {} - - StringPrinterBufferPointer(const U *bytes, S size, - Deleter deleter = nullptr) - : m_data(reinterpret_cast<const T *>(bytes)), m_size(size), - m_deleter(deleter) {} - - StringPrinterBufferPointer(StringPrinterBufferPointer &&rhs) - : m_data(rhs.m_data), m_size(rhs.m_size), m_deleter(rhs.m_deleter) { - rhs.m_data = nullptr; - } - - StringPrinterBufferPointer(const StringPrinterBufferPointer &rhs) - : m_data(rhs.m_data), m_size(rhs.m_size), m_deleter(rhs.m_deleter) { - rhs.m_data = nullptr; // this is why m_data has to be mutable - } - - ~StringPrinterBufferPointer() { - if (m_data && m_deleter) - m_deleter(m_data); - m_data = nullptr; - } - - const T *GetBytes() const { return m_data; } - - const S GetSize() const { return m_size; } - - StringPrinterBufferPointer & - operator=(const StringPrinterBufferPointer &rhs) { - if (m_data && m_deleter) - m_deleter(m_data); - m_data = rhs.m_data; - m_size = rhs.m_size; - m_deleter = rhs.m_deleter; - rhs.m_data = nullptr; - return *this; - } - - private: - mutable const T *m_data; - size_t m_size; - Deleter m_deleter; - }; - - typedef std::function<StringPrinter::StringPrinterBufferPointer< - uint8_t, char, size_t>(uint8_t *, uint8_t *, uint8_t *&)> - EscapingHelper; - typedef std::function<EscapingHelper(GetPrintableElementType)> - EscapingHelperGenerator; - - static EscapingHelper - GetDefaultEscapingHelper(GetPrintableElementType elem_type); - template <StringElementType element_type> static bool ReadStringAndDumpToStream(const ReadStringAndDumpToStreamOptions &options); @@ -222,4 +157,4 @@ public: } // namespace formatters } // namespace lldb_private -#endif // liblldb_StringPrinter_h_ +#endif // LLDB_DATAFORMATTERS_STRINGPRINTER_H diff --git a/lldb/include/lldb/DataFormatters/TypeCategory.h b/lldb/include/lldb/DataFormatters/TypeCategory.h index d5aab6dc3a52..820872a59bda 100644 --- a/lldb/include/lldb/DataFormatters/TypeCategory.h +++ b/lldb/include/lldb/DataFormatters/TypeCategory.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef lldb_TypeCategory_h_ -#define lldb_TypeCategory_h_ +#ifndef LLDB_DATAFORMATTERS_TYPECATEGORY_H +#define LLDB_DATAFORMATTERS_TYPECATEGORY_H #include <initializer_list> #include <memory> @@ -285,13 +285,13 @@ public: } bool Get(lldb::LanguageType lang, const FormattersMatchVector &candidates, - lldb::TypeFormatImplSP &entry, uint32_t *reason = nullptr); + lldb::TypeFormatImplSP &entry); bool Get(lldb::LanguageType lang, const FormattersMatchVector &candidates, - lldb::TypeSummaryImplSP &entry, uint32_t *reason = nullptr); + lldb::TypeSummaryImplSP &entry); bool Get(lldb::LanguageType lang, const FormattersMatchVector &candidates, - lldb::SyntheticChildrenSP &entry, uint32_t *reason = nullptr); + lldb::SyntheticChildrenSP &entry); void Clear(FormatCategoryItems items = ALL_ITEM_TYPES); @@ -366,4 +366,4 @@ private: } // namespace lldb_private -#endif // lldb_TypeCategory_h_ +#endif // LLDB_DATAFORMATTERS_TYPECATEGORY_H diff --git a/lldb/include/lldb/DataFormatters/TypeCategoryMap.h b/lldb/include/lldb/DataFormatters/TypeCategoryMap.h index ae577a334014..832652f7d745 100644 --- a/lldb/include/lldb/DataFormatters/TypeCategoryMap.h +++ b/lldb/include/lldb/DataFormatters/TypeCategoryMap.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef lldb_TypeCategoryMap_h_ -#define lldb_TypeCategoryMap_h_ +#ifndef LLDB_DATAFORMATTERS_TYPECATEGORYMAP_H +#define LLDB_DATAFORMATTERS_TYPECATEGORYMAP_H #include <functional> #include <list> @@ -108,4 +108,4 @@ private: }; } // namespace lldb_private -#endif // lldb_TypeCategoryMap_h_ +#endif // LLDB_DATAFORMATTERS_TYPECATEGORYMAP_H diff --git a/lldb/include/lldb/DataFormatters/TypeFormat.h b/lldb/include/lldb/DataFormatters/TypeFormat.h index 77e8c0efc706..b8ed6a3443b3 100644 --- a/lldb/include/lldb/DataFormatters/TypeFormat.h +++ b/lldb/include/lldb/DataFormatters/TypeFormat.h @@ -7,9 +7,8 @@ // //===----------------------------------------------------------------------===// -#ifndef lldb_TypeFormat_h_ -#define lldb_TypeFormat_h_ - +#ifndef LLDB_DATAFORMATTERS_TYPEFORMAT_H +#define LLDB_DATAFORMATTERS_TYPEFORMAT_H #include <functional> #include <string> @@ -153,7 +152,8 @@ protected: uint32_t m_my_revision; private: - DISALLOW_COPY_AND_ASSIGN(TypeFormatImpl); + TypeFormatImpl(const TypeFormatImpl &) = delete; + const TypeFormatImpl &operator=(const TypeFormatImpl &) = delete; }; class TypeFormatImpl_Format : public TypeFormatImpl { @@ -181,7 +181,9 @@ protected: lldb::Format m_format; private: - DISALLOW_COPY_AND_ASSIGN(TypeFormatImpl_Format); + TypeFormatImpl_Format(const TypeFormatImpl_Format &) = delete; + const TypeFormatImpl_Format & + operator=(const TypeFormatImpl_Format &) = delete; }; class TypeFormatImpl_EnumType : public TypeFormatImpl { @@ -210,8 +212,10 @@ protected: mutable std::unordered_map<void *, CompilerType> m_types; private: - DISALLOW_COPY_AND_ASSIGN(TypeFormatImpl_EnumType); + TypeFormatImpl_EnumType(const TypeFormatImpl_EnumType &) = delete; + const TypeFormatImpl_EnumType & + operator=(const TypeFormatImpl_EnumType &) = delete; }; } // namespace lldb_private -#endif // lldb_TypeFormat_h_ +#endif // LLDB_DATAFORMATTERS_TYPEFORMAT_H diff --git a/lldb/include/lldb/DataFormatters/TypeSummary.h b/lldb/include/lldb/DataFormatters/TypeSummary.h index 9c97b3606f25..6c3780f7276d 100644 --- a/lldb/include/lldb/DataFormatters/TypeSummary.h +++ b/lldb/include/lldb/DataFormatters/TypeSummary.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef lldb_TypeSummary_h_ -#define lldb_TypeSummary_h_ +#ifndef LLDB_DATAFORMATTERS_TYPESUMMARY_H +#define LLDB_DATAFORMATTERS_TYPESUMMARY_H #include <stdint.h> @@ -270,7 +270,8 @@ protected: private: Kind m_kind; - DISALLOW_COPY_AND_ASSIGN(TypeSummaryImpl); + TypeSummaryImpl(const TypeSummaryImpl &) = delete; + const TypeSummaryImpl &operator=(const TypeSummaryImpl &) = delete; }; // simple string-based summaries, using ${var to show data @@ -297,7 +298,8 @@ struct StringSummaryFormat : public TypeSummaryImpl { } private: - DISALLOW_COPY_AND_ASSIGN(StringSummaryFormat); + StringSummaryFormat(const StringSummaryFormat &) = delete; + const StringSummaryFormat &operator=(const StringSummaryFormat &) = delete; }; // summaries implemented via a C++ function @@ -341,7 +343,9 @@ struct CXXFunctionSummaryFormat : public TypeSummaryImpl { typedef std::shared_ptr<CXXFunctionSummaryFormat> SharedPointer; private: - DISALLOW_COPY_AND_ASSIGN(CXXFunctionSummaryFormat); + CXXFunctionSummaryFormat(const CXXFunctionSummaryFormat &) = delete; + const CXXFunctionSummaryFormat & + operator=(const CXXFunctionSummaryFormat &) = delete; }; // Python-based summaries, running script code to show data @@ -387,8 +391,9 @@ struct ScriptSummaryFormat : public TypeSummaryImpl { typedef std::shared_ptr<ScriptSummaryFormat> SharedPointer; private: - DISALLOW_COPY_AND_ASSIGN(ScriptSummaryFormat); + ScriptSummaryFormat(const ScriptSummaryFormat &) = delete; + const ScriptSummaryFormat &operator=(const ScriptSummaryFormat &) = delete; }; } // namespace lldb_private -#endif // lldb_TypeSummary_h_ +#endif // LLDB_DATAFORMATTERS_TYPESUMMARY_H diff --git a/lldb/include/lldb/DataFormatters/TypeSynthetic.h b/lldb/include/lldb/DataFormatters/TypeSynthetic.h index 93443cf7e84b..c852ff18bfa2 100644 --- a/lldb/include/lldb/DataFormatters/TypeSynthetic.h +++ b/lldb/include/lldb/DataFormatters/TypeSynthetic.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef lldb_TypeSynthetic_h_ -#define lldb_TypeSynthetic_h_ +#ifndef LLDB_DATAFORMATTERS_TYPESYNTHETIC_H +#define LLDB_DATAFORMATTERS_TYPESYNTHETIC_H #include <stdint.h> @@ -96,7 +96,9 @@ protected: private: bool m_valid; - DISALLOW_COPY_AND_ASSIGN(SyntheticChildrenFrontEnd); + SyntheticChildrenFrontEnd(const SyntheticChildrenFrontEnd &) = delete; + const SyntheticChildrenFrontEnd & + operator=(const SyntheticChildrenFrontEnd &) = delete; }; class SyntheticValueProviderFrontEnd : public SyntheticChildrenFrontEnd { @@ -121,7 +123,10 @@ public: lldb::ValueObjectSP GetSyntheticValue() override = 0; private: - DISALLOW_COPY_AND_ASSIGN(SyntheticValueProviderFrontEnd); + SyntheticValueProviderFrontEnd(const SyntheticValueProviderFrontEnd &) = + delete; + const SyntheticValueProviderFrontEnd & + operator=(const SyntheticValueProviderFrontEnd &) = delete; }; class SyntheticChildren { @@ -265,7 +270,8 @@ protected: Flags m_flags; private: - DISALLOW_COPY_AND_ASSIGN(SyntheticChildren); + SyntheticChildren(const SyntheticChildren &) = delete; + const SyntheticChildren &operator=(const SyntheticChildren &) = delete; }; class TypeFilterImpl : public SyntheticChildren { @@ -333,7 +339,8 @@ public: private: TypeFilterImpl *filter; - DISALLOW_COPY_AND_ASSIGN(FrontEnd); + FrontEnd(const FrontEnd &) = delete; + const FrontEnd &operator=(const FrontEnd &) = delete; }; SyntheticChildrenFrontEnd::AutoPointer @@ -344,7 +351,8 @@ public: typedef std::shared_ptr<TypeFilterImpl> SharedPointer; private: - DISALLOW_COPY_AND_ASSIGN(TypeFilterImpl); + TypeFilterImpl(const TypeFilterImpl &) = delete; + const TypeFilterImpl &operator=(const TypeFilterImpl &) = delete; }; class CXXSyntheticChildren : public SyntheticChildren { @@ -372,7 +380,8 @@ protected: std::string m_description; private: - DISALLOW_COPY_AND_ASSIGN(CXXSyntheticChildren); + CXXSyntheticChildren(const CXXSyntheticChildren &) = delete; + const CXXSyntheticChildren &operator=(const CXXSyntheticChildren &) = delete; }; class ScriptedSyntheticChildren : public SyntheticChildren { @@ -435,7 +444,8 @@ public: StructuredData::ObjectSP m_wrapper_sp; ScriptInterpreter *m_interpreter; - DISALLOW_COPY_AND_ASSIGN(FrontEnd); + FrontEnd(const FrontEnd &) = delete; + const FrontEnd &operator=(const FrontEnd &) = delete; }; SyntheticChildrenFrontEnd::AutoPointer @@ -448,8 +458,10 @@ public: } private: - DISALLOW_COPY_AND_ASSIGN(ScriptedSyntheticChildren); + ScriptedSyntheticChildren(const ScriptedSyntheticChildren &) = delete; + const ScriptedSyntheticChildren & + operator=(const ScriptedSyntheticChildren &) = delete; }; } // namespace lldb_private -#endif // lldb_TypeSynthetic_h_ +#endif // LLDB_DATAFORMATTERS_TYPESYNTHETIC_H diff --git a/lldb/include/lldb/DataFormatters/ValueObjectPrinter.h b/lldb/include/lldb/DataFormatters/ValueObjectPrinter.h index 33813b38701c..f1301d8595b1 100644 --- a/lldb/include/lldb/DataFormatters/ValueObjectPrinter.h +++ b/lldb/include/lldb/DataFormatters/ValueObjectPrinter.h @@ -7,9 +7,8 @@ // //===----------------------------------------------------------------------===// -#ifndef lldb_ValueObjectPrinter_h_ -#define lldb_ValueObjectPrinter_h_ - +#ifndef LLDB_DATAFORMATTERS_VALUEOBJECTPRINTER_H +#define LLDB_DATAFORMATTERS_VALUEOBJECTPRINTER_H #include "lldb/lldb-private.h" #include "lldb/lldb-public.h" @@ -58,7 +57,7 @@ protected: const char *GetDescriptionForDisplay(); - const char *GetRootNameForDisplay(const char *if_fail = nullptr); + const char *GetRootNameForDisplay(); bool ShouldPrintValueObject(); @@ -142,9 +141,10 @@ private: friend struct StringSummaryFormat; - DISALLOW_COPY_AND_ASSIGN(ValueObjectPrinter); + ValueObjectPrinter(const ValueObjectPrinter &) = delete; + const ValueObjectPrinter &operator=(const ValueObjectPrinter &) = delete; }; } // namespace lldb_private -#endif // lldb_ValueObjectPrinter_h_ +#endif // LLDB_DATAFORMATTERS_VALUEOBJECTPRINTER_H diff --git a/lldb/include/lldb/DataFormatters/VectorIterator.h b/lldb/include/lldb/DataFormatters/VectorIterator.h index cde4be498b0f..33650a3dac8f 100644 --- a/lldb/include/lldb/DataFormatters/VectorIterator.h +++ b/lldb/include/lldb/DataFormatters/VectorIterator.h @@ -7,8 +7,8 @@ // //===----------------------------------------------------------------------===// -#ifndef liblldb_VectorIterator_h_ -#define liblldb_VectorIterator_h_ +#ifndef LLDB_DATAFORMATTERS_VECTORITERATOR_H +#define LLDB_DATAFORMATTERS_VECTORITERATOR_H #include "lldb/lldb-forward.h" @@ -42,4 +42,4 @@ private: } // namespace formatters } // namespace lldb_private -#endif // liblldb_CF_h_ +#endif // LLDB_DATAFORMATTERS_VECTORITERATOR_H diff --git a/lldb/include/lldb/DataFormatters/VectorType.h b/lldb/include/lldb/DataFormatters/VectorType.h index b757f758e77f..6a66b1815c29 100644 --- a/lldb/include/lldb/DataFormatters/VectorType.h +++ b/lldb/include/lldb/DataFormatters/VectorType.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef liblldb_VectorType_h_ -#define liblldb_VectorType_h_ +#ifndef LLDB_DATAFORMATTERS_VECTORTYPE_H +#define LLDB_DATAFORMATTERS_VECTORTYPE_H #include "lldb/lldb-forward.h" @@ -21,4 +21,4 @@ VectorTypeSyntheticFrontEndCreator(CXXSyntheticChildren *, lldb::ValueObjectSP); } // namespace formatters } // namespace lldb_private -#endif // liblldb_VectorType_h_ +#endif // LLDB_DATAFORMATTERS_VECTORTYPE_H diff --git a/lldb/include/lldb/Expression/DWARFExpression.h b/lldb/include/lldb/Expression/DWARFExpression.h index bfae142d5e01..6b63b186e3e4 100644 --- a/lldb/include/lldb/Expression/DWARFExpression.h +++ b/lldb/include/lldb/Expression/DWARFExpression.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef liblldb_DWARFExpression_h_ -#define liblldb_DWARFExpression_h_ +#ifndef LLDB_EXPRESSION_DWARFEXPRESSION_H +#define LLDB_EXPRESSION_DWARFEXPRESSION_H #include "lldb/Core/Address.h" #include "lldb/Core/Disassembler.h" @@ -217,14 +217,6 @@ public: lldb::addr_t func_load_addr, lldb::addr_t address, ABI *abi); - static bool PrintDWARFExpression(Stream &s, const DataExtractor &data, - int address_size, int dwarf_ref_size, - bool location_expression); - - static void PrintDWARFLocationList(Stream &s, const DWARFUnit *cu, - const DataExtractor &debug_loc_data, - lldb::offset_t offset); - bool MatchesOperand(StackFrame &frame, const Instruction::Operand &op); private: @@ -233,11 +225,8 @@ private: /// \param[in] s /// The stream to use for pretty-printing. /// - /// \param[in] offset - /// The offset into the data buffer of the opcodes to be printed. - /// - /// \param[in] length - /// The length in bytes of the opcodes to be printed. + /// \param[in] data + /// The data extractor. /// /// \param[in] level /// The level of detail to use in pretty-printing. @@ -275,4 +264,4 @@ private: } // namespace lldb_private -#endif // liblldb_DWARFExpression_h_ +#endif // LLDB_EXPRESSION_DWARFEXPRESSION_H diff --git a/lldb/include/lldb/Expression/DiagnosticManager.h b/lldb/include/lldb/Expression/DiagnosticManager.h index e5aecce08727..c0271c954ba3 100644 --- a/lldb/include/lldb/Expression/DiagnosticManager.h +++ b/lldb/include/lldb/Expression/DiagnosticManager.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef lldb_DiagnosticManager_h -#define lldb_DiagnosticManager_h +#ifndef LLDB_EXPRESSION_DIAGNOSTICMANAGER_H +#define LLDB_EXPRESSION_DIAGNOSTICMANAGER_H #include "lldb/lldb-defines.h" #include "lldb/lldb-types.h" @@ -78,7 +78,7 @@ public: bool precede_with_newline = true) { if (precede_with_newline) m_message.push_back('\n'); - m_message.append(message); + m_message += message; } protected: @@ -148,4 +148,4 @@ protected: }; } -#endif /* lldb_DiagnosticManager_h */ +#endif // LLDB_EXPRESSION_DIAGNOSTICMANAGER_H diff --git a/lldb/include/lldb/Expression/DynamicCheckerFunctions.h b/lldb/include/lldb/Expression/DynamicCheckerFunctions.h index 7be24b6ea962..02bce5abdf4c 100644 --- a/lldb/include/lldb/Expression/DynamicCheckerFunctions.h +++ b/lldb/include/lldb/Expression/DynamicCheckerFunctions.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef liblldb_DynamicCheckerFunctions_h_ -#define liblldb_DynamicCheckerFunctions_h_ +#ifndef LLDB_EXPRESSION_DYNAMICCHECKERFUNCTIONS_H +#define LLDB_EXPRESSION_DYNAMICCHECKERFUNCTIONS_H #include "lldb/lldb-types.h" @@ -59,4 +59,4 @@ private: }; } // namespace lldb_private -#endif // liblldb_DynamicCheckerFunctions_h_ +#endif // LLDB_EXPRESSION_DYNAMICCHECKERFUNCTIONS_H diff --git a/lldb/include/lldb/Expression/Expression.h b/lldb/include/lldb/Expression/Expression.h index e0ea7e99f4f9..aaac889e6ed2 100644 --- a/lldb/include/lldb/Expression/Expression.h +++ b/lldb/include/lldb/Expression/Expression.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef liblldb_Expression_h_ -#define liblldb_Expression_h_ +#ifndef LLDB_EXPRESSION_EXPRESSION_H +#define LLDB_EXPRESSION_EXPRESSION_H #include <map> #include <string> @@ -51,7 +51,9 @@ public: /// Return the language that should be used when parsing. To use the /// default, return eLanguageTypeUnknown. - virtual lldb::LanguageType Language() { return lldb::eLanguageTypeUnknown; } + virtual lldb::LanguageType Language() const { + return lldb::eLanguageTypeUnknown; + } /// Return the Materializer that the parser should use when registering /// external values. @@ -101,4 +103,4 @@ protected: } // namespace lldb_private -#endif // liblldb_Expression_h_ +#endif // LLDB_EXPRESSION_EXPRESSION_H diff --git a/lldb/include/lldb/Expression/ExpressionParser.h b/lldb/include/lldb/Expression/ExpressionParser.h index 2e7b3075d509..71d2410ea7c3 100644 --- a/lldb/include/lldb/Expression/ExpressionParser.h +++ b/lldb/include/lldb/Expression/ExpressionParser.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef liblldb_ExpressionParser_h_ -#define liblldb_ExpressionParser_h_ +#ifndef LLDB_EXPRESSION_EXPRESSIONPARSER_H +#define LLDB_EXPRESSION_EXPRESSIONPARSER_H #include "lldb/Utility/CompletionRequest.h" #include "lldb/Utility/Status.h" @@ -133,4 +133,4 @@ protected: }; } -#endif // liblldb_ExpressionParser_h_ +#endif // LLDB_EXPRESSION_EXPRESSIONPARSER_H diff --git a/lldb/include/lldb/Expression/ExpressionSourceCode.h b/lldb/include/lldb/Expression/ExpressionSourceCode.h index db8ef967ab15..a3be73997c26 100644 --- a/lldb/include/lldb/Expression/ExpressionSourceCode.h +++ b/lldb/include/lldb/Expression/ExpressionSourceCode.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef liblldb_ExpressionSourceCode_h -#define liblldb_ExpressionSourceCode_h +#ifndef LLDB_EXPRESSION_EXPRESSIONSOURCECODE_H +#define LLDB_EXPRESSION_EXPRESSIONSOURCECODE_H #include "lldb/lldb-enumerations.h" #include "llvm/ADT/ArrayRef.h" diff --git a/lldb/include/lldb/Expression/ExpressionTypeSystemHelper.h b/lldb/include/lldb/Expression/ExpressionTypeSystemHelper.h index 9c645532cdc1..1bba30ad8620 100644 --- a/lldb/include/lldb/Expression/ExpressionTypeSystemHelper.h +++ b/lldb/include/lldb/Expression/ExpressionTypeSystemHelper.h @@ -7,8 +7,8 @@ // //===----------------------------------------------------------------------===// -#ifndef ExpressionTypeSystemHelper_h -#define ExpressionTypeSystemHelper_h +#ifndef LLDB_EXPRESSION_EXPRESSIONTYPESYSTEMHELPER_H +#define LLDB_EXPRESSION_EXPRESSIONTYPESYSTEMHELPER_H #include "llvm/Support/Casting.h" @@ -44,4 +44,4 @@ protected: } // namespace lldb_private -#endif /* ExpressionTypeSystemHelper_h */ +#endif // LLDB_EXPRESSION_EXPRESSIONTYPESYSTEMHELPER_H diff --git a/lldb/include/lldb/Expression/ExpressionVariable.h b/lldb/include/lldb/Expression/ExpressionVariable.h index c20c2301bb54..60062d212bad 100644 --- a/lldb/include/lldb/Expression/ExpressionVariable.h +++ b/lldb/include/lldb/Expression/ExpressionVariable.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef liblldb_ExpressionVariable_h_ -#define liblldb_ExpressionVariable_h_ +#ifndef LLDB_EXPRESSION_EXPRESSIONVARIABLE_H +#define LLDB_EXPRESSION_EXPRESSIONVARIABLE_H #include <memory> #include <vector> @@ -221,11 +221,7 @@ public: uint32_t addr_byte_size) = 0; /// Return a new persistent variable name with the specified prefix. - ConstString GetNextPersistentVariableName(Target &target, - llvm::StringRef prefix); - - virtual llvm::StringRef - GetPersistentVariablePrefix(bool is_error = false) const = 0; + virtual ConstString GetNextPersistentVariableName(bool is_error = false) = 0; virtual void RemovePersistentVariable(lldb::ExpressionVariableSP variable) = 0; @@ -237,6 +233,10 @@ public: void RegisterExecutionUnit(lldb::IRExecutionUnitSP &execution_unit_sp); +protected: + virtual llvm::StringRef + GetPersistentVariablePrefix(bool is_error = false) const = 0; + private: LLVMCastKind m_kind; @@ -251,4 +251,4 @@ private: } // namespace lldb_private -#endif // liblldb_ExpressionVariable_h_ +#endif // LLDB_EXPRESSION_EXPRESSIONVARIABLE_H diff --git a/lldb/include/lldb/Expression/FunctionCaller.h b/lldb/include/lldb/Expression/FunctionCaller.h index 1303655f449f..f35ee820edde 100644 --- a/lldb/include/lldb/Expression/FunctionCaller.h +++ b/lldb/include/lldb/Expression/FunctionCaller.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef liblldb_FunctionCaller_h_ -#define liblldb_FunctionCaller_h_ +#ifndef LLDB_EXPRESSION_FUNCTIONCALLER_H +#define LLDB_EXPRESSION_FUNCTIONCALLER_H #include <list> #include <memory> @@ -336,4 +336,4 @@ protected: } // namespace lldb_private -#endif // liblldb_FunctionCaller_h_ +#endif // LLDB_EXPRESSION_FUNCTIONCALLER_H diff --git a/lldb/include/lldb/Expression/IRExecutionUnit.h b/lldb/include/lldb/Expression/IRExecutionUnit.h index 05f2f8471ef8..ad3c7372e67d 100644 --- a/lldb/include/lldb/Expression/IRExecutionUnit.h +++ b/lldb/include/lldb/Expression/IRExecutionUnit.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef liblldb_IRExecutionUnit_h_ -#define liblldb_IRExecutionUnit_h_ +#ifndef LLDB_EXPRESSION_IREXECUTIONUNIT_H +#define LLDB_EXPRESSION_IREXECUTIONUNIT_H #include <atomic> #include <memory> @@ -71,7 +71,7 @@ public: llvm::Module *GetModule() { return m_module; } llvm::Function *GetFunction() { - return ((m_module != nullptr) ? m_module->getFunction(m_name.AsCString()) + return ((m_module != nullptr) ? m_module->getFunction(m_name.GetStringRef()) : nullptr); } @@ -406,4 +406,4 @@ private: } // namespace lldb_private -#endif // liblldb_IRExecutionUnit_h_ +#endif // LLDB_EXPRESSION_IREXECUTIONUNIT_H diff --git a/lldb/include/lldb/Expression/IRInterpreter.h b/lldb/include/lldb/Expression/IRInterpreter.h index 6148093e718f..98ece967a923 100644 --- a/lldb/include/lldb/Expression/IRInterpreter.h +++ b/lldb/include/lldb/Expression/IRInterpreter.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef liblldb_IRInterpreter_h_ -#define liblldb_IRInterpreter_h_ +#ifndef LLDB_EXPRESSION_IRINTERPRETER_H +#define LLDB_EXPRESSION_IRINTERPRETER_H #include "lldb/Utility/ConstString.h" #include "lldb/Utility/Stream.h" @@ -22,7 +22,6 @@ class Module; namespace lldb_private { -class ClangExpressionDeclMap; class IRMemoryMap; } diff --git a/lldb/include/lldb/Expression/IRMemoryMap.h b/lldb/include/lldb/Expression/IRMemoryMap.h index d6a17a9848fb..abec5442793c 100644 --- a/lldb/include/lldb/Expression/IRMemoryMap.h +++ b/lldb/include/lldb/Expression/IRMemoryMap.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef lldb_IRMemoryMap_h_ -#define lldb_IRMemoryMap_h_ +#ifndef LLDB_EXPRESSION_IRMEMORYMAP_H +#define LLDB_EXPRESSION_IRMEMORYMAP_H #include "lldb/Utility/DataBufferHeap.h" #include "lldb/Utility/UserID.h" @@ -107,7 +107,8 @@ private: size_t size, uint32_t permissions, uint8_t alignment, AllocationPolicy m_policy); - DISALLOW_COPY_AND_ASSIGN(Allocation); + Allocation(const Allocation &) = delete; + const Allocation &operator=(const Allocation &) = delete; }; static_assert(sizeof(Allocation) <= diff --git a/lldb/include/lldb/Expression/LLVMUserExpression.h b/lldb/include/lldb/Expression/LLVMUserExpression.h index 2679c01a4e00..244a28aec242 100644 --- a/lldb/include/lldb/Expression/LLVMUserExpression.h +++ b/lldb/include/lldb/Expression/LLVMUserExpression.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef liblldb_LLVMUserExpression_h -#define liblldb_LLVMUserExpression_h +#ifndef LLDB_EXPRESSION_LLVMUSEREXPRESSION_H +#define LLDB_EXPRESSION_LLVMUSEREXPRESSION_H #include <map> #include <string> @@ -71,8 +71,6 @@ public: /// translation unit. const char *Text() override { return m_transformed_text.c_str(); } - lldb::ModuleSP GetJITModule() override; - protected: lldb::ExpressionResults DoExecute(DiagnosticManager &diagnostic_manager, ExecutionContext &exe_ctx, diff --git a/lldb/include/lldb/Expression/Materializer.h b/lldb/include/lldb/Expression/Materializer.h index 70f622e7850b..754e67c5dfa7 100644 --- a/lldb/include/lldb/Expression/Materializer.h +++ b/lldb/include/lldb/Expression/Materializer.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef liblldb_Materializer_h -#define liblldb_Materializer_h +#ifndef LLDB_EXPRESSION_MATERIALIZER_H +#define LLDB_EXPRESSION_MATERIALIZER_H #include <memory> #include <vector> @@ -22,14 +22,12 @@ namespace lldb_private { class Materializer { public: - Materializer(); + Materializer() = default; ~Materializer(); class Dematerializer { public: - Dematerializer() - : m_materializer(nullptr), m_map(nullptr), - m_process_address(LLDB_INVALID_ADDRESS) {} + Dematerializer() = default; ~Dematerializer() { Wipe(); } @@ -56,11 +54,11 @@ public: } } - Materializer *m_materializer; + Materializer *m_materializer = nullptr; lldb::ThreadWP m_thread_wp; StackID m_stack_id; - IRMemoryMap *m_map; - lldb::addr_t m_process_address; + IRMemoryMap *m_map = nullptr; + lldb::addr_t m_process_address = LLDB_INVALID_ADDRESS; }; typedef std::shared_ptr<Dematerializer> DematerializerSP; @@ -128,10 +126,10 @@ private: DematerializerWP m_dematerializer_wp; EntityVector m_entities; - uint32_t m_current_offset; - uint32_t m_struct_alignment; + uint32_t m_current_offset = 0; + uint32_t m_struct_alignment = 8; }; } // namespace lldb_private -#endif // liblldb_Materializer_h +#endif // LLDB_EXPRESSION_MATERIALIZER_H diff --git a/lldb/include/lldb/Expression/REPL.h b/lldb/include/lldb/Expression/REPL.h index 035ad63271e4..a0df53eb9b4c 100644 --- a/lldb/include/lldb/Expression/REPL.h +++ b/lldb/include/lldb/Expression/REPL.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef lldb_REPL_h -#define lldb_REPL_h +#ifndef LLDB_EXPRESSION_REPL_H +#define LLDB_EXPRESSION_REPL_H #include <string> @@ -130,8 +130,8 @@ protected: lldb::ValueObjectSP &valobj_sp, ExpressionVariable *var = nullptr) = 0; - virtual int CompleteCode(const std::string ¤t_code, - StringList &matches) = 0; + virtual void CompleteCode(const std::string ¤t_code, + CompletionRequest &request) = 0; OptionGroupFormat m_format_options = OptionGroupFormat(lldb::eFormatDefault); OptionGroupValueObjectDisplay m_varobj_options; @@ -158,4 +158,4 @@ private: } // namespace lldb_private -#endif // lldb_REPL_h +#endif // LLDB_EXPRESSION_REPL_H diff --git a/lldb/include/lldb/Expression/UserExpression.h b/lldb/include/lldb/Expression/UserExpression.h index 83122d8ba518..8236c417f73a 100644 --- a/lldb/include/lldb/Expression/UserExpression.h +++ b/lldb/include/lldb/Expression/UserExpression.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef liblldb_UserExpression_h_ -#define liblldb_UserExpression_h_ +#ifndef LLDB_EXPRESSION_USEREXPRESSION_H +#define LLDB_EXPRESSION_USEREXPRESSION_H #include <memory> #include <string> @@ -194,7 +194,7 @@ public: /// Return the language that should be used when parsing. To use the /// default, return eLanguageTypeUnknown. - lldb::LanguageType Language() override { return m_language; } + lldb::LanguageType Language() const override { return m_language; } /// Return the desired result type of the function, or eResultTypeAny if /// indifferent. @@ -213,8 +213,6 @@ public: return lldb::ExpressionVariableSP(); } - 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. /// @@ -244,9 +242,6 @@ public: /// If non-nullptr, the fixed expression is copied into the provided /// string. /// - /// \param[out] jit_module_sp_ptr - /// If non-nullptr, used to persist the generated IR module. - /// /// \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 @@ -265,7 +260,6 @@ public: llvm::StringRef expr_cstr, llvm::StringRef expr_prefix, lldb::ValueObjectSP &result_valobj_sp, Status &error, std::string *fixed_expression = nullptr, - lldb::ModuleSP *jit_module_sp_ptr = nullptr, ValueObject *ctx_obj = nullptr); static const Status::ValueType kNoResult = @@ -314,4 +308,4 @@ protected: } // namespace lldb_private -#endif // liblldb_UserExpression_h_ +#endif // LLDB_EXPRESSION_USEREXPRESSION_H diff --git a/lldb/include/lldb/Expression/UtilityFunction.h b/lldb/include/lldb/Expression/UtilityFunction.h index c3d185899b0f..5ebbc0ede1e3 100644 --- a/lldb/include/lldb/Expression/UtilityFunction.h +++ b/lldb/include/lldb/Expression/UtilityFunction.h @@ -7,8 +7,8 @@ // //===----------------------------------------------------------------------===// -#ifndef liblldb_UtilityFunction_h_ -#define liblldb_UtilityFunction_h_ +#ifndef LLDB_EXPRESSION_UTILITYFUNCTION_H +#define LLDB_EXPRESSION_UTILITYFUNCTION_H #include <memory> #include <string> @@ -118,4 +118,4 @@ protected: } // namespace lldb_private -#endif // liblldb_UtilityFunction_h_ +#endif // LLDB_EXPRESSION_UTILITYFUNCTION_H diff --git a/lldb/include/lldb/Host/Config.h.cmake b/lldb/include/lldb/Host/Config.h.cmake index e9065ed04caa..42f4ca1a26c6 100644 --- a/lldb/include/lldb/Host/Config.h.cmake +++ b/lldb/include/lldb/Host/Config.h.cmake @@ -46,6 +46,8 @@ #cmakedefine01 LLDB_ENABLE_PYTHON +#cmakedefine01 LLDB_EMBED_PYTHON_HOME + #cmakedefine LLDB_PYTHON_HOME "${LLDB_PYTHON_HOME}" #define LLDB_LIBDIR_SUFFIX "${LLVM_LIBDIR_SUFFIX}" diff --git a/lldb/include/lldb/Host/ConnectionFileDescriptor.h b/lldb/include/lldb/Host/ConnectionFileDescriptor.h index 00444d011af3..ff6bcc4766ea 100644 --- a/lldb/include/lldb/Host/ConnectionFileDescriptor.h +++ b/lldb/include/lldb/Host/ConnectionFileDescriptor.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef liblldb_Host_ConnectionFileDescriptor_h_ -#define liblldb_Host_ConnectionFileDescriptor_h_ +#ifndef LLDB_HOST_CONNECTIONFILEDESCRIPTOR_H +#define LLDB_HOST_CONNECTIONFILEDESCRIPTOR_H #include "lldb/Host/posix/ConnectionFileDescriptorPosix.h" diff --git a/lldb/include/lldb/Host/Debug.h b/lldb/include/lldb/Host/Debug.h index 036ce1ebccd5..402325c4c166 100644 --- a/lldb/include/lldb/Host/Debug.h +++ b/lldb/include/lldb/Host/Debug.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef liblldb_Debug_h_ -#define liblldb_Debug_h_ +#ifndef LLDB_HOST_DEBUG_H +#define LLDB_HOST_DEBUG_H #include <vector> @@ -148,4 +148,4 @@ struct ThreadStopInfo { }; } -#endif // liblldb_Debug_h_ +#endif // LLDB_HOST_DEBUG_H diff --git a/lldb/include/lldb/Host/Editline.h b/lldb/include/lldb/Host/Editline.h index db3d9e48cfbb..356e8f734732 100644 --- a/lldb/include/lldb/Host/Editline.h +++ b/lldb/include/lldb/Host/Editline.h @@ -19,17 +19,14 @@ // good amount of the text will // disappear. It's still in the buffer, just invisible. // b) The prompt printing logic for dealing with ANSI formatting characters is -// broken, which is why we're -// working around it here. -// c) When resizing the terminal window, if the cursor moves between rows -// libedit will get confused. d) The incremental search uses escape to cancel -// input, so it's confused by +// broken, which is why we're working around it here. +// c) The incremental search uses escape to cancel input, so it's confused by // ANSI sequences starting with escape. -// e) Emoji support is fairly terrible, presumably it doesn't understand +// d) Emoji support is fairly terrible, presumably it doesn't understand // composed characters? -#ifndef liblldb_Editline_h_ -#define liblldb_Editline_h_ +#ifndef LLDB_HOST_EDITLINE_H +#define LLDB_HOST_EDITLINE_H #if defined(__cplusplus) #include "lldb/Host/Config.h" @@ -50,6 +47,7 @@ #include <histedit.h> #endif +#include <csignal> #include <mutex> #include <string> #include <vector> @@ -171,9 +169,7 @@ public: /// editing scenarios. void SetContinuationPrompt(const char *continuation_prompt); - /// Required to update the width of the terminal registered for I/O. It is - /// critical that this - /// be correct at all times. + /// Call when the terminal size changes void TerminalSizeChanged(); /// Returns the prompt established by SetPrompt() @@ -328,7 +324,8 @@ private: bool CompleteCharacter(char ch, EditLineGetCharType &out); -private: + void ApplyTerminalSizeChange(); + #if LLDB_EDITLINE_USE_WCHAR std::wstring_convert<std::codecvt_utf8<wchar_t>> m_utf8conv; #endif @@ -350,6 +347,7 @@ private: std::string m_set_continuation_prompt; std::string m_current_prompt; bool m_needs_prompt_repaint = false; + volatile std::sig_atomic_t m_terminal_size_has_changed = 0; std::string m_editor_name; FILE *m_input_file; FILE *m_output_file; @@ -368,4 +366,4 @@ private: } #endif // #if defined(__cplusplus) -#endif // liblldb_Editline_h_ +#endif // LLDB_HOST_EDITLINE_H diff --git a/lldb/include/lldb/Host/File.h b/lldb/include/lldb/Host/File.h index 9beb20556dcd..d205a3fe6911 100644 --- a/lldb/include/lldb/Host/File.h +++ b/lldb/include/lldb/Host/File.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef liblldb_File_h_ -#define liblldb_File_h_ +#ifndef LLDB_HOST_FILE_H +#define LLDB_HOST_FILE_H #include "lldb/Host/PosixApi.h" #include "lldb/Utility/IOObject.h" @@ -367,7 +367,8 @@ protected: void CalculateInteractiveAndTerminal(); private: - DISALLOW_COPY_AND_ASSIGN(File); + File(const File &) = delete; + const File &operator=(const File &) = delete; }; class NativeFile : public File { @@ -428,9 +429,10 @@ protected: std::mutex offset_access_mutex; private: - DISALLOW_COPY_AND_ASSIGN(NativeFile); + NativeFile(const NativeFile &) = delete; + const NativeFile &operator=(const NativeFile &) = delete; }; } // namespace lldb_private -#endif // liblldb_File_h_ +#endif // LLDB_HOST_FILE_H diff --git a/lldb/include/lldb/Host/FileCache.h b/lldb/include/lldb/Host/FileCache.h index c76916701ebb..df0d9a88c6df 100644 --- a/lldb/include/lldb/Host/FileCache.h +++ b/lldb/include/lldb/Host/FileCache.h @@ -5,8 +5,8 @@ // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// -#ifndef liblldb_Host_FileCache_h -#define liblldb_Host_FileCache_h +#ifndef LLDB_HOST_FILECACHE_H +#define LLDB_HOST_FILECACHE_H #include <map> #include <stdint.h> diff --git a/lldb/include/lldb/Host/FileSystem.h b/lldb/include/lldb/Host/FileSystem.h index 528c43519a32..8dcff3402592 100644 --- a/lldb/include/lldb/Host/FileSystem.h +++ b/lldb/include/lldb/Host/FileSystem.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef liblldb_Host_FileSystem_h -#define liblldb_Host_FileSystem_h +#ifndef LLDB_HOST_FILESYSTEM_H +#define LLDB_HOST_FILESYSTEM_H #include "lldb/Host/File.h" #include "lldb/Utility/DataBufferLLVM.h" @@ -186,6 +186,9 @@ public: return m_fs; } + void Collect(const FileSpec &file_spec); + void Collect(const llvm::Twine &file); + private: static llvm::Optional<FileSystem> &InstanceImpl(); llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem> m_fs; diff --git a/lldb/include/lldb/Host/Host.h b/lldb/include/lldb/Host/Host.h index 884c5cf63213..f19cb85d2329 100644 --- a/lldb/include/lldb/Host/Host.h +++ b/lldb/include/lldb/Host/Host.h @@ -27,8 +27,8 @@ namespace lldb_private { class FileAction; class ProcessLaunchInfo; class ProcessInstanceInfo; -class ProcessInstanceInfoList; class ProcessInstanceInfoMatch; +typedef std::vector<ProcessInstanceInfo> ProcessInstanceInfoList; // Exit Type for inferior processes struct WaitStatus { @@ -232,6 +232,10 @@ public: static std::unique_ptr<Connection> CreateDefaultConnection(llvm::StringRef url); + +protected: + static uint32_t FindProcessesImpl(const ProcessInstanceInfoMatch &match_info, + ProcessInstanceInfoList &proc_infos); }; } // namespace lldb_private diff --git a/lldb/include/lldb/Host/HostGetOpt.h b/lldb/include/lldb/Host/HostGetOpt.h index dedeb2e2fcc3..746e03e1bd1e 100644 --- a/lldb/include/lldb/Host/HostGetOpt.h +++ b/lldb/include/lldb/Host/HostGetOpt.h @@ -5,7 +5,9 @@ // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// -#pragma once + +#ifndef LLDB_HOST_HOSTGETOPT_H +#define LLDB_HOST_HOSTGETOPT_H #if !defined(_MSC_VER) && !defined(__NetBSD__) @@ -21,3 +23,5 @@ #include <lldb/Host/common/GetOptInc.h> #endif + +#endif // LLDB_HOST_HOSTGETOPT_H diff --git a/lldb/include/lldb/Host/HostInfo.h b/lldb/include/lldb/Host/HostInfo.h index 196127d40763..b7010d69d88e 100644 --- a/lldb/include/lldb/Host/HostInfo.h +++ b/lldb/include/lldb/Host/HostInfo.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef lldb_Host_HostInfo_h_ -#define lldb_Host_HostInfo_h_ +#ifndef LLDB_HOST_HOSTINFO_H +#define LLDB_HOST_HOSTINFO_H /// \class HostInfo HostInfo.h "lldb/Host/HostInfo.h" /// A class that provides host computer information. @@ -35,7 +35,7 @@ #if defined(_WIN32) #include "lldb/Host/windows/HostInfoWindows.h" #define HOST_INFO_TYPE HostInfoWindows -#elif defined(__linux__) +#elif defined(__linux__) || defined(__EMSCRIPTEN__) #if defined(__ANDROID__) #include "lldb/Host/android/HostInfoAndroid.h" #define HOST_INFO_TYPE HostInfoAndroid diff --git a/lldb/include/lldb/Host/HostInfoBase.h b/lldb/include/lldb/Host/HostInfoBase.h index c59050cb34e9..70682c9b685e 100644 --- a/lldb/include/lldb/Host/HostInfoBase.h +++ b/lldb/include/lldb/Host/HostInfoBase.h @@ -6,12 +6,13 @@ // //===----------------------------------------------------------------------===// -#ifndef lldb_Host_HostInfoBase_h_ -#define lldb_Host_HostInfoBase_h_ +#ifndef LLDB_HOST_HOSTINFOBASE_H +#define LLDB_HOST_HOSTINFOBASE_H #include "lldb/Utility/ArchSpec.h" #include "lldb/Utility/FileSpec.h" #include "lldb/Utility/UserIDResolver.h" +#include "lldb/Utility/XcodeSDK.h" #include "lldb/lldb-enumerations.h" #include "llvm/ADT/StringRef.h" @@ -91,6 +92,12 @@ public: static bool ComputePathRelativeToLibrary(FileSpec &file_spec, llvm::StringRef dir); + static FileSpec GetXcodeContentsDirectory() { return {}; } + static FileSpec GetXcodeDeveloperDirectory() { return {}; } + + /// Return the directory containing a specific Xcode SDK. + static llvm::StringRef GetXcodeSDKPath(XcodeSDK sdk) { return {}; } + protected: static bool ComputeSharedLibraryDirectory(FileSpec &file_spec); static bool ComputeSupportExeDirectory(FileSpec &file_spec); diff --git a/lldb/include/lldb/Host/HostNativeProcess.h b/lldb/include/lldb/Host/HostNativeProcess.h index c86a2aef38fc..d1e577dc3289 100644 --- a/lldb/include/lldb/Host/HostNativeProcess.h +++ b/lldb/include/lldb/Host/HostNativeProcess.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef lldb_Host_HostNativeProcess_h_ -#define lldb_Host_HostNativeProcess_h_ +#ifndef LLDB_HOST_HOSTNATIVEPROCESS_H +#define LLDB_HOST_HOSTNATIVEPROCESS_H #if defined(_WIN32) #include "lldb/Host/windows/HostProcessWindows.h" diff --git a/lldb/include/lldb/Host/HostNativeProcessBase.h b/lldb/include/lldb/Host/HostNativeProcessBase.h index aaa517d53217..642c63443c20 100644 --- a/lldb/include/lldb/Host/HostNativeProcessBase.h +++ b/lldb/include/lldb/Host/HostNativeProcessBase.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef lldb_Host_HostNativeProcessBase_h_ -#define lldb_Host_HostNativeProcessBase_h_ +#ifndef LLDB_HOST_HOSTNATIVEPROCESSBASE_H +#define LLDB_HOST_HOSTNATIVEPROCESSBASE_H #include "lldb/Host/HostProcess.h" #include "lldb/Utility/Status.h" @@ -19,7 +19,9 @@ namespace lldb_private { class HostThread; class HostNativeProcessBase { - DISALLOW_COPY_AND_ASSIGN(HostNativeProcessBase); + HostNativeProcessBase(const HostNativeProcessBase &) = delete; + const HostNativeProcessBase & + operator=(const HostNativeProcessBase &) = delete; public: HostNativeProcessBase() : m_process(LLDB_INVALID_PROCESS) {} diff --git a/lldb/include/lldb/Host/HostNativeThread.h b/lldb/include/lldb/Host/HostNativeThread.h index 8bf65849d880..cef08f0539a9 100644 --- a/lldb/include/lldb/Host/HostNativeThread.h +++ b/lldb/include/lldb/Host/HostNativeThread.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef lldb_Host_HostNativeThread_h_ -#define lldb_Host_HostNativeThread_h_ +#ifndef LLDB_HOST_HOSTNATIVETHREAD_H +#define LLDB_HOST_HOSTNATIVETHREAD_H #include "HostNativeThreadForward.h" diff --git a/lldb/include/lldb/Host/HostNativeThreadBase.h b/lldb/include/lldb/Host/HostNativeThreadBase.h index a196f0bc82ca..0dfd363cc8fb 100644 --- a/lldb/include/lldb/Host/HostNativeThreadBase.h +++ b/lldb/include/lldb/Host/HostNativeThreadBase.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef lldb_Host_HostNativeThreadBase_h_ -#define lldb_Host_HostNativeThreadBase_h_ +#ifndef LLDB_HOST_HOSTNATIVETHREADBASE_H +#define LLDB_HOST_HOSTNATIVETHREADBASE_H #include "lldb/Utility/Status.h" #include "lldb/lldb-defines.h" @@ -23,7 +23,8 @@ namespace lldb_private { class HostNativeThreadBase { friend class ThreadLauncher; - DISALLOW_COPY_AND_ASSIGN(HostNativeThreadBase); + HostNativeThreadBase(const HostNativeThreadBase &) = delete; + const HostNativeThreadBase &operator=(const HostNativeThreadBase &) = delete; public: HostNativeThreadBase(); diff --git a/lldb/include/lldb/Host/HostNativeThreadForward.h b/lldb/include/lldb/Host/HostNativeThreadForward.h index 261d3c7a836e..35b6e2f09e05 100644 --- a/lldb/include/lldb/Host/HostNativeThreadForward.h +++ b/lldb/include/lldb/Host/HostNativeThreadForward.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef lldb_Host_HostNativeThreadForward_h_ -#define lldb_Host_HostNativeThreadForward_h_ +#ifndef LLDB_HOST_HOSTNATIVETHREADFORWARD_H +#define LLDB_HOST_HOSTNATIVETHREADFORWARD_H namespace lldb_private { #if defined(_WIN32) diff --git a/lldb/include/lldb/Host/HostProcess.h b/lldb/include/lldb/Host/HostProcess.h index fcea52a284d9..0b7c30364223 100644 --- a/lldb/include/lldb/Host/HostProcess.h +++ b/lldb/include/lldb/Host/HostProcess.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef lldb_Host_HostProcess_h_ -#define lldb_Host_HostProcess_h_ +#ifndef LLDB_HOST_HOSTPROCESS_H +#define LLDB_HOST_HOSTPROCESS_H #include "lldb/Host/Host.h" #include "lldb/lldb-types.h" diff --git a/lldb/include/lldb/Host/HostThread.h b/lldb/include/lldb/Host/HostThread.h index 7bf2a1dc2db9..d3477e115e2d 100644 --- a/lldb/include/lldb/Host/HostThread.h +++ b/lldb/include/lldb/Host/HostThread.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef lldb_Host_HostThread_h_ -#define lldb_Host_HostThread_h_ +#ifndef LLDB_HOST_HOSTTHREAD_H +#define LLDB_HOST_HOSTTHREAD_H #include "lldb/Host/HostNativeThreadForward.h" #include "lldb/Utility/Status.h" diff --git a/lldb/include/lldb/Host/LZMA.h b/lldb/include/lldb/Host/LZMA.h index c741cc3bbde1..5314dab53e44 100644 --- a/lldb/include/lldb/Host/LZMA.h +++ b/lldb/include/lldb/Host/LZMA.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef liblldb_Host_LZMA_h_ -#define liblldb_Host_LZMA_h_ +#ifndef LLDB_HOST_LZMA_H +#define LLDB_HOST_LZMA_H #include "llvm/ADT/ArrayRef.h" @@ -31,4 +31,4 @@ llvm::Error uncompress(llvm::ArrayRef<uint8_t> InputBuffer, } // End of namespace lldb_private -#endif // liblldb_Host_LZMA_h_ +#endif // LLDB_HOST_LZMA_H diff --git a/lldb/include/lldb/Host/LockFile.h b/lldb/include/lldb/Host/LockFile.h index 2a1cd3dbb8f7..ff09eb475f78 100644 --- a/lldb/include/lldb/Host/LockFile.h +++ b/lldb/include/lldb/Host/LockFile.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef liblldb_Host_LockFile_h_ -#define liblldb_Host_LockFile_h_ +#ifndef LLDB_HOST_LOCKFILE_H +#define LLDB_HOST_LOCKFILE_H #if defined(_WIN32) #include "lldb/Host/windows/LockFileWindows.h" @@ -21,4 +21,4 @@ typedef LockFilePosix LockFile; } #endif -#endif // liblldb_Host_LockFile_h_ +#endif // LLDB_HOST_LOCKFILE_H diff --git a/lldb/include/lldb/Host/LockFileBase.h b/lldb/include/lldb/Host/LockFileBase.h index be9e258c5c2d..6a5fd424869c 100644 --- a/lldb/include/lldb/Host/LockFileBase.h +++ b/lldb/include/lldb/Host/LockFileBase.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef liblldb_Host_LockFileBase_h_ -#define liblldb_Host_LockFileBase_h_ +#ifndef LLDB_HOST_LOCKFILEBASE_H +#define LLDB_HOST_LOCKFILEBASE_H #include "lldb/Utility/Status.h" diff --git a/lldb/include/lldb/Host/MainLoop.h b/lldb/include/lldb/Host/MainLoop.h index d59aa28ccb0e..9ca5040b60a8 100644 --- a/lldb/include/lldb/Host/MainLoop.h +++ b/lldb/include/lldb/Host/MainLoop.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef lldb_Host_MainLoop_h_ -#define lldb_Host_MainLoop_h_ +#ifndef LLDB_HOST_MAINLOOP_H +#define LLDB_HOST_MAINLOOP_H #include "lldb/Host/Config.h" #include "lldb/Host/MainLoopBase.h" @@ -86,7 +86,8 @@ private: int m_signo; friend class MainLoop; - DISALLOW_COPY_AND_ASSIGN(SignalHandle); + SignalHandle(const SignalHandle &) = delete; + const SignalHandle &operator=(const SignalHandle &) = delete; }; struct SignalInfo { @@ -108,4 +109,4 @@ private: } // namespace lldb_private -#endif // lldb_Host_MainLoop_h_ +#endif // LLDB_HOST_MAINLOOP_H diff --git a/lldb/include/lldb/Host/MainLoopBase.h b/lldb/include/lldb/Host/MainLoopBase.h index 3fee2b2c09d8..fa8cc77a94ba 100644 --- a/lldb/include/lldb/Host/MainLoopBase.h +++ b/lldb/include/lldb/Host/MainLoopBase.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef lldb_Host_posix_MainLoopBase_h_ -#define lldb_Host_posix_MainLoopBase_h_ +#ifndef LLDB_HOST_MAINLOOPBASE_H +#define LLDB_HOST_MAINLOOPBASE_H #include "lldb/Utility/IOObject.h" #include "lldb/Utility/Status.h" @@ -75,13 +75,14 @@ private: IOObject::WaitableHandle m_handle; friend class MainLoopBase; - DISALLOW_COPY_AND_ASSIGN(ReadHandle); + ReadHandle(const ReadHandle &) = delete; + const ReadHandle &operator=(const ReadHandle &) = delete; }; -private: - DISALLOW_COPY_AND_ASSIGN(MainLoopBase); + MainLoopBase(const MainLoopBase &) = delete; + const MainLoopBase &operator=(const MainLoopBase &) = delete; }; } // namespace lldb_private -#endif // lldb_Host_posix_MainLoopBase_h_ +#endif // LLDB_HOST_MAINLOOPBASE_H diff --git a/lldb/include/lldb/Host/MonitoringProcessLauncher.h b/lldb/include/lldb/Host/MonitoringProcessLauncher.h index 59111a04fc98..e2fce42a228e 100644 --- a/lldb/include/lldb/Host/MonitoringProcessLauncher.h +++ b/lldb/include/lldb/Host/MonitoringProcessLauncher.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef lldb_Host_MonitoringProcessLauncher_h_ -#define lldb_Host_MonitoringProcessLauncher_h_ +#ifndef LLDB_HOST_MONITORINGPROCESSLAUNCHER_H +#define LLDB_HOST_MONITORINGPROCESSLAUNCHER_H #include <memory> #include "lldb/Host/ProcessLauncher.h" @@ -31,4 +31,4 @@ private: } // namespace lldb_private -#endif // lldb_Host_MonitoringProcessLauncher_h_ +#endif // LLDB_HOST_MONITORINGPROCESSLAUNCHER_H diff --git a/lldb/include/lldb/Host/OptionParser.h b/lldb/include/lldb/Host/OptionParser.h index b03eeb74ec4e..7c84c115ee05 100644 --- a/lldb/include/lldb/Host/OptionParser.h +++ b/lldb/include/lldb/Host/OptionParser.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef liblldb_OptionParser_h_ -#define liblldb_OptionParser_h_ +#ifndef LLDB_HOST_OPTIONPARSER_H +#define LLDB_HOST_OPTIONPARSER_H #include <mutex> #include <string> @@ -51,4 +51,4 @@ public: }; } -#endif // liblldb_OptionParser_h_ +#endif // LLDB_HOST_OPTIONPARSER_H diff --git a/lldb/include/lldb/Host/Pipe.h b/lldb/include/lldb/Host/Pipe.h index ea75342e5427..06daf1f6dd90 100644 --- a/lldb/include/lldb/Host/Pipe.h +++ b/lldb/include/lldb/Host/Pipe.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef liblldb_Host_Pipe_h_ -#define liblldb_Host_Pipe_h_ +#ifndef LLDB_HOST_PIPE_H +#define LLDB_HOST_PIPE_H #if defined(_WIN32) #include "lldb/Host/windows/PipeWindows.h" @@ -21,4 +21,4 @@ typedef PipePosix Pipe; } #endif -#endif // liblldb_Host_Pipe_h_ +#endif // LLDB_HOST_PIPE_H diff --git a/lldb/include/lldb/Host/PipeBase.h b/lldb/include/lldb/Host/PipeBase.h index 1aa4db339b29..48c19b899cef 100644 --- a/lldb/include/lldb/Host/PipeBase.h +++ b/lldb/include/lldb/Host/PipeBase.h @@ -7,8 +7,8 @@ // //===----------------------------------------------------------------------===// -#ifndef liblldb_Host_PipeBase_h_ -#define liblldb_Host_PipeBase_h_ +#ifndef LLDB_HOST_PIPEBASE_H +#define LLDB_HOST_PIPEBASE_H #include <chrono> #include <string> diff --git a/lldb/include/lldb/Host/PosixApi.h b/lldb/include/lldb/Host/PosixApi.h index 04ca3a84983b..4cbbd628157a 100644 --- a/lldb/include/lldb/Host/PosixApi.h +++ b/lldb/include/lldb/Host/PosixApi.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef liblldb_Host_PosixApi_h -#define liblldb_Host_PosixApi_h +#ifndef LLDB_HOST_POSIXAPI_H +#define LLDB_HOST_POSIXAPI_H // This file defines platform specific functions, macros, and types necessary // to provide a minimum level of compatibility across all platforms to rely on diff --git a/lldb/include/lldb/Host/ProcessLaunchInfo.h b/lldb/include/lldb/Host/ProcessLaunchInfo.h index d068aa636bc7..e83d8396e9f2 100644 --- a/lldb/include/lldb/Host/ProcessLaunchInfo.h +++ b/lldb/include/lldb/Host/ProcessLaunchInfo.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef liblldb_ProcessLaunch_Info_h -#define liblldb_ProcessLaunch_Info_h +#ifndef LLDB_HOST_PROCESSLAUNCHINFO_H +#define LLDB_HOST_PROCESSLAUNCHINFO_H // C++ Headers #include <string> @@ -165,4 +165,4 @@ protected: }; } -#endif // liblldb_ProcessLaunch_Info_h +#endif // LLDB_HOST_PROCESSLAUNCHINFO_H diff --git a/lldb/include/lldb/Host/ProcessLauncher.h b/lldb/include/lldb/Host/ProcessLauncher.h index a5b6a6c76bba..9467b2c009b7 100644 --- a/lldb/include/lldb/Host/ProcessLauncher.h +++ b/lldb/include/lldb/Host/ProcessLauncher.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef lldb_Host_ProcessLauncher_h_ -#define lldb_Host_ProcessLauncher_h_ +#ifndef LLDB_HOST_PROCESSLAUNCHER_H +#define LLDB_HOST_PROCESSLAUNCHER_H namespace lldb_private { diff --git a/lldb/include/lldb/Host/ProcessRunLock.h b/lldb/include/lldb/Host/ProcessRunLock.h index 4927fbbf7821..43463d144de3 100644 --- a/lldb/include/lldb/Host/ProcessRunLock.h +++ b/lldb/include/lldb/Host/ProcessRunLock.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef liblldb_ProcessRunLock_h_ -#define liblldb_ProcessRunLock_h_ +#ifndef LLDB_HOST_PROCESSRUNLOCK_H +#define LLDB_HOST_PROCESSRUNLOCK_H #include <stdint.h> #include <time.h> @@ -67,7 +67,8 @@ public: ProcessRunLock *m_lock; private: - DISALLOW_COPY_AND_ASSIGN(ProcessRunLocker); + ProcessRunLocker(const ProcessRunLocker &) = delete; + const ProcessRunLocker &operator=(const ProcessRunLocker &) = delete; }; protected: @@ -75,9 +76,10 @@ protected: bool m_running; private: - DISALLOW_COPY_AND_ASSIGN(ProcessRunLock); + ProcessRunLock(const ProcessRunLock &) = delete; + const ProcessRunLock &operator=(const ProcessRunLock &) = delete; }; } // namespace lldb_private -#endif // liblldb_ProcessRunLock_h_ +#endif // LLDB_HOST_PROCESSRUNLOCK_H diff --git a/lldb/include/lldb/Host/PseudoTerminal.h b/lldb/include/lldb/Host/PseudoTerminal.h index 18679b6fcdd9..8a5a233e7748 100644 --- a/lldb/include/lldb/Host/PseudoTerminal.h +++ b/lldb/include/lldb/Host/PseudoTerminal.h @@ -29,36 +29,37 @@ public: /// Default constructor /// - /// Constructs this object with invalid master and slave file descriptors. + /// Constructs this object with invalid primary and secondary 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 + /// The destructor will close the primary and secondary file descriptors if + /// they are valid and ownership has not been released using one of: @li + /// PseudoTerminal::ReleasePrimaryFileDescriptor() @li /// PseudoTerminal::ReleaseSaveFileDescriptor() ~PseudoTerminal(); - /// Close the master file descriptor if it is valid. - void CloseMasterFileDescriptor(); + /// Close the primary file descriptor if it is valid. + void ClosePrimaryFileDescriptor(); - /// Close the slave file descriptor if it is valid. - void CloseSlaveFileDescriptor(); + /// Close the secondary file descriptor if it is valid. + void CloseSecondaryFileDescriptor(); /// Fork a child process that uses pseudo terminals for its stdio. /// /// In the parent process, a call to this function results in a pid being - /// returned. If the pid is valid, the master file descriptor can be used + /// returned. If the pid is valid, the primary file descriptor can be used /// for read/write access to stdio of the child process. /// /// In the child process the stdin/stdout/stderr will already be routed to - /// the slave pseudo terminal and the master file descriptor will be closed - /// as it is no longer needed by the child process. + /// the secondary pseudo terminal and the primary file descriptor will be + /// closed as it is no longer needed by the child process. /// - /// This class will close the file descriptors for the master/slave when the - /// destructor is called. The file handles can be released using either: @li - /// PseudoTerminal::ReleaseMasterFileDescriptor() @li + /// This class will close the file descriptors for the primary/secondary when + /// the destructor is called. The file handles can be released using either: + /// @li PseudoTerminal::ReleasePrimaryFileDescriptor() @li /// PseudoTerminal::ReleaseSaveFileDescriptor() /// /// \param[out] error_str @@ -71,37 +72,37 @@ public: /// \b Child process: zero. lldb::pid_t Fork(char *error_str, size_t error_len); - /// The master file descriptor accessor. + /// The primary file descriptor accessor. /// - /// This object retains ownership of the master file descriptor when this + /// This object retains ownership of the primary file descriptor when this /// accessor is used. Users can call the member function - /// PseudoTerminal::ReleaseMasterFileDescriptor() if this object should - /// release ownership of the slave file descriptor. + /// PseudoTerminal::ReleasePrimaryFileDescriptor() if this object should + /// release ownership of the secondary file descriptor. /// /// \return - /// The master file descriptor, or PseudoTerminal::invalid_fd - /// if the master file descriptor is not currently valid. + /// The primary file descriptor, or PseudoTerminal::invalid_fd + /// if the primary file descriptor is not currently valid. /// - /// \see PseudoTerminal::ReleaseMasterFileDescriptor() - int GetMasterFileDescriptor() const; + /// \see PseudoTerminal::ReleasePrimaryFileDescriptor() + int GetPrimaryFileDescriptor() const; - /// The slave file descriptor accessor. + /// The secondary file descriptor accessor. /// - /// This object retains ownership of the slave file descriptor when this + /// This object retains ownership of the secondary file descriptor when this /// accessor is used. Users can call the member function - /// PseudoTerminal::ReleaseSlaveFileDescriptor() if this object should - /// release ownership of the slave file descriptor. + /// PseudoTerminal::ReleaseSecondaryFileDescriptor() if this object should + /// release ownership of the secondary file descriptor. /// /// \return - /// The slave file descriptor, or PseudoTerminal::invalid_fd - /// if the slave file descriptor is not currently valid. + /// The secondary file descriptor, or PseudoTerminal::invalid_fd + /// if the secondary file descriptor is not currently valid. /// - /// \see PseudoTerminal::ReleaseSlaveFileDescriptor() - int GetSlaveFileDescriptor() const; + /// \see PseudoTerminal::ReleaseSecondaryFileDescriptor() + int GetSecondaryFileDescriptor() const; - /// Get the name of the slave pseudo terminal. + /// Get the name of the secondary pseudo terminal. /// - /// A master pseudo terminal should already be valid prior to + /// A primary pseudo terminal should already be valid prior to /// calling this function. /// /// \param[out] error_str @@ -109,27 +110,27 @@ public: /// occur. This can be NULL if no error status is desired. /// /// \return - /// The name of the slave pseudo terminal as a NULL terminated + /// The name of the secondary 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 /// this value. NULL is returned if this object doesn't have - /// a valid master pseudo terminal opened or if the call to + /// a valid primary pseudo terminal opened or if the call to /// \c ptsname() fails. /// - /// \see PseudoTerminal::OpenFirstAvailableMaster() - const char *GetSlaveName(char *error_str, size_t error_len) const; + /// \see PseudoTerminal::OpenFirstAvailablePrimary() + const char *GetSecondaryName(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 - /// permissions. The opened master file descriptor is stored in this object + /// permissions. The opened primary file descriptor is stored in this object /// and can be accessed by calling the - /// PseudoTerminal::GetMasterFileDescriptor() accessor. Clients can call the - /// PseudoTerminal::ReleaseMasterFileDescriptor() accessor function if they - /// wish to use the master file descriptor beyond the lifespan of this + /// PseudoTerminal::GetPrimaryFileDescriptor() accessor. Clients can call the + /// PseudoTerminal::ReleasePrimaryFileDescriptor() accessor function if they + /// wish to use the primary file descriptor beyond the lifespan of this /// object. /// - /// If this object still has a valid master file descriptor when its + /// If this object still has a valid primary file descriptor when its /// destructor is called, it will close it. /// /// \param[in] oflag @@ -141,25 +142,25 @@ public: /// occur. This can be NULL if no error status is desired. /// /// \return - /// \b true when the master files descriptor is + /// \b true when the primary files descriptor is /// successfully opened. /// \b false if anything goes wrong. /// - /// \see PseudoTerminal::GetMasterFileDescriptor() @see - /// PseudoTerminal::ReleaseMasterFileDescriptor() - bool OpenFirstAvailableMaster(int oflag, char *error_str, size_t error_len); + /// \see PseudoTerminal::GetPrimaryFileDescriptor() @see + /// PseudoTerminal::ReleasePrimaryFileDescriptor() + bool OpenFirstAvailablePrimary(int oflag, char *error_str, size_t error_len); - /// Open the slave for the current master pseudo terminal. + /// Open the secondary for the current primary pseudo terminal. /// - /// A master pseudo terminal should already be valid prior to - /// calling this function. The opened slave file descriptor is stored in + /// A primary pseudo terminal should already be valid prior to + /// calling this function. The opened secondary file descriptor is stored in /// this object and can be accessed by calling the - /// PseudoTerminal::GetSlaveFileDescriptor() accessor. Clients can call the - /// PseudoTerminal::ReleaseSlaveFileDescriptor() accessor function if they - /// wish to use the slave file descriptor beyond the lifespan of this + /// PseudoTerminal::GetSecondaryFileDescriptor() accessor. Clients can call + /// the PseudoTerminal::ReleaseSecondaryFileDescriptor() accessor function if + /// they wish to use the secondary file descriptor beyond the lifespan of this /// object. /// - /// If this object still has a valid slave file descriptor when its + /// If this object still has a valid secondary file descriptor when its /// destructor is called, it will close it. /// /// \param[in] oflag @@ -170,48 +171,49 @@ public: /// occur. This can be NULL if no error status is desired. /// /// \return - /// \b true when the master files descriptor is + /// \b true when the primary files descriptor is /// successfully opened. /// \b false if anything goes wrong. /// - /// \see PseudoTerminal::OpenFirstAvailableMaster() @see - /// PseudoTerminal::GetSlaveFileDescriptor() @see - /// PseudoTerminal::ReleaseSlaveFileDescriptor() - bool OpenSlave(int oflag, char *error_str, size_t error_len); + /// \see PseudoTerminal::OpenFirstAvailablePrimary() @see + /// PseudoTerminal::GetSecondaryFileDescriptor() @see + /// PseudoTerminal::ReleaseSecondaryFileDescriptor() + bool OpenSecondary(int oflag, char *error_str, size_t error_len); - /// Release the master file descriptor. + /// Release the primary file descriptor. /// - /// Releases ownership of the master pseudo terminal file descriptor without - /// closing it. The destructor for this class will close the master file + /// Releases ownership of the primary pseudo terminal file descriptor without + /// closing it. The destructor for this class will close the primary file /// descriptor if the ownership isn't released using this call and the - /// master file descriptor has been opened. + /// primary file descriptor has been opened. /// /// \return - /// The master file descriptor, or PseudoTerminal::invalid_fd + /// The primary file descriptor, or PseudoTerminal::invalid_fd /// if the mast file descriptor is not currently valid. - int ReleaseMasterFileDescriptor(); + int ReleasePrimaryFileDescriptor(); - /// Release the slave file descriptor. + /// Release the secondary file descriptor. /// - /// Release ownership of the slave pseudo terminal file descriptor without - /// closing it. The destructor for this class will close the slave file - /// descriptor if the ownership isn't released using this call and the slave - /// file descriptor has been opened. + /// Release ownership of the secondary pseudo terminal file descriptor without + /// closing it. The destructor for this class will close the secondary file + /// descriptor if the ownership isn't released using this call and the + /// secondary file descriptor has been opened. /// /// \return - /// The slave file descriptor, or PseudoTerminal::invalid_fd - /// if the slave file descriptor is not currently valid. - int ReleaseSlaveFileDescriptor(); + /// The secondary file descriptor, or PseudoTerminal::invalid_fd + /// if the secondary file descriptor is not currently valid. + int ReleaseSecondaryFileDescriptor(); protected: // Member variables - int m_master_fd; ///< The file descriptor for the master. - int m_slave_fd; ///< The file descriptor for the slave. + int m_primary_fd; ///< The file descriptor for the primary. + int m_secondary_fd; ///< The file descriptor for the secondary. private: - DISALLOW_COPY_AND_ASSIGN(PseudoTerminal); + PseudoTerminal(const PseudoTerminal &) = delete; + const PseudoTerminal &operator=(const PseudoTerminal &) = delete; }; } // namespace lldb_private -#endif // #ifndef liblldb_PseudoTerminal_h_ +#endif // LLDB_HOST_PSEUDOTERMINAL_H diff --git a/lldb/include/lldb/Host/SafeMachO.h b/lldb/include/lldb/Host/SafeMachO.h index ec9887ececd5..d7c376d23a4a 100644 --- a/lldb/include/lldb/Host/SafeMachO.h +++ b/lldb/include/lldb/Host/SafeMachO.h @@ -5,8 +5,8 @@ // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// -#ifndef liblldb_SafeMachO_h_ -#define liblldb_SafeMachO_h_ +#ifndef LLDB_HOST_SAFEMACHO_H +#define LLDB_HOST_SAFEMACHO_H // This header file is required to work around collisions between the defines // in mach/machine.h, and enum members of the same name in llvm's MachO.h. If @@ -112,4 +112,4 @@ #include "llvm/BinaryFormat/MachO.h" -#endif // liblldb_SafeMachO_h_ +#endif // LLDB_HOST_SAFEMACHO_H diff --git a/lldb/include/lldb/Host/Socket.h b/lldb/include/lldb/Host/Socket.h index c6df5634e24e..36db0ec63e9d 100644 --- a/lldb/include/lldb/Host/Socket.h +++ b/lldb/include/lldb/Host/Socket.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef liblldb_Host_Socket_h_ -#define liblldb_Host_Socket_h_ +#ifndef LLDB_HOST_SOCKET_H +#define LLDB_HOST_SOCKET_H #include <memory> #include <string> @@ -36,6 +36,8 @@ typedef SOCKET NativeSocket; #else typedef int NativeSocket; #endif +class TCPSocket; +class UDPSocket; class Socket : public IOObject { public: @@ -64,13 +66,16 @@ public: // Initialize a Tcp Socket object in listening mode. listen and accept are // implemented separately because the caller may wish to manipulate or query // the socket after it is initialized, but before entering a blocking accept. - static Status TcpListen(llvm::StringRef host_and_port, - bool child_processes_inherit, Socket *&socket, - Predicate<uint16_t> *predicate, int backlog = 5); - static Status TcpConnect(llvm::StringRef host_and_port, - bool child_processes_inherit, Socket *&socket); - static Status UdpConnect(llvm::StringRef host_and_port, - bool child_processes_inherit, Socket *&socket); + static llvm::Expected<std::unique_ptr<TCPSocket>> + TcpListen(llvm::StringRef host_and_port, bool child_processes_inherit, + Predicate<uint16_t> *predicate, int backlog = 5); + + static llvm::Expected<std::unique_ptr<Socket>> + TcpConnect(llvm::StringRef host_and_port, bool child_processes_inherit); + + static llvm::Expected<std::unique_ptr<UDPSocket>> + UdpConnect(llvm::StringRef host_and_port, bool child_processes_inherit); + static Status UnixDomainConnect(llvm::StringRef host_and_port, bool child_processes_inherit, Socket *&socket); @@ -127,4 +132,4 @@ protected: } // namespace lldb_private -#endif // liblldb_Host_Socket_h_ +#endif // LLDB_HOST_SOCKET_H diff --git a/lldb/include/lldb/Host/SocketAddress.h b/lldb/include/lldb/Host/SocketAddress.h index 766303a3c1fd..862e1104a084 100644 --- a/lldb/include/lldb/Host/SocketAddress.h +++ b/lldb/include/lldb/Host/SocketAddress.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef liblldb_SocketAddress_h_ -#define liblldb_SocketAddress_h_ +#ifndef LLDB_HOST_SOCKETADDRESS_H +#define LLDB_HOST_SOCKETADDRESS_H #include <stdint.h> @@ -185,4 +185,4 @@ protected: } // namespace lldb_private -#endif // liblldb_SocketAddress_h_ +#endif // LLDB_HOST_SOCKETADDRESS_H diff --git a/lldb/include/lldb/Host/StringConvert.h b/lldb/include/lldb/Host/StringConvert.h index 4b2c6901a96b..ad629ff30429 100644 --- a/lldb/include/lldb/Host/StringConvert.h +++ b/lldb/include/lldb/Host/StringConvert.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef liblldb_StringConvert_h_ -#define liblldb_StringConvert_h_ +#ifndef LLDB_HOST_STRINGCONVERT_H +#define LLDB_HOST_STRINGCONVERT_H #include <stdint.h> diff --git a/lldb/include/lldb/Host/TaskPool.h b/lldb/include/lldb/Host/TaskPool.h deleted file mode 100644 index 49805ce193ed..000000000000 --- a/lldb/include/lldb/Host/TaskPool.h +++ /dev/null @@ -1,92 +0,0 @@ -//===--------------------- TaskPool.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 utility_TaskPool_h_ -#define utility_TaskPool_h_ - -#include "llvm/ADT/STLExtras.h" -#include <functional> -#include <future> -#include <list> -#include <memory> -#include <mutex> -#include <type_traits> - -namespace lldb_private { - -// Global TaskPool class for running tasks in parallel on a set of worker -// thread created the first time the task pool is used. The TaskPool provide no -// guarantee about the order the task will be run and about what tasks will run -// in parallel. None of the task added to the task pool should block on -// something (mutex, future, condition variable) what will be set only by the -// completion of an other task on the task pool as they may run on the same -// thread sequentally. -class TaskPool { -public: - // Add a new task to the task pool and return a std::future belonging to the - // newly created task. The caller of this function has to wait on the future - // for this task to complete. - template <typename F, typename... Args> - static std::future<typename std::result_of<F(Args...)>::type> - AddTask(F &&f, Args &&... args); - - // Run all of the specified tasks on the task pool and wait until all of them - // are finished before returning. This method is intended to be used for - // small number tasks where listing them as function arguments is acceptable. - // For running large number of tasks you should use AddTask for each task and - // then call wait() on each returned future. - template <typename... T> static void RunTasks(T &&... tasks); - -private: - TaskPool() = delete; - - template <typename... T> struct RunTaskImpl; - - static void AddTaskImpl(std::function<void()> &&task_fn); -}; - -template <typename F, typename... Args> -std::future<typename std::result_of<F(Args...)>::type> -TaskPool::AddTask(F &&f, Args &&... args) { - auto task_sp = std::make_shared< - std::packaged_task<typename std::result_of<F(Args...)>::type()>>( - std::bind(std::forward<F>(f), std::forward<Args>(args)...)); - - AddTaskImpl([task_sp]() { (*task_sp)(); }); - - return task_sp->get_future(); -} - -template <typename... T> void TaskPool::RunTasks(T &&... tasks) { - RunTaskImpl<T...>::Run(std::forward<T>(tasks)...); -} - -template <typename Head, typename... Tail> -struct TaskPool::RunTaskImpl<Head, Tail...> { - static void Run(Head &&h, Tail &&... t) { - auto f = AddTask(std::forward<Head>(h)); - RunTaskImpl<Tail...>::Run(std::forward<Tail>(t)...); - f.wait(); - } -}; - -template <> struct TaskPool::RunTaskImpl<> { - static void Run() {} -}; - -// Run 'func' on every value from begin .. end-1. Each worker will grab -// 'batch_size' numbers at a time to work on, so for very fast functions, batch -// should be large enough to avoid too much cache line contention. -void TaskMapOverInt(size_t begin, size_t end, - const llvm::function_ref<void(size_t)> &func); - -unsigned GetHardwareConcurrencyHint(); - -} // namespace lldb_private - -#endif // #ifndef utility_TaskPool_h_ diff --git a/lldb/include/lldb/Host/Terminal.h b/lldb/include/lldb/Host/Terminal.h index 671f8d63f89f..61993223ea06 100644 --- a/lldb/include/lldb/Host/Terminal.h +++ b/lldb/include/lldb/Host/Terminal.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef liblldb_Terminal_h_ -#define liblldb_Terminal_h_ +#ifndef LLDB_HOST_TERMINAL_H +#define LLDB_HOST_TERMINAL_H #if defined(__cplusplus) #include "lldb/Host/Config.h" @@ -179,4 +179,4 @@ protected: } // namespace lldb_private #endif // #if defined(__cplusplus) -#endif // #ifndef liblldb_Terminal_h_ +#endif // LLDB_HOST_TERMINAL_H diff --git a/lldb/include/lldb/Host/ThreadLauncher.h b/lldb/include/lldb/Host/ThreadLauncher.h index e45ffa9df757..00b42fa6a11d 100644 --- a/lldb/include/lldb/Host/ThreadLauncher.h +++ b/lldb/include/lldb/Host/ThreadLauncher.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef lldb_Host_ThreadLauncher_h_ -#define lldb_Host_ThreadLauncher_h_ +#ifndef LLDB_HOST_THREADLAUNCHER_H +#define LLDB_HOST_THREADLAUNCHER_H #include "lldb/Host/HostThread.h" #include "lldb/lldb-types.h" diff --git a/lldb/include/lldb/Host/Time.h b/lldb/include/lldb/Host/Time.h index b27eb082167e..83b76ec0f9d1 100644 --- a/lldb/include/lldb/Host/Time.h +++ b/lldb/include/lldb/Host/Time.h @@ -8,8 +8,8 @@ // Include system time headers, adding missing functions as necessary -#ifndef liblldb_Host_Time_h_ -#define liblldb_Host_Time_h_ +#ifndef LLDB_HOST_TIME_H +#define LLDB_HOST_TIME_H #ifdef __ANDROID__ #include <android/api-level.h> @@ -22,4 +22,4 @@ extern time_t timegm(struct tm *t); #include <time.h> #endif -#endif // liblldb_Host_Time_h_ +#endif // LLDB_HOST_TIME_H diff --git a/lldb/include/lldb/Host/XML.h b/lldb/include/lldb/Host/XML.h index ca51d304dc8f..a80f1e9e4d26 100644 --- a/lldb/include/lldb/Host/XML.h +++ b/lldb/include/lldb/Host/XML.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef liblldb_XML_h_ -#define liblldb_XML_h_ +#ifndef LLDB_HOST_XML_H +#define LLDB_HOST_XML_H #include "lldb/Host/Config.h" @@ -179,4 +179,4 @@ protected: } // namespace lldb_private -#endif // liblldb_XML_h_ +#endif // LLDB_HOST_XML_H diff --git a/lldb/include/lldb/Host/common/GetOptInc.h b/lldb/include/lldb/Host/common/GetOptInc.h index c69f7227a5cf..3fb9add47954 100644 --- a/lldb/include/lldb/Host/common/GetOptInc.h +++ b/lldb/include/lldb/Host/common/GetOptInc.h @@ -1,4 +1,13 @@ -#pragma once +//===-- GetOptInc.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_HOST_COMMON_GETOPTINC_H +#define LLDB_HOST_COMMON_GETOPTINC_H #include "lldb/lldb-defines.h" @@ -50,3 +59,5 @@ int getopt_long(int argc, char *const *argv, const char *optstring, int getopt_long_only(int argc, char *const *argv, const char *optstring, const struct option *longopts, int *longindex); #endif + +#endif // LLDB_HOST_COMMON_GETOPTINC_H diff --git a/lldb/include/lldb/Host/common/NativeBreakpointList.h b/lldb/include/lldb/Host/common/NativeBreakpointList.h index c2725b2df959..21d2f096370a 100644 --- a/lldb/include/lldb/Host/common/NativeBreakpointList.h +++ b/lldb/include/lldb/Host/common/NativeBreakpointList.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef liblldb_NativeBreakpointList_h_ -#define liblldb_NativeBreakpointList_h_ +#ifndef LLDB_HOST_COMMON_NATIVEBREAKPOINTLIST_H +#define LLDB_HOST_COMMON_NATIVEBREAKPOINTLIST_H #include "lldb/lldb-private-forward.h" #include "lldb/lldb-types.h" @@ -23,4 +23,4 @@ struct HardwareBreakpoint { using HardwareBreakpointMap = std::map<lldb::addr_t, HardwareBreakpoint>; } -#endif // ifndef liblldb_NativeBreakpointList_h_ +#endif // LLDB_HOST_COMMON_NATIVEBREAKPOINTLIST_H diff --git a/lldb/include/lldb/Host/common/NativeProcessProtocol.h b/lldb/include/lldb/Host/common/NativeProcessProtocol.h index 2d48717c4fbb..2faab6f587cd 100644 --- a/lldb/include/lldb/Host/common/NativeProcessProtocol.h +++ b/lldb/include/lldb/Host/common/NativeProcessProtocol.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef liblldb_NativeProcessProtocol_h_ -#define liblldb_NativeProcessProtocol_h_ +#ifndef LLDB_HOST_COMMON_NATIVEPROCESSPROTOCOL_H +#define LLDB_HOST_COMMON_NATIVEPROCESSPROTOCOL_H #include "NativeBreakpointList.h" #include "NativeThreadProtocol.h" @@ -379,16 +379,10 @@ public: /// \param[in] traceid /// The user id of the tracing instance. /// - /// \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 - /// Status indicates what went wrong. - /// /// \param[out] config - /// The actual configuration being used for tracing. + /// The configuration being used for tracing. + /// + /// \return A status indicating what went wrong. virtual Status GetTraceConfig(lldb::user_id_t traceid, TraceOptions &config) { return Status("Not implemented"); } @@ -475,4 +469,4 @@ private: }; } // namespace lldb_private -#endif // #ifndef liblldb_NativeProcessProtocol_h_ +#endif // LLDB_HOST_COMMON_NATIVEPROCESSPROTOCOL_H diff --git a/lldb/include/lldb/Host/common/NativeRegisterContext.h b/lldb/include/lldb/Host/common/NativeRegisterContext.h index 6bba8f2a5d29..3b54d4ae1e05 100644 --- a/lldb/include/lldb/Host/common/NativeRegisterContext.h +++ b/lldb/include/lldb/Host/common/NativeRegisterContext.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef liblldb_NativeRegisterContext_h_ -#define liblldb_NativeRegisterContext_h_ +#ifndef LLDB_HOST_COMMON_NATIVEREGISTERCONTEXT_H +#define LLDB_HOST_COMMON_NATIVEREGISTERCONTEXT_H #include "lldb/Host/common/NativeWatchpointList.h" #include "lldb/lldb-private.h" @@ -170,9 +170,11 @@ protected: private: // For RegisterContext only - DISALLOW_COPY_AND_ASSIGN(NativeRegisterContext); + NativeRegisterContext(const NativeRegisterContext &) = delete; + const NativeRegisterContext & + operator=(const NativeRegisterContext &) = delete; }; } // namespace lldb_private -#endif // liblldb_NativeRegisterContext_h_ +#endif // LLDB_HOST_COMMON_NATIVEREGISTERCONTEXT_H diff --git a/lldb/include/lldb/Host/common/NativeThreadProtocol.h b/lldb/include/lldb/Host/common/NativeThreadProtocol.h index 36ae67933f53..8d4c03549bb9 100644 --- a/lldb/include/lldb/Host/common/NativeThreadProtocol.h +++ b/lldb/include/lldb/Host/common/NativeThreadProtocol.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef liblldb_NativeThreadProtocol_h_ -#define liblldb_NativeThreadProtocol_h_ +#ifndef LLDB_HOST_COMMON_NATIVETHREADPROTOCOL_H +#define LLDB_HOST_COMMON_NATIVETHREADPROTOCOL_H #include <memory> @@ -53,4 +53,4 @@ protected: }; } -#endif // #ifndef liblldb_NativeThreadProtocol_h_ +#endif // LLDB_HOST_COMMON_NATIVETHREADPROTOCOL_H diff --git a/lldb/include/lldb/Host/common/NativeWatchpointList.h b/lldb/include/lldb/Host/common/NativeWatchpointList.h index c83ba1eaadca..66f93bf1c8f7 100644 --- a/lldb/include/lldb/Host/common/NativeWatchpointList.h +++ b/lldb/include/lldb/Host/common/NativeWatchpointList.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef liblldb_NativeWatchpointList_h_ -#define liblldb_NativeWatchpointList_h_ +#ifndef LLDB_HOST_COMMON_NATIVEWATCHPOINTLIST_H +#define LLDB_HOST_COMMON_NATIVEWATCHPOINTLIST_H #include "lldb/Utility/Status.h" #include "lldb/lldb-private-forward.h" @@ -38,4 +38,4 @@ private: }; } -#endif // ifndef liblldb_NativeWatchpointList_h_ +#endif // LLDB_HOST_COMMON_NATIVEWATCHPOINTLIST_H diff --git a/lldb/include/lldb/Host/common/TCPSocket.h b/lldb/include/lldb/Host/common/TCPSocket.h index faf3bb693c32..b782c9e6096c 100644 --- a/lldb/include/lldb/Host/common/TCPSocket.h +++ b/lldb/include/lldb/Host/common/TCPSocket.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef liblldb_TCPSocket_h_ -#define liblldb_TCPSocket_h_ +#ifndef LLDB_HOST_COMMON_TCPSOCKET_H +#define LLDB_HOST_COMMON_TCPSOCKET_H #include "lldb/Host/Socket.h" #include "lldb/Host/SocketAddress.h" @@ -57,4 +57,4 @@ private: }; } -#endif // ifndef liblldb_TCPSocket_h_ +#endif // LLDB_HOST_COMMON_TCPSOCKET_H diff --git a/lldb/include/lldb/Host/common/UDPSocket.h b/lldb/include/lldb/Host/common/UDPSocket.h index b7b6db67d10d..bae707e345d8 100644 --- a/lldb/include/lldb/Host/common/UDPSocket.h +++ b/lldb/include/lldb/Host/common/UDPSocket.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef liblldb_UDPSocket_h_ -#define liblldb_UDPSocket_h_ +#ifndef LLDB_HOST_COMMON_UDPSOCKET_H +#define LLDB_HOST_COMMON_UDPSOCKET_H #include "lldb/Host/Socket.h" @@ -16,8 +16,8 @@ class UDPSocket : public Socket { public: UDPSocket(bool should_close, bool child_processes_inherit); - static Status Connect(llvm::StringRef name, bool child_processes_inherit, - Socket *&socket); + static llvm::Expected<std::unique_ptr<UDPSocket>> + Connect(llvm::StringRef name, bool child_processes_inherit); std::string GetRemoteConnectionURI() const override; @@ -33,4 +33,4 @@ private: }; } -#endif // ifndef liblldb_UDPSocket_h_ +#endif // LLDB_HOST_COMMON_UDPSOCKET_H diff --git a/lldb/include/lldb/Host/posix/ConnectionFileDescriptorPosix.h b/lldb/include/lldb/Host/posix/ConnectionFileDescriptorPosix.h index b25fc47c56b6..3ee8f9d9133e 100644 --- a/lldb/include/lldb/Host/posix/ConnectionFileDescriptorPosix.h +++ b/lldb/include/lldb/Host/posix/ConnectionFileDescriptorPosix.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef liblldb_Host_posix_ConnectionFileDescriptorPosix_h_ -#define liblldb_Host_posix_ConnectionFileDescriptorPosix_h_ +#ifndef LLDB_HOST_POSIX_CONNECTIONFILEDESCRIPTORPOSIX_H +#define LLDB_HOST_POSIX_CONNECTIONFILEDESCRIPTORPOSIX_H #include <atomic> #include <memory> @@ -116,9 +116,11 @@ protected: private: void InitializeSocket(Socket *socket); - DISALLOW_COPY_AND_ASSIGN(ConnectionFileDescriptor); + ConnectionFileDescriptor(const ConnectionFileDescriptor &) = delete; + const ConnectionFileDescriptor & + operator=(const ConnectionFileDescriptor &) = delete; }; } // namespace lldb_private -#endif // liblldb_ConnectionFileDescriptor_h_ +#endif // LLDB_HOST_POSIX_CONNECTIONFILEDESCRIPTORPOSIX_H diff --git a/lldb/include/lldb/Host/posix/DomainSocket.h b/lldb/include/lldb/Host/posix/DomainSocket.h index e407ce16bbcb..35c33811f60d 100644 --- a/lldb/include/lldb/Host/posix/DomainSocket.h +++ b/lldb/include/lldb/Host/posix/DomainSocket.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef liblldb_DomainSocket_h_ -#define liblldb_DomainSocket_h_ +#ifndef LLDB_HOST_POSIX_DOMAINSOCKET_H +#define LLDB_HOST_POSIX_DOMAINSOCKET_H #include "lldb/Host/Socket.h" @@ -34,4 +34,4 @@ private: }; } -#endif // ifndef liblldb_DomainSocket_h_ +#endif // LLDB_HOST_POSIX_DOMAINSOCKET_H diff --git a/lldb/include/lldb/Host/posix/HostInfoPosix.h b/lldb/include/lldb/Host/posix/HostInfoPosix.h index 26910132f3c8..825c79f53ecb 100644 --- a/lldb/include/lldb/Host/posix/HostInfoPosix.h +++ b/lldb/include/lldb/Host/posix/HostInfoPosix.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef lldb_Host_posix_HostInfoPosix_h_ -#define lldb_Host_posix_HostInfoPosix_h_ +#ifndef LLDB_HOST_POSIX_HOSTINFOPOSIX_H +#define LLDB_HOST_POSIX_HOSTINFOPOSIX_H #include "lldb/Host/HostInfoBase.h" #include "lldb/Utility/FileSpec.h" diff --git a/lldb/include/lldb/Host/posix/HostProcessPosix.h b/lldb/include/lldb/Host/posix/HostProcessPosix.h index a313358631b5..5def1b77eefe 100644 --- a/lldb/include/lldb/Host/posix/HostProcessPosix.h +++ b/lldb/include/lldb/Host/posix/HostProcessPosix.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef lldb_Host_HostProcesPosix_h_ -#define lldb_Host_HostProcesPosix_h_ +#ifndef LLDB_HOST_POSIX_HOSTPROCESSPOSIX_H +#define LLDB_HOST_POSIX_HOSTPROCESSPOSIX_H #include "lldb/Host/HostNativeProcessBase.h" #include "lldb/Utility/Status.h" @@ -39,4 +39,4 @@ public: } // namespace lldb_private -#endif // lldb_Host_HostProcesPosix_h_ +#endif // LLDB_HOST_POSIX_HOSTPROCESSPOSIX_H diff --git a/lldb/include/lldb/Host/posix/HostThreadPosix.h b/lldb/include/lldb/Host/posix/HostThreadPosix.h index 54012e15ad99..6c8e09fc1103 100644 --- a/lldb/include/lldb/Host/posix/HostThreadPosix.h +++ b/lldb/include/lldb/Host/posix/HostThreadPosix.h @@ -6,15 +6,16 @@ // //===----------------------------------------------------------------------===// -#ifndef lldb_Host_posix_HostThreadPosix_h_ -#define lldb_Host_posix_HostThreadPosix_h_ +#ifndef LLDB_HOST_POSIX_HOSTTHREADPOSIX_H +#define LLDB_HOST_POSIX_HOSTTHREADPOSIX_H #include "lldb/Host/HostNativeThreadBase.h" namespace lldb_private { class HostThreadPosix : public HostNativeThreadBase { - DISALLOW_COPY_AND_ASSIGN(HostThreadPosix); + HostThreadPosix(const HostThreadPosix &) = delete; + const HostThreadPosix &operator=(const HostThreadPosix &) = delete; public: HostThreadPosix(); @@ -29,4 +30,4 @@ public: } // namespace lldb_private -#endif // lldb_Host_posix_HostThreadPosix_h_ +#endif // LLDB_HOST_POSIX_HOSTTHREADPOSIX_H diff --git a/lldb/include/lldb/Host/posix/LockFilePosix.h b/lldb/include/lldb/Host/posix/LockFilePosix.h index 63333bff4cd3..870f9a2f525d 100644 --- a/lldb/include/lldb/Host/posix/LockFilePosix.h +++ b/lldb/include/lldb/Host/posix/LockFilePosix.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef liblldb_Host_posix_LockFilePosix_h_ -#define liblldb_Host_posix_LockFilePosix_h_ +#ifndef LLDB_HOST_POSIX_LOCKFILEPOSIX_H +#define LLDB_HOST_POSIX_LOCKFILEPOSIX_H #include "lldb/Host/LockFileBase.h" @@ -32,4 +32,4 @@ protected: } // namespace lldb_private -#endif // liblldb_Host_posix_LockFilePosix_h_ +#endif // LLDB_HOST_POSIX_LOCKFILEPOSIX_H diff --git a/lldb/include/lldb/Host/posix/PipePosix.h b/lldb/include/lldb/Host/posix/PipePosix.h index df341f2fc895..77c0e2f7ef49 100644 --- a/lldb/include/lldb/Host/posix/PipePosix.h +++ b/lldb/include/lldb/Host/posix/PipePosix.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef liblldb_Host_posix_PipePosix_h_ -#define liblldb_Host_posix_PipePosix_h_ +#ifndef LLDB_HOST_POSIX_PIPEPOSIX_H +#define LLDB_HOST_POSIX_PIPEPOSIX_H #if defined(__cplusplus) #include "lldb/Host/PipeBase.h" @@ -77,4 +77,4 @@ private: } // namespace lldb_private #endif // #if defined(__cplusplus) -#endif // liblldb_Host_posix_PipePosix_h_ +#endif // LLDB_HOST_POSIX_PIPEPOSIX_H diff --git a/lldb/include/lldb/Host/posix/ProcessLauncherPosixFork.h b/lldb/include/lldb/Host/posix/ProcessLauncherPosixFork.h index 15e2d6d23b8e..427fb5b4f483 100644 --- a/lldb/include/lldb/Host/posix/ProcessLauncherPosixFork.h +++ b/lldb/include/lldb/Host/posix/ProcessLauncherPosixFork.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef lldb_Host_posix_ProcessLauncherPosixFork_h_ -#define lldb_Host_posix_ProcessLauncherPosixFork_h_ +#ifndef LLDB_HOST_POSIX_PROCESSLAUNCHERPOSIXFORK_H +#define LLDB_HOST_POSIX_PROCESSLAUNCHERPOSIXFORK_H #include "lldb/Host/ProcessLauncher.h" diff --git a/lldb/include/lldb/Initialization/SystemInitializer.h b/lldb/include/lldb/Initialization/SystemInitializer.h index e616ad1ee811..4426bfb224e3 100644 --- a/lldb/include/lldb/Initialization/SystemInitializer.h +++ b/lldb/include/lldb/Initialization/SystemInitializer.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef LLDB_INITIALIZATION_SYSTEM_INITIALIZER_H -#define LLDB_INITIALIZATION_SYSTEM_INITIALIZER_H +#ifndef LLDB_INITIALIZATION_SYSTEMINITIALIZER_H +#define LLDB_INITIALIZATION_SYSTEMINITIALIZER_H #include "llvm/Support/Error.h" diff --git a/lldb/include/lldb/Initialization/SystemInitializerCommon.h b/lldb/include/lldb/Initialization/SystemInitializerCommon.h index ad7e58e50bbe..3a5081680879 100644 --- a/lldb/include/lldb/Initialization/SystemInitializerCommon.h +++ b/lldb/include/lldb/Initialization/SystemInitializerCommon.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef LLDB_INITIALIZATION_SYSTEM_INITIALIZER_COMMON_H -#define LLDB_INITIALIZATION_SYSTEM_INITIALIZER_COMMON_H +#ifndef LLDB_INITIALIZATION_SYSTEMINITIALIZERCOMMON_H +#define LLDB_INITIALIZATION_SYSTEMINITIALIZERCOMMON_H #include "SystemInitializer.h" @@ -31,4 +31,4 @@ public: } // namespace lldb_private -#endif // LLDB_INITIALIZATION_SYSTEM_INITIALIZER_COMMON_H +#endif // LLDB_INITIALIZATION_SYSTEMINITIALIZERCOMMON_H diff --git a/lldb/include/lldb/Initialization/SystemLifetimeManager.h b/lldb/include/lldb/Initialization/SystemLifetimeManager.h index 2e99b86dbdbd..27e1a22b19dd 100644 --- a/lldb/include/lldb/Initialization/SystemLifetimeManager.h +++ b/lldb/include/lldb/Initialization/SystemLifetimeManager.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef LLDB_INITIALIZATION_SYSTEM_LIFETIME_MANAGER_H -#define LLDB_INITIALIZATION_SYSTEM_LIFETIME_MANAGER_H +#ifndef LLDB_INITIALIZATION_SYSTEMLIFETIMEMANAGER_H +#define LLDB_INITIALIZATION_SYSTEMLIFETIMEMANAGER_H #include "lldb/Initialization/SystemInitializer.h" #include "lldb/lldb-private-types.h" diff --git a/lldb/include/lldb/Interpreter/CommandAlias.h b/lldb/include/lldb/Interpreter/CommandAlias.h index 1e186d77f8e6..26826db62705 100644 --- a/lldb/include/lldb/Interpreter/CommandAlias.h +++ b/lldb/include/lldb/Interpreter/CommandAlias.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef liblldb_CommandAlias_h_ -#define liblldb_CommandAlias_h_ +#ifndef LLDB_INTERPRETER_COMMANDALIAS_H +#define LLDB_INTERPRETER_COMMANDALIAS_H #include <memory> @@ -81,4 +81,4 @@ private: }; } // namespace lldb_private -#endif // liblldb_CommandAlias_h_ +#endif // LLDB_INTERPRETER_COMMANDALIAS_H diff --git a/lldb/include/lldb/Interpreter/CommandCompletions.h b/lldb/include/lldb/Interpreter/CommandCompletions.h index 275cc7e7c145..39d1c98eaa39 100644 --- a/lldb/include/lldb/Interpreter/CommandCompletions.h +++ b/lldb/include/lldb/Interpreter/CommandCompletions.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef lldb_CommandCompletions_h_ -#define lldb_CommandCompletions_h_ +#ifndef LLDB_INTERPRETER_COMMANDCOMPLETIONS_H +#define LLDB_INTERPRETER_COMMANDCOMPLETIONS_H #include <set> @@ -23,13 +23,6 @@ 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 void (*CompletionCallback)(CommandInterpreter &interpreter, - CompletionRequest &request, - // A search filter to limit the search... - lldb_private::SearchFilter *searcher); enum CommonCompletionTypes { eNoCompletion = 0u, eSourceFileCompletion = (1u << 0), @@ -41,15 +34,13 @@ public: ePlatformPluginCompletion = (1u << 6), eArchitectureCompletion = (1u << 7), eVariablePathCompletion = (1u << 8), + eRegisterCompletion = (1u << 9), + eBreakpointCompletion = (1u << 10), + eProcessPluginCompletion = (1u << 11), // This item serves two purposes. It is the last element in the enum, so // you can add custom enums starting from here in your Option class. Also // if you & in this bit the base code will not process the option. - eCustomCompletion = (1u << 9) - }; - - struct CommonCompletionElement { - uint32_t type; - CompletionCallback callback; + eCustomCompletion = (1u << 12) }; static bool InvokeCommonCompletionCallbacks( @@ -94,99 +85,17 @@ public: static void 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); - - ~Completer() override; - - CallbackReturn SearchCallback(SearchFilter &filter, SymbolContext &context, - Address *addr) override = 0; - - lldb::SearchDepth GetDepth() override = 0; - - virtual void DoCompletion(SearchFilter *filter) = 0; - - protected: - CommandInterpreter &m_interpreter; - CompletionRequest &m_request; - - private: - DISALLOW_COPY_AND_ASSIGN(Completer); - }; - - // SourceFileCompleter implements the source file completer - class SourceFileCompleter : public Completer { - public: - SourceFileCompleter(CommandInterpreter &interpreter, - bool include_support_files, CompletionRequest &request); - - lldb::SearchDepth GetDepth() override; - - Searcher::CallbackReturn SearchCallback(SearchFilter &filter, - SymbolContext &context, - Address *addr) override; - - void DoCompletion(SearchFilter *filter) override; - - private: - bool m_include_support_files; - FileSpecList m_matching_files; - const char *m_file_name; - const char *m_dir_name; - - DISALLOW_COPY_AND_ASSIGN(SourceFileCompleter); - }; - - // ModuleCompleter implements the module completer - class ModuleCompleter : public Completer { - public: - ModuleCompleter(CommandInterpreter &interpreter, - CompletionRequest &request); - - lldb::SearchDepth GetDepth() override; - - Searcher::CallbackReturn SearchCallback(SearchFilter &filter, - SymbolContext &context, - Address *addr) override; - - void DoCompletion(SearchFilter *filter) override; - - private: - const char *m_file_name; - const char *m_dir_name; - - DISALLOW_COPY_AND_ASSIGN(ModuleCompleter); - }; - - // SymbolCompleter implements the symbol completer - class SymbolCompleter : public Completer { - public: - SymbolCompleter(CommandInterpreter &interpreter, - CompletionRequest &request); - - lldb::SearchDepth GetDepth() override; - - Searcher::CallbackReturn SearchCallback(SearchFilter &filter, - SymbolContext &context, - Address *addr) override; - - void DoCompletion(SearchFilter *filter) override; - - private: - RegularExpression m_regex; - typedef std::set<ConstString> collection; - collection m_match_set; + static void Registers(CommandInterpreter &interpreter, + CompletionRequest &request, SearchFilter *searcher); - DISALLOW_COPY_AND_ASSIGN(SymbolCompleter); - }; + static void Breakpoints(CommandInterpreter &interpreter, + CompletionRequest &request, SearchFilter *searcher); -private: - static CommonCompletionElement g_common_completions[]; + static void ProcessPluginNames(CommandInterpreter &interpreter, + CompletionRequest &request, + SearchFilter *searcher); }; } // namespace lldb_private -#endif // lldb_CommandCompletions_h_ +#endif // LLDB_INTERPRETER_COMMANDCOMPLETIONS_H diff --git a/lldb/include/lldb/Interpreter/CommandHistory.h b/lldb/include/lldb/Interpreter/CommandHistory.h index c1386f84fe2e..fbb42247f11a 100644 --- a/lldb/include/lldb/Interpreter/CommandHistory.h +++ b/lldb/include/lldb/Interpreter/CommandHistory.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef liblldb_CommandHistory_h_ -#define liblldb_CommandHistory_h_ +#ifndef LLDB_INTERPRETER_COMMANDHISTORY_H +#define LLDB_INTERPRETER_COMMANDHISTORY_H #include <mutex> #include <string> @@ -46,7 +46,8 @@ public: static const char g_repeat_char = '!'; private: - DISALLOW_COPY_AND_ASSIGN(CommandHistory); + CommandHistory(const CommandHistory &) = delete; + const CommandHistory &operator=(const CommandHistory &) = delete; typedef std::vector<std::string> History; mutable std::recursive_mutex m_mutex; @@ -55,4 +56,4 @@ private: } // namespace lldb_private -#endif // liblldb_CommandHistory_h_ +#endif // LLDB_INTERPRETER_COMMANDHISTORY_H diff --git a/lldb/include/lldb/Interpreter/CommandInterpreter.h b/lldb/include/lldb/Interpreter/CommandInterpreter.h index d08951e608cb..8a9dce7a19bc 100644 --- a/lldb/include/lldb/Interpreter/CommandInterpreter.h +++ b/lldb/include/lldb/Interpreter/CommandInterpreter.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef liblldb_CommandInterpreter_h_ -#define liblldb_CommandInterpreter_h_ +#ifndef LLDB_INTERPRETER_COMMANDINTERPRETER_H +#define LLDB_INTERPRETER_COMMANDINTERPRETER_H #include "lldb/Core/Debugger.h" #include "lldb/Core/IOHandler.h" @@ -26,6 +26,32 @@ #include <mutex> namespace lldb_private { +class CommandInterpreter; + +class CommandInterpreterRunResult { +public: + CommandInterpreterRunResult() + : m_num_errors(0), m_result(lldb::eCommandInterpreterResultSuccess) {} + + uint32_t GetNumErrors() const { return m_num_errors; } + + lldb::CommandInterpreterResult GetResult() const { return m_result; } + + bool IsResult(lldb::CommandInterpreterResult result) { + return m_result == result; + } + +protected: + friend CommandInterpreter; + + void IncrementNumberOfErrors() { m_num_errors++; } + + void SetResult(lldb::CommandInterpreterResult result) { m_result = result; } + +private: + int m_num_errors; + lldb::CommandInterpreterResult m_result; +}; class CommandInterpreterRunOptions { public: @@ -144,6 +170,20 @@ public: m_add_to_history = add_to_history ? eLazyBoolYes : eLazyBoolNo; } + bool GetAutoHandleEvents() const { + return DefaultToYes(m_auto_handle_events); + } + + void SetAutoHandleEvents(bool auto_handle_events) { + m_auto_handle_events = auto_handle_events ? eLazyBoolYes : eLazyBoolNo; + } + + bool GetSpawnThread() const { return DefaultToNo(m_spawn_thread); } + + void SetSpawnThread(bool spawn_thread) { + m_spawn_thread = spawn_thread ? eLazyBoolYes : eLazyBoolNo; + } + LazyBool m_stop_on_continue; LazyBool m_stop_on_error; LazyBool m_stop_on_crash; @@ -152,6 +192,8 @@ public: LazyBool m_print_results; LazyBool m_print_errors; LazyBool m_add_to_history; + LazyBool m_auto_handle_events; + LazyBool m_spawn_thread; private: static bool DefaultToYes(LazyBool flag) { @@ -426,8 +468,8 @@ public: bool IsActive(); - void RunCommandInterpreter(bool auto_handle_events, bool spawn_thread, - CommandInterpreterRunOptions &options); + CommandInterpreterRunResult + RunCommandInterpreter(CommandInterpreterRunOptions &options); void GetLLDBCommandsFromIOHandler(const char *prompt, IOHandlerDelegate &delegate, @@ -452,6 +494,10 @@ public: bool GetEchoCommentCommands() const; void SetEchoCommentCommands(bool enable); + const CommandObject::CommandMap &GetUserCommands() const { + return m_user_dict; + } + /// Specify if the command interpreter should allow that the user can /// specify a custom exit code when calling 'quit'. void AllowExitCodeOnQuit(bool allow); @@ -474,16 +520,10 @@ public: bool GetStopCmdSourceOnError() const; - uint32_t GetNumErrors() const { return m_num_errors; } - - bool GetQuitRequested() const { return m_quit_requested; } - lldb::IOHandlerSP GetIOHandler(bool force_create = false, CommandInterpreterRunOptions *options = nullptr); - bool GetStoppedForCrash() const { return m_stopped_for_crash; } - bool GetSpaceReplPrompts() const; protected: @@ -574,9 +614,7 @@ private: // the user has been told uint32_t m_command_source_depth; std::vector<uint32_t> m_command_source_flags; - uint32_t m_num_errors; - bool m_quit_requested; - bool m_stopped_for_crash; + CommandInterpreterRunResult m_result; // The exit code the user has requested when calling the 'quit' command. // No value means the user hasn't set a custom exit code so far. @@ -587,4 +625,4 @@ private: } // namespace lldb_private -#endif // liblldb_CommandInterpreter_h_ +#endif // LLDB_INTERPRETER_COMMANDINTERPRETER_H diff --git a/lldb/include/lldb/Interpreter/CommandObject.h b/lldb/include/lldb/Interpreter/CommandObject.h index f4dc2d606dda..cc4d40b23c31 100644 --- a/lldb/include/lldb/Interpreter/CommandObject.h +++ b/lldb/include/lldb/Interpreter/CommandObject.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef liblldb_CommandObject_h_ -#define liblldb_CommandObject_h_ +#ifndef LLDB_INTERPRETER_COMMANDOBJECT_H +#define LLDB_INTERPRETER_COMMANDOBJECT_H #include <map> #include <string> @@ -40,7 +40,7 @@ int AddNamesMatchingPartialString( const bool add_all = cmd_str.empty(); for (auto iter = in_map.begin(), end = in_map.end(); iter != end; iter++) { - if (add_all || (iter->first.find(cmd_str, 0) == 0)) { + if (add_all || (iter->first.find(std::string(cmd_str), 0) == 0)) { ++number_added; matches.AppendString(iter->first.c_str()); if (descriptions) @@ -411,4 +411,4 @@ protected: } // namespace lldb_private -#endif // liblldb_CommandObject_h_ +#endif // LLDB_INTERPRETER_COMMANDOBJECT_H diff --git a/lldb/include/lldb/Interpreter/CommandObjectMultiword.h b/lldb/include/lldb/Interpreter/CommandObjectMultiword.h index 72ec8a9c5ca9..6b383f8cfb34 100644 --- a/lldb/include/lldb/Interpreter/CommandObjectMultiword.h +++ b/lldb/include/lldb/Interpreter/CommandObjectMultiword.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef liblldb_CommandObjectMultiword_h_ -#define liblldb_CommandObjectMultiword_h_ +#ifndef LLDB_INTERPRETER_COMMANDOBJECTMULTIWORD_H +#define LLDB_INTERPRETER_COMMANDOBJECTMULTIWORD_H #include "lldb/Interpreter/CommandObject.h" #include "lldb/Utility/CompletionRequest.h" @@ -131,4 +131,4 @@ protected: } // namespace lldb_private -#endif // liblldb_CommandObjectMultiword_h_ +#endif // LLDB_INTERPRETER_COMMANDOBJECTMULTIWORD_H diff --git a/lldb/include/lldb/Interpreter/CommandObjectRegexCommand.h b/lldb/include/lldb/Interpreter/CommandObjectRegexCommand.h index 7800d5de1b38..01d7c6d118d4 100644 --- a/lldb/include/lldb/Interpreter/CommandObjectRegexCommand.h +++ b/lldb/include/lldb/Interpreter/CommandObjectRegexCommand.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef liblldb_CommandObjectRegexCommand_h_ -#define liblldb_CommandObjectRegexCommand_h_ +#ifndef LLDB_INTERPRETER_COMMANDOBJECTREGEXCOMMAND_H +#define LLDB_INTERPRETER_COMMANDOBJECTREGEXCOMMAND_H #include <list> @@ -51,9 +51,11 @@ protected: bool m_is_removable; private: - DISALLOW_COPY_AND_ASSIGN(CommandObjectRegexCommand); + CommandObjectRegexCommand(const CommandObjectRegexCommand &) = delete; + const CommandObjectRegexCommand & + operator=(const CommandObjectRegexCommand &) = delete; }; } // namespace lldb_private -#endif // liblldb_CommandObjectRegexCommand_h_ +#endif // LLDB_INTERPRETER_COMMANDOBJECTREGEXCOMMAND_H diff --git a/lldb/include/lldb/Interpreter/CommandOptionValidators.h b/lldb/include/lldb/Interpreter/CommandOptionValidators.h index 5483c1509556..218cc87fdf22 100644 --- a/lldb/include/lldb/Interpreter/CommandOptionValidators.h +++ b/lldb/include/lldb/Interpreter/CommandOptionValidators.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef liblldb_CommandOptionValidators_h_ -#define liblldb_CommandOptionValidators_h_ +#ifndef LLDB_INTERPRETER_COMMANDOPTIONVALIDATORS_H +#define LLDB_INTERPRETER_COMMANDOPTIONVALIDATORS_H #include "lldb/lldb-private-types.h" @@ -25,4 +25,4 @@ class PosixPlatformCommandOptionValidator : public OptionValidator { } // namespace lldb_private -#endif // liblldb_CommandOptionValidators_h_ +#endif // LLDB_INTERPRETER_COMMANDOPTIONVALIDATORS_H diff --git a/lldb/include/lldb/Interpreter/CommandReturnObject.h b/lldb/include/lldb/Interpreter/CommandReturnObject.h index 8af76e07e5ae..a7c2eea57663 100644 --- a/lldb/include/lldb/Interpreter/CommandReturnObject.h +++ b/lldb/include/lldb/Interpreter/CommandReturnObject.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef liblldb_CommandReturnObject_h_ -#define liblldb_CommandReturnObject_h_ +#ifndef LLDB_INTERPRETER_COMMANDRETURNOBJECT_H +#define LLDB_INTERPRETER_COMMANDRETURNOBJECT_H #include "lldb/Core/StreamFile.h" #include "lldb/Utility/StreamString.h" @@ -16,6 +16,7 @@ #include "llvm/ADT/StringRef.h" #include "llvm/Support/FormatVariadic.h" +#include "llvm/Support/WithColor.h" #include <memory> @@ -23,21 +24,21 @@ namespace lldb_private { class CommandReturnObject { public: - CommandReturnObject(); + CommandReturnObject(bool colors); ~CommandReturnObject(); llvm::StringRef GetOutputData() { lldb::StreamSP stream_sp(m_out_stream.GetStreamAtIndex(eStreamStringIndex)); if (stream_sp) - return static_pointer_cast<StreamString>(stream_sp)->GetString(); + return std::static_pointer_cast<StreamString>(stream_sp)->GetString(); return llvm::StringRef(); } llvm::StringRef GetErrorData() { lldb::StreamSP stream_sp(m_err_stream.GetStreamAtIndex(eStreamStringIndex)); if (stream_sp) - return static_pointer_cast<StreamString>(stream_sp)->GetString(); + return std::static_pointer_cast<StreamString>(stream_sp)->GetString(); return llvm::StringRef(); } @@ -45,7 +46,7 @@ public: // Make sure we at least have our normal string stream output stream lldb::StreamSP stream_sp(m_out_stream.GetStreamAtIndex(eStreamStringIndex)); if (!stream_sp) { - stream_sp.reset(new StreamString()); + stream_sp = std::make_shared<StreamString>(); m_out_stream.SetStreamAtIndex(eStreamStringIndex, stream_sp); } return m_out_stream; @@ -55,7 +56,7 @@ public: // Make sure we at least have our normal string stream output stream lldb::StreamSP stream_sp(m_err_stream.GetStreamAtIndex(eStreamStringIndex)); if (!stream_sp) { - stream_sp.reset(new StreamString()); + stream_sp = std::make_shared<StreamString>(); m_err_stream.SetStreamAtIndex(eStreamStringIndex, stream_sp); } return m_err_stream; @@ -157,4 +158,4 @@ private: } // namespace lldb_private -#endif // liblldb_CommandReturnObject_h_ +#endif // LLDB_INTERPRETER_COMMANDRETURNOBJECT_H diff --git a/lldb/include/lldb/Interpreter/OptionGroupArchitecture.h b/lldb/include/lldb/Interpreter/OptionGroupArchitecture.h index 4b7f9fe92e35..1eadf45bae47 100644 --- a/lldb/include/lldb/Interpreter/OptionGroupArchitecture.h +++ b/lldb/include/lldb/Interpreter/OptionGroupArchitecture.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef liblldb_OptionGroupArchitecture_h_ -#define liblldb_OptionGroupArchitecture_h_ +#ifndef LLDB_INTERPRETER_OPTIONGROUPARCHITECTURE_H +#define LLDB_INTERPRETER_OPTIONGROUPARCHITECTURE_H #include "lldb/Interpreter/Options.h" #include "lldb/Utility/ArchSpec.h" @@ -42,4 +42,4 @@ protected: } // namespace lldb_private -#endif // liblldb_OptionGroupArchitecture_h_ +#endif // LLDB_INTERPRETER_OPTIONGROUPARCHITECTURE_H diff --git a/lldb/include/lldb/Interpreter/OptionGroupBoolean.h b/lldb/include/lldb/Interpreter/OptionGroupBoolean.h index 77490457528a..061e31340854 100644 --- a/lldb/include/lldb/Interpreter/OptionGroupBoolean.h +++ b/lldb/include/lldb/Interpreter/OptionGroupBoolean.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef liblldb_OptionGroupBoolean_h_ -#define liblldb_OptionGroupBoolean_h_ +#ifndef LLDB_INTERPRETER_OPTIONGROUPBOOLEAN_H +#define LLDB_INTERPRETER_OPTIONGROUPBOOLEAN_H #include "lldb/Interpreter/OptionValueBoolean.h" #include "lldb/Interpreter/Options.h" @@ -48,4 +48,4 @@ protected: } // namespace lldb_private -#endif // liblldb_OptionGroupBoolean_h_ +#endif // LLDB_INTERPRETER_OPTIONGROUPBOOLEAN_H diff --git a/lldb/include/lldb/Interpreter/OptionGroupFile.h b/lldb/include/lldb/Interpreter/OptionGroupFile.h index cce3714e98b9..374cf10ea30a 100644 --- a/lldb/include/lldb/Interpreter/OptionGroupFile.h +++ b/lldb/include/lldb/Interpreter/OptionGroupFile.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef liblldb_OptionGroupFile_h_ -#define liblldb_OptionGroupFile_h_ +#ifndef LLDB_INTERPRETER_OPTIONGROUPFILE_H +#define LLDB_INTERPRETER_OPTIONGROUPFILE_H #include "lldb/Interpreter/OptionValueFileSpec.h" #include "lldb/Interpreter/OptionValueFileSpecList.h" @@ -78,4 +78,4 @@ protected: } // namespace lldb_private -#endif // liblldb_OptionGroupFile_h_ +#endif // LLDB_INTERPRETER_OPTIONGROUPFILE_H diff --git a/lldb/include/lldb/Interpreter/OptionGroupFormat.h b/lldb/include/lldb/Interpreter/OptionGroupFormat.h index 1b5020a392c5..62c6f97c6214 100644 --- a/lldb/include/lldb/Interpreter/OptionGroupFormat.h +++ b/lldb/include/lldb/Interpreter/OptionGroupFormat.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef liblldb_OptionGroupFormat_h_ -#define liblldb_OptionGroupFormat_h_ +#ifndef LLDB_INTERPRETER_OPTIONGROUPFORMAT_H +#define LLDB_INTERPRETER_OPTIONGROUPFORMAT_H #include "lldb/Interpreter/OptionValueFormat.h" #include "lldb/Interpreter/OptionValueSInt64.h" @@ -78,4 +78,4 @@ protected: } // namespace lldb_private -#endif // liblldb_OptionGroupFormat_h_ +#endif // LLDB_INTERPRETER_OPTIONGROUPFORMAT_H diff --git a/lldb/include/lldb/Interpreter/OptionGroupOutputFile.h b/lldb/include/lldb/Interpreter/OptionGroupOutputFile.h index 82d68b7c164e..a71998f3bc1a 100644 --- a/lldb/include/lldb/Interpreter/OptionGroupOutputFile.h +++ b/lldb/include/lldb/Interpreter/OptionGroupOutputFile.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef liblldb_OptionGroupOutputFile_h_ -#define liblldb_OptionGroupOutputFile_h_ +#ifndef LLDB_INTERPRETER_OPTIONGROUPOUTPUTFILE_H +#define LLDB_INTERPRETER_OPTIONGROUPOUTPUTFILE_H #include "lldb/Interpreter/OptionValueBoolean.h" #include "lldb/Interpreter/OptionValueFileSpec.h" @@ -45,4 +45,4 @@ protected: } // namespace lldb_private -#endif // liblldb_OptionGroupOutputFile_h_ +#endif // LLDB_INTERPRETER_OPTIONGROUPOUTPUTFILE_H diff --git a/lldb/include/lldb/Interpreter/OptionGroupPlatform.h b/lldb/include/lldb/Interpreter/OptionGroupPlatform.h index ea5a3f39ef83..99945e5246fd 100644 --- a/lldb/include/lldb/Interpreter/OptionGroupPlatform.h +++ b/lldb/include/lldb/Interpreter/OptionGroupPlatform.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef liblldb_OptionGroupPlatform_h_ -#define liblldb_OptionGroupPlatform_h_ +#ifndef LLDB_INTERPRETER_OPTIONGROUPPLATFORM_H +#define LLDB_INTERPRETER_OPTIONGROUPPLATFORM_H #include "lldb/Interpreter/Options.h" #include "lldb/Utility/ConstString.h" @@ -70,4 +70,4 @@ protected: } // namespace lldb_private -#endif // liblldb_OptionGroupPlatform_h_ +#endif // LLDB_INTERPRETER_OPTIONGROUPPLATFORM_H diff --git a/lldb/include/lldb/Interpreter/OptionGroupPythonClassWithDict.h b/lldb/include/lldb/Interpreter/OptionGroupPythonClassWithDict.h index 2229c1aa08a2..d4c924a44157 100644 --- a/lldb/include/lldb/Interpreter/OptionGroupPythonClassWithDict.h +++ b/lldb/include/lldb/Interpreter/OptionGroupPythonClassWithDict.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef liblldb_OptionGroupPythonClassWithDict_h_ -#define liblldb_OptionGroupPythonClassWithDict_h_ +#ifndef LLDB_INTERPRETER_OPTIONGROUPPYTHONCLASSWITHDICT_H +#define LLDB_INTERPRETER_OPTIONGROUPPYTHONCLASSWITHDICT_H #include "lldb/lldb-types.h" #include "lldb/Interpreter/Options.h" @@ -60,4 +60,4 @@ protected: } // namespace lldb_private -#endif // liblldb_OptionGroupPythonClassWithDict_h_ +#endif // LLDB_INTERPRETER_OPTIONGROUPPYTHONCLASSWITHDICT_H diff --git a/lldb/include/lldb/Interpreter/OptionGroupString.h b/lldb/include/lldb/Interpreter/OptionGroupString.h index ce1058954054..1a3b5bdd88ed 100644 --- a/lldb/include/lldb/Interpreter/OptionGroupString.h +++ b/lldb/include/lldb/Interpreter/OptionGroupString.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef liblldb_OptionGroupString_h_ -#define liblldb_OptionGroupString_h_ +#ifndef LLDB_INTERPRETER_OPTIONGROUPSTRING_H +#define LLDB_INTERPRETER_OPTIONGROUPSTRING_H #include "lldb/Interpreter/OptionValueString.h" #include "lldb/Interpreter/Options.h" @@ -45,4 +45,4 @@ protected: } // namespace lldb_private -#endif // liblldb_OptionGroupString_h_ +#endif // LLDB_INTERPRETER_OPTIONGROUPSTRING_H diff --git a/lldb/include/lldb/Interpreter/OptionGroupUInt64.h b/lldb/include/lldb/Interpreter/OptionGroupUInt64.h index 12f08a38c533..783c4b632f00 100644 --- a/lldb/include/lldb/Interpreter/OptionGroupUInt64.h +++ b/lldb/include/lldb/Interpreter/OptionGroupUInt64.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef liblldb_OptionGroupUInt64_h_ -#define liblldb_OptionGroupUInt64_h_ +#ifndef LLDB_INTERPRETER_OPTIONGROUPUINT64_H +#define LLDB_INTERPRETER_OPTIONGROUPUINT64_H #include "lldb/Interpreter/OptionValueUInt64.h" #include "lldb/Interpreter/Options.h" @@ -46,4 +46,4 @@ protected: } // namespace lldb_private -#endif // liblldb_OptionGroupUInt64_h_ +#endif // LLDB_INTERPRETER_OPTIONGROUPUINT64_H diff --git a/lldb/include/lldb/Interpreter/OptionGroupUUID.h b/lldb/include/lldb/Interpreter/OptionGroupUUID.h index 22fc3a100c75..b1c779f7b5a4 100644 --- a/lldb/include/lldb/Interpreter/OptionGroupUUID.h +++ b/lldb/include/lldb/Interpreter/OptionGroupUUID.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef liblldb_OptionGroupUUID_h_ -#define liblldb_OptionGroupUUID_h_ +#ifndef LLDB_INTERPRETER_OPTIONGROUPUUID_H +#define LLDB_INTERPRETER_OPTIONGROUPUUID_H #include "lldb/Interpreter/OptionValueUUID.h" #include "lldb/Interpreter/Options.h" @@ -38,4 +38,4 @@ protected: } // namespace lldb_private -#endif // liblldb_OptionGroupUUID_h_ +#endif // LLDB_INTERPRETER_OPTIONGROUPUUID_H diff --git a/lldb/include/lldb/Interpreter/OptionGroupValueObjectDisplay.h b/lldb/include/lldb/Interpreter/OptionGroupValueObjectDisplay.h index 5a1bbc9e7b66..1ad53321d26e 100644 --- a/lldb/include/lldb/Interpreter/OptionGroupValueObjectDisplay.h +++ b/lldb/include/lldb/Interpreter/OptionGroupValueObjectDisplay.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef liblldb_OptionGroupValueObjectDisplay_h_ -#define liblldb_OptionGroupValueObjectDisplay_h_ +#ifndef LLDB_INTERPRETER_OPTIONGROUPVALUEOBJECTDISPLAY_H +#define LLDB_INTERPRETER_OPTIONGROUPVALUEOBJECTDISPLAY_H #include "lldb/Core/ValueObject.h" #include "lldb/Interpreter/Options.h" @@ -55,4 +55,4 @@ public: } // namespace lldb_private -#endif // liblldb_OptionGroupValueObjectDisplay_h_ +#endif // LLDB_INTERPRETER_OPTIONGROUPVALUEOBJECTDISPLAY_H diff --git a/lldb/include/lldb/Interpreter/OptionGroupVariable.h b/lldb/include/lldb/Interpreter/OptionGroupVariable.h index 0c042f4c1cdb..252ca3b42c5e 100644 --- a/lldb/include/lldb/Interpreter/OptionGroupVariable.h +++ b/lldb/include/lldb/Interpreter/OptionGroupVariable.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef liblldb_OptionGroupVariable_h_ -#define liblldb_OptionGroupVariable_h_ +#ifndef LLDB_INTERPRETER_OPTIONGROUPVARIABLE_H +#define LLDB_INTERPRETER_OPTIONGROUPVARIABLE_H #include "lldb/Interpreter/OptionValueString.h" #include "lldb/Interpreter/Options.h" @@ -41,9 +41,10 @@ public: OptionValueString summary_string; // a summary string private: - DISALLOW_COPY_AND_ASSIGN(OptionGroupVariable); + OptionGroupVariable(const OptionGroupVariable &) = delete; + const OptionGroupVariable &operator=(const OptionGroupVariable &) = delete; }; } // namespace lldb_private -#endif // liblldb_OptionGroupVariable_h_ +#endif // LLDB_INTERPRETER_OPTIONGROUPVARIABLE_H diff --git a/lldb/include/lldb/Interpreter/OptionGroupWatchpoint.h b/lldb/include/lldb/Interpreter/OptionGroupWatchpoint.h index 3729c000b8e0..6a6c8638aede 100644 --- a/lldb/include/lldb/Interpreter/OptionGroupWatchpoint.h +++ b/lldb/include/lldb/Interpreter/OptionGroupWatchpoint.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef liblldb_OptionGroupWatchpoint_h_ -#define liblldb_OptionGroupWatchpoint_h_ +#ifndef LLDB_INTERPRETER_OPTIONGROUPWATCHPOINT_H +#define LLDB_INTERPRETER_OPTIONGROUPWATCHPOINT_H #include "lldb/Interpreter/Options.h" @@ -46,9 +46,11 @@ public: bool watch_type_specified; private: - DISALLOW_COPY_AND_ASSIGN(OptionGroupWatchpoint); + OptionGroupWatchpoint(const OptionGroupWatchpoint &) = delete; + const OptionGroupWatchpoint & + operator=(const OptionGroupWatchpoint &) = delete; }; } // namespace lldb_private -#endif // liblldb_OptionGroupWatchpoint_h_ +#endif // LLDB_INTERPRETER_OPTIONGROUPWATCHPOINT_H diff --git a/lldb/include/lldb/Interpreter/OptionValue.h b/lldb/include/lldb/Interpreter/OptionValue.h index 44c7f621a582..5b07427094bf 100644 --- a/lldb/include/lldb/Interpreter/OptionValue.h +++ b/lldb/include/lldb/Interpreter/OptionValue.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef liblldb_OptionValue_h_ -#define liblldb_OptionValue_h_ +#ifndef LLDB_INTERPRETER_OPTIONVALUE_H +#define LLDB_INTERPRETER_OPTIONVALUE_H #include "lldb/Core/FormatEntity.h" #include "lldb/Utility/CompletionRequest.h" @@ -326,4 +326,4 @@ protected: } // namespace lldb_private -#endif // liblldb_OptionValue_h_ +#endif // LLDB_INTERPRETER_OPTIONVALUE_H diff --git a/lldb/include/lldb/Interpreter/OptionValueArch.h b/lldb/include/lldb/Interpreter/OptionValueArch.h index 3923e3d3dba4..7b63c68fddbf 100644 --- a/lldb/include/lldb/Interpreter/OptionValueArch.h +++ b/lldb/include/lldb/Interpreter/OptionValueArch.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef liblldb_OptionValueArch_h_ -#define liblldb_OptionValueArch_h_ +#ifndef LLDB_INTERPRETER_OPTIONVALUEARCH_H +#define LLDB_INTERPRETER_OPTIONVALUEARCH_H #include "lldb/Interpreter/OptionValue.h" #include "lldb/Utility/ArchSpec.h" @@ -81,4 +81,4 @@ protected: } // namespace lldb_private -#endif // liblldb_OptionValueArch_h_ +#endif // LLDB_INTERPRETER_OPTIONVALUEARCH_H diff --git a/lldb/include/lldb/Interpreter/OptionValueArgs.h b/lldb/include/lldb/Interpreter/OptionValueArgs.h index 0254b9aa7e14..25f7fdde0bf3 100644 --- a/lldb/include/lldb/Interpreter/OptionValueArgs.h +++ b/lldb/include/lldb/Interpreter/OptionValueArgs.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef liblldb_OptionValueArgs_h_ -#define liblldb_OptionValueArgs_h_ +#ifndef LLDB_INTERPRETER_OPTIONVALUEARGS_H +#define LLDB_INTERPRETER_OPTIONVALUEARGS_H #include "lldb/Interpreter/OptionValueArray.h" @@ -28,4 +28,4 @@ public: } // namespace lldb_private -#endif // liblldb_OptionValueArgs_h_ +#endif // LLDB_INTERPRETER_OPTIONVALUEARGS_H diff --git a/lldb/include/lldb/Interpreter/OptionValueArray.h b/lldb/include/lldb/Interpreter/OptionValueArray.h index 10f3bf5f729f..000351c2f586 100644 --- a/lldb/include/lldb/Interpreter/OptionValueArray.h +++ b/lldb/include/lldb/Interpreter/OptionValueArray.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef liblldb_OptionValueArray_h_ -#define liblldb_OptionValueArray_h_ +#ifndef LLDB_INTERPRETER_OPTIONVALUEARRAY_H +#define LLDB_INTERPRETER_OPTIONVALUEARRAY_H #include <vector> @@ -125,4 +125,4 @@ protected: } // namespace lldb_private -#endif // liblldb_OptionValueArray_h_ +#endif // LLDB_INTERPRETER_OPTIONVALUEARRAY_H diff --git a/lldb/include/lldb/Interpreter/OptionValueBoolean.h b/lldb/include/lldb/Interpreter/OptionValueBoolean.h index 42b2ca4d2845..d221f6d034c2 100644 --- a/lldb/include/lldb/Interpreter/OptionValueBoolean.h +++ b/lldb/include/lldb/Interpreter/OptionValueBoolean.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef liblldb_OptionValueBoolean_h_ -#define liblldb_OptionValueBoolean_h_ +#ifndef LLDB_INTERPRETER_OPTIONVALUEBOOLEAN_H +#define LLDB_INTERPRETER_OPTIONVALUEBOOLEAN_H #include "lldb/Interpreter/OptionValue.h" @@ -85,4 +85,4 @@ protected: } // namespace lldb_private -#endif // liblldb_OptionValueBoolean_h_ +#endif // LLDB_INTERPRETER_OPTIONVALUEBOOLEAN_H diff --git a/lldb/include/lldb/Interpreter/OptionValueChar.h b/lldb/include/lldb/Interpreter/OptionValueChar.h index d8661363751b..8d0aa91d7076 100644 --- a/lldb/include/lldb/Interpreter/OptionValueChar.h +++ b/lldb/include/lldb/Interpreter/OptionValueChar.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef liblldb_OptionValueChar_h_ -#define liblldb_OptionValueChar_h_ +#ifndef LLDB_INTERPRETER_OPTIONVALUECHAR_H +#define LLDB_INTERPRETER_OPTIONVALUECHAR_H #include "lldb/Interpreter/OptionValue.h" @@ -68,4 +68,4 @@ protected: } // namespace lldb_private -#endif // liblldb_OptionValueChar_h_ +#endif // LLDB_INTERPRETER_OPTIONVALUECHAR_H diff --git a/lldb/include/lldb/Interpreter/OptionValueDictionary.h b/lldb/include/lldb/Interpreter/OptionValueDictionary.h index 8785d38f5423..1bc45252607c 100644 --- a/lldb/include/lldb/Interpreter/OptionValueDictionary.h +++ b/lldb/include/lldb/Interpreter/OptionValueDictionary.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef liblldb_OptionValueDictionary_h_ -#define liblldb_OptionValueDictionary_h_ +#ifndef LLDB_INTERPRETER_OPTIONVALUEDICTIONARY_H +#define LLDB_INTERPRETER_OPTIONVALUEDICTIONARY_H #include <map> @@ -81,4 +81,4 @@ protected: } // namespace lldb_private -#endif // liblldb_OptionValueDictionary_h_ +#endif // LLDB_INTERPRETER_OPTIONVALUEDICTIONARY_H diff --git a/lldb/include/lldb/Interpreter/OptionValueEnumeration.h b/lldb/include/lldb/Interpreter/OptionValueEnumeration.h index eb19737f8653..26ba7ad5f646 100644 --- a/lldb/include/lldb/Interpreter/OptionValueEnumeration.h +++ b/lldb/include/lldb/Interpreter/OptionValueEnumeration.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef liblldb_OptionValueEnumeration_h_ -#define liblldb_OptionValueEnumeration_h_ +#ifndef LLDB_INTERPRETER_OPTIONVALUEENUMERATION_H +#define LLDB_INTERPRETER_OPTIONVALUEENUMERATION_H #include "lldb/Core/UniqueCStringMap.h" #include "lldb/Interpreter/OptionValue.h" @@ -83,4 +83,4 @@ protected: } // namespace lldb_private -#endif // liblldb_OptionValueEnumeration_h_ +#endif // LLDB_INTERPRETER_OPTIONVALUEENUMERATION_H diff --git a/lldb/include/lldb/Interpreter/OptionValueFileSpec.h b/lldb/include/lldb/Interpreter/OptionValueFileSpec.h index a6df18149076..2b18c9533f91 100644 --- a/lldb/include/lldb/Interpreter/OptionValueFileSpec.h +++ b/lldb/include/lldb/Interpreter/OptionValueFileSpec.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef liblldb_OptionValueFileSpec_h_ -#define liblldb_OptionValueFileSpec_h_ +#ifndef LLDB_INTERPRETER_OPTIONVALUEFILESPEC_H +#define LLDB_INTERPRETER_OPTIONVALUEFILESPEC_H #include "lldb/Interpreter/OptionValue.h" @@ -86,4 +86,4 @@ protected: } // namespace lldb_private -#endif // liblldb_OptionValueFileSpec_h_ +#endif // LLDB_INTERPRETER_OPTIONVALUEFILESPEC_H diff --git a/lldb/include/lldb/Interpreter/OptionValueFileSpecList.h b/lldb/include/lldb/Interpreter/OptionValueFileSpecList.h index 5607437fd0dc..7b762bf6b309 100644 --- a/lldb/include/lldb/Interpreter/OptionValueFileSpecList.h +++ b/lldb/include/lldb/Interpreter/OptionValueFileSpecList.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef liblldb_OptionValueFileSpecList_h_ -#define liblldb_OptionValueFileSpecList_h_ +#ifndef LLDB_INTERPRETER_OPTIONVALUEFILESPECLIST_H +#define LLDB_INTERPRETER_OPTIONVALUEFILESPECLIST_H #include <mutex> @@ -74,4 +74,4 @@ protected: } // namespace lldb_private -#endif // liblldb_OptionValueFileSpecList_h_ +#endif // LLDB_INTERPRETER_OPTIONVALUEFILESPECLIST_H diff --git a/lldb/include/lldb/Interpreter/OptionValueFormat.h b/lldb/include/lldb/Interpreter/OptionValueFormat.h index 020f4aeda17a..6904c93a2f33 100644 --- a/lldb/include/lldb/Interpreter/OptionValueFormat.h +++ b/lldb/include/lldb/Interpreter/OptionValueFormat.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef liblldb_OptionValueFormat_h_ -#define liblldb_OptionValueFormat_h_ +#ifndef LLDB_INTERPRETER_OPTIONVALUEFORMAT_H +#define LLDB_INTERPRETER_OPTIONVALUEFORMAT_H #include "lldb/Interpreter/OptionValue.h" @@ -63,4 +63,4 @@ protected: } // namespace lldb_private -#endif // liblldb_OptionValueFormat_h_ +#endif // LLDB_INTERPRETER_OPTIONVALUEFORMAT_H diff --git a/lldb/include/lldb/Interpreter/OptionValueFormatEntity.h b/lldb/include/lldb/Interpreter/OptionValueFormatEntity.h index 419ff5c03e3a..beb5d6843a98 100644 --- a/lldb/include/lldb/Interpreter/OptionValueFormatEntity.h +++ b/lldb/include/lldb/Interpreter/OptionValueFormatEntity.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef liblldb_OptionValueFormatEntity_h_ -#define liblldb_OptionValueFormatEntity_h_ +#ifndef LLDB_INTERPRETER_OPTIONVALUEFORMATENTITY_H +#define LLDB_INTERPRETER_OPTIONVALUEFORMATENTITY_H #include "lldb/Core/FormatEntity.h" #include "lldb/Interpreter/OptionValue.h" @@ -64,4 +64,4 @@ protected: } // namespace lldb_private -#endif // liblldb_OptionValueFormatEntity_h_ +#endif // LLDB_INTERPRETER_OPTIONVALUEFORMATENTITY_H diff --git a/lldb/include/lldb/Interpreter/OptionValueLanguage.h b/lldb/include/lldb/Interpreter/OptionValueLanguage.h index 505dc89e9208..f4ca2fd69ab5 100644 --- a/lldb/include/lldb/Interpreter/OptionValueLanguage.h +++ b/lldb/include/lldb/Interpreter/OptionValueLanguage.h @@ -7,8 +7,8 @@ // //===----------------------------------------------------------------------===// -#ifndef liblldb_OptionValueLanguage_h_ -#define liblldb_OptionValueLanguage_h_ +#ifndef LLDB_INTERPRETER_OPTIONVALUELANGUAGE_H +#define LLDB_INTERPRETER_OPTIONVALUELANGUAGE_H #include "lldb/Interpreter/OptionValue.h" #include "lldb/lldb-enumerations.h" @@ -66,4 +66,4 @@ protected: } // namespace lldb_private -#endif // liblldb_OptionValueLanguage_h_ +#endif // LLDB_INTERPRETER_OPTIONVALUELANGUAGE_H diff --git a/lldb/include/lldb/Interpreter/OptionValuePathMappings.h b/lldb/include/lldb/Interpreter/OptionValuePathMappings.h index 35c2af45bc97..18f5cbaf4336 100644 --- a/lldb/include/lldb/Interpreter/OptionValuePathMappings.h +++ b/lldb/include/lldb/Interpreter/OptionValuePathMappings.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef liblldb_OptionValuePathMappings_h_ -#define liblldb_OptionValuePathMappings_h_ +#ifndef LLDB_INTERPRETER_OPTIONVALUEPATHMAPPINGS_H +#define LLDB_INTERPRETER_OPTIONVALUEPATHMAPPINGS_H #include "lldb/Interpreter/OptionValue.h" #include "lldb/Target/PathMappingList.h" @@ -58,4 +58,4 @@ protected: } // namespace lldb_private -#endif // liblldb_OptionValuePathMappings_h_ +#endif // LLDB_INTERPRETER_OPTIONVALUEPATHMAPPINGS_H diff --git a/lldb/include/lldb/Interpreter/OptionValueProperties.h b/lldb/include/lldb/Interpreter/OptionValueProperties.h index 980f01183ef5..76f09cc77123 100644 --- a/lldb/include/lldb/Interpreter/OptionValueProperties.h +++ b/lldb/include/lldb/Interpreter/OptionValueProperties.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef liblldb_OptionValueProperties_h_ -#define liblldb_OptionValueProperties_h_ +#ifndef LLDB_INTERPRETER_OPTIONVALUEPROPERTIES_H +#define LLDB_INTERPRETER_OPTIONVALUEPROPERTIES_H #include <vector> @@ -218,4 +218,4 @@ protected: } // namespace lldb_private -#endif // liblldb_OptionValueProperties_h_ +#endif // LLDB_INTERPRETER_OPTIONVALUEPROPERTIES_H diff --git a/lldb/include/lldb/Interpreter/OptionValueRegex.h b/lldb/include/lldb/Interpreter/OptionValueRegex.h index 8c10dacb0313..b09b8414d5bf 100644 --- a/lldb/include/lldb/Interpreter/OptionValueRegex.h +++ b/lldb/include/lldb/Interpreter/OptionValueRegex.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef liblldb_OptionValueRegex_h_ -#define liblldb_OptionValueRegex_h_ +#ifndef LLDB_INTERPRETER_OPTIONVALUEREGEX_H +#define LLDB_INTERPRETER_OPTIONVALUEREGEX_H #include "lldb/Interpreter/OptionValue.h" #include "lldb/Utility/RegularExpression.h" @@ -17,7 +17,8 @@ namespace lldb_private { class OptionValueRegex : public OptionValue { public: OptionValueRegex(const char *value = nullptr) - : OptionValue(), m_regex(llvm::StringRef::withNullAsEmpty(value)) {} + : OptionValue(), m_regex(llvm::StringRef::withNullAsEmpty(value)), + m_default_regex_str(llvm::StringRef::withNullAsEmpty(value).str()) {} ~OptionValueRegex() override = default; @@ -36,7 +37,7 @@ public: VarSetOperationType = eVarSetOperationAssign) = delete; bool Clear() override { - m_regex = RegularExpression(); + m_regex = RegularExpression(m_default_regex_str); m_value_was_set = false; return true; } @@ -59,8 +60,9 @@ public: protected: RegularExpression m_regex; + std::string m_default_regex_str; }; } // namespace lldb_private -#endif // liblldb_OptionValueRegex_h_ +#endif // LLDB_INTERPRETER_OPTIONVALUEREGEX_H diff --git a/lldb/include/lldb/Interpreter/OptionValueSInt64.h b/lldb/include/lldb/Interpreter/OptionValueSInt64.h index c2e8ff43a99a..fbabaaeb2ff4 100644 --- a/lldb/include/lldb/Interpreter/OptionValueSInt64.h +++ b/lldb/include/lldb/Interpreter/OptionValueSInt64.h @@ -7,8 +7,8 @@ // //===----------------------------------------------------------------------===// -#ifndef liblldb_OptionValueSInt64_h_ -#define liblldb_OptionValueSInt64_h_ +#ifndef LLDB_INTERPRETER_OPTIONVALUESINT64_H +#define LLDB_INTERPRETER_OPTIONVALUESINT64_H #include "lldb/Interpreter/OptionValue.h" @@ -102,4 +102,4 @@ protected: } // namespace lldb_private -#endif // liblldb_OptionValueSInt64_h_ +#endif // LLDB_INTERPRETER_OPTIONVALUESINT64_H diff --git a/lldb/include/lldb/Interpreter/OptionValueString.h b/lldb/include/lldb/Interpreter/OptionValueString.h index d9e76d8b58fe..cd371c567020 100644 --- a/lldb/include/lldb/Interpreter/OptionValueString.h +++ b/lldb/include/lldb/Interpreter/OptionValueString.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef liblldb_OptionValueString_h_ -#define liblldb_OptionValueString_h_ +#ifndef LLDB_INTERPRETER_OPTIONVALUESTRING_H +#define LLDB_INTERPRETER_OPTIONVALUESTRING_H #include <string> @@ -136,4 +136,4 @@ protected: } // namespace lldb_private -#endif // liblldb_OptionValueString_h_ +#endif // LLDB_INTERPRETER_OPTIONVALUESTRING_H diff --git a/lldb/include/lldb/Interpreter/OptionValueUInt64.h b/lldb/include/lldb/Interpreter/OptionValueUInt64.h index 5978cdb4434f..0096e87de367 100644 --- a/lldb/include/lldb/Interpreter/OptionValueUInt64.h +++ b/lldb/include/lldb/Interpreter/OptionValueUInt64.h @@ -7,8 +7,8 @@ // //===----------------------------------------------------------------------===// -#ifndef liblldb_OptionValueUInt64_h_ -#define liblldb_OptionValueUInt64_h_ +#ifndef LLDB_INTERPRETER_OPTIONVALUEUINT64_H +#define LLDB_INTERPRETER_OPTIONVALUEUINT64_H #include "lldb/Interpreter/OptionValue.h" @@ -79,4 +79,4 @@ protected: } // namespace lldb_private -#endif // liblldb_OptionValueUInt64_h_ +#endif // LLDB_INTERPRETER_OPTIONVALUEUINT64_H diff --git a/lldb/include/lldb/Interpreter/OptionValueUUID.h b/lldb/include/lldb/Interpreter/OptionValueUUID.h index 576440d80519..2fb8caa3aa53 100644 --- a/lldb/include/lldb/Interpreter/OptionValueUUID.h +++ b/lldb/include/lldb/Interpreter/OptionValueUUID.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef liblldb_OptionValueUUID_h_ -#define liblldb_OptionValueUUID_h_ +#ifndef LLDB_INTERPRETER_OPTIONVALUEUUID_H +#define LLDB_INTERPRETER_OPTIONVALUEUUID_H #include "lldb/Utility/UUID.h" #include "lldb/Interpreter/OptionValue.h" @@ -61,4 +61,4 @@ protected: } // namespace lldb_private -#endif // liblldb_OptionValueUUID_h_ +#endif // LLDB_INTERPRETER_OPTIONVALUEUUID_H diff --git a/lldb/include/lldb/Interpreter/OptionValues.h b/lldb/include/lldb/Interpreter/OptionValues.h index d90b2867a4b0..36e7c192d60a 100644 --- a/lldb/include/lldb/Interpreter/OptionValues.h +++ b/lldb/include/lldb/Interpreter/OptionValues.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef liblldb_OptionValues_h_ -#define liblldb_OptionValues_h_ +#ifndef LLDB_INTERPRETER_OPTIONVALUES_H +#define LLDB_INTERPRETER_OPTIONVALUES_H #include "lldb/Interpreter/OptionValue.h" #include "lldb/Interpreter/OptionValueArch.h" @@ -30,4 +30,4 @@ #include "lldb/Interpreter/OptionValueUInt64.h" #include "lldb/Interpreter/OptionValueUUID.h" -#endif // liblldb_OptionValues_h_ +#endif // LLDB_INTERPRETER_OPTIONVALUES_H diff --git a/lldb/include/lldb/Interpreter/Options.h b/lldb/include/lldb/Interpreter/Options.h index d07c2560ef2d..ebceaea8383d 100644 --- a/lldb/include/lldb/Interpreter/Options.h +++ b/lldb/include/lldb/Interpreter/Options.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef liblldb_Options_h_ -#define liblldb_Options_h_ +#ifndef LLDB_INTERPRETER_OPTIONS_H +#define LLDB_INTERPRETER_OPTIONS_H #include <set> #include <vector> @@ -43,7 +43,7 @@ typedef std::vector<OptionArgElement> OptionElementVector; static inline bool isprint8(int ch) { if (ch & 0xffffff00u) return false; - return isprint(ch); + return llvm::isPrint(ch); } /// \class Options Options.h "lldb/Interpreter/Options.h" @@ -328,4 +328,4 @@ public: } // namespace lldb_private -#endif // liblldb_Options_h_ +#endif // LLDB_INTERPRETER_OPTIONS_H diff --git a/lldb/include/lldb/Interpreter/Property.h b/lldb/include/lldb/Interpreter/Property.h index 76264832705b..97ec7ca1d4af 100644 --- a/lldb/include/lldb/Interpreter/Property.h +++ b/lldb/include/lldb/Interpreter/Property.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef liblldb_Property_h_ -#define liblldb_Property_h_ +#ifndef LLDB_INTERPRETER_PROPERTY_H +#define LLDB_INTERPRETER_PROPERTY_H #include "lldb/Interpreter/OptionValue.h" #include "lldb/Utility/ConstString.h" @@ -75,4 +75,4 @@ protected: } // namespace lldb_private -#endif // liblldb_Property_h_ +#endif // LLDB_INTERPRETER_PROPERTY_H diff --git a/lldb/include/lldb/Interpreter/ScriptInterpreter.h b/lldb/include/lldb/Interpreter/ScriptInterpreter.h index 1784c93adbac..491923e6a6c4 100644 --- a/lldb/include/lldb/Interpreter/ScriptInterpreter.h +++ b/lldb/include/lldb/Interpreter/ScriptInterpreter.h @@ -6,19 +6,19 @@ // //===----------------------------------------------------------------------===// -#ifndef liblldb_ScriptInterpreter_h_ -#define liblldb_ScriptInterpreter_h_ - -#include "lldb/lldb-private.h" +#ifndef LLDB_INTERPRETER_SCRIPTINTERPRETER_H +#define LLDB_INTERPRETER_SCRIPTINTERPRETER_H #include "lldb/Breakpoint/BreakpointOptions.h" +#include "lldb/Core/Communication.h" #include "lldb/Core/PluginInterface.h" #include "lldb/Core/SearchFilter.h" +#include "lldb/Core/StreamFile.h" +#include "lldb/Host/PseudoTerminal.h" #include "lldb/Utility/Broadcaster.h" #include "lldb/Utility/Status.h" #include "lldb/Utility/StructuredData.h" - -#include "lldb/Host/PseudoTerminal.h" +#include "lldb/lldb-private.h" namespace lldb_private { @@ -29,7 +29,38 @@ public: virtual ~ScriptInterpreterLocker() = default; private: - DISALLOW_COPY_AND_ASSIGN(ScriptInterpreterLocker); + ScriptInterpreterLocker(const ScriptInterpreterLocker &) = delete; + const ScriptInterpreterLocker & + operator=(const ScriptInterpreterLocker &) = delete; +}; + +class ScriptInterpreterIORedirect { +public: + /// Create an IO redirect. If IO is enabled, this will redirects the output + /// to the command return object if set or to the debugger otherwise. If IO + /// is disabled, it will redirect all IO to /dev/null. + static llvm::Expected<std::unique_ptr<ScriptInterpreterIORedirect>> + Create(bool enable_io, Debugger &debugger, CommandReturnObject *result); + + ~ScriptInterpreterIORedirect(); + + lldb::FileSP GetInputFile() const { return m_input_file_sp; } + lldb::FileSP GetOutputFile() const { return m_output_file_sp->GetFileSP(); } + lldb::FileSP GetErrorFile() const { return m_error_file_sp->GetFileSP(); } + + /// Flush our output and error file handles. + void Flush(); + +private: + ScriptInterpreterIORedirect(std::unique_ptr<File> input, + std::unique_ptr<File> output); + ScriptInterpreterIORedirect(Debugger &debugger, CommandReturnObject *result); + + lldb::FileSP m_input_file_sp; + lldb::StreamFileSP m_output_file_sp; + lldb::StreamFileSP m_error_file_sp; + Communication m_communication; + bool m_disconnect; }; class ScriptInterpreter : public PluginInterface { @@ -467,8 +498,6 @@ public: const char *GetScriptInterpreterPtyName(); - int GetMasterFileDescriptor(); - virtual llvm::Expected<unsigned> GetMaxPositionalArgumentsForCallable(const llvm::StringRef &callable_name) { return llvm::createStringError( @@ -488,4 +517,4 @@ protected: } // namespace lldb_private -#endif // liblldb_ScriptInterpreter_h_ +#endif // LLDB_INTERPRETER_SCRIPTINTERPRETER_H diff --git a/lldb/include/lldb/Symbol/ArmUnwindInfo.h b/lldb/include/lldb/Symbol/ArmUnwindInfo.h index a74b4442df14..24f9f1a0a61f 100644 --- a/lldb/include/lldb/Symbol/ArmUnwindInfo.h +++ b/lldb/include/lldb/Symbol/ArmUnwindInfo.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef liblldb_ArmUnwindInfo_h_ -#define liblldb_ArmUnwindInfo_h_ +#ifndef LLDB_SYMBOL_ARMUNWINDINFO_H +#define LLDB_SYMBOL_ARMUNWINDINFO_H #include "lldb/Symbol/ObjectFile.h" #include "lldb/Utility/DataExtractor.h" @@ -65,4 +65,4 @@ private: } // namespace lldb_private -#endif // liblldb_ArmUnwindInfo_h_ +#endif // LLDB_SYMBOL_ARMUNWINDINFO_H diff --git a/lldb/include/lldb/Symbol/Block.h b/lldb/include/lldb/Symbol/Block.h index c2760dddf45f..de94556d3f22 100644 --- a/lldb/include/lldb/Symbol/Block.h +++ b/lldb/include/lldb/Symbol/Block.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef liblldb_Block_h_ -#define liblldb_Block_h_ +#ifndef LLDB_SYMBOL_BLOCK_H +#define LLDB_SYMBOL_BLOCK_H #include "lldb/Core/AddressRange.h" #include "lldb/Symbol/CompilerType.h" @@ -40,7 +40,7 @@ namespace lldb_private { /// blocks. class Block : public UserID, public SymbolContextScope { public: - typedef RangeArray<uint32_t, uint32_t, 1> RangeList; + typedef RangeVector<uint32_t, uint32_t, 1> RangeList; typedef RangeList::Entry Range; /// Construct with a User ID \a uid, \a depth. @@ -376,9 +376,10 @@ protected: Block *GetSiblingForChild(const Block *child_block) const; private: - DISALLOW_COPY_AND_ASSIGN(Block); + Block(const Block &) = delete; + const Block &operator=(const Block &) = delete; }; } // namespace lldb_private -#endif // liblldb_Block_h_ +#endif // LLDB_SYMBOL_BLOCK_H diff --git a/lldb/include/lldb/Symbol/CallFrameInfo.h b/lldb/include/lldb/Symbol/CallFrameInfo.h index 765ddb41ab0c..7db8722baaf5 100644 --- a/lldb/include/lldb/Symbol/CallFrameInfo.h +++ b/lldb/include/lldb/Symbol/CallFrameInfo.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef liblldb_CallFrameInfo_h_ -#define liblldb_CallFrameInfo_h_ +#ifndef LLDB_SYMBOL_CALLFRAMEINFO_H +#define LLDB_SYMBOL_CALLFRAMEINFO_H #include "lldb/Core/Address.h" @@ -25,4 +25,4 @@ public: } // namespace lldb_private -#endif // liblldb_CallFrameInfo_h_ +#endif // LLDB_SYMBOL_CALLFRAMEINFO_H diff --git a/lldb/include/lldb/Symbol/ClangASTContext.h b/lldb/include/lldb/Symbol/ClangASTContext.h deleted file mode 100644 index 338417b20b8a..000000000000 --- a/lldb/include/lldb/Symbol/ClangASTContext.h +++ /dev/null @@ -1,1006 +0,0 @@ -//===-- ClangASTContext.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_ClangASTContext_h_ -#define liblldb_ClangASTContext_h_ - -#include <stdint.h> - -#include <functional> -#include <initializer_list> -#include <map> -#include <memory> -#include <set> -#include <string> -#include <utility> -#include <vector> - -#include "clang/AST/ASTContext.h" -#include "clang/AST/TemplateBase.h" -#include "llvm/ADT/APSInt.h" -#include "llvm/ADT/SmallVector.h" - -#include "lldb/Core/ClangForward.h" -#include "lldb/Expression/ExpressionVariable.h" -#include "lldb/Symbol/CompilerType.h" -#include "lldb/Symbol/TypeSystem.h" -#include "lldb/Target/Target.h" -#include "lldb/Utility/ConstString.h" -#include "lldb/Utility/Log.h" -#include "lldb/Utility/Logging.h" -#include "lldb/lldb-enumerations.h" - -class DWARFASTParserClang; -class PDBASTParser; - -namespace lldb_private { - -class Declaration; - -class ClangASTContext : public TypeSystem { - // LLVM RTTI support - static char ID; - -public: - typedef void (*CompleteTagDeclCallback)(void *baton, clang::TagDecl *); - typedef void (*CompleteObjCInterfaceDeclCallback)(void *baton, - clang::ObjCInterfaceDecl *); - - // llvm casting support - bool isA(const void *ClassID) const override { return ClassID == &ID; } - static bool classof(const TypeSystem *ts) { return ts->isA(&ID); } - - /// Constructs a ClangASTContext with an ASTContext using the given triple. - /// - /// \param triple The llvm::Triple used for the ASTContext. The triple defines - /// certain characteristics of the ASTContext and its types - /// (e.g., whether certain primitive types exist or what their - /// signedness is). - explicit ClangASTContext(llvm::Triple triple); - - /// Constructs a ClangASTContext that uses an existing ASTContext internally. - /// Useful when having an existing ASTContext created by Clang. - /// - /// \param existing_ctxt An existing ASTContext. - explicit ClangASTContext(clang::ASTContext &existing_ctxt); - - ~ClangASTContext() override; - - void Finalize() override; - - // PluginInterface functions - ConstString GetPluginName() override; - - uint32_t GetPluginVersion() override; - - static ConstString GetPluginNameStatic(); - - static lldb::TypeSystemSP CreateInstance(lldb::LanguageType language, - Module *module, Target *target); - - static LanguageSet GetSupportedLanguagesForTypes(); - static LanguageSet GetSupportedLanguagesForExpressions(); - - static void Initialize(); - - static void Terminate(); - - static ClangASTContext *GetASTContext(clang::ASTContext *ast_ctx); - - static ClangASTContext *GetScratch(Target &target, - bool create_on_demand = true) { - auto type_system_or_err = target.GetScratchTypeSystemForLanguage( - lldb::eLanguageTypeC, create_on_demand); - if (auto err = type_system_or_err.takeError()) { - LLDB_LOG_ERROR(lldb_private::GetLogIfAnyCategoriesSet(LIBLLDB_LOG_TARGET), - std::move(err), "Couldn't get scratch ClangASTContext"); - return nullptr; - } - return llvm::dyn_cast<ClangASTContext>(&type_system_or_err.get()); - } - - clang::ASTContext &getASTContext(); - - clang::MangleContext *getMangleContext(); - - std::shared_ptr<clang::TargetOptions> &getTargetOptions(); - - clang::TargetInfo *getTargetInfo(); - - void setSema(clang::Sema *s); - clang::Sema *getSema() { return m_sema; } - - const char *GetTargetTriple(); - - void SetExternalSource( - llvm::IntrusiveRefCntPtr<clang::ExternalASTSource> &ast_source_up); - - bool GetCompleteDecl(clang::Decl *decl) { - return ClangASTContext::GetCompleteDecl(&getASTContext(), decl); - } - - static void DumpDeclHiearchy(clang::Decl *decl); - - static void DumpDeclContextHiearchy(clang::DeclContext *decl_ctx); - - static bool DeclsAreEquivalent(clang::Decl *lhs_decl, clang::Decl *rhs_decl); - - static bool GetCompleteDecl(clang::ASTContext *ast, clang::Decl *decl); - - void SetMetadataAsUserID(const clang::Decl *decl, lldb::user_id_t user_id); - void SetMetadataAsUserID(const clang::Type *type, lldb::user_id_t user_id); - - void SetMetadata(const clang::Decl *object, ClangASTMetadata &meta_data); - - void SetMetadata(const clang::Type *object, ClangASTMetadata &meta_data); - ClangASTMetadata *GetMetadata(const clang::Decl *object); - ClangASTMetadata *GetMetadata(const clang::Type *object); - - // Basic Types - CompilerType GetBuiltinTypeForEncodingAndBitSize(lldb::Encoding encoding, - size_t bit_size) override; - - CompilerType GetBasicType(lldb::BasicType type); - - static lldb::BasicType GetBasicTypeEnumeration(ConstString name); - - CompilerType - GetBuiltinTypeForDWARFEncodingAndBitSize(llvm::StringRef type_name, - uint32_t dw_ate, uint32_t bit_size); - - CompilerType GetCStringType(bool is_const); - - static clang::DeclContext *GetDeclContextForType(clang::QualType type); - - static clang::DeclContext *GetDeclContextForType(const CompilerType &type); - - uint32_t GetPointerByteSize() override; - - clang::TranslationUnitDecl *GetTranslationUnitDecl() { - return getASTContext().getTranslationUnitDecl(); - } - - static bool AreTypesSame(CompilerType type1, CompilerType type2, - bool ignore_qualifiers = false); - - /// Creates a CompilerType form the given QualType with the current - /// ClangASTContext instance as the CompilerType's typesystem. - /// \param qt The QualType for a type that belongs to the ASTContext of this - /// ClangASTContext. - /// \return The CompilerType representing the given QualType. If the - /// QualType's type pointer is a nullptr then the function returns an - /// invalid CompilerType. - CompilerType GetType(clang::QualType qt) { - if (qt.getTypePtrOrNull() == nullptr) - return CompilerType(); - // Check that the type actually belongs to this ClangASTContext. - assert(qt->getAsTagDecl() == nullptr || - &qt->getAsTagDecl()->getASTContext() == &getASTContext()); - return CompilerType(this, qt.getAsOpaquePtr()); - } - - CompilerType GetTypeForDecl(clang::NamedDecl *decl); - - CompilerType GetTypeForDecl(clang::TagDecl *decl); - - CompilerType GetTypeForDecl(clang::ObjCInterfaceDecl *objc_decl); - - template <typename RecordDeclType> - CompilerType - GetTypeForIdentifier(ConstString type_name, - clang::DeclContext *decl_context = nullptr) { - CompilerType compiler_type; - - if (type_name.GetLength()) { - clang::ASTContext &ast = getASTContext(); - if (!decl_context) - decl_context = ast.getTranslationUnitDecl(); - - clang::IdentifierInfo &myIdent = ast.Idents.get(type_name.GetCString()); - clang::DeclarationName myName = - ast.DeclarationNames.getIdentifier(&myIdent); - - clang::DeclContext::lookup_result result = decl_context->lookup(myName); - - if (!result.empty()) { - clang::NamedDecl *named_decl = result[0]; - if (const RecordDeclType *record_decl = - llvm::dyn_cast<RecordDeclType>(named_decl)) - compiler_type.SetCompilerType( - this, clang::QualType(record_decl->getTypeForDecl(), 0) - .getAsOpaquePtr()); - } - } - - return compiler_type; - } - - CompilerType CreateStructForIdentifier( - ConstString type_name, - const std::initializer_list<std::pair<const char *, CompilerType>> - &type_fields, - bool packed = false); - - CompilerType GetOrCreateStructForIdentifier( - ConstString type_name, - const std::initializer_list<std::pair<const char *, CompilerType>> - &type_fields, - bool packed = false); - - static bool IsOperator(llvm::StringRef name, - clang::OverloadedOperatorKind &op_kind); - - // Structure, Unions, Classes - - static clang::AccessSpecifier - ConvertAccessTypeToAccessSpecifier(lldb::AccessType access); - - static clang::AccessSpecifier - UnifyAccessSpecifiers(clang::AccessSpecifier lhs, clang::AccessSpecifier rhs); - - static uint32_t GetNumBaseClasses(const clang::CXXRecordDecl *cxx_record_decl, - bool omit_empty_base_classes); - - CompilerType CreateRecordType(clang::DeclContext *decl_ctx, - lldb::AccessType access_type, - llvm::StringRef name, int kind, - lldb::LanguageType language, - ClangASTMetadata *metadata = nullptr, - bool exports_symbols = false); - - class TemplateParameterInfos { - public: - bool IsValid() const { - if (args.empty()) - return false; - return args.size() == names.size() && - ((bool)pack_name == (bool)packed_args) && - (!packed_args || !packed_args->packed_args); - } - - llvm::SmallVector<const char *, 2> names; - llvm::SmallVector<clang::TemplateArgument, 2> args; - - const char * pack_name = nullptr; - std::unique_ptr<TemplateParameterInfos> packed_args; - }; - - clang::FunctionTemplateDecl * - CreateFunctionTemplateDecl(clang::DeclContext *decl_ctx, - clang::FunctionDecl *func_decl, const char *name, - const TemplateParameterInfos &infos); - - void CreateFunctionTemplateSpecializationInfo( - clang::FunctionDecl *func_decl, clang::FunctionTemplateDecl *Template, - const TemplateParameterInfos &infos); - - clang::ClassTemplateDecl * - CreateClassTemplateDecl(clang::DeclContext *decl_ctx, - lldb::AccessType access_type, const char *class_name, - int kind, const TemplateParameterInfos &infos); - - clang::TemplateTemplateParmDecl * - CreateTemplateTemplateParmDecl(const char *template_name); - - clang::ClassTemplateSpecializationDecl *CreateClassTemplateSpecializationDecl( - clang::DeclContext *decl_ctx, - clang::ClassTemplateDecl *class_template_decl, int kind, - const TemplateParameterInfos &infos); - - CompilerType - CreateClassTemplateSpecializationType(clang::ClassTemplateSpecializationDecl * - class_template_specialization_decl); - - static clang::DeclContext * - GetAsDeclContext(clang::FunctionDecl *function_decl); - - static bool CheckOverloadedOperatorKindParameterCount( - bool is_method, clang::OverloadedOperatorKind op_kind, - uint32_t num_params); - - bool FieldIsBitfield(clang::FieldDecl *field, uint32_t &bitfield_bit_size); - - static bool RecordHasFields(const clang::RecordDecl *record_decl); - - CompilerType CreateObjCClass(llvm::StringRef name, - clang::DeclContext *decl_ctx, bool isForwardDecl, - bool isInternal, - ClangASTMetadata *metadata = nullptr); - - bool SetTagTypeKind(clang::QualType type, int kind) const; - - bool SetDefaultAccessForRecordFields(clang::RecordDecl *record_decl, - int default_accessibility, - int *assigned_accessibilities, - size_t num_assigned_accessibilities); - - // Returns a mask containing bits from the ClangASTContext::eTypeXXX - // enumerations - - // Namespace Declarations - - clang::NamespaceDecl * - GetUniqueNamespaceDeclaration(const char *name, clang::DeclContext *decl_ctx, - bool is_inline = false); - - // Function Types - - clang::FunctionDecl * - CreateFunctionDeclaration(clang::DeclContext *decl_ctx, const char *name, - const CompilerType &function_Type, int storage, - bool is_inline); - - CompilerType CreateFunctionType(const CompilerType &result_type, - const CompilerType *args, unsigned num_args, - bool is_variadic, unsigned type_quals, - clang::CallingConv cc); - - CompilerType CreateFunctionType(const CompilerType &result_type, - const CompilerType *args, unsigned num_args, - bool is_variadic, unsigned type_quals) { - return CreateFunctionType(result_type, args, num_args, is_variadic, - type_quals, clang::CC_C); - } - - clang::ParmVarDecl *CreateParameterDeclaration(clang::DeclContext *decl_ctx, - const char *name, - const CompilerType ¶m_type, - int storage, - bool add_decl=false); - - void SetFunctionParameters(clang::FunctionDecl *function_decl, - clang::ParmVarDecl **params, unsigned num_params); - - 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 - - CompilerType GetIntTypeFromBitSize(size_t bit_size, bool is_signed); - - CompilerType GetPointerSizedIntType(bool is_signed); - - // Floating point functions - - static CompilerType GetFloatTypeFromBitSize(clang::ASTContext *ast, - size_t bit_size); - - // TypeSystem methods - DWARFASTParser *GetDWARFParser() override; - PDBASTParser *GetPDBParser() override; - - // ClangASTContext callbacks for external source lookups. - void CompleteTagDecl(clang::TagDecl *); - - void CompleteObjCInterfaceDecl(clang::ObjCInterfaceDecl *); - - bool LayoutRecordType( - const clang::RecordDecl *record_decl, uint64_t &size, uint64_t &alignment, - llvm::DenseMap<const clang::FieldDecl *, uint64_t> &field_offsets, - llvm::DenseMap<const clang::CXXRecordDecl *, clang::CharUnits> - &base_offsets, - llvm::DenseMap<const clang::CXXRecordDecl *, clang::CharUnits> - &vbase_offsets); - - // CompilerDecl override functions - ConstString DeclGetName(void *opaque_decl) override; - - ConstString DeclGetMangledName(void *opaque_decl) override; - - CompilerDeclContext DeclGetDeclContext(void *opaque_decl) override; - - CompilerType DeclGetFunctionReturnType(void *opaque_decl) override; - - size_t DeclGetFunctionNumArguments(void *opaque_decl) override; - - CompilerType DeclGetFunctionArgumentType(void *opaque_decl, - size_t arg_idx) override; - - CompilerType GetTypeForDecl(void *opaque_decl) override; - - // CompilerDeclContext override functions - - /// Creates a CompilerDeclContext from the given DeclContext - /// with the current ClangASTContext instance as its typesystem. - /// The DeclContext has to come from the ASTContext of this - /// ClangASTContext. - CompilerDeclContext CreateDeclContext(clang::DeclContext *ctx); - - std::vector<CompilerDecl> - DeclContextFindDeclByName(void *opaque_decl_ctx, ConstString name, - const bool ignore_using_decls) override; - - ConstString DeclContextGetName(void *opaque_decl_ctx) override; - - ConstString DeclContextGetScopeQualifiedName(void *opaque_decl_ctx) override; - - bool DeclContextIsClassMethod(void *opaque_decl_ctx, - lldb::LanguageType *language_ptr, - bool *is_instance_method_ptr, - ConstString *language_object_name_ptr) override; - - bool DeclContextIsContainedInLookup(void *opaque_decl_ctx, - void *other_opaque_decl_ctx) override; - - // Clang specific clang::DeclContext functions - - static clang::DeclContext * - DeclContextGetAsDeclContext(const CompilerDeclContext &dc); - - static clang::ObjCMethodDecl * - DeclContextGetAsObjCMethodDecl(const CompilerDeclContext &dc); - - static clang::CXXMethodDecl * - DeclContextGetAsCXXMethodDecl(const CompilerDeclContext &dc); - - static clang::FunctionDecl * - DeclContextGetAsFunctionDecl(const CompilerDeclContext &dc); - - static clang::NamespaceDecl * - DeclContextGetAsNamespaceDecl(const CompilerDeclContext &dc); - - static ClangASTMetadata *DeclContextGetMetaData(const CompilerDeclContext &dc, - const clang::Decl *object); - - static clang::ASTContext * - DeclContextGetClangASTContext(const CompilerDeclContext &dc); - - // Tests - - bool IsArrayType(lldb::opaque_compiler_type_t type, - CompilerType *element_type, uint64_t *size, - bool *is_incomplete) override; - - bool IsVectorType(lldb::opaque_compiler_type_t type, - CompilerType *element_type, uint64_t *size) override; - - bool IsAggregateType(lldb::opaque_compiler_type_t type) override; - - bool IsAnonymousType(lldb::opaque_compiler_type_t type) override; - - bool IsBeingDefined(lldb::opaque_compiler_type_t type) override; - - bool IsCharType(lldb::opaque_compiler_type_t type) override; - - bool IsCompleteType(lldb::opaque_compiler_type_t type) override; - - bool IsConst(lldb::opaque_compiler_type_t type) override; - - bool IsCStringType(lldb::opaque_compiler_type_t type, - uint32_t &length) override; - - static bool IsCXXClassType(const CompilerType &type); - - bool IsDefined(lldb::opaque_compiler_type_t type) override; - - bool IsFloatingPointType(lldb::opaque_compiler_type_t type, uint32_t &count, - bool &is_complex) override; - - bool IsFunctionType(lldb::opaque_compiler_type_t type, - bool *is_variadic_ptr) override; - - uint32_t IsHomogeneousAggregate(lldb::opaque_compiler_type_t type, - CompilerType *base_type_ptr) override; - - size_t - GetNumberOfFunctionArguments(lldb::opaque_compiler_type_t type) override; - - CompilerType GetFunctionArgumentAtIndex(lldb::opaque_compiler_type_t type, - const size_t index) override; - - bool IsFunctionPointerType(lldb::opaque_compiler_type_t type) override; - - bool IsBlockPointerType(lldb::opaque_compiler_type_t type, - CompilerType *function_pointer_type_ptr) override; - - bool IsIntegerType(lldb::opaque_compiler_type_t type, - bool &is_signed) override; - - bool IsEnumerationType(lldb::opaque_compiler_type_t type, - bool &is_signed) override; - - static bool IsObjCClassType(const CompilerType &type); - - static bool IsObjCClassTypeAndHasIVars(const CompilerType &type, - bool check_superclass); - - static bool IsObjCObjectOrInterfaceType(const CompilerType &type); - - static bool IsObjCObjectPointerType(const CompilerType &type, - CompilerType *target_type = nullptr); - - bool IsPolymorphicClass(lldb::opaque_compiler_type_t type) override; - - static bool IsClassType(lldb::opaque_compiler_type_t type); - - static bool IsEnumType(lldb::opaque_compiler_type_t type); - - bool IsPossibleDynamicType(lldb::opaque_compiler_type_t type, - CompilerType *target_type, // Can pass nullptr - bool check_cplusplus, bool check_objc) override; - - bool IsRuntimeGeneratedType(lldb::opaque_compiler_type_t type) override; - - bool IsPointerType(lldb::opaque_compiler_type_t type, - CompilerType *pointee_type) override; - - bool IsPointerOrReferenceType(lldb::opaque_compiler_type_t type, - CompilerType *pointee_type) override; - - bool IsReferenceType(lldb::opaque_compiler_type_t type, - CompilerType *pointee_type, bool *is_rvalue) override; - - bool IsScalarType(lldb::opaque_compiler_type_t type) override; - - bool IsTypedefType(lldb::opaque_compiler_type_t type) override; - - bool IsVoidType(lldb::opaque_compiler_type_t type) override; - - bool CanPassInRegisters(const CompilerType &type) override; - - bool SupportsLanguage(lldb::LanguageType language) override; - - static llvm::Optional<std::string> GetCXXClassName(const CompilerType &type); - - // Type Completion - - bool GetCompleteType(lldb::opaque_compiler_type_t type) override; - - // Accessors - - ConstString GetTypeName(lldb::opaque_compiler_type_t type) override; - - uint32_t GetTypeInfo(lldb::opaque_compiler_type_t type, - CompilerType *pointee_or_element_compiler_type) override; - - lldb::LanguageType - GetMinimumLanguage(lldb::opaque_compiler_type_t type) override; - - lldb::TypeClass GetTypeClass(lldb::opaque_compiler_type_t type) override; - - 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. - static CompilerType - CreateTypedefType(const CompilerType &type, const char *typedef_name, - const CompilerDeclContext &compiler_decl_ctx); - - CompilerType GetArrayElementType(lldb::opaque_compiler_type_t type, - uint64_t *stride) override; - - CompilerType GetArrayType(lldb::opaque_compiler_type_t type, - uint64_t size) override; - - CompilerType GetCanonicalType(lldb::opaque_compiler_type_t type) override; - - CompilerType - GetFullyUnqualifiedType(lldb::opaque_compiler_type_t type) override; - - // Returns -1 if this isn't a function of if the function doesn't have a - // prototype Returns a value >= 0 if there is a prototype. - int GetFunctionArgumentCount(lldb::opaque_compiler_type_t type) override; - - CompilerType GetFunctionArgumentTypeAtIndex(lldb::opaque_compiler_type_t type, - size_t idx) override; - - CompilerType - GetFunctionReturnType(lldb::opaque_compiler_type_t type) override; - - size_t GetNumMemberFunctions(lldb::opaque_compiler_type_t type) override; - - TypeMemberFunctionImpl - GetMemberFunctionAtIndex(lldb::opaque_compiler_type_t type, - size_t idx) override; - - CompilerType GetNonReferenceType(lldb::opaque_compiler_type_t type) override; - - CompilerType GetPointeeType(lldb::opaque_compiler_type_t type) override; - - CompilerType GetPointerType(lldb::opaque_compiler_type_t type) override; - - CompilerType - GetLValueReferenceType(lldb::opaque_compiler_type_t type) override; - - CompilerType - GetRValueReferenceType(lldb::opaque_compiler_type_t type) override; - - CompilerType GetAtomicType(lldb::opaque_compiler_type_t type) override; - - CompilerType AddConstModifier(lldb::opaque_compiler_type_t type) override; - - CompilerType AddVolatileModifier(lldb::opaque_compiler_type_t type) override; - - CompilerType AddRestrictModifier(lldb::opaque_compiler_type_t type) override; - - CompilerType CreateTypedef(lldb::opaque_compiler_type_t type, - const char *name, - const CompilerDeclContext &decl_ctx) override; - - // 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 - - const llvm::fltSemantics &GetFloatTypeSemantics(size_t byte_size) override; - - llvm::Optional<uint64_t> GetByteSize(lldb::opaque_compiler_type_t type, - ExecutionContextScope *exe_scope) { - if (llvm::Optional<uint64_t> bit_size = GetBitSize(type, exe_scope)) - return (*bit_size + 7) / 8; - return llvm::None; - } - - 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; - - lldb::Format GetFormat(lldb::opaque_compiler_type_t type) override; - - llvm::Optional<size_t> - GetTypeBitAlign(lldb::opaque_compiler_type_t type, - ExecutionContextScope *exe_scope) override; - - uint32_t GetNumChildren(lldb::opaque_compiler_type_t type, - bool omit_empty_base_classes, - const ExecutionContext *exe_ctx) 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, - ConstString name); - - void ForEachEnumerator( - lldb::opaque_compiler_type_t type, - std::function<bool(const CompilerType &integer_type, - ConstString name, - const llvm::APSInt &value)> const &callback) override; - - uint32_t GetNumFields(lldb::opaque_compiler_type_t type) override; - - CompilerType GetFieldAtIndex(lldb::opaque_compiler_type_t type, size_t idx, - std::string &name, uint64_t *bit_offset_ptr, - uint32_t *bitfield_bit_size_ptr, - bool *is_bitfield_ptr) override; - - uint32_t GetNumDirectBaseClasses(lldb::opaque_compiler_type_t type) override; - - uint32_t GetNumVirtualBaseClasses(lldb::opaque_compiler_type_t type) override; - - CompilerType GetDirectBaseClassAtIndex(lldb::opaque_compiler_type_t type, - size_t idx, - uint32_t *bit_offset_ptr) override; - - CompilerType GetVirtualBaseClassAtIndex(lldb::opaque_compiler_type_t type, - size_t idx, - uint32_t *bit_offset_ptr) override; - - static uint32_t GetNumPointeeChildren(clang::QualType type); - - CompilerType GetChildCompilerTypeAtIndex( - lldb::opaque_compiler_type_t type, ExecutionContext *exe_ctx, size_t idx, - bool transparent_pointers, bool omit_empty_base_classes, - bool ignore_array_bounds, std::string &child_name, - uint32_t &child_byte_size, int32_t &child_byte_offset, - uint32_t &child_bitfield_bit_size, uint32_t &child_bitfield_bit_offset, - bool &child_is_base_class, bool &child_is_deref_of_parent, - ValueObject *valobj, uint64_t &language_flags) override; - - // Lookup a child given a name. This function will match base class names and - // member member names in "clang_type" only, not descendants. - uint32_t GetIndexOfChildWithName(lldb::opaque_compiler_type_t type, - const char *name, - bool omit_empty_base_classes) override; - - // Lookup a child member given a name. This function will match member names - // only and will descend into "clang_type" children in search for the first - // member in this class, or any base class that matches "name". - // TODO: Return all matches for a given name by returning a - // vector<vector<uint32_t>> - // so we catch all names that match a given child name, not just the first. - size_t - GetIndexOfChildMemberWithName(lldb::opaque_compiler_type_t type, - const char *name, bool omit_empty_base_classes, - std::vector<uint32_t> &child_indexes) override; - - size_t GetNumTemplateArguments(lldb::opaque_compiler_type_t type) override; - - lldb::TemplateArgumentKind - GetTemplateArgumentKind(lldb::opaque_compiler_type_t type, - size_t idx) override; - CompilerType GetTypeTemplateArgument(lldb::opaque_compiler_type_t type, - size_t idx) override; - llvm::Optional<CompilerType::IntegralTemplateArgument> - GetIntegralTemplateArgument(lldb::opaque_compiler_type_t type, - size_t idx) override; - - CompilerType GetTypeForFormatters(void *type) override; - -#define LLDB_INVALID_DECL_LEVEL UINT32_MAX - // LLDB_INVALID_DECL_LEVEL is returned by CountDeclLevels if child_decl_ctx - // could not be found in decl_ctx. - uint32_t CountDeclLevels(clang::DeclContext *frame_decl_ctx, - clang::DeclContext *child_decl_ctx, - ConstString *child_name = nullptr, - CompilerType *child_type = nullptr); - - // Modifying RecordType - static clang::FieldDecl *AddFieldToRecordType(const CompilerType &type, - llvm::StringRef name, - const CompilerType &field_type, - lldb::AccessType access, - uint32_t bitfield_bit_size); - - static void BuildIndirectFields(const CompilerType &type); - - static void SetIsPacked(const CompilerType &type); - - static clang::VarDecl *AddVariableToRecordType(const CompilerType &type, - llvm::StringRef name, - const CompilerType &var_type, - lldb::AccessType access); - - clang::CXXMethodDecl *AddMethodToCXXRecordType( - lldb::opaque_compiler_type_t type, llvm::StringRef name, - const char *mangled_name, const CompilerType &method_type, - lldb::AccessType access, bool is_virtual, bool is_static, bool is_inline, - bool is_explicit, bool is_attr_used, bool is_artificial); - - void AddMethodOverridesForCXXRecordType(lldb::opaque_compiler_type_t type); - - // C++ Base Classes - std::unique_ptr<clang::CXXBaseSpecifier> - CreateBaseClassSpecifier(lldb::opaque_compiler_type_t type, - lldb::AccessType access, bool is_virtual, - bool base_of_class); - - bool TransferBaseClasses( - lldb::opaque_compiler_type_t type, - std::vector<std::unique_ptr<clang::CXXBaseSpecifier>> bases); - - static bool SetObjCSuperClass(const CompilerType &type, - const CompilerType &superclass_compiler_type); - - static bool AddObjCClassProperty(const CompilerType &type, - const char *property_name, - const CompilerType &property_compiler_type, - clang::ObjCIvarDecl *ivar_decl, - const char *property_setter_name, - const char *property_getter_name, - uint32_t property_attributes, - ClangASTMetadata *metadata); - - static clang::ObjCMethodDecl *AddMethodToObjCObjectType( - const CompilerType &type, - const char *name, // the full symbol name as seen in the symbol table - // (lldb::opaque_compiler_type_t type, "-[NString - // stringWithCString:]") - const CompilerType &method_compiler_type, lldb::AccessType access, - bool is_artificial, bool is_variadic, bool is_objc_direct_call); - - static bool SetHasExternalStorage(lldb::opaque_compiler_type_t type, - bool has_extern); - - // 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); - clang::EnumConstantDecl *AddEnumerationValueToEnumerationType( - const CompilerType &enum_type, const Declaration &decl, const char *name, - const llvm::APSInt &value); - - CompilerType GetEnumerationIntegerType(lldb::opaque_compiler_type_t type); - - // Pointers & References - - // Call this function using the class type when you want to make a member - // pointer type to pointee_type. - static CompilerType CreateMemberPointerType(const CompilerType &type, - const CompilerType &pointee_type); - - // 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); - - /// Dump clang AST types from the symbol file. - /// - /// \param[in] s - /// A stream to send the dumped AST node(s) to - /// \param[in] symbol_name - /// The name of the symbol to dump, if it is empty dump all the symbols - void DumpFromSymbolFile(Stream &s, llvm::StringRef symbol_name); - - void DumpValue(lldb::opaque_compiler_type_t type, ExecutionContext *exe_ctx, - Stream *s, lldb::Format format, const DataExtractor &data, - lldb::offset_t data_offset, size_t data_byte_size, - uint32_t bitfield_bit_size, uint32_t bitfield_bit_offset, - bool show_types, bool show_summary, bool verbose, - uint32_t depth) override; - - bool DumpTypeValue(lldb::opaque_compiler_type_t type, Stream *s, - lldb::Format format, const DataExtractor &data, - lldb::offset_t data_offset, size_t data_byte_size, - uint32_t bitfield_bit_size, uint32_t bitfield_bit_offset, - ExecutionContextScope *exe_scope) override; - - void DumpSummary(lldb::opaque_compiler_type_t type, ExecutionContext *exe_ctx, - Stream *s, const DataExtractor &data, - lldb::offset_t data_offset, size_t data_byte_size) override; - - void DumpTypeDescription( - lldb::opaque_compiler_type_t type) override; // Dump to stdout - - void DumpTypeDescription(lldb::opaque_compiler_type_t type, - Stream *s) override; - - static void DumpTypeName(const CompilerType &type); - - static clang::EnumDecl *GetAsEnumDecl(const CompilerType &type); - - static clang::RecordDecl *GetAsRecordDecl(const CompilerType &type); - - static clang::TagDecl *GetAsTagDecl(const CompilerType &type); - - static clang::TypedefNameDecl *GetAsTypedefDecl(const CompilerType &type); - - static clang::CXXRecordDecl * - GetAsCXXRecordDecl(lldb::opaque_compiler_type_t type); - - static clang::ObjCInterfaceDecl * - GetAsObjCInterfaceDecl(const CompilerType &type); - - clang::ClassTemplateDecl *ParseClassTemplateDecl( - clang::DeclContext *decl_ctx, lldb::AccessType access_type, - const char *parent_name, int tag_decl_kind, - const ClangASTContext::TemplateParameterInfos &template_param_infos); - - clang::BlockDecl *CreateBlockDeclaration(clang::DeclContext *ctx); - - clang::UsingDirectiveDecl * - CreateUsingDirectiveDeclaration(clang::DeclContext *decl_ctx, - clang::NamespaceDecl *ns_decl); - - clang::UsingDecl *CreateUsingDeclaration(clang::DeclContext *current_decl_ctx, - clang::NamedDecl *target); - - clang::VarDecl *CreateVariableDeclaration(clang::DeclContext *decl_context, - const char *name, - clang::QualType type); - - static lldb::opaque_compiler_type_t - GetOpaqueCompilerType(clang::ASTContext *ast, lldb::BasicType basic_type); - - static clang::QualType GetQualType(lldb::opaque_compiler_type_t type) { - if (type) - return clang::QualType::getFromOpaquePtr(type); - return clang::QualType(); - } - - static clang::QualType - GetCanonicalQualType(lldb::opaque_compiler_type_t type) { - if (type) - return clang::QualType::getFromOpaquePtr(type).getCanonicalType(); - return clang::QualType(); - } - - clang::DeclarationName - GetDeclarationName(const char *name, const CompilerType &function_clang_type); - -private: - const clang::ClassTemplateSpecializationDecl * - GetAsTemplateSpecialization(lldb::opaque_compiler_type_t type); - - // Classes that inherit from ClangASTContext can see and modify these - std::string m_target_triple; - 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_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<clang::MangleContext> m_mangle_ctx_up; - uint32_t m_pointer_byte_size = 0; - bool m_ast_owned = false; - - typedef llvm::DenseMap<const clang::Decl *, ClangASTMetadata> DeclMetadataMap; - /// Maps Decls to their associated ClangASTMetadata. - DeclMetadataMap m_decl_metadata; - - typedef llvm::DenseMap<const clang::Type *, ClangASTMetadata> TypeMetadataMap; - /// Maps Types to their associated ClangASTMetadata. - TypeMetadataMap m_type_metadata; - - /// 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; - - // For ClangASTContext only - ClangASTContext(const ClangASTContext &); - const ClangASTContext &operator=(const ClangASTContext &); - /// Creates the internal ASTContext. - void CreateASTContext(); - void SetTargetTriple(llvm::StringRef target_triple); -}; - -class ClangASTContextForExpressions : public ClangASTContext { -public: - ClangASTContextForExpressions(Target &target, llvm::Triple triple); - - ~ClangASTContextForExpressions() override = default; - - void Finalize() override; - - UserExpression * - GetUserExpression(llvm::StringRef expr, llvm::StringRef prefix, - lldb::LanguageType language, - Expression::ResultType desired_type, - const EvaluateExpressionOptions &options, - ValueObject *ctx_obj) override; - - FunctionCaller *GetFunctionCaller(const CompilerType &return_type, - const Address &function_address, - const ValueList &arg_value_list, - const char *name) override; - - UtilityFunction *GetUtilityFunction(const char *text, - const char *name) override; - - PersistentExpressionState *GetPersistentExpressionState() override; -private: - lldb::TargetWP m_target_wp; - std::unique_ptr<PersistentExpressionState> - m_persistent_variables; // These are the persistent variables associated - // with this process for the expression parser - std::unique_ptr<ClangASTSource> m_scratch_ast_source_up; -}; - -} // namespace lldb_private - -#endif // liblldb_ClangASTContext_h_ diff --git a/lldb/include/lldb/Symbol/ClangASTImporter.h b/lldb/include/lldb/Symbol/ClangASTImporter.h deleted file mode 100644 index faec3a77b56f..000000000000 --- a/lldb/include/lldb/Symbol/ClangASTImporter.h +++ /dev/null @@ -1,328 +0,0 @@ -//===-- ClangASTImporter.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_ClangASTImporter_h_ -#define liblldb_ClangASTImporter_h_ - -#include <map> -#include <memory> -#include <set> -#include <vector> - -#include "clang/AST/ASTImporter.h" -#include "clang/AST/CharUnits.h" -#include "clang/AST/Decl.h" -#include "clang/AST/DeclCXX.h" -#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" - -namespace lldb_private { - -class ClangASTImporter { -public: - struct LayoutInfo { - LayoutInfo() - : bit_size(0), alignment(0), field_offsets(), base_offsets(), - vbase_offsets() {} - uint64_t bit_size; - uint64_t alignment; - llvm::DenseMap<const clang::FieldDecl *, uint64_t> field_offsets; - llvm::DenseMap<const clang::CXXRecordDecl *, clang::CharUnits> base_offsets; - llvm::DenseMap<const clang::CXXRecordDecl *, clang::CharUnits> - vbase_offsets; - }; - - ClangASTImporter() - : m_file_manager(clang::FileSystemOptions(), - FileSystem::Instance().GetVirtualFileSystem()) {} - - CompilerType CopyType(ClangASTContext &dst, const CompilerType &src_type); - - clang::Decl *CopyDecl(clang::ASTContext *dst_ctx, clang::Decl *decl); - - CompilerType DeportType(ClangASTContext &dst, const CompilerType &src_type); - - clang::Decl *DeportDecl(clang::ASTContext *dst_ctx, clang::Decl *decl); - - /// Sets the layout for the given RecordDecl. The layout will later be - /// used by Clang's during code generation. Not calling this function for - /// a RecordDecl will cause that Clang's codegen tries to layout the - /// record by itself. - /// - /// \param decl The RecordDecl to set the layout for. - /// \param layout The layout for the record. - void SetRecordLayout(clang::RecordDecl *decl, const LayoutInfo &layout); - - bool LayoutRecordType( - const clang::RecordDecl *record_decl, uint64_t &bit_size, - uint64_t &alignment, - llvm::DenseMap<const clang::FieldDecl *, uint64_t> &field_offsets, - llvm::DenseMap<const clang::CXXRecordDecl *, clang::CharUnits> - &base_offsets, - llvm::DenseMap<const clang::CXXRecordDecl *, clang::CharUnits> - &vbase_offsets); - - bool CanImport(const CompilerType &type); - - bool Import(const CompilerType &type); - - bool CompleteType(const CompilerType &compiler_type); - - void CompleteDecl(clang::Decl *decl); - - bool CompleteTagDecl(clang::TagDecl *decl); - - bool CompleteTagDeclWithOrigin(clang::TagDecl *decl, clang::TagDecl *origin); - - bool CompleteObjCInterfaceDecl(clang::ObjCInterfaceDecl *interface_decl); - - bool CompleteAndFetchChildren(clang::QualType type); - - bool RequireCompleteType(clang::QualType type); - - void SetDeclOrigin(const clang::Decl *decl, clang::Decl *original_decl); - - ClangASTMetadata *GetDeclMetadata(const clang::Decl *decl); - - // - // Namespace maps - // - - typedef std::vector<std::pair<lldb::ModuleSP, CompilerDeclContext>> - NamespaceMap; - typedef std::shared_ptr<NamespaceMap> NamespaceMapSP; - - void RegisterNamespaceMap(const clang::NamespaceDecl *decl, - NamespaceMapSP &namespace_map); - - NamespaceMapSP GetNamespaceMap(const clang::NamespaceDecl *decl); - - void BuildNamespaceMap(const clang::NamespaceDecl *decl); - - // - // Completers for maps - // - - class MapCompleter { - public: - virtual ~MapCompleter(); - - virtual void CompleteNamespaceMap(NamespaceMapSP &namespace_map, - ConstString name, - NamespaceMapSP &parent_map) const = 0; - }; - - void InstallMapCompleter(clang::ASTContext *dst_ctx, - MapCompleter &completer) { - ASTContextMetadataSP context_md; - ContextMetadataMap::iterator context_md_iter = m_metadata_map.find(dst_ctx); - - if (context_md_iter == m_metadata_map.end()) { - context_md = ASTContextMetadataSP(new ASTContextMetadata(dst_ctx)); - m_metadata_map[dst_ctx] = context_md; - } else { - context_md = context_md_iter->second; - } - - context_md->m_map_completer = &completer; - } - - void ForgetDestination(clang::ASTContext *dst_ctx); - void ForgetSource(clang::ASTContext *dst_ctx, clang::ASTContext *src_ctx); - -public: - struct DeclOrigin { - DeclOrigin() : ctx(nullptr), decl(nullptr) {} - - DeclOrigin(clang::ASTContext *_ctx, clang::Decl *_decl) - : ctx(_ctx), decl(_decl) {} - - DeclOrigin(const DeclOrigin &rhs) { - ctx = rhs.ctx; - decl = rhs.decl; - } - - void operator=(const DeclOrigin &rhs) { - ctx = rhs.ctx; - decl = rhs.decl; - } - - bool Valid() { return (ctx != nullptr || decl != nullptr); } - - clang::ASTContext *ctx; - clang::Decl *decl; - }; - - typedef llvm::DenseMap<const clang::Decl *, DeclOrigin> OriginMap; - - /// Listener interface used by the ASTImporterDelegate to inform other code - /// about decls that have been imported the first time. - struct NewDeclListener { - virtual ~NewDeclListener() = default; - /// A decl has been imported for the first time. - virtual void NewDeclImported(clang::Decl *from, clang::Decl *to) = 0; - }; - - /// 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 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. - struct ASTImporterDelegate : public clang::ASTImporter { - 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_master(master), m_source_ctx(source_ctx) { - setODRHandling(clang::ASTImporter::ODRHandlingType::Liberal); - } - - /// 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; - } - } - }; - - void ImportDefinitionTo(clang::Decl *to, clang::Decl *from); - - void Imported(clang::Decl *from, clang::Decl *to) override; - - clang::Decl *GetOriginalDecl(clang::Decl *To) override; - - void SetImportListener(NewDeclListener *listener) { - assert(m_new_decl_listener == nullptr && "Already attached a listener?"); - m_new_decl_listener = listener; - } - void RemoveImportListener() { m_new_decl_listener = nullptr; } - - protected: - llvm::Expected<clang::Decl *> ImportImpl(clang::Decl *From) override; - - private: - /// 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. - llvm::SmallPtrSet<clang::Decl *, 16> m_decls_to_ignore; - ClangASTImporter &m_master; - clang::ASTContext *m_source_ctx; - CxxModuleHandler *m_std_handler = nullptr; - /// The currently attached listener. - NewDeclListener *m_new_decl_listener = nullptr; - }; - - typedef std::shared_ptr<ASTImporterDelegate> ImporterDelegateSP; - typedef llvm::DenseMap<clang::ASTContext *, ImporterDelegateSP> DelegateMap; - typedef llvm::DenseMap<const clang::NamespaceDecl *, NamespaceMapSP> - NamespaceMetaMap; - - struct ASTContextMetadata { - ASTContextMetadata(clang::ASTContext *dst_ctx) - : m_dst_ctx(dst_ctx), m_delegates(), m_origins(), m_namespace_maps(), - m_map_completer(nullptr) {} - - clang::ASTContext *m_dst_ctx; - DelegateMap m_delegates; - OriginMap m_origins; - - NamespaceMetaMap m_namespace_maps; - MapCompleter *m_map_completer; - }; - - typedef std::shared_ptr<ASTContextMetadata> ASTContextMetadataSP; - typedef llvm::DenseMap<const clang::ASTContext *, ASTContextMetadataSP> - ContextMetadataMap; - - ContextMetadataMap m_metadata_map; - - ASTContextMetadataSP GetContextMetadata(clang::ASTContext *dst_ctx) { - ContextMetadataMap::iterator context_md_iter = m_metadata_map.find(dst_ctx); - - if (context_md_iter == m_metadata_map.end()) { - ASTContextMetadataSP context_md = - ASTContextMetadataSP(new ASTContextMetadata(dst_ctx)); - m_metadata_map[dst_ctx] = context_md; - return context_md; - } - return context_md_iter->second; - } - - ASTContextMetadataSP MaybeGetContextMetadata(clang::ASTContext *dst_ctx) { - ContextMetadataMap::iterator context_md_iter = m_metadata_map.find(dst_ctx); - - if (context_md_iter != m_metadata_map.end()) - return context_md_iter->second; - return ASTContextMetadataSP(); - } - - ImporterDelegateSP GetDelegate(clang::ASTContext *dst_ctx, - clang::ASTContext *src_ctx) { - ASTContextMetadataSP context_md = GetContextMetadata(dst_ctx); - - DelegateMap &delegates = context_md->m_delegates; - DelegateMap::iterator delegate_iter = delegates.find(src_ctx); - - if (delegate_iter == delegates.end()) { - ImporterDelegateSP delegate = - ImporterDelegateSP(new ASTImporterDelegate(*this, dst_ctx, src_ctx)); - delegates[src_ctx] = delegate; - return delegate; - } - return delegate_iter->second; - } - -public: - DeclOrigin GetDeclOrigin(const clang::Decl *decl); - - clang::FileManager m_file_manager; - typedef llvm::DenseMap<const clang::RecordDecl *, LayoutInfo> - RecordDeclToLayoutMap; - - RecordDeclToLayoutMap m_record_decl_to_layout_map; -}; - -} // namespace lldb_private - -#endif // liblldb_ClangASTImporter_h_ diff --git a/lldb/include/lldb/Symbol/ClangASTMetadata.h b/lldb/include/lldb/Symbol/ClangASTMetadata.h deleted file mode 100644 index fdf4388f0847..000000000000 --- a/lldb/include/lldb/Symbol/ClangASTMetadata.h +++ /dev/null @@ -1,100 +0,0 @@ -//===-- ClangASTMetadata.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_ClangASTMetadata_h -#define liblldb_ClangASTMetadata_h - -#include "lldb/Core/dwarf.h" -#include "lldb/lldb-defines.h" -#include "lldb/lldb-enumerations.h" - -namespace lldb_private { - -class ClangASTMetadata { -public: - ClangASTMetadata() - : m_user_id(0), m_union_is_user_id(false), m_union_is_isa_ptr(false), - m_has_object_ptr(false), m_is_self(false), m_is_dynamic_cxx(true) {} - - bool GetIsDynamicCXXType() const { return m_is_dynamic_cxx; } - - void SetIsDynamicCXXType(bool b) { m_is_dynamic_cxx = b; } - - void SetUserID(lldb::user_id_t user_id) { - m_user_id = user_id; - m_union_is_user_id = true; - m_union_is_isa_ptr = false; - } - - lldb::user_id_t GetUserID() const { - if (m_union_is_user_id) - return m_user_id; - else - return LLDB_INVALID_UID; - } - - void SetISAPtr(uint64_t isa_ptr) { - m_isa_ptr = isa_ptr; - m_union_is_user_id = false; - m_union_is_isa_ptr = true; - } - - uint64_t GetISAPtr() const { - if (m_union_is_isa_ptr) - return m_isa_ptr; - else - return 0; - } - - void SetObjectPtrName(const char *name) { - m_has_object_ptr = true; - if (strcmp(name, "self") == 0) - m_is_self = true; - else if (strcmp(name, "this") == 0) - m_is_self = false; - else - m_has_object_ptr = false; - } - - lldb::LanguageType GetObjectPtrLanguage() const { - if (m_has_object_ptr) { - if (m_is_self) - return lldb::eLanguageTypeObjC; - else - return lldb::eLanguageTypeC_plus_plus; - } - return lldb::eLanguageTypeUnknown; - } - - const char *GetObjectPtrName() const { - if (m_has_object_ptr) { - if (m_is_self) - return "self"; - else - return "this"; - } else - return nullptr; - } - - bool HasObjectPtr() const { return m_has_object_ptr; } - - void Dump(Stream *s); - -private: - union { - lldb::user_id_t m_user_id; - uint64_t m_isa_ptr; - }; - - bool m_union_is_user_id : 1, m_union_is_isa_ptr : 1, m_has_object_ptr : 1, - m_is_self : 1, m_is_dynamic_cxx : 1; -}; - -} // namespace lldb_private - -#endif // liblldb_ClangASTMetadata_h diff --git a/lldb/include/lldb/Symbol/ClangExternalASTSourceCallbacks.h b/lldb/include/lldb/Symbol/ClangExternalASTSourceCallbacks.h deleted file mode 100644 index 290ecc9b9017..000000000000 --- a/lldb/include/lldb/Symbol/ClangExternalASTSourceCallbacks.h +++ /dev/null @@ -1,46 +0,0 @@ -//===-- ClangExternalASTSourceCallbacks.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_ClangExternalASTSourceCallbacks_h_ -#define liblldb_ClangExternalASTSourceCallbacks_h_ - -#include "lldb/Symbol/ClangASTContext.h" -#include "clang/AST/ExternalASTSource.h" - -namespace lldb_private { - -class ClangASTContext; - -class ClangExternalASTSourceCallbacks : public clang::ExternalASTSource { -public: - ClangExternalASTSourceCallbacks(ClangASTContext &ast) : m_ast(ast) {} - - void FindExternalLexicalDecls( - const clang::DeclContext *DC, - llvm::function_ref<bool(clang::Decl::Kind)> IsKindWeWant, - llvm::SmallVectorImpl<clang::Decl *> &Result) override; - - void CompleteType(clang::TagDecl *tag_decl) override; - - void CompleteType(clang::ObjCInterfaceDecl *objc_decl) override; - - bool layoutRecordType( - const clang::RecordDecl *Record, uint64_t &Size, uint64_t &Alignment, - llvm::DenseMap<const clang::FieldDecl *, uint64_t> &FieldOffsets, - llvm::DenseMap<const clang::CXXRecordDecl *, clang::CharUnits> - &BaseOffsets, - llvm::DenseMap<const clang::CXXRecordDecl *, clang::CharUnits> - &VirtualBaseOffsets) override; - -private: - ClangASTContext &m_ast; -}; - -} // namespace lldb_private - -#endif // liblldb_ClangExternalASTSourceCallbacks_h_ diff --git a/lldb/include/lldb/Symbol/ClangUtil.h b/lldb/include/lldb/Symbol/ClangUtil.h deleted file mode 100644 index 5ffbce340e59..000000000000 --- a/lldb/include/lldb/Symbol/ClangUtil.h +++ /dev/null @@ -1,46 +0,0 @@ -//===-- ClangUtil.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 -// -// A collection of helper methods and data structures for manipulating clang -// types and decls. -//===----------------------------------------------------------------------===// - -#ifndef LLDB_SYMBOL_CLANGUTIL_H -#define LLDB_SYMBOL_CLANGUTIL_H - -#include "clang/AST/DeclBase.h" -#include "clang/AST/Type.h" - -#include "lldb/Symbol/CompilerType.h" - -namespace clang { -class TagDecl; -} - -namespace lldb_private { -struct ClangUtil { - static bool IsClangType(const CompilerType &ct); - - static clang::QualType GetQualType(const CompilerType &ct); - - static clang::QualType GetCanonicalQualType(const CompilerType &ct); - - static CompilerType RemoveFastQualifiers(const CompilerType &ct); - - static clang::TagDecl *GetAsTagDecl(const CompilerType &type); - - /// Returns a textual representation of the given Decl's AST. Does not - /// deserialize any child nodes. - static std::string DumpDecl(const clang::Decl *d); - /// Returns a textual representation of the given type. - static std::string ToString(const clang::Type *t); - /// Returns a textual representation of the given CompilerType (assuming - /// its underlying type is a Clang type). - static std::string ToString(const CompilerType &c); -}; -} - -#endif diff --git a/lldb/include/lldb/Symbol/CompactUnwindInfo.h b/lldb/include/lldb/Symbol/CompactUnwindInfo.h index 2646661ec237..e622c5fde229 100644 --- a/lldb/include/lldb/Symbol/CompactUnwindInfo.h +++ b/lldb/include/lldb/Symbol/CompactUnwindInfo.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef liblldb_CompactUnwindInfo_h_ -#define liblldb_CompactUnwindInfo_h_ +#ifndef LLDB_SYMBOL_COMPACTUNWINDINFO_H +#define LLDB_SYMBOL_COMPACTUNWINDINFO_H #include "lldb/Symbol/ObjectFile.h" #include "lldb/Symbol/UnwindPlan.h" @@ -164,4 +164,4 @@ private: } // namespace lldb_private -#endif // liblldb_CompactUnwindInfo_h_ +#endif // LLDB_SYMBOL_COMPACTUNWINDINFO_H diff --git a/lldb/include/lldb/Symbol/CompileUnit.h b/lldb/include/lldb/Symbol/CompileUnit.h index aec5cc7c8743..256148f20d12 100644 --- a/lldb/include/lldb/Symbol/CompileUnit.h +++ b/lldb/include/lldb/Symbol/CompileUnit.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef liblldb_CompUnit_h_ -#define liblldb_CompUnit_h_ +#ifndef LLDB_SYMBOL_COMPILEUNIT_H +#define LLDB_SYMBOL_COMPILEUNIT_H #include "lldb/Core/FileSpecList.h" #include "lldb/Core/ModuleChild.h" @@ -447,9 +447,10 @@ private: (1u << 6) ///< Have we parsed the debug macros already? }; - DISALLOW_COPY_AND_ASSIGN(CompileUnit); + CompileUnit(const CompileUnit &) = delete; + const CompileUnit &operator=(const CompileUnit &) = delete; }; } // namespace lldb_private -#endif // liblldb_CompUnit_h_ +#endif // LLDB_SYMBOL_COMPILEUNIT_H diff --git a/lldb/include/lldb/Symbol/CompilerDecl.h b/lldb/include/lldb/Symbol/CompilerDecl.h index 4fd269d4730e..67290b9be066 100644 --- a/lldb/include/lldb/Symbol/CompilerDecl.h +++ b/lldb/include/lldb/Symbol/CompilerDecl.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef liblldb_CompilerDecl_h_ -#define liblldb_CompilerDecl_h_ +#ifndef LLDB_SYMBOL_COMPILERDECL_H +#define LLDB_SYMBOL_COMPILERDECL_H #include "lldb/Symbol/CompilerType.h" #include "lldb/Utility/ConstString.h" @@ -94,4 +94,4 @@ bool operator!=(const CompilerDecl &lhs, const CompilerDecl &rhs); } // namespace lldb_private -#endif // #ifndef liblldb_CompilerDecl_h_ +#endif // LLDB_SYMBOL_COMPILERDECL_H diff --git a/lldb/include/lldb/Symbol/CompilerDeclContext.h b/lldb/include/lldb/Symbol/CompilerDeclContext.h index 6db6f4d3f623..87d4ca30884e 100644 --- a/lldb/include/lldb/Symbol/CompilerDeclContext.h +++ b/lldb/include/lldb/Symbol/CompilerDeclContext.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef liblldb_CompilerDeclContext_h_ -#define liblldb_CompilerDeclContext_h_ +#ifndef LLDB_SYMBOL_COMPILERDECLCONTEXT_H +#define LLDB_SYMBOL_COMPILERDECLCONTEXT_H #include <vector> @@ -38,7 +38,7 @@ public: /// This constructor should only be called from the respective TypeSystem /// implementation. /// - /// \see lldb_private::ClangASTContext::CreateDeclContext(clang::DeclContext*) + /// \see lldb_private::TypeSystemClang::CreateDeclContext(clang::DeclContext*) CompilerDeclContext(TypeSystem *type_system, void *decl_ctx) : m_type_system(type_system), m_opaque_decl_ctx(decl_ctx) {} @@ -126,4 +126,4 @@ bool operator!=(const CompilerDeclContext &lhs, const CompilerDeclContext &rhs); } // namespace lldb_private -#endif // #ifndef liblldb_CompilerDeclContext_h_ +#endif // LLDB_SYMBOL_COMPILERDECLCONTEXT_H diff --git a/lldb/include/lldb/Symbol/CompilerType.h b/lldb/include/lldb/Symbol/CompilerType.h index 37e826291c88..280966a327ec 100644 --- a/lldb/include/lldb/Symbol/CompilerType.h +++ b/lldb/include/lldb/Symbol/CompilerType.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef liblldb_CompilerType_h_ -#define liblldb_CompilerType_h_ +#ifndef LLDB_SYMBOL_COMPILERTYPE_H +#define LLDB_SYMBOL_COMPILERTYPE_H #include <functional> #include <string> @@ -37,34 +37,37 @@ public: /// This constructor should only be called from the respective TypeSystem /// implementation. /// - /// \see lldb_private::ClangASTContext::GetType(clang::QualType) + /// \see lldb_private::TypeSystemClang::GetType(clang::QualType) CompilerType(TypeSystem *type_system, lldb::opaque_compiler_type_t type) - : m_type(type), m_type_system(type_system) {} + : m_type(type), m_type_system(type_system) { + assert(Verify() && "verification failed"); + } CompilerType(const CompilerType &rhs) : m_type(rhs.m_type), m_type_system(rhs.m_type_system) {} CompilerType() = default; - // Operators - + /// Operators. + /// \{ const CompilerType &operator=(const CompilerType &rhs) { m_type = rhs.m_type; m_type_system = rhs.m_type_system; return *this; } - // Tests - - explicit operator bool() const { - return m_type != nullptr && m_type_system != nullptr; - } - bool operator<(const CompilerType &rhs) const { if (m_type_system == rhs.m_type_system) return m_type < rhs.m_type; return m_type_system < rhs.m_type_system; } + /// \} + + /// Tests. + /// \{ + explicit operator bool() const { + return m_type != nullptr && m_type_system != nullptr; + } bool IsValid() const { return m_type != nullptr && m_type_system != nullptr; } @@ -115,8 +118,9 @@ public: bool IsPolymorphicClass() const; - bool IsPossibleDynamicType(CompilerType *target_type, // Can pass nullptr - bool check_cplusplus, bool check_objc) const; + /// \param target_type Can pass nullptr. + bool IsPossibleDynamicType(CompilerType *target_type, bool check_cplusplus, + bool check_objc) const; bool IsPointerToScalarType() const; @@ -136,23 +140,22 @@ public: bool IsTypedefType() const; bool IsVoidType() const; + /// \} - // Type Completion - + /// Type Completion. + /// \{ bool GetCompleteType() const; + /// \} - // AST related queries - + /// AST related queries. + /// \{ size_t GetPointerByteSize() const; + /// \} - // Accessors - + /// Accessors. + /// \{ TypeSystem *GetTypeSystem() const { return m_type_system; } - ConstString GetConstQualifiedTypeName() const; - - ConstString GetConstTypeName() const; - ConstString GetTypeName() const; ConstString GetDisplayTypeName() const; @@ -170,9 +173,10 @@ public: lldb::opaque_compiler_type_t type); unsigned GetTypeQualifiers() const; + /// \} - // Creating related types - + /// Creating related types. + /// \{ CompilerType GetArrayElementType(uint64_t *stride = nullptr) const; CompilerType GetArrayType(uint64_t size) const; @@ -181,8 +185,8 @@ public: CompilerType GetFullyUnqualifiedType() const; - // Returns -1 if this isn't a function of if the function doesn't have a - // prototype Returns a value >= 0 if there is a prototype. + /// Returns -1 if this isn't a function of if the function doesn't + /// have a prototype Returns a value >= 0 if there is a prototype. int GetFunctionArgumentCount() const; CompilerType GetFunctionArgumentTypeAtIndex(size_t idx) const; @@ -193,62 +197,65 @@ 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. + /// 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. + /// 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 + /// 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. + /// Return a new CompilerType that is a L value reference to this type if this + /// type is valid and the type system supports L value references, else return + /// an invalid type. CompilerType GetLValueReferenceType() const; - // Return a new CompilerType that is a R value reference to this type if this - // type is valid and the type system supports R value references, else return - // an invalid type. + /// Return a new CompilerType that is a R value reference to this type if this + /// type is valid and the type system supports R value references, else return + /// an invalid type. CompilerType GetRValueReferenceType() const; - // Return a new CompilerType adds a const modifier to this type if this type - // is valid and the type system supports const modifiers, else return an - // invalid type. + /// Return a new CompilerType adds a const modifier to this type if this type + /// is valid and the type system supports const modifiers, else return an + /// invalid type. CompilerType AddConstModifier() const; - // Return a new CompilerType adds a volatile modifier to this type if this - // type is valid and the type system supports volatile modifiers, else return - // an invalid type. + /// Return a new CompilerType adds a volatile modifier to this type if this + /// type is valid and the type system supports volatile modifiers, else return + /// an invalid type. CompilerType AddVolatileModifier() const; - // Return a new CompilerType that is the atomic type of this type. If this - // type is not valid or the type system doesn't support atomic types, this - // returns an invalid type. + /// Return a new CompilerType that is the atomic type of this type. If this + /// type is not valid or the type system doesn't support atomic types, this + /// returns an invalid type. CompilerType GetAtomicType() const; - // Return a new CompilerType adds a restrict modifier to this type if this - // type is valid and the type system supports restrict modifiers, else return - // an invalid type. + /// Return a new CompilerType adds a restrict modifier to this type if this + /// type is valid and the type system supports restrict modifiers, else return + /// an invalid type. CompilerType AddRestrictModifier() const; - // Create a typedef to this type using "name" as the name of the typedef this - // type is valid and the type system supports typedefs, else return an - // invalid type. + /// Create a typedef to this type using "name" as the name of the typedef this + /// type is valid and the type system supports typedefs, else return an + /// invalid type. + /// \param payload The typesystem-specific \p lldb::Type payload. CompilerType CreateTypedef(const char *name, - const CompilerDeclContext &decl_ctx) const; + const CompilerDeclContext &decl_ctx, + uint32_t payload) const; - // If the current object represents a typedef type, get the underlying type + /// If the current object represents a typedef type, get the underlying type CompilerType GetTypedefedType() const; - // Create related types using the current type's AST + /// Create related types using the current type's AST CompilerType GetBasicTypeFromAST(lldb::BasicType basic_type) const; + /// \} - // Exploring the type - + /// Exploring the type. + /// \{ struct IntegralTemplateArgument; /// Return the size of the type in bytes. @@ -260,7 +267,8 @@ public: lldb::Format GetFormat() const; - llvm::Optional<size_t> GetTypeBitAlign(ExecutionContextScope *exe_scope) const; + llvm::Optional<size_t> + GetTypeBitAlign(ExecutionContextScope *exe_scope) const; uint32_t GetNumChildren(bool omit_empty_base_classes, const ExecutionContext *exe_ctx) const; @@ -269,12 +277,11 @@ public: 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. + /// 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, - ConstString name, + std::function<bool(const CompilerType &integer_type, ConstString name, const llvm::APSInt &value)> const &callback) const; uint32_t GetNumFields() const; @@ -309,17 +316,17 @@ public: bool &child_is_deref_of_parent, ValueObject *valobj, uint64_t &language_flags) const; - // Lookup a child given a name. This function will match base class names and - // member member names in "clang_type" only, not descendants. + /// Lookup a child given a name. This function will match base class names and + /// member member names in "clang_type" only, not descendants. uint32_t GetIndexOfChildWithName(const char *name, bool omit_empty_base_classes) const; - // Lookup a child member given a name. This function will match member names - // only and will descend into "clang_type" children in search for the first - // member in this class, or any base class that matches "name". - // TODO: Return all matches for a given name by returning a - // vector<vector<uint32_t>> - // so we catch all names that match a given child name, not just the first. + /// Lookup a child member given a name. This function will match member names + /// only and will descend into "clang_type" children in search for the first + /// member in this class, or any base class that matches "name". + /// TODO: Return all matches for a given name by returning a + /// vector<vector<uint32_t>> + /// so we catch all names that match a given child name, not just the first. size_t GetIndexOfChildMemberWithName(const char *name, bool omit_empty_base_classes, std::vector<uint32_t> &child_indexes) const; @@ -329,7 +336,7 @@ public: lldb::TemplateArgumentKind GetTemplateArgumentKind(size_t idx) const; CompilerType GetTypeTemplateArgument(size_t idx) const; - // Returns the value of the template argument and its type. + /// Returns the value of the template argument and its type. llvm::Optional<IntegralTemplateArgument> GetIntegralTemplateArgument(size_t idx) const; @@ -338,9 +345,10 @@ public: LazyBool ShouldPrintAsOneLiner(ValueObject *valobj) const; bool IsMeaninglessWithoutDynamicResolution() const; + /// \} - // Dumping types - + /// Dumping types. + /// \{ #ifndef NDEBUG /// Convenience LLVM-style dump method for use in the debugger only. /// Don't call this function from actual code. @@ -362,19 +370,33 @@ public: const DataExtractor &data, lldb::offset_t data_offset, size_t data_byte_size); - void DumpTypeDescription() const; // Dump to stdout + /// Dump to stdout. + void DumpTypeDescription(lldb::DescriptionLevel level = + lldb::eDescriptionLevelFull) const; - void DumpTypeDescription(Stream *s) const; + /// Print a description of the type to a stream. The exact implementation + /// varies, but the expectation is that eDescriptionLevelFull returns a + /// source-like representation of the type, whereas eDescriptionLevelVerbose + /// does a dump of the underlying AST if applicable. + void DumpTypeDescription(Stream *s, lldb::DescriptionLevel level = + lldb::eDescriptionLevelFull) const; + /// \} bool GetValueAsScalar(const DataExtractor &data, lldb::offset_t data_offset, size_t data_byte_size, Scalar &value) const; - void Clear() { m_type = nullptr; m_type_system = nullptr; } private: +#ifndef NDEBUG + /// If the type is valid, ask the TypeSystem to verify the integrity + /// of the type to catch CompilerTypes that mix and match invalid + /// TypeSystem/Opaque type pairs. + bool Verify() const; +#endif + lldb::opaque_compiler_type_t m_type = nullptr; TypeSystem *m_type_system = nullptr; }; @@ -389,4 +411,4 @@ struct CompilerType::IntegralTemplateArgument { } // namespace lldb_private -#endif // liblldb_CompilerType_h_ +#endif // LLDB_SYMBOL_COMPILERTYPE_H diff --git a/lldb/include/lldb/Symbol/CxxModuleHandler.h b/lldb/include/lldb/Symbol/CxxModuleHandler.h deleted file mode 100644 index f4aef3666ece..000000000000 --- a/lldb/include/lldb/Symbol/CxxModuleHandler.h +++ /dev/null @@ -1,65 +0,0 @@ -//===-- 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/lldb/include/lldb/Symbol/DWARFCallFrameInfo.h b/lldb/include/lldb/Symbol/DWARFCallFrameInfo.h index 104075f28df3..f85bc7e844a0 100644 --- a/lldb/include/lldb/Symbol/DWARFCallFrameInfo.h +++ b/lldb/include/lldb/Symbol/DWARFCallFrameInfo.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef liblldb_DWARFCallFrameInfo_h_ -#define liblldb_DWARFCallFrameInfo_h_ +#ifndef LLDB_SYMBOL_DWARFCALLFRAMEINFO_H +#define LLDB_SYMBOL_DWARFCALLFRAMEINFO_H #include <map> #include <mutex> @@ -166,4 +166,4 @@ private: } // namespace lldb_private -#endif // liblldb_DWARFCallFrameInfo_h_ +#endif // LLDB_SYMBOL_DWARFCALLFRAMEINFO_H diff --git a/lldb/include/lldb/Symbol/DebugMacros.h b/lldb/include/lldb/Symbol/DebugMacros.h index da46c8b23c1d..0ea70f5deb84 100644 --- a/lldb/include/lldb/Symbol/DebugMacros.h +++ b/lldb/include/lldb/Symbol/DebugMacros.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef liblldb_DebugMacros_h_ -#define liblldb_DebugMacros_h_ +#ifndef LLDB_SYMBOL_DEBUGMACROS_H +#define LLDB_SYMBOL_DEBUGMACROS_H #include <memory> #include <vector> @@ -27,7 +27,6 @@ public: INVALID, DEFINE, UNDEF, START_FILE, END_FILE, INDIRECT }; -public: static DebugMacroEntry CreateDefineEntry(uint32_t line, const char *str); static DebugMacroEntry CreateUndefEntry(uint32_t line, const char *str); @@ -89,11 +88,12 @@ public: } private: - DISALLOW_COPY_AND_ASSIGN(DebugMacros); + DebugMacros(const DebugMacros &) = delete; + const DebugMacros &operator=(const DebugMacros &) = delete; std::vector<DebugMacroEntry> m_macro_entries; }; } // namespace lldb_private -#endif // liblldb_DebugMacros_h_ +#endif // LLDB_SYMBOL_DEBUGMACROS_H diff --git a/lldb/include/lldb/Symbol/DeclVendor.h b/lldb/include/lldb/Symbol/DeclVendor.h index 748c0c8ac961..67dcaf1734bd 100644 --- a/lldb/include/lldb/Symbol/DeclVendor.h +++ b/lldb/include/lldb/Symbol/DeclVendor.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef liblldb_DeclVendor_h_ -#define liblldb_DeclVendor_h_ +#ifndef LLDB_SYMBOL_DECLVENDOR_H +#define LLDB_SYMBOL_DECLVENDOR_H #include "lldb/lldb-defines.h" @@ -67,7 +67,8 @@ public: private: // For DeclVendor only - DISALLOW_COPY_AND_ASSIGN(DeclVendor); + DeclVendor(const DeclVendor &) = delete; + const DeclVendor &operator=(const DeclVendor &) = delete; const DeclVendorKind m_kind; }; diff --git a/lldb/include/lldb/Symbol/Declaration.h b/lldb/include/lldb/Symbol/Declaration.h index a751d6ba039f..7f19f45411a0 100644 --- a/lldb/include/lldb/Symbol/Declaration.h +++ b/lldb/include/lldb/Symbol/Declaration.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef liblldb_Declaration_h_ -#define liblldb_Declaration_h_ +#ifndef LLDB_SYMBOL_DECLARATION_H +#define LLDB_SYMBOL_DECLARATION_H #include "lldb/Utility/FileSpec.h" #include "lldb/lldb-private.h" @@ -202,4 +202,4 @@ bool operator==(const Declaration &lhs, const Declaration &rhs); } // namespace lldb_private -#endif // liblldb_Declaration_h_ +#endif // LLDB_SYMBOL_DECLARATION_H diff --git a/lldb/include/lldb/Symbol/FuncUnwinders.h b/lldb/include/lldb/Symbol/FuncUnwinders.h index c49f6b0fa942..2e841b3b34bd 100644 --- a/lldb/include/lldb/Symbol/FuncUnwinders.h +++ b/lldb/include/lldb/Symbol/FuncUnwinders.h @@ -1,5 +1,5 @@ -#ifndef liblldb_FuncUnwinders_h -#define liblldb_FuncUnwinders_h +#ifndef LLDB_SYMBOL_FUNCUNWINDERS_H +#define LLDB_SYMBOL_FUNCUNWINDERS_H #include "lldb/Core/AddressRange.h" #include "lldb/lldb-private-enumerations.h" @@ -149,10 +149,11 @@ private: Address m_first_non_prologue_insn; - DISALLOW_COPY_AND_ASSIGN(FuncUnwinders); + FuncUnwinders(const FuncUnwinders &) = delete; + const FuncUnwinders &operator=(const FuncUnwinders &) = delete; }; // class FuncUnwinders } // namespace lldb_private -#endif // liblldb_FuncUnwinders_h +#endif // LLDB_SYMBOL_FUNCUNWINDERS_H diff --git a/lldb/include/lldb/Symbol/Function.h b/lldb/include/lldb/Symbol/Function.h index f675b5fdffa6..300d829219d4 100644 --- a/lldb/include/lldb/Symbol/Function.h +++ b/lldb/include/lldb/Symbol/Function.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef liblldb_Function_h_ -#define liblldb_Function_h_ +#ifndef LLDB_SYMBOL_FUNCTION_H +#define LLDB_SYMBOL_FUNCTION_H #include "lldb/Core/AddressRange.h" #include "lldb/Core/Mangled.h" @@ -17,6 +17,8 @@ #include "lldb/Utility/UserID.h" #include "llvm/ADT/ArrayRef.h" +#include <mutex> + namespace lldb_private { class ExecutionContext; @@ -113,10 +115,11 @@ public: 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. + /// Function method name (not a mangled name). + ConstString m_name; + + /// Information describing where this function information was defined. + Declaration m_declaration; }; /// \class InlineFunctionInfo Function.h "lldb/Symbol/Function.h" @@ -199,11 +202,11 @@ public: /// 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; + void DumpStopContext(Stream *s) const; - ConstString GetName(lldb::LanguageType language) const; + ConstString GetName() const; - ConstString GetDisplayName(lldb::LanguageType language) const; + ConstString GetDisplayName() const; /// Get accessor for the call site declaration information. /// @@ -240,9 +243,10 @@ public: size_t MemorySize() const override; private: - // Member variables. - Mangled m_mangled; ///< Mangled inlined function name (can be empty if there - ///is no mangled information). + /// Mangled inlined function name (can be empty if there is no mangled + /// information). + Mangled m_mangled; + Declaration m_call_decl; }; @@ -266,6 +270,7 @@ using CallSiteParameterArray = llvm::SmallVector<CallSiteParameter, 0>; /// in the call graph between two functions, or to evaluate DW_OP_entry_value. class CallEdge { public: + enum class AddrType : uint8_t { Call, AfterCall }; virtual ~CallEdge() {} /// Get the callee's definition. @@ -281,23 +286,50 @@ public: /// made the call. lldb::addr_t GetReturnPCAddress(Function &caller, Target &target) const; - /// Like \ref GetReturnPCAddress, but returns an unslid function-local PC - /// offset. - lldb::addr_t GetUnresolvedReturnPCAddress() const { return return_pc; } + /// Return an address in the caller. This can either be the address of the + /// call instruction, or the address of the instruction after the call. + std::pair<AddrType, lldb::addr_t> GetCallerAddress(Function &caller, + Target &target) const { + return {caller_address_type, + GetLoadAddress(caller_address, caller, target)}; + } + + bool IsTailCall() const { return is_tail_call; } /// Get the call site parameters available at this call edge. llvm::ArrayRef<CallSiteParameter> GetCallSiteParameters() const { return parameters; } + /// Non-tail-calls go first, sorted by the return address. They are followed + /// by tail calls, which have no specific order. + std::pair<bool, lldb::addr_t> GetSortKey() const { + return {is_tail_call, GetUnresolvedReturnPCAddress()}; + } + protected: - CallEdge(lldb::addr_t return_pc, CallSiteParameterArray &¶meters) - : return_pc(return_pc), parameters(std::move(parameters)) {} + CallEdge(AddrType caller_address_type, lldb::addr_t caller_address, + bool is_tail_call, CallSiteParameterArray &¶meters) + : caller_address(caller_address), + caller_address_type(caller_address_type), is_tail_call(is_tail_call), + parameters(std::move(parameters)) {} + + /// Helper that finds the load address of \p unresolved_pc, a file address + /// which refers to an instruction within \p caller. + static lldb::addr_t GetLoadAddress(lldb::addr_t unresolved_pc, + Function &caller, Target &target); + + /// Like \ref GetReturnPCAddress, but returns an unresolved file address. + lldb::addr_t GetUnresolvedReturnPCAddress() const { + return caller_address_type == AddrType::AfterCall && !is_tail_call + ? caller_address + : LLDB_INVALID_ADDRESS; + } - /// An invalid address if this is a tail call. Otherwise, the function-local - /// PC offset. Adding this PC offset to the function's base load address - /// gives the return PC for the call. - lldb::addr_t return_pc; +private: + lldb::addr_t caller_address; + AddrType caller_address_type; + bool is_tail_call; CallSiteParameterArray parameters; }; @@ -309,9 +341,11 @@ class DirectCallEdge : public CallEdge { public: /// Construct a call edge using a symbol name to identify the callee, and a /// return PC within the calling function to identify a specific call site. - DirectCallEdge(const char *symbol_name, lldb::addr_t return_pc, + DirectCallEdge(const char *symbol_name, AddrType caller_address_type, + lldb::addr_t caller_address, bool is_tail_call, CallSiteParameterArray &¶meters) - : CallEdge(return_pc, std::move(parameters)) { + : CallEdge(caller_address_type, caller_address, is_tail_call, + std::move(parameters)) { lazy_callee.symbol_name = symbol_name; } @@ -340,9 +374,11 @@ class IndirectCallEdge : public CallEdge { public: /// Construct a call edge using a DWARFExpression to identify the callee, and /// a return PC within the calling function to identify a specific call site. - IndirectCallEdge(DWARFExpression call_target, lldb::addr_t return_pc, + IndirectCallEdge(DWARFExpression call_target, AddrType caller_address_type, + lldb::addr_t caller_address, bool is_tail_call, CallSiteParameterArray &¶meters) - : CallEdge(return_pc, std::move(parameters)), + : CallEdge(caller_address_type, caller_address, is_tail_call, + std::move(parameters)), call_target(std::move(call_target)) {} Function *GetCallee(ModuleList &images, ExecutionContext &exe_ctx) override; @@ -602,34 +638,55 @@ public: protected: enum { - flagsCalculatedPrologueSize = - (1 << 0) ///< Have we already tried to calculate the prologue size? + /// Whether we already tried to calculate the prologue size. + flagsCalculatedPrologueSize = (1 << 0) }; - // 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. - Type *m_type; ///< The function prototype type for this function that include - ///the function info (FunctionInfo), return type and parameters. - Mangled m_mangled; ///< The mangled function name if any, if empty, there is - ///no mangled information. - Block m_block; ///< All lexical blocks contained in this function. - AddressRange m_range; ///< The function address range that covers the widest - ///range needed to contain all blocks - DWARFExpression m_frame_base; ///< The frame base expression for variables - ///that are relative to the frame pointer. + /// The compile unit that owns this function. + CompileUnit *m_comp_unit; + + /// The user ID of for the prototype Type for this function. + lldb::user_id_t m_type_uid; + + /// The function prototype type for this function that includes the function + /// info (FunctionInfo), return type and parameters. + Type *m_type; + + /// The mangled function name if any. If empty, there is no mangled + /// information. + Mangled m_mangled; + + /// All lexical blocks contained in this function. + Block m_block; + + /// The function address range that covers the widest range needed to contain + /// all blocks + AddressRange m_range; + + /// The frame base expression for variables that are relative to the frame + /// pointer. + DWARFExpression m_frame_base; + Flags m_flags; - uint32_t - m_prologue_byte_size; ///< Compute the prologue size once and cache it - bool m_call_edges_resolved = false; ///< Whether call site info has been - /// parsed. - std::vector<std::unique_ptr<CallEdge>> m_call_edges; ///< Outgoing call edges. + /// Compute the prologue size once and cache it. + uint32_t m_prologue_byte_size; + + /// Exclusive lock that controls read/write access to m_call_edges and + /// m_call_edges_resolved. + std::mutex m_call_edges_lock; + + /// Whether call site info has been parsed. + bool m_call_edges_resolved = false; + + /// Outgoing call edges. + std::vector<std::unique_ptr<CallEdge>> m_call_edges; + private: - DISALLOW_COPY_AND_ASSIGN(Function); + Function(const Function &) = delete; + const Function &operator=(const Function &) = delete; }; } // namespace lldb_private -#endif // liblldb_Function_h_ +#endif // LLDB_SYMBOL_FUNCTION_H diff --git a/lldb/include/lldb/Symbol/LineEntry.h b/lldb/include/lldb/Symbol/LineEntry.h index 32ffef72ee5e..7e56ef814765 100644 --- a/lldb/include/lldb/Symbol/LineEntry.h +++ b/lldb/include/lldb/Symbol/LineEntry.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef liblldb_LineEntry_h_ -#define liblldb_LineEntry_h_ +#ifndef LLDB_SYMBOL_LINEENTRY_H +#define LLDB_SYMBOL_LINEENTRY_H #include "lldb/Core/AddressRange.h" #include "lldb/Utility/FileSpec.h" @@ -118,7 +118,7 @@ struct LineEntry { /// 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 + /// range of continuous LineEntries with line #0 will be included in the /// complete range. /// /// @param[in] include_inlined_functions @@ -173,4 +173,4 @@ bool operator<(const LineEntry &lhs, const LineEntry &rhs); } // namespace lldb_private -#endif // liblldb_LineEntry_h_ +#endif // LLDB_SYMBOL_LINEENTRY_H diff --git a/lldb/include/lldb/Symbol/LineTable.h b/lldb/include/lldb/Symbol/LineTable.h index 043f3eb895cb..d66b58ca4c6d 100644 --- a/lldb/include/lldb/Symbol/LineTable.h +++ b/lldb/include/lldb/Symbol/LineTable.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef liblldb_LineTable_h_ -#define liblldb_LineTable_h_ +#ifndef LLDB_SYMBOL_LINETABLE_H +#define LLDB_SYMBOL_LINETABLE_H #include "lldb/Core/ModuleChild.h" #include "lldb/Core/Section.h" @@ -29,7 +29,8 @@ public: virtual void Clear() = 0; private: - DISALLOW_COPY_AND_ASSIGN(LineSequence); + LineSequence(const LineSequence &) = delete; + const LineSequence &operator=(const LineSequence &) = delete; }; /// \class LineTable LineTable.h "lldb/Symbol/LineTable.h" @@ -42,6 +43,13 @@ public: /// The compile unit to which this line table belongs. LineTable(CompileUnit *comp_unit); + /// Construct with entries found in \a sequences. + /// + /// \param[in] sequences + /// Unsorted list of line sequences. + LineTable(CompileUnit *comp_unit, + std::vector<std::unique_ptr<LineSequence>> &&sequences); + /// Destructor. ~LineTable(); @@ -64,11 +72,11 @@ public: bool is_epilogue_begin, bool is_terminal_entry); // Used to instantiate the LineSequence helper class - LineSequence *CreateLineSequenceContainer(); + static std::unique_ptr<LineSequence> CreateLineSequenceContainer(); // Append an entry to a caller-provided collection that will later be // inserted in this line table. - void AppendLineEntryToSequence(LineSequence *sequence, lldb::addr_t file_addr, + static void AppendLineEntryToSequence(LineSequence *sequence, lldb::addr_t file_addr, uint32_t line, uint16_t column, uint16_t file_idx, bool is_start_of_statement, bool is_start_of_basic_block, @@ -176,7 +184,7 @@ public: /// 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> + typedef lldb_private::RangeVector<lldb::addr_t, lldb::addr_t, 32> FileAddressRanges; /// Gets all contiguous file address ranges for the entire line table. @@ -259,6 +267,8 @@ protected: public: LessThanBinaryPredicate(LineTable *line_table); bool operator()(const LineTable::Entry &, const LineTable::Entry &) const; + bool operator()(const std::unique_ptr<LineSequence> &, + const std::unique_ptr<LineSequence> &) const; protected: LineTable *m_line_table; @@ -328,9 +338,10 @@ protected: bool ConvertEntryAtIndexToLineEntry(uint32_t idx, LineEntry &line_entry); private: - DISALLOW_COPY_AND_ASSIGN(LineTable); + LineTable(const LineTable &) = delete; + const LineTable &operator=(const LineTable &) = delete; }; } // namespace lldb_private -#endif // liblldb_LineTable_h_ +#endif // LLDB_SYMBOL_LINETABLE_H diff --git a/lldb/include/lldb/Symbol/LocateSymbolFile.h b/lldb/include/lldb/Symbol/LocateSymbolFile.h index 0ff834df9c40..93b76e53f41f 100644 --- a/lldb/include/lldb/Symbol/LocateSymbolFile.h +++ b/lldb/include/lldb/Symbol/LocateSymbolFile.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef liblldb_Symbols_h_ -#define liblldb_Symbols_h_ +#ifndef LLDB_SYMBOL_LOCATESYMBOLFILE_H +#define LLDB_SYMBOL_LOCATESYMBOLFILE_H #include <stdint.h> @@ -55,4 +55,4 @@ public: } // namespace lldb_private -#endif // liblldb_Symbols_h_ +#endif // LLDB_SYMBOL_LOCATESYMBOLFILE_H diff --git a/lldb/include/lldb/Symbol/ObjectContainer.h b/lldb/include/lldb/Symbol/ObjectContainer.h index 9310fdc18d90..1e01e93da9d2 100644 --- a/lldb/include/lldb/Symbol/ObjectContainer.h +++ b/lldb/include/lldb/Symbol/ObjectContainer.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef liblldb_ObjectContainer_h_ -#define liblldb_ObjectContainer_h_ +#ifndef LLDB_SYMBOL_OBJECTCONTAINER_H +#define LLDB_SYMBOL_OBJECTCONTAINER_H #include "lldb/Core/ModuleChild.h" #include "lldb/Core/PluginInterface.h" @@ -167,9 +167,10 @@ protected: m_data; ///< The data for this object file so things can be parsed lazily. private: - DISALLOW_COPY_AND_ASSIGN(ObjectContainer); + ObjectContainer(const ObjectContainer &) = delete; + const ObjectContainer &operator=(const ObjectContainer &) = delete; }; } // namespace lldb_private -#endif // liblldb_ObjectContainer_h_ +#endif // LLDB_SYMBOL_OBJECTCONTAINER_H diff --git a/lldb/include/lldb/Symbol/ObjectFile.h b/lldb/include/lldb/Symbol/ObjectFile.h index 841a38e5b15a..e814015c0bf7 100644 --- a/lldb/include/lldb/Symbol/ObjectFile.h +++ b/lldb/include/lldb/Symbol/ObjectFile.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef liblldb_ObjectFile_h_ -#define liblldb_ObjectFile_h_ +#ifndef LLDB_SYMBOL_OBJECTFILE_H +#define LLDB_SYMBOL_OBJECTFILE_H #include "lldb/Core/FileSpecList.h" #include "lldb/Core/ModuleChild.h" @@ -172,10 +172,10 @@ public: lldb::addr_t header_addr, lldb::DataBufferSP &file_data_sp); - static size_t GetModuleSpecifications(const FileSpec &file, - lldb::offset_t file_offset, - lldb::offset_t file_size, - ModuleSpecList &specs); + static size_t + GetModuleSpecifications(const FileSpec &file, lldb::offset_t file_offset, + lldb::offset_t file_size, ModuleSpecList &specs, + lldb::DataBufferSP data_sp = lldb::DataBufferSP()); static size_t GetModuleSpecifications(const lldb_private::FileSpec &file, lldb::DataBufferSP &data_sp, @@ -686,7 +686,8 @@ protected: uint64_t Offset); private: - DISALLOW_COPY_AND_ASSIGN(ObjectFile); + ObjectFile(const ObjectFile &) = delete; + const ObjectFile &operator=(const ObjectFile &) = delete; }; } // namespace lldb_private @@ -703,4 +704,4 @@ template <> struct format_provider<lldb_private::ObjectFile::Strata> { }; } // namespace llvm -#endif // liblldb_ObjectFile_h_ +#endif // LLDB_SYMBOL_OBJECTFILE_H diff --git a/lldb/include/lldb/Symbol/SourceModule.h b/lldb/include/lldb/Symbol/SourceModule.h index b12ff01a5198..7799b6504b15 100644 --- a/lldb/include/lldb/Symbol/SourceModule.h +++ b/lldb/include/lldb/Symbol/SourceModule.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef liblldb_SourceModule_h_ -#define liblldb_SourceModule_h_ +#ifndef LLDB_SYMBOL_SOURCEMODULE_H +#define LLDB_SYMBOL_SOURCEMODULE_H #include "lldb/Utility/ConstString.h" #include <vector> diff --git a/lldb/include/lldb/Symbol/Symbol.h b/lldb/include/lldb/Symbol/Symbol.h index 36f89c044ea9..3a235f260ba5 100644 --- a/lldb/include/lldb/Symbol/Symbol.h +++ b/lldb/include/lldb/Symbol/Symbol.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef liblldb_Symbol_h_ -#define liblldb_Symbol_h_ +#ifndef LLDB_SYMBOL_SYMBOL_H +#define LLDB_SYMBOL_SYMBOL_H #include "lldb/Core/AddressRange.h" #include "lldb/Core/Mangled.h" @@ -267,4 +267,4 @@ protected: } // namespace lldb_private -#endif // liblldb_Symbol_h_ +#endif // LLDB_SYMBOL_SYMBOL_H diff --git a/lldb/include/lldb/Symbol/SymbolContext.h b/lldb/include/lldb/Symbol/SymbolContext.h index 4c7b727fe618..cc49ce51c713 100644 --- a/lldb/include/lldb/Symbol/SymbolContext.h +++ b/lldb/include/lldb/Symbol/SymbolContext.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef liblldb_SymbolContext_h_ -#define liblldb_SymbolContext_h_ +#ifndef LLDB_SYMBOL_SYMBOLCONTEXT_H +#define LLDB_SYMBOL_SYMBOLCONTEXT_H #include <memory> #include <string> @@ -475,4 +475,4 @@ bool operator!=(const SymbolContextList &lhs, const SymbolContextList &rhs); } // namespace lldb_private -#endif // liblldb_SymbolContext_h_ +#endif // LLDB_SYMBOL_SYMBOLCONTEXT_H diff --git a/lldb/include/lldb/Symbol/SymbolContextScope.h b/lldb/include/lldb/Symbol/SymbolContextScope.h index a626302053df..3b244caed333 100644 --- a/lldb/include/lldb/Symbol/SymbolContextScope.h +++ b/lldb/include/lldb/Symbol/SymbolContextScope.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef liblldb_SymbolContextScope_h_ -#define liblldb_SymbolContextScope_h_ +#ifndef LLDB_SYMBOL_SYMBOLCONTEXTSCOPE_H +#define LLDB_SYMBOL_SYMBOLCONTEXTSCOPE_H #include "lldb/lldb-private.h" @@ -100,4 +100,4 @@ public: } // namespace lldb_private -#endif // liblldb_SymbolContextScope_h_ +#endif // LLDB_SYMBOL_SYMBOLCONTEXTSCOPE_H diff --git a/lldb/include/lldb/Symbol/SymbolFile.h b/lldb/include/lldb/Symbol/SymbolFile.h index fdd812eb5167..9f5806915dcb 100644 --- a/lldb/include/lldb/Symbol/SymbolFile.h +++ b/lldb/include/lldb/Symbol/SymbolFile.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef liblldb_SymbolFile_h_ -#define liblldb_SymbolFile_h_ +#ifndef LLDB_SYMBOL_SYMBOLFILE_H +#define LLDB_SYMBOL_SYMBOLFILE_H #include "lldb/Core/PluginInterface.h" #include "lldb/Symbol/CompilerDecl.h" @@ -18,6 +18,7 @@ #include "lldb/Symbol/Type.h" #include "lldb/Symbol/TypeList.h" #include "lldb/Symbol/TypeSystem.h" +#include "lldb/Utility/XcodeSDK.h" #include "lldb/lldb-private.h" #include "llvm/ADT/DenseSet.h" #include "llvm/Support/Errc.h" @@ -128,6 +129,8 @@ public: Symtab *GetSymtab(); virtual lldb::LanguageType ParseLanguage(CompileUnit &comp_unit) = 0; + /// Return the Xcode SDK comp_unit was compiled against. + virtual XcodeSDK ParseXcodeSDK(CompileUnit &comp_unit) { return {}; } virtual size_t ParseFunctions(CompileUnit &comp_unit) = 0; virtual bool ParseLineTable(CompileUnit &comp_unit) = 0; virtual bool ParseDebugMacros(CompileUnit &comp_unit) = 0; @@ -136,12 +139,16 @@ public: /// \p comp_unit. Recursively also descends into the referenced external /// modules of any encountered compilation unit. /// + /// This function can be used to traverse Clang -gmodules debug + /// information, which is stored in DWARF files separate from the + /// object files. + /// /// \param comp_unit /// When this SymbolFile consists of multiple auxilliary /// SymbolFiles, for example, a Darwin debug map that references /// multiple .o files, comp_unit helps choose the auxilliary /// file. In most other cases comp_unit's symbol file is - /// identiacal with *this. + /// identical with *this. /// /// \param[in] lambda /// The lambda that should be applied to every function. The lambda can @@ -182,7 +189,7 @@ public: }; /// If \c type_uid points to an array type, return its characteristics. /// To support variable-length array types, this function takes an - /// optional \p ExtecutionContext. If \c exe_ctx is non-null, the + /// optional \p ExecutionContext. If \c exe_ctx is non-null, the /// dynamic characteristics for that context are returned. virtual llvm::Optional<ArrayInfo> GetDynamicArrayInfoForUID(lldb::user_id_t type_uid, @@ -208,21 +215,21 @@ public: SymbolContextList &sc_list); virtual void DumpClangAST(Stream &s) {} - virtual void - FindGlobalVariables(ConstString name, - const CompilerDeclContext *parent_decl_ctx, - uint32_t max_matches, VariableList &variables); + virtual void FindGlobalVariables(ConstString name, + const CompilerDeclContext &parent_decl_ctx, + uint32_t max_matches, + VariableList &variables); virtual void FindGlobalVariables(const RegularExpression ®ex, uint32_t max_matches, VariableList &variables); virtual void FindFunctions(ConstString name, - const CompilerDeclContext *parent_decl_ctx, + const CompilerDeclContext &parent_decl_ctx, lldb::FunctionNameType name_type_mask, bool include_inlines, SymbolContextList &sc_list); virtual void FindFunctions(const RegularExpression ®ex, bool include_inlines, SymbolContextList &sc_list); virtual void - FindTypes(ConstString name, const CompilerDeclContext *parent_decl_ctx, + FindTypes(ConstString name, const CompilerDeclContext &parent_decl_ctx, uint32_t max_matches, llvm::DenseSet<lldb_private::SymbolFile *> &searched_symbol_files, TypeMap &types); @@ -251,8 +258,7 @@ public: GetTypeSystemForLanguage(lldb::LanguageType language); virtual CompilerDeclContext - FindNamespace(ConstString name, - const CompilerDeclContext *parent_decl_ctx) { + FindNamespace(ConstString name, const CompilerDeclContext &parent_decl_ctx) { return CompilerDeclContext(); } @@ -311,9 +317,10 @@ protected: bool m_calculated_abilities; private: - DISALLOW_COPY_AND_ASSIGN(SymbolFile); + SymbolFile(const SymbolFile &) = delete; + const SymbolFile &operator=(const SymbolFile &) = delete; }; } // namespace lldb_private -#endif // liblldb_SymbolFile_h_ +#endif // LLDB_SYMBOL_SYMBOLFILE_H diff --git a/lldb/include/lldb/Symbol/SymbolVendor.h b/lldb/include/lldb/Symbol/SymbolVendor.h index 96c6ea5c7332..c9c59a3fc1be 100644 --- a/lldb/include/lldb/Symbol/SymbolVendor.h +++ b/lldb/include/lldb/Symbol/SymbolVendor.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef liblldb_SymbolVendor_h_ -#define liblldb_SymbolVendor_h_ +#ifndef LLDB_SYMBOL_SYMBOLVENDOR_H +#define LLDB_SYMBOL_SYMBOLVENDOR_H #include <vector> @@ -52,9 +52,10 @@ protected: private: // For SymbolVendor only - DISALLOW_COPY_AND_ASSIGN(SymbolVendor); + SymbolVendor(const SymbolVendor &) = delete; + const SymbolVendor &operator=(const SymbolVendor &) = delete; }; } // namespace lldb_private -#endif // liblldb_SymbolVendor_h_ +#endif // LLDB_SYMBOL_SYMBOLVENDOR_H diff --git a/lldb/include/lldb/Symbol/Symtab.h b/lldb/include/lldb/Symbol/Symtab.h index f121bef1bfbe..c232925eec75 100644 --- a/lldb/include/lldb/Symbol/Symtab.h +++ b/lldb/include/lldb/Symbol/Symtab.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef liblldb_Symtab_h_ -#define liblldb_Symtab_h_ +#ifndef LLDB_SYMBOL_SYMTAB_H +#define LLDB_SYMBOL_SYMTAB_H #include "lldb/Core/UniqueCStringMap.h" #include "lldb/Symbol/Symbol.h" @@ -224,9 +224,10 @@ private: const char *decl_context, const std::set<const char *> &class_contexts); - DISALLOW_COPY_AND_ASSIGN(Symtab); + Symtab(const Symtab &) = delete; + const Symtab &operator=(const Symtab &) = delete; }; } // namespace lldb_private -#endif // liblldb_Symtab_h_ +#endif // LLDB_SYMBOL_SYMTAB_H diff --git a/lldb/include/lldb/Symbol/TaggedASTType.h b/lldb/include/lldb/Symbol/TaggedASTType.h index 043a9138e07b..f02f99258a3f 100644 --- a/lldb/include/lldb/Symbol/TaggedASTType.h +++ b/lldb/include/lldb/Symbol/TaggedASTType.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef liblldb_TaggedASTType_h_ -#define liblldb_TaggedASTType_h_ +#ifndef LLDB_SYMBOL_TAGGEDASTTYPE_H +#define LLDB_SYMBOL_TAGGEDASTTYPE_H #include "lldb/Symbol/CompilerType.h" diff --git a/lldb/include/lldb/Symbol/Type.h b/lldb/include/lldb/Symbol/Type.h index 95a3bc497517..8735d016bb22 100644 --- a/lldb/include/lldb/Symbol/Type.h +++ b/lldb/include/lldb/Symbol/Type.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef liblldb_Type_h_ -#define liblldb_Type_h_ +#ifndef LLDB_SYMBOL_TYPE_H +#define LLDB_SYMBOL_TYPE_H #include "lldb/Symbol/CompilerDecl.h" #include "lldb/Symbol/CompilerType.h" @@ -97,13 +97,14 @@ public: 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); + ResolveState compiler_type_resolve_state, uint32_t opaque_payload = 0); // This makes an invalid type. Used for functions that return a Type when // they get an error. Type(); - void Dump(Stream *s, bool show_context); + void Dump(Stream *s, bool show_context, + lldb::DescriptionLevel level = lldb::eDescriptionLevelFull); void DumpTypeName(Stream *s); @@ -196,11 +197,11 @@ public: uint32_t GetEncodingMask(); - bool IsCompleteObjCClass() { return m_is_complete_objc_class; } - - void SetIsCompleteObjCClass(bool is_complete_objc_class) { - m_is_complete_objc_class = is_complete_objc_class; - } + typedef uint32_t Payload; + /// Return the language-specific payload. + Payload GetPayload() { return m_payload; } + /// Return the language-specific payload. + void SetPayload(Payload opaque_payload) { m_payload = opaque_payload; } protected: ConstString m_name; @@ -215,11 +216,12 @@ protected: Declaration m_decl; CompilerType m_compiler_type; ResolveState m_compiler_type_resolve_state; - bool m_is_complete_objc_class; + /// Language-specific flags. + Payload m_payload; Type *GetEncodingType(); - bool ResolveClangType(ResolveState compiler_type_resolve_state); + bool ResolveCompilerType(ResolveState compiler_type_resolve_state); }; // the two classes here are used by the public API as a backend to the SBType @@ -510,4 +512,4 @@ private: } // namespace lldb_private -#endif // liblldb_Type_h_ +#endif // LLDB_SYMBOL_TYPE_H diff --git a/lldb/include/lldb/Symbol/TypeList.h b/lldb/include/lldb/Symbol/TypeList.h index 38342b6d6f4f..03390858025b 100644 --- a/lldb/include/lldb/Symbol/TypeList.h +++ b/lldb/include/lldb/Symbol/TypeList.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef liblldb_TypeList_h_ -#define liblldb_TypeList_h_ +#ifndef LLDB_SYMBOL_TYPELIST_H +#define LLDB_SYMBOL_TYPELIST_H #include "lldb/Symbol/Type.h" #include "lldb/Utility/Iterable.h" @@ -63,9 +63,10 @@ private: collection m_types; - DISALLOW_COPY_AND_ASSIGN(TypeList); + TypeList(const TypeList &) = delete; + const TypeList &operator=(const TypeList &) = delete; }; } // namespace lldb_private -#endif // liblldb_TypeList_h_ +#endif // LLDB_SYMBOL_TYPELIST_H diff --git a/lldb/include/lldb/Symbol/TypeMap.h b/lldb/include/lldb/Symbol/TypeMap.h index e7d2b254cbf3..ede54c1a09d4 100644 --- a/lldb/include/lldb/Symbol/TypeMap.h +++ b/lldb/include/lldb/Symbol/TypeMap.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef liblldb_TypeMap_h_ -#define liblldb_TypeMap_h_ +#ifndef LLDB_SYMBOL_TYPEMAP_H +#define LLDB_SYMBOL_TYPEMAP_H #include "lldb/Symbol/Type.h" #include "lldb/Utility/Iterable.h" @@ -26,7 +26,8 @@ public: void Clear(); - void Dump(Stream *s, bool show_context); + void Dump(Stream *s, bool show_context, + lldb::DescriptionLevel level = lldb::eDescriptionLevelFull); TypeMap FindTypes(ConstString name); @@ -66,9 +67,10 @@ private: collection m_types; - DISALLOW_COPY_AND_ASSIGN(TypeMap); + TypeMap(const TypeMap &) = delete; + const TypeMap &operator=(const TypeMap &) = delete; }; } // namespace lldb_private -#endif // liblldb_TypeMap_h_ +#endif // LLDB_SYMBOL_TYPEMAP_H diff --git a/lldb/include/lldb/Symbol/TypeSystem.h b/lldb/include/lldb/Symbol/TypeSystem.h index 91f751acf6c7..e188f29354b8 100644 --- a/lldb/include/lldb/Symbol/TypeSystem.h +++ b/lldb/include/lldb/Symbol/TypeSystem.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef liblldb_TypeSystem_h_ -#define liblldb_TypeSystem_h_ +#ifndef LLDB_SYMBOL_TYPESYSTEM_H +#define LLDB_SYMBOL_TYPESYSTEM_H #include <functional> #include <map> @@ -129,6 +129,11 @@ public: void *other_opaque_decl_ctx) = 0; // Tests +#ifndef NDEBUG + /// Verify the integrity of the type to catch CompilerTypes that mix + /// and match invalid TypeSystem/Opaque type pairs. + virtual bool Verify(lldb::opaque_compiler_type_t type) = 0; +#endif virtual bool IsArrayType(lldb::opaque_compiler_type_t type, CompilerType *element_type, uint64_t *size, @@ -199,6 +204,8 @@ public: virtual ConstString GetTypeName(lldb::opaque_compiler_type_t type) = 0; + virtual ConstString GetDisplayTypeName(lldb::opaque_compiler_type_t type) = 0; + virtual uint32_t GetTypeInfo(lldb::opaque_compiler_type_t type, CompilerType *pointee_or_element_compiler_type) = 0; @@ -252,9 +259,12 @@ public: virtual CompilerType AddRestrictModifier(lldb::opaque_compiler_type_t type); + /// \param opaque_payload The m_payload field of Type, which may + /// carry TypeSystem-specific extra information. virtual CompilerType CreateTypedef(lldb::opaque_compiler_type_t type, const char *name, - const CompilerDeclContext &decl_ctx); + const CompilerDeclContext &decl_ctx, + uint32_t opaque_payload); // Exploring the type @@ -364,11 +374,18 @@ public: uint32_t bitfield_bit_offset, ExecutionContextScope *exe_scope) = 0; - virtual void - DumpTypeDescription(lldb::opaque_compiler_type_t type) = 0; // Dump to stdout + /// Dump the type to stdout. + virtual void DumpTypeDescription( + lldb::opaque_compiler_type_t type, + lldb::DescriptionLevel level = lldb::eDescriptionLevelFull) = 0; - virtual void DumpTypeDescription(lldb::opaque_compiler_type_t type, - Stream *s) = 0; + /// Print a description of the type to a stream. The exact implementation + /// varies, but the expectation is that eDescriptionLevelFull returns a + /// source-like representation of the type, whereas eDescriptionLevelVerbose + /// does a dump of the underlying AST if applicable. + virtual void DumpTypeDescription( + lldb::opaque_compiler_type_t type, Stream *s, + lldb::DescriptionLevel level = lldb::eDescriptionLevelFull) = 0; // TODO: These methods appear unused. Should they be removed? @@ -380,7 +397,7 @@ public: lldb::offset_t data_offset, size_t data_byte_size) = 0; - // TODO: Determine if these methods should move to ClangASTContext. + // TODO: Determine if these methods should move to TypeSystemClang. virtual bool IsPointerOrReferenceType(lldb::opaque_compiler_type_t type, CompilerType *pointee_type) = 0; @@ -509,4 +526,4 @@ protected: } // namespace lldb_private -#endif // liblldb_TypeSystem_h_ +#endif // LLDB_SYMBOL_TYPESYSTEM_H diff --git a/lldb/include/lldb/Symbol/UnwindPlan.h b/lldb/include/lldb/Symbol/UnwindPlan.h index fa41ba5d056a..8902b5f4eaa7 100644 --- a/lldb/include/lldb/Symbol/UnwindPlan.h +++ b/lldb/include/lldb/Symbol/UnwindPlan.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef liblldb_UnwindPlan_h -#define liblldb_UnwindPlan_h +#ifndef LLDB_SYMBOL_UNWINDPLAN_H +#define LLDB_SYMBOL_UNWINDPLAN_H #include <map> #include <memory> @@ -320,7 +320,6 @@ public: } m_value; }; // class FAValue - public: Row(); Row(const UnwindPlan::Row &rhs) = default; @@ -375,7 +374,6 @@ public: collection m_register_locations; }; // class Row -public: typedef std::shared_ptr<Row> RowSP; UnwindPlan(lldb::RegisterKind reg_kind) @@ -540,4 +538,4 @@ private: } // namespace lldb_private -#endif // liblldb_UnwindPlan_h +#endif // LLDB_SYMBOL_UNWINDPLAN_H diff --git a/lldb/include/lldb/Symbol/UnwindTable.h b/lldb/include/lldb/Symbol/UnwindTable.h index c1dc519c4b20..9548b1f3fcec 100644 --- a/lldb/include/lldb/Symbol/UnwindTable.h +++ b/lldb/include/lldb/Symbol/UnwindTable.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef liblldb_UnwindTable_h -#define liblldb_UnwindTable_h +#ifndef LLDB_SYMBOL_UNWINDTABLE_H +#define LLDB_SYMBOL_UNWINDTABLE_H #include <map> #include <mutex> @@ -79,9 +79,10 @@ private: std::unique_ptr<CompactUnwindInfo> m_compact_unwind_up; std::unique_ptr<ArmUnwindInfo> m_arm_unwind_up; - DISALLOW_COPY_AND_ASSIGN(UnwindTable); + UnwindTable(const UnwindTable &) = delete; + const UnwindTable &operator=(const UnwindTable &) = delete; }; } // namespace lldb_private -#endif // liblldb_UnwindTable_h +#endif // LLDB_SYMBOL_UNWINDTABLE_H diff --git a/lldb/include/lldb/Symbol/Variable.h b/lldb/include/lldb/Symbol/Variable.h index 30f57f1f9110..66abdc0b3117 100644 --- a/lldb/include/lldb/Symbol/Variable.h +++ b/lldb/include/lldb/Symbol/Variable.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef liblldb_Variable_h_ -#define liblldb_Variable_h_ +#ifndef LLDB_SYMBOL_VARIABLE_H +#define LLDB_SYMBOL_VARIABLE_H #include "lldb/Core/Mangled.h" #include "lldb/Expression/DWARFExpression.h" @@ -141,4 +141,4 @@ private: } // namespace lldb_private -#endif // liblldb_Variable_h_ +#endif // LLDB_SYMBOL_VARIABLE_H diff --git a/lldb/include/lldb/Symbol/VariableList.h b/lldb/include/lldb/Symbol/VariableList.h index 87f98668a8a8..9fea628a81b6 100644 --- a/lldb/include/lldb/Symbol/VariableList.h +++ b/lldb/include/lldb/Symbol/VariableList.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef liblldb_VariableList_h_ -#define liblldb_VariableList_h_ +#ifndef LLDB_SYMBOL_VARIABLELIST_H +#define LLDB_SYMBOL_VARIABLELIST_H #include "lldb/Symbol/SymbolContext.h" #include "lldb/Symbol/Variable.h" @@ -80,9 +80,10 @@ protected: private: // For VariableList only - DISALLOW_COPY_AND_ASSIGN(VariableList); + VariableList(const VariableList &) = delete; + const VariableList &operator=(const VariableList &) = delete; }; } // namespace lldb_private -#endif // liblldb_VariableList_h_ +#endif // LLDB_SYMBOL_VARIABLELIST_H diff --git a/lldb/include/lldb/Target/ABI.h b/lldb/include/lldb/Target/ABI.h index 1aff1e2f7817..b252e4b54f03 100644 --- a/lldb/include/lldb/Target/ABI.h +++ b/lldb/include/lldb/Target/ABI.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef liblldb_ABI_h_ -#define liblldb_ABI_h_ +#ifndef LLDB_TARGET_ABI_H +#define LLDB_TARGET_ABI_H #include "lldb/Core/PluginInterface.h" #include "lldb/Symbol/UnwindPlan.h" @@ -126,7 +126,7 @@ public: llvm::MCRegisterInfo &GetMCRegisterInfo() { return *m_mc_register_info_up; } - virtual void AugmentRegisterInfo(RegisterInfo &info); + virtual void AugmentRegisterInfo(RegisterInfo &info) = 0; virtual bool GetPointerReturnRegister(const char *&name) { return false; } @@ -138,10 +138,6 @@ protected: assert(m_mc_register_info_up && "ABI must have MCRegisterInfo"); } - bool GetRegisterInfoByName(ConstString name, RegisterInfo &info); - - virtual const RegisterInfo *GetRegisterInfoArray(uint32_t &count) = 0; - /// Utility function to construct a MCRegisterInfo using the ArchSpec triple. /// Plugins wishing to customize the construction can construct the /// MCRegisterInfo themselves. @@ -152,9 +148,44 @@ protected: std::unique_ptr<llvm::MCRegisterInfo> m_mc_register_info_up; private: - DISALLOW_COPY_AND_ASSIGN(ABI); + ABI(const ABI &) = delete; + const ABI &operator=(const ABI &) = delete; +}; + +class RegInfoBasedABI : public ABI { +public: + void AugmentRegisterInfo(RegisterInfo &info) override; + +protected: + using ABI::ABI; + + bool GetRegisterInfoByName(ConstString name, RegisterInfo &info); + + virtual const RegisterInfo *GetRegisterInfoArray(uint32_t &count) = 0; +}; + +class MCBasedABI : public ABI { +public: + void AugmentRegisterInfo(RegisterInfo &info) override; + + /// If the register name is of the form "<from_prefix>[<number>]" then change + /// the name to "<to_prefix>[<number>]". Otherwise, leave the name unchanged. + static void MapRegisterName(std::string ®, llvm::StringRef from_prefix, + llvm::StringRef to_prefix); +protected: + using ABI::ABI; + + /// Return eh_frame and dwarf numbers for the given register. + virtual std::pair<uint32_t, uint32_t> GetEHAndDWARFNums(llvm::StringRef reg); + + /// Return the generic number of the given register. + virtual uint32_t GetGenericNum(llvm::StringRef reg) = 0; + + /// For the given (capitalized) lldb register name, return the name of this + /// register in the MCRegisterInfo struct. + virtual std::string GetMCName(std::string reg) { return reg; } }; } // namespace lldb_private -#endif // liblldb_ABI_h_ +#endif // LLDB_TARGET_ABI_H diff --git a/lldb/include/lldb/Target/AssertFrameRecognizer.h b/lldb/include/lldb/Target/AssertFrameRecognizer.h new file mode 100644 index 000000000000..2ecc957d2a28 --- /dev/null +++ b/lldb/include/lldb/Target/AssertFrameRecognizer.h @@ -0,0 +1,54 @@ +//===-- AssertFrameRecognizer.cpp -------------------------------*- 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_ASSERTFRAMERECOGNIZER_H +#define LLDB_TARGET_ASSERTFRAMERECOGNIZER_H + +#include "lldb/Target/Process.h" +#include "lldb/Target/StackFrameRecognizer.h" +#include "lldb/Utility/ConstString.h" +#include "lldb/Utility/FileSpec.h" + +#include <tuple> + +namespace lldb_private { + +/// Registers the assert stack frame recognizer. +/// +/// \param[in] process +/// The process that is currently asserting. This will give us information on +/// the target and the platform. +void RegisterAssertFrameRecognizer(Process *process); + +/// \class AssertRecognizedStackFrame +/// +/// Holds the stack frame where the assert is called from. +class AssertRecognizedStackFrame : public RecognizedStackFrame { +public: + AssertRecognizedStackFrame(lldb::StackFrameSP most_relevant_frame_sp); + lldb::StackFrameSP GetMostRelevantFrame() override; + +private: + lldb::StackFrameSP m_most_relevant_frame; +}; + +/// \class AssertFrameRecognizer +/// +/// When a thread stops, it checks depending on the platform if the top frame is +/// an abort stack frame. If so, it looks for an assert stack frame in the upper +/// frames and set it as the most relavant frame when found. +class AssertFrameRecognizer : public StackFrameRecognizer { +public: + std::string GetName() override { return "Assert StackFrame Recognizer"; } + lldb::RecognizedStackFrameSP + RecognizeFrame(lldb::StackFrameSP frame_sp) override; +}; + +} // namespace lldb_private + +#endif // LLDB_TARGET_ASSERTFRAMERECOGNIZER_H diff --git a/lldb/include/lldb/Target/DynamicLoader.h b/lldb/include/lldb/Target/DynamicLoader.h index ac72b98e5e1a..d3ce1b05ed51 100644 --- a/lldb/include/lldb/Target/DynamicLoader.h +++ b/lldb/include/lldb/Target/DynamicLoader.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef liblldb_DynamicLoader_h_ -#define liblldb_DynamicLoader_h_ +#ifndef LLDB_TARGET_DYNAMICLOADER_H +#define LLDB_TARGET_DYNAMICLOADER_H #include "lldb/Core/PluginInterface.h" #include "lldb/Utility/FileSpec.h" @@ -310,9 +310,10 @@ protected: *m_process; ///< The process that this dynamic loader plug-in is tracking. private: - DISALLOW_COPY_AND_ASSIGN(DynamicLoader); + DynamicLoader(const DynamicLoader &) = delete; + const DynamicLoader &operator=(const DynamicLoader &) = delete; }; } // namespace lldb_private -#endif // liblldb_DynamicLoader_h_ +#endif // LLDB_TARGET_DYNAMICLOADER_H diff --git a/lldb/include/lldb/Target/ExecutionContext.h b/lldb/include/lldb/Target/ExecutionContext.h index 0819357fab32..169d56ac9b64 100644 --- a/lldb/include/lldb/Target/ExecutionContext.h +++ b/lldb/include/lldb/Target/ExecutionContext.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef liblldb_ExecutionContext_h_ -#define liblldb_ExecutionContext_h_ +#ifndef LLDB_TARGET_EXECUTIONCONTEXT_H +#define LLDB_TARGET_EXECUTIONCONTEXT_H #include <mutex> @@ -565,4 +565,4 @@ protected: } // namespace lldb_private -#endif // liblldb_ExecutionContext_h_ +#endif // LLDB_TARGET_EXECUTIONCONTEXT_H diff --git a/lldb/include/lldb/Target/ExecutionContextScope.h b/lldb/include/lldb/Target/ExecutionContextScope.h index 0121ce61a1d7..d7003e9a572e 100644 --- a/lldb/include/lldb/Target/ExecutionContextScope.h +++ b/lldb/include/lldb/Target/ExecutionContextScope.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef liblldb_ExecutionContextScope_h_ -#define liblldb_ExecutionContextScope_h_ +#ifndef LLDB_TARGET_EXECUTIONCONTEXTSCOPE_H +#define LLDB_TARGET_EXECUTIONCONTEXTSCOPE_H #include "lldb/lldb-private.h" @@ -55,4 +55,4 @@ public: } // namespace lldb_private -#endif // liblldb_ExecutionContextScope_h_ +#endif // LLDB_TARGET_EXECUTIONCONTEXTSCOPE_H diff --git a/lldb/include/lldb/Target/InstrumentationRuntime.h b/lldb/include/lldb/Target/InstrumentationRuntime.h index 4cee76d657bb..dd4da26c215e 100644 --- a/lldb/include/lldb/Target/InstrumentationRuntime.h +++ b/lldb/include/lldb/Target/InstrumentationRuntime.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef liblldb_InstrumentationRuntime_h_ -#define liblldb_InstrumentationRuntime_h_ +#ifndef LLDB_TARGET_INSTRUMENTATIONRUNTIME_H +#define LLDB_TARGET_INSTRUMENTATIONRUNTIME_H #include <map> #include <vector> @@ -92,4 +92,4 @@ public: } // namespace lldb_private -#endif // liblldb_InstrumentationRuntime_h_ +#endif // LLDB_TARGET_INSTRUMENTATIONRUNTIME_H diff --git a/lldb/include/lldb/Target/InstrumentationRuntimeStopInfo.h b/lldb/include/lldb/Target/InstrumentationRuntimeStopInfo.h index 6c2a8ad87418..2cbf27d7b343 100644 --- a/lldb/include/lldb/Target/InstrumentationRuntimeStopInfo.h +++ b/lldb/include/lldb/Target/InstrumentationRuntimeStopInfo.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef liblldb_InstrumentationRuntimeStopInfo_h_ -#define liblldb_InstrumentationRuntimeStopInfo_h_ +#ifndef LLDB_TARGET_INSTRUMENTATIONRUNTIMESTOPINFO_H +#define LLDB_TARGET_INSTRUMENTATIONRUNTIMESTOPINFO_H #include <string> @@ -39,4 +39,4 @@ private: } // namespace lldb_private -#endif // liblldb_InstrumentationRuntimeStopInfo_h_ +#endif // LLDB_TARGET_INSTRUMENTATIONRUNTIMESTOPINFO_H diff --git a/lldb/include/lldb/Target/JITLoader.h b/lldb/include/lldb/Target/JITLoader.h index 1bafd828f78e..790fdfaf8548 100644 --- a/lldb/include/lldb/Target/JITLoader.h +++ b/lldb/include/lldb/Target/JITLoader.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef liblldb_JITLoader_h_ -#define liblldb_JITLoader_h_ +#ifndef LLDB_TARGET_JITLOADER_H +#define LLDB_TARGET_JITLOADER_H #include <vector> @@ -65,4 +65,4 @@ protected: } // namespace lldb_private -#endif // liblldb_JITLoader_h_ +#endif // LLDB_TARGET_JITLOADER_H diff --git a/lldb/include/lldb/Target/JITLoaderList.h b/lldb/include/lldb/Target/JITLoaderList.h index 4cc3a9ecb91d..f8d34d21a808 100644 --- a/lldb/include/lldb/Target/JITLoaderList.h +++ b/lldb/include/lldb/Target/JITLoaderList.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef liblldb_JITLoaderList_h_ -#define liblldb_JITLoaderList_h_ +#ifndef LLDB_TARGET_JITLOADERLIST_H +#define LLDB_TARGET_JITLOADERLIST_H #include <mutex> #include <vector> @@ -45,4 +45,4 @@ private: } // namespace lldb_private -#endif // liblldb_JITLoaderList_h_ +#endif // LLDB_TARGET_JITLOADERLIST_H diff --git a/lldb/include/lldb/Target/Language.h b/lldb/include/lldb/Target/Language.h index e00b042ac253..9dc9df363d79 100644 --- a/lldb/include/lldb/Target/Language.h +++ b/lldb/include/lldb/Target/Language.h @@ -7,8 +7,8 @@ // //===----------------------------------------------------------------------===// -#ifndef liblldb_Language_h_ -#define liblldb_Language_h_ +#ifndef LLDB_TARGET_LANGUAGE_H +#define LLDB_TARGET_LANGUAGE_H #include <functional> #include <memory> @@ -180,10 +180,6 @@ public: GetPossibleFormattersMatches(ValueObject &valobj, lldb::DynamicValueType use_dynamic); - virtual lldb_private::formatters::StringPrinter::EscapingHelper - GetStringPrinterEscapingHelper( - lldb_private::formatters::StringPrinter::GetPrintableElementType); - virtual std::unique_ptr<TypeScavenger> GetTypeScavenger(); virtual const char *GetLanguageSpecificTypeLookupHelp(); @@ -274,9 +270,10 @@ protected: Language(); private: - DISALLOW_COPY_AND_ASSIGN(Language); + Language(const Language &) = delete; + const Language &operator=(const Language &) = delete; }; } // namespace lldb_private -#endif // liblldb_Language_h_ +#endif // LLDB_TARGET_LANGUAGE_H diff --git a/lldb/include/lldb/Target/LanguageRuntime.h b/lldb/include/lldb/Target/LanguageRuntime.h index 73c8dfa3874d..b0b9b919911a 100644 --- a/lldb/include/lldb/Target/LanguageRuntime.h +++ b/lldb/include/lldb/Target/LanguageRuntime.h @@ -7,8 +7,8 @@ // //===----------------------------------------------------------------------===// -#ifndef liblldb_LanguageRuntime_h_ -#define liblldb_LanguageRuntime_h_ +#ifndef LLDB_TARGET_LANGUAGERUNTIME_H +#define LLDB_TARGET_LANGUAGERUNTIME_H #include "lldb/Breakpoint/BreakpointResolver.h" #include "lldb/Breakpoint/BreakpointResolverName.h" @@ -21,8 +21,6 @@ #include "lldb/lldb-private.h" #include "lldb/lldb-public.h" -#include "clang/Basic/TargetOptions.h" - namespace lldb_private { class ExceptionSearchFilter : public SearchFilter { @@ -53,7 +51,7 @@ protected: LanguageRuntime *m_language_runtime; lldb::SearchFilterSP m_filter_sp; - lldb::SearchFilterSP DoCopyForBreakpoint(Breakpoint &breakpoint) override; + lldb::SearchFilterSP DoCreateCopy() override; void UpdateModuleListIfNeeded(); }; @@ -136,7 +134,8 @@ public: virtual DeclVendor *GetDeclVendor() { return nullptr; } virtual lldb::BreakpointResolverSP - CreateExceptionResolver(Breakpoint *bkpt, bool catch_bp, bool throw_bp) = 0; + CreateExceptionResolver(const lldb::BreakpointSP &bkpt, + bool catch_bp, bool throw_bp) = 0; virtual lldb::SearchFilterSP CreateExceptionSearchFilter() { return m_process->GetTarget().GetSearchFilterForModule(nullptr); @@ -154,7 +153,7 @@ public: /// 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 bool IsAllowedRuntimeValue(ConstString name) { return false; } virtual llvm::Optional<CompilerType> GetRuntimeType(CompilerType base_type) { return llvm::None; @@ -162,13 +161,6 @@ public: virtual void ModulesDidLoad(const ModuleList &module_list) {} - // Called by the Clang expression evaluation engine to allow runtimes to - // alter the set of target options provided to the compiler. If the options - // prototype is modified, runtimes must return true, false otherwise. - virtual bool GetOverrideExprOptions(clang::TargetOptions &prototype) { - return false; - } - // Called by ClangExpressionParser::PrepareForExecution to query for any // custom LLVM IR passes that need to be run before an expression is // assembled and run. @@ -193,9 +185,10 @@ protected: Process *m_process; private: - DISALLOW_COPY_AND_ASSIGN(LanguageRuntime); + LanguageRuntime(const LanguageRuntime &) = delete; + const LanguageRuntime &operator=(const LanguageRuntime &) = delete; }; } // namespace lldb_private -#endif // liblldb_LanguageRuntime_h_ +#endif // LLDB_TARGET_LANGUAGERUNTIME_H diff --git a/lldb/include/lldb/Target/Memory.h b/lldb/include/lldb/Target/Memory.h index e62b8ef9c773..b3ad22aff16b 100644 --- a/lldb/include/lldb/Target/Memory.h +++ b/lldb/include/lldb/Target/Memory.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef liblldb_Memory_h_ -#define liblldb_Memory_h_ +#ifndef LLDB_TARGET_MEMORY_H +#define LLDB_TARGET_MEMORY_H #include "lldb/Utility/RangeMap.h" #include "lldb/lldb-private.h" @@ -45,7 +45,7 @@ public: protected: typedef std::map<lldb::addr_t, lldb::DataBufferSP> BlockMap; - typedef RangeArray<lldb::addr_t, lldb::addr_t, 4> InvalidRanges; + typedef RangeVector<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; @@ -59,7 +59,8 @@ protected: uint32_t m_L2_cache_line_byte_size; private: - DISALLOW_COPY_AND_ASSIGN(MemoryCache); + MemoryCache(const MemoryCache &) = delete; + const MemoryCache &operator=(const MemoryCache &) = delete; }; @@ -135,9 +136,10 @@ protected: PermissionsToBlockMap m_memory_map; private: - DISALLOW_COPY_AND_ASSIGN(AllocatedMemoryCache); + AllocatedMemoryCache(const AllocatedMemoryCache &) = delete; + const AllocatedMemoryCache &operator=(const AllocatedMemoryCache &) = delete; }; } // namespace lldb_private -#endif // liblldb_Memory_h_ +#endif // LLDB_TARGET_MEMORY_H diff --git a/lldb/include/lldb/Target/MemoryHistory.h b/lldb/include/lldb/Target/MemoryHistory.h index 501751c55e80..db1e86805996 100644 --- a/lldb/include/lldb/Target/MemoryHistory.h +++ b/lldb/include/lldb/Target/MemoryHistory.h @@ -7,8 +7,8 @@ // //===----------------------------------------------------------------------===// -#ifndef liblldb_MemoryHistory_h_ -#define liblldb_MemoryHistory_h_ +#ifndef LLDB_TARGET_MEMORYHISTORY_H +#define LLDB_TARGET_MEMORYHISTORY_H #include <vector> @@ -30,4 +30,4 @@ public: } // namespace lldb_private -#endif // liblldb_MemoryHistory_h_ +#endif // LLDB_TARGET_MEMORYHISTORY_H diff --git a/lldb/include/lldb/Target/MemoryRegionInfo.h b/lldb/include/lldb/Target/MemoryRegionInfo.h index 07e50188843e..a22da8d72b83 100644 --- a/lldb/include/lldb/Target/MemoryRegionInfo.h +++ b/lldb/include/lldb/Target/MemoryRegionInfo.h @@ -7,8 +7,8 @@ // //===----------------------------------------------------------------------===// -#ifndef lldb_MemoryRegionInfo_h -#define lldb_MemoryRegionInfo_h +#ifndef LLDB_TARGET_MEMORYREGIONINFO_H +#define LLDB_TARGET_MEMORYREGIONINFO_H #include "lldb/Utility/ConstString.h" #include "lldb/Utility/RangeMap.h" @@ -143,4 +143,4 @@ struct format_provider<lldb_private::MemoryRegionInfo::OptionalBool> { }; } -#endif // #ifndef lldb_MemoryRegionInfo_h +#endif // LLDB_TARGET_MEMORYREGIONINFO_H diff --git a/lldb/include/lldb/Target/ModuleCache.h b/lldb/include/lldb/Target/ModuleCache.h index 119616911393..9dc0e0903196 100644 --- a/lldb/include/lldb/Target/ModuleCache.h +++ b/lldb/include/lldb/Target/ModuleCache.h @@ -71,4 +71,4 @@ private: } // namespace lldb_private -#endif // utility_ModuleCache_h_ +#endif // LLDB_TARGET_MODULECACHE_H diff --git a/lldb/include/lldb/Target/OperatingSystem.h b/lldb/include/lldb/Target/OperatingSystem.h index c75d1ca2e5f4..6db5c0a01f36 100644 --- a/lldb/include/lldb/Target/OperatingSystem.h +++ b/lldb/include/lldb/Target/OperatingSystem.h @@ -7,9 +7,8 @@ // //===----------------------------------------------------------------------===// -#ifndef liblldb_OperatingSystem_h_ -#define liblldb_OperatingSystem_h_ - +#ifndef LLDB_TARGET_OPERATINGSYSTEM_H +#define LLDB_TARGET_OPERATINGSYSTEM_H #include "lldb/Core/PluginInterface.h" #include "lldb/lldb-private.h" @@ -70,9 +69,10 @@ protected: Process *m_process; ///< The process that this dynamic loader plug-in is tracking. private: - DISALLOW_COPY_AND_ASSIGN(OperatingSystem); + OperatingSystem(const OperatingSystem &) = delete; + const OperatingSystem &operator=(const OperatingSystem &) = delete; }; } // namespace lldb_private -#endif // liblldb_OperatingSystem_h_ +#endif // LLDB_TARGET_OPERATINGSYSTEM_H diff --git a/lldb/include/lldb/Target/PathMappingList.h b/lldb/include/lldb/Target/PathMappingList.h index d1759667f1f5..9e1e6eb26eb9 100644 --- a/lldb/include/lldb/Target/PathMappingList.h +++ b/lldb/include/lldb/Target/PathMappingList.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef liblldb_PathMappingList_h_ -#define liblldb_PathMappingList_h_ +#ifndef LLDB_TARGET_PATHMAPPINGLIST_H +#define LLDB_TARGET_PATHMAPPINGLIST_H #include <map> #include <vector> @@ -125,4 +125,4 @@ protected: } // namespace lldb_private -#endif // liblldb_PathMappingList_h_ +#endif // LLDB_TARGET_PATHMAPPINGLIST_H diff --git a/lldb/include/lldb/Target/Platform.h b/lldb/include/lldb/Target/Platform.h index 72b6be21b770..6234b8244b3f 100644 --- a/lldb/include/lldb/Target/Platform.h +++ b/lldb/include/lldb/Target/Platform.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef liblldb_Platform_h_ -#define liblldb_Platform_h_ +#ifndef LLDB_TARGET_PLATFORM_H +#define LLDB_TARGET_PLATFORM_H #include <functional> #include <map> @@ -23,6 +23,7 @@ #include "lldb/Utility/ArchSpec.h" #include "lldb/Utility/ConstString.h" #include "lldb/Utility/FileSpec.h" +#include "lldb/Utility/StructuredData.h" #include "lldb/Utility/Timeout.h" #include "lldb/Utility/UserIDResolver.h" #include "lldb/lldb-private-forward.h" @@ -32,8 +33,8 @@ namespace lldb_private { class ProcessInstanceInfo; -class ProcessInstanceInfoList; class ProcessInstanceInfoMatch; +typedef std::vector<ProcessInstanceInfo> ProcessInstanceInfoList; class ModuleCache; enum MmapFlags { eMmapFlagsPrivate = 1, eMmapFlagsAnon = 2 }; @@ -49,6 +50,9 @@ public: FileSpec GetModuleCacheDirectory() const; bool SetModuleCacheDirectory(const FileSpec &dir_spec); + +private: + void SetDefaultModuleCacheDirectory(const FileSpec &dir_spec); }; typedef std::shared_ptr<PlatformProperties> PlatformPropertiesSP; @@ -368,9 +372,13 @@ public: virtual lldb::ProcessSP ConnectProcess(llvm::StringRef connect_url, llvm::StringRef plugin_name, - lldb_private::Debugger &debugger, - lldb_private::Target *target, - lldb_private::Status &error); + Debugger &debugger, Target *target, + Status &error); + + virtual lldb::ProcessSP + ConnectProcessSynchronous(llvm::StringRef connect_url, + llvm::StringRef plugin_name, Debugger &debugger, + Stream &stream, Target *target, Status &error); /// Attach to an existing process using a process ID. /// @@ -823,7 +831,33 @@ public: virtual size_t ConnectToWaitingProcesses(lldb_private::Debugger &debugger, lldb_private::Status &error); + /// Gather all of crash informations into a structured data dictionary. + /// + /// If the platform have a crashed process with crash information entries, + /// gather all the entries into an structured data dictionary or return a + /// nullptr. This dictionary is generic and extensible, as it contains an + /// array for each different type of crash information. + /// + /// \param[in] process + /// The crashed process. + /// + /// \return + /// A structured data dictionary containing at each entry, the crash + /// information type as the entry key and the matching an array as the + /// entry value. \b nullptr if not implemented or if the process has no + /// crash information entry. \b error if an error occured. + virtual llvm::Expected<StructuredData::DictionarySP> + FetchExtendedCrashInformation(lldb_private::Process &process) { + return nullptr; + } + protected: + /// Private implementation of connecting to a process. If the stream is set + /// we connect synchronously. + lldb::ProcessSP DoConnectProcess(llvm::StringRef connect_url, + llvm::StringRef plugin_name, + Debugger &debugger, Stream *stream, + Target *target, Status &error); bool m_is_host; // Set to true when we are able to actually set the OS version while being // connected. For remote platforms, we might set the version ahead of time @@ -904,7 +938,8 @@ private: FileSpec GetModuleCacheRoot(); - DISALLOW_COPY_AND_ASSIGN(Platform); + Platform(const Platform &) = delete; + const Platform &operator=(const Platform &) = delete; }; class PlatformList { @@ -971,7 +1006,8 @@ protected: lldb::PlatformSP m_selected_platform_sp; private: - DISALLOW_COPY_AND_ASSIGN(PlatformList); + PlatformList(const PlatformList &) = delete; + const PlatformList &operator=(const PlatformList &) = delete; }; class OptionGroupPlatformRSync : public lldb_private::OptionGroup { @@ -996,7 +1032,9 @@ public: bool m_ignores_remote_hostname; private: - DISALLOW_COPY_AND_ASSIGN(OptionGroupPlatformRSync); + OptionGroupPlatformRSync(const OptionGroupPlatformRSync &) = delete; + const OptionGroupPlatformRSync & + operator=(const OptionGroupPlatformRSync &) = delete; }; class OptionGroupPlatformSSH : public lldb_private::OptionGroup { @@ -1019,7 +1057,9 @@ public: std::string m_ssh_opts; private: - DISALLOW_COPY_AND_ASSIGN(OptionGroupPlatformSSH); + OptionGroupPlatformSSH(const OptionGroupPlatformSSH &) = delete; + const OptionGroupPlatformSSH & + operator=(const OptionGroupPlatformSSH &) = delete; }; class OptionGroupPlatformCaching : public lldb_private::OptionGroup { @@ -1041,9 +1081,11 @@ public: std::string m_cache_dir; private: - DISALLOW_COPY_AND_ASSIGN(OptionGroupPlatformCaching); + OptionGroupPlatformCaching(const OptionGroupPlatformCaching &) = delete; + const OptionGroupPlatformCaching & + operator=(const OptionGroupPlatformCaching &) = delete; }; } // namespace lldb_private -#endif // liblldb_Platform_h_ +#endif // LLDB_TARGET_PLATFORM_H diff --git a/lldb/include/lldb/Target/Process.h b/lldb/include/lldb/Target/Process.h index 2ba996d4995f..bf9b64547ed5 100644 --- a/lldb/include/lldb/Target/Process.h +++ b/lldb/include/lldb/Target/Process.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef liblldb_Process_h_ -#define liblldb_Process_h_ +#ifndef LLDB_TARGET_PROCESS_H +#define LLDB_TARGET_PROCESS_H #include "lldb/Host/Config.h" @@ -37,6 +37,7 @@ #include "lldb/Target/Memory.h" #include "lldb/Target/QueueList.h" #include "lldb/Target/ThreadList.h" +#include "lldb/Target/ThreadPlanStack.h" #include "lldb/Utility/ArchSpec.h" #include "lldb/Utility/Broadcaster.h" #include "lldb/Utility/Event.h" @@ -57,7 +58,11 @@ namespace lldb_private { template <typename B, typename S> struct Range; -// ProcessProperties +class ProcessExperimentalProperties : public Properties { +public: + ProcessExperimentalProperties(); +}; + class ProcessProperties : public Properties { public: // Pass nullptr for "process" if the ProcessProperties are to be the global @@ -81,11 +86,15 @@ public: bool GetDetachKeepsStopped() const; void SetDetachKeepsStopped(bool keep_stopped); bool GetWarningsOptimization() const; + bool GetWarningsUnsupportedLanguage() const; bool GetStopOnExec() const; std::chrono::seconds GetUtilityExpressionTimeout() const; + bool GetOSPluginReportsAllThreads() const; + void SetOSPluginReportsAllThreads(bool does_report); protected: Process *m_process; // Can be nullptr for global ProcessProperties + std::unique_ptr<ProcessExperimentalProperties> m_experimental_properties_up; }; typedef std::shared_ptr<ProcessProperties> ProcessPropertiesSP; @@ -139,7 +148,9 @@ public: return (m_plugin_name.empty() ? nullptr : m_plugin_name.c_str()); } - void SetProcessPluginName(llvm::StringRef plugin) { m_plugin_name = plugin; } + void SetProcessPluginName(llvm::StringRef plugin) { + m_plugin_name = std::string(plugin); + } void Clear() { ProcessInstanceInfo::Clear(); @@ -380,7 +391,7 @@ public: }; /// Process warning types. - enum Warnings { eWarningsOptimization = 1 }; + enum Warnings { eWarningsOptimization = 1, eWarningsUnsupportedLanguage = 2 }; typedef Range<lldb::addr_t, lldb::addr_t> LoadRange; // We use a read/write lock to allow on or more clients to access the process @@ -441,6 +452,8 @@ public: void Dump(Stream *s) const override; + virtual bool ShouldStop(Event *event_ptr, bool &found_valid_stopinfo); + void DoOnRemoval(Event *event_ptr) override; static const Process::ProcessEventData * @@ -486,7 +499,8 @@ public: int m_update_state; bool m_interrupted; - DISALLOW_COPY_AND_ASSIGN(ProcessEventData); + ProcessEventData(const ProcessEventData &) = delete; + const ProcessEventData &operator=(const ProcessEventData &) = delete; }; /// Construct with a shared pointer to a target, and the Process listener. @@ -723,7 +737,7 @@ public: /// /// \return /// Returns an error object. - virtual Status ConnectRemote(Stream *strm, llvm::StringRef remote_url); + virtual Status ConnectRemote(llvm::StringRef remote_url); bool GetShouldDetach() const { return m_should_detach; } @@ -911,7 +925,7 @@ public: /// /// \return /// Returns an error object. - virtual Status DoConnectRemote(Stream *strm, llvm::StringRef remote_url) { + virtual Status DoConnectRemote(llvm::StringRef remote_url) { Status error; error.SetErrorString("remote connections are not supported"); return error; @@ -1265,7 +1279,7 @@ public: /// LLDB_INVALID_ADDRESS. /// /// \return - /// A StructureDataSP object which, if non-empty, will contain the + /// A StructuredDataSP 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 @@ -1309,9 +1323,14 @@ public: /// pre-computed. void PrintWarningOptimization(const SymbolContext &sc); + /// Print a user-visible warning about a function written in a + /// language that this version of LLDB doesn't support. + /// + /// \see PrintWarningOptimization + void PrintWarningUnsupportedLanguage(const SymbolContext &sc); + virtual bool GetProcessInfo(ProcessInstanceInfo &info); -public: /// Get the exit status for a process. /// /// \return @@ -2196,6 +2215,75 @@ public: void SetDynamicCheckers(DynamicCheckerFunctions *dynamic_checkers); +/// Prune ThreadPlanStacks for unreported threads. +/// +/// \param[in] tid +/// The tid whose Plan Stack we are seeking to prune. +/// +/// \return +/// \b true if the TID is found or \b false if not. +bool PruneThreadPlansForTID(lldb::tid_t tid); + +/// Prune ThreadPlanStacks for all unreported threads. +void PruneThreadPlans(); + + /// Find the thread plan stack associated with thread with \a tid. + /// + /// \param[in] tid + /// The tid whose Plan Stack we are seeking. + /// + /// \return + /// Returns a ThreadPlan if the TID is found or nullptr if not. + ThreadPlanStack *FindThreadPlans(lldb::tid_t tid); + + /// Dump the thread plans associated with thread with \a tid. + /// + /// \param[in/out] strm + /// The stream to which to dump the output + /// + /// \param[in] tid + /// The tid whose Plan Stack we are dumping + /// + /// \param[in] desc_level + /// How much detail to dump + /// + /// \param[in] internal + /// If \b true dump all plans, if false only user initiated plans + /// + /// \param[in] condense_trivial + /// If true, only dump a header if the plan stack is just the base plan. + /// + /// \param[in] skip_unreported_plans + /// If true, only dump a plan if it is currently backed by an + /// lldb_private::Thread *. + /// + /// \return + /// Returns \b true if TID was found, \b false otherwise + bool DumpThreadPlansForTID(Stream &strm, lldb::tid_t tid, + lldb::DescriptionLevel desc_level, bool internal, + bool condense_trivial, bool skip_unreported_plans); + + /// Dump all the thread plans for this process. + /// + /// \param[in/out] strm + /// The stream to which to dump the output + /// + /// \param[in] desc_level + /// How much detail to dump + /// + /// \param[in] internal + /// If \b true dump all plans, if false only user initiated plans + /// + /// \param[in] condense_trivial + /// If true, only dump a header if the plan stack is just the base plan. + /// + /// \param[in] skip_unreported_plans + /// If true, skip printing all thread plan stacks that don't currently + /// have a backing lldb_private::Thread *. + void DumpThreadPlans(Stream &strm, lldb::DescriptionLevel desc_level, + bool internal, bool condense_trivial, + bool skip_unreported_plans); + /// 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 @@ -2665,6 +2753,10 @@ protected: ///see them. This is usually the same as ///< m_thread_list_real, but might be different if there is an OS plug-in ///creating memory threads + ThreadPlanStackMap m_thread_plans; ///< This is the list of thread plans for + /// threads in m_thread_list, as well as + /// threads we knew existed, but haven't + /// determined that they have died yet. ThreadList m_extended_thread_list; ///< Owner for extended threads that may be ///generated, cleared on natural stops uint32_t m_extended_thread_stop_id; ///< The natural stop id when @@ -2843,10 +2935,11 @@ private: void ControlPrivateStateThread(uint32_t signal); - DISALLOW_COPY_AND_ASSIGN(Process); + Process(const Process &) = delete; + const Process &operator=(const Process &) = delete; }; -/// RAII guard that should be aquired when an utility function is called within +/// RAII guard that should be acquired when an utility function is called within /// a given process. class UtilityFunctionScope { Process *m_process; @@ -2864,4 +2957,4 @@ public: } // namespace lldb_private -#endif // liblldb_Process_h_ +#endif // LLDB_TARGET_PROCESS_H diff --git a/lldb/include/lldb/Target/ProcessStructReader.h b/lldb/include/lldb/Target/ProcessStructReader.h index ade29c0a7cf7..0a91bef8048b 100644 --- a/lldb/include/lldb/Target/ProcessStructReader.h +++ b/lldb/include/lldb/Target/ProcessStructReader.h @@ -101,4 +101,4 @@ public: }; } -#endif // utility_ProcessStructReader_h_ +#endif // LLDB_TARGET_PROCESSSTRUCTREADER_H diff --git a/lldb/include/lldb/Target/Queue.h b/lldb/include/lldb/Target/Queue.h index 10b9e0242070..058d46a75a83 100644 --- a/lldb/include/lldb/Target/Queue.h +++ b/lldb/include/lldb/Target/Queue.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef liblldb_Queue_h_ -#define liblldb_Queue_h_ +#ifndef LLDB_TARGET_QUEUE_H +#define LLDB_TARGET_QUEUE_H #include <string> #include <vector> @@ -144,9 +144,10 @@ private: // dispatch_queue_t for this Queue lldb::QueueKind m_kind; - DISALLOW_COPY_AND_ASSIGN(Queue); + Queue(const Queue &) = delete; + const Queue &operator=(const Queue &) = delete; }; } // namespace lldb_private -#endif // liblldb_Queue_h_ +#endif // LLDB_TARGET_QUEUE_H diff --git a/lldb/include/lldb/Target/QueueItem.h b/lldb/include/lldb/Target/QueueItem.h index dfae3b847263..64d3d23b3986 100644 --- a/lldb/include/lldb/Target/QueueItem.h +++ b/lldb/include/lldb/Target/QueueItem.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef liblldb_QueueItem_h_ -#define liblldb_QueueItem_h_ +#ifndef LLDB_TARGET_QUEUEITEM_H +#define LLDB_TARGET_QUEUEITEM_H #include <memory> #include <string> @@ -159,9 +159,10 @@ protected: std::string m_target_queue_label; private: - DISALLOW_COPY_AND_ASSIGN(QueueItem); + QueueItem(const QueueItem &) = delete; + const QueueItem &operator=(const QueueItem &) = delete; }; } // namespace lldb_private -#endif // liblldb_QueueItem_h_ +#endif // LLDB_TARGET_QUEUEITEM_H diff --git a/lldb/include/lldb/Target/QueueList.h b/lldb/include/lldb/Target/QueueList.h index 761107e41def..7c74a6a99ac1 100644 --- a/lldb/include/lldb/Target/QueueList.h +++ b/lldb/include/lldb/Target/QueueList.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef liblldb_QueueList_h_ -#define liblldb_QueueList_h_ +#ifndef LLDB_TARGET_QUEUELIST_H +#define LLDB_TARGET_QUEUELIST_H #include <mutex> #include <vector> @@ -107,4 +107,4 @@ private: } // namespace lldb_private -#endif // liblldb_QueueList_h_ +#endif // LLDB_TARGET_QUEUELIST_H diff --git a/lldb/include/lldb/Target/RegisterCheckpoint.h b/lldb/include/lldb/Target/RegisterCheckpoint.h index 4f9654f76343..d2bcc614f587 100644 --- a/lldb/include/lldb/Target/RegisterCheckpoint.h +++ b/lldb/include/lldb/Target/RegisterCheckpoint.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef liblldb_RegisterCheckpoint_h_ -#define liblldb_RegisterCheckpoint_h_ +#ifndef LLDB_TARGET_REGISTERCHECKPOINT_H +#define LLDB_TARGET_REGISTERCHECKPOINT_H #include "lldb/Target/StackID.h" #include "lldb/Utility/UserID.h" @@ -45,9 +45,10 @@ protected: Reason m_reason; // Make RegisterCheckpointSP if you wish to share the data in this class. - DISALLOW_COPY_AND_ASSIGN(RegisterCheckpoint); + RegisterCheckpoint(const RegisterCheckpoint &) = delete; + const RegisterCheckpoint &operator=(const RegisterCheckpoint &) = delete; }; } // namespace lldb_private -#endif // liblldb_RegisterCheckpoint_h_ +#endif // LLDB_TARGET_REGISTERCHECKPOINT_H diff --git a/lldb/include/lldb/Target/RegisterContext.h b/lldb/include/lldb/Target/RegisterContext.h index d6212dd49dd6..5e795e59f941 100644 --- a/lldb/include/lldb/Target/RegisterContext.h +++ b/lldb/include/lldb/Target/RegisterContext.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef liblldb_RegisterContext_h_ -#define liblldb_RegisterContext_h_ +#ifndef LLDB_TARGET_REGISTERCONTEXT_H +#define LLDB_TARGET_REGISTERCONTEXT_H #include "lldb/Target/ExecutionContextScope.h" #include "lldb/lldb-private.h" @@ -39,6 +39,8 @@ public: virtual const RegisterSet *GetRegisterSet(size_t reg_set) = 0; + virtual lldb::ByteOrder GetByteOrder(); + virtual bool ReadRegister(const RegisterInfo *reg_info, RegisterValue ®_value) = 0; @@ -105,7 +107,7 @@ public: /// 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; + uint32_t num); // Subclasses can override these functions if desired virtual uint32_t NumSupportedHardwareBreakpoints(); @@ -201,9 +203,10 @@ protected: 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); + RegisterContext(const RegisterContext &) = delete; + const RegisterContext &operator=(const RegisterContext &) = delete; }; } // namespace lldb_private -#endif // liblldb_RegisterContext_h_ +#endif // LLDB_TARGET_REGISTERCONTEXT_H diff --git a/lldb/include/lldb/Target/RegisterContextUnwind.h b/lldb/include/lldb/Target/RegisterContextUnwind.h new file mode 100644 index 000000000000..fa96c3e42c78 --- /dev/null +++ b/lldb/include/lldb/Target/RegisterContextUnwind.h @@ -0,0 +1,259 @@ +//===-- RegisterContextUnwind.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_REGISTERCONTEXTUNWIND_H +#define LLDB_TARGET_REGISTERCONTEXTUNWIND_H + +#include <vector> + +#include "lldb/Symbol/SymbolContext.h" +#include "lldb/Symbol/UnwindPlan.h" +#include "lldb/Target/RegisterContext.h" +#include "lldb/Target/RegisterNumber.h" +#include "lldb/Target/UnwindLLDB.h" +#include "lldb/lldb-private.h" + +namespace lldb_private { + +class UnwindLLDB; + +class RegisterContextUnwind : public lldb_private::RegisterContext { +public: + typedef std::shared_ptr<RegisterContextUnwind> SharedPtr; + + RegisterContextUnwind(lldb_private::Thread &thread, + const SharedPtr &next_frame, + lldb_private::SymbolContext &sym_ctx, + uint32_t frame_number, + lldb_private::UnwindLLDB &unwind_lldb); + + ~RegisterContextUnwind() override = default; + + void InvalidateAllRegisters() override; + + size_t GetRegisterCount() override; + + const lldb_private::RegisterInfo *GetRegisterInfoAtIndex(size_t reg) override; + + size_t GetRegisterSetCount() override; + + const lldb_private::RegisterSet *GetRegisterSet(size_t reg_set) override; + + bool ReadRegister(const lldb_private::RegisterInfo *reg_info, + lldb_private::RegisterValue &value) override; + + bool WriteRegister(const lldb_private::RegisterInfo *reg_info, + const lldb_private::RegisterValue &value) override; + + bool ReadAllRegisterValues(lldb::DataBufferSP &data_sp) override; + + bool WriteAllRegisterValues(const lldb::DataBufferSP &data_sp) override; + + uint32_t ConvertRegisterKindToRegisterNumber(lldb::RegisterKind kind, + uint32_t num) override; + + bool IsValid() const; + + bool IsTrapHandlerFrame() const; + + bool GetCFA(lldb::addr_t &cfa); + + bool GetStartPC(lldb::addr_t &start_pc); + + bool ReadPC(lldb::addr_t &start_pc); + +private: + enum FrameType { + eNormalFrame, + eTrapHandlerFrame, + eDebuggerFrame, // a debugger inferior function call frame; we get caller's + // registers from debugger + eSkipFrame, // The unwind resulted in a bogus frame but may get back on + // track so we don't want to give up yet + eNotAValidFrame // this frame is invalid for some reason - most likely it is + // past the top (end) of the stack + }; + + // UnwindLLDB needs to pass around references to RegisterLocations + friend class UnwindLLDB; + + // Returns true if we have an unwind loop -- the same stack frame unwinding + // multiple times. + bool CheckIfLoopingStack(); + + // Indicates whether this frame is frame zero -- the currently + // executing frame -- or not. + bool IsFrameZero() const; + + void InitializeZerothFrame(); + + void InitializeNonZerothFrame(); + + SharedPtr GetNextFrame() const; + + SharedPtr GetPrevFrame() const; + + // A SkipFrame occurs when the unwind out of frame 0 didn't go right -- we've + // got one bogus frame at frame #1. + // There is a good chance we'll get back on track if we follow the frame + // pointer chain (or whatever is appropriate + // on this ABI) so we allow one invalid frame to be in the stack. Ideally + // we'll mark this frame specially at some + // point and indicate to the user that the unwinder had a hiccup. Often when + // this happens we will miss a frame of + // the program's actual stack in the unwind and we want to flag that for the + // user somehow. + bool IsSkipFrame() const; + + /// Determines if a SymbolContext is a trap handler or not + /// + /// Given a SymbolContext, determines if this is a trap handler function + /// aka asynchronous signal handler. + /// + /// \return + /// Returns true if the SymbolContext is a trap handler. + bool IsTrapHandlerSymbol(lldb_private::Process *process, + const lldb_private::SymbolContext &m_sym_ctx) const; + + /// Check if the given unwind plan indicates a signal trap handler, and + /// update frame type and symbol context if so. + void PropagateTrapHandlerFlagFromUnwindPlan(lldb::UnwindPlanSP unwind_plan); + + // Provide a location for where THIS function saved the CALLER's register + // value + // Or a frame "below" this one saved it, i.e. a function called by this one, + // preserved a register that this + // function didn't modify/use. + // + // The RegisterLocation type may be set to eRegisterNotAvailable -- this will + // happen for a volatile register + // being queried mid-stack. Instead of floating frame 0's contents of that + // register up the stack (which may + // or may not be the value of that reg when the function was executing), we + // won't return any value. + // + // If a non-volatile register (a "preserved" register) is requested mid-stack + // and no frames "below" the requested + // stack have saved the register anywhere, it is safe to assume that frame 0's + // register values are still the same + // as the requesting frame's. + lldb_private::UnwindLLDB::RegisterSearchResult + SavedLocationForRegister(uint32_t lldb_regnum, + lldb_private::UnwindLLDB::RegisterLocation ®loc); + + bool ReadRegisterValueFromRegisterLocation( + lldb_private::UnwindLLDB::RegisterLocation regloc, + const lldb_private::RegisterInfo *reg_info, + lldb_private::RegisterValue &value); + + bool WriteRegisterValueToRegisterLocation( + lldb_private::UnwindLLDB::RegisterLocation regloc, + const lldb_private::RegisterInfo *reg_info, + const lldb_private::RegisterValue &value); + + /// If the unwind has to the caller frame has failed, try something else + /// + /// If lldb is using an assembly language based UnwindPlan for a frame and + /// the unwind to the caller frame fails, try falling back to a generic + /// UnwindPlan (architecture default unwindplan) to see if that might work + /// better. This is mostly helping to work around problems where the + /// assembly language inspection fails on hand-written assembly code. + /// + /// \return + /// Returns true if a fallback unwindplan was found & was installed. + bool TryFallbackUnwindPlan(); + + /// Switch to the fallback unwind plan unconditionally without any safety + /// checks that it is providing better results than the normal unwind plan. + /// + /// The only time it is valid to call this method is if the full unwindplan is + /// found to be fundamentally incorrect/impossible. + /// + /// Returns true if it was able to install the fallback unwind plan. + bool ForceSwitchToFallbackUnwindPlan(); + + // Get the contents of a general purpose (address-size) register for this + // frame + // (usually retrieved from the next frame) + bool ReadGPRValue(lldb::RegisterKind register_kind, uint32_t regnum, + lldb::addr_t &value); + + bool ReadGPRValue(const RegisterNumber ®_num, lldb::addr_t &value); + + // Get the Frame Address register for a given frame. + bool ReadFrameAddress(lldb::RegisterKind register_kind, + UnwindPlan::Row::FAValue &fa, lldb::addr_t &address); + + lldb::UnwindPlanSP GetFastUnwindPlanForFrame(); + + lldb::UnwindPlanSP GetFullUnwindPlanForFrame(); + + void UnwindLogMsg(const char *fmt, ...) __attribute__((format(printf, 2, 3))); + + void UnwindLogMsgVerbose(const char *fmt, ...) + __attribute__((format(printf, 2, 3))); + + bool IsUnwindPlanValidForCurrentPC(lldb::UnwindPlanSP unwind_plan_sp, + int &valid_pc_offset); + + lldb::addr_t GetReturnAddressHint(int32_t plan_offset); + + lldb_private::Thread &m_thread; + + /// + // The following tell us how to retrieve the CALLER's register values (ie the + // "previous" frame, aka the frame above) + // i.e. where THIS frame saved them + /// + + lldb::UnwindPlanSP m_fast_unwind_plan_sp; // may be NULL + lldb::UnwindPlanSP m_full_unwind_plan_sp; + lldb::UnwindPlanSP m_fallback_unwind_plan_sp; // may be NULL + + bool m_all_registers_available; // Can we retrieve all regs or just + // nonvolatile regs? + int m_frame_type; // enum FrameType + + lldb::addr_t m_cfa; + lldb::addr_t m_afa; + lldb_private::Address m_start_pc; + lldb_private::Address m_current_pc; + + int m_current_offset; // how far into the function we've executed; -1 if + // unknown + // 0 if no instructions have been executed yet. + + int m_current_offset_backed_up_one; // how far into the function we've + // executed; -1 if unknown + // 0 if no instructions have been executed yet. + // On architectures where the return address on the stack points + // to the instruction after the CALL, this value will have 1 + // subtracted from it. Else a function that ends in a CALL will + // have an offset pointing into the next function's address range. + // m_current_pc has the actual address of the "current" pc. + + lldb_private::SymbolContext &m_sym_ctx; + bool m_sym_ctx_valid; // if ResolveSymbolContextForAddress fails, don't try to + // use m_sym_ctx + + uint32_t m_frame_number; // What stack frame this RegisterContext is + + std::map<uint32_t, lldb_private::UnwindLLDB::RegisterLocation> + m_registers; // where to find reg values for this frame + + lldb_private::UnwindLLDB &m_parent_unwind; // The UnwindLLDB that is creating + // this RegisterContextUnwind + + RegisterContextUnwind(const RegisterContextUnwind &) = delete; + const RegisterContextUnwind & + operator=(const RegisterContextUnwind &) = delete; +}; + +} // namespace lldb_private + +#endif // LLDB_TARGET_REGISTERCONTEXTUNWIND_H diff --git a/lldb/include/lldb/Target/RegisterNumber.h b/lldb/include/lldb/Target/RegisterNumber.h index 0bef0c13f378..362812bcffd0 100644 --- a/lldb/include/lldb/Target/RegisterNumber.h +++ b/lldb/include/lldb/Target/RegisterNumber.h @@ -56,4 +56,4 @@ private: const char *m_name; }; -#endif // liblldb_RegisterNumber_h +#endif // LLDB_TARGET_REGISTERNUMBER_H diff --git a/lldb/include/lldb/Target/RemoteAwarePlatform.h b/lldb/include/lldb/Target/RemoteAwarePlatform.h index 55d5ff673f1d..5741dbe027b7 100644 --- a/lldb/include/lldb/Target/RemoteAwarePlatform.h +++ b/lldb/include/lldb/Target/RemoteAwarePlatform.h @@ -22,6 +22,10 @@ public: bool GetModuleSpec(const FileSpec &module_file_spec, const ArchSpec &arch, ModuleSpec &module_spec) override; + Status + ResolveExecutable(const ModuleSpec &module_spec, lldb::ModuleSP &module_sp, + const FileSpecList *module_search_paths_ptr) override; + lldb::user_id_t OpenFile(const FileSpec &file_spec, File::OpenOptions flags, uint32_t mode, Status &error) override; diff --git a/lldb/include/lldb/Target/SectionLoadHistory.h b/lldb/include/lldb/Target/SectionLoadHistory.h index 71b5d0c42746..dd024301d0cf 100644 --- a/lldb/include/lldb/Target/SectionLoadHistory.h +++ b/lldb/include/lldb/Target/SectionLoadHistory.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef liblldb_SectionLoadHistory_h_ -#define liblldb_SectionLoadHistory_h_ +#ifndef LLDB_TARGET_SECTIONLOADHISTORY_H +#define LLDB_TARGET_SECTIONLOADHISTORY_H #include <map> #include <mutex> @@ -75,9 +75,10 @@ protected: mutable std::recursive_mutex m_mutex; private: - DISALLOW_COPY_AND_ASSIGN(SectionLoadHistory); + SectionLoadHistory(const SectionLoadHistory &) = delete; + const SectionLoadHistory &operator=(const SectionLoadHistory &) = delete; }; } // namespace lldb_private -#endif // liblldb_SectionLoadHistory_h_ +#endif // LLDB_TARGET_SECTIONLOADHISTORY_H diff --git a/lldb/include/lldb/Target/SectionLoadList.h b/lldb/include/lldb/Target/SectionLoadList.h index caefa00ec1da..e8535e7ac51a 100644 --- a/lldb/include/lldb/Target/SectionLoadList.h +++ b/lldb/include/lldb/Target/SectionLoadList.h @@ -7,8 +7,8 @@ // //===----------------------------------------------------------------------===// -#ifndef liblldb_SectionLoadList_h_ -#define liblldb_SectionLoadList_h_ +#ifndef LLDB_TARGET_SECTIONLOADLIST_H +#define LLDB_TARGET_SECTIONLOADLIST_H #include <map> #include <mutex> @@ -70,4 +70,4 @@ protected: } // namespace lldb_private -#endif // liblldb_SectionLoadList_h_ +#endif // LLDB_TARGET_SECTIONLOADLIST_H diff --git a/lldb/include/lldb/Target/StackFrame.h b/lldb/include/lldb/Target/StackFrame.h index 1c6a2b481160..905c56c91263 100644 --- a/lldb/include/lldb/Target/StackFrame.h +++ b/lldb/include/lldb/Target/StackFrame.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef liblldb_StackFrame_h_ -#define liblldb_StackFrame_h_ +#ifndef LLDB_TARGET_STACKFRAME_H +#define LLDB_TARGET_STACKFRAME_H #include <memory> #include <mutex> @@ -367,12 +367,6 @@ public: /// may have limited support for inspecting variables. bool IsArtificial() const; - /// Query whether this frame behaves like the zeroth frame, in the sense - /// that its pc value might not immediately follow a call (and thus might - /// be the first address of its function). True for actual frame zero as - /// well as any other frame with the same trait. - bool BehavesLikeZerothFrame() const; - /// Query this frame to find what frame it is in this Thread's /// StackFrameList. /// @@ -517,6 +511,11 @@ private: bool m_cfa_is_valid; // Does this frame have a CFA? Different from CFA == // LLDB_INVALID_ADDRESS Kind m_stack_frame_kind; + + // Whether this frame behaves like the zeroth frame, in the sense + // that its pc value might not immediately follow a call (and thus might + // be the first address of its function). True for actual frame zero as + // well as any other frame with the same trait. bool m_behaves_like_zeroth_frame; lldb::VariableListSP m_variable_list_sp; ValueObjectList m_variable_list_value_objects; // Value objects for each @@ -526,9 +525,10 @@ private: StreamString m_disassembly; std::recursive_mutex m_mutex; - DISALLOW_COPY_AND_ASSIGN(StackFrame); + StackFrame(const StackFrame &) = delete; + const StackFrame &operator=(const StackFrame &) = delete; }; } // namespace lldb_private -#endif // liblldb_StackFrame_h_ +#endif // LLDB_TARGET_STACKFRAME_H diff --git a/lldb/include/lldb/Target/StackFrameList.h b/lldb/include/lldb/Target/StackFrameList.h index 5eb791950172..1b0b986d7059 100644 --- a/lldb/include/lldb/Target/StackFrameList.h +++ b/lldb/include/lldb/Target/StackFrameList.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef liblldb_StackFrameList_h_ -#define liblldb_StackFrameList_h_ +#ifndef LLDB_TARGET_STACKFRAMELIST_H +#define LLDB_TARGET_STACKFRAMELIST_H #include <memory> #include <mutex> @@ -94,7 +94,7 @@ protected: void GetFramesUpTo(uint32_t end_idx); - void GetOnlyConcreteFramesUpTo(uint32_t end_idx, Unwind *unwinder); + void GetOnlyConcreteFramesUpTo(uint32_t end_idx, Unwind &unwinder); void SynthesizeTailCallFrames(StackFrame &next_frame); @@ -155,9 +155,10 @@ protected: const bool m_show_inlined_frames; private: - DISALLOW_COPY_AND_ASSIGN(StackFrameList); + StackFrameList(const StackFrameList &) = delete; + const StackFrameList &operator=(const StackFrameList &) = delete; }; } // namespace lldb_private -#endif // liblldb_StackFrameList_h_ +#endif // LLDB_TARGET_STACKFRAMELIST_H diff --git a/lldb/include/lldb/Target/StackFrameRecognizer.h b/lldb/include/lldb/Target/StackFrameRecognizer.h index 2021ac5215f3..9c9105ac04e4 100644 --- a/lldb/include/lldb/Target/StackFrameRecognizer.h +++ b/lldb/include/lldb/Target/StackFrameRecognizer.h @@ -6,12 +6,13 @@ // //===----------------------------------------------------------------------===// -#ifndef liblldb_StackFrameRecognizer_h_ -#define liblldb_StackFrameRecognizer_h_ +#ifndef LLDB_TARGET_STACKFRAMERECOGNIZER_H +#define LLDB_TARGET_STACKFRAMERECOGNIZER_H #include "lldb/Core/ValueObject.h" #include "lldb/Core/ValueObjectList.h" #include "lldb/Symbol/VariableList.h" +#include "lldb/Target/StopInfo.h" #include "lldb/Utility/StructuredData.h" #include "lldb/lldb-private-forward.h" #include "lldb/lldb-public.h" @@ -33,10 +34,14 @@ public: virtual lldb::ValueObjectSP GetExceptionObject() { return lldb::ValueObjectSP(); } + virtual lldb::StackFrameSP GetMostRelevantFrame() { return nullptr; }; virtual ~RecognizedStackFrame(){}; + std::string GetStopDescription() { return m_stop_desc; } + protected: lldb::ValueObjectListSP m_arguments; + std::string m_stop_desc; }; /// \class StackFrameRecognizer @@ -85,7 +90,9 @@ public: lldb::StackFrameSP frame) override; private: - DISALLOW_COPY_AND_ASSIGN(ScriptedStackFrameRecognizer); + ScriptedStackFrameRecognizer(const ScriptedStackFrameRecognizer &) = delete; + const ScriptedStackFrameRecognizer & + operator=(const ScriptedStackFrameRecognizer &) = delete; }; /// \class StackFrameRecognizerManager @@ -97,7 +104,7 @@ class StackFrameRecognizerManager { public: static void AddRecognizer(lldb::StackFrameRecognizerSP recognizer, ConstString module, - ConstString symbol, + llvm::ArrayRef<ConstString> symbols, bool first_instruction_only = true); static void AddRecognizer(lldb::StackFrameRecognizerSP recognizer, @@ -105,10 +112,11 @@ public: lldb::RegularExpressionSP symbol, bool first_instruction_only = true); - static void ForEach( - std::function<void(uint32_t recognizer_id, std::string recognizer_name, - std::string module, std::string symbol, - bool regexp)> const &callback); + static void + ForEach(std::function<void(uint32_t recognizer_id, + std::string recognizer_name, std::string module, + llvm::ArrayRef<ConstString> symbols, + bool regexp)> const &callback); static bool RemoveRecognizerWithID(uint32_t recognizer_id); @@ -158,4 +166,4 @@ class ValueObjectRecognizerSynthesizedValue : public ValueObject { } // namespace lldb_private -#endif // liblldb_StackFrameRecognizer_h_ +#endif // LLDB_TARGET_STACKFRAMERECOGNIZER_H diff --git a/lldb/include/lldb/Target/StackID.h b/lldb/include/lldb/Target/StackID.h index a649a4faa939..827ed1be7c0f 100644 --- a/lldb/include/lldb/Target/StackID.h +++ b/lldb/include/lldb/Target/StackID.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef liblldb_StackID_h_ -#define liblldb_StackID_h_ +#ifndef LLDB_TARGET_STACKID_H +#define LLDB_TARGET_STACKID_H #include "lldb/Core/AddressRange.h" #include "lldb/lldb-private.h" @@ -96,4 +96,4 @@ bool operator<(const StackID &lhs, const StackID &rhs); } // namespace lldb_private -#endif // liblldb_StackID_h_ +#endif // LLDB_TARGET_STACKID_H diff --git a/lldb/include/lldb/Target/StopInfo.h b/lldb/include/lldb/Target/StopInfo.h index 61e1fbd4bd46..4378d2d63799 100644 --- a/lldb/include/lldb/Target/StopInfo.h +++ b/lldb/include/lldb/Target/StopInfo.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef liblldb_StopInfo_h_ -#define liblldb_StopInfo_h_ +#ifndef LLDB_TARGET_STOPINFO_H +#define LLDB_TARGET_STOPINFO_H #include <string> @@ -183,9 +183,10 @@ protected: private: friend class Thread; - DISALLOW_COPY_AND_ASSIGN(StopInfo); + StopInfo(const StopInfo &) = delete; + const StopInfo &operator=(const StopInfo &) = delete; }; } // namespace lldb_private -#endif // liblldb_StopInfo_h_ +#endif // LLDB_TARGET_STOPINFO_H diff --git a/lldb/include/lldb/Target/StructuredDataPlugin.h b/lldb/include/lldb/Target/StructuredDataPlugin.h index b20bdb3b263a..09241d5281fb 100644 --- a/lldb/include/lldb/Target/StructuredDataPlugin.h +++ b/lldb/include/lldb/Target/StructuredDataPlugin.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef StructuredDataPlugin_h -#define StructuredDataPlugin_h +#ifndef LLDB_TARGET_STRUCTUREDDATAPLUGIN_H +#define LLDB_TARGET_STRUCTUREDDATAPLUGIN_H #include "lldb/Core/PluginInterface.h" #include "lldb/Utility/StructuredData.h" @@ -162,7 +162,8 @@ protected: private: lldb::ProcessWP m_process_wp; - DISALLOW_COPY_AND_ASSIGN(StructuredDataPlugin); + StructuredDataPlugin(const StructuredDataPlugin &) = delete; + const StructuredDataPlugin &operator=(const StructuredDataPlugin &) = delete; }; } diff --git a/lldb/include/lldb/Target/SystemRuntime.h b/lldb/include/lldb/Target/SystemRuntime.h index b45f882d36b0..4f07d7ab52e5 100644 --- a/lldb/include/lldb/Target/SystemRuntime.h +++ b/lldb/include/lldb/Target/SystemRuntime.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef liblldb_SystemRuntime_h_ -#define liblldb_SystemRuntime_h_ +#ifndef LLDB_TARGET_SYSTEMRUNTIME_H +#define LLDB_TARGET_SYSTEMRUNTIME_H #include <vector> @@ -300,9 +300,10 @@ protected: std::vector<ConstString> m_types; private: - DISALLOW_COPY_AND_ASSIGN(SystemRuntime); + SystemRuntime(const SystemRuntime &) = delete; + const SystemRuntime &operator=(const SystemRuntime &) = delete; }; } // namespace lldb_private -#endif // liblldb_SystemRuntime_h_ +#endif // LLDB_TARGET_SYSTEMRUNTIME_H diff --git a/lldb/include/lldb/Target/Target.h b/lldb/include/lldb/Target/Target.h index 1e9153c401ef..280ce6359c72 100644 --- a/lldb/include/lldb/Target/Target.h +++ b/lldb/include/lldb/Target/Target.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef liblldb_Target_h_ -#define liblldb_Target_h_ +#ifndef LLDB_TARGET_TARGET_H +#define LLDB_TARGET_TARGET_H #include <list> #include <map> @@ -36,6 +36,8 @@ namespace lldb_private { +class ClangModulesDeclVendor; + OptionEnumValues GetDynamicValueTypes(); enum InlineStrategy { @@ -62,7 +64,6 @@ enum LoadDependentFiles { eLoadDependentsNo, }; -// TargetProperties class TargetExperimentalProperties : public Properties { public: TargetExperimentalProperties(); @@ -133,6 +134,8 @@ public: bool GetEnableAutoApplyFixIts() const; + uint64_t GetNumberOfRetriesWithFixits() const; + bool GetEnableNotifyAboutFixIts() const; bool GetEnableSaveObjects() const; @@ -202,11 +205,16 @@ public: bool GetInjectLocalVariables(ExecutionContext *exe_ctx) const; void SetInjectLocalVariables(ExecutionContext *exe_ctx, bool b); - + void SetRequireHardwareBreakpoints(bool b); bool GetRequireHardwareBreakpoints() const; + bool GetAutoInstallMainExecutable() const; + + void UpdateLaunchInfoFromProperties(); + + private: // Callbacks for m_launch_info. void Arg0ValueChangedCallback(); @@ -219,9 +227,12 @@ private: void DisableASLRValueChangedCallback(); void DisableSTDIOValueChangedCallback(); + Environment ComputeEnvironment() const; + // Member variables. ProcessLaunchInfo m_launch_info; std::unique_ptr<TargetExperimentalProperties> m_experimental_properties_up; + Target *m_target; }; class EvaluateExpressionOptions { @@ -371,6 +382,12 @@ public: bool GetAutoApplyFixIts() const { return m_auto_apply_fixits; } + void SetRetriesWithFixIts(uint64_t number_of_retries) { + m_retries_with_fixits = number_of_retries; + } + + uint64_t GetRetriesWithFixIts() const { return m_retries_with_fixits; } + bool IsForUtilityExpr() const { return m_running_utility_expression; } void SetIsForUtilityExpr(bool b) { m_running_utility_expression = b; } @@ -392,6 +409,7 @@ private: bool m_ansi_color_errors = false; bool m_result_is_internal = false; bool m_auto_apply_fixits = true; + uint64_t m_retries_with_fixits = 1; /// True if the executed code should be treated as utility code that is only /// used by LLDB internally. bool m_running_utility_expression = false; @@ -467,7 +485,8 @@ public: lldb::TargetSP m_target_sp; ModuleList m_module_list; - DISALLOW_COPY_AND_ASSIGN(TargetEventData); + TargetEventData(const TargetEventData &) = delete; + const TargetEventData &operator=(const TargetEventData &) = delete; }; ~Target() override; @@ -940,7 +959,7 @@ public: /// /// \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. + /// selected platform is not compatible with the architecture 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). @@ -1054,8 +1073,6 @@ public: const char *name, Status &error); - lldb::ClangASTImporterSP GetClangASTImporter(); - // Install any files through the platform that need be to installed prior to // launching or attaching. Status Install(ProcessLaunchInfo *launch_info); @@ -1093,11 +1110,6 @@ public: 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(ConstString name); /// This method will return the address of the starting function for @@ -1302,8 +1314,7 @@ protected: typedef std::map<lldb::LanguageType, lldb::REPLSP> REPLMap; REPLMap m_repl_map; - lldb::ClangASTImporterSP m_ast_importer_sp; - lldb::ClangModulesDeclVendorUP m_clang_modules_decl_vendor_up; + std::unique_ptr<ClangModulesDeclVendor> m_clang_modules_decl_vendor_up; lldb::SourceManagerUP m_source_manager_up; @@ -1359,9 +1370,10 @@ private: void FinalizeFileActions(ProcessLaunchInfo &info); - DISALLOW_COPY_AND_ASSIGN(Target); + Target(const Target &) = delete; + const Target &operator=(const Target &) = delete; }; } // namespace lldb_private -#endif // liblldb_Target_h_ +#endif // LLDB_TARGET_TARGET_H diff --git a/lldb/include/lldb/Target/TargetList.h b/lldb/include/lldb/Target/TargetList.h index 50a7a321ead1..5ed0344f175c 100644 --- a/lldb/include/lldb/Target/TargetList.h +++ b/lldb/include/lldb/Target/TargetList.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef liblldb_TargetList_h_ -#define liblldb_TargetList_h_ +#ifndef LLDB_TARGET_TARGETLIST_H +#define LLDB_TARGET_TARGETLIST_H #include <mutex> #include <vector> @@ -206,9 +206,10 @@ private: lldb::PlatformSP &platform_sp, lldb::TargetSP &target_sp, bool is_dummy_target); - DISALLOW_COPY_AND_ASSIGN(TargetList); + TargetList(const TargetList &) = delete; + const TargetList &operator=(const TargetList &) = delete; }; } // namespace lldb_private -#endif // liblldb_TargetList_h_ +#endif // LLDB_TARGET_TARGETLIST_H diff --git a/lldb/include/lldb/Target/Thread.h b/lldb/include/lldb/Target/Thread.h index cdc8d39251c6..205a0d965c63 100644 --- a/lldb/include/lldb/Target/Thread.h +++ b/lldb/include/lldb/Target/Thread.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef liblldb_Thread_h_ -#define liblldb_Thread_h_ +#ifndef LLDB_TARGET_THREAD_H +#define LLDB_TARGET_THREAD_H #include <memory> #include <mutex> @@ -28,6 +28,8 @@ namespace lldb_private { +class ThreadPlanStack; + class ThreadProperties : public Properties { public: ThreadProperties(bool is_global); @@ -111,7 +113,8 @@ public: lldb::ThreadSP m_thread_sp; StackID m_stack_id; - DISALLOW_COPY_AND_ASSIGN(ThreadEventData); + ThreadEventData(const ThreadEventData &) = delete; + const ThreadEventData &operator=(const ThreadEventData &) = delete; }; struct ThreadStateCheckpoint { @@ -119,7 +122,7 @@ public: // bit of data. lldb::StopInfoSP stop_info_sp; // You have to restore the stop info or you // might continue with the wrong signals. - std::vector<lldb::ThreadPlanSP> m_completed_plan_stack; + size_t m_completed_plan_checkpoint; lldb::RegisterCheckpointSP register_backup_sp; // You need to restore the registers, of course... uint32_t current_inlined_depth; @@ -177,8 +180,6 @@ 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 - /// 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; @@ -216,6 +217,12 @@ public: virtual void RefreshStateAfterStop() = 0; + void SelectMostRelevantFrame(); + + std::string GetStopDescription(); + + std::string GetStopDescriptionRaw(); + void WillStop(); bool ShouldStop(Event *event_ptr); @@ -908,7 +915,7 @@ public: /// /// \return /// A pointer to the next executed plan. - ThreadPlan *GetCurrentPlan(); + ThreadPlan *GetCurrentPlan() const; /// Unwinds the thread stack for the innermost expression plan currently /// on the thread plan stack. @@ -923,14 +930,14 @@ public: /// /// \return /// A pointer to the last completed plan. - lldb::ThreadPlanSP GetCompletedPlan(); + lldb::ThreadPlanSP GetCompletedPlan() const; /// Gets the outer-most return value from the completed plans /// /// \return /// A ValueObjectSP, either empty if there is no return value, /// or containing the return value. - lldb::ValueObjectSP GetReturnValueObject(); + lldb::ValueObjectSP GetReturnValueObject() const; /// Gets the outer-most expression variable from the completed plans /// @@ -938,7 +945,7 @@ public: /// 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(); + lldb::ExpressionVariableSP GetExpressionVariable() const; /// Checks whether the given plan is in the completed plans for this /// stop. @@ -949,7 +956,7 @@ public: /// \return /// Returns true if the input plan is in the completed plan stack, /// false otherwise. - bool IsThreadPlanDone(ThreadPlan *plan); + bool IsThreadPlanDone(ThreadPlan *plan) const; /// Checks whether the given plan is in the discarded plans for this /// stop. @@ -960,14 +967,14 @@ public: /// \return /// Returns true if the input plan is in the discarded plan stack, /// false otherwise. - bool WasThreadPlanDiscarded(ThreadPlan *plan); + bool WasThreadPlanDiscarded(ThreadPlan *plan) const; /// Check if we have completed plan to override breakpoint stop reason /// /// \return /// Returns true if completed plan stack is not empty /// false otherwise. - bool CompletedPlanOverridesBreakpoint(); + bool CompletedPlanOverridesBreakpoint() const; /// Queues a generic thread plan. /// @@ -1013,16 +1020,6 @@ public: /// otherwise. bool DiscardUserThreadPlansUpToIndex(uint32_t thread_index); - /// Prints the current plan stack. - /// - /// \param[in] s - /// The stream to which to dump the plan stack info. - /// - void DumpThreadPlans( - Stream *s, - lldb::DescriptionLevel desc_level = lldb::eDescriptionLevelVerbose, - bool include_internal = true, bool ignore_boring = false) const; - virtual bool CheckpointThreadState(ThreadStateCheckpoint &saved_state); virtual bool @@ -1151,7 +1148,7 @@ public: /// 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 The extended backtrace token. virtual void SetExtendedBacktraceToken(uint64_t token) {} /// Gets the extended backtrace token for this thread @@ -1181,17 +1178,17 @@ protected: // be called by classes that derive from Thread in their destructor. virtual void DestroyThread(); - void PushPlan(lldb::ThreadPlanSP &plan_sp); + ThreadPlanStack &GetPlans() const; + + void PushPlan(lldb::ThreadPlanSP plan_sp); void PopPlan(); void DiscardPlan(); - ThreadPlan *GetPreviousPlan(ThreadPlan *plan); + ThreadPlan *GetPreviousPlan(ThreadPlan *plan) const; - typedef std::vector<lldb::ThreadPlanSP> plan_stack; - - virtual lldb_private::Unwind *GetUnwinder(); + virtual Unwind &GetUnwinder(); // Check to see whether the thread is still at the last breakpoint hit that // stopped it. @@ -1215,7 +1212,7 @@ protected: m_temporary_resume_state = new_state; } - void FunctionOptimizationWarning(lldb_private::StackFrame *frame); + void FrameSelectedCallback(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. @@ -1234,13 +1231,6 @@ protected: lldb::StateType m_state; ///< The state of our process. mutable std::recursive_mutex m_state_mutex; ///< Multithreaded protection for m_state. - plan_stack m_plan_stack; ///< The stack of plans this thread is executing. - plan_stack m_completed_plan_stack; ///< Plans that have been completed by this - ///stop. They get deleted when the thread - ///resumes. - plan_stack m_discarded_plan_stack; ///< Plans that have been discarded by this - ///stop. They get deleted when the thread - ///resumes. mutable std::recursive_mutex m_frame_mutex; ///< Multithreaded protection for m_state. lldb::StackFrameListSP m_curr_frames_sp; ///< The stack frames that get lazily @@ -1261,20 +1251,19 @@ protected: bool m_destroy_called; // This is used internally to make sure derived Thread // classes call DestroyThread. LazyBool m_override_should_notify; + mutable std::unique_ptr<ThreadPlanStack> m_null_plan_stack_up; private: bool m_extended_info_fetched; // Have we tried to retrieve the m_extended_info // for this thread? StructuredData::ObjectSP m_extended_info; // The extended info for this thread -private: - bool PlanIsBasePlan(ThreadPlan *plan_ptr); - void BroadcastSelectedFrameChange(StackID &new_frame_id); - DISALLOW_COPY_AND_ASSIGN(Thread); + Thread(const Thread &) = delete; + const Thread &operator=(const Thread &) = delete; }; } // namespace lldb_private -#endif // liblldb_Thread_h_ +#endif // LLDB_TARGET_THREAD_H diff --git a/lldb/include/lldb/Target/ThreadCollection.h b/lldb/include/lldb/Target/ThreadCollection.h index 29ea827203e5..40dc938976ff 100644 --- a/lldb/include/lldb/Target/ThreadCollection.h +++ b/lldb/include/lldb/Target/ThreadCollection.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef liblldb_ThreadCollection_h_ -#define liblldb_ThreadCollection_h_ +#ifndef LLDB_TARGET_THREADCOLLECTION_H +#define LLDB_TARGET_THREADCOLLECTION_H #include <mutex> #include <vector> @@ -56,4 +56,4 @@ protected: } // namespace lldb_private -#endif // liblldb_ThreadCollection_h_ +#endif // LLDB_TARGET_THREADCOLLECTION_H diff --git a/lldb/include/lldb/Target/ThreadList.h b/lldb/include/lldb/Target/ThreadList.h index 64ddf5aea504..6af04f8ffc37 100644 --- a/lldb/include/lldb/Target/ThreadList.h +++ b/lldb/include/lldb/Target/ThreadList.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef liblldb_ThreadList_h_ -#define liblldb_ThreadList_h_ +#ifndef LLDB_TARGET_THREADLIST_H +#define LLDB_TARGET_THREADLIST_H #include <mutex> #include <vector> @@ -156,4 +156,4 @@ private: } // namespace lldb_private -#endif // liblldb_ThreadList_h_ +#endif // LLDB_TARGET_THREADLIST_H diff --git a/lldb/include/lldb/Target/ThreadPlan.h b/lldb/include/lldb/Target/ThreadPlan.h index ff87ed23cda5..8c2f9776eeb3 100644 --- a/lldb/include/lldb/Target/ThreadPlan.h +++ b/lldb/include/lldb/Target/ThreadPlan.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef liblldb_ThreadPlan_h_ -#define liblldb_ThreadPlan_h_ +#ifndef LLDB_TARGET_THREADPLAN_H +#define LLDB_TARGET_THREADPLAN_H #include <mutex> #include <string> @@ -251,7 +251,7 @@ namespace lldb_private { // However, if the plan doesn't want to be // the stop reason, then it can call SetPlanComplete and pass in "false" for // the "success" parameter. In that case, -// the real stop reason will be used instead. One exapmle of this is the +// the real stop reason will be used instead. One example of this is the // "StepRangeStepIn" thread plan. If it stops // because of a crash or breakpoint hit, it wants to unship itself, because it // isn't so useful to have step in keep going @@ -369,16 +369,16 @@ public: /// /// \return /// A pointer to the thread plan's owning thread. - Thread &GetThread() { return m_thread; } + Thread &GetThread(); - const Thread &GetThread() const { return m_thread; } + Target &GetTarget(); - Target &GetTarget() { return m_thread.GetProcess()->GetTarget(); } - - const Target &GetTarget() const { return m_thread.GetProcess()->GetTarget(); } + const Target &GetTarget() const; /// Print a description of this thread to the stream \a s. - /// \a thread. + /// \a thread. Don't expect that the result of GetThread is valid in + /// the description method. This might get called when the underlying + /// Thread has not been reported, so we only know the TID and not the thread. /// /// \param[in] s /// The stream to which to print the description. @@ -461,8 +461,12 @@ public: virtual void WillPop(); // This pushes a plan onto the plan stack of the current plan's thread. + // Also sets the plans to private and not master plans. A plan pushed by + // another thread plan is never either of the above. void PushPlan(lldb::ThreadPlanSP &thread_plan_sp) { - m_thread.PushPlan(thread_plan_sp); + GetThread().PushPlan(thread_plan_sp); + thread_plan_sp->SetPrivate(false); + thread_plan_sp->SetIsMasterPlan(false); } ThreadPlanKind GetKind() const { return m_kind; } @@ -493,7 +497,9 @@ public: // original stop reason so that stopping and calling a few functions won't // lose the history of the run. This call can be implemented to get you back // to the real stop info. - virtual lldb::StopInfoSP GetRealStopInfo() { return m_thread.GetStopInfo(); } + virtual lldb::StopInfoSP GetRealStopInfo() { + return GetThread().GetStopInfo(); + } // If the completion of the thread plan stepped out of a function, the return // value of the function might have been captured by the thread plan @@ -556,17 +562,17 @@ protected: // This is mostly a formal requirement, it allows us to make the Thread's // GetPreviousPlan protected, but only friend ThreadPlan to thread. - ThreadPlan *GetPreviousPlan() { return m_thread.GetPreviousPlan(this); } + ThreadPlan *GetPreviousPlan() { return GetThread().GetPreviousPlan(this); } // This forwards the private Thread::GetPrivateStopInfo which is generally // what ThreadPlan's need to know. lldb::StopInfoSP GetPrivateStopInfo() { - return m_thread.GetPrivateStopInfo(); + return GetThread().GetPrivateStopInfo(); } void SetStopInfo(lldb::StopInfoSP stop_reason_sp) { - m_thread.SetStopInfo(stop_reason_sp); + GetThread().SetStopInfo(stop_reason_sp); } void CachePlanExplainsStop(bool does_explain) { @@ -582,7 +588,8 @@ protected: bool IsUsuallyUnexplainedStopReason(lldb::StopReason); Status m_status; - Thread &m_thread; + Process &m_process; + lldb::tid_t m_tid; Vote m_stop_vote; Vote m_run_vote; bool m_takes_iteration_count; @@ -593,6 +600,9 @@ private: // For ThreadPlan only static lldb::user_id_t GetNextID(); + Thread *m_thread; // Stores a cached value of the thread, which is set to + // nullptr when the thread resumes. Don't use this anywhere + // but ThreadPlan::GetThread(). ThreadPlanKind m_kind; std::string m_name; std::recursive_mutex m_plan_complete_mutex; @@ -605,8 +615,8 @@ private: lldb::ThreadPlanTracerSP m_tracer_sp; -private: - DISALLOW_COPY_AND_ASSIGN(ThreadPlan); + ThreadPlan(const ThreadPlan &) = delete; + const ThreadPlan &operator=(const ThreadPlan &) = delete; }; // ThreadPlanNull: @@ -641,9 +651,10 @@ protected: lldb::StateType GetPlanRunState() override; - DISALLOW_COPY_AND_ASSIGN(ThreadPlanNull); + ThreadPlanNull(const ThreadPlanNull &) = delete; + const ThreadPlanNull &operator=(const ThreadPlanNull &) = delete; }; } // namespace lldb_private -#endif // liblldb_ThreadPlan_h_ +#endif // LLDB_TARGET_THREADPLAN_H diff --git a/lldb/include/lldb/Target/ThreadPlanBase.h b/lldb/include/lldb/Target/ThreadPlanBase.h index bc92a06229a7..48058a9b40ab 100644 --- a/lldb/include/lldb/Target/ThreadPlanBase.h +++ b/lldb/include/lldb/Target/ThreadPlanBase.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef liblldb_ThreadPlanFundamental_h_ -#define liblldb_ThreadPlanFundamental_h_ +#ifndef LLDB_TARGET_THREADPLANBASE_H +#define LLDB_TARGET_THREADPLANBASE_H #include "lldb/Target/Process.h" #include "lldb/Target/Thread.h" @@ -47,9 +47,10 @@ private: friend lldb::ThreadPlanSP Thread::QueueFundamentalPlan(bool abort_other_plans); - DISALLOW_COPY_AND_ASSIGN(ThreadPlanBase); + ThreadPlanBase(const ThreadPlanBase &) = delete; + const ThreadPlanBase &operator=(const ThreadPlanBase &) = delete; }; } // namespace lldb_private -#endif // liblldb_ThreadPlanFundamental_h_ +#endif // LLDB_TARGET_THREADPLANBASE_H diff --git a/lldb/include/lldb/Target/ThreadPlanCallFunction.h b/lldb/include/lldb/Target/ThreadPlanCallFunction.h index 685160a5678a..5b432e5e604a 100644 --- a/lldb/include/lldb/Target/ThreadPlanCallFunction.h +++ b/lldb/include/lldb/Target/ThreadPlanCallFunction.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef liblldb_ThreadPlanCallFunction_h_ -#define liblldb_ThreadPlanCallFunction_h_ +#ifndef LLDB_TARGET_THREADPLANCALLFUNCTION_H +#define LLDB_TARGET_THREADPLANCALLFUNCTION_H #include "lldb/Target/Thread.h" #include "lldb/Target/ThreadPlan.h" @@ -146,9 +146,11 @@ protected: private: CompilerType m_return_type; - DISALLOW_COPY_AND_ASSIGN(ThreadPlanCallFunction); + ThreadPlanCallFunction(const ThreadPlanCallFunction &) = delete; + const ThreadPlanCallFunction & + operator=(const ThreadPlanCallFunction &) = delete; }; } // namespace lldb_private -#endif // liblldb_ThreadPlanCallFunction_h_ +#endif // LLDB_TARGET_THREADPLANCALLFUNCTION_H diff --git a/lldb/include/lldb/Target/ThreadPlanCallFunctionUsingABI.h b/lldb/include/lldb/Target/ThreadPlanCallFunctionUsingABI.h index c21e4d3cf3f7..af343d8a6635 100644 --- a/lldb/include/lldb/Target/ThreadPlanCallFunctionUsingABI.h +++ b/lldb/include/lldb/Target/ThreadPlanCallFunctionUsingABI.h @@ -7,8 +7,8 @@ // //===----------------------------------------------------------------------===// -#ifndef liblldb_ThreadPlanCallFunctionUsingABI_h_ -#define liblldb_ThreadPlanCallFunctionUsingABI_h_ +#ifndef LLDB_TARGET_THREADPLANCALLFUNCTIONUSINGABI_H +#define LLDB_TARGET_THREADPLANCALLFUNCTIONUSINGABI_H #include "lldb/Target/ABI.h" #include "lldb/Target/Thread.h" @@ -44,9 +44,12 @@ protected: private: llvm::Type &m_return_type; - DISALLOW_COPY_AND_ASSIGN(ThreadPlanCallFunctionUsingABI); + ThreadPlanCallFunctionUsingABI(const ThreadPlanCallFunctionUsingABI &) = + delete; + const ThreadPlanCallFunctionUsingABI & + operator=(const ThreadPlanCallFunctionUsingABI &) = delete; }; } // namespace lldb_private -#endif // liblldb_ThreadPlanCallFunctionUsingABI_h_ +#endif // LLDB_TARGET_THREADPLANCALLFUNCTIONUSINGABI_H diff --git a/lldb/include/lldb/Target/ThreadPlanCallOnFunctionExit.h b/lldb/include/lldb/Target/ThreadPlanCallOnFunctionExit.h index ad3ee6e0e8f9..1dd6a04408e5 100644 --- a/lldb/include/lldb/Target/ThreadPlanCallOnFunctionExit.h +++ b/lldb/include/lldb/Target/ThreadPlanCallOnFunctionExit.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef ThreadPlanCallOnFunctionExit_h -#define ThreadPlanCallOnFunctionExit_h +#ifndef LLDB_TARGET_THREADPLANCALLONFUNCTIONEXIT_H +#define LLDB_TARGET_THREADPLANCALLONFUNCTIONEXIT_H #include "lldb/Target/ThreadPlan.h" @@ -50,4 +50,4 @@ private: }; } -#endif /* ThreadPlanCallOnFunctionExit_h */ +#endif // LLDB_TARGET_THREADPLANCALLONFUNCTIONEXIT_H diff --git a/lldb/include/lldb/Target/ThreadPlanCallUserExpression.h b/lldb/include/lldb/Target/ThreadPlanCallUserExpression.h index 637215582410..adaea6c7056f 100644 --- a/lldb/include/lldb/Target/ThreadPlanCallUserExpression.h +++ b/lldb/include/lldb/Target/ThreadPlanCallUserExpression.h @@ -7,8 +7,8 @@ // //===----------------------------------------------------------------------===// -#ifndef liblldb_ThreadPlanCallUserExpression_h_ -#define liblldb_ThreadPlanCallUserExpression_h_ +#ifndef LLDB_TARGET_THREADPLANCALLUSEREXPRESSION_H +#define LLDB_TARGET_THREADPLANCALLUSEREXPRESSION_H #include "lldb/Target/Thread.h" #include "lldb/Target/ThreadPlan.h" @@ -56,9 +56,11 @@ private: m_result_var_sp; // If we are left to manage the materialization, // then stuff the result expression variable here. - DISALLOW_COPY_AND_ASSIGN(ThreadPlanCallUserExpression); + ThreadPlanCallUserExpression(const ThreadPlanCallUserExpression &) = delete; + const ThreadPlanCallUserExpression & + operator=(const ThreadPlanCallUserExpression &) = delete; }; } // namespace lldb_private -#endif // liblldb_ThreadPlanCallUserExpression_h_ +#endif // LLDB_TARGET_THREADPLANCALLUSEREXPRESSION_H diff --git a/lldb/include/lldb/Target/ThreadPlanPython.h b/lldb/include/lldb/Target/ThreadPlanPython.h index 0ee559b12960..27bf3a560b1f 100644 --- a/lldb/include/lldb/Target/ThreadPlanPython.h +++ b/lldb/include/lldb/Target/ThreadPlanPython.h @@ -7,8 +7,8 @@ // //===----------------------------------------------------------------------===// -#ifndef liblldb_ThreadPlan_Python_h_ -#define liblldb_ThreadPlan_Python_h_ +#ifndef LLDB_TARGET_THREADPLANPYTHON_H +#define LLDB_TARGET_THREADPLANPYTHON_H #include <string> @@ -55,6 +55,8 @@ protected: bool DoPlanExplainsStop(Event *event_ptr) override; lldb::StateType GetPlanRunState() override; + + ScriptInterpreter *GetScriptInterpreter(); private: std::string m_class_name; @@ -66,9 +68,10 @@ private: StructuredData::ObjectSP m_implementation_sp; bool m_did_push; - DISALLOW_COPY_AND_ASSIGN(ThreadPlanPython); + ThreadPlanPython(const ThreadPlanPython &) = delete; + const ThreadPlanPython &operator=(const ThreadPlanPython &) = delete; }; } // namespace lldb_private -#endif // liblldb_ThreadPlan_Python_h_ +#endif // LLDB_TARGET_THREADPLANPYTHON_H diff --git a/lldb/include/lldb/Target/ThreadPlanRunToAddress.h b/lldb/include/lldb/Target/ThreadPlanRunToAddress.h index d82a9fad548a..10b8ec658cdd 100644 --- a/lldb/include/lldb/Target/ThreadPlanRunToAddress.h +++ b/lldb/include/lldb/Target/ThreadPlanRunToAddress.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef liblldb_ThreadPlanRunToAddress_h_ -#define liblldb_ThreadPlanRunToAddress_h_ +#ifndef LLDB_TARGET_THREADPLANRUNTOADDRESS_H +#define LLDB_TARGET_THREADPLANRUNTOADDRESS_H #include <vector> @@ -59,9 +59,11 @@ private: std::vector<lldb::break_id_t> m_break_ids; // This is the breakpoint we are // using to stop us at m_address. - DISALLOW_COPY_AND_ASSIGN(ThreadPlanRunToAddress); + ThreadPlanRunToAddress(const ThreadPlanRunToAddress &) = delete; + const ThreadPlanRunToAddress & + operator=(const ThreadPlanRunToAddress &) = delete; }; } // namespace lldb_private -#endif // liblldb_ThreadPlanRunToAddress_h_ +#endif // LLDB_TARGET_THREADPLANRUNTOADDRESS_H diff --git a/lldb/include/lldb/Target/ThreadPlanShouldStopHere.h b/lldb/include/lldb/Target/ThreadPlanShouldStopHere.h index dfcbbb355c54..54b30291c399 100644 --- a/lldb/include/lldb/Target/ThreadPlanShouldStopHere.h +++ b/lldb/include/lldb/Target/ThreadPlanShouldStopHere.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef liblldb_ThreadPlanShouldStopHere_h_ -#define liblldb_ThreadPlanShouldStopHere_h_ +#ifndef LLDB_TARGET_THREADPLANSHOULDSTOPHERE_H +#define LLDB_TARGET_THREADPLANSHOULDSTOPHERE_H #include "lldb/Target/ThreadPlan.h" @@ -130,9 +130,11 @@ protected: lldb_private::Flags m_flags; private: - DISALLOW_COPY_AND_ASSIGN(ThreadPlanShouldStopHere); + ThreadPlanShouldStopHere(const ThreadPlanShouldStopHere &) = delete; + const ThreadPlanShouldStopHere & + operator=(const ThreadPlanShouldStopHere &) = delete; }; } // namespace lldb_private -#endif // liblldb_ThreadPlanShouldStopHere_h_ +#endif // LLDB_TARGET_THREADPLANSHOULDSTOPHERE_H diff --git a/lldb/include/lldb/Target/ThreadPlanStack.h b/lldb/include/lldb/Target/ThreadPlanStack.h new file mode 100644 index 000000000000..f1874136cad8 --- /dev/null +++ b/lldb/include/lldb/Target/ThreadPlanStack.h @@ -0,0 +1,173 @@ +//===-- ThreadPlanStack.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_THREADPLANSTACK_H +#define LLDB_TARGET_THREADPLANSTACK_H + +#include <mutex> +#include <string> +#include <unordered_map> +#include <vector> + +#include "lldb/Target/Target.h" +#include "lldb/Target/Thread.h" +#include "lldb/lldb-private-forward.h" +#include "lldb/lldb-private.h" + +namespace lldb_private { + +// The ThreadPlans have a thread for use when they are asked all the ThreadPlan +// state machine questions, but they should never cache any pointers from their +// owning lldb_private::Thread. That's because we want to be able to detach +// them from an owning thread, then reattach them by TID. +// The ThreadPlanStack holds the ThreadPlans for a given TID. All its methods +// are private, and it should only be accessed through the owning thread. When +// it is detached from a thread, all you can do is reattach it or delete it. +class ThreadPlanStack { + friend class lldb_private::Thread; + +public: + ThreadPlanStack(const Thread &thread, bool make_empty = false); + ~ThreadPlanStack() {} + + enum StackKind { ePlans, eCompletedPlans, eDiscardedPlans }; + + using PlanStack = std::vector<lldb::ThreadPlanSP>; + + void DumpThreadPlans(Stream &s, lldb::DescriptionLevel desc_level, + bool include_internal) const; + + size_t CheckpointCompletedPlans(); + + void RestoreCompletedPlanCheckpoint(size_t checkpoint); + + void DiscardCompletedPlanCheckpoint(size_t checkpoint); + + void ThreadDestroyed(Thread *thread); + + void EnableTracer(bool value, bool single_stepping); + + void SetTracer(lldb::ThreadPlanTracerSP &tracer_sp); + + void PushPlan(lldb::ThreadPlanSP new_plan_sp); + + lldb::ThreadPlanSP PopPlan(); + + lldb::ThreadPlanSP DiscardPlan(); + + // If the input plan is nullptr, discard all plans. Otherwise make sure this + // plan is in the stack, and if so discard up to and including it. + void DiscardPlansUpToPlan(ThreadPlan *up_to_plan_ptr); + + void DiscardAllPlans(); + + void DiscardConsultingMasterPlans(); + + lldb::ThreadPlanSP GetCurrentPlan() const; + + lldb::ThreadPlanSP GetCompletedPlan(bool skip_private = true) const; + + lldb::ThreadPlanSP GetPlanByIndex(uint32_t plan_idx, + bool skip_private = true) const; + + lldb::ValueObjectSP GetReturnValueObject() const; + + lldb::ExpressionVariableSP GetExpressionVariable() const; + + bool AnyPlans() const; + + bool AnyCompletedPlans() const; + + bool AnyDiscardedPlans() const; + + bool IsPlanDone(ThreadPlan *plan) const; + + bool WasPlanDiscarded(ThreadPlan *plan) const; + + ThreadPlan *GetPreviousPlan(ThreadPlan *current_plan) const; + + ThreadPlan *GetInnermostExpression() const; + + void WillResume(); + +private: + const PlanStack &GetStackOfKind(ThreadPlanStack::StackKind kind) const; + + void PrintOneStack(Stream &s, llvm::StringRef stack_name, + const PlanStack &stack, lldb::DescriptionLevel desc_level, + bool include_internal) const; + + PlanStack m_plans; ///< The stack of plans this thread is executing. + PlanStack m_completed_plans; ///< Plans that have been completed by this + /// stop. They get deleted when the thread + /// resumes. + PlanStack m_discarded_plans; ///< Plans that have been discarded by this + /// stop. They get deleted when the thread + /// resumes. + size_t m_completed_plan_checkpoint = 0; // Monotonically increasing token for + // completed plan checkpoints. + std::unordered_map<size_t, PlanStack> m_completed_plan_store; +}; + +class ThreadPlanStackMap { +public: + ThreadPlanStackMap(Process &process) : m_process(process) {} + ~ThreadPlanStackMap() {} + + // Prune the map using the current_threads list. + void Update(ThreadList ¤t_threads, bool delete_missing, + bool check_for_new = true); + + void AddThread(Thread &thread) { + lldb::tid_t tid = thread.GetID(); + m_plans_list.emplace(tid, thread); + } + + bool RemoveTID(lldb::tid_t tid) { + auto result = m_plans_list.find(tid); + if (result == m_plans_list.end()) + return false; + result->second.ThreadDestroyed(nullptr); + m_plans_list.erase(result); + return true; + } + + ThreadPlanStack *Find(lldb::tid_t tid) { + auto result = m_plans_list.find(tid); + if (result == m_plans_list.end()) + return nullptr; + else + return &result->second; + } + + void Clear() { + for (auto plan : m_plans_list) + plan.second.ThreadDestroyed(nullptr); + m_plans_list.clear(); + } + + // Implements Process::DumpThreadPlans + void DumpPlans(Stream &strm, lldb::DescriptionLevel desc_level, bool internal, + bool ignore_boring, bool skip_unreported); + + // Implements Process::DumpThreadPlansForTID + bool DumpPlansForTID(Stream &strm, lldb::tid_t tid, + lldb::DescriptionLevel desc_level, bool internal, + bool ignore_boring, bool skip_unreported); + + bool PrunePlansForTID(lldb::tid_t tid); + +private: + Process &m_process; + using PlansList = std::unordered_map<lldb::tid_t, ThreadPlanStack>; + PlansList m_plans_list; +}; + +} // namespace lldb_private + +#endif // LLDB_TARGET_THREADPLANSTACK_H diff --git a/lldb/include/lldb/Target/ThreadPlanStepInRange.h b/lldb/include/lldb/Target/ThreadPlanStepInRange.h index a120c98fb36e..59b5721998b5 100644 --- a/lldb/include/lldb/Target/ThreadPlanStepInRange.h +++ b/lldb/include/lldb/Target/ThreadPlanStepInRange.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef liblldb_ThreadPlanStepInRange_h_ -#define liblldb_ThreadPlanStepInRange_h_ +#ifndef LLDB_TARGET_THREADPLANSTEPINRANGE_H +#define LLDB_TARGET_THREADPLANSTEPINRANGE_H #include "lldb/Core/AddressRange.h" #include "lldb/Target/StackID.h" @@ -49,6 +49,12 @@ public: bool IsVirtualStep() override; + // Plans that are implementing parts of a step in might need to follow the + // behavior of this plan w.r.t. StepThrough. They can get that from here. + static uint32_t GetDefaultFlagsValue() { + return s_default_flag_values; + } + protected: static bool DefaultShouldStopHereCallback(ThreadPlan *current_plan, Flags &flags, @@ -99,9 +105,11 @@ private: bool m_virtual_step; // true if we've just done a "virtual step", i.e. just // moved the inline stack depth. ConstString m_step_into_target; - DISALLOW_COPY_AND_ASSIGN(ThreadPlanStepInRange); + ThreadPlanStepInRange(const ThreadPlanStepInRange &) = delete; + const ThreadPlanStepInRange & + operator=(const ThreadPlanStepInRange &) = delete; }; } // namespace lldb_private -#endif // liblldb_ThreadPlanStepInRange_h_ +#endif // LLDB_TARGET_THREADPLANSTEPINRANGE_H diff --git a/lldb/include/lldb/Target/ThreadPlanStepInstruction.h b/lldb/include/lldb/Target/ThreadPlanStepInstruction.h index 127de417f6eb..760bc4886faa 100644 --- a/lldb/include/lldb/Target/ThreadPlanStepInstruction.h +++ b/lldb/include/lldb/Target/ThreadPlanStepInstruction.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef liblldb_ThreadPlanStepInstruction_h_ -#define liblldb_ThreadPlanStepInstruction_h_ +#ifndef LLDB_TARGET_THREADPLANSTEPINSTRUCTION_H +#define LLDB_TARGET_THREADPLANSTEPINSTRUCTION_H #include "lldb/Target/Thread.h" #include "lldb/Target/ThreadPlan.h" @@ -49,9 +49,11 @@ private: StackID m_stack_id; StackID m_parent_frame_id; - DISALLOW_COPY_AND_ASSIGN(ThreadPlanStepInstruction); + ThreadPlanStepInstruction(const ThreadPlanStepInstruction &) = delete; + const ThreadPlanStepInstruction & + operator=(const ThreadPlanStepInstruction &) = delete; }; } // namespace lldb_private -#endif // liblldb_ThreadPlanStepInstruction_h_ +#endif // LLDB_TARGET_THREADPLANSTEPINSTRUCTION_H diff --git a/lldb/include/lldb/Target/ThreadPlanStepOut.h b/lldb/include/lldb/Target/ThreadPlanStepOut.h index 576b416c3f2c..5c39232fd2e8 100644 --- a/lldb/include/lldb/Target/ThreadPlanStepOut.h +++ b/lldb/include/lldb/Target/ThreadPlanStepOut.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef liblldb_ThreadPlanStepOut_h_ -#define liblldb_ThreadPlanStepOut_h_ +#ifndef LLDB_TARGET_THREADPLANSTEPOUT_H +#define LLDB_TARGET_THREADPLANSTEPOUT_H #include "lldb/Target/Thread.h" #include "lldb/Target/ThreadPlan.h" @@ -85,9 +85,10 @@ private: void CalculateReturnValue(); - DISALLOW_COPY_AND_ASSIGN(ThreadPlanStepOut); + ThreadPlanStepOut(const ThreadPlanStepOut &) = delete; + const ThreadPlanStepOut &operator=(const ThreadPlanStepOut &) = delete; }; } // namespace lldb_private -#endif // liblldb_ThreadPlanStepOut_h_ +#endif // LLDB_TARGET_THREADPLANSTEPOUT_H diff --git a/lldb/include/lldb/Target/ThreadPlanStepOverBreakpoint.h b/lldb/include/lldb/Target/ThreadPlanStepOverBreakpoint.h index 7df7049b568a..86f7798487c3 100644 --- a/lldb/include/lldb/Target/ThreadPlanStepOverBreakpoint.h +++ b/lldb/include/lldb/Target/ThreadPlanStepOverBreakpoint.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef liblldb_ThreadPlanStepOverBreakpoint_h_ -#define liblldb_ThreadPlanStepOverBreakpoint_h_ +#ifndef LLDB_TARGET_THREADPLANSTEPOVERBREAKPOINT_H +#define LLDB_TARGET_THREADPLANSTEPOVERBREAKPOINT_H #include "lldb/Target/Thread.h" #include "lldb/Target/ThreadPlan.h" @@ -47,9 +47,11 @@ private: bool m_auto_continue; bool m_reenabled_breakpoint_site; - DISALLOW_COPY_AND_ASSIGN(ThreadPlanStepOverBreakpoint); + ThreadPlanStepOverBreakpoint(const ThreadPlanStepOverBreakpoint &) = delete; + const ThreadPlanStepOverBreakpoint & + operator=(const ThreadPlanStepOverBreakpoint &) = delete; }; } // namespace lldb_private -#endif // liblldb_ThreadPlanStepOverBreakpoint_h_ +#endif // LLDB_TARGET_THREADPLANSTEPOVERBREAKPOINT_H diff --git a/lldb/include/lldb/Target/ThreadPlanStepOverRange.h b/lldb/include/lldb/Target/ThreadPlanStepOverRange.h index 30763e3861fa..8585ac62f09b 100644 --- a/lldb/include/lldb/Target/ThreadPlanStepOverRange.h +++ b/lldb/include/lldb/Target/ThreadPlanStepOverRange.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef liblldb_ThreadPlanStepOverRange_h_ -#define liblldb_ThreadPlanStepOverRange_h_ +#ifndef LLDB_TARGET_THREADPLANSTEPOVERRANGE_H +#define LLDB_TARGET_THREADPLANSTEPOVERRANGE_H #include "lldb/Core/AddressRange.h" #include "lldb/Target/StackID.h" @@ -45,9 +45,11 @@ private: bool m_first_resume; - DISALLOW_COPY_AND_ASSIGN(ThreadPlanStepOverRange); + ThreadPlanStepOverRange(const ThreadPlanStepOverRange &) = delete; + const ThreadPlanStepOverRange & + operator=(const ThreadPlanStepOverRange &) = delete; }; } // namespace lldb_private -#endif // liblldb_ThreadPlanStepOverRange_h_ +#endif // LLDB_TARGET_THREADPLANSTEPOVERRANGE_H diff --git a/lldb/include/lldb/Target/ThreadPlanStepRange.h b/lldb/include/lldb/Target/ThreadPlanStepRange.h index 28209623a1e1..2fe885277100 100644 --- a/lldb/include/lldb/Target/ThreadPlanStepRange.h +++ b/lldb/include/lldb/Target/ThreadPlanStepRange.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef liblldb_ThreadPlanStepRange_h_ -#define liblldb_ThreadPlanStepRange_h_ +#ifndef LLDB_TARGET_THREADPLANSTEPRANGE_H +#define LLDB_TARGET_THREADPLANSTEPRANGE_H #include "lldb/Core/AddressRange.h" #include "lldb/Target/StackID.h" @@ -86,9 +86,10 @@ protected: private: std::vector<lldb::DisassemblerSP> m_instruction_ranges; - DISALLOW_COPY_AND_ASSIGN(ThreadPlanStepRange); + ThreadPlanStepRange(const ThreadPlanStepRange &) = delete; + const ThreadPlanStepRange &operator=(const ThreadPlanStepRange &) = delete; }; } // namespace lldb_private -#endif // liblldb_ThreadPlanStepRange_h_ +#endif // LLDB_TARGET_THREADPLANSTEPRANGE_H diff --git a/lldb/include/lldb/Target/ThreadPlanStepThrough.h b/lldb/include/lldb/Target/ThreadPlanStepThrough.h index 0d0621227b53..89262258e873 100644 --- a/lldb/include/lldb/Target/ThreadPlanStepThrough.h +++ b/lldb/include/lldb/Target/ThreadPlanStepThrough.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef liblldb_ThreadPlanStepThrough_h_ -#define liblldb_ThreadPlanStepThrough_h_ +#ifndef LLDB_TARGET_THREADPLANSTEPTHROUGH_H +#define LLDB_TARGET_THREADPLANSTEPTHROUGH_H #include "lldb/Target/Thread.h" #include "lldb/Target/ThreadPlan.h" @@ -53,9 +53,11 @@ private: StackID m_return_stack_id; bool m_stop_others; - DISALLOW_COPY_AND_ASSIGN(ThreadPlanStepThrough); + ThreadPlanStepThrough(const ThreadPlanStepThrough &) = delete; + const ThreadPlanStepThrough & + operator=(const ThreadPlanStepThrough &) = delete; }; } // namespace lldb_private -#endif // liblldb_ThreadPlanStepThrough_h_ +#endif // LLDB_TARGET_THREADPLANSTEPTHROUGH_H diff --git a/lldb/include/lldb/Target/ThreadPlanStepUntil.h b/lldb/include/lldb/Target/ThreadPlanStepUntil.h index 9a5934a36d7d..27e1f85e9cb9 100644 --- a/lldb/include/lldb/Target/ThreadPlanStepUntil.h +++ b/lldb/include/lldb/Target/ThreadPlanStepUntil.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef liblldb_ThreadPlanStepUntil_h_ -#define liblldb_ThreadPlanStepUntil_h_ +#ifndef LLDB_TARGET_THREADPLANSTEPUNTIL_H +#define LLDB_TARGET_THREADPLANSTEPUNTIL_H #include "lldb/Target/Thread.h" #include "lldb/Target/ThreadPlan.h" @@ -59,9 +59,10 @@ private: // Need an appropriate marker for the current stack so we can tell step out // from step in. - DISALLOW_COPY_AND_ASSIGN(ThreadPlanStepUntil); + ThreadPlanStepUntil(const ThreadPlanStepUntil &) = delete; + const ThreadPlanStepUntil &operator=(const ThreadPlanStepUntil &) = delete; }; } // namespace lldb_private -#endif // liblldb_ThreadPlanStepUntil_h_ +#endif // LLDB_TARGET_THREADPLANSTEPUNTIL_H diff --git a/lldb/include/lldb/Target/ThreadPlanTracer.h b/lldb/include/lldb/Target/ThreadPlanTracer.h index 80b08078e975..677a2c0dd93c 100644 --- a/lldb/include/lldb/Target/ThreadPlanTracer.h +++ b/lldb/include/lldb/Target/ThreadPlanTracer.h @@ -7,8 +7,8 @@ // //===----------------------------------------------------------------------===// -#ifndef liblldb_ThreadPlanTracer_h_ -#define liblldb_ThreadPlanTracer_h_ +#ifndef LLDB_TARGET_THREADPLANTRACER_H +#define LLDB_TARGET_THREADPLANTRACER_H #include "lldb/Symbol/TaggedASTType.h" #include "lldb/Target/Thread.h" @@ -57,9 +57,12 @@ public: } bool SingleStepEnabled() { return m_single_step; } + + Thread &GetThread(); protected: - Thread &m_thread; + Process &m_process; + lldb::tid_t m_tid; Stream *GetLogStream(); @@ -71,6 +74,7 @@ private: bool m_single_step; bool m_enabled; lldb::StreamSP m_stream_sp; + Thread *m_thread; }; class ThreadPlanAssemblyTracer : public ThreadPlanTracer { @@ -96,4 +100,4 @@ private: } // namespace lldb_private -#endif // liblldb_ThreadPlanTracer_h_ +#endif // LLDB_TARGET_THREADPLANTRACER_H diff --git a/lldb/include/lldb/Target/ThreadSpec.h b/lldb/include/lldb/Target/ThreadSpec.h index 05e7dcdb38d3..8c22d53185ff 100644 --- a/lldb/include/lldb/Target/ThreadSpec.h +++ b/lldb/include/lldb/Target/ThreadSpec.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef liblldb_ThreadSpec_h_ -#define liblldb_ThreadSpec_h_ +#ifndef LLDB_TARGET_THREADSPEC_H +#define LLDB_TARGET_THREADSPEC_H #include "lldb/Utility/StructuredData.h" #include "lldb/lldb-private.h" @@ -46,9 +46,11 @@ public: void SetTID(lldb::tid_t tid) { m_tid = tid; } - void SetName(llvm::StringRef name) { m_name = name; } + void SetName(llvm::StringRef name) { m_name = std::string(name); } - void SetQueueName(llvm::StringRef queue_name) { m_queue_name = queue_name; } + void SetQueueName(llvm::StringRef queue_name) { + m_queue_name = std::string(queue_name); + } uint32_t GetIndex() const { return m_index; } @@ -126,4 +128,4 @@ private: } // namespace lldb_private -#endif // liblldb_ThreadSpec_h_ +#endif // LLDB_TARGET_THREADSPEC_H diff --git a/lldb/include/lldb/Target/UnixSignals.h b/lldb/include/lldb/Target/UnixSignals.h index 120ffdd7ae25..cc24b76e4c3f 100644 --- a/lldb/include/lldb/Target/UnixSignals.h +++ b/lldb/include/lldb/Target/UnixSignals.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef lldb_UnixSignals_h_ -#define lldb_UnixSignals_h_ +#ifndef LLDB_TARGET_UNIXSIGNALS_H +#define LLDB_TARGET_UNIXSIGNALS_H #include <map> #include <string> @@ -126,4 +126,4 @@ protected: }; } // Namespace lldb -#endif // lldb_UnixSignals_h_ +#endif // LLDB_TARGET_UNIXSIGNALS_H diff --git a/lldb/include/lldb/Target/Unwind.h b/lldb/include/lldb/Target/Unwind.h index 652918ddad43..783b7103e8fe 100644 --- a/lldb/include/lldb/Target/Unwind.h +++ b/lldb/include/lldb/Target/Unwind.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef liblldb_Unwind_h_ -#define liblldb_Unwind_h_ +#ifndef LLDB_TARGET_UNWIND_H +#define LLDB_TARGET_UNWIND_H #include <mutex> @@ -77,9 +77,10 @@ protected: std::recursive_mutex m_unwind_mutex; private: - DISALLOW_COPY_AND_ASSIGN(Unwind); + Unwind(const Unwind &) = delete; + const Unwind &operator=(const Unwind &) = delete; }; } // namespace lldb_private -#endif // liblldb_Unwind_h_ +#endif // LLDB_TARGET_UNWIND_H diff --git a/lldb/include/lldb/Target/UnwindAssembly.h b/lldb/include/lldb/Target/UnwindAssembly.h index a70aef6e93c5..abfd38774399 100644 --- a/lldb/include/lldb/Target/UnwindAssembly.h +++ b/lldb/include/lldb/Target/UnwindAssembly.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef utility_UnwindAssembly_h_ -#define utility_UnwindAssembly_h_ +#ifndef LLDB_TARGET_UNWINDASSEMBLY_H +#define LLDB_TARGET_UNWINDASSEMBLY_H #include "lldb/Core/PluginInterface.h" #include "lldb/Utility/ArchSpec.h" @@ -45,9 +45,10 @@ protected: private: UnwindAssembly() = delete; - DISALLOW_COPY_AND_ASSIGN(UnwindAssembly); + UnwindAssembly(const UnwindAssembly &) = delete; + const UnwindAssembly &operator=(const UnwindAssembly &) = delete; }; } // namespace lldb_private -#endif // utility_UnwindAssembly_h_ +#endif // LLDB_TARGET_UNWINDASSEMBLY_H diff --git a/lldb/include/lldb/Target/UnwindLLDB.h b/lldb/include/lldb/Target/UnwindLLDB.h new file mode 100644 index 000000000000..c7c9cfbccbad --- /dev/null +++ b/lldb/include/lldb/Target/UnwindLLDB.h @@ -0,0 +1,159 @@ +//===-- UnwindLLDB.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_UNWINDLLDB_H +#define LLDB_TARGET_UNWINDLLDB_H + +#include <vector> + +#include "lldb/Symbol/FuncUnwinders.h" +#include "lldb/Symbol/SymbolContext.h" +#include "lldb/Symbol/UnwindPlan.h" +#include "lldb/Target/RegisterContext.h" +#include "lldb/Target/Unwind.h" +#include "lldb/Utility/ConstString.h" +#include "lldb/lldb-public.h" + +namespace lldb_private { + +class RegisterContextUnwind; + +class UnwindLLDB : public lldb_private::Unwind { +public: + UnwindLLDB(lldb_private::Thread &thread); + + ~UnwindLLDB() override = default; + + enum RegisterSearchResult { + eRegisterFound = 0, + eRegisterNotFound, + eRegisterIsVolatile + }; + +protected: + friend class lldb_private::RegisterContextUnwind; + + struct RegisterLocation { + enum RegisterLocationTypes { + eRegisterNotSaved = 0, // register was not preserved by callee. If + // volatile reg, is unavailable + eRegisterSavedAtMemoryLocation, // register is saved at a specific word of + // target mem (target_memory_location) + eRegisterInRegister, // register is available in a (possible other) + // register (register_number) + eRegisterSavedAtHostMemoryLocation, // register is saved at a word in + // lldb's address space + eRegisterValueInferred, // register val was computed (and is in + // inferred_value) + eRegisterInLiveRegisterContext // register value is in a live (stack frame + // #0) register + }; + int type; + union { + lldb::addr_t target_memory_location; + uint32_t + register_number; // in eRegisterKindLLDB register numbering system + void *host_memory_location; + uint64_t inferred_value; // eRegisterValueInferred - e.g. stack pointer == + // cfa + offset + } location; + }; + + void DoClear() override { + m_frames.clear(); + m_candidate_frame.reset(); + m_unwind_complete = false; + } + + uint32_t DoGetFrameCount() override; + + bool DoGetFrameInfoAtIndex(uint32_t frame_idx, lldb::addr_t &cfa, + lldb::addr_t &start_pc, + bool &behaves_like_zeroth_frame) override; + + lldb::RegisterContextSP + DoCreateRegisterContextForFrame(lldb_private::StackFrame *frame) override; + + typedef std::shared_ptr<RegisterContextUnwind> RegisterContextLLDBSP; + + // Needed to retrieve the "next" frame (e.g. frame 2 needs to retrieve frame + // 1's RegisterContextUnwind) + // The RegisterContext for frame_num must already exist or this returns an + // empty shared pointer. + RegisterContextLLDBSP GetRegisterContextForFrameNum(uint32_t frame_num); + + // Iterate over the RegisterContextUnwind's in our m_frames vector, look for + // the first one that has a saved location for this reg. + bool SearchForSavedLocationForRegister( + uint32_t lldb_regnum, lldb_private::UnwindLLDB::RegisterLocation ®loc, + uint32_t starting_frame_num, bool pc_register); + + /// Provide the list of user-specified trap handler functions + /// + /// The Platform is one source of trap handler function names; that + /// may be augmented via a setting. The setting needs to be converted + /// into an array of ConstStrings before it can be used - we only want + /// to do that once per thread so it's here in the UnwindLLDB object. + /// + /// \return + /// Vector of ConstStrings of trap handler function names. May be + /// empty. + const std::vector<ConstString> &GetUserSpecifiedTrapHandlerFunctionNames() { + return m_user_supplied_trap_handler_functions; + } + +private: + struct Cursor { + lldb::addr_t start_pc; // The start address of the function/symbol for this + // frame - current pc if unknown + lldb::addr_t cfa; // The canonical frame address for this stack frame + lldb_private::SymbolContext sctx; // A symbol context we'll contribute to & + // provide to the StackFrame creation + RegisterContextLLDBSP + reg_ctx_lldb_sp; // These are all RegisterContextUnwind's + + Cursor() + : start_pc(LLDB_INVALID_ADDRESS), cfa(LLDB_INVALID_ADDRESS), sctx(), + reg_ctx_lldb_sp() {} + + private: + Cursor(const Cursor &) = delete; + const Cursor &operator=(const Cursor &) = delete; + }; + + typedef std::shared_ptr<Cursor> CursorSP; + std::vector<CursorSP> m_frames; + CursorSP m_candidate_frame; + bool m_unwind_complete; // If this is true, we've enumerated all the frames in + // the stack, and m_frames.size() is the + // number of frames, etc. Otherwise we've only gone as far as directly asked, + // and m_frames.size() + // is how far we've currently gone. + + std::vector<ConstString> m_user_supplied_trap_handler_functions; + + // Check if Full UnwindPlan of First frame is valid or not. + // If not then try Fallback UnwindPlan of the frame. If Fallback + // UnwindPlan succeeds then update the Full UnwindPlan with the + // Fallback UnwindPlan. + void UpdateUnwindPlanForFirstFrameIfInvalid(ABI *abi); + + CursorSP GetOneMoreFrame(ABI *abi); + + bool AddOneMoreFrame(ABI *abi); + + bool AddFirstFrame(); + + // For UnwindLLDB only + UnwindLLDB(const UnwindLLDB &) = delete; + const UnwindLLDB &operator=(const UnwindLLDB &) = delete; +}; + +} // namespace lldb_private + +#endif // LLDB_TARGET_UNWINDLLDB_H diff --git a/lldb/include/lldb/Utility/AnsiTerminal.h b/lldb/include/lldb/Utility/AnsiTerminal.h index 21375e3821ca..c391adb2cf89 100644 --- a/lldb/include/lldb/Utility/AnsiTerminal.h +++ b/lldb/include/lldb/Utility/AnsiTerminal.h @@ -1,3 +1,7 @@ +#ifndef LLDB_UTILITY_ANSITERMINAL_H + +#define LLDB_UTILITY_ANSITERMINAL_H + //===---------------------AnsiTerminal.h ------------------------*- C++ -*-===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. @@ -111,7 +115,7 @@ inline std::string FormatAnsiTerminalCodes(llvm::StringRef format, llvm::StringRef left, right; std::tie(left, right) = format.split(tok_hdr); - fmt.append(left); + fmt += left; if (left == format && right.empty()) { // The header was not found. Just exit. @@ -138,3 +142,5 @@ inline std::string FormatAnsiTerminalCodes(llvm::StringRef format, } } } // namespace lldb_private + +#endif diff --git a/lldb/include/lldb/Utility/ArchSpec.h b/lldb/include/lldb/Utility/ArchSpec.h index 15e2fdb10c32..5466e573c1a5 100644 --- a/lldb/include/lldb/Utility/ArchSpec.h +++ b/lldb/include/lldb/Utility/ArchSpec.h @@ -16,6 +16,7 @@ #include "lldb/lldb-private-enumerations.h" #include "llvm/ADT/StringRef.h" #include "llvm/ADT/Triple.h" +#include "llvm/Support/YAMLTraits.h" #include <cstddef> #include <cstdint> #include <string> @@ -188,6 +189,10 @@ public: eCore_arc, // little endian ARC + eCore_avr, + + eCore_wasm32, + kNumCores, kCore_invalid, @@ -537,4 +542,16 @@ bool ParseMachCPUDashSubtypeTriple(llvm::StringRef triple_str, ArchSpec &arch); } // namespace lldb_private -#endif // #ifndef LLDB_UTILITY_ARCHSPEC_H +namespace llvm { +namespace yaml { +template <> struct ScalarTraits<lldb_private::ArchSpec> { + static void output(const lldb_private::ArchSpec &, void *, raw_ostream &); + static StringRef input(StringRef, void *, lldb_private::ArchSpec &); + static QuotingType mustQuote(StringRef S) { return QuotingType::Double; } +}; +} // namespace yaml +} // namespace llvm + +LLVM_YAML_IS_SEQUENCE_VECTOR(lldb_private::ArchSpec) + +#endif // LLDB_UTILITY_ARCHSPEC_H diff --git a/lldb/include/lldb/Utility/Args.h b/lldb/include/lldb/Utility/Args.h index 1308f4038dbd..2cce7d0c697c 100644 --- a/lldb/include/lldb/Utility/Args.h +++ b/lldb/include/lldb/Utility/Args.h @@ -14,6 +14,7 @@ #include "lldb/lldb-types.h" #include "llvm/ADT/ArrayRef.h" #include "llvm/ADT/StringRef.h" +#include "llvm/Support/YAMLTraits.h" #include <string> #include <utility> #include <vector> @@ -34,6 +35,9 @@ public: struct ArgEntry { private: friend class Args; + friend struct llvm::yaml::MappingTraits<Args>; + friend struct llvm::yaml::MappingTraits<Args::ArgEntry>; + std::unique_ptr<char[]> ptr; char quote; @@ -283,6 +287,8 @@ public: char quote_char); private: + friend struct llvm::yaml::MappingTraits<Args>; + std::vector<ArgEntry> m_entries; std::vector<char *> m_argv; }; @@ -373,4 +379,28 @@ private: } // namespace lldb_private +namespace llvm { +namespace yaml { +template <> struct MappingTraits<lldb_private::Args::ArgEntry> { + class NormalizedArgEntry { + public: + NormalizedArgEntry(IO &) {} + NormalizedArgEntry(IO &, lldb_private::Args::ArgEntry &entry) + : value(entry.ref()), quote(entry.quote) {} + lldb_private::Args::ArgEntry denormalize(IO &) { + return lldb_private::Args::ArgEntry(value, quote); + } + StringRef value; + uint8_t quote; + }; + static void mapping(IO &io, lldb_private::Args::ArgEntry &v); +}; +template <> struct MappingTraits<lldb_private::Args> { + static void mapping(IO &io, lldb_private::Args &v); +}; +} // namespace yaml +} // namespace llvm + +LLVM_YAML_IS_SEQUENCE_VECTOR(lldb_private::Args::ArgEntry) + #endif // LLDB_UTILITY_ARGS_H diff --git a/lldb/include/lldb/Utility/Baton.h b/lldb/include/lldb/Utility/Baton.h index c42867489c65..010f8da43868 100644 --- a/lldb/include/lldb/Utility/Baton.h +++ b/lldb/include/lldb/Utility/Baton.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef lldb_Baton_h_ -#define lldb_Baton_h_ +#ifndef LLDB_UTILITY_BATON_H +#define LLDB_UTILITY_BATON_H #include "lldb/lldb-enumerations.h" #include "lldb/lldb-public.h" @@ -76,4 +76,4 @@ protected: } // namespace lldb_private -#endif // lldb_Baton_h_ +#endif // LLDB_UTILITY_BATON_H diff --git a/lldb/include/lldb/Utility/Broadcaster.h b/lldb/include/lldb/Utility/Broadcaster.h index ead597d626d7..03995454ecb0 100644 --- a/lldb/include/lldb/Utility/Broadcaster.h +++ b/lldb/include/lldb/Utility/Broadcaster.h @@ -259,19 +259,6 @@ public: void CheckInWithManager(); /// Broadcast an event which has no associated data. - /// - /// \param[in] event_type - /// The element from the enum defining this broadcaster's events - /// that is being broadcast. - /// - /// \param[in] event_data - /// User event data that will be owned by the lldb::Event that - /// is created internally. - /// - /// \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); } @@ -308,7 +295,7 @@ 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_sp /// The Listener object that wants to monitor the events that /// get broadcast by this object. /// @@ -347,9 +334,6 @@ public: /// \param[in] event_mask /// A bit mask that indicates which events the listener is /// asking to monitor. - /// - /// \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); } @@ -367,7 +351,7 @@ public: /// (assuming \a listener was listening to this object) for other listener /// objects to use. /// - /// \param[in] listener + /// \param[in] listener_sp /// A Listener object that previously called AddListener. /// /// \param[in] event_mask @@ -389,7 +373,7 @@ public: /// 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_sp /// 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. @@ -530,7 +514,8 @@ protected: std::vector<uint32_t> m_hijacking_masks; private: - DISALLOW_COPY_AND_ASSIGN(BroadcasterImpl); + BroadcasterImpl(const BroadcasterImpl &) = delete; + const BroadcasterImpl &operator=(const BroadcasterImpl &) = delete; }; typedef std::shared_ptr<BroadcasterImpl> BroadcasterImplSP; @@ -549,7 +534,8 @@ private: /// The name of this broadcaster object. const ConstString m_broadcaster_name; - DISALLOW_COPY_AND_ASSIGN(Broadcaster); + Broadcaster(const Broadcaster &) = delete; + const Broadcaster &operator=(const Broadcaster &) = delete; }; } // namespace lldb_private diff --git a/lldb/include/lldb/Utility/CompletionRequest.h b/lldb/include/lldb/Utility/CompletionRequest.h index 570f626ac54e..1fbc96944e82 100644 --- a/lldb/include/lldb/Utility/CompletionRequest.h +++ b/lldb/include/lldb/Utility/CompletionRequest.h @@ -17,16 +17,21 @@ namespace lldb_private { enum class CompletionMode { - // The current token has been completed. + /// The current token has been completed. The client should indicate this + /// to the user (usually this is done by adding a trailing space behind the + /// token). + /// Example: "command sub" -> "command subcommand " (note the trailing space). Normal, - // The current token has been partially completed. This means that we found - // a completion, but that the completed token is still incomplete. Examples - // for this are file paths, where we want to complete "/bi" to "/bin/", but - // the file path token is still incomplete after the completion. Clients - // should not indicate to the user that this is a full completion (e.g. by - // not inserting the usual trailing space after a successful completion). + /// The current token has been partially completed. This means that we found + /// a completion, but that the token is still incomplete. Examples + /// for this are file paths, where we want to complete "/bi" to "/bin/", but + /// the file path token is still incomplete after the completion. Clients + /// should not indicate to the user that this is a full completion (e.g. by + /// not inserting the usual trailing space after a successful completion). + /// Example: "file /us" -> "file /usr/" (note the missing trailing space). Partial, - // The full line has been rewritten by the completion. + /// The full line has been rewritten by the completion. + /// Example: "alias name" -> "other_command full_name". RewriteLine, }; @@ -35,7 +40,12 @@ public: /// A single completion and all associated data. class Completion { + /// The actual text that should be completed. The meaning of this text + /// is defined by the CompletionMode. + /// \see m_mode std::string m_completion; + /// The description that should be displayed to the user alongside the + /// completion text. std::string m_descripton; CompletionMode m_mode; @@ -53,9 +63,12 @@ public: }; private: + /// List of found completions. std::vector<Completion> m_results; - /// List of added completions so far. Used to filter out duplicates. + /// A set of the unique keys of all found completions so far. Used to filter + /// out duplicates. + /// \see CompletionResult::Completion::GetUniqueKey llvm::StringSet<> m_added_values; public: @@ -102,7 +115,19 @@ public: CompletionRequest(llvm::StringRef command_line, unsigned raw_cursor_pos, CompletionResult &result); - llvm::StringRef GetRawLine() const { return m_command; } + /// Returns the raw user input used to create this CompletionRequest cut off + /// at the cursor position. The cursor will be at the end of the raw line. + llvm::StringRef GetRawLine() const { + return m_command.substr(0, GetRawCursorPos()); + } + + /// Returns the full raw user input used to create this CompletionRequest. + /// This string is not cut off at the cursor position and will include + /// characters behind the cursor position. + /// + /// You should most likely *not* use this function unless the characters + /// behind the cursor position influence the completion. + llvm::StringRef GetRawLineWithUnusedSuffix() const { return m_command; } unsigned GetRawCursorPos() const { return m_raw_cursor_pos; } @@ -135,8 +160,8 @@ public: /// the suggested completion is stored, so the given string can be free'd /// afterwards. /// - /// \param match The suggested completion. - /// \param completion An optional description of the completion string. The + /// \param completion The suggested completion. + /// \param description An optional description of the completion string. The /// description will be displayed to the user alongside the completion. /// \param mode The CompletionMode for this completion. void AddCompletion(llvm::StringRef completion, @@ -148,7 +173,7 @@ public: /// Adds a possible completion string if the completion would complete the /// current argument. /// - /// \param match The suggested completion. + /// \param completion The suggested completion. /// \param description An optional description of the completion string. The /// description will be displayed to the user alongside the completion. template <CompletionMode M = CompletionMode::Normal> @@ -178,7 +203,7 @@ public: /// The number of completions and descriptions must be identical. /// /// \param completions The list of completions. - /// \param completions The list of descriptions. + /// \param descriptions The list of descriptions. /// /// \see AddCompletion void AddCompletions(const StringList &completions, diff --git a/lldb/include/lldb/Utility/Connection.h b/lldb/include/lldb/Utility/Connection.h index 9e66dee1363b..39e6e40191b0 100644 --- a/lldb/include/lldb/Utility/Connection.h +++ b/lldb/include/lldb/Utility/Connection.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef liblldb_Connection_h_ -#define liblldb_Connection_h_ +#ifndef LLDB_UTILITY_CONNECTION_H +#define LLDB_UTILITY_CONNECTION_H #include "lldb/lldb-defines.h" #include "lldb/lldb-enumerations.h" @@ -125,7 +125,7 @@ public: /// Subclasses must override this function. /// /// \param[in] dst - /// A desination buffer that must be at least \a dst_len bytes + /// A destination buffer that must be at least \a dst_len bytes /// long. /// /// \param[in] dst_len @@ -175,9 +175,10 @@ public: private: // For Connection only - DISALLOW_COPY_AND_ASSIGN(Connection); + Connection(const Connection &) = delete; + const Connection &operator=(const Connection &) = delete; }; } // namespace lldb_private -#endif // liblldb_Connection_h_ +#endif // LLDB_UTILITY_CONNECTION_H diff --git a/lldb/include/lldb/Utility/ConstString.h b/lldb/include/lldb/Utility/ConstString.h index 74750459d16f..1e55b2ebb957 100644 --- a/lldb/include/lldb/Utility/ConstString.h +++ b/lldb/include/lldb/Utility/ConstString.h @@ -6,12 +6,13 @@ // //===----------------------------------------------------------------------===// -#ifndef liblldb_ConstString_h_ -#define liblldb_ConstString_h_ +#ifndef LLDB_UTILITY_CONSTSTRING_H +#define LLDB_UTILITY_CONSTSTRING_H -#include "llvm/ADT/StringRef.h" #include "llvm/ADT/DenseMapInfo.h" +#include "llvm/ADT/StringRef.h" #include "llvm/Support/FormatVariadic.h" +#include "llvm/Support/YAMLTraits.h" #include <stddef.h> @@ -481,6 +482,21 @@ template <> struct DenseMapInfo<lldb_private::ConstString> { } }; /// \} + +namespace yaml { +template <> struct ScalarTraits<lldb_private::ConstString> { + static void output(const lldb_private::ConstString &, void *, raw_ostream &); + static StringRef input(StringRef, void *, lldb_private::ConstString &); + static QuotingType mustQuote(StringRef S) { return QuotingType::Double; } +}; +} // namespace yaml + +inline raw_ostream &operator<<(raw_ostream &os, lldb_private::ConstString s) { + os << s.GetStringRef(); + return os; } +} // namespace llvm + +LLVM_YAML_IS_SEQUENCE_VECTOR(lldb_private::ConstString) -#endif // liblldb_ConstString_h_ +#endif // LLDB_UTILITY_CONSTSTRING_H diff --git a/lldb/include/lldb/Utility/DataBuffer.h b/lldb/include/lldb/Utility/DataBuffer.h index 523569301e84..302b13307958 100644 --- a/lldb/include/lldb/Utility/DataBuffer.h +++ b/lldb/include/lldb/Utility/DataBuffer.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef liblldb_DataBuffer_h_ -#define liblldb_DataBuffer_h_ +#ifndef LLDB_UTILITY_DATABUFFER_H +#define LLDB_UTILITY_DATABUFFER_H #if defined(__cplusplus) #include <stdint.h> @@ -79,7 +79,21 @@ public: } }; +class DataBufferUnowned : public DataBuffer { +public: + DataBufferUnowned(uint8_t *bytes, lldb::offset_t size) + : m_bytes(bytes), m_size(size) {} + + uint8_t *GetBytes() override { return m_bytes; } + const uint8_t *GetBytes() const override { return m_bytes; } + lldb::offset_t GetByteSize() const override { return m_size; } + +private: + uint8_t *m_bytes; + lldb::offset_t m_size; +}; + } // namespace lldb_private #endif /// #if defined(__cplusplus) -#endif /// lldb_DataBuffer_h_ +#endif // LLDB_UTILITY_DATABUFFER_H diff --git a/lldb/include/lldb/Utility/DataBufferHeap.h b/lldb/include/lldb/Utility/DataBufferHeap.h index 2a64694d7f29..ace526bf0a47 100644 --- a/lldb/include/lldb/Utility/DataBufferHeap.h +++ b/lldb/include/lldb/Utility/DataBufferHeap.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef liblldb_DataBufferHeap_h_ -#define liblldb_DataBufferHeap_h_ +#ifndef LLDB_UTILITY_DATABUFFERHEAP_H +#define LLDB_UTILITY_DATABUFFERHEAP_H #include "lldb/Utility/DataBuffer.h" #include "lldb/lldb-types.h" @@ -109,4 +109,4 @@ private: } // namespace lldb_private -#endif // liblldb_DataBufferHeap_h_ +#endif // LLDB_UTILITY_DATABUFFERHEAP_H diff --git a/lldb/include/lldb/Utility/DataBufferLLVM.h b/lldb/include/lldb/Utility/DataBufferLLVM.h index d4c110743068..4dc800c348c5 100644 --- a/lldb/include/lldb/Utility/DataBufferLLVM.h +++ b/lldb/include/lldb/Utility/DataBufferLLVM.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef LLDB_CORE_DATABUFFERLLVM_H -#define LLDB_CORE_DATABUFFERLLVM_H +#ifndef LLDB_UTILITY_DATABUFFERLLVM_H +#define LLDB_UTILITY_DATABUFFERLLVM_H #include "lldb/Utility/DataBuffer.h" #include "lldb/lldb-types.h" diff --git a/lldb/include/lldb/Utility/DataEncoder.h b/lldb/include/lldb/Utility/DataEncoder.h index f4964b250b9d..8edec54c36f5 100644 --- a/lldb/include/lldb/Utility/DataEncoder.h +++ b/lldb/include/lldb/Utility/DataEncoder.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef liblldb_DataEncoder_h_ -#define liblldb_DataEncoder_h_ +#ifndef LLDB_UTILITY_DATAENCODER_H +#define LLDB_UTILITY_DATAENCODER_H #if defined(__cplusplus) @@ -225,7 +225,6 @@ private: /// The total number of bytes of data this object refers to. size_t GetByteSize() const { return m_end - m_start; } -private: /// A pointer to the first byte of data. uint8_t *m_start; @@ -243,10 +242,11 @@ private: /// be shared among multiple instances mutable lldb::DataBufferSP m_data_sp; - DISALLOW_COPY_AND_ASSIGN(DataEncoder); + DataEncoder(const DataEncoder &) = delete; + const DataEncoder &operator=(const DataEncoder &) = delete; }; } // namespace lldb_private #endif // #if defined (__cplusplus) -#endif // #ifndef liblldb_DataEncoder_h_ +#endif // LLDB_UTILITY_DATAENCODER_H diff --git a/lldb/include/lldb/Utility/DataExtractor.h b/lldb/include/lldb/Utility/DataExtractor.h index bf0d1055cf43..0210af5cf6d1 100644 --- a/lldb/include/lldb/Utility/DataExtractor.h +++ b/lldb/include/lldb/Utility/DataExtractor.h @@ -9,12 +9,14 @@ #ifndef LLDB_UTILITY_DATAEXTRACTOR_H #define LLDB_UTILITY_DATAEXTRACTOR_H +#include "lldb/Utility/Endian.h" #include "lldb/lldb-defines.h" #include "lldb/lldb-enumerations.h" #include "lldb/lldb-forward.h" #include "lldb/lldb-types.h" #include "llvm/ADT/ArrayRef.h" #include "llvm/Support/DataExtractor.h" +#include "llvm/Support/SwapByteOrder.h" #include <cassert> #include <stdint.h> @@ -535,13 +537,13 @@ public: 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 + /// Extract an signed integer of size \a size from \a *offset_ptr, then + /// extract and sign-extend the bitfield from this value if \a /// bitfield_bit_size is non-zero. /// - /// Extract a single signed integer value (sign extending if required) and + /// Extract a single signed integer value (sign-extending if required) and /// update the offset pointed to by \a offset_ptr. The size of the extracted - /// integer is specified by the \a byte_size argument. \a byte_size must + /// integer is specified by the \a size argument. \a size must /// have a value greater than or equal to one and less than or equal to /// eight since the return value is 64 bits wide. /// @@ -573,24 +575,6 @@ public: 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 - /// by \a offset_ptr. The size of the extracted pointer comes from the \a - /// m_addr_size member variable and should be set correctly prior to - /// extracting any pointer values. - /// - /// \param[in,out] offset_ptr - /// A pointer to an offset within the data that will be advanced - /// 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 - /// The extracted pointer value as a 64 integer. - uint64_t GetPointer(lldb::offset_t *offset_ptr) const; - /// Get the current byte order value. /// /// \return @@ -997,19 +981,33 @@ public: } protected: + template <typename T> T Get(lldb::offset_t *offset_ptr, T fail_value) const { + constexpr size_t src_size = sizeof(T); + T val = fail_value; + + const T *src = static_cast<const T *>(GetData(offset_ptr, src_size)); + if (!src) + return val; + + memcpy(&val, src, src_size); + if (m_byte_order != endian::InlHostByteOrder()) + llvm::sys::swapByteOrder(val); + + return val; + } + // 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. lldb::ByteOrder m_byte_order; ///< The byte order of the data we are extracting from. - uint32_t m_addr_size; ///< The address size to use when extracting pointers or - /// addresses - mutable lldb::DataBufferSP m_data_sp; ///< The shared pointer to data that can - /// be shared among multiple instances + uint32_t m_addr_size; ///< The address size to use when extracting addresses. + /// The shared pointer to data that can be shared among multiple instances + lldb::DataBufferSP m_data_sp; const uint32_t m_target_byte_size; }; } // namespace lldb_private -#endif // liblldb_DataExtractor_h_ +#endif // LLDB_UTILITY_DATAEXTRACTOR_H diff --git a/lldb/include/lldb/Utility/Endian.h b/lldb/include/lldb/Utility/Endian.h index cead5f8603d2..1d1f8fa333b8 100644 --- a/lldb/include/lldb/Utility/Endian.h +++ b/lldb/include/lldb/Utility/Endian.h @@ -30,4 +30,4 @@ inline lldb::ByteOrder InlHostByteOrder() { } } -#endif // liblldb_host_endian_h_ +#endif // LLDB_UTILITY_ENDIAN_H diff --git a/lldb/include/lldb/Utility/Environment.h b/lldb/include/lldb/Utility/Environment.h index 398b3bae3106..e2af2eb2463d 100644 --- a/lldb/include/lldb/Utility/Environment.h +++ b/lldb/include/lldb/Utility/Environment.h @@ -50,6 +50,7 @@ public: using Base::erase; using Base::find; using Base::insert; + using Base::insert_or_assign; using Base::lookup; using Base::size; using Base::try_emplace; @@ -68,7 +69,8 @@ public: } std::pair<iterator, bool> insert(llvm::StringRef KeyEqValue) { - return insert(KeyEqValue.split('=')); + auto Split = KeyEqValue.split('='); + return insert(std::make_pair(Split.first, std::string(Split.second))); } void insert(const_iterator first, const_iterator last); @@ -92,4 +94,4 @@ template <> struct format_provider<lldb_private::Environment> { }; } // namespace llvm -#endif // #ifndef LLDB_UTILITY_ENVIRONMENT_H +#endif // LLDB_UTILITY_ENVIRONMENT_H diff --git a/lldb/include/lldb/Utility/Event.h b/lldb/include/lldb/Utility/Event.h index dd5d08024cef..06c02629d448 100644 --- a/lldb/include/lldb/Utility/Event.h +++ b/lldb/include/lldb/Utility/Event.h @@ -48,7 +48,8 @@ public: private: virtual void DoOnRemoval(Event *event_ptr) {} - DISALLOW_COPY_AND_ASSIGN(EventData); + EventData(const EventData &) = delete; + const EventData &operator=(const EventData &) = delete; }; // lldb::EventDataBytes @@ -92,7 +93,8 @@ public: private: std::string m_bytes; - DISALLOW_COPY_AND_ASSIGN(EventDataBytes); + EventDataBytes(const EventDataBytes &) = delete; + const EventDataBytes &operator=(const EventDataBytes &) = delete; }; class EventDataReceipt : public EventData { @@ -169,7 +171,9 @@ private: StructuredData::ObjectSP m_object_sp; lldb::StructuredDataPluginSP m_plugin_sp; - DISALLOW_COPY_AND_ASSIGN(EventDataStructuredData); + EventDataStructuredData(const EventDataStructuredData &) = delete; + const EventDataStructuredData & + operator=(const EventDataStructuredData &) = delete; }; // lldb::Event @@ -242,7 +246,8 @@ private: uint32_t m_type; // The bit describing this event lldb::EventDataSP m_data_sp; // User specific data for this event - DISALLOW_COPY_AND_ASSIGN(Event); + Event(const Event &) = delete; + const Event &operator=(const Event &) = delete; Event() = delete; }; diff --git a/lldb/include/lldb/Utility/FileSpec.h b/lldb/include/lldb/Utility/FileSpec.h index 533426671cc6..f7cbeb247100 100644 --- a/lldb/include/lldb/Utility/FileSpec.h +++ b/lldb/include/lldb/Utility/FileSpec.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef liblldb_FileSpec_h_ -#define liblldb_FileSpec_h_ +#ifndef LLDB_UTILITY_FILESPEC_H +#define LLDB_UTILITY_FILESPEC_H #include <functional> #include <string> @@ -18,6 +18,7 @@ #include "llvm/Support/FileSystem.h" #include "llvm/Support/FormatVariadic.h" #include "llvm/Support/Path.h" +#include "llvm/Support/YAMLTraits.h" #include <stddef.h> #include <stdint.h> @@ -397,6 +398,8 @@ public: ConstString GetLastPathComponent() const; protected: + friend struct llvm::yaml::MappingTraits<FileSpec>; + // Convenience method for setting the file without changing the style. void SetFile(llvm::StringRef path); @@ -410,6 +413,8 @@ protected: /// Dump a FileSpec object to a stream Stream &operator<<(Stream &s, const FileSpec &f); +/// Prevent ODR violations with traits for llvm::sys::path::Style. +LLVM_YAML_STRONG_TYPEDEF(FileSpec::Style, FileSpecStyle) } // namespace lldb_private namespace llvm { @@ -436,6 +441,16 @@ template <> struct format_provider<lldb_private::FileSpec> { static void format(const lldb_private::FileSpec &F, llvm::raw_ostream &Stream, StringRef Style); }; + +namespace yaml { +template <> struct ScalarEnumerationTraits<lldb_private::FileSpecStyle> { + static void enumeration(IO &io, lldb_private::FileSpecStyle &style); +}; + +template <> struct MappingTraits<lldb_private::FileSpec> { + static void mapping(IO &io, lldb_private::FileSpec &f); +}; +} // namespace yaml } // namespace llvm -#endif // liblldb_FileSpec_h_ +#endif // LLDB_UTILITY_FILESPEC_H diff --git a/lldb/include/lldb/Utility/Flags.h b/lldb/include/lldb/Utility/Flags.h index 254a5ec443c3..19f750639e94 100644 --- a/lldb/include/lldb/Utility/Flags.h +++ b/lldb/include/lldb/Utility/Flags.h @@ -29,7 +29,7 @@ public: /// Constructs this object with \a mask as the initial value for all of the /// flags. /// - /// \param[in] mask + /// \param[in] flags /// The initial value for all flags. Flags(ValueType flags = 0) : m_flags(flags) {} @@ -116,4 +116,4 @@ protected: } // namespace lldb_private -#endif // liblldb_Flags_h_ +#endif // LLDB_UTILITY_FLAGS_H diff --git a/lldb/include/lldb/Utility/GDBRemote.h b/lldb/include/lldb/Utility/GDBRemote.h index 21b2c8cd73cd..f5749b7e6eaf 100644 --- a/lldb/include/lldb/Utility/GDBRemote.h +++ b/lldb/include/lldb/Utility/GDBRemote.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef liblldb_GDBRemote_h_ -#define liblldb_GDBRemote_h_ +#ifndef LLDB_UTILITY_GDBREMOTE_H +#define LLDB_UTILITY_GDBREMOTE_H #include "lldb/Utility/FileSpec.h" #include "lldb/Utility/Reproducer.h" @@ -155,4 +155,4 @@ template <> struct MappingTraits<lldb_private::GDBRemotePacket> { } // namespace yaml } // namespace llvm -#endif // liblldb_GDBRemote_h_ +#endif // LLDB_UTILITY_GDBREMOTE_H diff --git a/lldb/include/lldb/Utility/IOObject.h b/lldb/include/lldb/Utility/IOObject.h index 16ed580abf71..9b2b9cfcfec0 100644 --- a/lldb/include/lldb/Utility/IOObject.h +++ b/lldb/include/lldb/Utility/IOObject.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef liblldb_Host_Common_IOObject_h_ -#define liblldb_Host_Common_IOObject_h_ +#ifndef LLDB_UTILITY_IOOBJECT_H +#define LLDB_UTILITY_IOOBJECT_H #include <stdarg.h> #include <stdio.h> @@ -45,7 +45,8 @@ protected: FDType m_fd_type; private: - DISALLOW_COPY_AND_ASSIGN(IOObject); + IOObject(const IOObject &) = delete; + const IOObject &operator=(const IOObject &) = delete; }; } // namespace lldb_private diff --git a/lldb/include/lldb/Utility/Iterable.h b/lldb/include/lldb/Utility/Iterable.h index d9c61aa958cc..3f9b8b1e4c57 100644 --- a/lldb/include/lldb/Utility/Iterable.h +++ b/lldb/include/lldb/Utility/Iterable.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef liblldb_Iterable_h_ -#define liblldb_Iterable_h_ +#ifndef LLDB_UTILITY_ITERABLE_H +#define LLDB_UTILITY_ITERABLE_H #include <utility> @@ -194,4 +194,4 @@ private: } // namespace lldb_private -#endif // liblldb_Iterable_h_ +#endif // LLDB_UTILITY_ITERABLE_H diff --git a/lldb/include/lldb/Utility/LLDBAssert.h b/lldb/include/lldb/Utility/LLDBAssert.h index 7008dd82496d..845af1d4cc2a 100644 --- a/lldb/include/lldb/Utility/LLDBAssert.h +++ b/lldb/include/lldb/Utility/LLDBAssert.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef utility_LLDBAssert_h_ -#define utility_LLDBAssert_h_ +#ifndef LLDB_UTILITY_LLDBASSERT_H +#define LLDB_UTILITY_LLDBASSERT_H #ifdef LLDB_CONFIGURATION_DEBUG #define lldbassert(x) assert(x) @@ -22,4 +22,4 @@ void lldb_assert(bool expression, const char *expr_text, const char *func, const char *file, unsigned int line); } -#endif // utility_LLDBAssert_h_ +#endif // LLDB_UTILITY_LLDBASSERT_H diff --git a/lldb/include/lldb/Utility/Listener.h b/lldb/include/lldb/Utility/Listener.h index 17fc47880e8f..9d96e36c5abc 100644 --- a/lldb/include/lldb/Utility/Listener.h +++ b/lldb/include/lldb/Utility/Listener.h @@ -145,7 +145,8 @@ private: // bool exact); // For Listener only - DISALLOW_COPY_AND_ASSIGN(Listener); + Listener(const Listener &) = delete; + const Listener &operator=(const Listener &) = delete; }; } // namespace lldb_private diff --git a/lldb/include/lldb/Utility/Predicate.h b/lldb/include/lldb/Utility/Predicate.h index cbccc3e91a8b..a17ac05f6e56 100644 --- a/lldb/include/lldb/Utility/Predicate.h +++ b/lldb/include/lldb/Utility/Predicate.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef liblldb_Predicate_h_ -#define liblldb_Predicate_h_ +#ifndef LLDB_UTILITY_PREDICATE_H +#define LLDB_UTILITY_PREDICATE_H #include <stdint.h> #include <time.h> @@ -221,9 +221,10 @@ private: m_condition.notify_all(); } - DISALLOW_COPY_AND_ASSIGN(Predicate); + Predicate(const Predicate &) = delete; + const Predicate &operator=(const Predicate &) = delete; }; } // namespace lldb_private -#endif // liblldb_Predicate_h_ +#endif // LLDB_UTILITY_PREDICATE_H diff --git a/lldb/include/lldb/Utility/ProcessInfo.h b/lldb/include/lldb/Utility/ProcessInfo.h index 9188bf3b7090..ec91060cda54 100644 --- a/lldb/include/lldb/Utility/ProcessInfo.h +++ b/lldb/include/lldb/Utility/ProcessInfo.h @@ -9,13 +9,13 @@ #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 "lldb/Utility/Reproducer.h" +#include "llvm/Support/YAMLTraits.h" #include <vector> namespace lldb_private { @@ -89,6 +89,7 @@ public: const Environment &GetEnvironment() const { return m_environment; } protected: + template <class T> friend struct llvm::yaml::MappingTraits; 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 @@ -150,46 +151,13 @@ public: bool verbose) const; protected: + friend struct llvm::yaml::MappingTraits<ProcessInstanceInfo>; 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); } - - llvm::StringRef GetProcessNameAtIndex(size_t idx) { - return ((idx < m_infos.size()) ? m_infos[idx].GetNameAsStringRef() : ""); - } - - 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; -}; +typedef std::vector<ProcessInstanceInfo> ProcessInstanceInfoList; // ProcessInstanceInfoMatch // @@ -248,6 +216,52 @@ protected: bool m_match_all_users; }; +namespace repro { +class ProcessInfoRecorder : public AbstractRecorder { +public: + ProcessInfoRecorder(const FileSpec &filename, std::error_code &ec) + : AbstractRecorder(filename, ec) {} + + static llvm::Expected<std::unique_ptr<ProcessInfoRecorder>> + Create(const FileSpec &filename); + + void Record(const ProcessInstanceInfoList &process_infos); +}; + +class ProcessInfoProvider : public repro::Provider<ProcessInfoProvider> { +public: + struct Info { + static const char *name; + static const char *file; + }; + + ProcessInfoProvider(const FileSpec &directory) : Provider(directory) {} + + ProcessInfoRecorder *GetNewProcessInfoRecorder(); + + void Keep() override; + void Discard() override; + + static char ID; + +private: + std::unique_ptr<llvm::raw_fd_ostream> m_stream_up; + std::vector<std::unique_ptr<ProcessInfoRecorder>> m_process_info_recorders; +}; + +llvm::Optional<ProcessInstanceInfoList> GetReplayProcessInstanceInfoList(); + +} // namespace repro } // namespace lldb_private -#endif // #ifndef LLDB_UTILITY_PROCESSINFO_H +LLVM_YAML_IS_SEQUENCE_VECTOR(lldb_private::ProcessInstanceInfo) + +namespace llvm { +namespace yaml { +template <> struct MappingTraits<lldb_private::ProcessInstanceInfo> { + static void mapping(IO &io, lldb_private::ProcessInstanceInfo &PII); +}; +} // namespace yaml +} // namespace llvm + +#endif // LLDB_UTILITY_PROCESSINFO_H diff --git a/lldb/include/lldb/Utility/RangeMap.h b/lldb/include/lldb/Utility/RangeMap.h index 9e0307351836..fb24c5a43479 100644 --- a/lldb/include/lldb/Utility/RangeMap.h +++ b/lldb/include/lldb/Utility/RangeMap.h @@ -122,220 +122,13 @@ 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 { +template <typename B, typename S, unsigned N = 0> class RangeVector { public: typedef B BaseType; typedef S SizeType; typedef Range<B, S> Entry; typedef llvm::SmallVector<Entry, N> Collection; - RangeArray() = default; - - ~RangeArray() = default; - - void Append(const Entry &entry) { m_entries.push_back(entry); } - - void Append(B base, S size) { m_entries.emplace_back(base, size); } - - bool RemoveEntrtAtIndex(uint32_t idx) { - if (idx < m_entries.size()) { - m_entries.erase(m_entries.begin() + idx); - return true; - } - return false; - } - - void Sort() { - if (m_entries.size() > 1) - std::stable_sort(m_entries.begin(), m_entries.end()); - } - -#ifdef ASSERT_RANGEMAP_ARE_SORTED - bool IsSorted() const { - typename Collection::const_iterator pos, end, prev; - for (pos = m_entries.begin(), end = m_entries.end(), prev = end; pos != end; - prev = pos++) { - if (prev != end && *pos < *prev) - return false; - } - return true; - } -#endif - - void CombineConsecutiveRanges() { -#ifdef ASSERT_RANGEMAP_ARE_SORTED - assert(IsSorted()); -#endif - // Can't combine if ranges if we have zero or one range - if (m_entries.size() > 1) { - // The list should be sorted prior to calling this function - typename Collection::iterator pos; - typename Collection::iterator end; - typename Collection::iterator prev; - bool can_combine = false; - // First we determine if we can combine any of the Entry objects so we - // don't end up allocating and making a new collection for no reason - for (pos = m_entries.begin(), end = m_entries.end(), prev = end; - pos != end; prev = pos++) { - if (prev != end && prev->DoesAdjoinOrIntersect(*pos)) { - can_combine = true; - break; - } - } - - // We we can combine at least one entry, then we make a new collection - // and populate it accordingly, and then swap it into place. - if (can_combine) { - Collection minimal_ranges; - for (pos = m_entries.begin(), end = m_entries.end(), prev = end; - pos != end; prev = pos++) { - if (prev != end && prev->DoesAdjoinOrIntersect(*pos)) - minimal_ranges.back().SetRangeEnd( - std::max<BaseType>(prev->GetRangeEnd(), pos->GetRangeEnd())); - else - minimal_ranges.push_back(*pos); - } - // Use the swap technique in case our new vector is much smaller. We - // must swap when using the STL because std::vector objects never - // release or reduce the memory once it has been allocated/reserved. - m_entries.swap(minimal_ranges); - } - } - } - - BaseType GetMinRangeBase(BaseType fail_value) const { -#ifdef ASSERT_RANGEMAP_ARE_SORTED - assert(IsSorted()); -#endif - if (m_entries.empty()) - return fail_value; - // m_entries must be sorted, so if we aren't empty, we grab the first - // range's base - return m_entries.front().GetRangeBase(); - } - - BaseType GetMaxRangeEnd(BaseType fail_value) const { -#ifdef ASSERT_RANGEMAP_ARE_SORTED - assert(IsSorted()); -#endif - if (m_entries.empty()) - return fail_value; - // m_entries must be sorted, so if we aren't empty, we grab the last - // range's end - return m_entries.back().GetRangeEnd(); - } - - void Slide(BaseType slide) { - typename Collection::iterator pos, end; - for (pos = m_entries.begin(), end = m_entries.end(); pos != end; ++pos) - pos->Slide(slide); - } - - void Clear() { m_entries.clear(); } - - bool IsEmpty() const { return m_entries.empty(); } - - size_t GetSize() const { return m_entries.size(); } - - const Entry *GetEntryAtIndex(size_t i) const { - return ((i < m_entries.size()) ? &m_entries[i] : nullptr); - } - - // Clients must ensure that "i" is a valid index prior to calling this - // function - const Entry &GetEntryRef(size_t i) const { return m_entries[i]; } - - Entry *Back() { return (m_entries.empty() ? nullptr : &m_entries.back()); } - - const Entry *Back() const { - return (m_entries.empty() ? nullptr : &m_entries.back()); - } - - static bool BaseLessThan(const Entry &lhs, const Entry &rhs) { - return lhs.GetRangeBase() < rhs.GetRangeBase(); - } - - uint32_t FindEntryIndexThatContains(B addr) const { -#ifdef ASSERT_RANGEMAP_ARE_SORTED - assert(IsSorted()); -#endif - if (!m_entries.empty()) { - Entry entry(addr, 1); - typename Collection::const_iterator begin = m_entries.begin(); - typename Collection::const_iterator end = m_entries.end(); - typename Collection::const_iterator pos = - std::lower_bound(begin, end, entry, BaseLessThan); - - if (pos != end && pos->Contains(addr)) { - return std::distance(begin, pos); - } else if (pos != begin) { - --pos; - if (pos->Contains(addr)) - return std::distance(begin, pos); - } - } - return UINT32_MAX; - } - - const Entry *FindEntryThatContains(B addr) const { -#ifdef ASSERT_RANGEMAP_ARE_SORTED - assert(IsSorted()); -#endif - if (!m_entries.empty()) { - Entry entry(addr, 1); - typename Collection::const_iterator begin = m_entries.begin(); - typename Collection::const_iterator end = m_entries.end(); - typename Collection::const_iterator pos = - std::lower_bound(begin, end, entry, BaseLessThan); - - if (pos != end && pos->Contains(addr)) { - return &(*pos); - } else if (pos != begin) { - --pos; - if (pos->Contains(addr)) { - return &(*pos); - } - } - } - return nullptr; - } - - const Entry *FindEntryThatContains(const Entry &range) const { -#ifdef ASSERT_RANGEMAP_ARE_SORTED - assert(IsSorted()); -#endif - if (!m_entries.empty()) { - typename Collection::const_iterator begin = m_entries.begin(); - typename Collection::const_iterator end = m_entries.end(); - typename Collection::const_iterator pos = - std::lower_bound(begin, end, range, BaseLessThan); - - if (pos != end && pos->Contains(range)) { - return &(*pos); - } else if (pos != begin) { - --pos; - if (pos->Contains(range)) { - return &(*pos); - } - } - } - return nullptr; - } - -protected: - Collection m_entries; -}; - -template <typename B, typename S> class RangeVector { -public: - typedef B BaseType; - typedef S SizeType; - typedef Range<B, S> Entry; - typedef std::vector<Entry> Collection; - RangeVector() = default; ~RangeVector() = default; @@ -601,19 +394,31 @@ struct RangeData : public Range<B, S> { RangeData(B base, S size, DataType d) : Range<B, S>(base, size), data(d) {} }; +// We can treat the vector as a flattened Binary Search Tree, augmenting it +// with upper bounds (max of range endpoints) for every index allows us to +// query for range containment quicker. +template <typename B, typename S, typename T> +struct AugmentedRangeData : public RangeData<B, S, T> { + B upper_bound; + + AugmentedRangeData(const RangeData<B, S, T> &rd) + : RangeData<B, S, T>(rd), upper_bound() {} +}; + template <typename B, typename S, typename T, unsigned N = 0, class Compare = std::less<T>> class RangeDataVector { public: typedef lldb_private::Range<B, S> Range; typedef RangeData<B, S, T> Entry; - typedef llvm::SmallVector<Entry, N> Collection; + typedef AugmentedRangeData<B, S, T> AugmentedEntry; + typedef llvm::SmallVector<AugmentedEntry, N> Collection; RangeDataVector(Compare compare = Compare()) : m_compare(compare) {} ~RangeDataVector() = default; - void Append(const Entry &entry) { m_entries.push_back(entry); } + void Append(const Entry &entry) { m_entries.emplace_back(entry); } void Sort() { if (m_entries.size() > 1) @@ -625,13 +430,13 @@ public: return a.size < b.size; return compare(a.data, b.data); }); + if (!m_entries.empty()) + ComputeUpperBounds(0, m_entries.size()); } #ifdef ASSERT_RANGEMAP_ARE_SORTED bool IsSorted() const { typename Collection::const_iterator pos, end, prev; - // First we determine if we can combine any of the Entry objects so we - // don't end up allocating and making a new collection for no reason for (pos = m_entries.begin(), end = m_entries.end(), prev = end; pos != end; prev = pos++) { if (prev != end && *pos < *prev) @@ -701,26 +506,20 @@ public: } uint32_t FindEntryIndexThatContains(B addr) const { - const Entry *entry = FindEntryThatContains(addr); + const AugmentedEntry *entry = + static_cast<const AugmentedEntry *>(FindEntryThatContains(addr)); if (entry) return std::distance(m_entries.begin(), entry); return UINT32_MAX; } - uint32_t FindEntryIndexesThatContain(B addr, - std::vector<uint32_t> &indexes) const { + uint32_t FindEntryIndexesThatContain(B addr, std::vector<uint32_t> &indexes) { #ifdef ASSERT_RANGEMAP_ARE_SORTED assert(IsSorted()); #endif - // Search the entries until the first entry that has a larger base address - // than `addr`. As m_entries is sorted by their base address, all following - // entries can't contain `addr` as their base address is already larger. - for (const auto &entry : m_entries) { - if (entry.Contains(addr)) - indexes.push_back(entry.data); - else if (entry.GetRangeBase() > addr) - break; - } + if (!m_entries.empty()) + FindEntryIndexesThatContain(addr, 0, m_entries.size(), indexes); + return indexes.size(); } @@ -806,6 +605,54 @@ public: protected: Collection m_entries; Compare m_compare; + +private: + // Compute extra information needed for search + B ComputeUpperBounds(size_t lo, size_t hi) { + size_t mid = (lo + hi) / 2; + AugmentedEntry &entry = m_entries[mid]; + + entry.upper_bound = entry.base + entry.size; + + if (lo < mid) + entry.upper_bound = + std::max(entry.upper_bound, ComputeUpperBounds(lo, mid)); + + if (mid + 1 < hi) + entry.upper_bound = + std::max(entry.upper_bound, ComputeUpperBounds(mid + 1, hi)); + + return entry.upper_bound; + } + + // This is based on the augmented tree implementation found at + // https://en.wikipedia.org/wiki/Interval_tree#Augmented_tree + void FindEntryIndexesThatContain(B addr, size_t lo, size_t hi, + std::vector<uint32_t> &indexes) { + size_t mid = (lo + hi) / 2; + const AugmentedEntry &entry = m_entries[mid]; + + // addr is greater than the rightmost point of any interval below mid + // so there are cannot be any matches. + if (addr > entry.upper_bound) + return; + + // Recursively search left subtree + if (lo < mid) + FindEntryIndexesThatContain(addr, lo, mid, indexes); + + // If addr is smaller than the start of the current interval it + // cannot contain it nor can any of its right subtree. + if (addr < entry.base) + return; + + if (entry.Contains(addr)) + indexes.push_back(entry.data); + + // Recursively search right subtree + if (mid + 1 < hi) + FindEntryIndexesThatContain(addr, mid + 1, hi, indexes); + } }; // A simple range with data class where you get to define the type of diff --git a/lldb/include/lldb/Utility/RegisterValue.h b/lldb/include/lldb/Utility/RegisterValue.h index eeb3ce52a82b..c9f295a8d95a 100644 --- a/lldb/include/lldb/Utility/RegisterValue.h +++ b/lldb/include/lldb/Utility/RegisterValue.h @@ -26,7 +26,8 @@ struct RegisterInfo; class RegisterValue { public: - enum { kMaxRegisterByteSize = 64u }; + // big enough to support up to 256 byte AArch64 SVE + enum { kMaxRegisterByteSize = 256u }; enum Type { eTypeInvalid, @@ -259,9 +260,10 @@ protected: Scalar m_scalar; struct { - uint8_t bytes[kMaxRegisterByteSize]; // This must be big enough to hold any - // register for any supported target. - uint8_t length; + mutable uint8_t + bytes[kMaxRegisterByteSize]; // This must be big enough to hold any + // register for any supported target. + uint16_t length; lldb::ByteOrder byte_order; } buffer; }; diff --git a/lldb/include/lldb/Utility/RegularExpression.h b/lldb/include/lldb/Utility/RegularExpression.h index 6acc203d8e7c..415f1b58b111 100644 --- a/lldb/include/lldb/Utility/RegularExpression.h +++ b/lldb/include/lldb/Utility/RegularExpression.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef liblldb_RegularExpression_h_ -#define liblldb_RegularExpression_h_ +#ifndef LLDB_UTILITY_REGULAREXPRESSION_H +#define LLDB_UTILITY_REGULAREXPRESSION_H #include "llvm/ADT/StringRef.h" #include "llvm/Support/Error.h" @@ -91,4 +91,4 @@ private: } // namespace lldb_private -#endif // liblldb_RegularExpression_h_ +#endif // LLDB_UTILITY_REGULAREXPRESSION_H diff --git a/lldb/include/lldb/Utility/Reproducer.h b/lldb/include/lldb/Utility/Reproducer.h index 0d23fe8571ff..ab673e5e0019 100644 --- a/lldb/include/lldb/Utility/Reproducer.h +++ b/lldb/include/lldb/Utility/Reproducer.h @@ -27,6 +27,7 @@ class Reproducer; enum class ReproducerMode { Capture, Replay, + PassiveReplay, Off, }; @@ -98,6 +99,8 @@ public: return m_collector; } + void recordInterestingDirectory(const llvm::Twine &dir); + void Keep() override { auto mapping = GetRoot().CopyByAppendingPathComponent(Info::file); // Temporary files that are removed during execution can cause copy errors. @@ -132,7 +135,7 @@ public: static char ID; }; -/// Provider for the LLDB current working directroy. +/// Provider for the LLDB current working directory. /// /// When the reproducer is kept, it writes lldb's current working directory to /// a file named cwd.txt in the reproducer root. @@ -142,8 +145,11 @@ public: llvm::SmallString<128> cwd; if (std::error_code EC = llvm::sys::fs::current_path(cwd)) return; - m_cwd = cwd.str(); + m_cwd = std::string(cwd.str()); } + + void Update(llvm::StringRef path) { m_cwd = std::string(path); } + struct Info { static const char *name; static const char *file; @@ -153,6 +159,9 @@ public: static char ID; }; +/// The recorder is a small object handed out by a provider to record data. It +/// is commonly used in combination with a MultiProvider which is meant to +/// record information for multiple instances of the same source of data. class AbstractRecorder { protected: AbstractRecorder(const FileSpec &filename, std::error_code &ec) @@ -175,6 +184,7 @@ protected: bool m_record; }; +/// Recorder that records its data as text to a file. class DataRecorder : public AbstractRecorder { public: DataRecorder(const FileSpec &filename, std::error_code &ec) @@ -193,24 +203,88 @@ public: } }; -class CommandProvider : public Provider<CommandProvider> { +/// Recorder that records its data as YAML to a file. +class YamlRecorder : public AbstractRecorder { +public: + YamlRecorder(const FileSpec &filename, std::error_code &ec) + : AbstractRecorder(filename, ec) {} + + static llvm::Expected<std::unique_ptr<YamlRecorder>> + Create(const FileSpec &filename); + + template <typename T> void Record(const T &t) { + if (!m_record) + return; + llvm::yaml::Output yout(m_os); + // The YAML traits are defined as non-const because they are used for + // serialization and deserialization. The cast is safe because + // serialization doesn't modify the object. + yout << const_cast<T &>(t); + m_os.flush(); + } +}; + +/// The MultiProvider is a provider that hands out recorder which can be used +/// to capture data for different instances of the same object. The recorders +/// can be passed around or stored as an instance member. +/// +/// The Info::file for the MultiProvider contains an index of files for every +/// recorder. Use the MultiLoader to read the index and get the individual +/// files. +template <typename T, typename V> +class MultiProvider : public repro::Provider<V> { +public: + MultiProvider(const FileSpec &directory) : Provider<V>(directory) {} + + T *GetNewRecorder() { + std::size_t i = m_recorders.size() + 1; + std::string filename = (llvm::Twine(V::Info::name) + llvm::Twine("-") + + llvm::Twine(i) + llvm::Twine(".yaml")) + .str(); + auto recorder_or_error = + T::Create(this->GetRoot().CopyByAppendingPathComponent(filename)); + if (!recorder_or_error) { + llvm::consumeError(recorder_or_error.takeError()); + return nullptr; + } + + m_recorders.push_back(std::move(*recorder_or_error)); + return m_recorders.back().get(); + } + + void Keep() override { + std::vector<std::string> files; + for (auto &recorder : m_recorders) { + recorder->Stop(); + files.push_back(recorder->GetFilename().GetPath()); + } + + FileSpec file = this->GetRoot().CopyByAppendingPathComponent(V::Info::file); + std::error_code ec; + llvm::raw_fd_ostream os(file.GetPath(), ec, llvm::sys::fs::OF_Text); + if (ec) + return; + llvm::yaml::Output yout(os); + yout << files; + } + + void Discard() override { m_recorders.clear(); } + +private: + std::vector<std::unique_ptr<T>> m_recorders; +}; + +class CommandProvider : public MultiProvider<DataRecorder, 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; + CommandProvider(const FileSpec &directory) + : MultiProvider<DataRecorder, CommandProvider>(directory) {} static char ID; - -private: - std::vector<std::unique_ptr<DataRecorder>> m_data_recorders; }; /// The generator is responsible for the logic needed to generate a @@ -231,6 +305,12 @@ public: /// might need to clean up files already written to disk. void Discard(); + /// Enable or disable auto generate. + void SetAutoGenerate(bool b); + + /// Return whether auto generate is enabled. + bool IsAutoGenerate() const; + /// Create and register a new provider. template <typename T> T *Create() { std::unique_ptr<ProviderBase> provider = std::make_unique<T>(m_root); @@ -272,11 +352,14 @@ private: /// Flag to ensure that we never call both keep and discard. bool m_done = false; + + /// Flag to auto generate a reproducer when it would otherwise be discarded. + bool m_auto_generate = false; }; class Loader final { public: - Loader(FileSpec root); + Loader(FileSpec root, bool passive = false); template <typename T> FileSpec GetFile() { if (!HasFile(T::file)) @@ -298,12 +381,15 @@ public: const FileSpec &GetRoot() const { return m_root; } + bool IsPassiveReplay() const { return m_passive_replay; } + private: bool HasFile(llvm::StringRef file); FileSpec m_root; std::vector<std::string> m_files; bool m_loaded; + bool m_passive_replay; }; /// The reproducer enables clients to obtain access to the Generator and @@ -331,7 +417,7 @@ public: protected: llvm::Error SetCapture(llvm::Optional<FileSpec> root); - llvm::Error SetReplay(llvm::Optional<FileSpec> root); + llvm::Error SetReplay(llvm::Optional<FileSpec> root, bool passive = false); private: static llvm::Optional<Reproducer> &InstanceImpl(); @@ -342,6 +428,8 @@ private: mutable std::mutex m_mutex; }; +/// Loader for data captured with the MultiProvider. It will read the index and +/// return the path to the files in the index. template <typename T> class MultiLoader { public: MultiLoader(std::vector<std::string> files) : m_files(files) {} diff --git a/lldb/include/lldb/Utility/ReproducerInstrumentation.h b/lldb/include/lldb/Utility/ReproducerInstrumentation.h index 75d66045758f..5fc33ad1a17b 100644 --- a/lldb/include/lldb/Utility/ReproducerInstrumentation.h +++ b/lldb/include/lldb/Utility/ReproducerInstrumentation.h @@ -5,8 +5,8 @@ // //===----------------------------------------------------------------------===// -#ifndef LLDB_UTILITY_REPRODUCER_INSTRUMENTATION_H -#define LLDB_UTILITY_REPRODUCER_INSTRUMENTATION_H +#ifndef LLDB_UTILITY_REPRODUCERINSTRUMENTATION_H +#define LLDB_UTILITY_REPRODUCERINSTRUMENTATION_H #include "lldb/Utility/FileSpec.h" #include "lldb/Utility/Log.h" @@ -16,7 +16,6 @@ #include "llvm/ADT/StringRef.h" #include "llvm/Support/ErrorHandling.h" -#include <iostream> #include <map> #include <type_traits> @@ -33,6 +32,11 @@ inline void stringify_append(llvm::raw_string_ostream &ss, const T &t) { } template <typename T> +inline void stringify_append(llvm::raw_string_ostream &ss, T *t) { + ss << reinterpret_cast<void *>(t); +} + +template <typename T> inline void stringify_append(llvm::raw_string_ostream &ss, const T *t) { ss << reinterpret_cast<const void *>(t); } @@ -43,6 +47,12 @@ inline void stringify_append<char>(llvm::raw_string_ostream &ss, ss << '\"' << t << '\"'; } +template <> +inline void stringify_append<std::nullptr_t>(llvm::raw_string_ostream &ss, + const std::nullptr_t &t) { + ss << "\"nullptr\""; +} + template <typename Head> inline void stringify_helper(llvm::raw_string_ostream &ss, const Head &head) { stringify_append(ss, head); @@ -69,120 +79,146 @@ template <typename... Ts> inline std::string stringify_args(const Ts &... ts) { // #define LLDB_REPRO_INSTR_TRACE #define LLDB_REGISTER_CONSTRUCTOR(Class, Signature) \ - R.Register<Class * Signature>(&construct<Class Signature>::doit, "", #Class, \ - #Class, #Signature) + R.Register<Class * Signature>(&construct<Class Signature>::record, "", \ + #Class, #Class, #Signature) + #define LLDB_REGISTER_METHOD(Result, Class, Method, Signature) \ R.Register( \ - &invoke<Result(Class::*) Signature>::method<(&Class::Method)>::doit, \ + &invoke<Result(Class::*) Signature>::method<(&Class::Method)>::record, \ #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, \ + R.Register(&invoke<Result(Class::*) \ + Signature const>::method<(&Class::Method)>::record, \ #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) + R.Register(&invoke<Result(*) Signature>::method<(&Class::Method)>::record, \ + #Result, #Class, #Method, #Signature) + +#define LLDB_REGISTER_CHAR_PTR_METHOD_STATIC(Result, Class, Method) \ + R.Register( \ + &invoke<Result (*)(char *, size_t)>::method<(&Class::Method)>::record, \ + &invoke_char_ptr<Result (*)(char *, \ + size_t)>::method<(&Class::Method)>::record, \ + #Result, #Class, #Method, "(char*, size_t"); + +#define LLDB_REGISTER_CHAR_PTR_METHOD(Result, Class, Method) \ + R.Register(&invoke<Result (Class::*)(char *, size_t)>::method<( \ + &Class::Method)>::record, \ + &invoke_char_ptr<Result (Class::*)(char *, size_t)>::method<( \ + &Class::Method)>::record, \ + #Result, #Class, #Method, "(char*, size_t"); + +#define LLDB_REGISTER_CHAR_PTR_METHOD_CONST(Result, Class, Method) \ + R.Register(&invoke<Result (Class::*)(char *, size_t) \ + const>::method<(&Class::Method)>::record, \ + &invoke_char_ptr<Result (Class::*)(char *, size_t) \ + const>::method<(&Class::Method)>::record, \ + #Result, #Class, #Method, "(char*, size_t"); + +#define LLDB_CONSTRUCT_(T, Class, ...) \ + lldb_private::repro::Recorder _recorder(LLVM_PRETTY_FUNCTION); \ + lldb_private::repro::construct<T>::handle(LLDB_GET_INSTRUMENTATION_DATA(), \ + _recorder, Class, __VA_ARGS__); #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); \ - } + LLDB_CONSTRUCT_(Class Signature, this, __VA_ARGS__) #define LLDB_RECORD_CONSTRUCTOR_NO_ARGS(Class) \ - lldb_private::repro::Recorder sb_recorder(LLVM_PRETTY_FUNCTION); \ - if (lldb_private::repro::InstrumentationData data = \ + LLDB_CONSTRUCT_(Class(), this, lldb_private::repro::EmptyArg()) + +#define LLDB_RECORD_(T1, T2, ...) \ + lldb_private::repro::Recorder _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()>::doit); \ - sb_recorder.RecordResult(this); \ + if (lldb_private::repro::Serializer *_serializer = \ + _data.GetSerializer()) { \ + _recorder.Record(*_serializer, _data.GetRegistry(), \ + &lldb_private::repro::invoke<T1>::method<T2>::record, \ + __VA_ARGS__); \ + } else if (lldb_private::repro::Deserializer *_deserializer = \ + _data.GetDeserializer()) { \ + if (_recorder.ShouldCapture()) { \ + return lldb_private::repro::invoke<T1>::method<T2>::replay( \ + _recorder, *_deserializer, _data.GetRegistry()); \ + } \ + } \ } #define LLDB_RECORD_METHOD(Result, Class, Method, Signature, ...) \ - lldb_private::repro::Recorder sb_recorder( \ - LLVM_PRETTY_FUNCTION, stringify_args(*this, __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__); \ - } + LLDB_RECORD_(Result(Class::*) Signature, (&Class::Method), this, __VA_ARGS__) #define LLDB_RECORD_METHOD_CONST(Result, Class, Method, Signature, ...) \ - lldb_private::repro::Recorder sb_recorder( \ - LLVM_PRETTY_FUNCTION, stringify_args(*this, __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__); \ - } + LLDB_RECORD_(Result(Class::*) Signature const, (&Class::Method), this, \ + __VA_ARGS__) #define LLDB_RECORD_METHOD_NO_ARGS(Result, Class, Method) \ - lldb_private::repro::Recorder sb_recorder(LLVM_PRETTY_FUNCTION, \ - stringify_args(*this)); \ - 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); \ - } + LLDB_RECORD_(Result (Class::*)(), (&Class::Method), this) #define LLDB_RECORD_METHOD_CONST_NO_ARGS(Result, Class, Method) \ - lldb_private::repro::Recorder sb_recorder(LLVM_PRETTY_FUNCTION, \ - stringify_args(*this)); \ - 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); \ - } + LLDB_RECORD_(Result (Class::*)() const, (&Class::Method), 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__); \ - } + LLDB_RECORD_(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_RECORD_(Result (*)(), (&Class::Method), lldb_private::repro::EmptyArg()) + +#define LLDB_RECORD_CHAR_PTR_(T1, T2, StrOut, ...) \ + lldb_private::repro::Recorder _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 (*)()>(&Class::Method)); \ + if (lldb_private::repro::Serializer *_serializer = \ + _data.GetSerializer()) { \ + _recorder.Record(*_serializer, _data.GetRegistry(), \ + &lldb_private::repro::invoke<T1>::method<(T2)>::record, \ + __VA_ARGS__); \ + } else if (lldb_private::repro::Deserializer *_deserializer = \ + _data.GetDeserializer()) { \ + if (_recorder.ShouldCapture()) { \ + return lldb_private::repro::invoke_char_ptr<T1>::method<T2>::replay( \ + _recorder, *_deserializer, _data.GetRegistry(), StrOut); \ + } \ + } \ } -#define LLDB_RECORD_RESULT(Result) sb_recorder.RecordResult(Result); +#define LLDB_RECORD_CHAR_PTR_METHOD(Result, Class, Method, Signature, StrOut, \ + ...) \ + LLDB_RECORD_CHAR_PTR_(Result(Class::*) Signature, (&Class::Method), StrOut, \ + this, __VA_ARGS__) + +#define LLDB_RECORD_CHAR_PTR_METHOD_CONST(Result, Class, Method, Signature, \ + StrOut, ...) \ + LLDB_RECORD_CHAR_PTR_(Result(Class::*) Signature const, (&Class::Method), \ + StrOut, this, __VA_ARGS__) + +#define LLDB_RECORD_CHAR_PTR_STATIC_METHOD(Result, Class, Method, Signature, \ + StrOut, ...) \ + LLDB_RECORD_CHAR_PTR_(Result(*) Signature, (&Class::Method), StrOut, \ + __VA_ARGS__) + +#define LLDB_RECORD_RESULT(Result) _recorder.RecordResult(Result, true); /// 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__)); + lldb_private::repro::Recorder _recorder; + #define LLDB_RECORD_DUMMY_NO_ARGS(Result, Class, Method) \ - lldb_private::repro::Recorder sb_recorder(LLVM_PRETTY_FUNCTION); + lldb_private::repro::Recorder _recorder; namespace lldb_private { namespace repro { +template <class T> +struct is_trivially_serializable + : std::integral_constant<bool, std::is_fundamental<T>::value || + std::is_enum<T>::value> {}; + /// Mapping between serialized indices and their corresponding objects. /// /// This class is used during replay to map indices back to in-memory objects. @@ -205,19 +241,24 @@ public: } /// Adds a pointer to an object to the mapping for the given index. - template <typename T> void AddObjectForIndex(unsigned idx, T *object) { + template <typename T> T *AddObjectForIndex(unsigned idx, T *object) { AddObjectForIndexImpl( idx, static_cast<void *>( const_cast<typename std::remove_const<T>::type *>(object))); + return object; } /// Adds a reference to an object to the mapping for the given index. - template <typename T> void AddObjectForIndex(unsigned idx, T &object) { + template <typename T> T &AddObjectForIndex(unsigned idx, T &object) { AddObjectForIndexImpl( idx, static_cast<void *>( const_cast<typename std::remove_const<T>::type *>(&object))); + return object; } + /// Get all objects sorted by their index. + std::vector<void *> GetAllObjects() const; + private: /// Helper method that does the actual lookup. The void* result is later cast /// by the caller. @@ -238,11 +279,11 @@ struct ReferenceTag {}; struct ValueTag {}; struct FundamentalPointerTag {}; struct FundamentalReferenceTag {}; -struct NotImplementedTag {}; /// Return the deserialization tag for the given type T. template <class T> struct serializer_tag { - typedef typename std::conditional<std::is_trivially_copyable<T>::value, ValueTag, NotImplementedTag>::type type; + typedef typename std::conditional<std::is_trivially_copyable<T>::value, + ValueTag, ReferenceTag>::type type; }; template <class T> struct serializer_tag<T *> { typedef @@ -275,27 +316,37 @@ public: /// Deserialize and interpret value as T. template <typename T> T Deserialize() { + T t = Read<T>(typename serializer_tag<T>::type()); #ifdef LLDB_REPRO_INSTR_TRACE - llvm::errs() << "Deserializing with " << LLVM_PRETTY_FUNCTION << "\n"; + llvm::errs() << "Deserializing with " << LLVM_PRETTY_FUNCTION << " -> " + << stringify_args(t) << "\n"; #endif - return Read<T>(typename serializer_tag<T>::type()); + return t; + } + + template <typename T> const T &HandleReplayResult(const T &t) { + unsigned result = Deserialize<unsigned>(); + if (is_trivially_serializable<T>::value) + return t; + // We need to make a copy as the original object might go out of scope. + return *m_index_to_object.AddObjectForIndex(result, new T(t)); } /// Store the returned value in the index-to-object mapping. - template <typename T> void HandleReplayResult(const T &t) { + template <typename T> T &HandleReplayResult(T &t) { unsigned result = Deserialize<unsigned>(); - if (std::is_fundamental<T>::value) - return; + if (is_trivially_serializable<T>::value) + return t; // We need to make a copy as the original object might go out of scope. - m_index_to_object.AddObjectForIndex(result, new T(t)); + return *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) { + template <typename T> T *HandleReplayResult(T *t) { unsigned result = Deserialize<unsigned>(); - if (std::is_fundamental<T>::value) - return; - m_index_to_object.AddObjectForIndex(result, t); + if (is_trivially_serializable<T>::value) + return t; + return m_index_to_object.AddObjectForIndex(result, t); } /// All returned types are recorded, even when the function returns a void. @@ -306,12 +357,11 @@ public: (void)result; } -private: - template <typename T> T Read(NotImplementedTag) { - m_buffer = m_buffer.drop_front(sizeof(T)); - return T(); + std::vector<void *> GetAllObjects() const { + return m_index_to_object.GetAllObjects(); } +private: template <typename T> T Read(ValueTag) { assert(HasData(sizeof(T))); T t; @@ -362,7 +412,11 @@ private: /// 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 <> const char **Deserializer::Deserialize<const char **>(); +template <> const uint8_t *Deserializer::Deserialize<const uint8_t *>(); +template <> const void *Deserializer::Deserialize<const void *>(); template <> char *Deserializer::Deserialize<char *>(); +template <> void *Deserializer::Deserialize<void *>(); /// Helpers to auto-synthesize function replay code. It deserializes the replay /// function's arguments one by one and finally calls the corresponding @@ -404,7 +458,11 @@ struct DefaultReplayer<Result(Args...)> : public Replayer { DefaultReplayer(Result (*f)(Args...)) : Replayer(), f(f) {} void operator()(Deserializer &deserializer) const override { - deserializer.HandleReplayResult( + Replay(deserializer); + } + + Result Replay(Deserializer &deserializer) const { + return deserializer.HandleReplayResult( DeserializationHelper<Args...>::template deserialized<Result>::doit( deserializer, f)); } @@ -419,6 +477,10 @@ struct DefaultReplayer<void(Args...)> : public Replayer { DefaultReplayer(void (*f)(Args...)) : Replayer(), f(f) {} void operator()(Deserializer &deserializer) const override { + Replay(deserializer); + } + + void Replay(Deserializer &deserializer) const { DeserializationHelper<Args...>::template deserialized<void>::doit( deserializer, f); deserializer.HandleReplayResultVoid(); @@ -474,18 +536,25 @@ public: /// Replay functions from a buffer. bool Replay(llvm::StringRef buffer); + /// Replay functions from a deserializer. + bool Replay(Deserializer &deserializer); + /// Returns the ID for a given function address. unsigned GetID(uintptr_t addr); + /// Get the replayer matching the given ID. + Replayer *GetReplayer(unsigned id); + + std::string GetSignature(unsigned id); + + void CheckID(unsigned expected, unsigned actual); + 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; @@ -494,37 +563,6 @@ private: 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. /// @@ -561,6 +599,10 @@ private: /// 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) { +#ifdef LLDB_REPRO_INSTR_TRACE + llvm::errs() << "Serializing with " << LLVM_PRETTY_FUNCTION << " -> " + << stringify_args(t) << "\n"; +#endif if (std::is_fundamental<T>::value) { Serialize(*t); } else { @@ -573,7 +615,11 @@ private: /// 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) { +#ifdef LLDB_REPRO_INSTR_TRACE + llvm::errs() << "Serializing with " << LLVM_PRETTY_FUNCTION << " -> " + << stringify_args(t) << "\n"; +#endif + if (is_trivially_serializable<T>::value) { m_stream.write(reinterpret_cast<const char *>(&t), sizeof(T)); } else { unsigned idx = m_tracker.GetIndexForObject(&t); @@ -581,14 +627,43 @@ private: } } + void Serialize(const void *v) { + // FIXME: Support void* + } + 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); +#ifdef LLDB_REPRO_INSTR_TRACE + llvm::errs() << "Serializing with " << LLVM_PRETTY_FUNCTION << " -> " + << stringify_args(t) << "\n"; +#endif + const size_t size = t ? strlen(t) : std::numeric_limits<size_t>::max(); + Serialize(size); + if (t) { + m_stream << t; + m_stream.write(0x0); + } + } + + void Serialize(const char **t) { + size_t size = 0; + if (!t) { + Serialize(size); + return; + } + + // Compute the size of the array. + const char *const *temp = t; + while (*temp++) + size++; + Serialize(size); + + // Serialize the content of the array. + while (*t) + Serialize(*t++); } /// Serialization stream. @@ -596,24 +671,46 @@ private: /// Mapping of objects to indices. ObjectToIndex m_tracker; -}; +}; // namespace repro 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; } + Serializer *GetSerializer() { return m_serializer; } + Deserializer *GetDeserializer() { return m_deserializer; } Registry &GetRegistry() { return *m_registry; } - operator bool() { return m_serializer != nullptr && m_registry != nullptr; } + operator bool() { + return (m_serializer != nullptr || m_deserializer != nullptr) && + m_registry != nullptr; + } + + static void Initialize(Serializer &serializer, Registry ®istry); + static void Initialize(Deserializer &serializer, Registry ®istry); + static InstrumentationData &Instance(); + +protected: + friend llvm::optional_detail::OptionalStorage<InstrumentationData, true>; + friend llvm::Optional<InstrumentationData>; + + InstrumentationData() + : m_serializer(nullptr), m_deserializer(nullptr), m_registry(nullptr) {} + InstrumentationData(Serializer &serializer, Registry ®istry) + : m_serializer(&serializer), m_deserializer(nullptr), + m_registry(®istry) {} + InstrumentationData(Deserializer &deserializer, Registry ®istry) + : m_serializer(nullptr), m_deserializer(&deserializer), + m_registry(®istry) {} private: + static llvm::Optional<InstrumentationData> &InstanceImpl(); + Serializer *m_serializer; + Deserializer *m_deserializer; Registry *m_registry; }; +struct EmptyArg {}; + /// 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 @@ -628,7 +725,8 @@ private: /// this class is also used for logging. class Recorder { public: - Recorder(llvm::StringRef pretty_func = {}, std::string &&pretty_args = {}); + Recorder(); + Recorder(llvm::StringRef pretty_func, std::string &&pretty_args = {}); ~Recorder(); /// Records a single function call. @@ -679,9 +777,26 @@ public: m_result_recorded = true; } + /// Specializations for the no-argument methods. These are passed an empty + /// dummy argument so the same variadic macro can be used. These methods + /// strip the arguments before forwarding them. + template <typename Result> + void Record(Serializer &serializer, Registry ®istry, Result (*f)(), + const EmptyArg &arg) { + Record(serializer, registry, f); + } + /// Record the result of a function call. - template <typename Result> Result RecordResult(Result &&r) { - UpdateBoundary(); + template <typename Result> + Result RecordResult(Result &&r, bool update_boundary) { + // When recording the result from the LLDB_RECORD_RESULT macro, we need to + // update the boundary so we capture the copy constructor. However, when + // called to record the this pointer of the (copy) constructor, the + // boundary should not be toggled, because it is called from the + // LLDB_RECORD_CONSTRUCTOR macro, which might be followed by other API + // calls. + if (update_boundary) + UpdateBoundary(); if (m_serializer && ShouldCapture()) { assert(!m_result_recorded); m_serializer->SerializeAll(r); @@ -690,14 +805,41 @@ public: return std::forward<Result>(r); } + template <typename Result, typename T> + Result Replay(Deserializer &deserializer, Registry ®istry, uintptr_t addr, + bool update_boundary) { + unsigned actual_id = registry.GetID(addr); + unsigned id = deserializer.Deserialize<unsigned>(); + registry.CheckID(id, actual_id); + return ReplayResult<Result>( + static_cast<DefaultReplayer<T> *>(registry.GetReplayer(id)) + ->Replay(deserializer), + update_boundary); + } + + void Replay(Deserializer &deserializer, Registry ®istry, uintptr_t addr) { + unsigned actual_id = registry.GetID(addr); + unsigned id = deserializer.Deserialize<unsigned>(); + registry.CheckID(id, actual_id); + registry.GetReplayer(id)->operator()(deserializer); + } + + template <typename Result> + Result ReplayResult(Result &&r, bool update_boundary) { + if (update_boundary) + UpdateBoundary(); + return std::forward<Result>(r); + } + + bool ShouldCapture() { return m_local_boundary; } + private: + template <typename T> friend struct replay; 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 << " (" @@ -721,7 +863,197 @@ private: static bool g_global_boundary; }; +/// 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 *handle(lldb_private::repro::InstrumentationData data, + lldb_private::repro::Recorder &recorder, Class *c, + const EmptyArg &) { + return handle(data, recorder, c); + } + + static Class *handle(lldb_private::repro::InstrumentationData data, + lldb_private::repro::Recorder &recorder, Class *c, + Args... args) { + if (!data) + return nullptr; + + if (Serializer *serializer = data.GetSerializer()) { + recorder.Record(*serializer, data.GetRegistry(), &record, args...); + recorder.RecordResult(c, false); + } else if (Deserializer *deserializer = data.GetDeserializer()) { + if (recorder.ShouldCapture()) { + replay(recorder, *deserializer, data.GetRegistry()); + } + } + + return nullptr; + } + + static Class *record(Args... args) { return new Class(args...); } + + static Class *replay(Recorder &recorder, Deserializer &deserializer, + Registry ®istry) { + return recorder.Replay<Class *, Class *(Args...)>( + deserializer, registry, uintptr_t(&record), false); + } +}; + +/// 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 record(Class *c, Args... args) { return (c->*m)(args...); } + + static Result replay(Recorder &recorder, Deserializer &deserializer, + Registry ®istry) { + return recorder.Replay<Result, Result(Class *, Args...)>( + deserializer, registry, uintptr_t(&record), true); + } + }; +}; + +template <typename Class, typename... Args> +struct invoke<void (Class::*)(Args...)> { + template <void (Class::*m)(Args...)> struct method { + static void record(Class *c, Args... args) { (c->*m)(args...); } + static void replay(Recorder &recorder, Deserializer &deserializer, + Registry ®istry) { + recorder.Replay(deserializer, registry, uintptr_t(&record)); + } + }; +}; + +template <typename Result, typename Class, typename... Args> +struct invoke<Result (Class::*)(Args...) const> { + template <Result (Class::*m)(Args...) const> struct method { + static Result record(Class *c, Args... args) { return (c->*m)(args...); } + static Result replay(Recorder &recorder, Deserializer &deserializer, + Registry ®istry) { + return recorder.Replay<Result, Result(Class *, Args...)>( + deserializer, registry, uintptr_t(&record), true); + } + }; +}; + +template <typename Class, typename... Args> +struct invoke<void (Class::*)(Args...) const> { + template <void (Class::*m)(Args...) const> struct method { + static void record(Class *c, Args... args) { return (c->*m)(args...); } + static void replay(Recorder &recorder, Deserializer &deserializer, + Registry ®istry) { + recorder.Replay(deserializer, registry, uintptr_t(&record)); + } + }; +}; + +template <typename Signature> struct replay; + +template <typename Result, typename Class, typename... Args> +struct replay<Result (Class::*)(Args...)> { + template <Result (Class::*m)(Args...)> struct method {}; +}; + +template <typename Result, typename... Args> +struct invoke<Result (*)(Args...)> { + template <Result (*m)(Args...)> struct method { + static Result record(Args... args) { return (*m)(args...); } + static Result replay(Recorder &recorder, Deserializer &deserializer, + Registry ®istry) { + return recorder.Replay<Result, Result(Args...)>(deserializer, registry, + uintptr_t(&record), true); + } + }; +}; + +template <typename... Args> struct invoke<void (*)(Args...)> { + template <void (*m)(Args...)> struct method { + static void record(Args... args) { return (*m)(args...); } + static void replay(Recorder &recorder, Deserializer &deserializer, + Registry ®istry) { + recorder.Replay(deserializer, registry, uintptr_t(&record)); + } + }; +}; + +/// Special handling for functions returning strings as (char*, size_t). +/// { + +/// For inline replay, we ignore the arguments and use the ones from the +/// serializer instead. This doesn't work for methods that use a char* and a +/// size to return a string. For one these functions have a custom replayer to +/// prevent override the input buffer. Furthermore, the template-generated +/// deserialization is not easy to hook into. +/// +/// The specializations below hand-implement the serialization logic for the +/// inline replay. Instead of using the function from the registry, it uses the +/// one passed into the macro. +template <typename Signature> struct invoke_char_ptr; +template <typename Result, typename Class, typename... Args> +struct invoke_char_ptr<Result (Class::*)(Args...) const> { + template <Result (Class::*m)(Args...) const> struct method { + static Result record(Class *c, char *s, size_t l) { + char *buffer = reinterpret_cast<char *>(calloc(l, sizeof(char))); + return (c->*m)(buffer, l); + } + + static Result replay(Recorder &recorder, Deserializer &deserializer, + Registry ®istry, char *str) { + deserializer.Deserialize<unsigned>(); + Class *c = deserializer.Deserialize<Class *>(); + deserializer.Deserialize<const char *>(); + size_t l = deserializer.Deserialize<size_t>(); + return recorder.ReplayResult( + std::move(deserializer.HandleReplayResult((c->*m)(str, l))), true); + } + }; +}; + +template <typename Signature> struct invoke_char_ptr; +template <typename Result, typename Class, typename... Args> +struct invoke_char_ptr<Result (Class::*)(Args...)> { + template <Result (Class::*m)(Args...)> struct method { + static Result record(Class *c, char *s, size_t l) { + char *buffer = reinterpret_cast<char *>(calloc(l, sizeof(char))); + return (c->*m)(buffer, l); + } + + static Result replay(Recorder &recorder, Deserializer &deserializer, + Registry ®istry, char *str) { + deserializer.Deserialize<unsigned>(); + Class *c = deserializer.Deserialize<Class *>(); + deserializer.Deserialize<const char *>(); + size_t l = deserializer.Deserialize<size_t>(); + return recorder.ReplayResult( + std::move(deserializer.HandleReplayResult((c->*m)(str, l))), true); + } + }; +}; + +template <typename Result, typename... Args> +struct invoke_char_ptr<Result (*)(Args...)> { + template <Result (*m)(Args...)> struct method { + static Result record(char *s, size_t l) { + char *buffer = reinterpret_cast<char *>(calloc(l, sizeof(char))); + return (*m)(buffer, l); + } + + static Result replay(Recorder &recorder, Deserializer &deserializer, + Registry ®istry, char *str) { + deserializer.Deserialize<unsigned>(); + deserializer.Deserialize<const char *>(); + size_t l = deserializer.Deserialize<size_t>(); + return recorder.ReplayResult( + std::move(deserializer.HandleReplayResult((*m)(str, l))), true); + } + }; +}; +/// } + } // namespace repro } // namespace lldb_private -#endif // LLDB_UTILITY_REPRODUCER_INSTRUMENTATION_H +#endif // LLDB_UTILITY_REPRODUCERINSTRUMENTATION_H diff --git a/lldb/include/lldb/Utility/Scalar.h b/lldb/include/lldb/Utility/Scalar.h index 69c948ec6222..f215fa71c84c 100644 --- a/lldb/include/lldb/Utility/Scalar.h +++ b/lldb/include/lldb/Utility/Scalar.h @@ -83,20 +83,11 @@ public: Scalar(double v) : m_type(e_double), m_float(v) { m_float = llvm::APFloat(v); } - Scalar(long double v, bool 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, - (reinterpret_cast<type128 *>(&v))->x)); - else - m_float = - llvm::APFloat(llvm::APFloat::x87DoubleExtended(), - llvm::APInt(BITWIDTH_INT128, NUM_OF_WORDS_INT128, - (reinterpret_cast<type128 *>(&v))->x)); - } + Scalar(long double v) + : m_type(e_long_double), + m_float(llvm::APFloat::x87DoubleExtended(), + llvm::APInt(BITWIDTH_INT128, NUM_OF_WORDS_INT128, + (reinterpret_cast<type128 *>(&v))->x)) {} Scalar(llvm::APInt v) : m_type(), m_float(static_cast<float>(0)) { m_integer = llvm::APInt(v); m_type = GetBestTypeForBitSize(m_integer.getBitWidth(), true); @@ -115,7 +106,10 @@ public: bool ClearBit(uint32_t bit); - const void *GetBytes() const; + /// Store the binary representation of this value into the given storage. + /// Exactly GetByteSize() bytes will be stored, and the buffer must be large + /// enough to hold this data. + void GetBytes(llvm::MutableArrayRef<uint8_t> storage) const; size_t GetByteSize() const; @@ -131,7 +125,7 @@ public: m_integer.clearAllBits(); } - const char *GetTypeAsCString() const; + const char *GetTypeAsCString() const { return GetValueTypeAsCString(m_type); } void GetValue(Stream *s, bool show_type) const; @@ -139,8 +133,8 @@ public: return (m_type >= e_sint) && (m_type <= e_long_double); } - /// Convert integer to \p type, limited to \p bits size. - void TruncOrExtendTo(Scalar::Type type, uint16_t bits); + /// Convert to an integer with \p bits and the given signedness. + void TruncOrExtendTo(uint16_t bits, bool sign); bool Promote(Scalar::Type type); @@ -162,16 +156,6 @@ public: // 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); - Scalar &operator=(unsigned long v); - Scalar &operator=(long long v); - Scalar &operator=(unsigned long long v); - Scalar &operator=(float v); - Scalar &operator=(double v); - Scalar &operator=(long double v); - Scalar &operator=(llvm::APInt v); Scalar &operator+=(const Scalar &rhs); Scalar &operator<<=(const Scalar &rhs); // Shift left Scalar &operator>>=(const Scalar &rhs); // Shift right (arithmetic) @@ -204,7 +188,7 @@ public: unsigned char UChar(unsigned char fail_value = 0) const; - signed char SChar(char fail_value = 0) const; + signed char SChar(signed char fail_value = 0) const; unsigned short UShort(unsigned short fail_value = 0) const; @@ -220,7 +204,7 @@ public: unsigned long long ULongLong(unsigned long long fail_value = 0) const; - llvm::APInt SInt128(llvm::APInt &fail_value) const; + llvm::APInt SInt128(const llvm::APInt &fail_value) const; llvm::APInt UInt128(const llvm::APInt &fail_value) const; @@ -282,7 +266,8 @@ protected: Scalar::Type m_type; llvm::APInt m_integer; llvm::APFloat m_float; - bool m_ieee_quad = false; + + template <typename T> T GetAs(T fail_value) const; private: friend const Scalar operator+(const Scalar &lhs, const Scalar &rhs); diff --git a/lldb/include/lldb/Utility/SelectHelper.h b/lldb/include/lldb/Utility/SelectHelper.h index ec37f194d329..63f1fe6421cf 100644 --- a/lldb/include/lldb/Utility/SelectHelper.h +++ b/lldb/include/lldb/Utility/SelectHelper.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef liblldb_SelectHelper_h_ -#define liblldb_SelectHelper_h_ +#ifndef LLDB_UTILITY_SELECTHELPER_H +#define LLDB_UTILITY_SELECTHELPER_H #include "lldb/Utility/Status.h" #include "lldb/lldb-types.h" @@ -68,4 +68,4 @@ protected: llvm::Optional<std::chrono::steady_clock::time_point> m_end_time; }; -#endif // liblldb_SelectHelper_h_ +#endif // LLDB_UTILITY_SELECTHELPER_H diff --git a/lldb/include/lldb/Utility/SharedCluster.h b/lldb/include/lldb/Utility/SharedCluster.h index 71bbb334cff3..375c1c131a09 100644 --- a/lldb/include/lldb/Utility/SharedCluster.h +++ b/lldb/include/lldb/Utility/SharedCluster.h @@ -6,90 +6,54 @@ // //===----------------------------------------------------------------------===// -#ifndef utility_SharedCluster_h_ -#define utility_SharedCluster_h_ +#ifndef LLDB_UTILITY_SHAREDCLUSTER_H +#define LLDB_UTILITY_SHAREDCLUSTER_H #include "lldb/Utility/LLDBAssert.h" -#include "lldb/Utility/SharingPtr.h" - -#include "llvm/ADT/SmallPtrSet.h" +#include "llvm/ADT/STLExtras.h" +#include "llvm/ADT/SmallVector.h" +#include <memory> #include <mutex> namespace lldb_private { -namespace imp { -template <typename T> -class shared_ptr_refcount : public lldb_private::imp::shared_count { -public: - template <class Y> - shared_ptr_refcount(Y *in) : shared_count(0), manager(in) {} - - shared_ptr_refcount() : shared_count(0) {} - - ~shared_ptr_refcount() override {} - - void on_zero_shared() override { manager->DecrementRefCount(); } - -private: - T *manager; -}; - -} // namespace imp - -template <class T> class ClusterManager { +template <class T> +class ClusterManager : public std::enable_shared_from_this<ClusterManager<T>> { public: - ClusterManager() : m_objects(), m_external_ref(0), m_mutex() {} + static std::shared_ptr<ClusterManager> Create() { + return std::shared_ptr<ClusterManager>(new ClusterManager()); + } ~ClusterManager() { - for (typename llvm::SmallPtrSet<T *, 16>::iterator pos = m_objects.begin(), - end = m_objects.end(); - pos != end; ++pos) { - T *object = *pos; - delete object; - } - - // Decrement refcount should have been called on this ClusterManager, and - // it should have locked the mutex, now we will unlock it before we destroy - // it... - m_mutex.unlock(); + for (T *obj : m_objects) + delete obj; } void ManageObject(T *new_object) { std::lock_guard<std::mutex> guard(m_mutex); - m_objects.insert(new_object); + assert(!llvm::is_contained(m_objects, new_object) && + "ManageObject called twice for the same object?"); + m_objects.push_back(new_object); } - typename lldb_private::SharingPtr<T> GetSharedPointer(T *desired_object) { - { - std::lock_guard<std::mutex> guard(m_mutex); - m_external_ref++; - if (0 == m_objects.count(desired_object)) { - lldbassert(false && "object not found in shared cluster when expected"); - desired_object = nullptr; - } + std::shared_ptr<T> GetSharedPointer(T *desired_object) { + std::lock_guard<std::mutex> guard(m_mutex); + auto this_sp = this->shared_from_this(); + if (!llvm::is_contained(m_objects, desired_object)) { + lldbassert(false && "object not found in shared cluster when expected"); + desired_object = nullptr; } - return typename lldb_private::SharingPtr<T>( - desired_object, new imp::shared_ptr_refcount<ClusterManager>(this)); + return {std::move(this_sp), desired_object}; } private: - void DecrementRefCount() { - m_mutex.lock(); - m_external_ref--; - if (m_external_ref == 0) - delete this; - else - m_mutex.unlock(); - } - - friend class imp::shared_ptr_refcount<ClusterManager>; + ClusterManager() : m_objects(), m_mutex() {} - llvm::SmallPtrSet<T *, 16> m_objects; - int m_external_ref; + llvm::SmallVector<T *, 16> m_objects; std::mutex m_mutex; }; } // namespace lldb_private -#endif // utility_SharedCluster_h_ +#endif // LLDB_UTILITY_SHAREDCLUSTER_H diff --git a/lldb/include/lldb/Utility/SharingPtr.h b/lldb/include/lldb/Utility/SharingPtr.h deleted file mode 100644 index e4ab3d27a69b..000000000000 --- a/lldb/include/lldb/Utility/SharingPtr.h +++ /dev/null @@ -1,609 +0,0 @@ -//===---------------------SharingPtr.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 utility_SharingPtr_h_ -#define utility_SharingPtr_h_ - -#include <memory> - -// Microsoft Visual C++ currently does not enable std::atomic to work in CLR -// mode - as such we need to "hack around it" for MSVC++ builds only using -// Windows specific intrinsics instead of the C++11 atomic support -#ifdef _MSC_VER -#include <intrin.h> -#else -#include <atomic> -#endif - -#include <stddef.h> - - -//#define ENABLE_SP_LOGGING 1 // DON'T CHECK THIS LINE IN UNLESS COMMENTED OUT -#if defined(ENABLE_SP_LOGGING) - -extern "C" void track_sp(void *sp_this, void *ptr, long count); - -#endif - -namespace lldb_private { - -namespace imp { - -class 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) {} - - void add_shared(); - void release_shared(); - long use_count() const { return shared_owners_ + 1; } - -protected: -#ifdef _MSC_VER - long shared_owners_; -#else - std::atomic<long> shared_owners_; -#endif - virtual ~shared_count(); - -private: - virtual void on_zero_shared() = 0; -}; - -template <class T> class shared_ptr_pointer : public shared_count { - T data_; - -public: - shared_ptr_pointer(T p) : data_(p) {} - -private: - void on_zero_shared() override; - - 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() { - delete data_; -} - -template <class T> class shared_ptr_emplace : public shared_count { - T data_; - -public: - shared_ptr_emplace() : data_() {} - - template <class A0> shared_ptr_emplace(A0 &a0) : data_(a0) {} - - template <class A0, class A1> - shared_ptr_emplace(A0 &a0, A1 &a1) : data_(a0, a1) {} - - template <class A0, class A1, class A2> - shared_ptr_emplace(A0 &a0, A1 &a1, A2 &a2) : data_(a0, a1, a2) {} - - template <class A0, class A1, class A2, class A3> - shared_ptr_emplace(A0 &a0, A1 &a1, A2 &a2, A3 &a3) : data_(a0, a1, a2, a3) {} - - template <class A0, class A1, class A2, class A3, class A4> - shared_ptr_emplace(A0 &a0, A1 &a1, A2 &a2, A3 &a3, A4 &a4) - : data_(a0, a1, a2, a3, a4) {} - -private: - void on_zero_shared() override; - -public: - T *get() { return &data_; } -}; - -template <class T> void shared_ptr_emplace<T>::on_zero_shared() {} - -} // namespace imp - -template <class T> class SharingPtr { -public: - typedef T element_type; - -private: - element_type *ptr_; - imp::shared_count *cntrl_; - - struct nat { - int for_bool_; - }; - -public: - SharingPtr(); - SharingPtr(std::nullptr_t); - template <class Y> explicit SharingPtr(Y *p); - template <class Y> explicit SharingPtr(Y *p, imp::shared_count *ctrl_block); - template <class Y> SharingPtr(const SharingPtr<Y> &r, element_type *p); - SharingPtr(const SharingPtr &r); - template <class Y> SharingPtr(const SharingPtr<Y> &r); - - ~SharingPtr(); - - SharingPtr &operator=(const SharingPtr &r); - template <class Y> SharingPtr &operator=(const SharingPtr<Y> &r); - - void swap(SharingPtr &r); - void reset(); - template <class Y> void reset(Y *p); - void reset(std::nullptr_t); - - element_type *get() const { return ptr_; } - element_type &operator*() const { return *ptr_; } - element_type *operator->() const { return ptr_; } - long use_count() const { return cntrl_ ? cntrl_->use_count() : 0; } - bool unique() const { return use_count() == 1; } - bool empty() const { return cntrl_ == nullptr; } - operator nat *() const { return (nat *)get(); } - - static SharingPtr<T> make_shared(); - - template <class A0> static SharingPtr<T> make_shared(A0 &); - - template <class A0, class A1> static SharingPtr<T> make_shared(A0 &, A1 &); - - template <class A0, class A1, class A2> - static SharingPtr<T> make_shared(A0 &, A1 &, A2 &); - - template <class A0, class A1, class A2, class A3> - static SharingPtr<T> make_shared(A0 &, A1 &, A2 &, A3 &); - - template <class A0, class A1, class A2, class A3, class A4> - static SharingPtr<T> make_shared(A0 &, A1 &, A2 &, A3 &, A4 &); - -private: - template <class U> friend class SharingPtr; -}; - -template <class T> -inline SharingPtr<T>::SharingPtr() : ptr_(nullptr), cntrl_(nullptr) {} - -template <class T> -inline SharingPtr<T>::SharingPtr(std::nullptr_t) - : ptr_(nullptr), cntrl_(nullptr) {} - -template <class T> -template <class Y> -SharingPtr<T>::SharingPtr(Y *p) : ptr_(p), cntrl_(nullptr) { - std::unique_ptr<Y> hold(p); - typedef imp::shared_ptr_pointer<Y *> _CntrlBlk; - cntrl_ = new _CntrlBlk(p); - hold.release(); -} - -template <class T> -template <class Y> -SharingPtr<T>::SharingPtr(Y *p, imp::shared_count *cntrl_block) - : ptr_(p), cntrl_(cntrl_block) {} - -template <class T> -template <class Y> -inline SharingPtr<T>::SharingPtr(const SharingPtr<Y> &r, element_type *p) - : ptr_(p), cntrl_(r.cntrl_) { - if (cntrl_) - cntrl_->add_shared(); -} - -template <class T> -inline SharingPtr<T>::SharingPtr(const SharingPtr &r) - : ptr_(r.ptr_), cntrl_(r.cntrl_) { - if (cntrl_) - cntrl_->add_shared(); -} - -template <class T> -template <class Y> -inline SharingPtr<T>::SharingPtr(const SharingPtr<Y> &r) - : ptr_(r.ptr_), cntrl_(r.cntrl_) { - if (cntrl_) - cntrl_->add_shared(); -} - -template <class T> SharingPtr<T>::~SharingPtr() { - if (cntrl_) - cntrl_->release_shared(); -} - -template <class T> -inline SharingPtr<T> &SharingPtr<T>::operator=(const SharingPtr &r) { - SharingPtr(r).swap(*this); - return *this; -} - -template <class T> -template <class Y> -inline SharingPtr<T> &SharingPtr<T>::operator=(const SharingPtr<Y> &r) { - SharingPtr(r).swap(*this); - return *this; -} - -template <class T> inline void SharingPtr<T>::swap(SharingPtr &r) { - std::swap(ptr_, r.ptr_); - std::swap(cntrl_, r.cntrl_); -} - -template <class T> inline void SharingPtr<T>::reset() { - SharingPtr().swap(*this); -} - -template <class T> inline void SharingPtr<T>::reset(std::nullptr_t p) { - reset(); -} - -template <class T> template <class Y> inline void SharingPtr<T>::reset(Y *p) { - SharingPtr(p).swap(*this); -} - -template <class T> SharingPtr<T> SharingPtr<T>::make_shared() { - typedef imp::shared_ptr_emplace<T> CntrlBlk; - SharingPtr<T> r; - r.cntrl_ = new CntrlBlk(); - r.ptr_ = static_cast<CntrlBlk *>(r.cntrl_)->get(); - return r; -} - -template <class T> -template <class A0> -SharingPtr<T> SharingPtr<T>::make_shared(A0 &a0) { - typedef imp::shared_ptr_emplace<T> CntrlBlk; - SharingPtr<T> r; - r.cntrl_ = new CntrlBlk(a0); - r.ptr_ = static_cast<CntrlBlk *>(r.cntrl_)->get(); - return r; -} - -template <class T> -template <class A0, class A1> -SharingPtr<T> SharingPtr<T>::make_shared(A0 &a0, A1 &a1) { - typedef imp::shared_ptr_emplace<T> CntrlBlk; - SharingPtr<T> r; - r.cntrl_ = new CntrlBlk(a0, a1); - r.ptr_ = static_cast<CntrlBlk *>(r.cntrl_)->get(); - return r; -} - -template <class T> -template <class A0, class A1, class A2> -SharingPtr<T> SharingPtr<T>::make_shared(A0 &a0, A1 &a1, A2 &a2) { - typedef imp::shared_ptr_emplace<T> CntrlBlk; - SharingPtr<T> r; - r.cntrl_ = new CntrlBlk(a0, a1, a2); - r.ptr_ = static_cast<CntrlBlk *>(r.cntrl_)->get(); - return r; -} - -template <class T> -template <class A0, class A1, class A2, class A3> -SharingPtr<T> SharingPtr<T>::make_shared(A0 &a0, A1 &a1, A2 &a2, A3 &a3) { - typedef imp::shared_ptr_emplace<T> CntrlBlk; - SharingPtr<T> r; - r.cntrl_ = new CntrlBlk(a0, a1, a2, a3); - r.ptr_ = static_cast<CntrlBlk *>(r.cntrl_)->get(); - return r; -} - -template <class T> -template <class A0, class A1, class A2, class A3, class A4> -SharingPtr<T> SharingPtr<T>::make_shared(A0 &a0, A1 &a1, A2 &a2, A3 &a3, - A4 &a4) { - typedef imp::shared_ptr_emplace<T> CntrlBlk; - SharingPtr<T> r; - r.cntrl_ = new CntrlBlk(a0, a1, a2, a3, a4); - r.ptr_ = static_cast<CntrlBlk *>(r.cntrl_)->get(); - return r; -} - -template <class T> inline SharingPtr<T> make_shared() { - return SharingPtr<T>::make_shared(); -} - -template <class T, class A0> inline SharingPtr<T> make_shared(A0 &a0) { - return SharingPtr<T>::make_shared(a0); -} - -template <class T, class A0, class A1> -inline SharingPtr<T> make_shared(A0 &a0, A1 &a1) { - return SharingPtr<T>::make_shared(a0, a1); -} - -template <class T, class A0, class A1, class A2> -inline SharingPtr<T> make_shared(A0 &a0, A1 &a1, A2 &a2) { - return SharingPtr<T>::make_shared(a0, a1, a2); -} - -template <class T, class A0, class A1, class A2, class A3> -inline SharingPtr<T> make_shared(A0 &a0, A1 &a1, A2 &a2, A3 &a3) { - return SharingPtr<T>::make_shared(a0, a1, a2, a3); -} - -template <class T, class A0, class A1, class A2, class A3, class A4> -inline SharingPtr<T> make_shared(A0 &a0, A1 &a1, A2 &a2, A3 &a3, A4 &a4) { - return SharingPtr<T>::make_shared(a0, a1, a2, a3, a4); -} - -template <class T, class U> -inline bool operator==(const SharingPtr<T> &__x, const SharingPtr<U> &__y) { - return __x.get() == __y.get(); -} - -template <class T, class U> -inline bool operator!=(const SharingPtr<T> &__x, const SharingPtr<U> &__y) { - return !(__x == __y); -} - -template <class T, class U> -inline bool operator<(const SharingPtr<T> &__x, const SharingPtr<U> &__y) { - return __x.get() < __y.get(); -} - -template <class T> inline void swap(SharingPtr<T> &__x, SharingPtr<T> &__y) { - __x.swap(__y); -} - -template <class T, class U> -inline SharingPtr<T> static_pointer_cast(const SharingPtr<U> &r) { - return SharingPtr<T>(r, static_cast<T *>(r.get())); -} - -template <class T, class U> -SharingPtr<T> const_pointer_cast(const SharingPtr<U> &r) { - return SharingPtr<T>(r, const_cast<T *>(r.get())); -} - -template <class T> class LoggingSharingPtr : public SharingPtr<T> { - typedef SharingPtr<T> base; - -public: - typedef void (*Callback)(void *, const LoggingSharingPtr &, bool action); - // action: false means increment just happened - // true means decrement is about to happen - - LoggingSharingPtr() : cb_(0), baton_(nullptr) {} - - LoggingSharingPtr(Callback cb, void *baton) : cb_(cb), baton_(baton) { - if (cb_) - cb_(baton_, *this, false); - } - - template <class Y> - LoggingSharingPtr(Y *p) : base(p), cb_(0), baton_(nullptr) {} - - template <class Y> - LoggingSharingPtr(Y *p, Callback cb, void *baton) - : base(p), cb_(cb), baton_(baton) { - if (cb_) - cb_(baton_, *this, false); - } - - ~LoggingSharingPtr() { - if (cb_) - cb_(baton_, *this, true); - } - - LoggingSharingPtr(const LoggingSharingPtr &p) - : base(p), cb_(p.cb_), baton_(p.baton_) { - if (cb_) - cb_(baton_, *this, false); - } - - LoggingSharingPtr &operator=(const LoggingSharingPtr &p) { - if (cb_) - cb_(baton_, *this, true); - base::operator=(p); - cb_ = p.cb_; - baton_ = p.baton_; - if (cb_) - cb_(baton_, *this, false); - return *this; - } - - void reset() { - if (cb_) - cb_(baton_, *this, true); - base::reset(); - } - - template <class Y> void reset(Y *p) { - if (cb_) - cb_(baton_, *this, true); - base::reset(p); - if (cb_) - cb_(baton_, *this, false); - } - - void SetCallback(Callback cb, void *baton) { - cb_ = cb; - baton_ = baton; - } - - void ClearCallback() { - cb_ = 0; - baton_ = 0; - } - -private: - Callback cb_; - void *baton_; -}; - -template <class T> class IntrusiveSharingPtr; - -template <class T> class ReferenceCountedBase { -public: - explicit ReferenceCountedBase() : shared_owners_(-1) {} - - void add_shared(); - - void release_shared(); - - long use_count() const { return shared_owners_ + 1; } - -protected: - long shared_owners_; - - friend class IntrusiveSharingPtr<T>; - -private: - ReferenceCountedBase(const ReferenceCountedBase &) = delete; - ReferenceCountedBase &operator=(const ReferenceCountedBase &) = delete; -}; - -template <class T> void lldb_private::ReferenceCountedBase<T>::add_shared() { -#ifdef _MSC_VER - _InterlockedIncrement(&shared_owners_); -#else - ++shared_owners_; -#endif -} - -template <class T> -void lldb_private::ReferenceCountedBase<T>::release_shared() { -#ifdef _MSC_VER - if (_InterlockedDecrement(&shared_owners_) == -1) -#else - if (--shared_owners_ == -1) -#endif - delete static_cast<T *>(this); -} - -template <class T> -class ReferenceCountedBaseVirtual : public imp::shared_count { -public: - explicit ReferenceCountedBaseVirtual() : imp::shared_count(-1) {} - - ~ReferenceCountedBaseVirtual() override = default; - - void on_zero_shared() override; -}; - -template <class T> void ReferenceCountedBaseVirtual<T>::on_zero_shared() {} - -template <typename T> class IntrusiveSharingPtr { -public: - typedef T element_type; - - explicit IntrusiveSharingPtr() : ptr_(0) {} - - explicit IntrusiveSharingPtr(T *ptr) : ptr_(ptr) { add_shared(); } - - IntrusiveSharingPtr(const IntrusiveSharingPtr &rhs) : ptr_(rhs.ptr_) { - add_shared(); - } - - template <class X> - IntrusiveSharingPtr(const IntrusiveSharingPtr<X> &rhs) : ptr_(rhs.get()) { - add_shared(); - } - - IntrusiveSharingPtr &operator=(const IntrusiveSharingPtr &rhs) { - reset(rhs.get()); - return *this; - } - - template <class X> - IntrusiveSharingPtr &operator=(const IntrusiveSharingPtr<X> &rhs) { - reset(rhs.get()); - return *this; - } - - IntrusiveSharingPtr &operator=(T *ptr) { - reset(ptr); - return *this; - } - - ~IntrusiveSharingPtr() { - release_shared(); - ptr_ = nullptr; - } - - T &operator*() const { return *ptr_; } - - T *operator->() const { return ptr_; } - - T *get() const { return ptr_; } - - explicit operator bool() const { return ptr_ != 0; } - - void swap(IntrusiveSharingPtr &rhs) { - std::swap(ptr_, rhs.ptr_); -#if defined(ENABLE_SP_LOGGING) - track_sp(this, ptr_, use_count()); - track_sp(&rhs, rhs.ptr_, rhs.use_count()); -#endif - } - - void reset(T *ptr = nullptr) { IntrusiveSharingPtr(ptr).swap(*this); } - - long use_count() const { - if (ptr_) - return ptr_->use_count(); - return 0; - } - - bool unique() const { return use_count() == 1; } - -private: - element_type *ptr_; - - void add_shared() { - if (ptr_) { - ptr_->add_shared(); -#if defined(ENABLE_SP_LOGGING) - track_sp(this, ptr_, ptr_->use_count()); -#endif - } - } - void release_shared() { - if (ptr_) { -#if defined(ENABLE_SP_LOGGING) - track_sp(this, nullptr, ptr_->use_count() - 1); -#endif - ptr_->release_shared(); - } - } -}; - -template <class T, class U> -inline bool operator==(const IntrusiveSharingPtr<T> &lhs, - const IntrusiveSharingPtr<U> &rhs) { - return lhs.get() == rhs.get(); -} - -template <class T, class U> -inline bool operator!=(const IntrusiveSharingPtr<T> &lhs, - const IntrusiveSharingPtr<U> &rhs) { - return lhs.get() != rhs.get(); -} - -template <class T, class U> -inline bool operator==(const IntrusiveSharingPtr<T> &lhs, U *rhs) { - return lhs.get() == rhs; -} - -template <class T, class U> -inline bool operator!=(const IntrusiveSharingPtr<T> &lhs, U *rhs) { - return lhs.get() != rhs; -} - -template <class T, class U> -inline bool operator==(T *lhs, const IntrusiveSharingPtr<U> &rhs) { - return lhs == rhs.get(); -} - -template <class T, class U> -inline bool operator!=(T *lhs, const IntrusiveSharingPtr<U> &rhs) { - return lhs != rhs.get(); -} - -} // namespace lldb_private - -#endif // utility_SharingPtr_h_ diff --git a/lldb/include/lldb/Utility/Status.h b/lldb/include/lldb/Utility/Status.h index 36f52922c9bc..9babad18edc0 100644 --- a/lldb/include/lldb/Utility/Status.h +++ b/lldb/include/lldb/Utility/Status.h @@ -111,7 +111,7 @@ public: /// Set accessor from a kern_return_t. /// - /// Set accesssor for the error value to \a err and the error type to \c + /// Set accessor for the error value to \a err and the error type to \c /// MachKernel. /// /// \param[in] err @@ -123,9 +123,9 @@ public: int SetExpressionErrorWithFormat(lldb::ExpressionResults, const char *format, ...) __attribute__((format(printf, 3, 4))); - /// Set accesssor with an error value and type. + /// Set accessor with an error value and type. /// - /// Set accesssor for the error value to \a err and the error type to \a + /// Set accessor for the error value to \a err and the error type to \a /// type. /// /// \param[in] err @@ -217,4 +217,4 @@ template <> struct format_provider<lldb_private::Status> { } \ } while (0); -#endif // #ifndef LLDB_UTILITY_STATUS_H +#endif // LLDB_UTILITY_STATUS_H diff --git a/lldb/include/lldb/Utility/Stream.h b/lldb/include/lldb/Utility/Stream.h index 18a16a3461c1..e7f065a1fc7b 100644 --- a/lldb/include/lldb/Utility/Stream.h +++ b/lldb/include/lldb/Utility/Stream.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef liblldb_Stream_h_ -#define liblldb_Stream_h_ +#ifndef LLDB_UTILITY_STREAM_H +#define LLDB_UTILITY_STREAM_H #include "lldb/Utility/Flags.h" #include "lldb/lldb-defines.h" @@ -56,12 +56,13 @@ public: /// /// 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); + Stream(uint32_t flags, uint32_t addr_size, lldb::ByteOrder byte_order, + bool colors = false); /// Construct a default Stream, not binary, host byte order and host addr /// size. /// - Stream(); + Stream(bool colors = false); // FIXME: Streams should not be copyable. Stream(const Stream &other) : m_forwarder(*this) { (*this) = other; } @@ -270,10 +271,8 @@ public: /// optional string following the indentation spaces. /// /// \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); + /// A string to print following the indentation. + size_t Indent(llvm::StringRef s = ""); /// Decrement the current indentation level. void IndentLess(unsigned amount = 2); @@ -405,8 +404,10 @@ protected: } public: - RawOstreamForward(Stream &target) - : llvm::raw_ostream(/*unbuffered*/ true), m_target(target) {} + RawOstreamForward(Stream &target, bool colors = false) + : llvm::raw_ostream(/*unbuffered*/ true), m_target(target) { + enable_colors(colors); + } }; RawOstreamForward m_forwarder; }; @@ -461,4 +462,4 @@ void DumpAddressRange(llvm::raw_ostream &s, uint64_t lo_addr, uint64_t hi_addr, } // namespace lldb_private -#endif // liblldb_Stream_h_ +#endif // LLDB_UTILITY_STREAM_H diff --git a/lldb/include/lldb/Utility/StreamCallback.h b/lldb/include/lldb/Utility/StreamCallback.h index 6dbee67ecca2..d6d74fb84799 100644 --- a/lldb/include/lldb/Utility/StreamCallback.h +++ b/lldb/include/lldb/Utility/StreamCallback.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef liblldb_StreamCallback_h_ -#define liblldb_StreamCallback_h_ +#ifndef LLDB_UTILITY_STREAMCALLBACK_H +#define LLDB_UTILITY_STREAMCALLBACK_H #include "lldb/lldb-types.h" #include "llvm/Support/raw_ostream.h" @@ -32,4 +32,4 @@ private: } // namespace lldb_private -#endif // liblldb_StreamCallback_h +#endif // LLDB_UTILITY_STREAMCALLBACK_H diff --git a/lldb/include/lldb/Utility/StreamString.h b/lldb/include/lldb/Utility/StreamString.h index 581e102d4e80..b0be0f7dd76a 100644 --- a/lldb/include/lldb/Utility/StreamString.h +++ b/lldb/include/lldb/Utility/StreamString.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef liblldb_StreamString_h_ -#define liblldb_StreamString_h_ +#ifndef LLDB_UTILITY_STREAMSTRING_H +#define LLDB_UTILITY_STREAMSTRING_H #include "lldb/Utility/Stream.h" #include "lldb/lldb-enumerations.h" @@ -51,4 +51,4 @@ protected: } // namespace lldb_private -#endif // liblldb_StreamString_h_ +#endif // LLDB_UTILITY_STREAMSTRING_H diff --git a/lldb/include/lldb/Utility/StreamTee.h b/lldb/include/lldb/Utility/StreamTee.h index 92e94d4494f6..2995bc07f42a 100644 --- a/lldb/include/lldb/Utility/StreamTee.h +++ b/lldb/include/lldb/Utility/StreamTee.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef liblldb_StreamTee_h_ -#define liblldb_StreamTee_h_ +#ifndef LLDB_UTILITY_STREAMTEE_H +#define LLDB_UTILITY_STREAMTEE_H #include <limits.h> @@ -19,7 +19,8 @@ namespace lldb_private { class StreamTee : public Stream { public: - StreamTee() : Stream(), m_streams_mutex(), m_streams() {} + StreamTee(bool colors = false) + : Stream(colors), m_streams_mutex(), m_streams() {} StreamTee(lldb::StreamSP &stream_sp) : Stream(), m_streams_mutex(), m_streams() { @@ -137,4 +138,4 @@ protected: } // namespace lldb_private -#endif // liblldb_StreamTee_h_ +#endif // LLDB_UTILITY_STREAMTEE_H diff --git a/lldb/include/lldb/Utility/StringExtractor.h b/lldb/include/lldb/Utility/StringExtractor.h index 293fef2fbe6b..6a5bb24779a4 100644 --- a/lldb/include/lldb/Utility/StringExtractor.h +++ b/lldb/include/lldb/Utility/StringExtractor.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef utility_StringExtractor_h_ -#define utility_StringExtractor_h_ +#ifndef LLDB_UTILITY_STRINGEXTRACTOR_H +#define LLDB_UTILITY_STRINGEXTRACTOR_H #include "llvm/ADT/ArrayRef.h" #include "llvm/ADT/StringRef.h" @@ -26,7 +26,7 @@ public: virtual ~StringExtractor(); void Reset(llvm::StringRef str) { - m_packet = str; + m_packet = std::string(str); m_index = 0; } @@ -118,4 +118,4 @@ protected: uint64_t m_index; }; -#endif // utility_StringExtractor_h_ +#endif // LLDB_UTILITY_STRINGEXTRACTOR_H diff --git a/lldb/include/lldb/Utility/StringLexer.h b/lldb/include/lldb/Utility/StringLexer.h index 533fd4fb896e..52f98e860da2 100644 --- a/lldb/include/lldb/Utility/StringLexer.h +++ b/lldb/include/lldb/Utility/StringLexer.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef utility_StringLexer_h_ -#define utility_StringLexer_h_ +#ifndef LLDB_UTILITY_STRINGLEXER_H +#define LLDB_UTILITY_STRINGLEXER_H #include <initializer_list> #include <string> @@ -53,4 +53,4 @@ private: } // namespace lldb_private -#endif // #ifndef utility_StringLexer_h_ +#endif // LLDB_UTILITY_STRINGLEXER_H diff --git a/lldb/include/lldb/Utility/StringList.h b/lldb/include/lldb/Utility/StringList.h index 0b1d955678b3..591a15861593 100644 --- a/lldb/include/lldb/Utility/StringList.h +++ b/lldb/include/lldb/Utility/StringList.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef liblldb_StringList_h_ -#define liblldb_StringList_h_ +#ifndef LLDB_UTILITY_STRINGLIST_H +#define LLDB_UTILITY_STRINGLIST_H #include "llvm/ADT/StringRef.h" @@ -132,4 +132,4 @@ private: } // namespace lldb_private -#endif // liblldb_StringList_h_ +#endif // LLDB_UTILITY_STRINGLIST_H diff --git a/lldb/include/lldb/Utility/StructuredData.h b/lldb/include/lldb/Utility/StructuredData.h index 01b14fc3d4d3..14c82e669676 100644 --- a/lldb/include/lldb/Utility/StructuredData.h +++ b/lldb/include/lldb/Utility/StructuredData.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef liblldb_StructuredData_h_ -#define liblldb_StructuredData_h_ +#ifndef LLDB_UTILITY_STRUCTUREDDATA_H +#define LLDB_UTILITY_STRUCTUREDDATA_H #include "llvm/ADT/StringRef.h" #include "llvm/Support/JSON.h" @@ -339,7 +339,7 @@ public: explicit String(llvm::StringRef S) : Object(lldb::eStructuredDataTypeString), m_value(S) {} - void SetValue(llvm::StringRef S) { m_value = S; } + void SetValue(llvm::StringRef S) { m_value = std::string(S); } llvm::StringRef GetValue() { return m_value; } @@ -553,4 +553,4 @@ public: } // namespace lldb_private -#endif // liblldb_StructuredData_h_ +#endif // LLDB_UTILITY_STRUCTUREDDATA_H diff --git a/lldb/include/lldb/Utility/TildeExpressionResolver.h b/lldb/include/lldb/Utility/TildeExpressionResolver.h index 196fdfcf9ab4..3253767ffd75 100644 --- a/lldb/include/lldb/Utility/TildeExpressionResolver.h +++ b/lldb/include/lldb/Utility/TildeExpressionResolver.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef LLDB_UTILITY_TILDE_EXPRESSION_RESOLVER_H -#define LLDB_UTILITY_TILDE_EXPRESSION_RESOLVER_H +#ifndef LLDB_UTILITY_TILDEEXPRESSIONRESOLVER_H +#define LLDB_UTILITY_TILDEEXPRESSIONRESOLVER_H #include "llvm/ADT/StringRef.h" #include "llvm/ADT/StringSet.h" @@ -61,4 +61,4 @@ public: }; } -#endif // #ifndef LLDB_UTILITY_TILDE_EXPRESSION_RESOLVER_H +#endif // LLDB_UTILITY_TILDEEXPRESSIONRESOLVER_H diff --git a/lldb/include/lldb/Utility/Timeout.h b/lldb/include/lldb/Utility/Timeout.h index 202b747fd480..80e201515577 100644 --- a/lldb/include/lldb/Utility/Timeout.h +++ b/lldb/include/lldb/Utility/Timeout.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef liblldb_Timeout_h_ -#define liblldb_Timeout_h_ +#ifndef LLDB_UTILITY_TIMEOUT_H +#define LLDB_UTILITY_TIMEOUT_H #include "llvm/ADT/Optional.h" #include "llvm/Support/Chrono.h" @@ -67,4 +67,4 @@ struct format_provider<lldb_private::Timeout<Ratio>, void> { }; } -#endif // liblldb_Timeout_h_ +#endif // LLDB_UTILITY_TIMEOUT_H diff --git a/lldb/include/lldb/Utility/Timer.h b/lldb/include/lldb/Utility/Timer.h index ad9421a75b15..f97315b2db0f 100644 --- a/lldb/include/lldb/Utility/Timer.h +++ b/lldb/include/lldb/Utility/Timer.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef liblldb_Timer_h_ -#define liblldb_Timer_h_ +#ifndef LLDB_UTILITY_TIMER_H +#define LLDB_UTILITY_TIMER_H #include "lldb/lldb-defines.h" #include "llvm/Support/Chrono.h" @@ -34,7 +34,8 @@ public: std::atomic<uint64_t> m_count; std::atomic<Category *> m_next; - DISALLOW_COPY_AND_ASSIGN(Category); + Category(const Category &) = delete; + const Category &operator=(const Category &) = delete; }; /// Default constructor. @@ -66,9 +67,10 @@ protected: static std::atomic<unsigned> g_display_depth; private: - DISALLOW_COPY_AND_ASSIGN(Timer); + Timer(const Timer &) = delete; + const Timer &operator=(const Timer &) = delete; }; } // namespace lldb_private -#endif // liblldb_Timer_h_ +#endif // LLDB_UTILITY_TIMER_H diff --git a/lldb/include/lldb/Utility/TraceOptions.h b/lldb/include/lldb/Utility/TraceOptions.h index d5e21ccd8ba3..97aad33899be 100644 --- a/lldb/include/lldb/Utility/TraceOptions.h +++ b/lldb/include/lldb/Utility/TraceOptions.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef liblldb_TraceOptions_h_ -#define liblldb_TraceOptions_h_ +#ifndef LLDB_UTILITY_TRACEOPTIONS_H +#define LLDB_UTILITY_TRACEOPTIONS_H #include "lldb/lldb-defines.h" #include "lldb/lldb-enumerations.h" @@ -57,4 +57,4 @@ private: }; } -#endif // liblldb_TraceOptions_h_ +#endif // LLDB_UTILITY_TRACEOPTIONS_H diff --git a/lldb/include/lldb/Utility/UUID.h b/lldb/include/lldb/Utility/UUID.h index 0284357be44a..5327719094c0 100644 --- a/lldb/include/lldb/Utility/UUID.h +++ b/lldb/include/lldb/Utility/UUID.h @@ -63,18 +63,13 @@ public: std::string GetAsString(llvm::StringRef separator = "-") const; - size_t SetFromStringRef(llvm::StringRef str, uint32_t num_uuid_bytes = 16); + bool SetFromStringRef(llvm::StringRef str); // 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. + bool SetFromOptionalStringRef(llvm::StringRef str); + + /// Decode as many UUID bytes as possible from the C string \a cstr. /// /// \param[in] str /// An llvm::StringRef that points at a UUID string value (no leading @@ -88,8 +83,7 @@ public: /// The original string, with all decoded bytes removed. static llvm::StringRef DecodeUUIDBytesFromString(llvm::StringRef str, - llvm::SmallVectorImpl<uint8_t> &uuid_bytes, - uint32_t num_uuid_bytes = 16); + llvm::SmallVectorImpl<uint8_t> &uuid_bytes); private: UUID(llvm::ArrayRef<uint8_t> bytes) : m_bytes(bytes.begin(), bytes.end()) {} diff --git a/lldb/include/lldb/Utility/UriParser.h b/lldb/include/lldb/Utility/UriParser.h index 4a3f01230e1a..6a64c3d747b5 100644 --- a/lldb/include/lldb/Utility/UriParser.h +++ b/lldb/include/lldb/Utility/UriParser.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef utility_UriParser_h_ -#define utility_UriParser_h_ +#ifndef LLDB_UTILITY_URIPARSER_H +#define LLDB_UTILITY_URIPARSER_H #include "llvm/ADT/StringRef.h" @@ -28,4 +28,4 @@ public: }; } -#endif // utility_UriParser_h_ +#endif // LLDB_UTILITY_URIPARSER_H diff --git a/lldb/include/lldb/Utility/UserID.h b/lldb/include/lldb/Utility/UserID.h index 2dc5cdb23d0e..9fc6985a5a99 100644 --- a/lldb/include/lldb/Utility/UserID.h +++ b/lldb/include/lldb/Utility/UserID.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef liblldb_UserID_h_ -#define liblldb_UserID_h_ +#ifndef LLDB_UTILITY_USERID_H +#define LLDB_UTILITY_USERID_H #include "lldb/lldb-defines.h" #include "lldb/lldb-types.h" @@ -90,4 +90,4 @@ Stream &operator<<(Stream &strm, const UserID &uid); } // namespace lldb_private -#endif // liblldb_UserID_h_ +#endif // LLDB_UTILITY_USERID_H diff --git a/lldb/include/lldb/Utility/UserIDResolver.h b/lldb/include/lldb/Utility/UserIDResolver.h index bca82a11b660..e0f7b69cc075 100644 --- a/lldb/include/lldb/Utility/UserIDResolver.h +++ b/lldb/include/lldb/Utility/UserIDResolver.h @@ -53,4 +53,4 @@ private: } // namespace lldb_private -#endif // #ifndef LLDB_HOST_USERIDRESOLVER_H +#endif // LLDB_UTILITY_USERIDRESOLVER_H diff --git a/lldb/include/lldb/Utility/VASPrintf.h b/lldb/include/lldb/Utility/VASPrintf.h index 582645fd2292..a4b5f7ddae2c 100644 --- a/lldb/include/lldb/Utility/VASPrintf.h +++ b/lldb/include/lldb/Utility/VASPrintf.h @@ -17,4 +17,4 @@ namespace lldb_private { bool VASprintf(llvm::SmallVectorImpl<char> &buf, const char *fmt, va_list args); } -#endif // #ifdef LLDB_UTILITY_VASPRINTF_H +#endif // LLDB_UTILITY_VASPRINTF_H diff --git a/lldb/include/lldb/Utility/VMRange.h b/lldb/include/lldb/Utility/VMRange.h index 72f859b67582..4b01cd86da2c 100644 --- a/lldb/include/lldb/Utility/VMRange.h +++ b/lldb/include/lldb/Utility/VMRange.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef liblldb_VMRange_h_ -#define liblldb_VMRange_h_ +#ifndef LLDB_UTILITY_VMRANGE_H +#define LLDB_UTILITY_VMRANGE_H #include "lldb/lldb-types.h" #include "llvm/Support/raw_ostream.h" @@ -101,4 +101,4 @@ bool operator>=(const VMRange &lhs, const VMRange &rhs); } // namespace lldb_private -#endif // liblldb_VMRange_h_ +#endif // LLDB_UTILITY_VMRANGE_H diff --git a/lldb/include/lldb/Utility/XcodeSDK.h b/lldb/include/lldb/Utility/XcodeSDK.h new file mode 100644 index 000000000000..307fe7f46798 --- /dev/null +++ b/lldb/include/lldb/Utility/XcodeSDK.h @@ -0,0 +1,96 @@ +//===-- XcodeSDK.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_SDK_H +#define LLDB_UTILITY_SDK_H + +#include "lldb/lldb-forward.h" +#include "llvm/ADT/StringRef.h" +#include "llvm/Support/VersionTuple.h" +#include <tuple> + +namespace llvm { +class Triple; +} + +namespace lldb_private { + +/// An abstraction for Xcode-style SDKs that works like \ref ArchSpec. +class XcodeSDK { + std::string m_name; + +public: + /// Different types of Xcode SDKs. + enum Type : int { + MacOSX = 0, + iPhoneSimulator, + iPhoneOS, + AppleTVSimulator, + AppleTVOS, + WatchSimulator, + watchOS, + bridgeOS, + Linux, + unknown = -1 + }; + static constexpr int numSDKTypes = Linux + 1; + + /// A parsed SDK directory name. + struct Info { + Type type = unknown; + llvm::VersionTuple version; + bool internal = false; + + Info() = default; + bool operator<(const Info &other) const; + bool operator==(const Info &other) const; + }; + + + /// Default constructor, constructs an empty string. + XcodeSDK() = default; + /// Construct an XcodeSDK object from a specification. + XcodeSDK(Info info); + /// Initialize an XcodeSDK object with an SDK name. The SDK name is the last + /// directory component of a path one would pass to clang's -isysroot + /// parameter. For example, "MacOSX.10.14.sdk". + XcodeSDK(std::string &&name) : m_name(std::move(name)) {} + static XcodeSDK GetAnyMacOS() { return XcodeSDK("MacOSX.sdk"); } + + /// The merge function follows a strict order to maintain monotonicity: + /// 1. SDK with the higher SDKType wins. + /// 2. The newer SDK wins. + void Merge(XcodeSDK other); + + XcodeSDK &operator=(XcodeSDK other); + XcodeSDK(const XcodeSDK&) = default; + bool operator==(XcodeSDK other); + + /// Return parsed SDK type and version number. + Info Parse() const; + bool IsAppleInternalSDK() const; + llvm::VersionTuple GetVersion() const; + Type GetType() const; + llvm::StringRef GetString() const; + /// Whether this Xcode SDK supports Swift. + bool SupportsSwift() const; + + /// Whether LLDB feels confident importing Clang modules from this SDK. + static bool SDKSupportsModules(Type type, llvm::VersionTuple version); + static bool SDKSupportsModules(Type desired_type, const FileSpec &sdk_path); + /// Return the canonical SDK name, such as "macosx" for the macOS SDK. + static std::string GetCanonicalName(Info info); + /// Return the best-matching SDK type for a specific triple. + static XcodeSDK::Type GetSDKTypeForTriple(const llvm::Triple &triple); + + static std::string FindXcodeContentsDirectoryInPath(llvm::StringRef path); +}; + +} // namespace lldb_private + +#endif diff --git a/lldb/include/lldb/lldb-defines.h b/lldb/include/lldb/lldb-defines.h index b87964403f7e..fea8079779a1 100644 --- a/lldb/include/lldb/lldb-defines.h +++ b/lldb/include/lldb/lldb-defines.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef LLDB_lldb_defines_h_ -#define LLDB_lldb_defines_h_ +#ifndef LLDB_LLDB_DEFINES_H +#define LLDB_LLDB_DEFINES_H #include "lldb/lldb-types.h" @@ -133,15 +133,4 @@ #define UNUSED_IF_ASSERT_DISABLED(x) ((void)(x)) -#if defined(__cplusplus) - -/// \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 - -#endif // #if defined(__cplusplus) - -#endif // LLDB_lldb_defines_h_ +#endif // LLDB_LLDB_DEFINES_H diff --git a/lldb/include/lldb/lldb-enumerations.h b/lldb/include/lldb/lldb-enumerations.h index 8cbb459ee1ea..b3e8d604913f 100644 --- a/lldb/include/lldb/lldb-enumerations.h +++ b/lldb/include/lldb/lldb-enumerations.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef LLDB_lldb_enumerations_h_ -#define LLDB_lldb_enumerations_h_ +#ifndef LLDB_LLDB_ENUMERATIONS_H +#define LLDB_LLDB_ENUMERATIONS_H #include <type_traits> @@ -269,7 +269,8 @@ enum ExpressionResults { eExpressionHitBreakpoint, eExpressionTimedOut, eExpressionResultUnavailable, - eExpressionStoppedForDebug + eExpressionStoppedForDebug, + eExpressionThreadVanished }; enum SearchDepth { @@ -590,6 +591,7 @@ enum CommandArgumentType { eArgTypeWatchType, eArgRawInput, eArgTypeCommand, + eArgTypeColumnNum, eArgTypeLastArg // Always keep this entry as the last entry in this // enumeration!! }; @@ -694,6 +696,7 @@ enum SectionType { eSectionTypeDWARFDebugRngListsDwo, eSectionTypeDWARFDebugLocDwo, eSectionTypeDWARFDebugLocListsDwo, + eSectionTypeDWARFDebugTuIndex, }; FLAGS_ENUM(EmulateInstructionOptions){ @@ -1079,6 +1082,20 @@ enum TypeSummaryCapping { eTypeSummaryCapped = true, eTypeSummaryUncapped = false }; + +/// The result from a command interpreter run. +enum CommandInterpreterResult { + /// Command interpreter finished successfully. + eCommandInterpreterResultSuccess, + /// Stopped because the corresponding option was set and the inferior + /// crashed. + eCommandInterpreterResultInferiorCrash, + /// Stopped because the corresponding option was set and a command returned + /// an error. + eCommandInterpreterResultCommandError, + /// Stopped because quit was requested. + eCommandInterpreterResultQuitRequested, +}; } // namespace lldb -#endif // LLDB_lldb_enumerations_h_ +#endif // LLDB_LLDB_ENUMERATIONS_H diff --git a/lldb/include/lldb/lldb-forward.h b/lldb/include/lldb/lldb-forward.h index d2371f94f4b8..4fd2a07dd616 100644 --- a/lldb/include/lldb/lldb-forward.h +++ b/lldb/include/lldb/lldb-forward.h @@ -6,25 +6,26 @@ // //===----------------------------------------------------------------------===// -#ifndef LLDB_lldb_forward_h_ -#define LLDB_lldb_forward_h_ +#ifndef LLDB_LLDB_FORWARD_H +#define LLDB_LLDB_FORWARD_H #if defined(__cplusplus) -#include "lldb/Utility/SharingPtr.h" +#include <memory> // lldb forward declarations namespace lldb_private { class ABI; +class ASTResultSynthesizer; +class ASTStructExtractor; class Address; class AddressRange; class AddressResolver; class ArchSpec; -class ArmUnwindInfo; +class Architecture; class Args; -class ASTResultSynthesizer; -class ASTStructExtractor; +class ArmUnwindInfo; class Baton; class Block; class Breakpoint; @@ -44,16 +45,8 @@ class BreakpointSiteList; class BroadcastEventSpec; class Broadcaster; class BroadcasterManager; +class CXXSyntheticChildren; class CallFrameInfo; -class ClangASTContext; -class ClangASTImporter; -class ClangASTMetadata; -class ClangASTSource; -class ClangExpressionDeclMap; -class ClangExpressionParser; -class ClangExpressionVariable; -class ClangModulesDeclVendor; -class ClangPersistentVariables; class CommandInterpreter; class CommandInterpreterRunOptions; class CommandObject; @@ -61,15 +54,13 @@ class CommandObjectMultiword; class CommandReturnObject; class Communication; class CompactUnwindInfo; -struct CompilerContext; +class CompileUnit; class CompilerDecl; class CompilerDeclContext; class CompilerType; -class CompileUnit; class Connection; class ConnectionFileDescriptor; class ConstString; -class CXXSyntheticChildren; class DWARFCallFrameInfo; class DWARFDataExtractor; class DWARFExpression; @@ -85,7 +76,7 @@ class DynamicCheckerFunctions; class DynamicLoader; class Editline; class EmulateInstruction; -class Status; +class Environment; class EvaluateExpressionOptions; class Event; class EventData; @@ -94,26 +85,26 @@ class ExecutionContext; class ExecutionContextRef; class ExecutionContextScope; class Expression; +class ExpressionTypeSystemHelper; class ExpressionVariable; class ExpressionVariableList; -class ExpressionTypeSystemHelper; class File; class FileSpec; class FileSpecList; class Flags; -class TypeCategoryImpl; class FormatManager; class FormattersMatchCandidate; class FuncUnwinders; class Function; +class FunctionCaller; class FunctionInfo; +class IOHandler; +class IOObject; +class IRExecutionUnit; class InlineFunctionInfo; class Instruction; class InstructionList; class InstrumentationRuntime; -class IOHandler; -class IOObject; -class IRExecutionUnit; class JITLoader; class JITLoaderList; class Language; @@ -131,15 +122,13 @@ class Module; class ModuleList; class ModuleSpec; class ModuleSpecList; -struct NameSearchContext; class ObjectContainer; -class OptionGroup; -class OptionGroupOptions; -class OptionGroupPlatform; class ObjectFile; class ObjectFileJITDelegate; class OperatingSystem; -class Options; +class OptionGroup; +class OptionGroupOptions; +class OptionGroupPlatform; class OptionValue; class OptionValueArch; class OptionValueArgs; @@ -151,8 +140,8 @@ class OptionValueEnumeration; class OptionValueFileSpec; class OptionValueFileSpecList; class OptionValueFormat; -class OptionValueLanguage; class OptionValueFormatEntity; +class OptionValueLanguage; class OptionValuePathMappings; class OptionValueProperties; class OptionValueRegex; @@ -160,31 +149,32 @@ class OptionValueSInt64; class OptionValueString; class OptionValueUInt64; class OptionValueUUID; +class Options; class PathMappingList; -class FunctionCaller; class PersistentExpressionState; class Platform; class Process; class ProcessAttachInfo; -class ProcessModID; class ProcessInfo; class ProcessInstanceInfo; -class ProcessInstanceInfoList; class ProcessInstanceInfoMatch; class ProcessLaunchInfo; +class ProcessModID; class Property; -struct PropertyDefinition; +class Queue; +class QueueImpl; +class QueueItem; +class REPL; class RecognizedStackFrame; class RegisterCheckpoint; class RegisterContext; class RegisterValue; class RegularExpression; -class REPL; class RichManglingContext; class Scalar; class ScriptInterpreter; class ScriptInterpreterLocker; -struct ScriptSummaryFormat; +class ScriptedSyntheticChildren; class SearchFilter; class Section; class SectionList; @@ -198,21 +188,17 @@ class StackFrameList; class StackFrameRecognizer; class StackFrameRecognizerManager; class StackID; +class Status; class StopInfo; class Stoppoint; class StoppointCallbackContext; class StoppointLocation; class Stream; -template <unsigned N> class StreamBuffer; class StreamFile; class StreamString; class StringList; -struct StringSummaryFormat; class StructuredDataImpl; class StructuredDataPlugin; -class SystemRuntime; -class TypeSummaryImpl; -class TypeSummaryOptions; class Symbol; class SymbolContext; class SymbolContextList; @@ -224,12 +210,7 @@ class SymbolVendor; class Symtab; class SyntheticChildren; class SyntheticChildrenFrontEnd; -class TypeFilterImpl; -class TypeSystem; -class ScriptedSyntheticChildren; -class Queue; -class QueueItem; -class QueueImpl; +class SystemRuntime; class Target; class TargetList; class TargetProperties; @@ -249,17 +230,22 @@ class ThreadSpec; class TraceOptions; class Type; class TypeAndOrName; +class TypeCategoryImpl; class TypeCategoryMap; +class TypeEnumMemberImpl; +class TypeEnumMemberListImpl; +class TypeFilterImpl; +class TypeFormatImpl; class TypeImpl; class TypeList; -class TypeMap; class TypeListImpl; -class TypeMemberImpl; +class TypeMap; class TypeMemberFunctionImpl; -class TypeEnumMemberImpl; -class TypeEnumMemberListImpl; -class TypeFormatImpl; +class TypeMemberImpl; class TypeNameSpecifierImpl; +class TypeSummaryImpl; +class TypeSummaryOptions; +class TypeSystem; class UUID; class UnixSignals; class Unwind; @@ -283,7 +269,12 @@ class VariableList; class Watchpoint; class WatchpointList; class WatchpointOptions; +struct CompilerContext; struct LineEntry; +struct PropertyDefinition; +struct ScriptSummaryFormat; +struct StringSummaryFormat; +template <unsigned N> class StreamBuffer; } // namespace lldb_private @@ -299,17 +290,12 @@ 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::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; typedef std::weak_ptr<lldb_private::BroadcasterManager> BroadcasterManagerWP; -typedef std::unique_ptr<lldb_private::ClangASTContext> ClangASTContextUP; -typedef std::shared_ptr<lldb_private::ClangASTImporter> ClangASTImporterSP; -typedef std::unique_ptr<lldb_private::ClangModulesDeclVendor> - ClangModulesDeclVendorUP; -typedef std::unique_ptr<lldb_private::ClangPersistentVariables> - ClangPersistentVariablesUP; typedef std::shared_ptr<lldb_private::UserExpression> UserExpressionSP; typedef std::shared_ptr<lldb_private::CommandObject> CommandObjectSP; typedef std::shared_ptr<lldb_private::Communication> CommunicationSP; @@ -467,7 +453,7 @@ typedef std::weak_ptr<lldb_private::UnixSignals> UnixSignalsWP; typedef std::shared_ptr<lldb_private::UnwindAssembly> UnwindAssemblySP; typedef std::shared_ptr<lldb_private::UnwindPlan> UnwindPlanSP; typedef std::shared_ptr<lldb_private::UtilityFunction> UtilityFunctionSP; -typedef lldb_private::SharingPtr<lldb_private::ValueObject> ValueObjectSP; +typedef std::shared_ptr<lldb_private::ValueObject> ValueObjectSP; typedef std::shared_ptr<lldb_private::Value> ValueSP; typedef std::shared_ptr<lldb_private::ValueList> ValueListSP; typedef std::shared_ptr<lldb_private::Variable> VariableSP; @@ -477,13 +463,5 @@ typedef std::shared_ptr<lldb_private::Watchpoint> WatchpointSP; } // namespace lldb -// llvm forward declarations -namespace llvm { - -struct ItaniumPartialDemangler; -class StringRef; - -} // namespace llvm - #endif // #if defined(__cplusplus) -#endif // LLDB_lldb_forward_h_ +#endif // LLDB_LLDB_FORWARD_H diff --git a/lldb/include/lldb/lldb-private-defines.h b/lldb/include/lldb/lldb-private-defines.h index 737d9ef2434e..d66e6ef1518d 100644 --- a/lldb/include/lldb/lldb-private-defines.h +++ b/lldb/include/lldb/lldb-private-defines.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef liblldb_lldb_private_defines_h_ -#define liblldb_lldb_private_defines_h_ +#ifndef LLDB_LLDB_PRIVATE_DEFINES_H +#define LLDB_LLDB_PRIVATE_DEFINES_H #if defined(__cplusplus) @@ -33,4 +33,4 @@ #endif // #if defined(__cplusplus) -#endif // liblldb_lldb_private_defines_h_ +#endif // LLDB_LLDB_PRIVATE_DEFINES_H diff --git a/lldb/include/lldb/lldb-private-enumerations.h b/lldb/include/lldb/lldb-private-enumerations.h index 9b7879c05f9e..7009d1b4fba7 100644 --- a/lldb/include/lldb/lldb-private-enumerations.h +++ b/lldb/include/lldb/lldb-private-enumerations.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef LLDB_lldb_private_enumerations_h_ -#define LLDB_lldb_private_enumerations_h_ +#ifndef LLDB_LLDB_PRIVATE_ENUMERATIONS_H +#define LLDB_LLDB_PRIVATE_ENUMERATIONS_H #include "llvm/ADT/StringRef.h" #include "llvm/Support/FormatProviders.h" @@ -148,18 +148,6 @@ enum ExecutionPolicy { eExecutionPolicyTopLevel // used for top-level code }; -// Ways that the FormatManager picks a particular format for a type -enum FormatterChoiceCriterion { - eFormatterChoiceCriterionDirectChoice = 0x00000000, - eFormatterChoiceCriterionStrippedPointerReference = 0x00000001, - eFormatterChoiceCriterionNavigatedTypedefs = 0x00000002, - eFormatterChoiceCriterionRegularExpressionSummary = 0x00000004, - eFormatterChoiceCriterionRegularExpressionFilter = 0x00000004, - eFormatterChoiceCriterionLanguagePlugin = 0x00000008, - eFormatterChoiceCriterionStrippedBitField = 0x00000010, - eFormatterChoiceCriterionWentToStaticValue = 0x00000020 -}; - // Synchronicity behavior of scripted commands enum ScriptedCommandSynchronicity { eScriptedCommandSynchronicitySynchronous, @@ -267,4 +255,4 @@ template <> struct format_provider<lldb_private::Vote> { }; } -#endif // LLDB_lldb_private_enumerations_h_ +#endif // LLDB_LLDB_PRIVATE_ENUMERATIONS_H diff --git a/lldb/include/lldb/lldb-private-forward.h b/lldb/include/lldb/lldb-private-forward.h index 330070745adb..b5944cba8f27 100644 --- a/lldb/include/lldb/lldb-private-forward.h +++ b/lldb/include/lldb/lldb-private-forward.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef LLDB_lldb_private_forward_h_ -#define LLDB_lldb_private_forward_h_ +#ifndef LLDB_LLDB_PRIVATE_FORWARD_H +#define LLDB_LLDB_PRIVATE_FORWARD_H namespace lldb_private { // forward decls. @@ -18,4 +18,4 @@ class ResumeActionList; class UnixSignals; } -#endif // #ifndef LLDB_lldb_private_forward_h_ +#endif // LLDB_LLDB_PRIVATE_FORWARD_H diff --git a/lldb/include/lldb/lldb-private-interfaces.h b/lldb/include/lldb/lldb-private-interfaces.h index 27a2c4c3f27f..1568e7a3cb51 100644 --- a/lldb/include/lldb/lldb-private-interfaces.h +++ b/lldb/include/lldb/lldb-private-interfaces.h @@ -6,21 +6,23 @@ // //===----------------------------------------------------------------------===// -#ifndef liblldb_lldb_private_interfaces_h_ -#define liblldb_lldb_private_interfaces_h_ +#ifndef LLDB_LLDB_PRIVATE_INTERFACES_H +#define LLDB_LLDB_PRIVATE_INTERFACES_H #if defined(__cplusplus) #include "lldb/lldb-enumerations.h" #include "lldb/lldb-forward.h" -#include "lldb/lldb-types.h" - #include "lldb/lldb-private-enumerations.h" - +#include "lldb/lldb-types.h" +#include <memory> #include <set> namespace lldb_private { -typedef lldb::ABISP (*ABICreateInstance)(lldb::ProcessSP process_sp, const ArchSpec &arch); +typedef lldb::ABISP (*ABICreateInstance)(lldb::ProcessSP process_sp, + const ArchSpec &arch); +typedef std::unique_ptr<Architecture> (*ArchitectureCreateInstance)( + const ArchSpec &arch); typedef Disassembler *(*DisassemblerCreateInstance)(const ArchSpec &arch, const char *flavor); typedef DynamicLoader *(*DynamicLoaderCreateInstance)(Process *process, @@ -107,4 +109,4 @@ typedef void (*DebuggerInitializeCallback)(Debugger &debugger); #endif // #if defined(__cplusplus) -#endif // liblldb_lldb_private_interfaces_h_ +#endif // LLDB_LLDB_PRIVATE_INTERFACES_H diff --git a/lldb/include/lldb/lldb-private-types.h b/lldb/include/lldb/lldb-private-types.h index bff471177214..fb8c2db2e21c 100644 --- a/lldb/include/lldb/lldb-private-types.h +++ b/lldb/include/lldb/lldb-private-types.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef liblldb_lldb_private_types_h_ -#define liblldb_lldb_private_types_h_ +#ifndef LLDB_LLDB_PRIVATE_TYPES_H +#define LLDB_LLDB_PRIVATE_TYPES_H #if defined(__cplusplus) @@ -28,38 +28,42 @@ 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. +/// 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 - uint32_t byte_size; // Size in bytes of the register - uint32_t byte_offset; // The byte offset in the register context data where - // this register's value is found. - // This is optional, and can be 0 if a particular RegisterContext does not - // need to address its registers by byte offset. - lldb::Encoding encoding; // Encoding of the register bits - lldb::Format format; // Default display format - uint32_t kinds[lldb::kNumRegisterKinds]; // Holds all of the various register - // numbers for all register kinds - uint32_t *value_regs; // List of registers (terminated with - // LLDB_INVALID_REGNUM). If this value is not null, - // all registers in this list will be read first, at - // which point the value for this register will be - // valid. For example, the value list for ah would be - // eax (x86) or rax (x64). - uint32_t *invalidate_regs; // List of registers (terminated with - // LLDB_INVALID_REGNUM). If this value is not - // null, all registers in this list will be - // invalidated when the value of this register - // changes. For example, the invalidate list for - // eax would be rax ax, ah, and al. - const uint8_t *dynamic_size_dwarf_expr_bytes; // A DWARF expression that when - // evaluated gives - // the byte size of this register. - size_t dynamic_size_dwarf_len; // The length of the DWARF expression in bytes - // in the dynamic_size_dwarf_expr_bytes - // member. + /// Name of this register, can't be NULL. + const char *name; + /// Alternate name of this register, can be NULL. + const char *alt_name; + /// Size in bytes of the register. + uint32_t byte_size; + /// The byte offset in the register context data where this register's + /// value is found. + /// This is optional, and can be 0 if a particular RegisterContext does not + /// need to address its registers by byte offset. + uint32_t byte_offset; + /// Encoding of the register bits. + lldb::Encoding encoding; + /// Default display format. + lldb::Format format; + /// Holds all of the various register numbers for all register kinds. + uint32_t kinds[lldb::kNumRegisterKinds]; // + /// List of registers (terminated with LLDB_INVALID_REGNUM). If this value is + /// not null, all registers in this list will be read first, at which point + /// the value for this register will be valid. For example, the value list + /// for ah would be eax (x86) or rax (x64). + uint32_t *value_regs; // + /// List of registers (terminated with LLDB_INVALID_REGNUM). If this value is + /// not null, all registers in this list will be invalidated when the value of + /// this register changes. For example, the invalidate list for eax would be + /// rax ax, ah, and al. + uint32_t *invalidate_regs; + /// A DWARF expression that when evaluated gives the byte size of this + /// register. + const uint8_t *dynamic_size_dwarf_expr_bytes; + /// The length of the DWARF expression in bytes in the + /// dynamic_size_dwarf_expr_bytes member. + size_t dynamic_size_dwarf_len; llvm::ArrayRef<uint8_t> data(const uint8_t *context_base) const { return llvm::ArrayRef<uint8_t>(context_base + byte_offset, byte_size); @@ -71,17 +75,20 @@ struct RegisterInfo { } }; -// Registers are grouped into register sets +/// 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 - size_t num_registers; // The number of registers in REGISTERS array below - const uint32_t *registers; // An array of register indices in this set. The - // values in this array are - // *indices* (not register numbers) into a particular RegisterContext's - // register array. For example, if eax is defined at index 4 for a - // particular RegisterContext, eax would be included in this RegisterSet by - // adding the value 4. Not by adding the value lldb_eax_i386. + /// Name of this register set. + const char *name; + /// A short name for this register set. + const char *short_name; + /// The number of registers in REGISTERS array below. + size_t num_registers; + /// An array of register indices in this set. The values in this array are + /// *indices* (not register numbers) into a particular RegisterContext's + /// register array. For example, if eax is defined at index 4 for a + /// particular RegisterContext, eax would be included in this RegisterSet by + /// adding the value 4. Not by adding the value lldb_eax_i386. + const uint32_t *registers; }; struct OptionEnumValueElement { @@ -101,22 +108,30 @@ struct OptionValidator { }; struct OptionDefinition { - uint32_t usage_mask; // Used to mark options that can be used together. If (1 - // << n & usage_mask) != 0 - // then this option belongs to option set n. - bool required; // This option is required (in the current usage level) - const char *long_option; // Full name for this option. - int short_option; // Single character for this option. - int option_has_arg; // no_argument, required_argument or optional_argument - OptionValidator *validator; // If non-NULL, option is valid iff - // |validator->IsValid()|, otherwise always valid. - OptionEnumValues enum_values; // If not empty, an array of enum values. - uint32_t completion_type; // Cookie the option class can use to do define the - // argument completion. - lldb::CommandArgumentType argument_type; // Type of argument this option takes - const char *usage_text; // Full text explaining what this options does and - // what (if any) argument to - // pass it. + /// Used to mark options that can be used together. If + /// `(1 << n & usage_mask) != 0` then this option belongs to option set n. + uint32_t usage_mask; + /// This option is required (in the current usage level). + bool required; + /// Full name for this option. + const char *long_option; + /// Single character for this option. + int short_option; + /// no_argument, required_argument or optional_argument + int option_has_arg; + /// If non-NULL, option is valid iff |validator->IsValid()|, otherwise + /// always valid. + OptionValidator *validator; + /// If not empty, an array of enum values. + OptionEnumValues enum_values; + /// The kind of completion for this option. + /// Contains values of the CommandCompletions::CommonCompletionTypes enum. + uint32_t completion_type; + /// Type of argument this option takes. + lldb::CommandArgumentType argument_type; + /// Full text explaining what this options does and what (if any) argument to + /// pass it. + const char *usage_text; }; typedef struct type128 { uint64_t x[2]; } type128; @@ -126,4 +141,4 @@ typedef struct type256 { uint64_t x[4]; } type256; #endif // #if defined(__cplusplus) -#endif // liblldb_lldb_private_types_h_ +#endif // LLDB_LLDB_PRIVATE_TYPES_H diff --git a/lldb/include/lldb/lldb-private.h b/lldb/include/lldb/lldb-private.h index 24954ad2a1f5..d65773aecd6d 100644 --- a/lldb/include/lldb/lldb-private.h +++ b/lldb/include/lldb/lldb-private.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef lldb_lldb_private_h_ -#define lldb_lldb_private_h_ +#ifndef LLDB_LLDB_PRIVATE_H +#define LLDB_LLDB_PRIVATE_H #if defined(__cplusplus) @@ -25,4 +25,4 @@ const char *GetVersion(); #endif // defined(__cplusplus) -#endif // lldb_lldb_private_h_ +#endif // LLDB_LLDB_PRIVATE_H diff --git a/lldb/include/lldb/lldb-public.h b/lldb/include/lldb/lldb-public.h index 449062f832f6..840edc6603e4 100644 --- a/lldb/include/lldb/lldb-public.h +++ b/lldb/include/lldb/lldb-public.h @@ -6,12 +6,12 @@ // //===----------------------------------------------------------------------===// -#ifndef LLDB_lldb_h_ -#define LLDB_lldb_h_ +#ifndef LLDB_LLDB_PUBLIC_H +#define LLDB_LLDB_PUBLIC_H #include "lldb/lldb-defines.h" #include "lldb/lldb-enumerations.h" #include "lldb/lldb-forward.h" #include "lldb/lldb-types.h" -#endif // LLDB_lldb_h_ +#endif // LLDB_LLDB_PUBLIC_H diff --git a/lldb/include/lldb/lldb-types.h b/lldb/include/lldb/lldb-types.h index 414a9f308052..c3e2f07acc45 100644 --- a/lldb/include/lldb/lldb-types.h +++ b/lldb/include/lldb/lldb-types.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef LLDB_lldb_types_h_ -#define LLDB_lldb_types_h_ +#ifndef LLDB_LLDB_TYPES_H +#define LLDB_LLDB_TYPES_H #include "lldb/lldb-enumerations.h" #include "lldb/lldb-forward.h" @@ -91,4 +91,4 @@ typedef void *opaque_compiler_type_t; typedef uint64_t queue_id_t; } // namespace lldb -#endif // LLDB_lldb_types_h_ +#endif // LLDB_LLDB_TYPES_H diff --git a/lldb/include/lldb/lldb-versioning.h b/lldb/include/lldb/lldb-versioning.h index 702ebd19a3ee..d9a0e6bf2832 100644 --- a/lldb/include/lldb/lldb-versioning.h +++ b/lldb/include/lldb/lldb-versioning.h @@ -7,8 +7,8 @@ // //===----------------------------------------------------------------------===// -#ifndef LLDB_lldb_versioning_h_ -#define LLDB_lldb_versioning_h_ +#ifndef LLDB_LLDB_VERSIONING_H +#define LLDB_LLDB_VERSIONING_H // LLDB API version #define LLDB_API_MAJOR_VERSION 1 @@ -1539,4 +1539,4 @@ // defined(LLDB_API_MINOR_VERSION_WANTED) && defined // (LLDB_API_MAJOR_VERSION) -#endif // LLDB_lldb_versioning_h_ +#endif // LLDB_LLDB_VERSIONING_H diff --git a/lldb/include/lldb/module.modulemap b/lldb/include/lldb/module.modulemap index e040df8f913b..7feea8ee99c3 100644 --- a/lldb/include/lldb/module.modulemap +++ b/lldb/include/lldb/module.modulemap @@ -49,12 +49,16 @@ module lldb_Host { module SocketAddress { header "Host/SocketAddress.h" export * } module Socket { header "Host/Socket.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 * } module Time { header "Host/Time.h" export * } module XML { header "Host/XML.h" export * } + module common { + umbrella "Host/common" + module * { export * } + } + export * } |