diff options
author | Dimitry Andric <dim@FreeBSD.org> | 2015-12-30 11:55:28 +0000 |
---|---|---|
committer | Dimitry Andric <dim@FreeBSD.org> | 2015-12-30 11:55:28 +0000 |
commit | e81d9d49145e432d917eea3a70d2ae74dcad1d89 (patch) | |
tree | 9ed5e1a91f242e2cb5911577356e487a55c01b78 | |
parent | 85d8ef8f1f0e0e063a8571944302be2d2026f823 (diff) | |
download | src-e81d9d49145e432d917eea3a70d2ae74dcad1d89.tar.gz src-e81d9d49145e432d917eea3a70d2ae74dcad1d89.zip |
Vendor import of stripped lldb trunk r256633:
Notes
Notes:
svn path=/vendor/lldb/dist/; revision=292932
1089 files changed, 93010 insertions, 55864 deletions
diff --git a/docs/lldb.1 b/docs/lldb.1 index 0d94dcbe6a78..a28cabe7acc0 100644 --- a/docs/lldb.1 +++ b/docs/lldb.1 @@ -1,19 +1,20 @@ -.Dd June 7, 2012 \" DATE +.Dd December 16, 2015 \" DATE .Dt LLDB 1 \" Program name and manual section number -.Os Darwin \" Operating System -.Sh NAME \" Section Header - required - don't modify +.Os +.Sh NAME \" Section Header - required - do not modify .Nm lldb .Nd The debugger -.Sh SYNOPSIS \" Section Header - required - don't modify +.Sh SYNOPSIS \" Section Header - required - do not modify .Nm lldb .Op Fl hvdexw .Op Fl a Ar arch +.Op Fl c Ar core-file .Op Fl l Ar script-language .Op Fl s Ar lldb-commands .Op Fl n Ar process-name .Op Fl p Ar pid .Ar [[--] <PROGRAM-ARG1> <PROGRAM-ARG2> ...] -.Sh DESCRIPTION \" Section Header - required - don't modify +.Sh DESCRIPTION \" Section Header - required - do not modify .Nm is the command line interface for the LLDB debugger library. .Nm @@ -24,7 +25,10 @@ The following options are available: .It Fl h, -help Prints out the usage information for the .Nm -debugger. The \fB\-\-help\fR text may be more up-to-date and +debugger. +The +.Fl -help +text may be more up-to-date and authoritative than the command line options described in this man page. .It Fl v, -version @@ -42,9 +46,13 @@ Specifies the executable file that will be launching / attaching to. .It Fl n, -attach-name Ar process-name Specifies the name of a currently-running process to attach to. -(or the name of a process to wait for if \fB\-w\fR is used.) +(or the name of a process to wait for if +.Fl w +is used.) .It Fl w, -wait-for -When used in concert with \&\fB\-n process-name\-E\fR, indicates that +When used in concert with +.Fl n Ar process-name , +indicates that .Nm should wait for a new process of that name to be started -- and attach to it as early in the process-launch as possible. @@ -52,9 +60,12 @@ to it as early in the process-launch as possible. Specifies a currently running process that .Nm should attach to. +.It Fl c, -core Ar core-file +Specifies the core file to examine. .It Fl l, -script-language Ar language Tells the debugger to use the specified scripting language for -user-defined scripts, rather than the default. Valid scripting +user-defined scripts, rather than the default. +Valid scripting languages that can be specified include Python, Perl, Ruby and Tcl. Currently only the Python extensions have been implemented. .It Fl d, -debug @@ -62,8 +73,9 @@ Tells the debugger to print out extra information for debugging itself. .It Fl s, -source Ar filename Tells .Nm -to read in and execute the file "\fBfilename\fR", which -should contain +to read in and execute the file +.Qq Ar filename , +which should contain .Nm commands. .It Fl e, -editor @@ -73,39 +85,62 @@ to open source files using the host's "external editor" mechanism. .It Fl x, -no-lldbinit Do not automatically parse any '.lldbinit' files. .Pp -(If you don't provide -f then the first argument will be the file to be debugged +(If you do not provide -f then the first argument will be the file to +be debugged so 'lldb -- <filename> [<ARG1> [<ARG2>]]' also works. -Remember to end the options with "--" if any of your arguments have a "-" in them.) +Remember to end the options with "--" if any of your arguments have +a "-" in them.) .El .Sh USING LLDB In .Nm -there is a \fBhelp\fR command which can be used to find descriptions and examples of -all +there is a +.Cm help +command which can be used to find descriptions and examples of all .Nm -commands. To get help on "\fBbreakpoint set\fR" you would type "\fBhelp breakpoint set\fR". +commands. +To get help on +.Qq Cm breakpoint set +you would type +.Qq Cm help breakpoint set . .Pp -There is also an \fBapropos\fR command which will search the help text of all commands -for a given term -- this is useful for locating a command by topic. For instance, "\fBapropos breakpoint\fR" -will list any command that has the word \fBbreakpoint\fR in its help text. +There is also an +.Cm apropos +command which will search the help text of all commands +for a given term -- this is useful for locating a command by topic. +For instance, +.Qq Cm apropos breakpoint +will list any command that has the word +.Qq Cm breakpoint +in its help text. .Sh FILES .Nm will read settings/aliases/commands from three files at startup, if they exist. .Pp -First, it will read a \fB~/.lldbinit-\fIdebugger\fR command file. If you are using the +First, it will read a +.Pa ~/.lldbinit-debugger +command file. +If you are using the .Nm -command line interface, this is \fB~/.lldbinit-lldb\fR. If you are using +command line interface, this is +.Pa ~/.lldbinit-lldb . +If you are using .Nm inside a GUI debugger like .Nm Xcode -this will be \fB~/.lldbinit-Xcode\fR. This is a useful place to put settings that you -want to apply only when a given +this will be +.Pa ~/.lldbinit-Xcode . +This is a useful place to put settings that you want to apply only when a given .Nm command interpreter is used. .Pp -Second, \fB~/.lldbinit\fR is read. +Second, +.Pa ~/.lldbinit +is read. .Pp -Third, an \fR.lldbinit\fR file in the current working directory (where +Third, an +.Pa .lldbinit +file in the current working directory (where .Nm is started) will be read. .Sh SEE ALSO diff --git a/include/lldb/API/LLDB.h b/include/lldb/API/LLDB.h index 66e095395f13..eed10d08c6cc 100644 --- a/include/lldb/API/LLDB.h +++ b/include/lldb/API/LLDB.h @@ -16,6 +16,7 @@ // Project includes #include "lldb/API/SBDefines.h" #include "lldb/API/SBAddress.h" +#include "lldb/API/SBAttachInfo.h" #include "lldb/API/SBBlock.h" #include "lldb/API/SBBreakpoint.h" #include "lldb/API/SBBreakpointLocation.h" @@ -30,28 +31,47 @@ #include "lldb/API/SBError.h" #include "lldb/API/SBEvent.h" #include "lldb/API/SBExecutionContext.h" +#include "lldb/API/SBExpressionOptions.h" #include "lldb/API/SBFileSpec.h" +#include "lldb/API/SBFileSpecList.h" #include "lldb/API/SBFrame.h" #include "lldb/API/SBFunction.h" #include "lldb/API/SBHostOS.h" #include "lldb/API/SBInstruction.h" #include "lldb/API/SBInstructionList.h" +#include "lldb/API/SBLanguageRuntime.h" +#include "lldb/API/SBLaunchInfo.h" #include "lldb/API/SBLineEntry.h" #include "lldb/API/SBListener.h" #include "lldb/API/SBModule.h" +#include "lldb/API/SBModuleSpec.h" +#include "lldb/API/SBPlatform.h" #include "lldb/API/SBProcess.h" #include "lldb/API/SBQueue.h" #include "lldb/API/SBQueueItem.h" +#include "lldb/API/SBSection.h" #include "lldb/API/SBSourceManager.h" #include "lldb/API/SBStream.h" #include "lldb/API/SBStringList.h" #include "lldb/API/SBSymbol.h" #include "lldb/API/SBSymbolContext.h" +#include "lldb/API/SBSymbolContextList.h" #include "lldb/API/SBTarget.h" #include "lldb/API/SBThread.h" +#include "lldb/API/SBThreadCollection.h" +#include "lldb/API/SBThreadPlan.h" #include "lldb/API/SBType.h" +#include "lldb/API/SBTypeCategory.h" +#include "lldb/API/SBTypeEnumMember.h" +#include "lldb/API/SBTypeFilter.h" +#include "lldb/API/SBTypeFormat.h" +#include "lldb/API/SBTypeNameSpecifier.h" +#include "lldb/API/SBTypeSummary.h" +#include "lldb/API/SBTypeSynthetic.h" +#include "lldb/API/SBUnixSignals.h" #include "lldb/API/SBValue.h" #include "lldb/API/SBValueList.h" #include "lldb/API/SBVariablesOptions.h" +#include "lldb/API/SBWatchpoint.h" #endif // LLDB_LLDB_h_ diff --git a/include/lldb/API/SBAttachInfo.h b/include/lldb/API/SBAttachInfo.h index 712150e128be..a246d9919cfa 100644 --- a/include/lldb/API/SBAttachInfo.h +++ b/include/lldb/API/SBAttachInfo.h @@ -23,8 +23,47 @@ public: SBAttachInfo (lldb::pid_t pid); + //------------------------------------------------------------------ + /// Attach to a process by name. + /// + /// This function implies that a future call to SBTarget::Attach(...) + /// will be synchronous. + /// + /// @param[in] path + /// A full or partial name for the process to attach to. + /// + /// @param[in] wait_for + /// If \b false, attach to an existing process whose name matches. + /// If \b true, then wait for the next process whose name matches. + //------------------------------------------------------------------ SBAttachInfo (const char *path, bool wait_for); + //------------------------------------------------------------------ + /// Attach to a process by name. + /// + /// Future calls to SBTarget::Attach(...) will be synchronous or + /// asynchronous depending on the \a async argument. + /// + /// @param[in] path + /// A full or partial name for the process to attach to. + /// + /// @param[in] wait_for + /// If \b false, attach to an existing process whose name matches. + /// If \b true, then wait for the next process whose name matches. + /// + /// @param[in] async + /// If \b false, then the SBTarget::Attach(...) call will be a + /// synchronous call with no way to cancel the attach in + /// progress. + /// If \b true, then the SBTarget::Attach(...) function will + /// return immediately and clients are expected to wait for a + /// process eStateStopped event if a suitable process is + /// eventually found. If the client wants to cancel the event, + /// SBProcess::Stop() can be called and an eStateExited process + /// event will be delivered. + //------------------------------------------------------------------ + SBAttachInfo (const char *path, bool wait_for, bool async); + SBAttachInfo (const SBAttachInfo &rhs); ~SBAttachInfo(); @@ -47,9 +86,45 @@ public: bool GetWaitForLaunch (); + //------------------------------------------------------------------ + /// Set attach by process name settings. + /// + /// Designed to be used after a call to SBAttachInfo::SetExecutable(). + /// This function implies that a call to SBTarget::Attach(...) will + /// be synchronous. + /// + /// @param[in] wait_for + /// If \b false, attach to an existing process whose name matches. + /// If \b true, then wait for the next process whose name matches. + //------------------------------------------------------------------ void SetWaitForLaunch (bool b); + //------------------------------------------------------------------ + /// Set attach by process name settings. + /// + /// Designed to be used after a call to SBAttachInfo::SetExecutable(). + /// Future calls to SBTarget::Attach(...) will be synchronous or + /// asynchronous depending on the \a async argument. + /// + /// @param[in] wait_for + /// If \b false, attach to an existing process whose name matches. + /// If \b true, then wait for the next process whose name matches. + /// + /// @param[in] async + /// If \b false, then the SBTarget::Attach(...) call will be a + /// synchronous call with no way to cancel the attach in + /// progress. + /// If \b true, then the SBTarget::Attach(...) function will + /// return immediately and clients are expected to wait for a + /// process eStateStopped event if a suitable process is + /// eventually found. If the client wants to cancel the event, + /// SBProcess::Stop() can be called and an eStateExited process + /// event will be delivered. + //------------------------------------------------------------------ + void + SetWaitForLaunch (bool b, bool async); + bool GetIgnoreExisting (); diff --git a/include/lldb/API/SBCommandInterpreter.h b/include/lldb/API/SBCommandInterpreter.h index 235a2f3ea603..a8e9bf7ed769 100644 --- a/include/lldb/API/SBCommandInterpreter.h +++ b/include/lldb/API/SBCommandInterpreter.h @@ -10,6 +10,12 @@ #ifndef LLDB_SBCommandInterpreter_h_ #define LLDB_SBCommandInterpreter_h_ +// C Includes +// C++ Includes +#include <memory> + +// Other libraries and framework includes +// Project includes #include "lldb/API/SBDefines.h" #include "lldb/API/SBDebugger.h" @@ -59,6 +65,7 @@ public: void SetAddToHistory (bool); + private: lldb_private::CommandInterpreterRunOptions * get () const; @@ -84,11 +91,11 @@ public: SBCommandInterpreter (const lldb::SBCommandInterpreter &rhs); + ~SBCommandInterpreter (); + const lldb::SBCommandInterpreter & operator = (const lldb::SBCommandInterpreter &rhs); - ~SBCommandInterpreter (); - static const char * GetArgumentTypeAsCString (const lldb::CommandArgumentType arg_type); @@ -187,7 +194,7 @@ public: lldb::CommandOverrideCallback callback, void *baton); - SBCommandInterpreter (lldb_private::CommandInterpreter *interpreter_ptr = NULL); // Access using SBDebugger::GetCommandInterpreter(); + SBCommandInterpreter(lldb_private::CommandInterpreter *interpreter_ptr = nullptr); // Access using SBDebugger::GetCommandInterpreter(); //---------------------------------------------------------------------- /// Return true if the command interpreter is the active IO handler. @@ -213,7 +220,7 @@ public: /// /// @return /// The string that should be written into the file handle that is - /// feeding the input stream for the debugger, or NULL if there is + /// feeding the input stream for the debugger, or nullptr if there is /// no string for this control key. //---------------------------------------------------------------------- const char * @@ -233,7 +240,6 @@ public: ResolveCommand(const char *command_line, SBCommandReturnObject &result); protected: - lldb_private::CommandInterpreter & ref (); @@ -242,6 +248,7 @@ protected: void reset (lldb_private::CommandInterpreter *); + private: friend class SBDebugger; @@ -254,6 +261,9 @@ private: class SBCommandPluginInterface { public: + virtual + ~SBCommandPluginInterface() = default; + virtual bool DoExecute (lldb::SBDebugger /*debugger*/, char** /*command*/, @@ -261,16 +271,11 @@ public: { return false; } - - virtual - ~SBCommandPluginInterface () - {} }; class SBCommand { public: - SBCommand (); bool @@ -298,13 +303,12 @@ public: SetFlags (uint32_t flags); lldb::SBCommand - AddMultiwordCommand (const char* name, const char* help = NULL); + AddMultiwordCommand(const char* name, const char* help = nullptr); lldb::SBCommand - AddCommand (const char* name, lldb::SBCommandPluginInterface* impl, const char* help = NULL); + AddCommand(const char* name, lldb::SBCommandPluginInterface* impl, const char* help = nullptr); private: - friend class SBDebugger; friend class SBCommandInterpreter; diff --git a/include/lldb/API/SBCommandReturnObject.h b/include/lldb/API/SBCommandReturnObject.h index c51d6bc8d2d5..b45eb9c14c04 100644 --- a/include/lldb/API/SBCommandReturnObject.h +++ b/include/lldb/API/SBCommandReturnObject.h @@ -10,8 +10,14 @@ #ifndef LLDB_SBCommandReturnObject_h_ #define LLDB_SBCommandReturnObject_h_ +// C Includes #include <stdio.h> +// C++ Includes +#include <memory> + +// Other libraries and framework includes +// Project includes #include "lldb/API/SBDefines.h" namespace lldb { @@ -19,22 +25,20 @@ namespace lldb { class LLDB_API SBCommandReturnObject { public: - SBCommandReturnObject (); SBCommandReturnObject (const lldb::SBCommandReturnObject &rhs); + ~SBCommandReturnObject (); + const lldb::SBCommandReturnObject & operator = (const lldb::SBCommandReturnObject &rhs); - SBCommandReturnObject (lldb_private::CommandReturnObject *ptr); lldb_private::CommandReturnObject * Release (); - ~SBCommandReturnObject (); - bool IsValid() const; @@ -99,8 +103,8 @@ public: GetError (bool only_if_no_immediate); void - SetError (lldb::SBError &error, - const char *fallback_error_cstr = NULL); + SetError(lldb::SBError &error, + const char *fallback_error_cstr = nullptr); void SetError (const char* error_cstr); @@ -124,10 +128,10 @@ protected: void SetLLDBObjectPtr (lldb_private::CommandReturnObject *ptr); - private: +private: std::unique_ptr<lldb_private::CommandReturnObject> m_opaque_ap; }; } // namespace lldb -#endif // LLDB_SBCommandReturnObject_h_ +#endif // LLDB_SBCommandReturnObject_h_ diff --git a/include/lldb/API/SBDebugger.h b/include/lldb/API/SBDebugger.h index 4f2c1d7f8756..7588cfc9ec42 100644 --- a/include/lldb/API/SBDebugger.h +++ b/include/lldb/API/SBDebugger.h @@ -16,13 +16,13 @@ #include "lldb/API/SBPlatform.h" namespace lldb { - class LLDB_API SBInputReader { public: - SBInputReader(); - ~SBInputReader(); + SBInputReader() = default; + ~SBInputReader() = default; + SBError Initialize(lldb::SBDebugger&, unsigned long (*)(void*, lldb::SBInputReader*, lldb::InputReaderAction, char const*, unsigned long), void*, lldb::InputReaderGranularity, char const*, char const*, bool); void SetIsDone(bool); bool IsActive() const; @@ -31,6 +31,16 @@ public: class LLDB_API SBDebugger { public: + SBDebugger(); + + SBDebugger(const lldb::SBDebugger &rhs); + + SBDebugger(const lldb::DebuggerSP &debugger_sp); + + ~SBDebugger(); + + lldb::SBDebugger & + operator = (const lldb::SBDebugger &rhs); static void Initialize(); @@ -54,17 +64,6 @@ public: static void MemoryPressureDetected (); - SBDebugger(); - - SBDebugger(const lldb::SBDebugger &rhs); - - SBDebugger(const lldb::DebuggerSP &debugger_sp); - - lldb::SBDebugger & - operator = (const lldb::SBDebugger &rhs); - - ~SBDebugger(); - bool IsValid() const; @@ -288,6 +287,9 @@ public: GetCategory (const char* category_name); SBTypeCategory + GetCategory (lldb::LanguageType lang_type); + + SBTypeCategory CreateCategory (const char* category_name); bool @@ -329,8 +331,11 @@ public: int &num_errors, bool &quit_requested, bool &stopped_for_crash); -private: + + SBError + RunREPL (lldb::LanguageType language, const char *repl_options); +private: friend class SBCommandInterpreter; friend class SBInputReader; friend class SBListener; @@ -357,7 +362,6 @@ private: }; // class SBDebugger - } // namespace lldb #endif // LLDB_SBDebugger_h_ diff --git a/include/lldb/API/SBDefines.h b/include/lldb/API/SBDefines.h index 09bea502dd01..d81bba5a2e23 100644 --- a/include/lldb/API/SBDefines.h +++ b/include/lldb/API/SBDefines.h @@ -86,9 +86,7 @@ class LLDB_API SBTypeMemberFunction; class LLDB_API SBTypeNameSpecifier; class LLDB_API SBTypeSummary; class LLDB_API SBTypeSummaryOptions; -#ifndef LLDB_DISABLE_PYTHON class LLDB_API SBTypeSynthetic; -#endif class LLDB_API SBTypeList; class LLDB_API SBValue; class LLDB_API SBValueList; diff --git a/include/lldb/API/SBFunction.h b/include/lldb/API/SBFunction.h index 86cfeb49bb58..f76c77c44e3f 100644 --- a/include/lldb/API/SBFunction.h +++ b/include/lldb/API/SBFunction.h @@ -53,6 +53,9 @@ public: lldb::SBAddress GetEndAddress (); + const char * + GetArgumentName (uint32_t arg_idx); + uint32_t GetPrologueByteSize (); @@ -66,6 +69,9 @@ public: GetLanguage (); bool + GetIsOptimized (); + + bool operator == (const lldb::SBFunction &rhs) const; bool diff --git a/include/lldb/API/SBProcess.h b/include/lldb/API/SBProcess.h index 71bca4fc697a..1a9cc8022880 100644 --- a/include/lldb/API/SBProcess.h +++ b/include/lldb/API/SBProcess.h @@ -294,8 +294,56 @@ public: uint32_t GetNumSupportedHardwareWatchpoints (lldb::SBError &error) const; + //------------------------------------------------------------------ + /// Load a shared library into this process. + /// + /// @param[in] remote_image_spec + /// The path for the shared library on the target what you want + /// to load. + /// + /// @param[out] error + /// An error object that gets filled in with any errors that + /// might occur when trying to load the shared library. + /// + /// @return + /// A token that represents the shared library that can be + /// later used to unload the shared library. A value of + /// LLDB_INVALID_IMAGE_TOKEN will be returned if the shared + /// library can't be opened. + //------------------------------------------------------------------ uint32_t - LoadImage (lldb::SBFileSpec &image_spec, lldb::SBError &error); + LoadImage (lldb::SBFileSpec &remote_image_spec, lldb::SBError &error); + + //------------------------------------------------------------------ + /// Load a shared library into this process. + /// + /// @param[in] local_image_spec + /// The file spec that points to the shared library that you + /// want to load if the library is located on the host. The + /// library will be copied over to the location specified by + /// remote_image_spec or into the current working directory with + /// the same filename if the remote_image_spec isn't specified. + /// + /// @param[in] remote_image_spec + /// If local_image_spec is specified then the location where the + /// library should be copied over from the host. If + /// local_image_spec isn't specified, then the path for the + /// shared library on the target what you want to load. + /// + /// @param[out] error + /// An error object that gets filled in with any errors that + /// might occur when trying to load the shared library. + /// + /// @return + /// A token that represents the shared library that can be + /// later used to unload the shared library. A value of + /// LLDB_INVALID_IMAGE_TOKEN will be returned if the shared + /// library can't be opened. + //------------------------------------------------------------------ + uint32_t + LoadImage (const lldb::SBFileSpec &local_image_spec, + const lldb::SBFileSpec &remote_image_spec, + lldb::SBError &error); lldb::SBError UnloadImage (uint32_t image_token); @@ -341,6 +389,10 @@ public: bool IsInstrumentationRuntimePresent(InstrumentationRuntimeType type); + // Save the state of the process in a core file (or mini dump on Windows). + lldb::SBError + SaveCore(const char *file_name); + protected: friend class SBAddress; friend class SBBreakpoint; diff --git a/include/lldb/API/SBStream.h b/include/lldb/API/SBStream.h index 2b25cd2c68f2..e62723c2f37e 100644 --- a/include/lldb/API/SBStream.h +++ b/include/lldb/API/SBStream.h @@ -21,7 +21,9 @@ class LLDB_API SBStream public: SBStream (); - + + SBStream (SBStream &&rhs); + ~SBStream (); bool diff --git a/include/lldb/API/SBTarget.h b/include/lldb/API/SBTarget.h index 2ca0b124ce0a..723c433b521a 100644 --- a/include/lldb/API/SBTarget.h +++ b/include/lldb/API/SBTarget.h @@ -10,6 +10,10 @@ #ifndef LLDB_SBTarget_h_ #define LLDB_SBTarget_h_ +// C Includes +// C++ Includes +// Other libraries and framework includes +// Project includes #include "lldb/API/SBDefines.h" #include "lldb/API/SBAddress.h" #include "lldb/API/SBAttachInfo.h" @@ -50,14 +54,14 @@ public: SBTarget (const lldb::TargetSP& target_sp); - const lldb::SBTarget& - operator = (const lldb::SBTarget& rhs); - //------------------------------------------------------------------ // Destructor //------------------------------------------------------------------ ~SBTarget(); + const lldb::SBTarget& + operator = (const lldb::SBTarget& rhs); + bool IsValid() const; @@ -135,17 +139,17 @@ public: /// /// @param[in] stdin_path /// The path to use when re-directing the STDIN of the new - /// process. If all stdXX_path arguments are NULL, a pseudo + /// process. If all stdXX_path arguments are nullptr, a pseudo /// terminal will be used. /// /// @param[in] stdout_path /// The path to use when re-directing the STDOUT of the new - /// process. If all stdXX_path arguments are NULL, a pseudo + /// process. If all stdXX_path arguments are nullptr, a pseudo /// terminal will be used. /// /// @param[in] stderr_path /// The path to use when re-directing the STDERR of the new - /// process. If all stdXX_path arguments are NULL, a pseudo + /// process. If all stdXX_path arguments are nullptr, a pseudo /// terminal will be used. /// /// @param[in] working_directory @@ -175,8 +179,10 @@ public: uint32_t launch_flags, // See LaunchFlags bool stop_at_entry, lldb::SBError& error); - - + + SBProcess + LoadCore (const char *core_file); + //------------------------------------------------------------------ /// Launch a new process with sensible defaults. /// @@ -212,9 +218,6 @@ public: Launch (SBLaunchInfo &launch_info, SBError& error); SBProcess - LoadCore (const char *core_file); - - SBProcess Attach (SBAttachInfo &attach_info, SBError& error); //------------------------------------------------------------------ @@ -248,6 +251,7 @@ public: ::pid_t pid, // 32 bit int process ID lldb::SBError& error); // DEPRECATED #endif + //------------------------------------------------------------------ /// Attach to process with name. /// @@ -288,7 +292,7 @@ public: /// The url to connect to, e.g., 'connect://localhost:12345'. /// /// @param[in] plugin_name - /// The plugin name to be used; can be NULL. + /// The plugin name to be used; can be nullptr. /// /// @param[out] error /// An error explaining what went wrong if the connect fails. @@ -421,7 +425,6 @@ public: lldb::SBError SetModuleLoadAddress (lldb::SBModule module, int64_t sections_offset); - //------------------------------------------------------------------ /// Clear the section base load addresses for all sections in a module. @@ -618,7 +621,7 @@ public: BreakpointCreateByLocation (const lldb::SBFileSpec &file_spec, uint32_t line); lldb::SBBreakpoint - BreakpointCreateByName (const char *symbol_name, const char *module_name = NULL); + BreakpointCreateByName(const char *symbol_name, const char *module_name = nullptr); // This version uses name_type_mask = eFunctionNameTypeAuto lldb::SBBreakpoint @@ -633,14 +636,29 @@ public: const SBFileSpecList &comp_unit_list); lldb::SBBreakpoint + BreakpointCreateByName (const char *symbol_name, + uint32_t name_type_mask, // Logical OR one or more FunctionNameType enum bits + lldb::LanguageType symbol_language, + const SBFileSpecList &module_list, + const SBFileSpecList &comp_unit_list); + + lldb::SBBreakpoint + BreakpointCreateByNames (const char *symbol_name[], + uint32_t num_names, + uint32_t name_type_mask, // Logical OR one or more FunctionNameType enum bits + const SBFileSpecList &module_list, + const SBFileSpecList &comp_unit_list); + + lldb::SBBreakpoint BreakpointCreateByNames (const char *symbol_name[], uint32_t num_names, uint32_t name_type_mask, // Logical OR one or more FunctionNameType enum bits + lldb::LanguageType symbol_language, const SBFileSpecList &module_list, const SBFileSpecList &comp_unit_list); lldb::SBBreakpoint - BreakpointCreateByRegex (const char *symbol_name_regex, const char *module_name = NULL); + BreakpointCreateByRegex (const char *symbol_name_regex, const char *module_name = nullptr); lldb::SBBreakpoint BreakpointCreateByRegex (const char *symbol_name_regex, @@ -648,9 +666,15 @@ public: const SBFileSpecList &comp_unit_list); lldb::SBBreakpoint - BreakpointCreateBySourceRegex (const char *source_regex, - const SBFileSpec &source_file, - const char *module_name = NULL); + BreakpointCreateByRegex (const char *symbol_name_regex, + lldb::LanguageType symbol_language, + const SBFileSpecList &module_list, + const SBFileSpecList &comp_unit_list); + + lldb::SBBreakpoint + BreakpointCreateBySourceRegex(const char *source_regex, + const SBFileSpec &source_file, + const char *module_name = nullptr); lldb::SBBreakpoint BreakpointCreateBySourceRegex (const char *source_regex, @@ -665,6 +689,9 @@ public: lldb::SBBreakpoint BreakpointCreateByAddress (addr_t address); + lldb::SBBreakpoint + BreakpointCreateBySBAddress (SBAddress &address); + uint32_t GetNumBreakpoints () const; @@ -808,15 +835,10 @@ protected: void SetSP (const lldb::TargetSP& target_sp); - private: - //------------------------------------------------------------------ - // For Target only - //------------------------------------------------------------------ - lldb::TargetSP m_opaque_sp; }; } // namespace lldb -#endif // LLDB_SBTarget_h_ +#endif // LLDB_SBTarget_h_ diff --git a/include/lldb/API/SBType.h b/include/lldb/API/SBType.h index 01f0c6afc795..ed3c2ff23863 100644 --- a/include/lldb/API/SBType.h +++ b/include/lldb/API/SBType.h @@ -85,7 +85,13 @@ public: const char * GetName (); - + + const char * + GetDemangledName (); + + const char * + GetMangledName (); + lldb::SBType GetType (); @@ -158,6 +164,9 @@ public: bool IsTypedefType (); + bool + IsAnonymousType (); + lldb::SBType GetPointerType(); @@ -290,7 +299,7 @@ protected: friend class SBTypeList; friend class SBValue; - SBType (const lldb_private::ClangASTType &); + SBType (const lldb_private::CompilerType &); SBType (const lldb::TypeSP &); SBType (const lldb::TypeImplSP &); diff --git a/include/lldb/API/SBTypeCategory.h b/include/lldb/API/SBTypeCategory.h index 30c338b28a46..997b3fc2f98d 100644 --- a/include/lldb/API/SBTypeCategory.h +++ b/include/lldb/API/SBTypeCategory.h @@ -36,6 +36,15 @@ namespace lldb { const char* GetName(); + lldb::LanguageType + GetLanguageAtIndex (uint32_t idx); + + uint32_t + GetNumLanguages (); + + void + AddLanguage (lldb::LanguageType language); + bool GetDescription (lldb::SBStream &description, lldb::DescriptionLevel description_level); diff --git a/include/lldb/API/SBTypeSummary.h b/include/lldb/API/SBTypeSummary.h index 9b367ba5f982..f4c666180085 100644 --- a/include/lldb/API/SBTypeSummary.h +++ b/include/lldb/API/SBTypeSummary.h @@ -12,8 +12,6 @@ #include "lldb/API/SBDefines.h" -#ifndef LLDB_DISABLE_PYTHON - namespace lldb { class LLDB_API SBTypeSummaryOptions { @@ -71,6 +69,9 @@ namespace lldb { public: SBTypeSummary(); + + // Native function summary formatter callback + typedef bool (*FormatCallback) (SBValue, SBTypeSummaryOptions, SBStream&); static SBTypeSummary CreateWithSummaryString (const char* data, @@ -83,6 +84,11 @@ namespace lldb { static SBTypeSummary CreateWithScriptCode (const char* data, uint32_t options = 0); // see lldb::eTypeOption values + + static SBTypeSummary + CreateWithCallback (FormatCallback cb, + uint32_t options = 0, + const char* description = nullptr); SBTypeSummary (const lldb::SBTypeSummary &rhs); @@ -126,6 +132,9 @@ namespace lldb { operator = (const lldb::SBTypeSummary &rhs); bool + DoesPrintValue (lldb::SBValue value); + + bool IsEqualTo (lldb::SBTypeSummary &rhs); bool @@ -160,6 +169,4 @@ namespace lldb { } // namespace lldb -#endif // LLDB_DISABLE_PYTHON - #endif // LLDB_SBTypeSummary_h_ diff --git a/include/lldb/API/SBValue.h b/include/lldb/API/SBValue.h index a070b149f34f..a7e015064f96 100644 --- a/include/lldb/API/SBValue.h +++ b/include/lldb/API/SBValue.h @@ -139,10 +139,8 @@ public: lldb::SBTypeFormat GetTypeFormat (); -#ifndef LLDB_DISABLE_PYTHON lldb::SBTypeSummary GetTypeSummary (); -#endif lldb::SBTypeFilter GetTypeFilter (); @@ -206,7 +204,11 @@ public: /// pointer to a 'Point' type, then the child at index zero will be /// the 'x' member, and the child at index 1 will be the 'y' member /// (the child at index zero won't be a 'Point' instance). - /// + /// + /// If you actually need an SBValue that represents the type pointed + /// to by a SBValue for which GetType().IsPointeeType() returns true, + /// regardless of the pointee type, you can do that with SBValue::Dereference. + /// /// Arrays have a preset number of children that can be accessed by /// index and will returns invalid child values for indexes that are /// out of bounds unless the \a synthetic_allowed is \b true. In this @@ -332,6 +334,9 @@ public: uint32_t GetNumChildren (); + uint32_t + GetNumChildren (uint32_t max); + void * GetOpaqueType(); @@ -350,6 +355,7 @@ public: lldb::SBValue Dereference (); + // Deprecated - please use GetType().IsPointerType() instead. bool TypeIsPointerType (); diff --git a/include/lldb/API/SystemInitializerFull.h b/include/lldb/API/SystemInitializerFull.h index 6280fe8aef04..9e37611a6598 100644 --- a/include/lldb/API/SystemInitializerFull.h +++ b/include/lldb/API/SystemInitializerFull.h @@ -26,15 +26,15 @@ class SystemInitializerFull : public SystemInitializerCommon { public: SystemInitializerFull(); - virtual ~SystemInitializerFull(); + ~SystemInitializerFull() override; void Initialize() override; void Terminate() override; private: void InitializeSWIG(); - void TerminateSWIG(); }; -} -#endif +} // namespace lldb_private + +#endif // LLDB_API_SYSTEM_INITIALIZER_FULL_H diff --git a/include/lldb/Breakpoint/Breakpoint.h b/include/lldb/Breakpoint/Breakpoint.h index a70c2787a1ef..7fdf06da3936 100644 --- a/include/lldb/Breakpoint/Breakpoint.h +++ b/include/lldb/Breakpoint/Breakpoint.h @@ -12,7 +12,10 @@ // C Includes // C++ Includes +#include <memory> +#include <string> #include <unordered_set> +#include <vector> // Other libraries and framework includes // Project includes @@ -81,11 +84,9 @@ class Breakpoint: public Stoppoint { public: - static const ConstString & GetEventIdentifier (); - //------------------------------------------------------------------ /// An enum specifying the match style for breakpoint settings. At /// present only used for function name style breakpoints. @@ -101,18 +102,16 @@ public: public EventData { public: + BreakpointEventData (lldb::BreakpointEventType sub_type, + const lldb::BreakpointSP &new_breakpoint_sp); + + ~BreakpointEventData() override; static const ConstString & GetFlavorString (); - virtual const ConstString & - GetFlavor () const; - - BreakpointEventData (lldb::BreakpointEventType sub_type, - const lldb::BreakpointSP &new_breakpoint_sp); - - virtual - ~BreakpointEventData(); + const ConstString & + GetFlavor() const override; lldb::BreakpointEventType GetBreakpointEventType () const; @@ -126,9 +125,8 @@ public: return m_locations; } - - virtual void - Dump (Stream *s) const; + void + Dump(Stream *s) const override; static lldb::BreakpointEventType GetBreakpointEventTypeFromEvent (const lldb::EventSP &event_sp); @@ -146,7 +144,6 @@ public: GetEventDataFromEvent (const Event *event_sp); private: - lldb::BreakpointEventType m_breakpoint_event; lldb::BreakpointSP m_new_breakpoint_sp; BreakpointLocationCollection m_locations; @@ -154,11 +151,10 @@ public: DISALLOW_COPY_AND_ASSIGN (BreakpointEventData); }; - class BreakpointPrecondition { public: - virtual ~BreakpointPrecondition() {} + virtual ~BreakpointPrecondition() = default; virtual bool EvaluatePrecondition(StoppointCallbackContext &context); @@ -167,7 +163,7 @@ public: ConfigurePrecondition(Args &options); virtual void - DescribePrecondition(Stream &stream, lldb::DescriptionLevel level); + GetDescription(Stream &stream, lldb::DescriptionLevel level); }; typedef std::shared_ptr<BreakpointPrecondition> BreakpointPreconditionSP; @@ -179,7 +175,7 @@ public: /// breakpoints. The varieties of breakpoints are specified instead by /// providing different resolvers & filters. //------------------------------------------------------------------ - ~Breakpoint(); + ~Breakpoint() override; //------------------------------------------------------------------ // Methods @@ -197,14 +193,13 @@ public: /// Standard "Dump" method. At present it does nothing. //------------------------------------------------------------------ void - Dump (Stream *s); + Dump(Stream *s) override; //------------------------------------------------------------------ // The next set of methods provide ways to tell the breakpoint to update // it's location list - usually done when modules appear or disappear. //------------------------------------------------------------------ - //------------------------------------------------------------------ /// Tell this breakpoint to clear all its breakpoint sites. Done /// when the process holding the breakpoint sites is destroyed. @@ -262,7 +257,6 @@ public: bool load_event, bool delete_locations = false); - //------------------------------------------------------------------ /// Tells the breakpoint the old module \a old_module_sp has been /// replaced by new_module_sp (usually because the underlying file has been @@ -294,8 +288,8 @@ public: /// Returns a pointer to the new location. //------------------------------------------------------------------ lldb::BreakpointLocationSP - AddLocation (const Address &addr, - bool *new_location = NULL); + AddLocation(const Address &addr, + bool *new_location = nullptr); //------------------------------------------------------------------ /// Find a breakpoint location by Address. @@ -304,7 +298,7 @@ public: /// The Address specifying the location. /// @return /// Returns a shared pointer to the location at \a addr. The pointer - /// in the shared pointer will be NULL if there is no location at that address. + /// in the shared pointer will be nullptr if there is no location at that address. //------------------------------------------------------------------ lldb::BreakpointLocationSP FindLocationByAddress (const Address &addr); @@ -328,7 +322,7 @@ public: /// The ID specifying the location. /// @return /// Returns a shared pointer to the location with ID \a bp_loc_id. The pointer - /// in the shared pointer will be NULL if there is no location with that ID. + /// in the shared pointer will be nullptr if there is no location with that ID. //------------------------------------------------------------------ lldb::BreakpointLocationSP FindLocationByID (lldb::break_id_t bp_loc_id); @@ -341,7 +335,7 @@ public: /// /// @return /// Returns a shared pointer to the location with index \a - /// index. The shared pointer might contain NULL if \a index is + /// index. The shared pointer might contain nullptr if \a index is /// greater than then number of actual locations. //------------------------------------------------------------------ lldb::BreakpointLocationSP @@ -373,7 +367,7 @@ public: /// If \a enable is \b true, enable the breakpoint, if \b false disable it. //------------------------------------------------------------------ void - SetEnabled (bool enable); + SetEnabled(bool enable) override; //------------------------------------------------------------------ /// Check the Enable/Disable state. @@ -381,7 +375,7 @@ public: /// \b true if the breakpoint is enabled, \b false if disabled. //------------------------------------------------------------------ bool - IsEnabled (); + IsEnabled() override; //------------------------------------------------------------------ /// Set the breakpoint to ignore the next \a count breakpoint hits. @@ -407,7 +401,6 @@ public: uint32_t GetHitCount () const; - //------------------------------------------------------------------ /// If \a one_shot is \b true, breakpoint will be deleted on first hit. //------------------------------------------------------------------ @@ -490,7 +483,7 @@ public: /// /// @param[in] condition /// The condition expression to evaluate when the breakpoint is hit. - /// Pass in NULL to clear the condition. + /// Pass in nullptr to clear the condition. //------------------------------------------------------------------ void SetCondition (const char *condition); @@ -498,7 +491,7 @@ public: /// Return a pointer to the text of the condition expression. /// /// @return - /// A pointer to the condition expression text, or NULL if no + /// A pointer to the condition expression text, or nullptr if no // condition has been set. //------------------------------------------------------------------ const char *GetConditionText () const; @@ -560,7 +553,7 @@ public: /// Return the "kind" description for a breakpoint. /// /// @return - /// The breakpoint kind, or NULL if none is set. + /// The breakpoint kind, or nullptr if none is set. //------------------------------------------------------------------ const char *GetBreakpointKind () const { @@ -619,7 +612,6 @@ public: BreakpointOptions * GetOptions (); - //------------------------------------------------------------------ /// Invoke the callback action when the breakpoint is hit. /// @@ -713,7 +705,6 @@ protected: // Protected Methods //------------------------------------------------------------------ - //------------------------------------------------------------------ /// Constructors and Destructors /// Only the Target can make a breakpoint, and it owns the breakpoint lifespans. @@ -807,4 +798,4 @@ private: } // namespace lldb_private -#endif // liblldb_Breakpoint_h_ +#endif // liblldb_Breakpoint_h_ diff --git a/include/lldb/Breakpoint/BreakpointLocation.h b/include/lldb/Breakpoint/BreakpointLocation.h index c3e620d085c6..58d144cfb668 100644 --- a/include/lldb/Breakpoint/BreakpointLocation.h +++ b/include/lldb/Breakpoint/BreakpointLocation.h @@ -11,12 +11,10 @@ #define liblldb_BreakpointLocation_h_ // C Includes - // C++ Includes -#include <list> +#include <memory> // Other libraries and framework includes - // Project includes #include "lldb/lldb-private.h" #include "lldb/Breakpoint/StoppointLocation.h" @@ -49,7 +47,7 @@ class BreakpointLocation : public StoppointLocation { public: - ~BreakpointLocation (); + ~BreakpointLocation() override; //------------------------------------------------------------------ /// Gets the load address for this breakpoint location @@ -58,7 +56,7 @@ public: /// LLDB_INVALID_ADDRESS if not yet set. //------------------------------------------------------------------ lldb::addr_t - GetLoadAddress () const; + GetLoadAddress() const override; //------------------------------------------------------------------ /// Gets the Address for this breakpoint location @@ -74,6 +72,9 @@ public: //------------------------------------------------------------------ Breakpoint & GetBreakpoint (); + + Target & + GetTarget(); //------------------------------------------------------------------ /// Determines whether we should stop due to a hit at this @@ -88,7 +89,7 @@ public: /// \b false otherwise. //------------------------------------------------------------------ bool - ShouldStop (StoppointCallbackContext *context); + ShouldStop(StoppointCallbackContext *context) override; //------------------------------------------------------------------ // The next section deals with various breakpoint options. @@ -169,16 +170,15 @@ public: /// Return a pointer to the text of the condition expression. /// /// @return - /// A pointer to the condition expression text, or NULL if no + /// A pointer to the condition expression text, or nullptr if no // condition has been set. //------------------------------------------------------------------ const char * - GetConditionText (size_t *hash = NULL) const; + GetConditionText(size_t *hash = nullptr) const; bool ConditionSaysStop (ExecutionContext &exe_ctx, Error &error); - //------------------------------------------------------------------ /// Set the valid thread to be checked when the breakpoint is hit. /// @@ -270,7 +270,7 @@ public: /// Standard "Dump" method. At present it does nothing. //------------------------------------------------------------------ void - Dump (Stream *s) const; + Dump(Stream *s) const override; //------------------------------------------------------------------ /// Use this to set location specific breakpoint options. @@ -299,7 +299,6 @@ public: bool ValidForThisThread (Thread *thread); - //------------------------------------------------------------------ /// Invoke the callback action when the breakpoint is hit. /// @@ -418,7 +417,6 @@ private: void UndoBumpHitCount(); - //------------------------------------------------------------------ // Constructors and Destructors // @@ -459,9 +457,9 @@ private: bool m_is_indirect; Address m_address; ///< The address defining this location. Breakpoint &m_owner; ///< The breakpoint that produced this object. - std::unique_ptr<BreakpointOptions> m_options_ap; ///< Breakpoint options pointer, NULL if we're using our breakpoint's options. + std::unique_ptr<BreakpointOptions> m_options_ap; ///< Breakpoint options pointer, nullptr if we're using our breakpoint's options. lldb::BreakpointSiteSP m_bp_site_sp; ///< Our breakpoint site (it may be shared by more than one location.) - lldb::ClangUserExpressionSP m_user_expression_sp; ///< The compiled expression to use in testing our condition. + lldb::UserExpressionSP m_user_expression_sp; ///< The compiled expression to use in testing our condition. Mutex m_condition_mutex; ///< Guards parsing and evaluation of the condition, which could be evaluated by multiple processes. size_t m_condition_hash; ///< For testing whether the condition source code changed. @@ -479,4 +477,4 @@ private: } // namespace lldb_private -#endif // liblldb_BreakpointLocation_h_ +#endif // liblldb_BreakpointLocation_h_ diff --git a/include/lldb/Breakpoint/BreakpointLocationList.h b/include/lldb/Breakpoint/BreakpointLocationList.h index f67ef89ad705..81526089b427 100644 --- a/include/lldb/Breakpoint/BreakpointLocationList.h +++ b/include/lldb/Breakpoint/BreakpointLocationList.h @@ -12,8 +12,9 @@ // C Includes // C++ Includes -#include <vector> #include <map> +#include <vector> + // Other libraries and framework includes // Project includes #include "lldb/lldb-private.h" @@ -56,7 +57,7 @@ public: /// The address to look for. /// /// @result - /// A shared pointer to the breakpoint. May contain a NULL + /// A shared pointer to the breakpoint. May contain a nullptr /// pointer if the breakpoint doesn't exist. //------------------------------------------------------------------ const lldb::BreakpointLocationSP @@ -70,7 +71,7 @@ public: /// The breakpoint location ID to seek for. /// /// @result - /// A shared pointer to the breakpoint. May contain a NULL + /// A shared pointer to the breakpoint. May contain a nullptr /// pointer if the breakpoint doesn't exist. //------------------------------------------------------------------ lldb::BreakpointLocationSP @@ -116,7 +117,7 @@ public: /// The breakpoint location index to seek for. /// /// @result - /// A shared pointer to the breakpoint. May contain a NULL + /// A shared pointer to the breakpoint. May contain a nullptr /// pointer if the breakpoint doesn't exist. //------------------------------------------------------------------ lldb::BreakpointLocationSP @@ -130,7 +131,7 @@ public: /// The breakpoint location index to seek for. /// /// @result - /// A shared pointer to the breakpoint. May contain a NULL + /// A shared pointer to the breakpoint. May contain a nullptr /// pointer if the breakpoint doesn't exist. //------------------------------------------------------------------ const lldb::BreakpointLocationSP @@ -216,7 +217,6 @@ public: lldb::DescriptionLevel level); protected: - //------------------------------------------------------------------ /// This is the standard constructor. /// @@ -246,9 +246,9 @@ protected: StopRecordingNewLocations(); lldb::BreakpointLocationSP - AddLocation (const Address &addr, - bool resolve_indirect_symbols, - bool *new_location = NULL); + AddLocation(const Address &addr, + bool resolve_indirect_symbols, + bool *new_location = nullptr); void SwapLocation (lldb::BreakpointLocationSP to_location_sp, lldb::BreakpointLocationSP from_location_sp); @@ -273,16 +273,17 @@ protected: mutable Mutex m_mutex; lldb::break_id_t m_next_id; BreakpointLocationCollection *m_new_location_recorder; + public: typedef AdaptedIterable<collection, lldb::BreakpointLocationSP, vector_adapter> BreakpointLocationIterable; + BreakpointLocationIterable BreakpointLocations() { return BreakpointLocationIterable(m_locations); } - }; } // namespace lldb_private -#endif // liblldb_BreakpointLocationList_h_ +#endif // liblldb_BreakpointLocationList_h_ diff --git a/include/lldb/Breakpoint/BreakpointOptions.h b/include/lldb/Breakpoint/BreakpointOptions.h index bf10fc096d75..e7882147a4da 100644 --- a/include/lldb/Breakpoint/BreakpointOptions.h +++ b/include/lldb/Breakpoint/BreakpointOptions.h @@ -12,6 +12,9 @@ // C Includes // C++ Includes +#include <memory> +#include <string> + // Other libraries and framework includes // Project includes #include "lldb/lldb-private.h" @@ -115,7 +118,6 @@ public: //------------------------------------------------------------------ void SetCallback (BreakpointHitCallback callback, const lldb::BatonSP &baton_sp, bool synchronous = false); - //------------------------------------------------------------------ /// Remove the callback from this option set. //------------------------------------------------------------------ @@ -184,10 +186,10 @@ public: /// Return a pointer to the text of the condition expression. /// /// @return - /// A pointer to the condition expression text, or NULL if no + /// A pointer to the condition expression text, or nullptr if no // condition has been set. //------------------------------------------------------------------ - const char *GetConditionText (size_t *hash = NULL) const; + const char *GetConditionText(size_t *hash = nullptr) const; //------------------------------------------------------------------ // Enabled/Ignore Count @@ -257,10 +259,10 @@ public: } //------------------------------------------------------------------ - /// Return the current thread spec for this option. This will return NULL if the no thread + /// Return the current thread spec for this option. This will return nullptr if the no thread /// specifications have been set for this Option yet. /// @return - /// The thread specification pointer for this option, or NULL if none has + /// The thread specification pointer for this option, or nullptr if none has /// been set yet. //------------------------------------------------------------------ const ThreadSpec * @@ -298,7 +300,6 @@ public: lldb::user_id_t break_id, lldb::user_id_t break_loc_id); - struct CommandData { CommandData () : @@ -308,10 +309,8 @@ public: { } - ~CommandData () - { - } - + ~CommandData() = default; + StringList user_source; std::string script_source; bool stop_on_error; @@ -325,16 +324,14 @@ public: { } - virtual - ~CommandBaton () + ~CommandBaton() override { delete ((CommandData *)m_data); - m_data = NULL; + m_data = nullptr; } - virtual void - GetDescription (Stream *s, lldb::DescriptionLevel level) const; - + void + GetDescription (Stream *s, lldb::DescriptionLevel level) const override; }; protected: @@ -359,4 +356,4 @@ private: } // namespace lldb_private -#endif // liblldb_BreakpointOptions_h_ +#endif // liblldb_BreakpointOptions_h_ diff --git a/include/lldb/Breakpoint/BreakpointResolver.h b/include/lldb/Breakpoint/BreakpointResolver.h index 6ba53ea92f36..198abed841b2 100644 --- a/include/lldb/Breakpoint/BreakpointResolver.h +++ b/include/lldb/Breakpoint/BreakpointResolver.h @@ -66,8 +66,7 @@ public: /// The Destructor is virtual, all significant breakpoint resolvers derive /// from this class. //------------------------------------------------------------------ - virtual - ~BreakpointResolver (); + ~BreakpointResolver() override; //------------------------------------------------------------------ /// This sets the breakpoint for this resolver. @@ -105,8 +104,8 @@ public: /// @param[in] s /// Stream to which the output is copied. //------------------------------------------------------------------ - virtual void - GetDescription (Stream *s) = 0; + void + GetDescription(Stream *s) override = 0; //------------------------------------------------------------------ /// Standard "Dump" method. At present it does nothing. @@ -157,4 +156,4 @@ private: } // namespace lldb_private -#endif // liblldb_BreakpointResolver_h_ +#endif // liblldb_BreakpointResolver_h_ diff --git a/include/lldb/Breakpoint/BreakpointResolverAddress.h b/include/lldb/Breakpoint/BreakpointResolverAddress.h index c8f034d7345b..8ec1e39e52ab 100644 --- a/include/lldb/Breakpoint/BreakpointResolverAddress.h +++ b/include/lldb/Breakpoint/BreakpointResolverAddress.h @@ -15,6 +15,7 @@ // Other libraries and framework includes // Project includes #include "lldb/Breakpoint/BreakpointResolver.h" +#include "lldb/Core/ModuleSpec.h" namespace lldb_private { @@ -31,8 +32,11 @@ public: BreakpointResolverAddress (Breakpoint *bkpt, const Address &addr); - virtual - ~BreakpointResolverAddress (); + BreakpointResolverAddress (Breakpoint *bkpt, + const Address &addr, + const FileSpec &module_spec); + + ~BreakpointResolverAddress() override; void ResolveBreakpoint (SearchFilter &filter) override; @@ -66,12 +70,15 @@ public: CopyForBreakpoint (Breakpoint &breakpoint) override; protected: - Address m_addr; - + 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 offset, then it will be converted + // to a Section+Offset address in this module, whenever that module gets around to + // being loaded. private: DISALLOW_COPY_AND_ASSIGN(BreakpointResolverAddress); }; } // namespace lldb_private -#endif // liblldb_BreakpointResolverAddress_h_ +#endif // liblldb_BreakpointResolverAddress_h_ diff --git a/include/lldb/Breakpoint/BreakpointResolverFileLine.h b/include/lldb/Breakpoint/BreakpointResolverFileLine.h index 2403d24515a7..2dde1546f126 100644 --- a/include/lldb/Breakpoint/BreakpointResolverFileLine.h +++ b/include/lldb/Breakpoint/BreakpointResolverFileLine.h @@ -35,8 +35,7 @@ public: bool skip_prologue, bool exact_match); - virtual - ~BreakpointResolverFileLine (); + ~BreakpointResolverFileLine() override; Searcher::CallbackReturn SearchCallback (SearchFilter &filter, @@ -76,4 +75,4 @@ private: } // namespace lldb_private -#endif // liblldb_BreakpointResolverFileLine_h_ +#endif // liblldb_BreakpointResolverFileLine_h_ diff --git a/include/lldb/Breakpoint/BreakpointResolverFileRegex.h b/include/lldb/Breakpoint/BreakpointResolverFileRegex.h index 8e18fff16447..a8d7a50b5d93 100644 --- a/include/lldb/Breakpoint/BreakpointResolverFileRegex.h +++ b/include/lldb/Breakpoint/BreakpointResolverFileRegex.h @@ -32,8 +32,7 @@ public: RegularExpression ®ex, bool exact_match); - virtual - ~BreakpointResolverFileRegex (); + ~BreakpointResolverFileRegex() override; Searcher::CallbackReturn SearchCallback (SearchFilter &filter, @@ -70,4 +69,4 @@ private: } // namespace lldb_private -#endif // liblldb_BreakpointResolverFileRegex_h_ +#endif // liblldb_BreakpointResolverFileRegex_h_ diff --git a/include/lldb/Breakpoint/BreakpointResolverName.h b/include/lldb/Breakpoint/BreakpointResolverName.h index c2a5b180f289..aaae9c1a12cf 100644 --- a/include/lldb/Breakpoint/BreakpointResolverName.h +++ b/include/lldb/Breakpoint/BreakpointResolverName.h @@ -14,6 +14,7 @@ // C++ Includes #include <vector> #include <string> + // Other libraries and framework includes // Project includes #include "lldb/Breakpoint/BreakpointResolver.h" @@ -34,6 +35,7 @@ public: BreakpointResolverName (Breakpoint *bkpt, const char *name, uint32_t name_type_mask, + lldb::LanguageType language, Breakpoint::MatchType type, bool skip_prologue); @@ -42,17 +44,20 @@ public: const char *names[], size_t num_names, uint32_t name_type_mask, + lldb::LanguageType language, bool skip_prologue); // This one takes a C++ array of names. It is always MatchType = Exact. BreakpointResolverName (Breakpoint *bkpt, std::vector<std::string> names, uint32_t name_type_mask, + lldb::LanguageType language, 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, + lldb::LanguageType language, bool skip_prologue); BreakpointResolverName (Breakpoint *bkpt, @@ -61,8 +66,7 @@ public: Breakpoint::MatchType type, bool skip_prologue); - virtual - ~BreakpointResolverName (); + ~BreakpointResolverName() override; Searcher::CallbackReturn SearchCallback (SearchFilter &filter, @@ -114,6 +118,7 @@ protected: ConstString m_class_name; RegularExpression m_regex; Breakpoint::MatchType m_match_type; + lldb::LanguageType m_language; bool m_skip_prologue; void @@ -122,4 +127,4 @@ protected: } // namespace lldb_private -#endif // liblldb_BreakpointResolverName_h_ +#endif // liblldb_BreakpointResolverName_h_ diff --git a/include/lldb/Breakpoint/BreakpointSite.h b/include/lldb/Breakpoint/BreakpointSite.h index d67fc8bb57f1..6cebcab8e2db 100644 --- a/include/lldb/Breakpoint/BreakpointSite.h +++ b/include/lldb/Breakpoint/BreakpointSite.h @@ -55,7 +55,7 @@ public: // display any breakpoint opcodes. }; - virtual ~BreakpointSite (); + ~BreakpointSite() override; //---------------------------------------------------------------------- // This section manages the breakpoint traps @@ -139,8 +139,8 @@ public: /// @return /// \b true if we should stop, \b false otherwise. //------------------------------------------------------------------ - virtual bool - ShouldStop (StoppointCallbackContext *context); + bool + ShouldStop(StoppointCallbackContext *context) override; //------------------------------------------------------------------ /// Standard Dump method @@ -149,7 +149,7 @@ public: /// The stream to dump this output. //------------------------------------------------------------------ void - Dump (Stream *s) const; + Dump(Stream *s) const override; //------------------------------------------------------------------ /// The "Owners" are the breakpoint locations that share this @@ -187,6 +187,20 @@ public: GetOwnerAtIndex (size_t idx); //------------------------------------------------------------------ + /// This method copies the breakpoint site's owners into a new collection. + /// It does this while the owners mutex is locked. + /// + /// @param[out] out_collection + /// The BreakpointLocationCollection into which to put the owners + /// of this breakpoint site. + /// + /// @return + /// The number of elements copied into out_collection. + //------------------------------------------------------------------ + size_t + CopyOwnersList (BreakpointLocationCollection &out_collection); + + //------------------------------------------------------------------ /// Check whether the owners of this breakpoint site have any /// thread specifiers, and if yes, is \a thread contained in any /// of these specifiers. @@ -201,7 +215,6 @@ public: bool ValidForThisThread (Thread *thread); - //------------------------------------------------------------------ /// Print a description of this breakpoint site to the stream \a s. /// GetDescription tells you about the breakpoint site's owners. @@ -301,4 +314,4 @@ private: } // namespace lldb_private -#endif // liblldb_BreakpointSite_h_ +#endif // liblldb_BreakpointSite_h_ diff --git a/include/lldb/Breakpoint/Watchpoint.h b/include/lldb/Breakpoint/Watchpoint.h index 926e0b506f31..34df24a92c06 100644 --- a/include/lldb/Breakpoint/Watchpoint.h +++ b/include/lldb/Breakpoint/Watchpoint.h @@ -11,19 +11,17 @@ #define liblldb_Watchpoint_h_ // C Includes - // C++ Includes -#include <list> +#include <memory> #include <string> // Other libraries and framework includes - // Project includes #include "lldb/lldb-private.h" #include "lldb/Breakpoint/WatchpointOptions.h" #include "lldb/Breakpoint/StoppointLocation.h" #include "lldb/Core/UserID.h" -#include "lldb/Symbol/ClangASTType.h" +#include "lldb/Symbol/CompilerType.h" #include "lldb/Target/Target.h" namespace lldb_private { @@ -33,23 +31,20 @@ class Watchpoint : public StoppointLocation { public: - class WatchpointEventData : public EventData { public: + WatchpointEventData (lldb::WatchpointEventType sub_type, + const lldb::WatchpointSP &new_watchpoint_sp); + + ~WatchpointEventData() override; static const ConstString & GetFlavorString (); - virtual const ConstString & - GetFlavor () const; - - WatchpointEventData (lldb::WatchpointEventType sub_type, - const lldb::WatchpointSP &new_watchpoint_sp); - - virtual - ~WatchpointEventData(); + const ConstString & + GetFlavor() const override; lldb::WatchpointEventType GetWatchpointEventType () const; @@ -57,8 +52,8 @@ public: lldb::WatchpointSP & GetWatchpoint (); - virtual void - Dump (Stream *s) const; + void + Dump(Stream *s) const override; static lldb::WatchpointEventType GetWatchpointEventTypeFromEvent (const lldb::EventSP &event_sp); @@ -70,15 +65,15 @@ public: GetEventDataFromEvent (const Event *event_sp); private: - lldb::WatchpointEventType m_watchpoint_event; lldb::WatchpointSP m_new_watchpoint_sp; DISALLOW_COPY_AND_ASSIGN (WatchpointEventData); }; - Watchpoint (Target& target, lldb::addr_t addr, uint32_t size, const ClangASTType *type, bool hardware = true); - ~Watchpoint (); + Watchpoint (Target& target, lldb::addr_t addr, uint32_t size, const CompilerType *type, bool hardware = true); + + ~Watchpoint() override; void IncrementFalseAlarmsAndReviseHitCount(); @@ -89,11 +84,11 @@ public: void SetEnabled (bool enabled, bool notify = true); - virtual bool - IsHardware () const; + bool + IsHardware() const override; - virtual bool - ShouldStop (StoppointCallbackContext *context); + bool + ShouldStop(StoppointCallbackContext *context) override; bool WatchpointRead () const; bool WatchpointWrite () const; @@ -110,8 +105,8 @@ public: bool CaptureWatchedValue (const ExecutionContext &exe_ctx); void GetDescription (Stream *s, lldb::DescriptionLevel level); - void Dump (Stream *s) const; - void DumpSnapshots (Stream *s, const char * prefix = NULL) const; + void Dump (Stream *s) const override; + void DumpSnapshots(Stream *s, const char *prefix = nullptr) const; void DumpWithLevel (Stream *s, lldb::DescriptionLevel description_level) const; Target &GetTarget() { return m_target; } const Error &GetError() { return m_error; } @@ -173,7 +168,7 @@ public: /// /// @param[in] condition /// The condition expression to evaluate when the watchpoint is hit. - /// Pass in NULL to clear the condition. + /// Pass in nullptr to clear the condition. //------------------------------------------------------------------ void SetCondition (const char *condition); @@ -181,7 +176,7 @@ public: /// Return a pointer to the text of the condition expression. /// /// @return - /// A pointer to the condition expression text, or NULL if no + /// A pointer to the condition expression text, or nullptr if no // condition has been set. //------------------------------------------------------------------ const char *GetConditionText () const; @@ -195,13 +190,12 @@ public: bool IsDisabledDuringEphemeralMode(); - const ClangASTType & - GetClangASTType() + const CompilerType & + GetCompilerType() { return m_type; } - private: friend class Target; friend class WatchpointList; @@ -240,13 +234,13 @@ private: std::string m_watch_spec_str; // Spec for the watchpoint. lldb::ValueObjectSP m_old_value_sp; lldb::ValueObjectSP m_new_value_sp; - ClangASTType m_type; + CompilerType m_type; Error m_error; // An error object describing errors associated with this watchpoint. WatchpointOptions m_options; // Settable watchpoint options, which is a delegate to handle // the callback machinery. bool m_being_created; - std::unique_ptr<ClangUserExpression> m_condition_ap; // The condition to test. + std::unique_ptr<UserExpression> m_condition_ap; // The condition to test. void SetID(lldb::watch_id_t id) { m_loc_id = id; } @@ -261,4 +255,4 @@ private: } // namespace lldb_private -#endif // liblldb_Watchpoint_h_ +#endif // liblldb_Watchpoint_h_ diff --git a/include/lldb/Breakpoint/WatchpointOptions.h b/include/lldb/Breakpoint/WatchpointOptions.h index 64c65f92b44f..eb08bb32e6ce 100644 --- a/include/lldb/Breakpoint/WatchpointOptions.h +++ b/include/lldb/Breakpoint/WatchpointOptions.h @@ -12,6 +12,9 @@ // C Includes // C++ Includes +#include <memory> +#include <string> + // Other libraries and framework includes // Project includes #include "lldb/lldb-private.h" @@ -99,7 +102,6 @@ public: //------------------------------------------------------------------ void SetCallback (WatchpointHitCallback callback, const lldb::BatonSP &baton_sp, bool synchronous = false); - //------------------------------------------------------------------ /// Remove the callback from this option set. //------------------------------------------------------------------ @@ -150,10 +152,10 @@ public: const Baton *GetBaton () const; //------------------------------------------------------------------ - /// Return the current thread spec for this option. This will return NULL if the no thread + /// Return the current thread spec for this option. This will return nullptr if the no thread /// specifications have been set for this Option yet. /// @return - /// The thread specification pointer for this option, or NULL if none has + /// The thread specification pointer for this option, or nullptr if none has /// been set yet. //------------------------------------------------------------------ const ThreadSpec * @@ -196,7 +198,6 @@ public: StoppointCallbackContext *context, lldb::user_id_t watch_id); - struct CommandData { CommandData () : @@ -206,10 +207,8 @@ public: { } - ~CommandData () - { - } - + ~CommandData() = default; + StringList user_source; std::string script_source; bool stop_on_error; @@ -223,16 +222,14 @@ public: { } - virtual - ~CommandBaton () + ~CommandBaton() override { delete ((CommandData *)m_data); - m_data = NULL; + m_data = nullptr; } - virtual void - GetDescription (Stream *s, lldb::DescriptionLevel level) const; - + void + GetDescription(Stream *s, lldb::DescriptionLevel level) const override; }; protected: @@ -252,4 +249,4 @@ private: } // namespace lldb_private -#endif // liblldb_WatchpointOptions_h_ +#endif // liblldb_WatchpointOptions_h_ diff --git a/include/lldb/Core/Address.h b/include/lldb/Core/Address.h index cfa16c30bedb..0afe55b12be3 100644 --- a/include/lldb/Core/Address.h +++ b/include/lldb/Core/Address.h @@ -13,6 +13,7 @@ // C Includes // C++ Includes #include <atomic> + // Other libraries and framework includes // Project includes #include "lldb/lldb-private.h" @@ -108,7 +109,6 @@ public: { } - //------------------------------------------------------------------ /// Copy constructor /// @@ -176,6 +176,7 @@ public: const Address& operator= (const Address& rhs); #endif + //------------------------------------------------------------------ /// Clear the object's state. /// @@ -216,7 +217,7 @@ public: class ModulePointerAndOffsetLessThanFunctionObject { public: - ModulePointerAndOffsetLessThanFunctionObject () {} + ModulePointerAndOffsetLessThanFunctionObject() = default; bool operator() (const Address& a, const Address& b) const @@ -326,7 +327,8 @@ public: /// not loaded. //------------------------------------------------------------------ lldb::addr_t - GetOpcodeLoadAddress (Target *target) const; + GetOpcodeLoadAddress (Target *target, + lldb::AddressClass addr_class = lldb::eAddressClassInvalid) const; //------------------------------------------------------------------ /// Get the section relative offset value. @@ -354,7 +356,7 @@ public: bool IsSectionOffset() const { - return IsValid() && (GetSection().get() != NULL); + return IsValid() && (GetSection().get() != nullptr); } //------------------------------------------------------------------ @@ -374,7 +376,6 @@ public: return m_offset != LLDB_INVALID_ADDRESS; } - //------------------------------------------------------------------ /// Get the memory cost of this object. /// @@ -425,7 +426,9 @@ public: SetLoadAddress (lldb::addr_t load_addr, Target *target); bool - SetOpcodeLoadAddress (lldb::addr_t load_addr, Target *target); + SetOpcodeLoadAddress (lldb::addr_t load_addr, + Target *target, + lldb::AddressClass addr_class = lldb::eAddressClassInvalid); bool SetCallableLoadAddress (lldb::addr_t load_addr, Target *target); @@ -505,6 +508,7 @@ public: { m_section_wp.reset(); } + //------------------------------------------------------------------ /// Reconstruct a symbol context from an address. /// @@ -564,10 +568,8 @@ protected: //------------------------------------------------------------------ bool SectionWasDeletedPrivate() const; - }; - //---------------------------------------------------------------------- // NOTE: Be careful using this operator. It can correctly compare two // addresses from the same Module correctly. It can't compare two @@ -584,12 +586,9 @@ protected: //---------------------------------------------------------------------- bool operator< (const Address& lhs, const Address& rhs); bool operator> (const Address& lhs, const Address& rhs); - - - bool operator== (const Address& lhs, const Address& rhs); bool operator!= (const Address& lhs, const Address& rhs); } // namespace lldb_private -#endif // liblldb_Address_h_ +#endif // liblldb_Address_h_ diff --git a/include/lldb/Core/AddressRange.h b/include/lldb/Core/AddressRange.h index 9d781f3e85ae..31e3286cb110 100644 --- a/include/lldb/Core/AddressRange.h +++ b/include/lldb/Core/AddressRange.h @@ -10,6 +10,10 @@ #ifndef liblldb_AddressRange_h_ #define liblldb_AddressRange_h_ +// C Includes +// C++ Includes +// Other libraries and framework includes +// Project includes #include "lldb/Core/Address.h" namespace lldb_private { @@ -62,7 +66,7 @@ public: /// @param[in] section_list /// A list of sections, one of which may contain the \a vaddr. //------------------------------------------------------------------ - AddressRange (lldb::addr_t file_addr, lldb::addr_t byte_size, const SectionList *section_list = NULL); + AddressRange(lldb::addr_t file_addr, lldb::addr_t byte_size, const SectionList *section_list = nullptr); //------------------------------------------------------------------ /// Construct with a Address object address and byte size. @@ -281,4 +285,4 @@ protected: } // namespace lldb_private -#endif // liblldb_AddressRange_h_ +#endif // liblldb_AddressRange_h_ diff --git a/include/lldb/Core/AddressResolver.h b/include/lldb/Core/AddressResolver.h index e5fe276e3fb1..711cc57c14a4 100644 --- a/include/lldb/Core/AddressResolver.h +++ b/include/lldb/Core/AddressResolver.h @@ -54,8 +54,7 @@ public: AddressResolver (); - virtual - ~AddressResolver (); + ~AddressResolver () override; virtual void ResolveAddress (SearchFilter &filter); @@ -64,8 +63,8 @@ public: ResolveAddressInModules (SearchFilter &filter, ModuleList &modules); - virtual void - GetDescription (Stream *s) = 0; + void + GetDescription (Stream *s) override = 0; std::vector<AddressRange> & GetAddressRanges (); @@ -86,4 +85,4 @@ private: } // namespace lldb_private -#endif // liblldb_AddressResolver_h_ +#endif // liblldb_AddressResolver_h_ diff --git a/include/lldb/Core/AddressResolverFileLine.h b/include/lldb/Core/AddressResolverFileLine.h index ddeb0e0301d2..5b47379ed18e 100644 --- a/include/lldb/Core/AddressResolverFileLine.h +++ b/include/lldb/Core/AddressResolverFileLine.h @@ -30,20 +30,19 @@ public: uint32_t line_no, bool check_inlines); - virtual - ~AddressResolverFileLine (); + ~AddressResolverFileLine () override; - virtual Searcher::CallbackReturn + Searcher::CallbackReturn SearchCallback (SearchFilter &filter, SymbolContext &context, Address *addr, - bool containing); + bool containing) override; - virtual Searcher::Depth - GetDepth (); + Searcher::Depth + GetDepth () override; - virtual void - GetDescription (Stream *s); + void + GetDescription (Stream *s) override; protected: FileSpec m_file_spec; // This is the file spec we are looking for. @@ -56,4 +55,4 @@ private: } // namespace lldb_private -#endif // liblldb_AddressResolverFileLine_h_ +#endif // liblldb_AddressResolverFileLine_h_ diff --git a/include/lldb/Core/AddressResolverName.h b/include/lldb/Core/AddressResolverName.h index afde675a89bb..cf792f5054e6 100644 --- a/include/lldb/Core/AddressResolverName.h +++ b/include/lldb/Core/AddressResolverName.h @@ -38,20 +38,19 @@ public: const char *method, AddressResolver::MatchType type); - virtual - ~AddressResolverName (); + ~AddressResolverName () override; - virtual Searcher::CallbackReturn + Searcher::CallbackReturn SearchCallback (SearchFilter &filter, SymbolContext &context, Address *addr, - bool containing); + bool containing) override; - virtual Searcher::Depth - GetDepth (); + Searcher::Depth + GetDepth () override; - virtual void - GetDescription (Stream *s); + void + GetDescription (Stream *s) override; protected: ConstString m_func_name; @@ -65,4 +64,4 @@ private: } // namespace lldb_private -#endif // liblldb_AddressResolverName_h_ +#endif // liblldb_AddressResolverName_h_ diff --git a/include/lldb/Core/ArchSpec.h b/include/lldb/Core/ArchSpec.h index 0b818a0c7123..13ff436cf08f 100644 --- a/include/lldb/Core/ArchSpec.h +++ b/include/lldb/Core/ArchSpec.h @@ -65,7 +65,11 @@ public: eMIPSAse_mips16 = 0x00000400, // MIPS16 ASE eMIPSAse_micromips = 0x00000800, // MICROMIPS ASE eMIPSAse_xpa = 0x00001000, // XPA ASE - eMIPSAse_mask = 0x00001fff + eMIPSAse_mask = 0x00001fff, + eMIPSABI_O32 = 0x00002000, + eMIPSABI_N32 = 0x00004000, + eMIPSABI_N64 = 0x00008000, + eMIPSABI_mask = 0x000ff000 }; enum Core @@ -208,7 +212,11 @@ public: kCore_mips64_last = eCore_mips64r6, kCore_mips64el_first = eCore_mips64el, - kCore_mips64el_last = eCore_mips64r6el + kCore_mips64el_last = eCore_mips64r6el, + + kCore_mips_first = eCore_mips32, + kCore_mips_last = eCore_mips64r6el + }; typedef void (* StopInfoOverrideCallbackType)(lldb_private::Thread &thread); @@ -337,10 +345,28 @@ public: } bool + TripleVendorIsUnspecifiedUnknown() const + { + return m_triple.getVendor() == llvm::Triple::UnknownVendor && m_triple.getVendorName().empty(); + } + + bool TripleOSWasSpecified() const { return !m_triple.getOSName().empty(); } + + bool + TripleEnvironmentWasSpecified () const + { + return !m_triple.getEnvironmentName().empty(); + } + + bool + TripleOSIsUnspecifiedUnknown() const + { + return m_triple.getOS() == llvm::Triple::UnknownOS && m_triple.getOSName().empty(); + } //------------------------------------------------------------------ /// Merges fields from another ArchSpec into this ArchSpec. @@ -480,6 +506,9 @@ public: return m_triple; } + void + DumpTriple(Stream &s) const; + //------------------------------------------------------------------ /// Architecture tripple setter. /// @@ -564,7 +593,18 @@ public: //------------------------------------------------------------------ StopInfoOverrideCallbackType GetStopInfoOverrideCallback () const; + + bool + IsFullySpecifiedTriple () const; + void + PiecewiseTripleCompare (const ArchSpec &other, + bool &arch_different, + bool &vendor_different, + bool &os_different, + bool &os_version_different, + bool &env_different); + uint32_t GetFlags () const { diff --git a/include/lldb/Core/Broadcaster.h b/include/lldb/Core/Broadcaster.h index 6d54b1b43133..8e59a41805ec 100644 --- a/include/lldb/Core/Broadcaster.h +++ b/include/lldb/Core/Broadcaster.h @@ -42,7 +42,7 @@ public: BroadcastEventSpec (const BroadcastEventSpec &rhs); - ~BroadcastEventSpec() {} + ~BroadcastEventSpec() = default; const ConstString &GetBroadcasterClass() const { @@ -89,7 +89,7 @@ public: BroadcasterManager (); - ~BroadcasterManager () {} + ~BroadcasterManager() = default; uint32_t RegisterListenerForEvents (Listener &listener, BroadcastEventSpec event_spec); @@ -128,7 +128,7 @@ private: { } - ~BroadcasterClassMatches () {} + ~BroadcasterClassMatches() = default; bool operator() (const event_listener_key input) const { @@ -147,7 +147,7 @@ private: { } - ~BroadcastEventSpecMatches () {} + ~BroadcastEventSpecMatches() = default; bool operator() (const event_listener_key input) const { @@ -168,7 +168,7 @@ private: { } - ~ListenerMatchesAndSharedBits () {} + ~ListenerMatchesAndSharedBits() = default; bool operator() (const event_listener_key input) const { @@ -190,7 +190,7 @@ private: { } - ~ListenerMatches() {} + ~ListenerMatches() = default; bool operator () (const event_listener_key input) const { @@ -204,7 +204,6 @@ private: const Listener *m_listener; }; - }; //---------------------------------------------------------------------- @@ -286,10 +285,10 @@ public: BroadcastEventIfUnique (lldb::EventSP &event_sp); void - BroadcastEvent (uint32_t event_type, EventData *event_data = NULL); + BroadcastEvent(uint32_t event_type, EventData *event_data = nullptr); void - BroadcastEventIfUnique (uint32_t event_type, EventData *event_data = NULL); + BroadcastEventIfUnique(uint32_t event_type, EventData *event_data = nullptr); void Clear(); @@ -332,7 +331,6 @@ public: const ConstString & GetBroadcasterName (); - //------------------------------------------------------------------ /// Get the event name(s) for one or more event bits. /// @@ -364,10 +362,10 @@ public: const char * GetEventName (uint32_t event_mask) const { - event_names_map::const_iterator pos = m_event_names.find (event_mask); + const auto pos = m_event_names.find (event_mask); if (pos != m_event_names.end()) return pos->second.c_str(); - return NULL; + return nullptr; } bool @@ -437,8 +435,6 @@ public: BroadcasterManager *GetManager(); protected: - - void PrivateBroadcastEvent (lldb::EventSP &event_sp, bool unique); diff --git a/include/lldb/Core/ClangForward.h b/include/lldb/Core/ClangForward.h index 6c627c2ad3b7..80abc15f671c 100644 --- a/include/lldb/Core/ClangForward.h +++ b/include/lldb/Core/ClangForward.h @@ -132,6 +132,8 @@ namespace clang namespace llvm { + class APInt; + class APSInt; class LLVMContext; class ExecutionEngine; } diff --git a/include/lldb/Core/Communication.h b/include/lldb/Core/Communication.h index 7924ed293d3c..d29aaca9c2ea 100644 --- a/include/lldb/Core/Communication.h +++ b/include/lldb/Core/Communication.h @@ -100,7 +100,6 @@ public: typedef void (*ReadThreadBytesReceived) (void *baton, const void *src, size_t src_len); - //------------------------------------------------------------------ /// Construct the Communication object with the specified name for /// the Broadcaster that this object inherits from. @@ -118,8 +117,7 @@ public: /// /// The destructor is virtual since this class gets subclassed. //------------------------------------------------------------------ - virtual - ~Communication(); + ~Communication() override; void Clear (); @@ -157,7 +155,7 @@ public: /// @see bool Connection::Disconnect (); //------------------------------------------------------------------ lldb::ConnectionStatus - Disconnect (Error *error_ptr = NULL); + Disconnect(Error *error_ptr = nullptr); //------------------------------------------------------------------ /// Check if the connection is valid. @@ -177,6 +175,7 @@ public: { return m_connection_sp.get(); } + //------------------------------------------------------------------ /// Read bytes from the current connection. /// @@ -278,7 +277,7 @@ public: /// @see void Communication::AppendBytesToCache (const uint8_t * bytes, size_t len, bool broadcast); //------------------------------------------------------------------ virtual bool - StartReadThread (Error *error_ptr = NULL); + StartReadThread(Error *error_ptr = nullptr); //------------------------------------------------------------------ /// Stops the read thread by cancelling it. @@ -288,10 +287,10 @@ public: /// false otherwise. //------------------------------------------------------------------ virtual bool - StopReadThread (Error *error_ptr = NULL); + StopReadThread(Error *error_ptr = nullptr); virtual bool - JoinReadThread (Error *error_ptr = NULL); + JoinReadThread(Error *error_ptr = nullptr); //------------------------------------------------------------------ /// Checks if there is a currently running read thread. /// @@ -323,7 +322,6 @@ public: SetReadThreadBytesReceivedCallback (ReadThreadBytesReceived callback, void *callback_baton); - //------------------------------------------------------------------ /// Wait for the read thread to process all outstanding data. /// @@ -350,18 +348,11 @@ public: static ConstString &GetStaticBroadcasterClass (); - virtual ConstString &GetBroadcasterClass() const + ConstString &GetBroadcasterClass() const override { return GetStaticBroadcasterClass(); } -private: - //------------------------------------------------------------------ - // For Communication only - //------------------------------------------------------------------ - DISALLOW_COPY_AND_ASSIGN (Communication); - - protected: lldb::ConnectionSP m_connection_sp; ///< The connection that is current in use by this communications class. HostThread m_read_thread; ///< The read thread handle in case we need to cancel the thread. @@ -381,6 +372,7 @@ protected: uint32_t timeout_usec, lldb::ConnectionStatus &status, Error *error_ptr); + //------------------------------------------------------------------ /// Append new bytes that get read from the read thread into the /// internal object byte cache. This will cause a \b @@ -424,8 +416,11 @@ protected: //------------------------------------------------------------------ size_t GetCachedBytes (void *dst, size_t dst_len); + +private: + DISALLOW_COPY_AND_ASSIGN (Communication); }; } // namespace lldb_private -#endif // liblldb_Communication_h_ +#endif // liblldb_Communication_h_ diff --git a/include/lldb/Core/Connection.h b/include/lldb/Core/Connection.h index 121395c0b23c..4b3024ebdc57 100644 --- a/include/lldb/Core/Connection.h +++ b/include/lldb/Core/Connection.h @@ -58,7 +58,7 @@ public: /// /// @param[out] error_ptr /// A pointer to an error object that should be given an - /// approriate error value if this method returns false. This + /// appropriate error value if this method returns false. This /// value can be NULL if the error value should be ignored. /// /// @return @@ -77,7 +77,7 @@ public: /// /// @param[out] error_ptr /// A pointer to an error object that should be given an - /// approriate error value if this method returns false. This + /// appropriate error value if this method returns false. This /// value can be NULL if the error value should be ignored. /// /// @return @@ -115,12 +115,12 @@ public: /// The number of microseconds to wait for the data. /// /// @param[out] status - /// On return, indicates whether the call was sucessful or terminated + /// On return, indicates whether the call was successful or terminated /// due to some error condition. /// /// @param[out] error_ptr /// A pointer to an error object that should be given an - /// approriate error value if this method returns zero. This + /// appropriate error value if this method returns zero. This /// value can be NULL if the error value should be ignored. /// /// @return @@ -151,7 +151,7 @@ public: /// /// @param[out] error_ptr /// A pointer to an error object that should be given an - /// approriate error value if this method returns zero. This + /// appropriate error value if this method returns zero. This /// value can be NULL if the error value should be ignored. /// /// @return @@ -182,7 +182,7 @@ public: /// operation). /// /// @return - /// Returns true is the interrupt request was sucessful. + /// Returns true is the interrupt request was successful. //------------------------------------------------------------------ virtual bool InterruptRead() = 0; diff --git a/include/lldb/Core/ConnectionSharedMemory.h b/include/lldb/Core/ConnectionSharedMemory.h index 48e62142954e..d0553699e14e 100644 --- a/include/lldb/Core/ConnectionSharedMemory.h +++ b/include/lldb/Core/ConnectionSharedMemory.h @@ -28,33 +28,32 @@ public: ConnectionSharedMemory (); - virtual - ~ConnectionSharedMemory (); + ~ConnectionSharedMemory () override; - virtual bool - IsConnected () const; + bool + IsConnected () const override; virtual lldb::ConnectionStatus BytesAvailable (uint32_t timeout_usec, Error *error_ptr); - virtual lldb::ConnectionStatus - Connect (const char *s, Error *error_ptr); + lldb::ConnectionStatus + Connect (const char *s, Error *error_ptr) override; - virtual lldb::ConnectionStatus - Disconnect (Error *error_ptr); + lldb::ConnectionStatus + Disconnect (Error *error_ptr) override; - virtual size_t + size_t Read (void *dst, size_t dst_len, uint32_t timeout_usec, lldb::ConnectionStatus &status, - Error *error_ptr); + Error *error_ptr) override; - virtual size_t - Write (const void *src, size_t src_len, lldb::ConnectionStatus &status, Error *error_ptr); + size_t + Write (const void *src, size_t src_len, lldb::ConnectionStatus &status, Error *error_ptr) override; - virtual std::string - GetURI(); + std::string + GetURI() override; lldb::ConnectionStatus Open (bool create, const char *name, size_t size, Error *error_ptr); @@ -64,10 +63,12 @@ protected: std::string m_name; int m_fd; // One buffer that contains all we need DataBufferMemoryMap m_mmap; + private: + DISALLOW_COPY_AND_ASSIGN (ConnectionSharedMemory); }; } // namespace lldb_private -#endif // liblldb_ConnectionSharedMemory_h_ +#endif // liblldb_ConnectionSharedMemory_h_ diff --git a/include/lldb/Core/ConstString.h b/include/lldb/Core/ConstString.h index cfe8ea2db0e1..6e234da0a595 100644 --- a/include/lldb/Core/ConstString.h +++ b/include/lldb/Core/ConstString.h @@ -9,13 +9,14 @@ #ifndef liblldb_ConstString_h_ #define liblldb_ConstString_h_ -#if defined(__cplusplus) -#include <assert.h> - -#include "lldb/lldb-private.h" +// C Includes +// C++ Includes +// Other libraries and framework includes #include "llvm/ADT/StringRef.h" +// Project includes +#include "lldb/lldb-private.h" namespace lldb_private { @@ -41,12 +42,11 @@ public: /// /// Initializes the string to an empty string. //------------------------------------------------------------------ - ConstString (): - m_string (NULL) + ConstString(): + m_string(nullptr) { } - //------------------------------------------------------------------ /// Copy constructor /// @@ -105,10 +105,7 @@ public: /// Since constant string values are currently not reference counted, /// there isn't much to do here. //------------------------------------------------------------------ - ~ConstString () - { - } - + ~ConstString() = default; //---------------------------------------------------------------------- /// C string equality binary predicate function object for ConstString @@ -224,18 +221,16 @@ public: /// Get the value of the contained string as a NULL terminated C /// string value. /// - /// If \a value_if_empty is NULL, then NULL will be returned. + /// If \a value_if_empty is nullptr, then nullptr will be returned. /// /// @return /// Returns \a value_if_empty if the string is empty, otherwise /// the C string value contained in this object. //------------------------------------------------------------------ const char * - AsCString(const char *value_if_empty = NULL) const + AsCString(const char *value_if_empty = nullptr) const { - if (IsEmpty()) - return value_if_empty; - return m_string; + return (IsEmpty() ? value_if_empty : m_string); } //------------------------------------------------------------------ @@ -256,12 +251,12 @@ public: /// /// Get the value of the contained string as a NULL terminated C /// string value. Similar to the ConstString::AsCString() function, - /// yet this function will always return NULL if the string is not + /// yet this function will always return nullptr if the string is not /// valid. So this function is a direct accessor to the string /// pointer value. /// /// @return - /// Returns NULL the string is invalid, otherwise the C string + /// Returns nullptr the string is invalid, otherwise the C string /// value contained in this object. //------------------------------------------------------------------ const char * @@ -270,7 +265,6 @@ public: return m_string; } - //------------------------------------------------------------------ /// Get the length in bytes of string value. /// @@ -293,7 +287,7 @@ public: void Clear () { - m_string = NULL; + m_string = nullptr; } //------------------------------------------------------------------ @@ -326,18 +320,18 @@ public: /// /// Dump the string value to the stream \a s. If the contained string /// is empty, print \a value_if_empty to the stream instead. If - /// \a value_if_empty is NULL, then nothing will be dumped to the + /// \a value_if_empty is nullptr, then nothing will be dumped to the /// stream. /// /// @param[in] s /// The stream that will be used to dump the object description. /// /// @param[in] value_if_empty - /// The value to dump if the string is empty. If NULL, nothing + /// The value to dump if the string is empty. If nullptr, nothing /// will be output to the stream. //------------------------------------------------------------------ void - Dump (Stream *s, const char *value_if_empty = NULL) const; + Dump(Stream *s, const char *value_if_empty = nullptr) const; //------------------------------------------------------------------ /// Dump the object debug description to a stream. @@ -358,7 +352,7 @@ public: bool IsEmpty () const { - return m_string == NULL || m_string[0] == '\0'; + return m_string == nullptr || m_string[0] == '\0'; } //------------------------------------------------------------------ @@ -473,7 +467,6 @@ public: { return sizeof(ConstString); } - //------------------------------------------------------------------ /// Get the size in bytes of the current global string pool. @@ -503,5 +496,4 @@ Stream& operator << (Stream& s, const ConstString& str); } // namespace lldb_private -#endif // #if defined(__cplusplus) -#endif // liblldb_ConstString_h_ +#endif // liblldb_ConstString_h_ diff --git a/include/lldb/Core/DataBufferHeap.h b/include/lldb/Core/DataBufferHeap.h index ad73fabe5f1e..d379c4cf4e86 100644 --- a/include/lldb/Core/DataBufferHeap.h +++ b/include/lldb/Core/DataBufferHeap.h @@ -9,7 +9,6 @@ #ifndef liblldb_DataBufferHeap_h_ #define liblldb_DataBufferHeap_h_ -#if defined(__cplusplus) #include <vector> @@ -69,26 +68,25 @@ public: /// Virtual destructor since this class inherits from a pure virtual /// base class #DataBuffer. //------------------------------------------------------------------ - virtual - ~DataBufferHeap(); + ~DataBufferHeap() override; //------------------------------------------------------------------ /// @copydoc DataBuffer::GetBytes() //------------------------------------------------------------------ - virtual uint8_t * - GetBytes (); + uint8_t * + GetBytes () override; //------------------------------------------------------------------ /// @copydoc DataBuffer::GetBytes() const //------------------------------------------------------------------ - virtual const uint8_t * - GetBytes () const; + const uint8_t * + GetBytes () const override; //------------------------------------------------------------------ /// @copydoc DataBuffer::GetByteSize() const //------------------------------------------------------------------ - virtual lldb::offset_t - GetByteSize () const; + lldb::offset_t + GetByteSize () const override; //------------------------------------------------------------------ /// Set the number of bytes in the data buffer. @@ -138,5 +136,4 @@ private: } // namespace lldb_private -#endif // #if defined(__cplusplus) -#endif // liblldb_DataBufferHeap_h_ +#endif // liblldb_DataBufferHeap_h_ diff --git a/include/lldb/Core/DataBufferMemoryMap.h b/include/lldb/Core/DataBufferMemoryMap.h index 944b975a318a..9479d4e1a455 100644 --- a/include/lldb/Core/DataBufferMemoryMap.h +++ b/include/lldb/Core/DataBufferMemoryMap.h @@ -9,8 +9,6 @@ #ifndef liblldb_DataBufferMemoryMap_h_ #define liblldb_DataBufferMemoryMap_h_ -#if defined(__cplusplus) - #include "lldb/lldb-private.h" #include "lldb/Core/DataBuffer.h" @@ -45,8 +43,7 @@ public: /// Virtual destructor since this class inherits from a pure virtual /// base class #DataBuffer. //------------------------------------------------------------------ - virtual - ~DataBufferMemoryMap (); + ~DataBufferMemoryMap () override; //------------------------------------------------------------------ /// Reverts this object to an empty state by unmapping any memory @@ -58,20 +55,20 @@ public: //------------------------------------------------------------------ /// @copydoc DataBuffer::GetBytes() //------------------------------------------------------------------ - virtual uint8_t * - GetBytes (); + uint8_t * + GetBytes () override; //------------------------------------------------------------------ /// @copydoc DataBuffer::GetBytes() const //------------------------------------------------------------------ - virtual const uint8_t * - GetBytes () const; + const uint8_t * + GetBytes () const override; //------------------------------------------------------------------ /// @copydoc DataBuffer::GetByteSize() const //------------------------------------------------------------------ - virtual lldb::offset_t - GetByteSize () const; + lldb::offset_t + GetByteSize () const override; //------------------------------------------------------------------ /// Error get accessor. @@ -161,5 +158,4 @@ private: } // namespace lldb_private -#endif // #if defined(__cplusplus) -#endif // liblldb_DataBufferMemoryMap_h_ +#endif // liblldb_DataBufferMemoryMap_h_ diff --git a/include/lldb/Core/DataEncoder.h b/include/lldb/Core/DataEncoder.h index 7889f4191e50..8b4727eb2de2 100644 --- a/include/lldb/Core/DataEncoder.h +++ b/include/lldb/Core/DataEncoder.h @@ -252,7 +252,7 @@ public: /// The offset in bytes into the contained data at which to /// start encoding. /// - /// @param[int] src + /// @param[in] src /// The buffer that contains the bytes to encode. /// /// @param[in] src_len diff --git a/include/lldb/Core/DataExtractor.h b/include/lldb/Core/DataExtractor.h index e61189b98103..d5cb5e8ba4bc 100644 --- a/include/lldb/Core/DataExtractor.h +++ b/include/lldb/Core/DataExtractor.h @@ -9,17 +9,18 @@ #ifndef liblldb_DataExtractor_h_ #define liblldb_DataExtractor_h_ -#if defined (__cplusplus) - - -#include "lldb/lldb-private.h" - -#include "llvm/ADT/SmallVector.h" +// C Includes #include <limits.h> #include <stdint.h> #include <string.h> -#include <vector> + +// C++ Includes +// Other libraries and framework includes +#include "llvm/ADT/SmallVector.h" + +// Project includes +#include "lldb/lldb-private.h" namespace lldb_private { @@ -64,6 +65,7 @@ public: size_t src_len, uint32_t bytes_per_line, lldb::addr_t base_addr); // Pass LLDB_INVALID_ADDRESS to not show address at start of line + //------------------------------------------------------------------ /// Default constructor. /// @@ -146,6 +148,7 @@ public: DataExtractor (const DataExtractor& data, lldb::offset_t offset, lldb::offset_t length, uint32_t target_byte_size = 1); DataExtractor (const DataExtractor& rhs); + //------------------------------------------------------------------ /// Assignment operator. /// @@ -183,14 +186,14 @@ public: //------------------------------------------------------------------ /// Dumps the binary data as \a type objects to stream \a s (or to - /// Log() if \a s is NULL) starting \a offset bytes into the data + /// Log() if \a s is nullptr) starting \a offset bytes into the data /// and stopping after dumping \a length bytes. The offset into the /// data is displayed at the beginning of each line and can be /// offset by base address \a base_addr. \a num_per_line objects /// will be displayed on each line. /// /// @param[in] s - /// The stream to dump the output to. If NULL the output will + /// The stream to dump the output to. If nullptr the output will /// be dumped to Log(). /// /// @param[in] offset @@ -212,19 +215,19 @@ public: /// /// @param[in] type_format /// The optional format to use for the \a type objects. If this - /// is NULL, the default format for the \a type will be used. + /// is nullptr, the default format for the \a type will be used. /// /// @return /// The offset at which dumping ended. //------------------------------------------------------------------ lldb::offset_t - PutToLog (Log *log, - lldb::offset_t offset, - lldb::offset_t length, - uint64_t base_addr, - uint32_t num_per_line, - Type type, - const char *type_format = NULL) const; + PutToLog(Log *log, + lldb::offset_t offset, + lldb::offset_t length, + uint64_t base_addr, + uint32_t num_per_line, + Type type, + const char *type_format = nullptr) const; //------------------------------------------------------------------ /// Dumps \a item_count objects into the stream \a s. @@ -241,7 +244,7 @@ public: /// item_bit_size and \a item_bit_offset values. /// /// @param[in] s - /// The stream to dump the output to. This value can not be NULL. + /// The stream to dump the output to. This value can not be nullptr. /// /// @param[in] offset /// The offset into the data at which to start dumping. @@ -287,25 +290,25 @@ public: /// The offset at which dumping ended. //------------------------------------------------------------------ lldb::offset_t - Dump (Stream *s, - lldb::offset_t offset, - lldb::Format item_format, - size_t item_byte_size, - size_t item_count, - size_t num_per_line, - uint64_t base_addr, - uint32_t item_bit_size, - uint32_t item_bit_offset, - ExecutionContextScope *exe_scope = NULL) const; + Dump(Stream *s, + lldb::offset_t offset, + lldb::Format item_format, + size_t item_byte_size, + size_t item_count, + size_t num_per_line, + uint64_t base_addr, + uint32_t item_bit_size, + uint32_t item_bit_offset, + ExecutionContextScope *exe_scope = nullptr) const; //------------------------------------------------------------------ /// Dump a UUID value at \a offset. /// /// Dump a UUID starting at \a offset bytes into this object's data. - /// If the stream \a s is NULL, the output will be sent to Log(). + /// If the stream \a s is nullptr, the output will be sent to Log(). /// /// @param[in] s - /// The stream to dump the output to. If NULL the output will + /// The stream to dump the output to. If nullptr the output will /// be dumped to Log(). /// /// @param[in] offset @@ -418,7 +421,7 @@ public: /// A pointer to the C string value in the data. If the offset /// pointed to by \a offset_ptr is out of bounds, or if the /// offset plus the length of the C string is out of bounds, - /// NULL will be returned. + /// nullptr will be returned. //------------------------------------------------------------------ const char * GetCStr (lldb::offset_t *offset_ptr) const; @@ -443,7 +446,7 @@ public: /// A pointer to the C string value in the data. If the offset /// pointed to by \a offset_ptr is out of bounds, or if the /// offset plus the length of the field is out of bounds, or if - /// the field does not contain a NULL terminator byte, NULL will + /// the field does not contain a NULL terminator byte, nullptr will /// be returned. const char * GetCStr (lldb::offset_t *offset_ptr, lldb::offset_t len) const; @@ -454,7 +457,7 @@ public: /// Returns a pointer to a bytes in this object's data at the offset /// pointed to by \a offset_ptr. If \a length is zero or too large, /// then the offset pointed to by \a offset_ptr will not be updated - /// and NULL will be returned. + /// and nullptr will be returned. /// /// @param[in,out] offset_ptr /// A pointer to an offset within the data that will be advanced @@ -469,7 +472,7 @@ public: /// /// @return /// A pointer to the bytes in this object's data if the offset - /// and length are valid, or NULL otherwise. + /// and length are valid, or nullptr otherwise. //------------------------------------------------------------------ const void* GetData (lldb::offset_t *offset_ptr, lldb::offset_t length) const @@ -552,7 +555,7 @@ public: /// /// @return /// Returns a pointer to the next byte contained in this - /// object's data, or NULL of there is no data in this object. + /// object's data, or nullptr of there is no data in this object. //------------------------------------------------------------------ const uint8_t * GetDataEnd () const @@ -578,7 +581,7 @@ public: /// /// @return /// Returns a pointer to the first byte contained in this - /// object's data, or NULL of there is no data in this object. + /// object's data, or nullptr of there is no data in this object. //------------------------------------------------------------------ const uint8_t * GetDataStart () const @@ -586,7 +589,6 @@ public: return m_start; } - //------------------------------------------------------------------ /// Extract a float from \a *offset_ptr. /// @@ -908,7 +910,7 @@ public: /// /// @return /// \a dst if all values were properly extracted and copied, - /// NULL otherwise. + /// nullptr otherwise. //------------------------------------------------------------------ void * GetU8 (lldb::offset_t *offset_ptr, void *dst, uint32_t count) const; @@ -955,7 +957,7 @@ public: /// /// @return /// \a dst if all values were properly extracted and copied, - /// NULL otherwise. + /// nullptr otherwise. //------------------------------------------------------------------ void * GetU16 (lldb::offset_t *offset_ptr, void *dst, uint32_t count) const; @@ -1002,7 +1004,7 @@ public: /// /// @return /// \a dst if all values were properly extracted and copied, - /// NULL otherwise. + /// nullptr otherwise. //------------------------------------------------------------------ void * GetU32 (lldb::offset_t *offset_ptr, void *dst, uint32_t count) const; @@ -1049,7 +1051,7 @@ public: /// /// @return /// \a dst if all values were properly extracted and copied, - /// NULL otherwise. + /// nullptr otherwise. //------------------------------------------------------------------ void * GetU64 ( lldb::offset_t *offset_ptr, void *dst, uint32_t count) const; @@ -1113,8 +1115,8 @@ public: /// An offset into the data. /// /// @return - /// A non-NULL C string pointer if \a offset is a valid offset, - /// NULL otherwise. + /// A non-nullptr C string pointer if \a offset is a valid offset, + /// nullptr otherwise. //------------------------------------------------------------------ const char * PeekCStr (lldb::offset_t offset) const; @@ -1126,8 +1128,8 @@ public: /// there are \a length bytes available starting at \a offset. /// /// @return - /// A non-NULL data pointer if \a offset is a valid offset and - /// there are \a length bytes available at that offset, NULL + /// A non-nullptr data pointer if \a offset is a valid offset and + /// there are \a length bytes available at that offset, nullptr /// otherwise. //------------------------------------------------------------------ const uint8_t* @@ -1135,7 +1137,7 @@ public: { if (length > 0 && ValidOffsetForDataOfSize(offset, length)) return m_start + offset; - return NULL; + return nullptr; } //------------------------------------------------------------------ @@ -1150,6 +1152,9 @@ public: void SetAddressByteSize (uint32_t addr_size) { +#ifdef LLDB_CONFIGURATION_DEBUG + assert (addr_size == 4 || addr_size == 8); +#endif m_addr_size = addr_size; } @@ -1159,7 +1164,7 @@ public: /// Use data that is owned by the caller when extracting values. /// The data must stay around as long as this object, or any object /// that copies a subset of this object's data, is valid. If \a - /// bytes is NULL, or \a length is zero, this object will contain + /// bytes is nullptr, or \a length is zero, this object will contain /// no data. /// /// @param[in] bytes @@ -1317,10 +1322,8 @@ public: void Checksum (llvm::SmallVectorImpl<uint8_t> &dest, uint64_t max_data = 0); - protected: - //------------------------------------------------------------------ // Member variables //------------------------------------------------------------------ @@ -1334,5 +1337,4 @@ protected: } // namespace lldb_private -#endif // #if defined (__cplusplus) -#endif // #ifndef liblldb_DataExtractor_h_ +#endif // liblldb_DataExtractor_h_ diff --git a/include/lldb/Core/Debugger.h b/include/lldb/Core/Debugger.h index 0d9b90c8919d..4ca648ca296e 100644 --- a/include/lldb/Core/Debugger.h +++ b/include/lldb/Core/Debugger.h @@ -9,11 +9,17 @@ #ifndef liblldb_Debugger_h_ #define liblldb_Debugger_h_ -#if defined(__cplusplus) - +// C Includes #include <stdint.h> +// C++ Includes +#include <memory> +#include <map> +#include <vector> + +// Other libraries and framework includes +// Project includes #include "lldb/lldb-public.h" #include "lldb/Core/Broadcaster.h" #include "lldb/Core/FormatEntity.h" @@ -32,8 +38,8 @@ namespace llvm namespace sys { class DynamicLibrary; -} -} +} // namespace sys +} // namespace llvm namespace lldb_private { @@ -44,7 +50,6 @@ namespace lldb_private { /// Provides a global root objects for the debugger core. //---------------------------------------------------------------------- - class Debugger : public std::enable_shared_from_this<Debugger>, public UserID, @@ -54,9 +59,10 @@ class Debugger : friend class SourceManager; // For GetSourceFileCache. public: + ~Debugger() override; static lldb::DebuggerSP - CreateInstance (lldb::LogOutputCallback log_callback = NULL, void *baton = NULL); + CreateInstance(lldb::LogOutputCallback log_callback = nullptr, void *baton = nullptr); static lldb::TargetSP FindTargetWithProcessID (lldb::pid_t pid); @@ -79,9 +85,26 @@ public: static void Destroy (lldb::DebuggerSP &debugger_sp); - virtual - ~Debugger (); + static lldb::DebuggerSP + FindDebuggerWithID(lldb::user_id_t id); + static lldb::DebuggerSP + FindDebuggerWithInstanceName(const ConstString &instance_name); + + static size_t + GetNumDebuggers(); + + static lldb::DebuggerSP + GetDebuggerAtIndex(size_t index); + + static bool + FormatDisassemblerAddress(const FormatEntity::Entry *format, + const SymbolContext *sc, + const SymbolContext *prev_sc, + const ExecutionContext *exe_ctx, + const Address *addr, + Stream &s); + void Clear(); bool @@ -108,8 +131,6 @@ public: return m_error_file_sp; } - - void SetInputFileHandle (FILE *fh, bool tranfer_ownership); @@ -209,6 +230,10 @@ public: bool IsTopIOHandler (const lldb::IOHandlerSP& reader_sp); + + bool + CheckTopIOHandlerTypes (IOHandler::Type top_type, + IOHandler::Type second_top_type); void PrintAsync (const char *s, size_t len, bool is_stdout); @@ -222,26 +247,6 @@ public: const char * GetIOHandlerHelpPrologue(); - static lldb::DebuggerSP - FindDebuggerWithID (lldb::user_id_t id); - - static lldb::DebuggerSP - FindDebuggerWithInstanceName (const ConstString &instance_name); - - static size_t - GetNumDebuggers(); - - static lldb::DebuggerSP - GetDebuggerAtIndex (size_t index); - - static bool - FormatDisassemblerAddress (const FormatEntity::Entry *format, - const SymbolContext *sc, - const SymbolContext *prev_sc, - const ExecutionContext *exe_ctx, - const Address *addr, - Stream &s); - void ClearIOHandlers (); @@ -257,22 +262,22 @@ public: void SetLoggingCallback (lldb::LogOutputCallback log_callback, void *baton); - //---------------------------------------------------------------------- // Properties Functions //---------------------------------------------------------------------- enum StopDisassemblyType { eStopDisassemblyTypeNever = 0, + eStopDisassemblyTypeNoDebugInfo, eStopDisassemblyTypeNoSource, eStopDisassemblyTypeAlways }; - virtual Error - SetPropertyValue (const ExecutionContext *exe_ctx, - VarSetOperationType op, - const char *property_path, - const char *value); + Error + SetPropertyValue(const ExecutionContext *exe_ctx, + VarSetOperationType op, + const char *property_path, + const char *value) override; bool GetAutoConfirm () const; @@ -329,6 +334,24 @@ public: GetAutoOneLineSummaries () const; bool + GetAutoIndent () const; + + bool + SetAutoIndent (bool b); + + bool + GetPrintDecls () const; + + bool + SetPrintDecls (bool b); + + uint32_t + GetTabSize () const; + + bool + SetTabSize (uint32_t tab_size); + + bool GetEscapeNonPrintables () const; bool @@ -360,6 +383,9 @@ public: { return m_event_handler_thread.IsJoinable(); } + + Error + RunREPL (lldb::LanguageType language, const char *repl_options); // This is for use in the command interpreter, when you either want the selected target, or if no target // is present you want to prime the dummy target with entities that will be copied over to new targets. @@ -367,8 +393,8 @@ public: Target *GetDummyTarget(); protected: - friend class CommandInterpreter; + friend class REPL; bool StartEventHandlerThread(); @@ -380,11 +406,17 @@ protected: EventHandlerThread (lldb::thread_arg_t arg); bool + HasIOHandlerThread(); + + bool StartIOHandlerThread(); void StopIOHandlerThread(); + void + JoinIOHandlerThread(); + static lldb::thread_result_t IOHandlerThread (lldb::thread_arg_t arg); @@ -450,16 +482,13 @@ protected: }; private: - // Use Debugger::CreateInstance() to get a shared pointer to a new // debugger object Debugger (lldb::LogOutputCallback m_log_callback, void *baton); DISALLOW_COPY_AND_ASSIGN (Debugger); - }; } // namespace lldb_private -#endif // #if defined(__cplusplus) -#endif // liblldb_Debugger_h_ +#endif // liblldb_Debugger_h_ diff --git a/include/lldb/Core/Disassembler.h b/include/lldb/Core/Disassembler.h index e08e2def4c18..bfa99de81ea4 100644 --- a/include/lldb/Core/Disassembler.h +++ b/include/lldb/Core/Disassembler.h @@ -48,6 +48,7 @@ public: CalculateMnemonicOperandsAndCommentIfNeeded (exe_ctx); return m_opcode_name.c_str(); } + const char * GetOperands (const ExecutionContext* exe_ctx) { @@ -127,7 +128,6 @@ public: /// so this method can properly align the instruction opcodes. /// May be 0 to indicate no indentation/alignment of the opcodes. //------------------------------------------------------------------ - virtual void Dump (Stream *s, uint32_t max_opcode_byte_size, @@ -142,6 +142,9 @@ public: virtual bool DoesBranch () = 0; + virtual bool + HasDelaySlot (); + virtual size_t Decode (const Disassembler &disassembler, const DataExtractor& data, @@ -208,7 +211,6 @@ protected: } }; - class InstructionList { public: @@ -260,30 +262,32 @@ public: PseudoInstruction (); - virtual - ~PseudoInstruction (); + ~PseudoInstruction() override; - virtual bool - DoesBranch (); + bool + DoesBranch() override; - virtual void - CalculateMnemonicOperandsAndComment (const ExecutionContext* exe_ctx) + bool + HasDelaySlot() override; + + void + CalculateMnemonicOperandsAndComment(const ExecutionContext* exe_ctx) override { // TODO: fill this in and put opcode name into Instruction::m_opcode_name, // mnemonic into Instruction::m_mnemonics, and any comment into // Instruction::m_comment } - virtual size_t - Decode (const Disassembler &disassembler, - const DataExtractor &data, - lldb::offset_t data_offset); + size_t + Decode(const Disassembler &disassembler, + const DataExtractor &data, + lldb::offset_t data_offset) override; void SetOpcode (size_t opcode_size, void *opcode_data); - virtual void - SetDescription (const char *description); + void + SetDescription(const char *description) override; protected: std::string m_description; @@ -405,7 +409,7 @@ public: // Constructors and Destructors //------------------------------------------------------------------ Disassembler(const ArchSpec &arch, const char *flavor); - virtual ~Disassembler(); + ~Disassembler() override; typedef const char * (*SummaryCallback)(const Instruction& inst, ExecutionContext *exe_context, void *user_data); @@ -478,4 +482,4 @@ private: } // namespace lldb_private -#endif // liblldb_Disassembler_h_ +#endif // liblldb_Disassembler_h_ diff --git a/include/lldb/Core/EmulateInstruction.h b/include/lldb/Core/EmulateInstruction.h index 774d80968ff9..c5e60022fc96 100644 --- a/include/lldb/Core/EmulateInstruction.h +++ b/include/lldb/Core/EmulateInstruction.h @@ -19,6 +19,8 @@ #include "lldb/Core/Opcode.h" #include "lldb/Core/RegisterValue.h" +namespace lldb_private { + //---------------------------------------------------------------------- /// @class EmulateInstruction EmulateInstruction.h "lldb/Core/EmulateInstruction.h" /// @brief A class that allows emulation of CPU opcodes. @@ -79,8 +81,6 @@ /// and emulating the instruction is just a bonus. //---------------------------------------------------------------------- -namespace lldb_private { - class EmulateInstruction : public PluginInterface { @@ -233,7 +233,6 @@ public: } ISAAndImmediateSigned; uint32_t isa; - } info; Context () : @@ -387,9 +386,8 @@ public: EmulateInstruction (const ArchSpec &arch); - virtual ~EmulateInstruction() - { - } + ~EmulateInstruction() override = default; + //---------------------------------------------------------------------- // Mandatory overrides //---------------------------------------------------------------------- @@ -404,7 +402,10 @@ public: virtual bool EvaluateInstruction (uint32_t evaluate_options) = 0; - + + virtual bool + IsInstructionConditional() { return false; } + virtual bool TestEmulation (Stream *out_stream, ArchSpec &arch, OptionValueDictionary *test_data) = 0; @@ -527,7 +528,6 @@ public: return m_arch; } - static size_t ReadMemoryFrame (EmulateInstruction *instruction, void *baton, @@ -628,7 +628,6 @@ protected: lldb::addr_t m_addr; Opcode m_opcode; - private: //------------------------------------------------------------------ // For EmulateInstruction only @@ -636,6 +635,6 @@ private: DISALLOW_COPY_AND_ASSIGN (EmulateInstruction); }; -} // namespace lldb_private +} // namespace lldb_private -#endif // lldb_EmulateInstruction_h_ +#endif // lldb_EmulateInstruction_h_ diff --git a/include/lldb/Core/Event.h b/include/lldb/Core/Event.h index 1c3eec0359c3..e8867c0e7e77 100644 --- a/include/lldb/Core/Event.h +++ b/include/lldb/Core/Event.h @@ -12,7 +12,7 @@ // C Includes // C++ Includes -#include <list> +#include <memory> #include <string> // Other libraries and framework includes @@ -49,7 +49,6 @@ private: } DISALLOW_COPY_AND_ASSIGN (EventData); - }; //---------------------------------------------------------------------- @@ -67,17 +66,16 @@ public: EventDataBytes (const void *src, size_t src_len); - virtual - ~EventDataBytes(); + ~EventDataBytes() override; //------------------------------------------------------------------ // Member functions //------------------------------------------------------------------ - virtual const ConstString & - GetFlavor () const; + const ConstString & + GetFlavor () const override; - virtual void - Dump (Stream *s) const; + void + Dump (Stream *s) const override; const void * GetBytes() const; @@ -113,7 +111,6 @@ private: std::string m_bytes; DISALLOW_COPY_AND_ASSIGN (EventDataBytes); - }; //---------------------------------------------------------------------- @@ -126,10 +123,9 @@ class Event friend class EventData; public: + Event(Broadcaster *broadcaster, uint32_t event_type, EventData *data = nullptr); - Event (Broadcaster *broadcaster, uint32_t event_type, EventData *data = NULL); - - Event (uint32_t event_type, EventData *data = NULL); + Event(uint32_t event_type, EventData *data = nullptr); ~Event (); @@ -184,7 +180,6 @@ public: m_data_ap.reset(); } - private: // This is only called by Listener when it pops an event off the queue for // the listener. It calls the Event Data's DoOnRemoval() method, which is @@ -202,7 +197,6 @@ private: m_broadcaster = broadcaster; } - Broadcaster * m_broadcaster; // The broadcaster that sent this event uint32_t m_type; // The bit describing this event std::unique_ptr<EventData> m_data_ap; // User specific data for this event @@ -214,4 +208,4 @@ private: } // namespace lldb_private -#endif // liblldb_Event_h_ +#endif // liblldb_Event_h_ diff --git a/include/lldb/Core/FileLineResolver.h b/include/lldb/Core/FileLineResolver.h index e1928f1b063d..f0f7fbdf756f 100644 --- a/include/lldb/Core/FileLineResolver.h +++ b/include/lldb/Core/FileLineResolver.h @@ -38,20 +38,19 @@ public: uint32_t line_no, bool check_inlines); - virtual - ~FileLineResolver (); + ~FileLineResolver () override; - virtual Searcher::CallbackReturn + Searcher::CallbackReturn SearchCallback (SearchFilter &filter, SymbolContext &context, Address *addr, - bool containing); + bool containing) override; - virtual Searcher::Depth - GetDepth (); + Searcher::Depth + GetDepth () override; - virtual void - GetDescription (Stream *s); + void + GetDescription (Stream *s) override; const SymbolContextList & GetFileLineMatches() @@ -78,4 +77,4 @@ private: } // namespace lldb_private -#endif // liblldb_FileLineResolver_h_ +#endif // liblldb_FileLineResolver_h_ diff --git a/include/lldb/Core/FormatEntity.h b/include/lldb/Core/FormatEntity.h index db4f59132832..659b696e61fd 100644 --- a/include/lldb/Core/FormatEntity.h +++ b/include/lldb/Core/FormatEntity.h @@ -9,18 +9,21 @@ #ifndef liblldb_FormatEntity_h_ #define liblldb_FormatEntity_h_ -#if defined(__cplusplus) +// C Includes +// C++ Includes #include <string> #include <vector> +// Other libraries and framework includes +// Project includes #include "lldb/lldb-private.h" #include "lldb/Core/Error.h" namespace llvm { class StringRef; -} +} // namespace llvm namespace lldb_private { @@ -81,6 +84,7 @@ namespace lldb_private FunctionPCOffset, FunctionInitial, FunctionChanged, + FunctionIsOptimized, LineEntryFile, LineEntryLineNumber, LineEntryStartAddress, @@ -108,13 +112,13 @@ namespace lldb_private bool keep_separator; }; - Entry (Type t = Type::Invalid, - const char *s = NULL, - const char *f = NULL) : + Entry(Type t = Type::Invalid, + const char *s = nullptr, + const char *f = nullptr) : string (s ? s : ""), printf_format (f ? f : ""), children (), - definition (NULL), + definition (nullptr), type (t), fmt (lldb::eFormatDefault), number (0), @@ -146,7 +150,7 @@ namespace lldb_private string.clear(); printf_format.clear(); children.clear(); - definition = NULL; + definition = nullptr; type = Type::Invalid; fmt = lldb::eFormatDefault; number = 0; @@ -252,12 +256,10 @@ namespace lldb_private static bool FormatFileSpec (const FileSpec &file, Stream &s, llvm::StringRef elements, llvm::StringRef element_format); protected: - static Error ParseInternal (llvm::StringRef &format, Entry &parent_entry, uint32_t depth); }; +} // namespace lldb_private -} -#endif // #if defined(__cplusplus) -#endif // liblldb_FormatEntity_h_ +#endif // liblldb_FormatEntity_h_ diff --git a/include/lldb/Core/History.h b/include/lldb/Core/History.h index b3626882f843..fbb7bd8b0c1a 100644 --- a/include/lldb/Core/History.h +++ b/include/lldb/Core/History.h @@ -82,7 +82,6 @@ private: collection m_events; DISALLOW_COPY_AND_ASSIGN (HistorySource); - }; //---------------------------------------------------------------------- @@ -103,8 +102,7 @@ class HistorySourceUInt : public HistorySource { } - virtual - ~HistorySourceUInt() + ~HistorySourceUInt() override { } @@ -112,44 +110,44 @@ class HistorySourceUInt : public HistorySource // in the subclass of this class to produce a history event and push it // onto the end of the history stack. - virtual HistoryEvent - CreateHistoryEvent () + HistoryEvent + CreateHistoryEvent () override { ++m_curr_id; return (HistoryEvent)m_curr_id; } - virtual void - DeleteHistoryEvent (HistoryEvent event) + void + DeleteHistoryEvent (HistoryEvent event) override { // Nothing to delete, the event contains the integer } - virtual void - DumpHistoryEvent (Stream &strm, HistoryEvent event); + void + DumpHistoryEvent (Stream &strm, HistoryEvent event) override; - virtual size_t - GetHistoryEventCount() + size_t + GetHistoryEventCount() override { return m_curr_id; } - virtual HistoryEvent - GetHistoryEventAtIndex (uint32_t idx) + HistoryEvent + GetHistoryEventAtIndex (uint32_t idx) override { return (HistoryEvent)((uintptr_t)idx); } - virtual HistoryEvent - GetCurrentHistoryEvent () + HistoryEvent + GetCurrentHistoryEvent () override { return (HistoryEvent)m_curr_id; } // Return 0 when lhs == rhs, 1 if lhs > rhs, or -1 if lhs < rhs. - virtual int + int CompareHistoryEvents (const HistoryEvent lhs, - const HistoryEvent rhs) + const HistoryEvent rhs) override { uintptr_t lhs_uint = (uintptr_t)lhs; uintptr_t rhs_uint = (uintptr_t)rhs; @@ -160,8 +158,8 @@ class HistorySourceUInt : public HistorySource return 0; } - virtual bool - IsCurrentHistoryEvent (const HistoryEvent event) + bool + IsCurrentHistoryEvent (const HistoryEvent event) override { return (uintptr_t)event == m_curr_id; } @@ -171,7 +169,6 @@ protected: uintptr_t m_curr_id; // The current value of the history unsigned unteger }; - } // namespace lldb_private -#endif // lldb_History_h_ +#endif // lldb_History_h_ diff --git a/include/lldb/Core/IOHandler.h b/include/lldb/Core/IOHandler.h index b617d8e75f58..3eba1c3cc9d8 100644 --- a/include/lldb/Core/IOHandler.h +++ b/include/lldb/Core/IOHandler.h @@ -10,10 +10,16 @@ #ifndef liblldb_IOHandler_h_ #define liblldb_IOHandler_h_ +// C Includes #include <string.h> -#include <stack> +// C++ Includes +#include <memory> +#include <string> +#include <vector> +// Other libraries and framework includes +// Project includes #include "lldb/lldb-public.h" #include "lldb/lldb-enumerations.h" #include "lldb/Core/ConstString.h" @@ -29,7 +35,7 @@ namespace curses { class Application; typedef std::unique_ptr<Application> ApplicationAP; -} +} // namespace curses namespace lldb_private { @@ -42,6 +48,7 @@ namespace lldb_private { Confirm, Curses, Expression, + REPL, ProcessIO, PythonInterpreter, PythonCode, @@ -123,7 +130,7 @@ namespace lldb_private { GetPrompt () { // Prompt support isn't mandatory - return NULL; + return nullptr; } virtual bool @@ -142,13 +149,13 @@ namespace lldb_private { virtual const char * GetCommandPrefix () { - return NULL; + return nullptr; } virtual const char * GetHelpPrologue() { - return NULL; + return nullptr; } int @@ -257,7 +264,6 @@ namespace lldb_private { private: DISALLOW_COPY_AND_ASSIGN (IOHandler); }; - //------------------------------------------------------------------ /// A delegate class for use with IOHandler subclasses. @@ -283,9 +289,7 @@ namespace lldb_private { } virtual - ~IOHandlerDelegate() - { - } + ~IOHandlerDelegate() = default; virtual void IOHandlerActivated (IOHandler &io_handler) @@ -309,7 +313,7 @@ namespace lldb_private { virtual const char * IOHandlerGetFixIndentationCharacters () { - return NULL; + return nullptr; } //------------------------------------------------------------------ @@ -395,13 +399,13 @@ namespace lldb_private { virtual const char * IOHandlerGetCommandPrefix () { - return NULL; + return nullptr; } virtual const char * IOHandlerGetHelpPrologue () { - return NULL; + return nullptr; } //------------------------------------------------------------------ @@ -415,6 +419,7 @@ namespace lldb_private { { return false; } + protected: Completion m_completion; // Support for common builtin completions bool m_io_handler_done; @@ -438,10 +443,7 @@ namespace lldb_private { { } - virtual - ~IOHandlerDelegateMultiline () - { - } + ~IOHandlerDelegateMultiline() override = default; ConstString IOHandlerGetControlSequence (char ch) override @@ -467,11 +469,11 @@ namespace lldb_private { } return false; } + protected: const std::string m_end_line; }; - class IOHandlerEditline : public IOHandler { public: @@ -499,8 +501,7 @@ namespace lldb_private { uint32_t line_number_start, // If non-zero show line numbers starting at 'line_number_start' IOHandlerDelegate &delegate); - virtual - ~IOHandlerEditline (); + ~IOHandlerEditline() override; void Run () override; @@ -632,8 +633,7 @@ namespace lldb_private { const char *prompt, bool default_response); - virtual - ~IOHandlerConfirm (); + ~IOHandlerConfirm() override; bool GetResponse () const @@ -694,14 +694,14 @@ namespace lldb_private { public: IOHandlerCursesValueObjectList (Debugger &debugger, ValueObjectList &valobj_list); - virtual - ~IOHandlerCursesValueObjectList (); + ~IOHandlerCursesValueObjectList() override; void Run () override; void GotEOF() override; + protected: ValueObjectList m_valobj_list; }; @@ -709,17 +709,14 @@ namespace lldb_private { class IOHandlerStack { public: - IOHandlerStack () : m_stack(), m_mutex(Mutex::eMutexTypeRecursive), - m_top (NULL) + m_top (nullptr) { } - ~IOHandlerStack () - { - } + ~IOHandlerStack() = default; size_t GetSize () const @@ -771,10 +768,8 @@ namespace lldb_private { sp->SetPopped (true); } // Set m_top the non-locking IsTop() call - if (m_stack.empty()) - m_top = NULL; - else - m_top = m_stack.back().get(); + + m_top = (m_stack.empty() ? nullptr : m_stack.back().get()); } Mutex & @@ -794,53 +789,42 @@ namespace lldb_private { { Mutex::Locker locker (m_mutex); const size_t num_io_handlers = m_stack.size(); - if (num_io_handlers >= 2 && - m_stack[num_io_handlers-1]->GetType() == top_type && - m_stack[num_io_handlers-2]->GetType() == second_top_type) - { - return true; - } - return false; + return (num_io_handlers >= 2 && + m_stack[num_io_handlers-1]->GetType() == top_type && + m_stack[num_io_handlers-2]->GetType() == second_top_type); } + ConstString GetTopIOHandlerControlSequence (char ch) { - if (m_top) - return m_top->GetControlSequence(ch); - return ConstString(); + return ((m_top != nullptr) ? m_top->GetControlSequence(ch) : ConstString()); } const char * GetTopIOHandlerCommandPrefix() { - if (m_top) - return m_top->GetCommandPrefix(); - return NULL; + return ((m_top != nullptr) ? m_top->GetCommandPrefix() : nullptr); } const char * GetTopIOHandlerHelpPrologue() { - if (m_top) - return m_top->GetHelpPrologue(); - return NULL; + return ((m_top != nullptr) ? m_top->GetHelpPrologue() : nullptr); } void PrintAsync (Stream *stream, const char *s, size_t len); protected: - typedef std::vector<lldb::IOHandlerSP> collection; collection m_stack; mutable Mutex m_mutex; IOHandler *m_top; private: - DISALLOW_COPY_AND_ASSIGN (IOHandlerStack); }; } // namespace lldb_private -#endif // #ifndef liblldb_IOHandler_h_ +#endif // liblldb_IOHandler_h_ diff --git a/include/lldb/Core/Language.h b/include/lldb/Core/Language.h deleted file mode 100644 index 670c6aa695e1..000000000000 --- a/include/lldb/Core/Language.h +++ /dev/null @@ -1,117 +0,0 @@ -//===-- Language.h ----------------------------------------------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -#ifndef liblldb_Language_h_ -#define liblldb_Language_h_ - -#include "lldb/lldb-private.h" - -namespace lldb_private { - -//---------------------------------------------------------------------- -/// @class Language Language.h "lldb/Core/Language.h" -/// @brief Encapsulates the programming language for an lldb object. -/// -/// Languages are represented by an enumeration value. -/// -/// The enumeration values used when describing the programming language -/// are the same values as the latest DWARF specification. -//---------------------------------------------------------------------- -class Language -{ -public: - //------------------------------------------------------------------ - /// Construct with optional language enumeration. - //------------------------------------------------------------------ - Language(lldb::LanguageType language = lldb::eLanguageTypeUnknown); - - //------------------------------------------------------------------ - /// Destructor. - /// - /// The destructor is virtual in case this class is subclassed. - //------------------------------------------------------------------ - virtual - ~Language(); - - //------------------------------------------------------------------ - /// Get the language value as a NULL termianted C string. - /// - /// @return - /// The C string representation of the language. The returned - /// string does not need to be freed as it comes from constant - /// strings. NULL can be returned when the language is set to - /// a value that doesn't match of of the lldb::LanguageType - /// enumerations. - //------------------------------------------------------------------ - const char * - AsCString (lldb::DescriptionLevel level = lldb::eDescriptionLevelBrief) const; - - void - Clear(); - - void - GetDescription (Stream *s, lldb::DescriptionLevel level) const; - - //------------------------------------------------------------------ - /// Dump the language value to the stream \a s. - /// - /// @param[in] s - /// The stream to which to dump the language description. - //------------------------------------------------------------------ - void - Dump(Stream *s) const; - - //------------------------------------------------------------------ - /// Get accessor for the language. - /// - /// @return - /// The enumeration value that describes the programming - /// language that an object is associated with. - //------------------------------------------------------------------ - virtual lldb::LanguageType - GetLanguage() const; - - //------------------------------------------------------------------ - /// Set accessor for the language. - /// - /// @param[in] language - /// The new enumeration value that describes the programming - /// language that an object is associated with. - //------------------------------------------------------------------ - void - SetLanguage(lldb::LanguageType language); - - //------------------------------------------------------------------ - /// Set accessor for the language. - /// - /// @param[in] language_cstr - /// The language name as a C string. - //------------------------------------------------------------------ - bool - SetLanguageFromCString(const char *language_cstr); - - -protected: - //------------------------------------------------------------------ - // Member variables - //------------------------------------------------------------------ - lldb::LanguageType m_language; ///< The programming language enumeration value. - ///< The enumeration values are the same as the - ///< latest DWARF specification. -}; - -//-------------------------------------------------------------- -/// Stream the language enumeration as a string object to a -/// Stream. -//-------------------------------------------------------------- -Stream& operator << (Stream& s, const Language& language); - -} // namespace lldb_private - -#endif // liblldb_Language_h_ diff --git a/include/lldb/Core/Listener.h b/include/lldb/Core/Listener.h index 2dbd2eb436ce..b11c1644507b 100644 --- a/include/lldb/Core/Listener.h +++ b/include/lldb/Core/Listener.h @@ -14,11 +14,9 @@ // C++ Includes #include <list> #include <map> -#include <set> #include <string> #include <vector> - // Other libraries and framework includes // Project includes #include "lldb/lldb-private.h" @@ -118,13 +116,12 @@ public: HandleBroadcastEvent (lldb::EventSP &event_sp); private: - //------------------------------------------------------------------ // Classes that inherit from Listener can see and modify these //------------------------------------------------------------------ struct BroadcasterInfo { - BroadcasterInfo(uint32_t mask, HandleBroadcastCallback cb = NULL, void *ud = NULL) : + BroadcasterInfo(uint32_t mask, HandleBroadcastCallback cb = nullptr, void *ud = nullptr) : event_mask (mask), callback (cb), callback_user_data (ud) @@ -141,28 +138,28 @@ private: typedef std::vector<BroadcasterManager *> broadcaster_manager_collection; bool - FindNextEventInternal (Broadcaster *broadcaster, // NULL for any broadcaster - const ConstString *sources, // NULL for any event - uint32_t num_sources, - uint32_t event_type_mask, - lldb::EventSP &event_sp, - bool remove); + FindNextEventInternal(Broadcaster *broadcaster, // nullptr for any broadcaster + const ConstString *sources, // nullptr for any event + uint32_t num_sources, + uint32_t event_type_mask, + lldb::EventSP &event_sp, + bool remove); + + bool + GetNextEventInternal(Broadcaster *broadcaster, // nullptr for any broadcaster + const ConstString *sources, // nullptr for any event + uint32_t num_sources, + uint32_t event_type_mask, + lldb::EventSP &event_sp); bool - GetNextEventInternal (Broadcaster *broadcaster, // NULL for any broadcaster - const ConstString *sources, // NULL for any event + WaitForEventsInternal(const TimeValue *timeout, + Broadcaster *broadcaster, // nullptr for any broadcaster + const ConstString *sources, // nullptr for any event uint32_t num_sources, uint32_t event_type_mask, lldb::EventSP &event_sp); - bool - WaitForEventsInternal (const TimeValue *timeout, - Broadcaster *broadcaster, // NULL for any broadcaster - const ConstString *sources, // NULL for any event - uint32_t num_sources, - uint32_t event_type_mask, - lldb::EventSP &event_sp); - std::string m_name; broadcaster_collection m_broadcasters; Mutex m_broadcasters_mutex; // Protects m_broadcasters @@ -191,4 +188,4 @@ private: } // namespace lldb_private -#endif // liblldb_Select_h_ +#endif // liblldb_Select_h_ diff --git a/include/lldb/Core/Log.h b/include/lldb/Core/Log.h index 3aa4b4d48e17..674fdfdfc0b2 100644 --- a/include/lldb/Core/Log.h +++ b/include/lldb/Core/Log.h @@ -182,17 +182,16 @@ private: DISALLOW_COPY_AND_ASSIGN(Log); }; - class LogChannel : public PluginInterface { public: LogChannel(); - virtual ~LogChannel(); + ~LogChannel() override; static lldb::LogChannelSP FindPlugin(const char *plugin_name); - // categories is a an array of chars that ends with a NULL element. + // categories is an array of chars that ends with a NULL element. virtual void Disable(const char **categories, Stream *feedback_strm) = 0; virtual bool Enable( @@ -209,7 +208,6 @@ private: DISALLOW_COPY_AND_ASSIGN(LogChannel); }; - } // namespace lldb_private -#endif // liblldb_Log_H_ +#endif // liblldb_Log_h_ diff --git a/include/lldb/Core/Logging.h b/include/lldb/Core/Logging.h index a4dd76f11237..ca04c84b21a6 100644 --- a/include/lldb/Core/Logging.h +++ b/include/lldb/Core/Logging.h @@ -48,6 +48,7 @@ #define LIBLLDB_LOG_SYSTEM_RUNTIME (1u << 26) #define LIBLLDB_LOG_JIT_LOADER (1u << 27) #define LIBLLDB_LOG_LANGUAGE (1u << 28) +#define LIBLLDB_LOG_DATAFORMATTERS (1u << 29) #define LIBLLDB_LOG_ALL (UINT32_MAX) #define LIBLLDB_LOG_DEFAULT (LIBLLDB_LOG_PROCESS |\ LIBLLDB_LOG_THREAD |\ diff --git a/include/lldb/Core/MappedHash.h b/include/lldb/Core/MappedHash.h index 4b77ff1ab8fc..5a52ab2b8b2d 100644 --- a/include/lldb/Core/MappedHash.h +++ b/include/lldb/Core/MappedHash.h @@ -1,29 +1,38 @@ +//===-- MappedHash.h --------------------------------------------*- C++ -*-===// // -// MappedHash.h +// The LLVM Compiler Infrastructure // +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// #ifndef liblldb_MappedHash_h_ #define liblldb_MappedHash_h_ +// C Includes #include <assert.h> #include <stdint.h> +// C++ Includes +#include <algorithm> +#include <functional> #include <map> #include <vector> +// Other libraries and framework includes +// Project includes #include "lldb/Core/DataExtractor.h" #include "lldb/Core/Stream.h" class MappedHash { public: - enum HashFunctionType { eHashFunctionDJB = 0u // Daniel J Bernstein hash function that is also used by the ELF GNU_HASH sections }; - static uint32_t HashStringUsingDJB (const char *s) { @@ -50,7 +59,6 @@ public: return 0; } - static const uint32_t HASH_MAGIC = 0x48415348u; static const uint32_t HASH_CIGAM = 0x48534148u; @@ -77,11 +85,9 @@ public: header_data () { } - + virtual - ~Header() - { - } + ~Header() = default; size_t GetByteSize() const @@ -254,8 +260,7 @@ public: header.bucket_count = num_unique_hashes; if (header.bucket_count == 0) header.bucket_count = 1; - - + std::vector<HashToHashData> hash_buckets; std::vector<uint32_t> hash_indexes (header.bucket_count, 0); std::vector<uint32_t> hash_values; @@ -345,10 +350,12 @@ public: } } } + protected: typedef std::vector<Entry> collection; collection m_entries; }; + // A class for reading and using a saved hash table from a block of data // in memory template <typename __KeyType, class __HeaderType, class __HashData> @@ -375,9 +382,9 @@ public: MemoryTable (lldb_private::DataExtractor &data) : m_header (), - m_hash_indexes (NULL), - m_hash_values (NULL), - m_hash_offsets (NULL) + m_hash_indexes (nullptr), + m_hash_values (nullptr), + m_hash_offsets (nullptr) { lldb::offset_t offset = m_header.Read (data, 0); if (offset != LLDB_INVALID_OFFSET && IsValid ()) @@ -387,12 +394,10 @@ public: m_hash_offsets = (const uint32_t *)data.GetData (&offset, m_header.hashes_count * sizeof(uint32_t)); } } - + virtual - ~MemoryTable () - { - } - + ~MemoryTable() = default; + bool IsValid () const { @@ -483,7 +488,6 @@ public: // subclass and return a valie "const char *" given a "key". The value // could also be a C string pointer, in which case just returning "key" // will suffice. - virtual const char * GetStringForKeyType (KeyType key) const = 0; @@ -506,7 +510,6 @@ public: // should be returned. If anything else goes wrong during parsing, // return "eResultError" and the corresponding "Find()" function will // be canceled and return false. - virtual Result GetHashDataForName (const char *name, lldb::offset_t* hash_data_offset_ptr, @@ -518,7 +521,6 @@ public: return m_header; } - void ForEach (std::function <bool(const HashData &hash_data)> const &callback) const { @@ -546,7 +548,6 @@ public: const uint32_t *m_hash_values; const uint32_t *m_hash_offsets; }; - }; -#endif // #ifndef liblldb_MappedHash_h_ +#endif // liblldb_MappedHash_h_ diff --git a/include/lldb/Core/Module.h b/include/lldb/Core/Module.h index 127ddaeb9fd4..35b182aa9801 100644 --- a/include/lldb/Core/Module.h +++ b/include/lldb/Core/Module.h @@ -10,6 +10,14 @@ #ifndef liblldb_Module_h_ #define liblldb_Module_h_ +// C Includes +// C++ Includes +#include <atomic> +#include <string> +#include <vector> + +// Other libraries and framework includes +// Project includes #include "lldb/lldb-forward.h" #include "lldb/Core/ArchSpec.h" #include "lldb/Core/UUID.h" @@ -17,6 +25,7 @@ #include "lldb/Host/Mutex.h" #include "lldb/Host/TimeValue.h" #include "lldb/Symbol/SymbolContextScope.h" +#include "lldb/Symbol/TypeSystem.h" #include "lldb/Target/PathMappingList.h" namespace lldb_private { @@ -85,11 +94,11 @@ public: /// module within a module (.a files and modules that contain /// multiple architectures). //------------------------------------------------------------------ - Module (const FileSpec& file_spec, - const ArchSpec& arch, - const ConstString *object_name = NULL, - lldb::offset_t object_offset = 0, - const TimeValue *object_mod_time_ptr = NULL); + Module(const FileSpec& file_spec, + const ArchSpec& arch, + const ConstString *object_name = nullptr, + lldb::offset_t object_offset = 0, + const TimeValue *object_mod_time_ptr = nullptr); Module (const ModuleSpec &module_spec); @@ -99,8 +108,7 @@ public: //------------------------------------------------------------------ /// Destructor. //------------------------------------------------------------------ - virtual - ~Module (); + ~Module() override; bool MatchesModuleSpec (const ModuleSpec &module_ref); @@ -154,11 +162,11 @@ public: /// /// @see SymbolContextScope //------------------------------------------------------------------ - virtual void - CalculateSymbolContext (SymbolContext* sc); + void + CalculateSymbolContext(SymbolContext* sc) override; - virtual lldb::ModuleSP - CalculateSymbolContextModule (); + lldb::ModuleSP + CalculateSymbolContextModule() override; void GetDescription (Stream *s, @@ -207,10 +215,9 @@ public: /// /// @see SymbolContextScope //------------------------------------------------------------------ - virtual void - DumpSymbolContext (Stream *s); + void + DumpSymbolContext(Stream *s) override; - //------------------------------------------------------------------ /// Find a symbol in the object file's symbol table. /// @@ -225,7 +232,7 @@ public: /// /// @return /// Returns a valid symbol pointer if a symbol was found, - /// NULL otherwise. + /// nullptr otherwise. //------------------------------------------------------------------ const Symbol * FindFirstSymbolWithNameAndType (const ConstString &name, @@ -288,7 +295,6 @@ public: FindCompileUnits (const FileSpec &path, bool append, SymbolContextList &sc_list); - //------------------------------------------------------------------ /// Find functions by name. @@ -323,7 +329,7 @@ public: //------------------------------------------------------------------ size_t FindFunctions (const ConstString &name, - const ClangNamespaceDecl *namespace_decl, + const CompilerDeclContext *parent_decl_ctx, uint32_t name_type_mask, bool symbols_ok, bool inlines_ok, @@ -392,8 +398,8 @@ public: /// The name of the global or static variable we are looking /// for. /// - /// @param[in] namespace_decl - /// If valid, a namespace to search in. + /// @param[in] parent_decl_ctx + /// If valid, a decl context that results must exist within /// /// @param[in] append /// If \b true, any matches will be appended to \a @@ -413,7 +419,7 @@ public: //------------------------------------------------------------------ size_t FindGlobalVariables (const ConstString &name, - const ClangNamespaceDecl *namespace_decl, + const CompilerDeclContext *parent_decl_ctx, bool append, size_t max_matches, VariableList& variable_list); @@ -524,7 +530,7 @@ public: size_t FindTypesInNamespace (const SymbolContext& sc, const ConstString &type_name, - const ClangNamespaceDecl *namespace_decl, + const CompilerDeclContext *parent_decl_ctx, size_t max_matches, TypeList& type_list); @@ -646,10 +652,10 @@ public: IsLoadedInTarget (Target *target); bool - LoadScriptingResourceInTarget (Target *target, - Error& error, - Stream* feedback_stream = NULL); - + LoadScriptingResourceInTarget(Target *target, + Error& error, + Stream* feedback_stream = nullptr); + //------------------------------------------------------------------ /// Get the number of compile units for this module. /// @@ -682,7 +688,7 @@ public: /// @return /// If Module::m_file does not exist, or no plug-in was found /// that can parse the file, or the object file doesn't contain - /// the current architecture in Module::m_arch, NULL will be + /// the current architecture in Module::m_arch, nullptr will be /// returned, else a valid object file interface will be /// returned. The returned pointer is owned by this object and /// remains valid as long as the object is around. @@ -730,7 +736,7 @@ public: /// process. /// /// @return - /// The object file loaded from memory or NULL, if the operation + /// The object file loaded from memory or nullptr, if the operation /// failed (see the `error` for more information in that case). //------------------------------------------------------------------ ObjectFile * @@ -747,20 +753,20 @@ public: /// /// @return /// If this module does not have a valid object file, or no - /// plug-in can be found that can use the object file, NULL will + /// plug-in can be found that can use the object file, nullptr will /// be returned, else a valid symbol vendor plug-in interface /// will be returned. The returned pointer is owned by this /// object and remains valid as long as the object is around. //------------------------------------------------------------------ virtual SymbolVendor* GetSymbolVendor(bool can_create = true, - lldb_private::Stream *feedback_strm = NULL); + lldb_private::Stream *feedback_strm = nullptr); //------------------------------------------------------------------ /// Get accessor the type list for this module. /// /// @return - /// A valid type list pointer, or NULL if there is no valid + /// A valid type list pointer, or nullptr if there is no valid /// symbol vendor for this module. //------------------------------------------------------------------ TypeList* @@ -935,7 +941,6 @@ public: uint32_t ResolveSymbolContextsForFileSpec (const FileSpec &file_spec, uint32_t line, bool check_inlines, uint32_t resolve_scope, SymbolContextList& sc_list); - void SetFileSpecAndObjectName (const FileSpec &file, const ConstString &object_name); @@ -943,8 +948,8 @@ public: bool GetIsDynamicLinkEditor (); - ClangASTContext & - GetClangASTContext (); + TypeSystem * + GetTypeSystemForLanguage (lldb::LanguageType language); // Special error functions that can do printf style formatting that will prepend the message with // something appropriate for this module (like the architecture, path and object name (if any)). @@ -1041,7 +1046,6 @@ public: bool RemapSourceFile (const char *path, std::string &new_path) const; - //------------------------------------------------------------------ /// Prepare to do a function name lookup. /// @@ -1067,6 +1071,10 @@ public: /// The mask of bits from lldb::FunctionNameType enumerations /// that tell us what kind of name we are looking for. /// + /// @param[out] language + /// If known, the language to use for determining the + /// lookup_name_type_mask. + /// /// @param[out] lookup_name /// The actual name that will be used when calling /// SymbolVendor::FindFunctions() or Symtab::FindFunctionSymbols() @@ -1087,6 +1095,7 @@ public: static void PrepareForFunctionNameLookup (const ConstString &name, uint32_t name_type_mask, + lldb::LanguageType language, ConstString &lookup_name, uint32_t &lookup_name_type_mask, bool &match_name_after_lookup); @@ -1110,17 +1119,16 @@ protected: lldb::SymbolVendorUP m_symfile_ap; ///< A pointer to the symbol vendor for this module. std::vector<lldb::SymbolVendorUP> m_old_symfiles; ///< If anyone calls Module::SetSymbolFileFileSpec() and changes the symbol file, ///< we need to keep all old symbol files around in case anyone has type references to them - lldb::ClangASTContextUP m_ast; ///< The AST context for this module. + 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 lldb::SectionListUP m_sections_ap; ///< Unified section list for module that is used by the ObjectFile and and ObjectFile instances for the debug info - bool m_did_load_objfile:1, - m_did_load_symbol_vendor:1, - m_did_parse_uuid:1, - m_did_init_ast:1; + std::atomic<bool> m_did_load_objfile; + std::atomic<bool> m_did_load_symbol_vendor; + std::atomic<bool> m_did_parse_uuid; mutable bool m_file_has_changed:1, m_first_file_changed_log:1; /// See if the module was modified after it was initially opened. - + //------------------------------------------------------------------ /// Resolve a file or load virtual address. /// @@ -1178,21 +1186,19 @@ protected: friend class SymbolFile; private: - Module (); // Only used internally by CreateJITModule () size_t FindTypes_Impl (const SymbolContext& sc, const ConstString &name, - const ClangNamespaceDecl *namespace_decl, + const CompilerDeclContext *parent_decl_ctx, bool append, size_t max_matches, - TypeList& types); + TypeMap& types); - DISALLOW_COPY_AND_ASSIGN (Module); }; } // namespace lldb_private -#endif // liblldb_Module_h_ +#endif // liblldb_Module_h_ diff --git a/include/lldb/Core/ModuleList.h b/include/lldb/Core/ModuleList.h index f4c12cf168ac..a0dd43263a2c 100644 --- a/include/lldb/Core/ModuleList.h +++ b/include/lldb/Core/ModuleList.h @@ -10,10 +10,14 @@ #ifndef liblldb_ModuleList_h_ #define liblldb_ModuleList_h_ -#include <vector> -#include <list> +// C Includes +// C++ Includes #include <functional> +#include <list> +#include <vector> +// Other libraries and framework includes +// Project includes #include "lldb/lldb-private.h" #include "lldb/Host/Mutex.h" #include "lldb/Utility/Iterable.h" @@ -30,10 +34,12 @@ namespace lldb_private { class ModuleList { public: - class Notifier { public: + virtual + ~Notifier() = default; + virtual void ModuleAdded (const ModuleList& module_list, const lldb::ModuleSP& module_sp) = 0; virtual void @@ -43,10 +49,6 @@ public: const lldb::ModuleSP& new_module_sp) = 0; virtual void WillClearList (const ModuleList& module_list) = 0; - - virtual - ~Notifier () - {} }; //------------------------------------------------------------------ @@ -144,6 +146,7 @@ public: //------------------------------------------------------------------ void Destroy(); + //------------------------------------------------------------------ /// Dump the description of each module contained in this list. /// @@ -209,7 +212,7 @@ public: /// An index into this module collection. /// /// @return - /// A pointer to a Module which can by NULL if \a idx is out + /// A pointer to a Module which can by nullptr if \a idx is out /// of range. /// /// @see ModuleList::GetSize() @@ -226,7 +229,7 @@ public: /// An index into this module collection. /// /// @return - /// A pointer to a Module which can by NULL if \a idx is out + /// A pointer to a Module which can by nullptr if \a idx is out /// of range. /// /// @see ModuleList::GetSize() @@ -534,10 +537,10 @@ public: GetSize () const; bool - LoadScriptingResourcesInTarget (Target *target, - std::list<Error>& errors, - Stream* feedback_stream = NULL, - bool continue_on_error = true); + LoadScriptingResourcesInTarget(Target *target, + std::list<Error>& errors, + Stream* feedback_stream = nullptr, + bool continue_on_error = true); static bool ModuleIsInCache (const Module *module_ptr); @@ -606,9 +609,8 @@ public: { return ModuleIterableNoLocking(m_modules); } - }; } // namespace lldb_private -#endif // liblldb_ModuleList_h_ +#endif // liblldb_ModuleList_h_ diff --git a/include/lldb/Core/ModuleSpec.h b/include/lldb/Core/ModuleSpec.h index be7041981a0a..95de7f375736 100644 --- a/include/lldb/Core/ModuleSpec.h +++ b/include/lldb/Core/ModuleSpec.h @@ -10,6 +10,12 @@ #ifndef liblldb_ModuleSpec_h_ #define liblldb_ModuleSpec_h_ +// C Includes +// C++ Includes +#include <vector> + +// Other libraries and framework includes +// Project includes #include "lldb/Core/ArchSpec.h" #include "lldb/Core/Stream.h" #include "lldb/Core/UUID.h" @@ -100,17 +106,13 @@ public: FileSpec * GetFileSpecPtr () { - if (m_file) - return &m_file; - return NULL; + return (m_file ? &m_file : nullptr); } const FileSpec * GetFileSpecPtr () const { - if (m_file) - return &m_file; - return NULL; + return (m_file ? &m_file : nullptr); } FileSpec & @@ -118,6 +120,7 @@ public: { return m_file; } + const FileSpec & GetFileSpec () const { @@ -127,17 +130,13 @@ public: FileSpec * GetPlatformFileSpecPtr () { - if (m_platform_file) - return &m_platform_file; - return NULL; + return (m_platform_file ? &m_platform_file : nullptr); } const FileSpec * GetPlatformFileSpecPtr () const { - if (m_platform_file) - return &m_platform_file; - return NULL; + return (m_platform_file ? &m_platform_file : nullptr); } FileSpec & @@ -155,17 +154,13 @@ public: FileSpec * GetSymbolFileSpecPtr () { - if (m_symbol_file) - return &m_symbol_file; - return NULL; + return (m_symbol_file ? &m_symbol_file : nullptr); } const FileSpec * GetSymbolFileSpecPtr () const { - if (m_symbol_file) - return &m_symbol_file; - return NULL; + return (m_symbol_file ? &m_symbol_file : nullptr); } FileSpec & @@ -180,21 +175,16 @@ public: return m_symbol_file; } - ArchSpec * GetArchitecturePtr () { - if (m_arch.IsValid()) - return &m_arch; - return NULL; + return (m_arch.IsValid() ? &m_arch : nullptr); } const ArchSpec * GetArchitecturePtr () const { - if (m_arch.IsValid()) - return &m_arch; - return NULL; + return (m_arch.IsValid() ? &m_arch : nullptr); } ArchSpec & @@ -212,17 +202,13 @@ public: UUID * GetUUIDPtr () { - if (m_uuid.IsValid()) - return &m_uuid; - return NULL; + return (m_uuid.IsValid() ? &m_uuid : nullptr); } const UUID * GetUUIDPtr () const { - if (m_uuid.IsValid()) - return &m_uuid; - return NULL; + return (m_uuid.IsValid() ? &m_uuid : nullptr); } UUID & @@ -306,7 +292,6 @@ public: m_object_mod_time.Clear(); } - explicit operator bool () const { if (m_file) @@ -329,7 +314,7 @@ public: } void - Dump (Stream &strm) + Dump (Stream &strm) const { bool dumped_something = false; if (m_file) @@ -361,7 +346,8 @@ public: { if (dumped_something) strm.PutCString(", "); - strm.Printf("arch = %s", m_arch.GetTriple().str().c_str()); + strm.Printf("arch = "); + m_arch.DumpTriple(strm); dumped_something = true; } if (m_uuid.IsValid()) @@ -476,9 +462,7 @@ public: m_specs = rhs.m_specs; } - ~ModuleSpecList () - { - } + ~ModuleSpecList() = default; ModuleSpecList & operator = (const ModuleSpecList &rhs) @@ -528,6 +512,7 @@ public: { return m_specs[i]; } + bool GetModuleSpecAtIndex (size_t i, ModuleSpec &module_spec) const { @@ -540,8 +525,7 @@ public: module_spec.Clear(); return false; } - - + bool FindMatchingModuleSpec (const ModuleSpec &module_spec, ModuleSpec &match_module_spec) const { @@ -620,4 +604,4 @@ protected: } // namespace lldb_private -#endif // liblldb_ModuleSpec_h_ +#endif // liblldb_ModuleSpec_h_ diff --git a/include/lldb/Core/Opcode.h b/include/lldb/Core/Opcode.h index 57b8077477ce..eac0746baba1 100644 --- a/include/lldb/Core/Opcode.h +++ b/include/lldb/Core/Opcode.h @@ -16,6 +16,7 @@ // C++ Includes // Other libraries and framework includes #include "llvm/Support/MathExtras.h" + // Project includes #include "lldb/Host/Endian.h" #include "lldb/lldb-public.h" @@ -23,7 +24,7 @@ namespace lldb { class SBInstruction; -} +} // namespace lldb namespace lldb_private { @@ -76,6 +77,7 @@ namespace lldb_private { m_byte_order = lldb::eByteOrderInvalid; m_type = Opcode::eTypeInvalid; } + Opcode::Type GetType () const { @@ -189,7 +191,7 @@ namespace lldb_private { void SetOpcodeBytes (const void *bytes, size_t length) { - if (bytes && length > 0) + if (bytes != nullptr && length > 0) { m_type = eTypeBytes; m_data.inst.length = length; @@ -210,9 +212,7 @@ namespace lldb_private { const void * GetOpcodeBytes () const { - if (m_type == Opcode::eTypeBytes) - return m_data.inst.bytes; - return NULL; + return ((m_type == Opcode::eTypeBytes) ? m_data.inst.bytes : nullptr); } uint32_t @@ -252,7 +252,7 @@ namespace lldb_private { case Opcode::eType64: return &m_data.inst64; case Opcode::eTypeBytes: return m_data.inst.bytes; } - return NULL; + return nullptr; } lldb::ByteOrder @@ -261,8 +261,8 @@ namespace lldb_private { bool GetEndianSwap() const { - return (m_byte_order == lldb::eByteOrderBig && lldb::endian::InlHostByteOrder() == lldb::eByteOrderLittle) || - (m_byte_order == lldb::eByteOrderLittle && lldb::endian::InlHostByteOrder() == lldb::eByteOrderBig); + return (m_byte_order == lldb::eByteOrderBig && endian::InlHostByteOrder() == lldb::eByteOrderLittle) || + (m_byte_order == lldb::eByteOrderLittle && endian::InlHostByteOrder() == lldb::eByteOrderBig); } lldb::ByteOrder m_byte_order; @@ -284,4 +284,4 @@ namespace lldb_private { } // namespace lldb_private -#endif // lldb_Opcode_h +#endif // lldb_Opcode_h diff --git a/include/lldb/Core/PluginManager.h b/include/lldb/Core/PluginManager.h index af940d788ab0..6f8001fbfd2b 100644 --- a/include/lldb/Core/PluginManager.h +++ b/include/lldb/Core/PluginManager.h @@ -7,10 +7,13 @@ // //===----------------------------------------------------------------------===// - #ifndef liblldb_PluginManager_h_ #define liblldb_PluginManager_h_ +// C Includes +// C++ Includes +// Other libraries and framework includes +// Project includes #include "lldb/lldb-private.h" #include "lldb/Host/FileSpec.h" @@ -42,7 +45,6 @@ public: static ABICreateInstance GetABICreateCallbackForPluginName (const ConstString &name); - //------------------------------------------------------------------ // Disassembler //------------------------------------------------------------------ @@ -60,15 +62,14 @@ public: static DisassemblerCreateInstance GetDisassemblerCreateCallbackForPluginName (const ConstString &name); - //------------------------------------------------------------------ // DynamicLoader //------------------------------------------------------------------ static bool - RegisterPlugin (const ConstString &name, - const char *description, - DynamicLoaderCreateInstance create_callback, - DebuggerInitializeCallback debugger_init_callback = NULL); + RegisterPlugin(const ConstString &name, + const char *description, + DynamicLoaderCreateInstance create_callback, + DebuggerInitializeCallback debugger_init_callback = nullptr); static bool UnregisterPlugin (DynamicLoaderCreateInstance create_callback); @@ -83,10 +84,10 @@ public: // JITLoader //------------------------------------------------------------------ static bool - RegisterPlugin (const ConstString &name, - const char *description, - JITLoaderCreateInstance create_callback, - DebuggerInitializeCallback debugger_init_callback = NULL); + RegisterPlugin(const ConstString &name, + const char *description, + JITLoaderCreateInstance create_callback, + DebuggerInitializeCallback debugger_init_callback = nullptr); static bool UnregisterPlugin (JITLoaderCreateInstance create_callback); @@ -117,11 +118,10 @@ public: //------------------------------------------------------------------ // OperatingSystem //------------------------------------------------------------------ - static bool - RegisterPlugin (const ConstString &name, - const char *description, - OperatingSystemCreateInstance create_callback); - + static bool RegisterPlugin(const ConstString &name, const char *description, + OperatingSystemCreateInstance create_callback, + DebuggerInitializeCallback debugger_init_callback); + static bool UnregisterPlugin (OperatingSystemCreateInstance create_callback); @@ -132,6 +132,23 @@ public: GetOperatingSystemCreateCallbackForPluginName (const ConstString &name); //------------------------------------------------------------------ + // Language + //------------------------------------------------------------------ + static bool + RegisterPlugin (const ConstString &name, + const char *description, + LanguageCreateInstance create_callback); + + static bool + UnregisterPlugin (LanguageCreateInstance create_callback); + + static LanguageCreateInstance + GetLanguageCreateCallbackAtIndex (uint32_t idx); + + static LanguageCreateInstance + GetLanguageCreateCallbackForPluginName (const ConstString &name); + + //------------------------------------------------------------------ // LanguageRuntime //------------------------------------------------------------------ static bool @@ -152,7 +169,6 @@ public: static LanguageRuntimeCreateInstance GetLanguageRuntimeCreateCallbackForPluginName (const ConstString &name); - //------------------------------------------------------------------ // SystemRuntime //------------------------------------------------------------------ @@ -170,17 +186,16 @@ public: static SystemRuntimeCreateInstance GetSystemRuntimeCreateCallbackForPluginName (const ConstString &name); - //------------------------------------------------------------------ // ObjectFile //------------------------------------------------------------------ static bool - RegisterPlugin (const ConstString &name, - const char *description, - ObjectFileCreateInstance create_callback, - ObjectFileCreateMemoryInstance create_memory_callback, - ObjectFileGetModuleSpecifications get_module_specifications, - ObjectFileSaveCore save_core = NULL); + RegisterPlugin(const ConstString &name, + const char *description, + ObjectFileCreateInstance create_callback, + ObjectFileCreateMemoryInstance create_memory_callback, + ObjectFileGetModuleSpecifications get_module_specifications, + ObjectFileSaveCore save_core = nullptr); static bool UnregisterPlugin (ObjectFileCreateInstance create_callback); @@ -248,10 +263,10 @@ public: // Platform //------------------------------------------------------------------ static bool - RegisterPlugin (const ConstString &name, - const char *description, - PlatformCreateInstance create_callback, - DebuggerInitializeCallback debugger_init_callback = NULL); + RegisterPlugin(const ConstString &name, + const char *description, + PlatformCreateInstance create_callback, + DebuggerInitializeCallback debugger_init_callback = nullptr); static bool UnregisterPlugin (PlatformCreateInstance create_callback); @@ -275,10 +290,10 @@ public: // Process //------------------------------------------------------------------ static bool - RegisterPlugin (const ConstString &name, - const char *description, - ProcessCreateInstance create_callback, - DebuggerInitializeCallback debugger_init_callback = NULL); + RegisterPlugin(const ConstString &name, + const char *description, + ProcessCreateInstance create_callback, + DebuggerInitializeCallback debugger_init_callback = nullptr); static bool UnregisterPlugin (ProcessCreateInstance create_callback); @@ -296,12 +311,30 @@ public: GetProcessPluginDescriptionAtIndex (uint32_t idx); //------------------------------------------------------------------ + // ScriptInterpreter + //------------------------------------------------------------------ + static bool + RegisterPlugin(const ConstString &name, const char *description, lldb::ScriptLanguage script_lang, + ScriptInterpreterCreateInstance create_callback); + + static bool + UnregisterPlugin(ScriptInterpreterCreateInstance create_callback); + + static ScriptInterpreterCreateInstance + GetScriptInterpreterCreateCallbackAtIndex(uint32_t idx); + + static lldb::ScriptInterpreterSP + GetScriptInterpreterForLanguage(lldb::ScriptLanguage script_lang, + CommandInterpreter &interpreter); + + //------------------------------------------------------------------ // SymbolFile //------------------------------------------------------------------ static bool RegisterPlugin (const ConstString &name, const char *description, - SymbolFileCreateInstance create_callback); + SymbolFileCreateInstance create_callback, + DebuggerInitializeCallback debugger_init_callback = nullptr); static bool UnregisterPlugin (SymbolFileCreateInstance create_callback); @@ -312,7 +345,6 @@ public: static SymbolFileCreateInstance GetSymbolFileCreateCallbackForPluginName (const ConstString &name); - //------------------------------------------------------------------ // SymbolVendor //------------------------------------------------------------------ @@ -385,6 +417,53 @@ public: static InstrumentationRuntimeCreateInstance GetInstrumentationRuntimeCreateCallbackForPluginName (const ConstString &name); + //------------------------------------------------------------------ + // TypeSystem + //------------------------------------------------------------------ + static bool + RegisterPlugin (const ConstString &name, + const char *description, + TypeSystemCreateInstance create_callback, + TypeSystemEnumerateSupportedLanguages enumerate_languages_callback); + + static bool + UnregisterPlugin (TypeSystemCreateInstance create_callback); + + static TypeSystemCreateInstance + GetTypeSystemCreateCallbackAtIndex (uint32_t idx); + + static TypeSystemCreateInstance + GetTypeSystemCreateCallbackForPluginName (const ConstString &name); + + static TypeSystemEnumerateSupportedLanguages + GetTypeSystemEnumerateSupportedLanguagesCallbackAtIndex (uint32_t idx); + + static TypeSystemEnumerateSupportedLanguages + GetTypeSystemEnumerateSupportedLanguagesCallbackForPluginName (const ConstString &name); + + //------------------------------------------------------------------ + // REPL + //------------------------------------------------------------------ + static bool + RegisterPlugin (const ConstString &name, + const char *description, + REPLCreateInstance create_callback, + REPLEnumerateSupportedLanguages enumerate_languages_callback); + + static bool + UnregisterPlugin (REPLCreateInstance create_callback); + + static REPLCreateInstance + GetREPLCreateCallbackAtIndex (uint32_t idx); + + static REPLCreateInstance + GetREPLCreateCallbackForPluginName (const ConstString &name); + + static REPLEnumerateSupportedLanguages + GetREPLEnumerateSupportedLanguagesCallbackAtIndex (uint32_t idx); + + static REPLEnumerateSupportedLanguages + GetREPLSystemEnumerateSupportedLanguagesCallbackForPluginName (const ConstString &name); //------------------------------------------------------------------ // Some plug-ins might register a DebuggerInitializeCallback @@ -419,16 +498,41 @@ public: static lldb::OptionValuePropertiesSP GetSettingForProcessPlugin (Debugger &debugger, const ConstString &setting_name); - + static bool CreateSettingForProcessPlugin (Debugger &debugger, const lldb::OptionValuePropertiesSP &properties_sp, const ConstString &description, bool is_global_property); -}; + static lldb::OptionValuePropertiesSP + GetSettingForSymbolFilePlugin (Debugger &debugger, + const ConstString &setting_name); + + static bool + CreateSettingForSymbolFilePlugin (Debugger &debugger, + const lldb::OptionValuePropertiesSP &properties_sp, + const ConstString &description, + bool is_global_property); + + static lldb::OptionValuePropertiesSP + GetSettingForJITLoaderPlugin (Debugger &debugger, + const ConstString &setting_name); + static bool + CreateSettingForJITLoaderPlugin (Debugger &debugger, + const lldb::OptionValuePropertiesSP &properties_sp, + const ConstString &description, + bool is_global_property); + + static lldb::OptionValuePropertiesSP GetSettingForOperatingSystemPlugin(Debugger &debugger, + const ConstString &setting_name); + + static bool CreateSettingForOperatingSystemPlugin(Debugger &debugger, + const lldb::OptionValuePropertiesSP &properties_sp, + const ConstString &description, bool is_global_property); +}; } // namespace lldb_private -#endif // liblldb_PluginManager_h_ +#endif // liblldb_PluginManager_h_ diff --git a/include/lldb/Core/RangeMap.h b/include/lldb/Core/RangeMap.h index d2c43a5d794d..b2e3f06f08a9 100644 --- a/include/lldb/Core/RangeMap.h +++ b/include/lldb/Core/RangeMap.h @@ -10,16 +10,21 @@ #ifndef liblldb_RangeMap_h_ #define liblldb_RangeMap_h_ +// C Includes +// C++ Includes +#include <algorithm> #include <vector> -#include "lldb/lldb-private.h" +// Other libraries and framework includes #include "llvm/ADT/SmallVector.h" +// Project includes +#include "lldb/lldb-private.h" + // Uncomment to make sure all Range objects are sorted when needed //#define ASSERT_RANGEMAP_ARE_SORTED namespace lldb_private { - //---------------------------------------------------------------------- // Templatized classes for dealing with generic ranges and also @@ -187,16 +192,11 @@ namespace lldb_private { typedef S SizeType; typedef Range<B,S> Entry; typedef llvm::SmallVector<Entry, N> Collection; - - RangeArray () : - m_entries () - { - } - - ~RangeArray() - { - } - + + RangeArray() = default; + + ~RangeArray() = default; + void Append (const Entry &entry) { @@ -236,6 +236,7 @@ namespace lldb_private { return true; } #endif + void CombineConsecutiveRanges () { @@ -281,7 +282,6 @@ namespace lldb_private { } } - BaseType GetMinRangeBase (BaseType fail_value) const { @@ -337,9 +337,7 @@ namespace lldb_private { const Entry * GetEntryAtIndex (size_t i) const { - if (i<m_entries.size()) - return &m_entries[i]; - return NULL; + return ((i < m_entries.size()) ? &m_entries[i] : nullptr); } // Clients must ensure that "i" is a valid index prior to calling this function @@ -352,17 +350,13 @@ namespace lldb_private { Entry * Back() { - if (m_entries.empty()) - return NULL; - return &m_entries.back(); + return (m_entries.empty() ? nullptr : &m_entries.back()); } const Entry * Back() const { - if (m_entries.empty()) - return NULL; - return &m_entries.back(); + return (m_entries.empty() ? nullptr : &m_entries.back()); } static bool @@ -424,7 +418,7 @@ namespace lldb_private { } } } - return NULL; + return nullptr; } const Entry * @@ -452,7 +446,7 @@ namespace lldb_private { } } } - return NULL; + return nullptr; } protected: @@ -467,16 +461,11 @@ namespace lldb_private { typedef S SizeType; typedef Range<B,S> Entry; typedef std::vector<Entry> Collection; - - RangeVector () : - m_entries () - { - } - - ~RangeVector() - { - } - + + RangeVector() = default; + + ~RangeVector() = default; + void Append (const Entry &entry) { @@ -516,6 +505,7 @@ namespace lldb_private { return true; } #endif + void CombineConsecutiveRanges () { @@ -560,8 +550,7 @@ namespace lldb_private { } } } - - + BaseType GetMinRangeBase (BaseType fail_value) const { @@ -623,9 +612,7 @@ namespace lldb_private { const Entry * GetEntryAtIndex (size_t i) const { - if (i<m_entries.size()) - return &m_entries[i]; - return NULL; + return ((i < m_entries.size()) ? &m_entries[i] : nullptr); } // Clients must ensure that "i" is a valid index prior to calling this function @@ -638,17 +625,13 @@ namespace lldb_private { Entry * Back() { - if (m_entries.empty()) - return NULL; - return &m_entries.back(); + return (m_entries.empty() ? nullptr : &m_entries.back()); } const Entry * Back() const { - if (m_entries.empty()) - return NULL; - return &m_entries.back(); + return (m_entries.empty() ? nullptr : &m_entries.back()); } static bool @@ -710,7 +693,7 @@ namespace lldb_private { } } } - return NULL; + return nullptr; } const Entry * @@ -738,7 +721,7 @@ namespace lldb_private { } } } - return NULL; + return nullptr; } protected: @@ -812,15 +795,10 @@ namespace lldb_private { typedef RangeData<B,S,T> Entry; typedef llvm::SmallVector<Entry, N> Collection; + RangeDataArray() = default; + + ~RangeDataArray() = default; - RangeDataArray () - { - } - - ~RangeDataArray() - { - } - void Append (const Entry &entry) { @@ -911,9 +889,7 @@ namespace lldb_private { const Entry * GetEntryAtIndex (size_t i) const { - if (i<m_entries.size()) - return &m_entries[i]; - return NULL; + return ((i < m_entries.size()) ? &m_entries[i] : nullptr); } // Clients must ensure that "i" is a valid index prior to calling this function @@ -984,8 +960,9 @@ namespace lldb_private { } } } - return NULL; + return nullptr; } + const Entry * FindEntryThatContains (B addr) const { @@ -1014,7 +991,7 @@ namespace lldb_private { } } } - return NULL; + return nullptr; } const Entry * @@ -1042,23 +1019,19 @@ namespace lldb_private { } } } - return NULL; + return nullptr; } Entry * Back() { - if (!m_entries.empty()) - return &m_entries.back(); - return NULL; + return (m_entries.empty() ? nullptr : &m_entries.back()); } const Entry * Back() const { - if (!m_entries.empty()) - return &m_entries.back(); - return NULL; + return (m_entries.empty() ? nullptr : &m_entries.back()); } protected: @@ -1073,15 +1046,11 @@ namespace lldb_private { public: typedef RangeData<B,S,T> Entry; typedef std::vector<Entry> Collection; - - RangeDataVector () - { - } - - ~RangeDataVector() - { - } - + + RangeDataVector() = default; + + ~RangeDataVector() = default; + void Append (const Entry &entry) { @@ -1181,7 +1150,6 @@ namespace lldb_private { } } } - } void @@ -1211,9 +1179,7 @@ namespace lldb_private { const Entry * GetEntryAtIndex (size_t i) const { - if (i<m_entries.size()) - return &m_entries[i]; - return NULL; + return ((i < m_entries.size()) ? &m_entries[i] : nullptr); } // Clients must ensure that "i" is a valid index prior to calling this function @@ -1272,8 +1238,9 @@ namespace lldb_private { if (pos != end && pos->Contains(addr)) return &(*pos); } - return NULL; + return nullptr; } + const Entry * FindEntryThatContains (B addr) const { @@ -1295,7 +1262,7 @@ namespace lldb_private { if (pos != end && pos->Contains(addr)) return &(*pos); } - return NULL; + return nullptr; } const Entry * @@ -1316,30 +1283,25 @@ namespace lldb_private { if (pos != end && pos->Contains(range)) return &(*pos); } - return NULL; + return nullptr; } Entry * Back() { - if (!m_entries.empty()) - return &m_entries.back(); - return NULL; + return (m_entries.empty() ? nullptr : &m_entries.back()); } const Entry * Back() const { - if (!m_entries.empty()) - return &m_entries.back(); - return NULL; + return (m_entries.empty() ? nullptr : &m_entries.back()); } protected: Collection m_entries; }; - - + //---------------------------------------------------------------------- // A simple range with data class where you get to define the type of // the range base "B", the type used for the range byte size "S", and @@ -1389,7 +1351,6 @@ namespace lldb_private { } }; - template <typename B, typename T, unsigned N> class AddressDataArray { @@ -1397,15 +1358,10 @@ namespace lldb_private { typedef AddressData<B,T> Entry; typedef llvm::SmallVector<Entry, N> Collection; + AddressDataArray() = default; + + ~AddressDataArray() = default; - AddressDataArray () - { - } - - ~AddressDataArray() - { - } - void Append (const Entry &entry) { @@ -1456,9 +1412,7 @@ namespace lldb_private { const Entry * GetEntryAtIndex (size_t i) const { - if (i<m_entries.size()) - return &m_entries[i]; - return NULL; + return ((i < m_entries.size()) ? &m_entries[i] : nullptr); } // Clients must ensure that "i" is a valid index prior to calling this function @@ -1497,7 +1451,7 @@ namespace lldb_private { return &(*pos); } } - return NULL; + return nullptr; } const Entry * @@ -1505,23 +1459,19 @@ namespace lldb_private { { if (entry >= &*m_entries.begin() && entry + 1 < &*m_entries.end()) return entry + 1; - return NULL; + return nullptr; } Entry * Back() { - if (!m_entries.empty()) - return &m_entries.back(); - return NULL; + return (m_entries.empty() ? nullptr : &m_entries.back()); } const Entry * Back() const { - if (!m_entries.empty()) - return &m_entries.back(); - return NULL; + return (m_entries.empty() ? nullptr : &m_entries.back()); } protected: @@ -1530,4 +1480,4 @@ namespace lldb_private { } // namespace lldb_private -#endif // liblldb_RangeMap_h_ +#endif // liblldb_RangeMap_h_ diff --git a/include/lldb/Core/RegisterValue.h b/include/lldb/Core/RegisterValue.h index 1b1a71a11c5a..030b849212c4 100644 --- a/include/lldb/Core/RegisterValue.h +++ b/include/lldb/Core/RegisterValue.h @@ -1,4 +1,4 @@ -//===-- RegisterValue.h ------------------------------------------*- C++ -*-===// +//===-- RegisterValue.h -----------------------------------------*- C++ -*-===// // // The LLVM Compiler Infrastructure // @@ -15,12 +15,14 @@ // C++ Includes // Other libraries and framework includes +#include "llvm/ADT/APInt.h" + // Project includes #include "lldb/lldb-public.h" #include "lldb/lldb-private.h" #include "lldb/Host/Endian.h" +#include "lldb/Core/Scalar.h" -//#define ENABLE_128_BIT_SUPPORT 1 namespace lldb_private { class RegisterValue @@ -30,6 +32,7 @@ namespace lldb_private { { kMaxRegisterByteSize = 32u }; + enum Type { eTypeInvalid, @@ -37,9 +40,7 @@ namespace lldb_private { eTypeUInt16, eTypeUInt32, eTypeUInt64, -#if defined (ENABLE_128_BIT_SUPPORT) eTypeUInt128, -#endif eTypeFloat, eTypeDouble, eTypeLongDouble, @@ -47,7 +48,8 @@ namespace lldb_private { }; RegisterValue () : - m_type (eTypeInvalid) + m_type (eTypeInvalid), + m_scalar ((unsigned long)0) { } @@ -55,57 +57,56 @@ namespace lldb_private { RegisterValue (uint8_t inst) : m_type (eTypeUInt8) { - m_data.uint8 = inst; + m_scalar = inst; } explicit RegisterValue (uint16_t inst) : m_type (eTypeUInt16) { - m_data.uint16 = inst; + m_scalar = inst; } explicit RegisterValue (uint32_t inst) : m_type (eTypeUInt32) { - m_data.uint32 = inst; + m_scalar = inst; } explicit RegisterValue (uint64_t inst) : m_type (eTypeUInt64) { - m_data.uint64 = inst; + m_scalar = inst; } -#if defined (ENABLE_128_BIT_SUPPORT) explicit - RegisterValue (__uint128_t inst) : + RegisterValue (llvm::APInt inst) : m_type (eTypeUInt128) { - m_data.uint128 = inst; + m_scalar = llvm::APInt(inst); } -#endif + explicit RegisterValue (float value) : m_type (eTypeFloat) { - m_data.ieee_float = value; + m_scalar = value; } explicit RegisterValue (double value) : m_type (eTypeDouble) { - m_data.ieee_double = value; + m_scalar = value; } explicit RegisterValue (long double value) : m_type (eTypeLongDouble) { - m_data.ieee_long_double = value; + m_scalar = value; } explicit @@ -161,13 +162,13 @@ namespace lldb_private { GetScalarValue (Scalar &scalar) const; uint8_t - GetAsUInt8 (uint8_t fail_value = UINT8_MAX, bool *success_ptr = NULL) const + GetAsUInt8(uint8_t fail_value = UINT8_MAX, bool *success_ptr = nullptr) const { if (m_type == eTypeUInt8) { if (success_ptr) *success_ptr = true; - return m_data.uint8; + return m_scalar.UChar(fail_value); } if (success_ptr) *success_ptr = true; @@ -175,27 +176,25 @@ namespace lldb_private { } uint16_t - GetAsUInt16 (uint16_t fail_value = UINT16_MAX, bool *success_ptr = NULL) const; + GetAsUInt16(uint16_t fail_value = UINT16_MAX, bool *success_ptr = nullptr) const; uint32_t - GetAsUInt32 (uint32_t fail_value = UINT32_MAX, bool *success_ptr = NULL) const; + GetAsUInt32(uint32_t fail_value = UINT32_MAX, bool *success_ptr = nullptr) const; uint64_t - GetAsUInt64 (uint64_t fail_value = UINT64_MAX, bool *success_ptr = NULL) const; + GetAsUInt64(uint64_t fail_value = UINT64_MAX, bool *success_ptr = nullptr) const; -#if defined (ENABLE_128_BIT_SUPPORT) - __uint128_t - GetAsUInt128 (__uint128_t fail_value = ~((__uint128_t)0), bool *success_ptr = NULL) const; -#endif + llvm::APInt + GetAsUInt128(const llvm::APInt& fail_value, bool *success_ptr = nullptr) const; float - GetAsFloat (float fail_value = 0.0f, bool *success_ptr = NULL) const; + GetAsFloat(float fail_value = 0.0f, bool *success_ptr = nullptr) const; double - GetAsDouble (double fail_value = 0.0, bool *success_ptr = NULL) const; + GetAsDouble(double fail_value = 0.0, bool *success_ptr = nullptr) const; long double - GetAsLongDouble (long double fail_value = 0.0, bool *success_ptr = NULL) const; + GetAsLongDouble(long double fail_value = 0.0, bool *success_ptr = nullptr) const; void SetValueToInvalid () @@ -219,95 +218,93 @@ namespace lldb_private { operator = (uint8_t uint) { m_type = eTypeUInt8; - m_data.uint8 = uint; + m_scalar = uint; } void operator = (uint16_t uint) { m_type = eTypeUInt16; - m_data.uint16 = uint; + m_scalar = uint; } void operator = (uint32_t uint) { m_type = eTypeUInt32; - m_data.uint32 = uint; + m_scalar = uint; } void operator = (uint64_t uint) { m_type = eTypeUInt64; - m_data.uint64 = uint; + m_scalar = uint; } -#if defined (ENABLE_128_BIT_SUPPORT) void - operator = (__uint128_t uint) + operator = (llvm::APInt uint) { m_type = eTypeUInt128; - m_data.uint128 = uint; + m_scalar = llvm::APInt(uint); } -#endif + void operator = (float f) { m_type = eTypeFloat; - m_data.ieee_float = f; + m_scalar = f; } void operator = (double f) { m_type = eTypeDouble; - m_data.ieee_double = f; + m_scalar = f; } void operator = (long double f) { m_type = eTypeLongDouble; - m_data.ieee_long_double = f; + m_scalar = f; } void SetUInt8 (uint8_t uint) { m_type = eTypeUInt8; - m_data.uint8 = uint; + m_scalar = uint; } void SetUInt16 (uint16_t uint) { m_type = eTypeUInt16; - m_data.uint16 = uint; + m_scalar = uint; } void SetUInt32 (uint32_t uint, Type t = eTypeUInt32) { m_type = t; - m_data.uint32 = uint; + m_scalar = uint; } void SetUInt64 (uint64_t uint, Type t = eTypeUInt64) { m_type = t; - m_data.uint64 = uint; + m_scalar = uint; } -#if defined (ENABLE_128_BIT_SUPPORT) void - SetUInt128 (__uint128_t uint) + SetUInt128 (llvm::APInt uint) { m_type = eTypeUInt128; - m_data.uint128 = uint; + m_scalar = uint; } -#endif + bool SetUInt (uint64_t uint, uint32_t byte_size); @@ -315,21 +312,21 @@ namespace lldb_private { SetFloat (float f) { m_type = eTypeFloat; - m_data.ieee_float = f; + m_scalar = f; } void SetDouble (double f) { m_type = eTypeDouble; - m_data.ieee_double = f; + m_scalar = f; } void SetLongDouble (long double f) { m_type = eTypeLongDouble; - m_data.ieee_long_double = f; + m_scalar = f; } void @@ -367,8 +364,8 @@ namespace lldb_private { GetByteOrder () const { if (m_type == eTypeBytes) - return m_data.buffer.byte_order; - return lldb::endian::InlHostByteOrder(); + return buffer.byte_order; + return endian::InlHostByteOrder(); } uint32_t @@ -384,29 +381,17 @@ namespace lldb_private { Clear(); protected: - RegisterValue::Type m_type; - union - { - uint8_t uint8; - uint16_t uint16; - uint32_t uint32; - uint64_t uint64; -#if defined (ENABLE_128_BIT_SUPPORT) - __uint128_t uint128; -#endif - float ieee_float; - double ieee_double; - long double ieee_long_double; - struct - { - uint8_t bytes[kMaxRegisterByteSize]; // This must be big enough to hold any register for any supported target. - uint8_t length; - lldb::ByteOrder byte_order; - } buffer; - } m_data; + Scalar m_scalar; + + struct + { + uint8_t bytes[kMaxRegisterByteSize]; // This must be big enough to hold any register for any supported target. + uint8_t length; + lldb::ByteOrder byte_order; + } buffer; }; } // namespace lldb_private -#endif // lldb_RegisterValue_h +#endif // lldb_RegisterValue_h diff --git a/include/lldb/Core/RegularExpression.h b/include/lldb/Core/RegularExpression.h index a58d17b4a794..b0ece5154ce1 100644 --- a/include/lldb/Core/RegularExpression.h +++ b/include/lldb/Core/RegularExpression.h @@ -7,9 +7,8 @@ // //===----------------------------------------------------------------------===// -#ifndef liblldb_DBRegex_h_ -#define liblldb_DBRegex_h_ -#if defined(__cplusplus) +#ifndef liblldb_RegularExpression_h_ +#define liblldb_RegularExpression_h_ #ifdef _WIN32 #include "../lib/Support/regex_impl.h" @@ -37,7 +36,6 @@ inline void regfree(llvm_regex_t * a) { llvm_regfree(a); } - #else #if __ANDROID_NDK__ #include <regex> @@ -52,7 +50,7 @@ inline void regfree(llvm_regex_t * a) namespace llvm { class StringRef; -} +} // namespace llvm namespace lldb_private { @@ -95,9 +93,7 @@ public: regmatch_t * GetData () { - if (m_matches.empty()) - return NULL; - return m_matches.data(); + return (m_matches.empty() ? nullptr : m_matches.data()); } bool @@ -110,9 +106,9 @@ public: GetMatchSpanningIndices (const char* s, uint32_t idx1, uint32_t idx2, llvm::StringRef& match_str) const; protected: - std::vector<regmatch_t> m_matches; ///< Where parenthesized subexpressions results are stored }; + //------------------------------------------------------------------ /// Default constructor. /// @@ -172,14 +168,14 @@ public: /// @param[in] match /// A pointer to a RegularExpression::Match structure that was /// properly initialized with the desired number of maximum - /// matches, or NULL if no parenthesized matching is needed. + /// matches, or nullptr if no parenthesized matching is needed. /// /// @return /// \b true if \a string matches the compiled regular /// expression, \b false otherwise. //------------------------------------------------------------------ bool - Execute (const char* string, Match *match = NULL) const; + Execute(const char* string, Match *match = nullptr) const; size_t GetErrorAsCString (char *err_str, size_t err_str_max_len) const; @@ -246,5 +242,4 @@ private: } // namespace lldb_private -#endif // #if defined(__cplusplus) -#endif // liblldb_DBRegex_h_ +#endif // liblldb_RegularExpression_h_ diff --git a/include/lldb/Core/STLUtils.h b/include/lldb/Core/STLUtils.h index 9321e057a397..b3c2124f447d 100644 --- a/include/lldb/Core/STLUtils.h +++ b/include/lldb/Core/STLUtils.h @@ -9,14 +9,18 @@ #ifndef liblldb_STLUtils_h_ #define liblldb_STLUtils_h_ -#if defined(__cplusplus) +// C Includes #include <string.h> +// C++ Includes #include <map> #include <ostream> #include <vector> +// Other libraries and framework includes +// Project includes + //---------------------------------------------------------------------- // C string less than compare function object //---------------------------------------------------------------------- @@ -28,7 +32,6 @@ struct CStringCompareFunctionObject } }; - //---------------------------------------------------------------------- // C string equality function object (binary predicate). //---------------------------------------------------------------------- @@ -40,7 +43,6 @@ struct CStringEqualBinaryPredicate } }; - //---------------------------------------------------------------------- // Templated type for finding an entry in a std::map<F,S> whose value // is equal to something @@ -48,21 +50,26 @@ struct CStringEqualBinaryPredicate template <class F, class S> class ValueEquals { -private: - S second_value; - public: ValueEquals (const S& val) : second_value(val) {} + // Compare the second item bool operator() (std::pair<const F, S> elem) { return elem.second == second_value; } + +private: + S second_value; }; template <class T> -inline void PrintAllCollectionElements (std::ostream &s, const T& coll, const char* header_cstr=NULL, const char* separator_cstr=" ") +inline void +PrintAllCollectionElements(std::ostream &s, + const T& coll, + const char* header_cstr = nullptr, + const char* separator_cstr = " ") { typename T::const_iterator pos; @@ -88,7 +95,4 @@ struct for_each_cplusplus_delete typedef std::vector<std::string> STLStringArray; typedef std::vector<const char *> CStringArray; - - -#endif // #if defined(__cplusplus) -#endif // liblldb_STLUtils_h_ +#endif // liblldb_STLUtils_h_ diff --git a/include/lldb/Core/Scalar.h b/include/lldb/Core/Scalar.h index 821a0fb1ae21..a476cd3bd867 100644 --- a/include/lldb/Core/Scalar.h +++ b/include/lldb/Core/Scalar.h @@ -11,6 +11,11 @@ #define liblldb_Scalar_h_ #include "lldb/lldb-private.h" +#include "llvm/ADT/APInt.h" +#include "llvm/ADT/APFloat.h" + +#define NUM_OF_WORDS_INT128 2 +#define BITWIDTH_INT128 128 namespace lldb_private { @@ -34,22 +39,60 @@ public: e_ulonglong, e_float, e_double, - e_long_double + e_long_double, + e_uint128, + e_sint128 }; //------------------------------------------------------------------ // Constructors and Destructors //------------------------------------------------------------------ Scalar(); - Scalar(int v) : m_type(e_sint), m_data() { m_data.sint = v; } - Scalar(unsigned int v) : m_type(e_uint), m_data() { m_data.uint = v; } - Scalar(long v) : m_type(e_slong), m_data() { m_data.slong = v; } - Scalar(unsigned long v) : m_type(e_ulong), m_data() { m_data.ulong = v; } - Scalar(long long v) : m_type(e_slonglong), m_data() { m_data.slonglong = v; } - Scalar(unsigned long long v): m_type(e_ulonglong), m_data() { m_data.ulonglong = v; } - Scalar(float v) : m_type(e_float), m_data() { m_data.flt = v; } - Scalar(double v) : m_type(e_double), m_data() { m_data.dbl = v; } - Scalar(long double v) : m_type(e_long_double), m_data() { m_data.ldbl = v; } + Scalar(int v) : m_type(e_sint), m_float((float)0) { m_integer = llvm::APInt(sizeof(int) * 8, v, true);} + Scalar(unsigned int v) : m_type(e_uint), m_float((float)0) { m_integer = llvm::APInt(sizeof(int) * 8, v);} + Scalar(long v) : m_type(e_slong), m_float((float)0) { m_integer = llvm::APInt(sizeof(long) * 8, v, true);} + Scalar(unsigned long v) : m_type(e_ulong), m_float((float)0) { m_integer = llvm::APInt(sizeof(long) * 8, v);} + Scalar(long long v) : m_type(e_slonglong), m_float((float)0) { m_integer = llvm::APInt(sizeof(long long) * 8, v, true);} + Scalar(unsigned long long v): m_type(e_ulonglong), m_float((float)0) { m_integer = llvm::APInt(sizeof(long long) * 8, v);} + Scalar(float v) : m_type(e_float), m_float(v) { m_float = llvm::APFloat(v); } + 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((float)0), m_ieee_quad(ieee_quad) + { + if(ieee_quad) + m_float = llvm::APFloat(llvm::APFloat::IEEEquad, llvm::APInt(BITWIDTH_INT128, NUM_OF_WORDS_INT128, ((type128 *)&v)->x)); + else + m_float = llvm::APFloat(llvm::APFloat::x87DoubleExtended, llvm::APInt(BITWIDTH_INT128, NUM_OF_WORDS_INT128, ((type128 *)&v)->x)); + } + Scalar(llvm::APInt v) : + m_type(), + m_float((float)0) + { + m_integer = llvm::APInt(v); + switch(m_integer.getBitWidth()) + { + case 8: + case 16: + case 32: + if(m_integer.isSignedIntN(sizeof(sint_t) * 8)) + m_type = e_sint; + else + m_type = e_uint; + break; + case 64: + if(m_integer.isSignedIntN(sizeof(slonglong_t) * 8)) + m_type = e_slonglong; + else + m_type = e_ulonglong; + break; + case 128: + if(m_integer.isSignedIntN(BITWIDTH_INT128)) + m_type = e_sint128; + else + m_type = e_uint128; + break; + } + } Scalar(const Scalar& rhs); //Scalar(const RegisterValue& reg_value); virtual ~Scalar(); @@ -61,15 +104,18 @@ public: ExtractBitfield (uint32_t bit_size, uint32_t bit_offset); + bool + SetBit(uint32_t bit); + + bool + ClearBit(uint32_t bit); + + void * + GetBytes() const; + size_t GetByteSize() const; - static size_t - GetMaxByteSize() - { - return sizeof(ValueData); - } - bool GetData (DataExtractor &data, size_t limit_byte_size = UINT32_MAX) const; @@ -83,7 +129,7 @@ public: IsZero() const; void - Clear() { m_type = e_void; m_data.ulonglong = 0; } + Clear() { m_type = e_void; m_integer.clearAllBits(); } const char * GetTypeAsCString() const; @@ -133,6 +179,7 @@ public: Scalar& operator= (float v); Scalar& operator= (double v); Scalar& operator= (long double v); + Scalar& operator= (llvm::APInt v); Scalar& operator= (const Scalar& rhs); // Assignment operator Scalar& operator+= (const Scalar& rhs); Scalar& operator<<= (const Scalar& rhs); // Shift left @@ -174,6 +221,9 @@ public: Scalar::Type GetType() const { return m_type; } + void + SetType(const RegisterInfo*); + //---------------------------------------------------------------------- // Returns a casted value of the current contained data without // modifying the current value. FAIL_VALUE will be returned if the type @@ -194,6 +244,18 @@ public: unsigned long long RawULongLong () const; + unsigned char + UChar(unsigned char fail_value = 0) const; + + char + SChar(char fail_value = 0) const; + + unsigned short + UShort(unsigned short fail_value = 0) const; + + short + SShort(short fail_value = 0) const; + unsigned int UInt(unsigned int fail_value = 0) const; @@ -209,6 +271,12 @@ public: unsigned long long ULongLong(unsigned long long fail_value = 0) const; + llvm::APInt + SInt128(llvm::APInt& fail_value) const; + + llvm::APInt + UInt128(const llvm::APInt& fail_value) const; + float Float(float fail_value = 0.0f) const; @@ -255,6 +323,10 @@ public: } protected: + typedef char schar_t; + typedef unsigned char uchar_t; + typedef short sshort_t; + typedef unsigned short ushort_t; typedef int sint_t; typedef unsigned int uint_t; typedef long slong_t; @@ -265,24 +337,13 @@ protected: typedef double double_t; typedef long double long_double_t; - union ValueData - { - int sint; - unsigned int uint; - long slong; - unsigned long ulong; - long long slonglong; - unsigned long long ulonglong; - float flt; - double dbl; - long double ldbl; - }; - //------------------------------------------------------------------ // Classes that inherit from Scalar can see and modify these //------------------------------------------------------------------ Scalar::Type m_type; - ValueData m_data; + llvm::APInt m_integer; + llvm::APFloat m_float; + bool m_ieee_quad = false; private: friend const Scalar operator+ (const Scalar& lhs, const Scalar& rhs); diff --git a/include/lldb/Core/SearchFilter.h b/include/lldb/Core/SearchFilter.h index bbb7509cedb2..3d5e1fb39b43 100644 --- a/include/lldb/Core/SearchFilter.h +++ b/include/lldb/Core/SearchFilter.h @@ -272,7 +272,7 @@ class SearchFilterForUnconstrainedSearches : { public: SearchFilterForUnconstrainedSearches (const lldb::TargetSP &target_sp) : SearchFilter(target_sp) {} - ~SearchFilterForUnconstrainedSearches () {} + ~SearchFilterForUnconstrainedSearches() override = default; bool ModulePasses (const FileSpec &module_spec) override; @@ -283,7 +283,6 @@ public: protected: lldb::SearchFilterSP DoCopyForBreakpoint (Breakpoint &breakpoint) override; - }; //---------------------------------------------------------------------- @@ -311,8 +310,7 @@ public: SearchFilterByModule (const SearchFilterByModule& rhs); - virtual - ~SearchFilterByModule (); + ~SearchFilterByModule() override; const SearchFilterByModule& operator=(const SearchFilterByModule& rhs); @@ -372,8 +370,7 @@ public: SearchFilterByModuleList (const SearchFilterByModuleList& rhs); - virtual - ~SearchFilterByModuleList (); + ~SearchFilterByModuleList() override; const SearchFilterByModuleList& operator=(const SearchFilterByModuleList& rhs); @@ -409,7 +406,7 @@ protected: lldb::SearchFilterSP DoCopyForBreakpoint (Breakpoint &breakpoint) override; -private: +protected: FileSpecList m_module_spec_list; }; @@ -434,8 +431,7 @@ public: SearchFilterByModuleListAndCU (const SearchFilterByModuleListAndCU& rhs); - virtual - ~SearchFilterByModuleListAndCU (); + ~SearchFilterByModuleListAndCU() override; const SearchFilterByModuleListAndCU& operator=(const SearchFilterByModuleListAndCU& rhs); @@ -466,10 +462,9 @@ protected: DoCopyForBreakpoint (Breakpoint &breakpoint) override; private: - FileSpecList m_module_spec_list; FileSpecList m_cu_spec_list; }; } // namespace lldb_private -#endif // liblldb_SearchFilter_h_ +#endif // liblldb_SearchFilter_h_ diff --git a/include/lldb/Core/Section.h b/include/lldb/Core/Section.h index 65d408e29867..8c92f1ba667e 100644 --- a/include/lldb/Core/Section.h +++ b/include/lldb/Core/Section.h @@ -64,9 +64,6 @@ public: lldb::SectionSP FindSectionContainingFileAddress (lldb::addr_t addr, uint32_t depth = UINT32_MAX) const; - bool - GetSectionData (const DataExtractor& module_data, DataExtractor& section_data) const; - // Get the number of sections in this list only size_t GetSize () const @@ -288,6 +285,46 @@ public: return m_obj_file; } + //------------------------------------------------------------------ + /// Read the section data from the object file that the section + /// resides in. + /// + /// @param[in] dst + /// Where to place the data + /// + /// @param[in] dst_len + /// How many bytes of section data to read + /// + /// @param[in] offset + /// The offset in bytes within this section's data at which to + /// start copying data from. + /// + /// @return + /// The number of bytes read from the section, or zero if the + /// section has no data or \a offset is not a valid offset + /// in this section. + //------------------------------------------------------------------ + lldb::offset_t + GetSectionData (void *dst, lldb::offset_t dst_len, lldb::offset_t offset = 0); + + //------------------------------------------------------------------ + /// Get the shared reference to the section data from the object + /// file that the section resides in. No copies of the data will be + /// make unless the object file has been read from memory. If the + /// object file is on disk, it will shared the mmap data for the + /// entire object file. + /// + /// @param[in] data + /// Where to place the data, address byte size, and byte order + /// + /// @return + /// The number of bytes read from the section, or zero if the + /// section has no data or \a offset is not a valid offset + /// in this section. + //------------------------------------------------------------------ + lldb::offset_t + GetSectionData (DataExtractor& data) const; + uint32_t GetLog2Align() { return m_log2align; diff --git a/include/lldb/Core/SourceManager.h b/include/lldb/Core/SourceManager.h index 0f65be1bee4b..5504bafd6b7e 100644 --- a/include/lldb/Core/SourceManager.h +++ b/include/lldb/Core/SourceManager.h @@ -13,6 +13,7 @@ // C Includes // C++ Includes #include <map> +#include <memory> #include <vector> // Other libraries and framework includes @@ -26,15 +27,17 @@ class SourceManager { public: #ifndef SWIG - class File { - friend bool operator== (const SourceManager::File &lhs, const SourceManager::File &rhs); + friend bool operator== (const SourceManager::File &lhs, const SourceManager::File &rhs); + public: - File (const FileSpec &file_spec, Target *target); ~File(); + void + UpdateIfNeeded (); + size_t DisplaySourceLines (uint32_t line, uint32_t context_before, @@ -80,7 +83,6 @@ public: GetNumLines (); protected: - bool CalculateLineOffsets (uint32_t line = UINT32_MAX); @@ -92,20 +94,18 @@ public: typedef std::vector<uint32_t> LineOffsets; LineOffsets m_offsets; }; - #endif // SWIG typedef std::shared_ptr<File> FileSP; #ifndef SWIG - // The SourceFileCache class separates the source manager from the cache of source files, so the // cache can be stored in the Debugger, but the source managers can be per target. class SourceFileCache { public: - SourceFileCache () {} - ~SourceFileCache() {} + SourceFileCache() = default; + ~SourceFileCache() = default; void AddSourceFile (const FileSP &file_sp); FileSP FindSourceFile (const FileSpec &file_spec) const; @@ -114,8 +114,7 @@ public: typedef std::map <FileSpec, FileSP> FileCache; FileCache m_file_cache; }; -#endif - +#endif // SWIG //------------------------------------------------------------------ // Constructors and Destructors @@ -127,7 +126,6 @@ public: ~SourceManager(); - FileSP GetLastFile () { @@ -135,28 +133,28 @@ public: } size_t - DisplaySourceLinesWithLineNumbers (const FileSpec &file, - uint32_t line, - uint32_t context_before, - uint32_t context_after, - const char* current_line_cstr, - Stream *s, - const SymbolContextList *bp_locs = NULL); + DisplaySourceLinesWithLineNumbers(const FileSpec &file, + uint32_t line, + uint32_t context_before, + uint32_t context_after, + const char* current_line_cstr, + Stream *s, + const SymbolContextList *bp_locs = nullptr); // This variant uses the last file we visited. size_t - DisplaySourceLinesWithLineNumbersUsingLastFile (uint32_t start_line, - uint32_t count, - uint32_t curr_line, - const char* current_line_cstr, - Stream *s, - const SymbolContextList *bp_locs = NULL); + DisplaySourceLinesWithLineNumbersUsingLastFile(uint32_t start_line, + uint32_t count, + uint32_t curr_line, + const char* current_line_cstr, + Stream *s, + const SymbolContextList *bp_locs = nullptr); size_t - DisplayMoreWithLineNumbers (Stream *s, - uint32_t count, - bool reverse, - const SymbolContextList *bp_locs = NULL); + DisplayMoreWithLineNumbers(Stream *s, + uint32_t count, + bool reverse, + const SymbolContextList *bp_locs = nullptr); bool SetDefaultFileAndLine (const FileSpec &file_spec, uint32_t line); @@ -167,7 +165,7 @@ public: bool DefaultFileAndLineSet () { - return (m_last_file_sp.get() != NULL); + return (m_last_file_sp.get() != nullptr); } void @@ -181,10 +179,6 @@ public: GetFile (const FileSpec &file_spec); protected: - - //------------------------------------------------------------------ - // Classes that inherit from SourceManager can see and modify these - //------------------------------------------------------------------ FileSP m_last_file_sp; uint32_t m_last_line; uint32_t m_last_count; @@ -193,13 +187,11 @@ protected: lldb::DebuggerWP m_debugger_wp; private: - //------------------------------------------------------------------ - // For SourceManager only - //------------------------------------------------------------------ DISALLOW_COPY_AND_ASSIGN (SourceManager); }; bool operator== (const SourceManager::File &lhs, const SourceManager::File &rhs); + } // namespace lldb_private -#endif // liblldb_SourceManager_h_ +#endif // liblldb_SourceManager_h_ diff --git a/include/lldb/Core/Stream.h b/include/lldb/Core/Stream.h index 11780aa6ff0f..f784069894ec 100644 --- a/include/lldb/Core/Stream.h +++ b/include/lldb/Core/Stream.h @@ -9,11 +9,15 @@ #ifndef liblldb_Stream_h_ #define liblldb_Stream_h_ -#if defined(__cplusplus) +// C Includes +#include <stdarg.h> + +// C++ Includes +// Other libraries and framework includes +// Project includes #include "lldb/lldb-private.h" #include "lldb/Core/Flags.h" -#include <stdarg.h> namespace lldb_private { @@ -221,7 +225,7 @@ public: /// in one statement. //------------------------------------------------------------------ Stream& - operator<< (void *p); + operator<< (const void *p); //------------------------------------------------------------------ /// Output a character \a ch to the stream \a s. @@ -353,13 +357,13 @@ public: /// Size in bytes of the address, used for formatting. /// /// @param[in] prefix - /// A prefix C string. If NULL, no prefix will be output. + /// A prefix C string. If nullptr, no prefix will be output. /// /// @param[in] suffix - /// A suffix C string. If NULL, no suffix will be output. + /// A suffix C string. If nullptr, no suffix will be output. //------------------------------------------------------------------ void - Address (uint64_t addr, uint32_t addr_size, const char *prefix = NULL, const char *suffix = NULL); + Address(uint64_t addr, uint32_t addr_size, const char *prefix = nullptr, const char *suffix = nullptr); //------------------------------------------------------------------ /// Output an address range to this stream. @@ -377,13 +381,13 @@ public: /// Size in bytes of the address, used for formatting. /// /// @param[in] prefix - /// A prefix C string. If NULL, no prefix will be output. + /// A prefix C string. If nullptr, no prefix will be output. /// /// @param[in] suffix - /// A suffix C string. If NULL, no suffix will be output. + /// A suffix C string. If nullptr, no suffix will be output. //------------------------------------------------------------------ void - AddressRange(uint64_t lo_addr, uint64_t hi_addr, uint32_t addr_size, const char *prefix = NULL, const char *suffix = NULL); + AddressRange(uint64_t lo_addr, uint64_t hi_addr, uint32_t addr_size, const char *prefix = nullptr, const char *suffix = nullptr); //------------------------------------------------------------------ /// Output a C string to the stream. @@ -475,11 +479,11 @@ public: /// print an optional string following the indentation spaces. /// /// @param[in] s - /// A C string to print following the indentation. If NULL, just + /// A C string to print following the indentation. If nullptr, just /// output the indentation characters. //------------------------------------------------------------------ size_t - Indent(const char *s = NULL); + Indent(const char *s = nullptr); //------------------------------------------------------------------ /// Decrement the current indentation level. @@ -607,6 +611,4 @@ protected: } // namespace lldb_private -#endif // #if defined(__cplusplus) #endif // liblldb_Stream_h_ - diff --git a/include/lldb/Core/StreamAsynchronousIO.h b/include/lldb/Core/StreamAsynchronousIO.h index d3b054463fa7..b069cfd496e1 100644 --- a/include/lldb/Core/StreamAsynchronousIO.h +++ b/include/lldb/Core/StreamAsynchronousIO.h @@ -22,14 +22,13 @@ class StreamAsynchronousIO : public: StreamAsynchronousIO (Debugger &debugger, bool for_stdout); - virtual ~StreamAsynchronousIO (); + ~StreamAsynchronousIO () override; - virtual void - Flush (); - - virtual size_t - Write (const void *src, size_t src_len); + void + Flush () override; + size_t + Write (const void *src, size_t src_len) override; private: Debugger &m_debugger; @@ -38,4 +37,5 @@ private: }; } // namespace lldb_private -#endif // #ifndef liblldb_StreamAsynchronousIO_h + +#endif // liblldb_StreamAsynchronousIO_h diff --git a/include/lldb/Core/StreamCallback.h b/include/lldb/Core/StreamCallback.h index b5fb91c6ce07..e5a9da7512bb 100644 --- a/include/lldb/Core/StreamCallback.h +++ b/include/lldb/Core/StreamCallback.h @@ -24,14 +24,13 @@ class StreamCallback : public: StreamCallback (lldb::LogOutputCallback callback, void *baton); - virtual ~StreamCallback (); + ~StreamCallback () override; - virtual void - Flush (); - - virtual size_t - Write (const void *src, size_t src_len); + void + Flush () override; + size_t + Write (const void *src, size_t src_len) override; private: typedef std::map<lldb::tid_t, StreamString> collection; @@ -44,4 +43,5 @@ private: }; } // namespace lldb_private -#endif // #ifndef liblldb_StreamCallback_h + +#endif // liblldb_StreamCallback_h diff --git a/include/lldb/Core/StreamFile.h b/include/lldb/Core/StreamFile.h index 55bb361780a5..781f0a599493 100644 --- a/include/lldb/Core/StreamFile.h +++ b/include/lldb/Core/StreamFile.h @@ -43,8 +43,7 @@ public: StreamFile (FILE *fh, bool transfer_ownership); - virtual - ~StreamFile(); + ~StreamFile() override; File & GetFile () @@ -58,11 +57,11 @@ public: return m_file; } - virtual void - Flush (); + void + Flush () override; - virtual size_t - Write (const void *s, size_t length); + size_t + Write (const void *s, size_t length) override; protected: //------------------------------------------------------------------ @@ -76,4 +75,4 @@ private: } // namespace lldb_private -#endif // liblldb_StreamFile_h_ +#endif // liblldb_StreamFile_h_ diff --git a/include/lldb/Core/StreamGDBRemote.h b/include/lldb/Core/StreamGDBRemote.h index 3fdb6f6e7012..834f412d0a03 100644 --- a/include/lldb/Core/StreamGDBRemote.h +++ b/include/lldb/Core/StreamGDBRemote.h @@ -29,8 +29,7 @@ namespace lldb_private { uint32_t addr_size, lldb::ByteOrder byte_order); - virtual - ~StreamGDBRemote (); + ~StreamGDBRemote() override; //------------------------------------------------------------------ /// Output a block of data to the stream performing GDB-remote escaping. @@ -51,4 +50,4 @@ namespace lldb_private { } // namespace lldb_private -#endif // liblldb_StreamGDBRemote_h_ +#endif // liblldb_StreamGDBRemote_h_ diff --git a/include/lldb/Core/StreamString.h b/include/lldb/Core/StreamString.h index 1aa46dd80a68..5b6bde7a13c2 100644 --- a/include/lldb/Core/StreamString.h +++ b/include/lldb/Core/StreamString.h @@ -25,14 +25,13 @@ public: uint32_t addr_size, lldb::ByteOrder byte_order); - virtual - ~StreamString (); + ~StreamString () override; - virtual void - Flush (); + void + Flush () override; - virtual size_t - Write (const void *s, size_t length); + size_t + Write (const void *s, size_t length) override; void Clear(); @@ -60,8 +59,8 @@ public: protected: std::string m_packet; - }; } // namespace lldb_private -#endif // #ifndef liblldb_StreamString_h_ + +#endif // liblldb_StreamString_h_ diff --git a/include/lldb/Core/StreamTee.h b/include/lldb/Core/StreamTee.h index e2a29a374553..7ab619b3bb79 100644 --- a/include/lldb/Core/StreamTee.h +++ b/include/lldb/Core/StreamTee.h @@ -59,8 +59,7 @@ public: m_streams = rhs.m_streams; } - virtual - ~StreamTee () + ~StreamTee () override { } @@ -76,8 +75,8 @@ public: return *this; } - virtual void - Flush () + void + Flush () override { Mutex::Locker locker (m_streams_mutex); collection::iterator pos, end; @@ -93,8 +92,8 @@ public: } } - virtual size_t - Write (const void *s, size_t length) + size_t + Write (const void *s, size_t length) override { Mutex::Locker locker (m_streams_mutex); if (m_streams.empty()) @@ -164,7 +163,6 @@ public: m_streams[idx] = stream_sp; } - protected: typedef std::vector<lldb::StreamSP> collection; mutable Mutex m_streams_mutex; @@ -172,4 +170,5 @@ protected: }; } // namespace lldb_private -#endif // #ifndef liblldb_StreamTee_h_ + +#endif // liblldb_StreamTee_h_ diff --git a/include/lldb/Core/StringList.h b/include/lldb/Core/StringList.h index c69ed872c30d..3e341b994075 100644 --- a/include/lldb/Core/StringList.h +++ b/include/lldb/Core/StringList.h @@ -10,18 +10,24 @@ #ifndef liblldb_StringList_h_ #define liblldb_StringList_h_ +// C Includes #include <stdint.h> -#include "lldb/Core/STLUtils.h" -#include "lldb/lldb-forward.h" +// C++ Includes +#include <string> + +// Other libraries and framework includes #include "llvm/ADT/StringRef.h" +// Project includes +#include "lldb/lldb-forward.h" +#include "lldb/Core/STLUtils.h" + namespace lldb_private { class StringList { public: - StringList (); StringList (const char *str); @@ -120,7 +126,7 @@ public: SplitIntoLines (const char *lines, size_t len); std::string - CopyList(const char* item_preamble = NULL, + CopyList(const char* item_preamble = nullptr, const char* items_sep = "\n") const; StringList& @@ -142,7 +148,6 @@ public: size_t &exact_matches_idx) const; private: - STLStringArray m_strings; }; diff --git a/include/lldb/Core/StructuredData.h b/include/lldb/Core/StructuredData.h index 7da29e48299d..52f34521ef0e 100644 --- a/include/lldb/Core/StructuredData.h +++ b/include/lldb/Core/StructuredData.h @@ -12,16 +12,16 @@ // C Includes // C++ Includes - #include <functional> #include <map> +#include <memory> #include <string> #include <utility> #include <vector> +// Other libraries and framework includes #include "llvm/ADT/StringRef.h" -// Other libraries and framework includes // Project includes #include "lldb/lldb-defines.h" #include "lldb/Core/ConstString.h" @@ -47,7 +47,6 @@ namespace lldb_private { class StructuredData { public: - class Object; class Array; class Integer; @@ -89,9 +88,7 @@ public: { } - virtual ~Object () - { - } + virtual ~Object() = default; virtual bool IsValid() const @@ -120,80 +117,62 @@ public: Array * GetAsArray () { - if (m_type == Type::eTypeArray) - return (Array *)this; - return NULL; + return ((m_type == Type::eTypeArray) ? static_cast<Array *>(this) : nullptr); } Dictionary * GetAsDictionary () { - if (m_type == Type::eTypeDictionary) - return (Dictionary *)this; - return NULL; + return ((m_type == Type::eTypeDictionary) ? static_cast<Dictionary *>(this) : nullptr); } Integer * GetAsInteger () { - if (m_type == Type::eTypeInteger) - return (Integer *)this; - return NULL; + return ((m_type == Type::eTypeInteger) ? static_cast<Integer *>(this) : nullptr); } uint64_t GetIntegerValue (uint64_t fail_value = 0) { Integer *integer = GetAsInteger (); - if (integer) - return integer->GetValue(); - return fail_value; + return ((integer != nullptr) ? integer->GetValue() : fail_value); } Float * GetAsFloat () { - if (m_type == Type::eTypeFloat) - return (Float *)this; - return NULL; + return ((m_type == Type::eTypeFloat) ? static_cast<Float *>(this) : nullptr); } double GetFloatValue (double fail_value = 0.0) { Float *f = GetAsFloat (); - if (f) - return f->GetValue(); - return fail_value; + return ((f != nullptr) ? f->GetValue() : fail_value); } Boolean * GetAsBoolean () { - if (m_type == Type::eTypeBoolean) - return (Boolean *)this; - return NULL; + return ((m_type == Type::eTypeBoolean) ? static_cast<Boolean *>(this) : nullptr); } bool GetBooleanValue (bool fail_value = false) { Boolean *b = GetAsBoolean (); - if (b) - return b->GetValue(); - return fail_value; + return ((b != nullptr) ? b->GetValue() : fail_value); } String * GetAsString () { - if (m_type == Type::eTypeString) - return (String *)this; - return NULL; + return ((m_type == Type::eTypeString) ? static_cast<String *>(this) : nullptr); } std::string - GetStringValue(const char *fail_value = NULL) + GetStringValue(const char *fail_value = nullptr) { String *s = GetAsString (); if (s) @@ -208,9 +187,7 @@ public: Generic * GetAsGeneric() { - if (m_type == Type::eTypeGeneric) - return (Generic *)this; - return NULL; + return ((m_type == Type::eTypeGeneric) ? static_cast<Generic *>(this) : nullptr); } ObjectSP @@ -233,10 +210,7 @@ public: { } - virtual - ~Array() - { - } + ~Array() override = default; bool ForEach (std::function <bool(Object* object)> const &foreach_callback) const @@ -249,7 +223,6 @@ public: return true; } - size_t GetSize() const { @@ -277,11 +250,14 @@ public: bool GetItemAtIndexAsInteger(size_t idx, IntType &result) const { - ObjectSP value = GetItemAtIndex(idx); - if (auto int_value = value->GetAsInteger()) + ObjectSP value_sp = GetItemAtIndex(idx); + if (value_sp.get()) { - result = static_cast<IntType>(int_value->GetValue()); - return true; + if (auto int_value = value_sp->GetAsInteger()) + { + result = static_cast<IntType>(int_value->GetValue()); + return true; + } } return false; } @@ -299,11 +275,14 @@ public: bool GetItemAtIndexAsString(size_t idx, std::string &result) const { - ObjectSP value = GetItemAtIndex(idx); - if (auto string_value = value->GetAsString()) + ObjectSP value_sp = GetItemAtIndex(idx); + if (value_sp.get()) { - result = string_value->GetValue(); - return true; + if (auto string_value = value_sp->GetAsString()) + { + result = string_value->GetValue(); + return true; + } } return false; } @@ -320,13 +299,13 @@ public: bool GetItemAtIndexAsString(size_t idx, ConstString &result) const { - ObjectSP value = GetItemAtIndex(idx); - if (!value) - return false; - if (auto string_value = value->GetAsString()) - { - result = ConstString(string_value->GetValue()); - return true; + ObjectSP value_sp = GetItemAtIndex(idx); + if (value_sp.get()) { + if (auto string_value = value_sp->GetAsString()) + { + result = ConstString(string_value->GetValue()); + return true; + } } return false; } @@ -343,17 +322,27 @@ public: bool GetItemAtIndexAsDictionary(size_t idx, Dictionary *&result) const { - ObjectSP value = GetItemAtIndex(idx); - result = value->GetAsDictionary(); - return (result != nullptr); + result = nullptr; + ObjectSP value_sp = GetItemAtIndex(idx); + if (value_sp.get()) + { + result = value_sp->GetAsDictionary(); + return (result != nullptr); + } + return false; } bool GetItemAtIndexAsArray(size_t idx, Array *&result) const { - ObjectSP value = GetItemAtIndex(idx); - result = value->GetAsArray(); - return (result != nullptr); + result = nullptr; + ObjectSP value_sp = GetItemAtIndex(idx); + if (value_sp.get()) + { + result = value_sp->GetAsArray(); + return (result != nullptr); + } + return false; } void @@ -375,8 +364,7 @@ public: collection m_items; }; - - class Integer : public Object + class Integer : public Object { public: Integer (uint64_t i = 0) : @@ -385,9 +373,7 @@ public: { } - virtual ~Integer() - { - } + ~Integer() override = default; void SetValue (uint64_t value) @@ -407,7 +393,7 @@ public: uint64_t m_value; }; - class Float : public Object + class Float : public Object { public: Float (double d = 0.0) : @@ -416,9 +402,7 @@ public: { } - virtual ~Float() - { - } + ~Float() override = default; void SetValue (double value) @@ -438,7 +422,7 @@ public: double m_value; }; - class Boolean : public Object + class Boolean : public Object { public: Boolean (bool b = false) : @@ -447,9 +431,7 @@ public: { } - virtual ~Boolean() - { - } + ~Boolean() override = default; void SetValue (bool value) @@ -469,12 +451,10 @@ public: bool m_value; }; - - - class String : public Object + class String : public Object { public: - String (const char *cstr = NULL) : + String(const char *cstr = nullptr) : Object (Type::eTypeString), m_value () { @@ -522,9 +502,7 @@ public: { } - virtual ~Dictionary() - { - } + ~Dictionary() override = default; size_t GetSize() const @@ -580,13 +558,13 @@ public: bool GetValueForKeyAsInteger(llvm::StringRef key, IntType &result) const { - ObjectSP value = GetValueForKey(key); - if (!value) - return false; - if (auto int_value = value->GetAsInteger()) - { - result = static_cast<IntType>(int_value->GetValue()); - return true; + ObjectSP value_sp = GetValueForKey(key); + if (value_sp) { + if (auto int_value = value_sp->GetAsInteger()) + { + result = static_cast<IntType>(int_value->GetValue()); + return true; + } } return false; } @@ -604,13 +582,14 @@ public: bool GetValueForKeyAsString(llvm::StringRef key, std::string &result) const { - ObjectSP value = GetValueForKey(key); - if (!value) - return false; - if (auto string_value = value->GetAsString()) + ObjectSP value_sp = GetValueForKey(key); + if (value_sp.get()) { - result = string_value->GetValue(); - return true; + if (auto string_value = value_sp->GetAsString()) + { + result = string_value->GetValue(); + return true; + } } return false; } @@ -632,13 +611,14 @@ public: bool GetValueForKeyAsString(llvm::StringRef key, ConstString &result) const { - ObjectSP value = GetValueForKey(key); - if (!value) - return false; - if (auto string_value = value->GetAsString()) + ObjectSP value_sp = GetValueForKey(key); + if (value_sp.get()) { - result = ConstString(string_value->GetValue()); - return true; + if (auto string_value = value_sp->GetAsString()) + { + result = ConstString(string_value->GetValue()); + return true; + } } return false; } @@ -656,22 +636,26 @@ public: GetValueForKeyAsDictionary(llvm::StringRef key, Dictionary *&result) const { result = nullptr; - ObjectSP value = GetValueForKey(key); - if (!value) - return false; - result = value->GetAsDictionary(); - return true; + ObjectSP value_sp = GetValueForKey(key); + if (value_sp.get()) + { + result = value_sp->GetAsDictionary(); + return (result != nullptr); + } + return false; } bool GetValueForKeyAsArray(llvm::StringRef key, Array *&result) const { result = nullptr; - ObjectSP value = GetValueForKey(key); - if (!value) - return false; - result = value->GetAsArray(); - return true; + ObjectSP value_sp = GetValueForKey(key); + if (value_sp.get()) + { + result = value_sp->GetAsArray(); + return (result != nullptr); + } + return false; } bool @@ -683,10 +667,10 @@ public: } void - AddItem (llvm::StringRef key, ObjectSP value) + AddItem (llvm::StringRef key, ObjectSP value_sp) { ConstString key_cs(key); - m_dict[key_cs] = value; + m_dict[key_cs] = value_sp; } void @@ -728,9 +712,7 @@ public: { } - virtual ~Null() - { - } + ~Null() override = default; bool IsValid() const override @@ -739,13 +721,11 @@ public: } void Dump(Stream &s) const override; - - protected: }; class Generic : public Object { - public: + public: explicit Generic(void *object = nullptr) : Object (Type::eTypeGeneric), m_object (object) @@ -772,16 +752,14 @@ public: void Dump(Stream &s) const override; - private: + private: void *m_object; }; static ObjectSP ParseJSON (std::string json_text); - -}; // class StructuredData - +}; } // namespace lldb_private -#endif // liblldb_StructuredData_h_ +#endif // liblldb_StructuredData_h_ diff --git a/include/lldb/Core/ThreadSafeDenseMap.h b/include/lldb/Core/ThreadSafeDenseMap.h index f5a7ccfb2ffa..6b2b59b7617c 100644 --- a/include/lldb/Core/ThreadSafeDenseMap.h +++ b/include/lldb/Core/ThreadSafeDenseMap.h @@ -54,7 +54,27 @@ public: Mutex::Locker locker(m_mutex); return m_map.lookup(k); } - + + bool + Lookup (_KeyType k, + _ValueType& v) + { + Mutex::Locker locker(m_mutex); + auto iter = m_map.find(k), + end = m_map.end(); + if (iter == end) + return false; + v = iter->second; + return true; + } + + void + Clear () + { + Mutex::Locker locker(m_mutex); + m_map.clear(); + } + protected: LLVMMapType m_map; Mutex m_mutex; diff --git a/include/lldb/Core/ThreadSafeDenseSet.h b/include/lldb/Core/ThreadSafeDenseSet.h index 19c67b65e8c1..e019c70ed5e5 100644 --- a/include/lldb/Core/ThreadSafeDenseSet.h +++ b/include/lldb/Core/ThreadSafeDenseSet.h @@ -55,6 +55,13 @@ namespace lldb_private { return (m_set.count(e) > 0); } + void + Clear () + { + Mutex::Locker locker(m_mutex); + m_set.clear(); + } + protected: LLVMSetType m_set; Mutex m_mutex; diff --git a/include/lldb/Core/Timer.h b/include/lldb/Core/Timer.h index e354d91be442..ffaeba6fce9b 100644 --- a/include/lldb/Core/Timer.h +++ b/include/lldb/Core/Timer.h @@ -9,11 +9,17 @@ #ifndef liblldb_Timer_h_ #define liblldb_Timer_h_ -#if defined(__cplusplus) +// C Includes #include <stdarg.h> #include <stdio.h> -#include <string> + +// C++ Includes +#include <atomic> +#include <mutex> + +// Other libraries and framework includes +// Project includes #include "lldb/lldb-private.h" #include "lldb/Host/TimeValue.h" @@ -34,19 +40,19 @@ namespace lldb_private { class Timer { public: - static void - Initialize (); - //-------------------------------------------------------------- /// Default constructor. //-------------------------------------------------------------- Timer(const char *category, const char *format, ...) __attribute__ ((format (printf, 3, 4))); //-------------------------------------------------------------- - /// Desstructor + /// Destructor //-------------------------------------------------------------- ~Timer(); + static void + Initialize (); + void Dump (); @@ -63,7 +69,6 @@ public: ResetCategoryTimes (); protected: - void ChildStarted (const TimeValue& time); @@ -76,17 +81,17 @@ protected: uint64_t GetTimerElapsedNanoSeconds(); - //-------------------------------------------------------------- - /// Member variables - //-------------------------------------------------------------- const char *m_category; TimeValue m_total_start; TimeValue m_timer_start; uint64_t m_total_ticks; // Total running time for this timer including when other timers below this are running uint64_t m_timer_ticks; // Ticks for this timer that do not include when other timers below this one are running - static uint32_t g_depth; - static uint32_t g_display_depth; - static FILE * g_file; + + static std::atomic<bool> g_quiet; + static std::atomic<unsigned> g_display_depth; + static std::mutex g_file_mutex; + static FILE* g_file; + private: Timer(); DISALLOW_COPY_AND_ASSIGN (Timer); @@ -99,10 +104,8 @@ public: m_start (TimeValue::Now()) { } - - ~IntervalTimer() - { - } + + ~IntervalTimer() = default; uint64_t GetElapsedNanoSeconds() const @@ -121,7 +124,7 @@ public: { TimeValue now (TimeValue::Now()); const uint64_t elapsed_nsec = now - m_start; - const char *unit = NULL; + const char *unit = nullptr; float elapsed_value; if (elapsed_nsec < 1000) { @@ -150,11 +153,11 @@ public: va_end (args); return result; } + protected: TimeValue m_start; }; } // namespace lldb_private -#endif // #if defined(__cplusplus) -#endif // #ifndef liblldb_Timer_h_ +#endif // liblldb_Timer_h_ diff --git a/include/lldb/Core/UUID.h b/include/lldb/Core/UUID.h index 3bb14421b1e9..88426cfb6c75 100644 --- a/include/lldb/Core/UUID.h +++ b/include/lldb/Core/UUID.h @@ -16,7 +16,6 @@ // Other libraries and framework includes // Project includes - #include "lldb/lldb-private.h" namespace lldb_private { @@ -58,7 +57,7 @@ public: SetBytes (const void *uuid_bytes, uint32_t num_uuid_bytes = 16); std::string - GetAsString (const char *separator = NULL) const; + GetAsString(const char *separator = nullptr) const; size_t SetFromCString (const char *c_str, uint32_t num_uuid_bytes = 16); @@ -80,7 +79,7 @@ public: /// decoded UUID. /// /// @param[out] end - /// If \a end is not NULL, it will be filled in with the a + /// If \a end is not nullptr, it will be filled in with the a /// pointer to the character after the last successfully decoded /// byte. /// diff --git a/include/lldb/Core/UniqueCStringMap.h b/include/lldb/Core/UniqueCStringMap.h index 972c0d53ea99..1e50f747f2a8 100644 --- a/include/lldb/Core/UniqueCStringMap.h +++ b/include/lldb/Core/UniqueCStringMap.h @@ -9,18 +9,18 @@ #ifndef liblldb_UniqueCStringMap_h_ #define liblldb_UniqueCStringMap_h_ -#if defined(__cplusplus) -#include <assert.h> +// C Includes +// C++ Includes #include <algorithm> #include <vector> +// Other libraries and framework includes +// Project includes #include "lldb/Core/RegularExpression.h" namespace lldb_private { - - //---------------------------------------------------------------------- // Templatized uniqued string map. // @@ -37,7 +37,7 @@ public: struct Entry { Entry () : - cstring(NULL), + cstring(nullptr), value() { } @@ -146,9 +146,7 @@ public: const char * GetCStringAtIndex (uint32_t idx) const { - if (idx < m_map.size()) - return m_map[idx].cstring; - return NULL; + return ((idx < m_map.size()) ? m_map[idx].cstring : nullptr); } //------------------------------------------------------------------ @@ -172,8 +170,9 @@ public: } return fail_value; } + //------------------------------------------------------------------ - // Get a pointer to the first entry that matches "name". NULL will + // Get a pointer to the first entry that matches "name". nullptr will // be returned if there is no entry that matches "name". // // The caller is responsible for ensuring that the collection does @@ -191,12 +190,12 @@ public: if (pos_cstr == unique_cstr) return &(*pos); } - return NULL; + return nullptr; } //------------------------------------------------------------------ // Get a pointer to the next entry that matches "name" from a - // previously returned Entry pointer. NULL will be returned if there + // previously returned Entry pointer. nullptr will be returned if there // is no subsequent entry that matches "name". // // The caller is responsible for ensuring that the collection does @@ -216,7 +215,7 @@ public: return next_entry; } } - return NULL; + return nullptr; } size_t @@ -261,7 +260,6 @@ public: return m_map.size(); } - //------------------------------------------------------------------ // Returns true if this map is empty. //------------------------------------------------------------------ @@ -346,6 +344,7 @@ public: } return num_removed; } + protected: typedef std::vector<Entry> collection; typedef typename collection::iterator iterator; @@ -353,9 +352,6 @@ protected: collection m_map; }; - - } // namespace lldb_private -#endif // #if defined(__cplusplus) -#endif // liblldb_UniqueCStringMap_h_ +#endif // liblldb_UniqueCStringMap_h_ diff --git a/include/lldb/Core/Value.h b/include/lldb/Core/Value.h index 957cedeb0dcc..a6d934afd294 100644 --- a/include/lldb/Core/Value.h +++ b/include/lldb/Core/Value.h @@ -12,23 +12,21 @@ // C Includes // C++ Includes -#include <string> #include <vector> + // Other libraries and framework includes // Project includes #include "lldb/lldb-private.h" -#include "lldb/Core/ClangForward.h" #include "lldb/Core/DataBufferHeap.h" #include "lldb/Core/Error.h" #include "lldb/Core/Scalar.h" -#include "lldb/Symbol/ClangASTType.h" +#include "lldb/Symbol/CompilerType.h" namespace lldb_private { class Value { public: - // Values Less than zero are an error, greater than or equal to zero // returns what the Scalar result is. enum ValueType @@ -101,6 +99,7 @@ public: // Casts a vector, if valid, to an unsigned int of matching or largest supported size. // Truncates to the beginning of the vector if required. // Returns a default constructed Scalar if the Vector data is internally inconsistent. + llvm::APInt rhs = llvm::APInt(BITWIDTH_INT128, NUM_OF_WORDS_INT128, ((type128 *)bytes)->x); Scalar GetAsScalar() const { @@ -111,11 +110,7 @@ public: else if (length == 2) scalar = *(const uint16_t *)bytes; else if (length == 4) scalar = *(const uint32_t *)bytes; else if (length == 8) scalar = *(const uint64_t *)bytes; -#if defined (ENABLE_128_BIT_SUPPORT) - else if (length >= 16) scalar = *(const __uint128_t *)bytes; -#else - else if (length >= 16) scalar = *(const uint64_t *)bytes; -#endif + else if (length >= 16) scalar = rhs; } return scalar; } @@ -136,11 +131,11 @@ public: Value & operator=(const Value &rhs); - const ClangASTType & - GetClangType(); + const CompilerType & + GetCompilerType(); void - SetClangType (const ClangASTType &clang_type); + SetCompilerType (const CompilerType &compiler_type); ValueType GetValueType() const; @@ -163,7 +158,7 @@ public: void ClearContext () { - m_context = NULL; + m_context = nullptr; m_context_type = eContextTypeInvalid; } @@ -269,13 +264,13 @@ public: GetValueDefaultFormat (); uint64_t - GetValueByteSize (Error *error_ptr); + GetValueByteSize (Error *error_ptr, ExecutionContext *exe_ctx); Error - GetValueAsData (ExecutionContext *exe_ctx, - DataExtractor &data, - uint32_t data_offset, - Module *module); // Can be NULL + GetValueAsData(ExecutionContext *exe_ctx, + DataExtractor &data, + uint32_t data_offset, + Module *module); // Can be nullptr static const char * GetValueTypeAsCString (ValueType context_type); @@ -292,7 +287,7 @@ public: protected: Scalar m_value; Vector m_vector; - ClangASTType m_clang_type; + CompilerType m_compiler_type; void * m_context; ValueType m_value_type; ContextType m_context_type; @@ -309,9 +304,7 @@ public: ValueList (const ValueList &rhs); - ~ValueList () - { - } + ~ValueList() = default; const ValueList & operator= (const ValueList &rhs); @@ -322,8 +315,6 @@ public: Value *GetValueAtIndex(size_t idx); void Clear(); -protected: - private: typedef std::vector<Value> collection; @@ -332,4 +323,4 @@ private: } // namespace lldb_private -#endif // liblldb_Value_h_ +#endif // liblldb_Value_h_ diff --git a/include/lldb/Core/ValueObject.h b/include/lldb/Core/ValueObject.h index cdc507093b28..c066cc7d3661 100644 --- a/include/lldb/Core/ValueObject.h +++ b/include/lldb/Core/ValueObject.h @@ -12,6 +12,8 @@ // C Includes // C++ Includes +#include <functional> +#include <initializer_list> #include <map> #include <vector> @@ -27,7 +29,7 @@ #include "lldb/Core/ConstString.h" #include "lldb/Core/UserID.h" #include "lldb/Core/Value.h" -#include "lldb/Symbol/ClangASTType.h" +#include "lldb/Symbol/CompilerType.h" #include "lldb/Target/ExecutionContext.h" #include "lldb/Target/ExecutionContextScope.h" #include "lldb/Target/Process.h" @@ -69,7 +71,6 @@ namespace lldb_private { class ValueObject : public UserID { public: - enum GetExpressionPathFormat { eGetExpressionPathFormatDereferencePointers = 1, @@ -221,13 +222,11 @@ public: return g_default_options; } - }; class EvaluationPoint { public: - EvaluationPoint (); EvaluationPoint (ExecutionContextScope *exe_scope, bool use_selected = false); @@ -326,6 +325,8 @@ public: bool m_needs_update; }; + virtual ~ValueObject(); + const EvaluationPoint & GetUpdatePoint () const { @@ -371,10 +372,8 @@ public: void SetNeedsUpdate (); - virtual ~ValueObject(); - - ClangASTType - GetClangType (); + CompilerType + GetCompilerType (); // this vends a TypeImpl that is useful at the SB API layer virtual TypeImpl @@ -408,7 +407,7 @@ public: GetObjectRuntimeLanguage(); virtual uint32_t - GetTypeInfo (ClangASTType *pointee_or_element_clang_type = NULL); + GetTypeInfo(CompilerType *pointee_or_element_compiler_type = nullptr); virtual bool IsPointerType (); @@ -425,8 +424,11 @@ public: virtual bool IsPossibleDynamicType (); - virtual bool - IsObjCNil (); + bool + IsNilReference (); + + bool + IsUninitializedReference (); virtual bool IsBaseClass () @@ -454,20 +456,20 @@ public: lldb::ValueObjectSP GetValueForExpressionPath(const char* expression, - const char** first_unparsed = NULL, - ExpressionPathScanEndReason* reason_to_stop = NULL, - ExpressionPathEndResultType* final_value_type = NULL, + const char** first_unparsed = nullptr, + ExpressionPathScanEndReason* reason_to_stop = nullptr, + ExpressionPathEndResultType* final_value_type = nullptr, const GetValueForExpressionPathOptions& options = GetValueForExpressionPathOptions::DefaultOptions(), - ExpressionPathAftermath* final_task_on_target = NULL); + ExpressionPathAftermath* final_task_on_target = nullptr); int GetValuesForExpressionPath(const char* expression, lldb::ValueObjectListSP& list, - const char** first_unparsed = NULL, - ExpressionPathScanEndReason* reason_to_stop = NULL, - ExpressionPathEndResultType* final_value_type = NULL, + const char** first_unparsed = nullptr, + ExpressionPathScanEndReason* reason_to_stop = nullptr, + ExpressionPathEndResultType* final_value_type = nullptr, const GetValueForExpressionPathOptions& options = GetValueForExpressionPathOptions::DefaultOptions(), - ExpressionPathAftermath* final_task_on_target = NULL); + ExpressionPathAftermath* final_task_on_target = nullptr); virtual bool IsInScope () @@ -517,10 +519,10 @@ public: std::string& destination); virtual uint64_t - GetValueAsUnsigned (uint64_t fail_value, bool *success = NULL); + GetValueAsUnsigned(uint64_t fail_value, bool *success = nullptr); virtual int64_t - GetValueAsSigned (int64_t fail_value, bool *success = NULL); + GetValueAsSigned(int64_t fail_value, bool *success = nullptr); virtual bool SetValueFromCString (const char *value_str, Error& error); @@ -556,37 +558,37 @@ public: // this will always create the children if necessary lldb::ValueObjectSP - GetChildAtIndexPath (const std::initializer_list<size_t> &idxs, - size_t* index_of_error = NULL); + GetChildAtIndexPath(const std::initializer_list<size_t> &idxs, + size_t* index_of_error = nullptr); lldb::ValueObjectSP - GetChildAtIndexPath (const std::vector<size_t> &idxs, - size_t* index_of_error = NULL); + GetChildAtIndexPath(const std::vector<size_t> &idxs, + size_t* index_of_error = nullptr); lldb::ValueObjectSP - GetChildAtIndexPath (const std::initializer_list< std::pair<size_t, bool> > &idxs, - size_t* index_of_error = NULL); + GetChildAtIndexPath(const std::initializer_list< std::pair<size_t, bool> > &idxs, + size_t* index_of_error = nullptr); lldb::ValueObjectSP - GetChildAtIndexPath (const std::vector< std::pair<size_t, bool> > &idxs, - size_t* index_of_error = NULL); + GetChildAtIndexPath(const std::vector< std::pair<size_t, bool> > &idxs, + size_t* index_of_error = nullptr); // this will always create the children if necessary lldb::ValueObjectSP - GetChildAtNamePath (const std::initializer_list<ConstString> &names, - ConstString* name_of_error = NULL); + GetChildAtNamePath(const std::initializer_list<ConstString> &names, + ConstString* name_of_error = nullptr); lldb::ValueObjectSP - GetChildAtNamePath (const std::vector<ConstString> &names, - ConstString* name_of_error = NULL); + GetChildAtNamePath(const std::vector<ConstString> &names, + ConstString* name_of_error = nullptr); lldb::ValueObjectSP - GetChildAtNamePath (const std::initializer_list< std::pair<ConstString, bool> > &names, - ConstString* name_of_error = NULL); + GetChildAtNamePath(const std::initializer_list< std::pair<ConstString, bool> > &names, + ConstString* name_of_error = nullptr); lldb::ValueObjectSP - GetChildAtNamePath (const std::vector< std::pair<ConstString, bool> > &names, - ConstString* name_of_error = NULL); + GetChildAtNamePath(const std::vector< std::pair<ConstString, bool> > &names, + ConstString* name_of_error = nullptr); virtual lldb::ValueObjectSP GetChildMemberWithName (const ConstString &name, bool can_create); @@ -595,7 +597,7 @@ public: GetIndexOfChildWithName (const ConstString &name); size_t - GetNumChildren (); + GetNumChildren (uint32_t max=UINT32_MAX); const Value & GetValue() const; @@ -606,15 +608,22 @@ public: virtual bool ResolveValue (Scalar &scalar); + // return 'false' whenever you set the error, otherwise + // callers may assume true means everything is OK - this will + // break breakpoint conditions among potentially a few others + virtual bool + IsLogicalTrue (Error& error); + virtual const char * GetLocationAsCString (); const char * - GetSummaryAsCString (); + GetSummaryAsCString (lldb::LanguageType lang = lldb::eLanguageTypeUnknown); bool GetSummaryAsCString (TypeSummaryImpl* summary_ptr, - std::string& destination); + std::string& destination, + lldb::LanguageType lang = lldb::eLanguageTypeUnknown); bool GetSummaryAsCString (std::string& destination, @@ -671,11 +680,11 @@ public: SetName (const ConstString &name); virtual lldb::addr_t - GetAddressOf (bool scalar_is_load_address = true, - AddressType *address_type = NULL); + GetAddressOf(bool scalar_is_load_address = true, + AddressType *address_type = nullptr); lldb::addr_t - GetPointerValue (AddressType *address_type = NULL); + GetPointerValue(AddressType *address_type = nullptr); lldb::ValueObjectSP GetSyntheticChild (const ConstString &key) const; @@ -690,10 +699,10 @@ public: GetSyntheticExpressionPathChild(const char* expression, bool can_create); virtual lldb::ValueObjectSP - GetSyntheticChildAtOffset(uint32_t offset, const ClangASTType& type, bool can_create); + GetSyntheticChildAtOffset(uint32_t offset, const CompilerType& type, bool can_create); virtual lldb::ValueObjectSP - GetSyntheticBase (uint32_t offset, const ClangASTType& type, bool can_create); + GetSyntheticBase (uint32_t offset, const CompilerType& type, bool can_create); virtual lldb::ValueObjectSP GetDynamicValue (lldb::DynamicValueType valueType); @@ -746,11 +755,11 @@ public: |