diff options
Diffstat (limited to 'lldb')
330 files changed, 7403 insertions, 11892 deletions
diff --git a/lldb/bindings/interface/SBModule.i b/lldb/bindings/interface/SBModule.i index 606c9a5bbd0c..bda602d15690 100644 --- a/lldb/bindings/interface/SBModule.i +++ b/lldb/bindings/interface/SBModule.i @@ -137,6 +137,13 @@ public: void Clear(); + %feature("docstring", "Check if the module is file backed. + @return + True, if the module is backed by an object file on disk. + False, if the module is backed by an object file in memory.") IsFileBacked; + bool + IsFileBacked() const; + %feature("docstring", " Get const accessor for the module file specification. diff --git a/lldb/bindings/interface/SBPlatform.i b/lldb/bindings/interface/SBPlatform.i index 65615be7a361..6413784e69e7 100644 --- a/lldb/bindings/interface/SBPlatform.i +++ b/lldb/bindings/interface/SBPlatform.i @@ -177,6 +177,9 @@ public: uint32_t GetOSUpdateVersion (); + void + SetSDKRoot(const char *sysroot); + lldb::SBError Get (lldb::SBFileSpec &src, lldb::SBFileSpec &dst); diff --git a/lldb/bindings/interface/SBThread.i b/lldb/bindings/interface/SBThread.i index d847d38f0d66..ba7f5b3fdf76 100644 --- a/lldb/bindings/interface/SBThread.i +++ b/lldb/bindings/interface/SBThread.i @@ -405,6 +405,12 @@ public: bool SafeToCallFunctions (); + %feature("autodoc"," + Retruns a SBValue object representing the siginfo for the current signal. + ") GetSiginfo; + lldb::SBValue + GetSiginfo(SBError &error); + STRING_EXTENSION(SBThread) #ifdef SWIGPYTHON diff --git a/lldb/bindings/python/python-swigsafecast.swig b/lldb/bindings/python/python-swigsafecast.swig index 7d639e664f53..eb684133abef 100644 --- a/lldb/bindings/python/python-swigsafecast.swig +++ b/lldb/bindings/python/python-swigsafecast.swig @@ -1,19 +1,32 @@ namespace lldb_private { namespace python { -PyObject *SBTypeToSWIGWrapper(lldb::SBEvent &event_sb) { - return SWIG_NewPointerObj(&event_sb, SWIGTYPE_p_lldb__SBEvent, 0); -} - -PyObject *SBTypeToSWIGWrapper(lldb::SBCommandReturnObject &cmd_ret_obj_sb) { - return SWIG_NewPointerObj(&cmd_ret_obj_sb, - SWIGTYPE_p_lldb__SBCommandReturnObject, 0); -} - PythonObject ToSWIGHelper(void *obj, swig_type_info *info) { return {PyRefType::Owned, SWIG_NewPointerObj(obj, info, SWIG_POINTER_OWN)}; } +/// A class that automatically clears an SB object when it goes out of scope. +/// Use for cases where the SB object points to a temporary/unowned entity. +template <typename T> class ScopedPythonObject : PythonObject { +public: + ScopedPythonObject(T *sb, swig_type_info *info) + : PythonObject(ToSWIGHelper(sb, info)), m_sb(sb) {} + ~ScopedPythonObject() { + if (m_sb) + *m_sb = T(); + } + ScopedPythonObject(ScopedPythonObject &&rhs) + : PythonObject(std::move(rhs)), m_sb(std::exchange(rhs.m_sb, nullptr)) {} + ScopedPythonObject(const ScopedPythonObject &) = delete; + ScopedPythonObject &operator=(const ScopedPythonObject &) = delete; + ScopedPythonObject &operator=(ScopedPythonObject &&) = delete; + + const PythonObject &obj() const { return *this; } + +private: + T *m_sb; +}; + PythonObject ToSWIGWrapper(std::unique_ptr<lldb::SBValue> value_sb) { return ToSWIGHelper(value_sb.release(), SWIGTYPE_p_lldb__SBValue); } @@ -94,5 +107,17 @@ PythonObject ToSWIGWrapper(const SymbolContext &sym_ctx) { SWIGTYPE_p_lldb__SBSymbolContext); } +ScopedPythonObject<lldb::SBCommandReturnObject> +ToSWIGWrapper(CommandReturnObject &cmd_retobj) { + return ScopedPythonObject<lldb::SBCommandReturnObject>( + new lldb::SBCommandReturnObject(cmd_retobj), + SWIGTYPE_p_lldb__SBCommandReturnObject); +} + +ScopedPythonObject<lldb::SBEvent> ToSWIGWrapper(Event *event) { + return ScopedPythonObject<lldb::SBEvent>(new lldb::SBEvent(event), + SWIGTYPE_p_lldb__SBEvent); +} + } // namespace python } // namespace lldb_private diff --git a/lldb/bindings/python/python-wrapper.swig b/lldb/bindings/python/python-wrapper.swig index a2c1f756a0a2..626fc47bebb9 100644 --- a/lldb/bindings/python/python-wrapper.swig +++ b/lldb/bindings/python/python-wrapper.swig @@ -152,12 +152,12 @@ bool lldb_private::LLDBSwigPythonCallTypeScript( return true; } -void *lldb_private::LLDBSwigPythonCreateSyntheticProvider( +PythonObject lldb_private::LLDBSwigPythonCreateSyntheticProvider( const char *python_class_name, const char *session_dictionary_name, const lldb::ValueObjectSP &valobj_sp) { if (python_class_name == NULL || python_class_name[0] == '\0' || !session_dictionary_name) - Py_RETURN_NONE; + return PythonObject(); PyErr_Cleaner py_err_cleaner(true); @@ -167,29 +167,29 @@ void *lldb_private::LLDBSwigPythonCreateSyntheticProvider( python_class_name, dict); if (!pfunc.IsAllocated()) - Py_RETURN_NONE; + return PythonObject(); auto sb_value = std::make_unique<lldb::SBValue>(valobj_sp); sb_value->SetPreferSyntheticValue(false); PythonObject val_arg = ToSWIGWrapper(std::move(sb_value)); if (!val_arg.IsAllocated()) - Py_RETURN_NONE; + return PythonObject(); PythonObject result = pfunc(val_arg, dict); if (result.IsAllocated()) - return result.release(); + return result; - Py_RETURN_NONE; + return PythonObject(); } -void *lldb_private::LLDBSwigPythonCreateCommandObject( +PythonObject lldb_private::LLDBSwigPythonCreateCommandObject( const char *python_class_name, const char *session_dictionary_name, lldb::DebuggerSP debugger_sp) { if (python_class_name == NULL || python_class_name[0] == '\0' || !session_dictionary_name) - Py_RETURN_NONE; + return PythonObject(); PyErr_Cleaner py_err_cleaner(true); auto dict = PythonModule::MainModule().ResolveName<PythonDictionary>( @@ -198,24 +198,19 @@ void *lldb_private::LLDBSwigPythonCreateCommandObject( python_class_name, dict); if (!pfunc.IsAllocated()) - return nullptr; - - PythonObject result = pfunc(ToSWIGWrapper(std::move(debugger_sp)), dict); + return PythonObject(); - if (result.IsAllocated()) - return result.release(); - - Py_RETURN_NONE; + return pfunc(ToSWIGWrapper(std::move(debugger_sp)), dict); } -void *lldb_private::LLDBSwigPythonCreateScriptedProcess( +PythonObject lldb_private::LLDBSwigPythonCreateScriptedProcess( const char *python_class_name, const char *session_dictionary_name, const lldb::TargetSP &target_sp, const lldb_private::StructuredDataImpl &args_impl, std::string &error_string) { if (python_class_name == NULL || python_class_name[0] == '\0' || !session_dictionary_name) - Py_RETURN_NONE; + return PythonObject(); PyErr_Cleaner py_err_cleaner(true); @@ -227,7 +222,7 @@ void *lldb_private::LLDBSwigPythonCreateScriptedProcess( if (!pfunc.IsAllocated()) { error_string.append("could not find script class: "); error_string.append(python_class_name); - return nullptr; + return PythonObject(); } PythonObject target_arg = ToSWIGWrapper(target_sp); @@ -240,7 +235,7 @@ void *lldb_private::LLDBSwigPythonCreateScriptedProcess( [&](const llvm::ErrorInfoBase &E) { error_string.append(E.message()); }); - Py_RETURN_NONE; + return PythonObject(); } PythonObject result = {}; @@ -249,21 +244,17 @@ void *lldb_private::LLDBSwigPythonCreateScriptedProcess( } else { error_string.assign("wrong number of arguments in __init__, should be 2 " "(not including self)"); - Py_RETURN_NONE; } - - if (result.IsAllocated()) - return result.release(); - Py_RETURN_NONE; + return result; } -void *lldb_private::LLDBSwigPythonCreateScriptedThread( +PythonObject lldb_private::LLDBSwigPythonCreateScriptedThread( const char *python_class_name, const char *session_dictionary_name, const lldb::ProcessSP &process_sp, const StructuredDataImpl &args_impl, std::string &error_string) { if (python_class_name == NULL || python_class_name[0] == '\0' || !session_dictionary_name) - Py_RETURN_NONE; + return PythonObject(); PyErr_Cleaner py_err_cleaner(true); @@ -275,7 +266,7 @@ void *lldb_private::LLDBSwigPythonCreateScriptedThread( if (!pfunc.IsAllocated()) { error_string.append("could not find script class: "); error_string.append(python_class_name); - return nullptr; + return PythonObject(); } llvm::Expected<PythonCallable::ArgInfo> arg_info = pfunc.GetArgInfo(); @@ -286,30 +277,24 @@ void *lldb_private::LLDBSwigPythonCreateScriptedThread( [&](const llvm::ErrorInfoBase &E) { error_string.append(E.message()); }); - Py_RETURN_NONE; + return PythonObject(); } - PythonObject result = {}; - if (arg_info.get().max_positional_args == 2) { - result = pfunc(ToSWIGWrapper(process_sp), ToSWIGWrapper(args_impl)); - } else { - error_string.assign("wrong number of arguments in __init__, should be 2 " - "(not including self)"); - Py_RETURN_NONE; - } + if (arg_info.get().max_positional_args == 2) + return pfunc(ToSWIGWrapper(process_sp), ToSWIGWrapper(args_impl)); - if (result.IsAllocated()) - return result.release(); - Py_RETURN_NONE; + error_string.assign("wrong number of arguments in __init__, should be 2 " + "(not including self)"); + return PythonObject(); } -void *lldb_private::LLDBSwigPythonCreateScriptedThreadPlan( +PythonObject lldb_private::LLDBSwigPythonCreateScriptedThreadPlan( const char *python_class_name, const char *session_dictionary_name, const lldb_private::StructuredDataImpl &args_impl, std::string &error_string, const lldb::ThreadPlanSP &thread_plan_sp) { if (python_class_name == NULL || python_class_name[0] == '\0' || !session_dictionary_name) - Py_RETURN_NONE; + return PythonObject(); PyErr_Cleaner py_err_cleaner(true); @@ -321,7 +306,7 @@ void *lldb_private::LLDBSwigPythonCreateScriptedThreadPlan( if (!pfunc.IsAllocated()) { error_string.append("could not find script class: "); error_string.append(python_class_name); - return nullptr; + return PythonObject(); } PythonObject tp_arg = ToSWIGWrapper(thread_plan_sp); @@ -334,7 +319,7 @@ void *lldb_private::LLDBSwigPythonCreateScriptedThreadPlan( [&](const llvm::ErrorInfoBase &E) { error_string.append(E.message()); }); - Py_RETURN_NONE; + return PythonObject(); } PythonObject result = {}; @@ -343,7 +328,7 @@ void *lldb_private::LLDBSwigPythonCreateScriptedThreadPlan( if (args_sb->IsValid()) { error_string.assign( "args passed, but __init__ does not take an args dictionary"); - Py_RETURN_NONE; + return PythonObject(); } result = pfunc(tp_arg, dict); } else if (arg_info.get().max_positional_args >= 3) { @@ -351,15 +336,13 @@ void *lldb_private::LLDBSwigPythonCreateScriptedThreadPlan( } else { error_string.assign("wrong number of arguments in __init__, should be 2 or " "3 (not including self)"); - Py_RETURN_NONE; + return PythonObject(); } // FIXME: At this point we should check that the class we found supports all // the methods that we need. - if (result.IsAllocated()) - return result.release(); - Py_RETURN_NONE; + return result; } bool lldb_private::LLDBSWIGPythonCallThreadPlan( @@ -376,9 +359,8 @@ bool lldb_private::LLDBSWIGPythonCallThreadPlan( PythonObject result; if (event != nullptr) { - lldb::SBEvent sb_event(event); - PythonObject event_arg(PyRefType::Owned, SBTypeToSWIGWrapper(sb_event)); - result = pfunc(event_arg); + ScopedPythonObject<SBEvent> event_arg = ToSWIGWrapper(event); + result = pfunc(event_arg.obj()); } else result = pfunc(); @@ -401,14 +383,14 @@ bool lldb_private::LLDBSWIGPythonCallThreadPlan( return false; } -void *lldb_private::LLDBSwigPythonCreateScriptedBreakpointResolver( +PythonObject lldb_private::LLDBSwigPythonCreateScriptedBreakpointResolver( const char *python_class_name, const char *session_dictionary_name, const StructuredDataImpl &args_impl, const lldb::BreakpointSP &breakpoint_sp) { if (python_class_name == NULL || python_class_name[0] == '\0' || !session_dictionary_name) - Py_RETURN_NONE; + return PythonObject(); PyErr_Cleaner py_err_cleaner(true); @@ -418,7 +400,7 @@ void *lldb_private::LLDBSwigPythonCreateScriptedBreakpointResolver( python_class_name, dict); if (!pfunc.IsAllocated()) - return nullptr; + return PythonObject(); PythonObject result = pfunc(ToSWIGWrapper(breakpoint_sp), ToSWIGWrapper(args_impl), dict); @@ -429,11 +411,9 @@ void *lldb_private::LLDBSwigPythonCreateScriptedBreakpointResolver( // Check that __callback__ is defined: auto callback_func = result.ResolveName<PythonCallable>("__callback__"); if (callback_func.IsAllocated()) - return result.release(); - else - result.release(); + return result; } - Py_RETURN_NONE; + return PythonObject(); } unsigned int lldb_private::LLDBSwigPythonCallBreakpointResolver( @@ -475,17 +455,17 @@ unsigned int lldb_private::LLDBSwigPythonCallBreakpointResolver( return ret_val; } -void *lldb_private::LLDBSwigPythonCreateScriptedStopHook( +PythonObject lldb_private::LLDBSwigPythonCreateScriptedStopHook( lldb::TargetSP target_sp, const char *python_class_name, const char *session_dictionary_name, const StructuredDataImpl &args_impl, Status &error) { if (python_class_name == NULL || python_class_name[0] == '\0') { error.SetErrorString("Empty class name."); - Py_RETURN_NONE; + return PythonObject(); } if (!session_dictionary_name) { error.SetErrorString("No session dictionary"); - Py_RETURN_NONE; + return PythonObject(); } PyErr_Cleaner py_err_cleaner(true); @@ -498,7 +478,7 @@ void *lldb_private::LLDBSwigPythonCreateScriptedStopHook( if (!pfunc.IsAllocated()) { error.SetErrorStringWithFormat("Could not find class: %s.", python_class_name); - return nullptr; + return PythonObject(); } PythonObject result = @@ -515,23 +495,22 @@ void *lldb_private::LLDBSwigPythonCreateScriptedStopHook( "Wrong number of args for " "handle_stop callback, should be 2 (excluding self), got: %zu", num_args); - Py_RETURN_NONE; + return PythonObject(); } else - return result.release(); + return result; } else { error.SetErrorString("Couldn't get num arguments for handle_stop " "callback."); - Py_RETURN_NONE; + return PythonObject(); } - return result.release(); + return result; } else { error.SetErrorStringWithFormat("Class \"%s\" is missing the required " "handle_stop callback.", python_class_name); - result.release(); } } - Py_RETURN_NONE; + return PythonObject(); } bool lldb_private::LLDBSwigPythonStopHookCallHandleStop( @@ -795,7 +774,6 @@ bool lldb_private::LLDBSwigPythonCallCommand( lldb::DebuggerSP debugger, const char *args, lldb_private::CommandReturnObject &cmd_retobj, lldb::ExecutionContextRefSP exe_ctx_ref_sp) { - lldb::SBCommandReturnObject cmd_retobj_sb(cmd_retobj); PyErr_Cleaner py_err_cleaner(true); auto dict = PythonModule::MainModule().ResolveName<PythonDictionary>( @@ -812,14 +790,13 @@ bool lldb_private::LLDBSwigPythonCallCommand( return false; } PythonObject debugger_arg = ToSWIGWrapper(std::move(debugger)); - PythonObject cmd_retobj_arg(PyRefType::Owned, - SBTypeToSWIGWrapper(cmd_retobj_sb)); + auto cmd_retobj_arg = ToSWIGWrapper(cmd_retobj); if (argc.get().max_positional_args < 5u) - pfunc(debugger_arg, PythonString(args), cmd_retobj_arg, dict); + pfunc(debugger_arg, PythonString(args), cmd_retobj_arg.obj(), dict); else pfunc(debugger_arg, PythonString(args), - ToSWIGWrapper(std::move(exe_ctx_ref_sp)), cmd_retobj_arg, dict); + ToSWIGWrapper(std::move(exe_ctx_ref_sp)), cmd_retobj_arg.obj(), dict); return true; } @@ -828,7 +805,6 @@ bool lldb_private::LLDBSwigPythonCallCommandObject( PyObject *implementor, lldb::DebuggerSP debugger, const char *args, lldb_private::CommandReturnObject &cmd_retobj, lldb::ExecutionContextRefSP exe_ctx_ref_sp) { - lldb::SBCommandReturnObject cmd_retobj_sb(cmd_retobj); PyErr_Cleaner py_err_cleaner(true); @@ -838,21 +814,20 @@ bool lldb_private::LLDBSwigPythonCallCommandObject( if (!pfunc.IsAllocated()) return false; - PythonObject cmd_retobj_arg(PyRefType::Owned, - SBTypeToSWIGWrapper(cmd_retobj_sb)); + auto cmd_retobj_arg = ToSWIGWrapper(cmd_retobj); pfunc(ToSWIGWrapper(std::move(debugger)), PythonString(args), - ToSWIGWrapper(exe_ctx_ref_sp), cmd_retobj_arg); + ToSWIGWrapper(exe_ctx_ref_sp), cmd_retobj_arg.obj()); return true; } -void *lldb_private::LLDBSWIGPythonCreateOSPlugin( +PythonObject lldb_private::LLDBSWIGPythonCreateOSPlugin( const char *python_class_name, const char *session_dictionary_name, const lldb::ProcessSP &process_sp) { if (python_class_name == NULL || python_class_name[0] == '\0' || !session_dictionary_name) - Py_RETURN_NONE; + return PythonObject(); PyErr_Cleaner py_err_cleaner(true); @@ -862,21 +837,16 @@ void *lldb_private::LLDBSWIGPythonCreateOSPlugin( python_class_name, dict); if (!pfunc.IsAllocated()) - Py_RETURN_NONE; - - auto result = pfunc(ToSWIGWrapper(process_sp)); - - if (result.IsAllocated()) - return result.release(); + return PythonObject(); - Py_RETURN_NONE; + return pfunc(ToSWIGWrapper(process_sp)); } -void *lldb_private::LLDBSWIGPython_CreateFrameRecognizer( +PythonObject lldb_private::LLDBSWIGPython_CreateFrameRecognizer( const char *python_class_name, const char *session_dictionary_name) { if (python_class_name == NULL || python_class_name[0] == '\0' || !session_dictionary_name) - Py_RETURN_NONE; + return PythonObject(); PyErr_Cleaner py_err_cleaner(true); @@ -886,14 +856,9 @@ void *lldb_private::LLDBSWIGPython_CreateFrameRecognizer( python_class_name, dict); if (!pfunc.IsAllocated()) - Py_RETURN_NONE; - - auto result = pfunc(); - - if (result.IsAllocated()) - return result.release(); + return PythonObject(); - Py_RETURN_NONE; + return pfunc(); } PyObject *lldb_private::LLDBSwigPython_GetRecognizedArguments( diff --git a/lldb/bindings/python/python.swig b/lldb/bindings/python/python.swig index 5dcbd68d8544..cb80e1be61a8 100644 --- a/lldb/bindings/python/python.swig +++ b/lldb/bindings/python/python.swig @@ -133,15 +133,8 @@ using namespace lldb; %include "python-wrapper.swig" %pythoncode%{ -_initialize = True -try: - import lldbconfig - _initialize = lldbconfig.INITIALIZE -except ImportError: - pass debugger_unique_id = 0 -if _initialize: - SBDebugger.Initialize() +SBDebugger.Initialize() debugger = None target = None process = None diff --git a/lldb/include/lldb/API/SBDebugger.h b/lldb/include/lldb/API/SBDebugger.h index 1c771330cddc..a82c147053eb 100644 --- a/lldb/include/lldb/API/SBDebugger.h +++ b/lldb/include/lldb/API/SBDebugger.h @@ -306,6 +306,10 @@ public: void SetScriptLanguage(lldb::ScriptLanguage script_lang); + lldb::LanguageType GetREPLLanguage() const; + + void SetREPLLanguage(lldb::LanguageType repl_lang); + bool GetCloseInputOnEOF() const; void SetCloseInputOnEOF(bool b); diff --git a/lldb/include/lldb/API/SBDefines.h b/lldb/include/lldb/API/SBDefines.h index 3ab10ad8e061..ecf1dc34d8c5 100644 --- a/lldb/include/lldb/API/SBDefines.h +++ b/lldb/include/lldb/API/SBDefines.h @@ -15,6 +15,18 @@ #include "lldb/lldb-types.h" #include "lldb/lldb-versioning.h" +#ifndef LLDB_API +#if defined(_WIN32) +#if defined(LLDB_IN_LIBLLDB) +#define LLDB_API __declspec(dllexport) +#else +#define LLDB_API __declspec(dllimport) +#endif +#else // defined (_WIN32) +#define LLDB_API +#endif +#endif + // Forward Declarations namespace lldb { diff --git a/lldb/include/lldb/API/SBModule.h b/lldb/include/lldb/API/SBModule.h index dd783fe4107d..7200a1ef53fd 100644 --- a/lldb/include/lldb/API/SBModule.h +++ b/lldb/include/lldb/API/SBModule.h @@ -37,6 +37,8 @@ public: void Clear(); + bool IsFileBacked() const; + /// Get const accessor for the module file specification. /// /// This function returns the file for the module on the host system diff --git a/lldb/include/lldb/API/SBPlatform.h b/lldb/include/lldb/API/SBPlatform.h index 98291f18247d..4f5d04a24e95 100644 --- a/lldb/include/lldb/API/SBPlatform.h +++ b/lldb/include/lldb/API/SBPlatform.h @@ -137,6 +137,8 @@ public: uint32_t GetOSUpdateVersion(); + void SetSDKRoot(const char *sysroot); + SBError Put(SBFileSpec &src, SBFileSpec &dst); SBError Get(SBFileSpec &src, SBFileSpec &dst); @@ -170,6 +172,7 @@ public: protected: friend class SBDebugger; friend class SBTarget; + friend class SBThread; lldb::PlatformSP GetSP() const; diff --git a/lldb/include/lldb/API/SBTarget.h b/lldb/include/lldb/API/SBTarget.h index abd9ebf07407..9e75b5e503a8 100644 --- a/lldb/include/lldb/API/SBTarget.h +++ b/lldb/include/lldb/API/SBTarget.h @@ -875,6 +875,7 @@ protected: friend class SBSection; friend class SBSourceManager; friend class SBSymbol; + friend class SBThread; friend class SBValue; friend class SBVariablesOptions; diff --git a/lldb/include/lldb/API/SBThread.h b/lldb/include/lldb/API/SBThread.h index ac1b8407a220..76f794c25d9e 100644 --- a/lldb/include/lldb/API/SBThread.h +++ b/lldb/include/lldb/API/SBThread.h @@ -208,6 +208,8 @@ public: bool SafeToCallFunctions(); + SBValue GetSiginfo(SBError &error); + private: friend class SBBreakpoint; friend class SBBreakpointLocation; diff --git a/lldb/include/lldb/API/SBType.h b/lldb/include/lldb/API/SBType.h index 529b4d0eeffc..5885432d0624 100644 --- a/lldb/include/lldb/API/SBType.h +++ b/lldb/include/lldb/API/SBType.h @@ -225,6 +225,7 @@ protected: friend class SBFunction; friend class SBModule; friend class SBTarget; + friend class SBThread; friend class SBTypeEnumMember; friend class SBTypeEnumMemberList; friend class SBTypeNameSpecifier; diff --git a/lldb/include/lldb/Breakpoint/Breakpoint.h b/lldb/include/lldb/Breakpoint/Breakpoint.h index 40435d5c3d0f..113f8c4905e1 100644 --- a/lldb/include/lldb/Breakpoint/Breakpoint.h +++ b/lldb/include/lldb/Breakpoint/Breakpoint.h @@ -581,7 +581,7 @@ public: llvm::json::Value GetStatistics(); /// Get the time it took to resolve all locations in this breakpoint. - StatsDuration GetResolveTime() const { return m_resolve_time; } + StatsDuration::Duration GetResolveTime() const { return m_resolve_time; } protected: friend class Target; @@ -660,7 +660,7 @@ private: BreakpointName::Permissions m_permissions; - StatsDuration m_resolve_time{0.0}; + StatsDuration m_resolve_time; void SendBreakpointChangedEvent(lldb::BreakpointEventType eventKind); diff --git a/lldb/include/lldb/Breakpoint/BreakpointOptions.h b/lldb/include/lldb/Breakpoint/BreakpointOptions.h index 7b78265920a2..c2456024d919 100644 --- a/lldb/include/lldb/Breakpoint/BreakpointOptions.h +++ b/lldb/include/lldb/Breakpoint/BreakpointOptions.h @@ -43,11 +43,10 @@ public: | eCondition | eAutoContinue) }; struct CommandData { - CommandData() : user_source(), script_source() {} + CommandData() {} CommandData(const StringList &user_source, lldb::ScriptLanguage interp) - : user_source(user_source), script_source(), interpreter(interp), - stop_on_error(true) {} + : user_source(user_source), interpreter(interp), stop_on_error(true) {} virtual ~CommandData() = default; @@ -195,8 +194,8 @@ public: /// The commands will be appended to this list. /// /// \return - /// \btrue if the command callback is a command-line callback, - /// \bfalse otherwise. + /// \b true if the command callback is a command-line callback, + /// \b false otherwise. bool GetCommandLineCallbacks(StringList &command_list); /// Remove the callback from this option set. diff --git a/lldb/include/lldb/Breakpoint/WatchpointOptions.h b/lldb/include/lldb/Breakpoint/WatchpointOptions.h index fbfcb91c4249..c5ad90c334c4 100644 --- a/lldb/include/lldb/Breakpoint/WatchpointOptions.h +++ b/lldb/include/lldb/Breakpoint/WatchpointOptions.h @@ -166,7 +166,7 @@ public: lldb::user_id_t watch_id); struct CommandData { - CommandData() : user_source(), script_source() {} + CommandData() {} ~CommandData() = default; diff --git a/lldb/include/lldb/Core/Address.h b/lldb/include/lldb/Core/Address.h index dc50e27ca277..f77ffc2fd25e 100644 --- a/lldb/include/lldb/Core/Address.h +++ b/lldb/include/lldb/Core/Address.h @@ -116,7 +116,7 @@ public: /// /// Initialize with a invalid section (NULL) and an invalid offset /// (LLDB_INVALID_ADDRESS). - Address() : m_section_wp() {} + Address() {} /// Copy constructor /// diff --git a/lldb/include/lldb/Core/Debugger.h b/lldb/include/lldb/Core/Debugger.h index 1ab21bec54c9..f9a1f1eea54f 100644 --- a/lldb/include/lldb/Core/Debugger.h +++ b/lldb/include/lldb/Core/Debugger.h @@ -306,6 +306,10 @@ public: bool SetScriptLanguage(lldb::ScriptLanguage script_lang); + lldb::LanguageType GetREPLLanguage() const; + + bool SetREPLLanguage(lldb::LanguageType repl_lang); + uint32_t GetTerminalWidth() const; bool SetTerminalWidth(uint32_t term_width); diff --git a/lldb/include/lldb/Core/Declaration.h b/lldb/include/lldb/Core/Declaration.h index f81de21bc8f8..6ae21eb65eb3 100644 --- a/lldb/include/lldb/Core/Declaration.h +++ b/lldb/include/lldb/Core/Declaration.h @@ -24,7 +24,7 @@ namespace lldb_private { class Declaration { public: /// Default constructor. - Declaration() : m_file() {} + Declaration() {} /// Construct with file specification, and optional line and column. /// @@ -45,7 +45,7 @@ public: /// Construct with a pointer to another Declaration object. Declaration(const Declaration *decl_ptr) - : m_file(), m_line(0), m_column(LLDB_INVALID_COLUMN_NUMBER) { + : m_line(0), m_column(LLDB_INVALID_COLUMN_NUMBER) { if (decl_ptr) *this = *decl_ptr; } @@ -152,8 +152,6 @@ public: /// The number of bytes that this object occupies in memory. /// The returned value does not include the bytes for any /// shared string values. - /// - /// \see ConstString::StaticMemorySize () size_t MemorySize() const; /// Set accessor for the declaration file specification. diff --git a/lldb/include/lldb/Core/Disassembler.h b/lldb/include/lldb/Core/Disassembler.h index 0925bf358b9c..87979fd92584 100644 --- a/lldb/include/lldb/Core/Disassembler.h +++ b/lldb/include/lldb/Core/Disassembler.h @@ -465,7 +465,7 @@ protected: uint32_t line = LLDB_INVALID_LINE_NUMBER; uint32_t column = 0; - SourceLine() : file() {} + SourceLine() {} bool operator==(const SourceLine &rhs) const { return file == rhs.file && line == rhs.line && rhs.column == column; @@ -489,7 +489,7 @@ protected: // Whether to print a blank line at the end of the source lines. bool print_source_context_end_eol = true; - SourceLinesToDisplay() : lines() {} + SourceLinesToDisplay() {} }; // Get the function's declaration line number, hopefully a line number diff --git a/lldb/include/lldb/Core/DumpDataExtractor.h b/lldb/include/lldb/Core/DumpDataExtractor.h index 12188609e8c0..08501b512a2b 100644 --- a/lldb/include/lldb/Core/DumpDataExtractor.h +++ b/lldb/include/lldb/Core/DumpDataExtractor.h @@ -76,6 +76,15 @@ class Stream; /// same integer value. If the items being displayed are not /// bitfields, this value should be zero. /// +/// \param[in] exe_scope +/// If provided, this will be used to lookup language specific +/// information, address information and memory tags. +/// (if they are requested by the other options) +/// +/// \param[in] show_memory_tags +/// If exe_scope and base_addr are valid, include memory tags +/// in the output. This does not apply to certain formats. +/// /// \return /// The offset at which dumping ended. lldb::offset_t @@ -83,7 +92,8 @@ DumpDataExtractor(const DataExtractor &DE, 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); + ExecutionContextScope *exe_scope = nullptr, + bool show_memory_tags = false); void DumpHexBytes(Stream *s, const void *src, size_t src_len, uint32_t bytes_per_line, lldb::addr_t base_addr); diff --git a/lldb/include/lldb/Core/FileSpecList.h b/lldb/include/lldb/Core/FileSpecList.h index cab8e9b9b43f..117c6b691498 100644 --- a/lldb/include/lldb/Core/FileSpecList.h +++ b/lldb/include/lldb/Core/FileSpecList.h @@ -152,8 +152,6 @@ public: /// /// \return /// The number of bytes that this object occupies in memory. - /// - /// \see ConstString::StaticMemorySize () size_t MemorySize() const; bool IsEmpty() const { return m_files.empty(); } diff --git a/lldb/include/lldb/Core/FormatEntity.h b/lldb/include/lldb/Core/FormatEntity.h index ecae8500df40..cd9019d55554 100644 --- a/lldb/include/lldb/Core/FormatEntity.h +++ b/lldb/include/lldb/Core/FormatEntity.h @@ -148,7 +148,7 @@ public: Entry(Type t = Type::Invalid, const char *s = nullptr, const char *f = nullptr) - : string(s ? s : ""), printf_format(f ? f : ""), children(), type(t) {} + : string(s ? s : ""), printf_format(f ? f : ""), type(t) {} Entry(llvm::StringRef s); Entry(char ch); diff --git a/lldb/include/lldb/Core/LoadedModuleInfoList.h b/lldb/include/lldb/Core/LoadedModuleInfoList.h index ad6da2bd7559..3f65ddc06d73 100644 --- a/lldb/include/lldb/Core/LoadedModuleInfoList.h +++ b/lldb/include/lldb/Core/LoadedModuleInfoList.h @@ -101,7 +101,7 @@ public: lldb::addr_t m_dynamic; }; - LoadedModuleInfoList() : m_list() {} + LoadedModuleInfoList() {} void add(const LoadedModuleInfo &mod) { m_list.push_back(mod); } diff --git a/lldb/include/lldb/Core/Mangled.h b/lldb/include/lldb/Core/Mangled.h index 6c92591a0881..4e4f75e18e34 100644 --- a/lldb/include/lldb/Core/Mangled.h +++ b/lldb/include/lldb/Core/Mangled.h @@ -72,10 +72,10 @@ public: return !(*this == rhs); } - /// Convert to pointer operator. + /// Convert to bool operator. /// - /// This allows code to check a Mangled object to see if it contains a valid - /// mangled name using code such as: + /// This allows code to check any Mangled objects to see if they contain + /// anything valid using code such as: /// /// \code /// Mangled mangled(...); @@ -84,25 +84,9 @@ public: /// \endcode /// /// \return - /// A pointer to this object if either the mangled or unmangled - /// name is set, NULL otherwise. - operator void *() const; - - /// Logical NOT operator. - /// - /// This allows code to check a Mangled object to see if it contains an - /// empty mangled name using code such as: - /// - /// \code - /// Mangled mangled(...); - /// if (!mangled) - /// { ... - /// \endcode - /// - /// \return - /// Returns \b true if the object has an empty mangled and - /// unmangled name, \b false otherwise. - bool operator!() const; + /// Returns \b true if either the mangled or unmangled name is set, + /// \b false if the object has an empty mangled and unmangled name. + explicit operator bool() const; /// Clear the mangled and demangled values. void Clear(); @@ -199,8 +183,6 @@ public: /// /// \return /// The number of bytes that this object occupies in memory. - /// - /// \see ConstString::StaticMemorySize () size_t MemorySize() const; /// Set the string value in this object. diff --git a/lldb/include/lldb/Core/Module.h b/lldb/include/lldb/Core/Module.h index 6b1e4f8f3704..f6c32586eda8 100644 --- a/lldb/include/lldb/Core/Module.h +++ b/lldb/include/lldb/Core/Module.h @@ -905,7 +905,7 @@ public: /// correctly. class LookupInfo { public: - LookupInfo() : m_name(), m_lookup_name() {} + LookupInfo() {} LookupInfo(ConstString name, lldb::FunctionNameType name_type_mask, lldb::LanguageType language); @@ -1047,11 +1047,11 @@ protected: /// We store a symbol table parse time duration here because we might have /// an object file and a symbol file which both have symbol tables. The parse /// time for the symbol tables can be aggregated here. - StatsDuration m_symtab_parse_time{0.0}; + StatsDuration m_symtab_parse_time; /// We store a symbol named index time duration here because we might have /// an object file and a symbol file which both have symbol tables. The parse /// time for the symbol tables can be aggregated here. - StatsDuration m_symtab_index_time{0.0}; + StatsDuration m_symtab_index_time; /// Resolve a file or load virtual address. /// diff --git a/lldb/include/lldb/Core/ModuleSpec.h b/lldb/include/lldb/Core/ModuleSpec.h index 8e5deebbab9a..bcf4ec30a673 100644 --- a/lldb/include/lldb/Core/ModuleSpec.h +++ b/lldb/include/lldb/Core/ModuleSpec.h @@ -25,18 +25,14 @@ namespace lldb_private { class ModuleSpec { public: - ModuleSpec() - : m_file(), m_platform_file(), m_symbol_file(), m_arch(), m_uuid(), - m_object_name(), m_source_mappings() {} + ModuleSpec() {} /// If the \c data argument is passed, its contents will be used /// as the module contents instead of trying to read them from /// \c file_spec . ModuleSpec(const FileSpec &file_spec, const UUID &uuid = UUID(), lldb::DataBufferSP data = lldb::DataBufferSP()) - : m_file(file_spec), m_platform_file(), m_symbol_file(), m_arch(), - m_uuid(uuid), m_object_name(), m_object_offset(0), m_source_mappings(), - m_data(data) { + : m_file(file_spec), m_uuid(uuid), m_object_offset(0), m_data(data) { if (data) m_object_size = data->GetByteSize(); else if (m_file) @@ -44,10 +40,8 @@ public: } ModuleSpec(const FileSpec &file_spec, const ArchSpec &arch) - : m_file(file_spec), m_platform_file(), m_symbol_file(), m_arch(arch), - m_uuid(), m_object_name(), m_object_offset(0), - m_object_size(FileSystem::Instance().GetByteSize(file_spec)), - m_source_mappings() {} + : m_file(file_spec), m_arch(arch), m_object_offset(0), + m_object_size(FileSystem::Instance().GetByteSize(file_spec)) {} FileSpec *GetFileSpecPtr() { return (m_file ? &m_file : nullptr); } @@ -279,9 +273,9 @@ protected: class ModuleSpecList { public: - ModuleSpecList() : m_specs(), m_mutex() {} + ModuleSpecList() {} - ModuleSpecList(const ModuleSpecList &rhs) : m_specs(), m_mutex() { + ModuleSpecList(const ModuleSpecList &rhs) { std::lock_guard<std::recursive_mutex> lhs_guard(m_mutex); std::lock_guard<std::recursive_mutex> rhs_guard(rhs.m_mutex); m_specs = rhs.m_specs; diff --git a/lldb/include/lldb/Core/StructuredDataImpl.h b/lldb/include/lldb/Core/StructuredDataImpl.h index 8930ebff8166..355aa77c4e5c 100644 --- a/lldb/include/lldb/Core/StructuredDataImpl.h +++ b/lldb/include/lldb/Core/StructuredDataImpl.h @@ -25,7 +25,7 @@ namespace lldb_private { class StructuredDataImpl { public: - StructuredDataImpl() : m_plugin_wp(), m_data_sp() {} + StructuredDataImpl() {} StructuredDataImpl(const StructuredDataImpl &rhs) = default; diff --git a/lldb/include/lldb/Core/ThreadSafeValue.h b/lldb/include/lldb/Core/ThreadSafeValue.h index 51820ec9cd9d..979f008b3170 100644 --- a/lldb/include/lldb/Core/ThreadSafeValue.h +++ b/lldb/include/lldb/Core/ThreadSafeValue.h @@ -18,7 +18,7 @@ namespace lldb_private { template <class T> class ThreadSafeValue { public: ThreadSafeValue() = default; - ThreadSafeValue(const T &value) : m_value(value), m_mutex() {} + ThreadSafeValue(const T &value) : m_value(value) {} ~ThreadSafeValue() = default; diff --git a/lldb/include/lldb/Core/UniqueCStringMap.h b/lldb/include/lldb/Core/UniqueCStringMap.h index e37027a0150a..9c8b8081d374 100644 --- a/lldb/include/lldb/Core/UniqueCStringMap.h +++ b/lldb/include/lldb/Core/UniqueCStringMap.h @@ -165,7 +165,21 @@ public: // my_map.Append (UniqueCStringMap::Entry(GetName(...), GetValue(...))); // } // my_map.Sort(); - void Sort() { llvm::sort(m_map.begin(), m_map.end(), Compare()); } + void Sort() { + Sort([](const T &, const T &) { return false; }); + } + + /// Sort contents of this map using the provided comparator to break ties for + /// entries with the same string value. + template <typename TCompare> void Sort(TCompare tc) { + Compare c; + llvm::sort(m_map, [&](const Entry &lhs, const Entry &rhs) -> bool { + int result = c.ThreeWay(lhs.cstring, rhs.cstring); + if (result == 0) + return tc(lhs.value, rhs.value); + return result < 0; + }); + } // Since we are using a vector to contain our items it will always double its // memory consumption as things are added to the vector, so if you intend to @@ -205,13 +219,24 @@ protected: return operator()(lhs, rhs.cstring); } + bool operator()(ConstString lhs, ConstString rhs) { + return ThreeWay(lhs, rhs) < 0; + } + // This is only for uniqueness, not lexicographical ordering, so we can // just compare pointers. *However*, comparing pointers from different // allocations is UB, so we need compare their integral values instead. - bool operator()(ConstString lhs, ConstString rhs) { - return uintptr_t(lhs.GetCString()) < uintptr_t(rhs.GetCString()); + int ThreeWay(ConstString lhs, ConstString rhs) { + auto lhsint = uintptr_t(lhs.GetCString()); + auto rhsint = uintptr_t(rhs.GetCString()); + if (lhsint < rhsint) + return -1; + if (lhsint > rhsint) + return 1; + return 0; } }; + collection m_map; }; diff --git a/lldb/include/lldb/Core/Value.h b/lldb/include/lldb/Core/Value.h index 1ee4fe639e6e..9f00a14251e2 100644 --- a/lldb/include/lldb/Core/Value.h +++ b/lldb/include/lldb/Core/Value.h @@ -156,7 +156,7 @@ protected: class ValueList { public: - ValueList() : m_values() {} + ValueList() {} ValueList(const ValueList &rhs); diff --git a/lldb/include/lldb/Core/ValueObject.h b/lldb/include/lldb/Core/ValueObject.h index 192149f05436..dac7aac06246 100644 --- a/lldb/include/lldb/Core/ValueObject.h +++ b/lldb/include/lldb/Core/ValueObject.h @@ -795,7 +795,7 @@ protected: class ChildrenManager { public: - ChildrenManager() : m_mutex(), m_children() {} + ChildrenManager() {} bool HasChildAtIndex(size_t idx) { std::lock_guard<std::recursive_mutex> guard(m_mutex); diff --git a/lldb/include/lldb/DataFormatters/FormatClasses.h b/lldb/include/lldb/DataFormatters/FormatClasses.h index b8540de3d740..2b47bcdf3a69 100644 --- a/lldb/include/lldb/DataFormatters/FormatClasses.h +++ b/lldb/include/lldb/DataFormatters/FormatClasses.h @@ -105,23 +105,23 @@ private: class TypeNameSpecifierImpl { public: - TypeNameSpecifierImpl() : m_type() {} + TypeNameSpecifierImpl() {} TypeNameSpecifierImpl(llvm::StringRef name, bool is_regex) - : m_is_regex(is_regex), m_type() { + : m_is_regex(is_regex) { m_type.m_type_name = std::string(name); } // if constructing with a given type, is_regex cannot be true since we are // giving an exact type to match - TypeNameSpecifierImpl(lldb::TypeSP type) : m_is_regex(false), m_type() { + TypeNameSpecifierImpl(lldb::TypeSP type) : m_is_regex(false) { if (type) { m_type.m_type_name = std::string(type->GetName().GetStringRef()); m_type.m_compiler_type = type->GetForwardCompilerType(); } } - TypeNameSpecifierImpl(CompilerType type) : m_is_regex(false), m_type() { + TypeNameSpecifierImpl(CompilerType type) : m_is_regex(false) { if (type.IsValid()) { m_type.m_type_name.assign(type.GetTypeName().GetCString()); m_type.m_compiler_type = type; diff --git a/lldb/include/lldb/DataFormatters/TypeSynthetic.h b/lldb/include/lldb/DataFormatters/TypeSynthetic.h index 24322bd51a0c..3f58297a529b 100644 --- a/lldb/include/lldb/DataFormatters/TypeSynthetic.h +++ b/lldb/include/lldb/DataFormatters/TypeSynthetic.h @@ -279,11 +279,11 @@ class TypeFilterImpl : public SyntheticChildren { public: TypeFilterImpl(const SyntheticChildren::Flags &flags) - : SyntheticChildren(flags), m_expression_paths() {} + : SyntheticChildren(flags) {} TypeFilterImpl(const SyntheticChildren::Flags &flags, const std::initializer_list<const char *> items) - : SyntheticChildren(flags), m_expression_paths() { + : SyntheticChildren(flags) { for (auto path : items) AddExpressionPath(path); } @@ -391,7 +391,7 @@ class ScriptedSyntheticChildren : public SyntheticChildren { public: ScriptedSyntheticChildren(const SyntheticChildren::Flags &flags, const char *pclass, const char *pcode = nullptr) - : SyntheticChildren(flags), m_python_class(), m_python_code() { + : SyntheticChildren(flags) { if (pclass) m_python_class = pclass; if (pcode) diff --git a/lldb/include/lldb/Expression/IRExecutionUnit.h b/lldb/include/lldb/Expression/IRExecutionUnit.h index bb43851e17c9..ef53ca512d75 100644 --- a/lldb/include/lldb/Expression/IRExecutionUnit.h +++ b/lldb/include/lldb/Expression/IRExecutionUnit.h @@ -347,10 +347,9 @@ private: AllocationRecord(uintptr_t host_address, uint32_t permissions, lldb::SectionType sect_type, size_t size, unsigned alignment, unsigned section_id, const char *name) - : m_name(), m_process_address(LLDB_INVALID_ADDRESS), - m_host_address(host_address), m_permissions(permissions), - m_sect_type(sect_type), m_size(size), m_alignment(alignment), - m_section_id(section_id) { + : m_process_address(LLDB_INVALID_ADDRESS), m_host_address(host_address), + m_permissions(permissions), m_sect_type(sect_type), m_size(size), + m_alignment(alignment), m_section_id(section_id) { if (name && name[0]) m_name = name; } diff --git a/lldb/include/lldb/Host/Debug.h b/lldb/include/lldb/Host/Debug.h index 7da59dd04a66..e4e410474c02 100644 --- a/lldb/include/lldb/Host/Debug.h +++ b/lldb/include/lldb/Host/Debug.h @@ -32,15 +32,13 @@ struct ResumeAction { // send a signal to the thread when the action is run or step. class ResumeActionList { public: - ResumeActionList() : m_actions(), m_signal_handled() {} + ResumeActionList() {} - ResumeActionList(lldb::StateType default_action, int signal) - : m_actions(), m_signal_handled() { + ResumeActionList(lldb::StateType default_action, int signal) { SetDefaultThreadActionIfNeeded(default_action, signal); } - ResumeActionList(const ResumeAction *actions, size_t num_actions) - : m_actions(), m_signal_handled() { + ResumeActionList(const ResumeAction *actions, size_t num_actions) { if (actions && num_actions) { m_actions.assign(actions, actions + num_actions); m_signal_handled.assign(num_actions, false); diff --git a/lldb/include/lldb/Host/FileSystem.h b/lldb/include/lldb/Host/FileSystem.h index 54f7ac5ddb58..9f863e8a9d7e 100644 --- a/lldb/include/lldb/Host/FileSystem.h +++ b/lldb/include/lldb/Host/FileSystem.h @@ -31,16 +31,13 @@ public: static const char *DEV_NULL; static const char *PATH_CONVERSION_ERROR; - FileSystem() - : m_fs(llvm::vfs::getRealFileSystem()), m_collector(nullptr), - m_home_directory() {} + FileSystem() : m_fs(llvm::vfs::getRealFileSystem()), m_collector(nullptr) {} FileSystem(std::shared_ptr<llvm::FileCollectorBase> collector) : m_fs(llvm::vfs::getRealFileSystem()), m_collector(std::move(collector)), - m_home_directory(), m_mapped(false) {} + m_mapped(false) {} FileSystem(llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem> fs, bool mapped = false) - : m_fs(std::move(fs)), m_collector(nullptr), m_home_directory(), - m_mapped(mapped) {} + : m_fs(std::move(fs)), m_collector(nullptr), m_mapped(mapped) {} FileSystem(const FileSystem &fs) = delete; FileSystem &operator=(const FileSystem &fs) = delete; diff --git a/lldb/include/lldb/Host/HostNativeThreadBase.h b/lldb/include/lldb/Host/HostNativeThreadBase.h index bfd70d745593..1c581c279e1e 100644 --- a/lldb/include/lldb/Host/HostNativeThreadBase.h +++ b/lldb/include/lldb/Host/HostNativeThreadBase.h @@ -46,7 +46,7 @@ protected: ThreadCreateTrampoline(lldb::thread_arg_t arg); lldb::thread_t m_thread = LLDB_INVALID_HOST_THREAD; - lldb::thread_result_t m_result = 0; + lldb::thread_result_t m_result = 0; // NOLINT(modernize-use-nullptr) }; } diff --git a/lldb/include/lldb/Host/XML.h b/lldb/include/lldb/Host/XML.h index 9edf46bf09df..da0f9cd7aa8c 100644 --- a/lldb/include/lldb/Host/XML.h +++ b/lldb/include/lldb/Host/XML.h @@ -76,8 +76,8 @@ public: XMLNode GetChild() const; - llvm::StringRef GetAttributeValue(const char *name, - const char *fail_value = nullptr) const; + std::string GetAttributeValue(const char *name, + const char *fail_value = nullptr) const; bool GetAttributeValueAsUnsigned(const char *name, uint64_t &value, uint64_t fail_value = 0, int base = 0) const; diff --git a/lldb/include/lldb/Host/common/NativeProcessProtocol.h b/lldb/include/lldb/Host/common/NativeProcessProtocol.h index 7c3458527616..c7494ba6b195 100644 --- a/lldb/include/lldb/Host/common/NativeProcessProtocol.h +++ b/lldb/include/lldb/Host/common/NativeProcessProtocol.h @@ -204,7 +204,7 @@ public: void SetCurrentThreadID(lldb::tid_t tid) { m_current_thread_id = tid; } - lldb::tid_t GetCurrentThreadID() { return m_current_thread_id; } + lldb::tid_t GetCurrentThreadID() const { return m_current_thread_id; } NativeThreadProtocol *GetCurrentThread() { return GetThreadByID(m_current_thread_id); @@ -251,8 +251,9 @@ public: libraries_svr4 = (1u << 5), memory_tagging = (1u << 6), savecore = (1u << 7), + siginfo_read = (1u << 8), - LLVM_MARK_AS_BITMASK_ENUM(savecore) + LLVM_MARK_AS_BITMASK_ENUM(siginfo_read) }; class Factory { diff --git a/lldb/include/lldb/Host/common/NativeThreadProtocol.h b/lldb/include/lldb/Host/common/NativeThreadProtocol.h index 5cf26bd95939..35ccc48d62d8 100644 --- a/lldb/include/lldb/Host/common/NativeThreadProtocol.h +++ b/lldb/include/lldb/Host/common/NativeThreadProtocol.h @@ -12,9 +12,13 @@ #include <memory> #include "lldb/Host/Debug.h" +#include "lldb/Utility/UnimplementedError.h" #include "lldb/lldb-private-forward.h" #include "lldb/lldb-types.h" +#include "llvm/Support/Error.h" +#include "llvm/Support/MemoryBuffer.h" + namespace lldb_private { // NativeThreadProtocol class NativeThreadProtocol { @@ -47,6 +51,11 @@ public: virtual Status RemoveHardwareBreakpoint(lldb::addr_t addr) = 0; + virtual llvm::Expected<std::unique_ptr<llvm::MemoryBuffer>> + GetSiginfo() const { + return llvm::make_error<UnimplementedError>(); + } + protected: NativeProcessProtocol &m_process; lldb::tid_t m_tid; diff --git a/lldb/include/lldb/Interpreter/CommandInterpreter.h b/lldb/include/lldb/Interpreter/CommandInterpreter.h index e6f0d5f9c4d4..3efb59fc0564 100644 --- a/lldb/include/lldb/Interpreter/CommandInterpreter.h +++ b/lldb/include/lldb/Interpreter/CommandInterpreter.h @@ -649,7 +649,7 @@ private: void FindCommandsForApropos(llvm::StringRef word, StringList &commands_found, StringList &commands_help, - CommandObject::CommandMap &command_map); + const CommandObject::CommandMap &command_map); // An interruptible wrapper around the stream output void PrintCommandOutput(Stream &stream, llvm::StringRef str); diff --git a/lldb/include/lldb/Interpreter/CommandObject.h b/lldb/include/lldb/Interpreter/CommandObject.h index 89cc161993a9..bfddf559e5fe 100644 --- a/lldb/include/lldb/Interpreter/CommandObject.h +++ b/lldb/include/lldb/Interpreter/CommandObject.h @@ -172,11 +172,6 @@ public: return nullptr; } - virtual void AproposAllSubCommands(llvm::StringRef prefix, - llvm::StringRef search_word, - StringList &commands_found, - StringList &commands_help) {} - void FormatLongHelpText(Stream &output_strm, llvm::StringRef long_help); void GenerateHelpText(CommandReturnObject &result); diff --git a/lldb/include/lldb/Interpreter/CommandObjectMultiword.h b/lldb/include/lldb/Interpreter/CommandObjectMultiword.h index a0e8d163c4b6..ab580c11eb4f 100644 --- a/lldb/include/lldb/Interpreter/CommandObjectMultiword.h +++ b/lldb/include/lldb/Interpreter/CommandObjectMultiword.h @@ -51,11 +51,6 @@ public: CommandObject *GetSubcommandObject(llvm::StringRef sub_cmd, StringList *matches = nullptr) override; - void AproposAllSubCommands(llvm::StringRef prefix, - llvm::StringRef search_word, - StringList &commands_found, - StringList &commands_help) override; - bool WantsRawCommandString() override { return false; } void HandleCompletion(CompletionRequest &request) override; @@ -110,11 +105,6 @@ public: CommandObject *GetSubcommandObject(llvm::StringRef sub_cmd, StringList *matches = nullptr) override; - void AproposAllSubCommands(llvm::StringRef prefix, - llvm::StringRef search_word, - StringList &commands_found, - StringList &commands_help) override; - bool LoadSubCommand(llvm::StringRef cmd_name, const lldb::CommandObjectSP &command_obj) override; diff --git a/lldb/include/lldb/Interpreter/OptionValueArray.h b/lldb/include/lldb/Interpreter/OptionValueArray.h index 011eefc34251..af43887635e9 100644 --- a/lldb/include/lldb/Interpreter/OptionValueArray.h +++ b/lldb/include/lldb/Interpreter/OptionValueArray.h @@ -18,7 +18,7 @@ namespace lldb_private { class OptionValueArray : public Cloneable<OptionValueArray, OptionValue> { public: OptionValueArray(uint32_t type_mask = UINT32_MAX, bool raw_value_dump = false) - : m_type_mask(type_mask), m_values(), m_raw_value_dump(raw_value_dump) {} + : m_type_mask(type_mask), m_raw_value_dump(raw_value_dump) {} ~OptionValueArray() override = default; diff --git a/lldb/include/lldb/Interpreter/OptionValueProperties.h b/lldb/include/lldb/Interpreter/OptionValueProperties.h index 6fa5403ac142..3e5685b7f0bf 100644 --- a/lldb/include/lldb/Interpreter/OptionValueProperties.h +++ b/lldb/include/lldb/Interpreter/OptionValueProperties.h @@ -114,6 +114,9 @@ public: GetPropertyAtIndexAsOptionValueLanguage(const ExecutionContext *exe_ctx, uint32_t idx) const; + bool SetPropertyAtIndexAsLanguage(const ExecutionContext *exe_ctx, + uint32_t idx, lldb::LanguageType lang); + bool GetPropertyAtIndexAsArgs(const ExecutionContext *exe_ctx, uint32_t idx, Args &args) const; diff --git a/lldb/include/lldb/Interpreter/Options.h b/lldb/include/lldb/Interpreter/Options.h index 6bf5c21fe98e..5899a9edc47f 100644 --- a/lldb/include/lldb/Interpreter/Options.h +++ b/lldb/include/lldb/Interpreter/Options.h @@ -169,7 +169,7 @@ public: /// user wants returned. /// /// \return - /// \btrue if we were in an option, \bfalse otherwise. + /// \b true if we were in an option, \b false otherwise. bool HandleOptionCompletion(lldb_private::CompletionRequest &request, OptionElementVector &option_map, CommandInterpreter &interpreter); diff --git a/lldb/include/lldb/Interpreter/ScriptedInterface.h b/lldb/include/lldb/Interpreter/ScriptedInterface.h index 427fa3f4f793..9de5e60cfea3 100644 --- a/lldb/include/lldb/Interpreter/ScriptedInterface.h +++ b/lldb/include/lldb/Interpreter/ScriptedInterface.h @@ -27,12 +27,13 @@ public: virtual StructuredData::GenericSP CreatePluginObject(llvm::StringRef class_name, ExecutionContext &exe_ctx, - StructuredData::DictionarySP args_sp) = 0; + StructuredData::DictionarySP args_sp, + StructuredData::Generic *script_obj = nullptr) = 0; template <typename Ret> - Ret ErrorWithMessage(llvm::StringRef caller_name, llvm::StringRef error_msg, - Status &error, - uint32_t log_caterogy = LIBLLDB_LOG_PROCESS) { + static Ret ErrorWithMessage(llvm::StringRef caller_name, + llvm::StringRef error_msg, Status &error, + LLDBLog log_caterogy = LLDBLog::Process) { LLDB_LOGF(GetLogIfAllCategoriesSet(log_caterogy), "%s ERROR = %s", caller_name.data(), error_msg.data()); error.SetErrorString(llvm::Twine(caller_name + llvm::Twine(" ERROR = ") + diff --git a/lldb/include/lldb/Interpreter/ScriptedProcessInterface.h b/lldb/include/lldb/Interpreter/ScriptedProcessInterface.h index 26fd956f96bb..0712b3bf4a3e 100644 --- a/lldb/include/lldb/Interpreter/ScriptedProcessInterface.h +++ b/lldb/include/lldb/Interpreter/ScriptedProcessInterface.h @@ -23,7 +23,8 @@ class ScriptedProcessInterface : virtual public ScriptedInterface { public: StructuredData::GenericSP CreatePluginObject(llvm::StringRef class_name, ExecutionContext &exe_ctx, - StructuredData::DictionarySP args_sp) override { + StructuredData::DictionarySP args_sp, + StructuredData::Generic *script_obj = nullptr) override { return nullptr; } @@ -41,6 +42,8 @@ public: return {}; } + virtual StructuredData::DictionarySP GetThreadsInfo() { return nullptr; } + virtual StructuredData::DictionarySP GetThreadWithID(lldb::tid_t tid) { return nullptr; } @@ -66,18 +69,17 @@ public: protected: friend class ScriptedThread; - virtual lldb::ScriptedThreadInterfaceSP GetScriptedThreadInterface() { + virtual lldb::ScriptedThreadInterfaceSP CreateScriptedThreadInterface() { return nullptr; } - - lldb::ScriptedThreadInterfaceSP m_scripted_thread_interface_sp = nullptr; }; class ScriptedThreadInterface : virtual public ScriptedInterface { public: StructuredData::GenericSP CreatePluginObject(llvm::StringRef class_name, ExecutionContext &exe_ctx, - StructuredData::DictionarySP args_sp) override { + StructuredData::DictionarySP args_sp, + StructuredData::Generic *script_obj = nullptr) override { return nullptr; } diff --git a/lldb/include/lldb/Symbol/CompactUnwindInfo.h b/lldb/include/lldb/Symbol/CompactUnwindInfo.h index ceb501e1c05f..402155cbe08d 100644 --- a/lldb/include/lldb/Symbol/CompactUnwindInfo.h +++ b/lldb/include/lldb/Symbol/CompactUnwindInfo.h @@ -86,7 +86,7 @@ private: // valid for (start of the function) uint32_t valid_range_offset_end = 0; // the offset of the start of the next function - FunctionInfo() : lsda_address(), personality_ptr_address() {} + FunctionInfo() {} }; struct UnwindHeader { diff --git a/lldb/include/lldb/Symbol/CompileUnit.h b/lldb/include/lldb/Symbol/CompileUnit.h index 34e34e5514df..44e1d673f1fd 100644 --- a/lldb/include/lldb/Symbol/CompileUnit.h +++ b/lldb/include/lldb/Symbol/CompileUnit.h @@ -208,9 +208,9 @@ public: /// unit file. /// /// \param[in] exact - /// If \btrue match only if there is a line table entry for this line + /// If \b true match only if there is a line table entry for this line /// number. - /// If \bfalse, find the line table entry equal to or after this line + /// If \b false, find the line table entry equal to or after this line /// number. /// /// \param[out] line_entry diff --git a/lldb/include/lldb/Symbol/DWARFCallFrameInfo.h b/lldb/include/lldb/Symbol/DWARFCallFrameInfo.h index f85bc7e844a0..43baf4dd39a1 100644 --- a/lldb/include/lldb/Symbol/DWARFCallFrameInfo.h +++ b/lldb/include/lldb/Symbol/DWARFCallFrameInfo.h @@ -107,7 +107,7 @@ private: : cie_offset(offset), version(-1), code_align(0), data_align(0), return_addr_reg_num(LLDB_INVALID_REGNUM), inst_offset(0), inst_length(0), ptr_encoding(0), lsda_addr_encoding(DW_EH_PE_omit), - personality_loc(LLDB_INVALID_ADDRESS), initial_row() {} + personality_loc(LLDB_INVALID_ADDRESS) {} }; typedef std::shared_ptr<CIE> CIESP; diff --git a/lldb/include/lldb/Symbol/Function.h b/lldb/include/lldb/Symbol/Function.h index b703617773ff..83f9979c3c52 100644 --- a/lldb/include/lldb/Symbol/Function.h +++ b/lldb/include/lldb/Symbol/Function.h @@ -110,8 +110,6 @@ public: /// The number of bytes that this object occupies in memory. /// The returned value does not include the bytes for any /// shared string values. - /// - /// \see ConstString::StaticMemorySize () virtual size_t MemorySize() const; protected: @@ -238,8 +236,6 @@ public: /// The number of bytes that this object occupies in memory. /// The returned value does not include the bytes for any /// shared string values. - /// - /// \see ConstString::StaticMemorySize () size_t MemorySize() const override; private: @@ -595,8 +591,6 @@ public: /// The number of bytes that this object occupies in memory. /// The returned value does not include the bytes for any /// shared string values. - /// - /// \see ConstString::StaticMemorySize () size_t MemorySize() const; /// Get whether compiler optimizations were enabled for this function diff --git a/lldb/include/lldb/Symbol/LineTable.h b/lldb/include/lldb/Symbol/LineTable.h index 5cd22bd831ee..b5121b29fe02 100644 --- a/lldb/include/lldb/Symbol/LineTable.h +++ b/lldb/include/lldb/Symbol/LineTable.h @@ -206,7 +206,6 @@ public: LineTable *LinkLineTable(const FileRangeMap &file_range_map); -protected: struct Entry { Entry() : line(0), is_start_of_statement(false), is_start_of_basic_block(false), @@ -303,6 +302,7 @@ protected: uint16_t file_idx = 0; }; +protected: struct EntrySearchInfo { LineTable *line_table; lldb_private::Section *a_section; diff --git a/lldb/include/lldb/Symbol/ObjectContainer.h b/lldb/include/lldb/Symbol/ObjectContainer.h index 1e01e93da9d2..4f0c73693295 100644 --- a/lldb/include/lldb/Symbol/ObjectContainer.h +++ b/lldb/include/lldb/Symbol/ObjectContainer.h @@ -39,7 +39,7 @@ public: lldb::DataBufferSP &data_sp, lldb::offset_t data_offset) : ModuleChild(module_sp), m_file(), // This file can be different than the module's file spec - m_offset(file_offset), m_length(length), m_data() { + m_offset(file_offset), m_length(length) { if (file) m_file = *file; if (data_sp) diff --git a/lldb/include/lldb/Symbol/SymbolFile.h b/lldb/include/lldb/Symbol/SymbolFile.h index 7c0365483c12..6cdb2bfb686b 100644 --- a/lldb/include/lldb/Symbol/SymbolFile.h +++ b/lldb/include/lldb/Symbol/SymbolFile.h @@ -67,8 +67,7 @@ public: // Constructors and Destructors SymbolFile(lldb::ObjectFileSP objfile_sp) - : m_objfile_sp(std::move(objfile_sp)), m_abilities(0), - m_calculated_abilities(false) {} + : m_objfile_sp(std::move(objfile_sp)) {} ~SymbolFile() override = default; @@ -317,14 +316,37 @@ public: /// /// \returns 0.0 if no information has been parsed or if there is /// no computational cost to parsing the debug information. - virtual StatsDuration GetDebugInfoParseTime() { return StatsDuration(0.0); } + virtual StatsDuration::Duration GetDebugInfoParseTime() { return {}; } /// Return the time it took to index the debug information in the object /// file. /// /// \returns 0.0 if the file doesn't need to be indexed or if it /// hasn't been indexed yet, or a valid duration if it has. - virtual StatsDuration GetDebugInfoIndexTime() { return StatsDuration(0.0); } + virtual StatsDuration::Duration GetDebugInfoIndexTime() { return {}; } + + /// Accessors for the bool that indicates if the debug info index was loaded + /// from, or saved to the module index cache. + /// + /// In statistics it is handy to know if a module's debug info was loaded from + /// or saved to the cache. When the debug info index is loaded from the cache + /// startup times can be faster. When the cache is enabled and the debug info + /// index is saved to the cache, debug sessions can be slower. These accessors + /// can be accessed by the statistics and emitted to help track these costs. + /// \{ + bool GetDebugInfoIndexWasLoadedFromCache() const { + return m_index_was_loaded_from_cache; + } + void SetDebugInfoIndexWasLoadedFromCache() { + m_index_was_loaded_from_cache = true; + } + bool GetDebugInfoIndexWasSavedToCache() const { + return m_index_was_saved_to_cache; + } + void SetDebugInfoIndexWasSavedToCache() { + m_index_was_saved_to_cache = true; + } + /// \} protected: void AssertModuleLock(); @@ -341,8 +363,10 @@ protected: llvm::Optional<std::vector<lldb::CompUnitSP>> m_compile_units; TypeList m_type_list; Symtab *m_symtab = nullptr; - uint32_t m_abilities; - bool m_calculated_abilities; + uint32_t m_abilities = 0; + bool m_calculated_abilities = false; + bool m_index_was_loaded_from_cache = false; + bool m_index_was_saved_to_cache = false; private: SymbolFile(const SymbolFile &) = delete; diff --git a/lldb/include/lldb/Symbol/Symtab.h b/lldb/include/lldb/Symbol/Symtab.h index fe0a82306c4f..504b49c02674 100644 --- a/lldb/include/lldb/Symbol/Symtab.h +++ b/lldb/include/lldb/Symbol/Symtab.h @@ -212,6 +212,30 @@ public: /// false if the symbol table wasn't cached or was out of date. bool LoadFromCache(); + + /// Accessors for the bool that indicates if the debug info index was loaded + /// from, or saved to the module index cache. + /// + /// In statistics it is handy to know if a module's debug info was loaded from + /// or saved to the cache. When the debug info index is loaded from the cache + /// startup times can be faster. When the cache is enabled and the debug info + /// index is saved to the cache, debug sessions can be slower. These accessors + /// can be accessed by the statistics and emitted to help track these costs. + /// \{ + bool GetWasLoadedFromCache() const { + return m_loaded_from_cache; + } + void SetWasLoadedFromCache() { + m_loaded_from_cache = true; + } + bool GetWasSavedToCache() const { + return m_saved_to_cache; + } + void SetWasSavedToCache() { + m_saved_to_cache = true; + } + /// \} + protected: typedef std::vector<Symbol> collection; typedef collection::iterator iterator; @@ -252,7 +276,8 @@ protected: m_name_to_symbol_indices; mutable std::recursive_mutex m_mutex; // Provide thread safety for this symbol table - bool m_file_addr_to_index_computed : 1, m_name_indexes_computed : 1; + bool m_file_addr_to_index_computed : 1, m_name_indexes_computed : 1, + m_loaded_from_cache : 1, m_saved_to_cache : 1; private: UniqueCStringMap<uint32_t> & diff --git a/lldb/include/lldb/Symbol/Type.h b/lldb/include/lldb/Symbol/Type.h index 7754e0299096..24b94921df94 100644 --- a/lldb/include/lldb/Symbol/Type.h +++ b/lldb/include/lldb/Symbol/Type.h @@ -314,7 +314,7 @@ private: class TypeListImpl { public: - TypeListImpl() : m_content() {} + TypeListImpl() {} void Append(const lldb::TypeImplSP &type) { m_content.push_back(type); } @@ -345,10 +345,7 @@ private: class TypeMemberImpl { public: - TypeMemberImpl() - : m_type_impl_sp(), m_name() - - {} + TypeMemberImpl() {} TypeMemberImpl(const lldb::TypeImplSP &type_impl_sp, uint64_t bit_offset, ConstString name, uint32_t bitfield_bit_size = 0, @@ -357,7 +354,7 @@ public: m_bitfield_bit_size(bitfield_bit_size), m_is_bitfield(is_bitfield) {} TypeMemberImpl(const lldb::TypeImplSP &type_impl_sp, uint64_t bit_offset) - : m_type_impl_sp(type_impl_sp), m_bit_offset(bit_offset), m_name(), + : m_type_impl_sp(type_impl_sp), m_bit_offset(bit_offset), m_bitfield_bit_size(0), m_is_bitfield(false) { if (m_type_impl_sp) m_name = m_type_impl_sp->GetName(); @@ -440,7 +437,7 @@ private: class TypeMemberFunctionImpl { public: - TypeMemberFunctionImpl() : m_type(), m_decl(), m_name() {} + TypeMemberFunctionImpl() {} TypeMemberFunctionImpl(const CompilerType &type, const CompilerDecl &decl, const std::string &name, @@ -477,7 +474,7 @@ private: class TypeEnumMemberImpl { public: - TypeEnumMemberImpl() : m_integer_type_sp(), m_name("<invalid>"), m_value() {} + TypeEnumMemberImpl() : m_name("<invalid>") {} TypeEnumMemberImpl(const lldb::TypeImplSP &integer_type_sp, ConstString name, const llvm::APSInt &value); @@ -505,7 +502,7 @@ protected: class TypeEnumMemberListImpl { public: - TypeEnumMemberListImpl() : m_content() {} + TypeEnumMemberListImpl() {} void Append(const lldb::TypeEnumMemberImplSP &type) { m_content.push_back(type); diff --git a/lldb/include/lldb/Symbol/UnwindPlan.h b/lldb/include/lldb/Symbol/UnwindPlan.h index cc2302d25831..ebb0ec421da7 100644 --- a/lldb/include/lldb/Symbol/UnwindPlan.h +++ b/lldb/include/lldb/Symbol/UnwindPlan.h @@ -395,12 +395,10 @@ public: typedef std::shared_ptr<Row> RowSP; UnwindPlan(lldb::RegisterKind reg_kind) - : m_row_list(), m_plan_valid_address_range(), m_register_kind(reg_kind), - m_return_addr_register(LLDB_INVALID_REGNUM), m_source_name(), + : m_register_kind(reg_kind), m_return_addr_register(LLDB_INVALID_REGNUM), m_plan_is_sourced_from_compiler(eLazyBoolCalculate), m_plan_is_valid_at_all_instruction_locations(eLazyBoolCalculate), - m_plan_is_for_signal_trap(eLazyBoolCalculate), - m_lsda_address(), m_personality_func_addr() {} + m_plan_is_for_signal_trap(eLazyBoolCalculate) {} // Performs a deep copy of the plan, including all the rows (expensive). UnwindPlan(const UnwindPlan &rhs) @@ -442,7 +440,7 @@ public: m_return_addr_register = regnum; } - uint32_t GetReturnAddressRegister(void) { return m_return_addr_register; } + uint32_t GetReturnAddressRegister() { return m_return_addr_register; } uint32_t GetInitialCFARegister() const { if (m_row_list.empty()) diff --git a/lldb/include/lldb/Target/InstrumentationRuntime.h b/lldb/include/lldb/Target/InstrumentationRuntime.h index eeec91f36af4..a6121c24b956 100644 --- a/lldb/include/lldb/Target/InstrumentationRuntime.h +++ b/lldb/include/lldb/Target/InstrumentationRuntime.h @@ -42,8 +42,7 @@ class InstrumentationRuntime protected: InstrumentationRuntime(const lldb::ProcessSP &process_sp) - : m_process_wp(), m_runtime_module(), m_breakpoint_id(0), - m_is_active(false) { + : m_breakpoint_id(0), m_is_active(false) { if (process_sp) m_process_wp = process_sp; } diff --git a/lldb/include/lldb/Target/Language.h b/lldb/include/lldb/Target/Language.h index 0b0891c14029..ce2d273a8277 100644 --- a/lldb/include/lldb/Target/Language.h +++ b/lldb/include/lldb/Target/Language.h @@ -57,8 +57,7 @@ public: class ImageListTypeScavenger : public TypeScavenger { class Result : public Language::TypeScavenger::Result { public: - Result(CompilerType type) - : Language::TypeScavenger::Result(), m_compiler_type(type) {} + Result(CompilerType type) : m_compiler_type(type) {} bool IsValid() override { return m_compiler_type.IsValid(); } @@ -95,7 +94,7 @@ public: template <typename... ScavengerTypes> class EitherTypeScavenger : public TypeScavenger { public: - EitherTypeScavenger() : TypeScavenger(), m_scavengers() { + EitherTypeScavenger() : TypeScavenger() { for (std::shared_ptr<TypeScavenger> scavenger : { std::shared_ptr<TypeScavenger>(new ScavengerTypes())... }) { if (scavenger) m_scavengers.push_back(scavenger); @@ -118,7 +117,7 @@ public: template <typename... ScavengerTypes> class UnionTypeScavenger : public TypeScavenger { public: - UnionTypeScavenger() : TypeScavenger(), m_scavengers() { + UnionTypeScavenger() : TypeScavenger() { for (std::shared_ptr<TypeScavenger> scavenger : { std::shared_ptr<TypeScavenger>(new ScavengerTypes())... }) { if (scavenger) m_scavengers.push_back(scavenger); diff --git a/lldb/include/lldb/Target/MemoryTagManager.h b/lldb/include/lldb/Target/MemoryTagManager.h index a5e0deba14a9..859c43cb437a 100644 --- a/lldb/include/lldb/Target/MemoryTagManager.h +++ b/lldb/include/lldb/Target/MemoryTagManager.h @@ -35,8 +35,8 @@ public: // you get will have been shifted down 56 before being returned. virtual lldb::addr_t GetLogicalTag(lldb::addr_t addr) const = 0; - // Remove non address bits from a pointer - virtual lldb::addr_t RemoveNonAddressBits(lldb::addr_t addr) const = 0; + // Remove tag bits from a pointer + virtual lldb::addr_t RemoveTagBits(lldb::addr_t addr) const = 0; // Return the difference between two addresses, ignoring any logical tags they // have. If your tags are just part of a larger set of ignored bits, this @@ -64,7 +64,7 @@ public: // (which may include one or more memory regions) // // If so, return a modified range which will have been expanded - // to be granule aligned. + // to be granule aligned. Otherwise return an error. // // Tags in the input addresses are ignored and not present // in the returned range. @@ -72,6 +72,23 @@ public: lldb::addr_t addr, lldb::addr_t end_addr, const lldb_private::MemoryRegionInfos &memory_regions) const = 0; + // Given a range addr to end_addr, check that end_addr >= addr. + // If it is not, return an error saying so. + // Otherwise, granule align it and return a set of ranges representing + // subsections of the aligned range that have memory tagging enabled. + // + // Basically a sparse version of MakeTaggedRange. Use this when you + // want to know which parts of a larger range have memory tagging. + // + // Regions in memory_regions should be sorted in ascending order and + // not overlap. (use Process GetMemoryRegions) + // + // Tags in the input addresses are ignored and not present + // in the returned ranges. + virtual llvm::Expected<std::vector<TagRange>> MakeTaggedRanges( + lldb::addr_t addr, lldb::addr_t end_addr, + const lldb_private::MemoryRegionInfos &memory_regions) const = 0; + // Return the type value to use in GDB protocol qMemTags packets to read // allocation tags. This is named "Allocation" specifically because the spec // allows for logical tags to be read the same way, though we do not use that. diff --git a/lldb/include/lldb/Target/MemoryTagMap.h b/lldb/include/lldb/Target/MemoryTagMap.h new file mode 100644 index 000000000000..acf3825bfb3f --- /dev/null +++ b/lldb/include/lldb/Target/MemoryTagMap.h @@ -0,0 +1,98 @@ +//===-- MemoryTagMap.h ------------------------------------------*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef LLDB_TARGET_MEMORYTAGMAP_H +#define LLDB_TARGET_MEMORYTAGMAP_H + +#include "lldb/Target/MemoryTagManager.h" +#include "lldb/lldb-private.h" +#include "llvm/ADT/Optional.h" +#include <map> + +namespace lldb_private { + +/// MemoryTagMap provides a way to give a sparse read result +/// when reading memory tags for a range. This is useful when +/// you want to annotate some large memory dump that might include +/// tagged memory but you don't know that it is all tagged. +class MemoryTagMap { +public: + /// Init an empty tag map + /// + /// \param [in] manager + /// Non-null pointer to a memory tag manager. + MemoryTagMap(const MemoryTagManager *manager); + + /// Insert tags into the map starting from addr. + /// + /// \param [in] addr + /// Start address of the range to insert tags for. + /// This address should be granule aligned and have had + /// any non address bits removed. + /// (ideally you would use the base of the range you used + /// to read the tags in the first place) + /// + /// \param [in] tags + /// Vector of tags to insert. The first tag will be inserted + /// at addr, the next at addr+granule size and so on until + /// all tags have been inserted. + void InsertTags(lldb::addr_t addr, const std::vector<lldb::addr_t> tags); + + bool Empty() const; + + /// Lookup memory tags for a range of memory from addr to addr+len. + /// + /// \param [in] addr + /// The start of the range. This may include non address bits and + /// does not have to be granule aligned. + /// + /// \param [in] len + /// The length in bytes of the range to read tags for. This does + /// not need to be multiple of the granule size. + /// + /// \return + /// A vector containing the tags found for the granules in the + /// range. (which is the result of granule aligning the given range) + /// + /// Each item in the vector is an optional tag. Meaning that if + /// it is valid then the granule had a tag and if not, it didn't. + /// + /// If the range had no tags at all, the vector will be empty. + /// If some of the range was tagged it will have items and some + /// of them may be llvm::None. + /// (this saves the caller checking whether all items are llvm::None) + std::vector<llvm::Optional<lldb::addr_t>> GetTags(lldb::addr_t addr, + size_t len) const; + +private: + /// Lookup the tag for address + /// + /// \param [in] address + /// The address to lookup a tag for. This should be aligned + /// to a granule boundary. + /// + /// \return + /// The tag for the granule that address refers to, or llvm::None + /// if it has no memory tag. + llvm::Optional<lldb::addr_t> GetTag(lldb::addr_t addr) const; + + // A map of granule aligned addresses to their memory tag + std::map<lldb::addr_t, lldb::addr_t> m_addr_to_tag; + + // Memory tag manager used to align addresses and get granule size. + // Ideally this would be a const& but only certain architectures will + // have a memory tag manager class to provide here. So for a method + // returning a MemoryTagMap, Optional<MemoryTagMap> allows it to handle + // architectures without memory tagging. Optionals cannot hold references + // so we go with a pointer that we assume will be not be null. + const MemoryTagManager *m_manager; +}; + +} // namespace lldb_private + +#endif // LLDB_TARGET_MEMORYTAGMAP_H diff --git a/lldb/include/lldb/Target/Platform.h b/lldb/include/lldb/Target/Platform.h index 26127359a322..4ef6c9d82b1a 100644 --- a/lldb/include/lldb/Target/Platform.h +++ b/lldb/include/lldb/Target/Platform.h @@ -863,6 +863,8 @@ public: return nullptr; } + virtual CompilerType GetSiginfoType(const llvm::Triple &triple); + protected: /// Create a list of ArchSpecs with the given OS and a architectures. The /// vendor field is left as an "unspecified unknown". @@ -958,7 +960,7 @@ private: class PlatformList { public: - PlatformList() : m_mutex(), m_platforms(), m_selected_platform_sp() {} + PlatformList() {} ~PlatformList() = default; diff --git a/lldb/include/lldb/Target/Process.h b/lldb/include/lldb/Target/Process.h index e27cb8cbf2aa..12ed1e09227c 100644 --- a/lldb/include/lldb/Target/Process.h +++ b/lldb/include/lldb/Target/Process.h @@ -112,15 +112,12 @@ protected: class ProcessAttachInfo : public ProcessInstanceInfo { public: - ProcessAttachInfo() - : ProcessInstanceInfo(), m_listener_sp(), m_hijack_listener_sp(), - m_plugin_name() {} + ProcessAttachInfo() {} ProcessAttachInfo(const ProcessLaunchInfo &launch_info) - : ProcessInstanceInfo(), m_listener_sp(), m_hijack_listener_sp(), - m_plugin_name(), m_resume_count(0), m_wait_for_launch(false), - m_ignore_existing(true), m_continue_once_attached(false), - m_detach_on_error(true), m_async(false) { + : m_resume_count(0), m_wait_for_launch(false), m_ignore_existing(true), + m_continue_once_attached(false), m_detach_on_error(true), + m_async(false) { ProcessInfo::operator=(launch_info); SetProcessPluginName(launch_info.GetProcessPluginName()); SetResumeCount(launch_info.GetResumeCount()); @@ -1887,7 +1884,7 @@ public: /// want to deallocate. /// /// \return - /// \btrue if the memory was deallocated, \bfalse otherwise. + /// \b true if the memory was deallocated, \b false otherwise. virtual Status DoDeallocateMemory(lldb::addr_t ptr) { Status error; error.SetErrorStringWithFormatv( @@ -1906,7 +1903,7 @@ public: /// want to deallocate. /// /// \return - /// \btrue if the memory was deallocated, \bfalse otherwise. + /// \b true if the memory was deallocated, \b false otherwise. Status DeallocateMemory(lldb::addr_t ptr); /// Get any available STDOUT. diff --git a/lldb/include/lldb/Target/RegisterCheckpoint.h b/lldb/include/lldb/Target/RegisterCheckpoint.h index daf20db999b3..8681fb962801 100644 --- a/lldb/include/lldb/Target/RegisterCheckpoint.h +++ b/lldb/include/lldb/Target/RegisterCheckpoint.h @@ -31,8 +31,7 @@ public: eDataBackup }; - RegisterCheckpoint(Reason reason) - : UserID(0), m_data_sp(), m_reason(reason) {} + RegisterCheckpoint(Reason reason) : UserID(0), m_reason(reason) {} ~RegisterCheckpoint() = default; diff --git a/lldb/include/lldb/Target/SectionLoadHistory.h b/lldb/include/lldb/Target/SectionLoadHistory.h index dd024301d0cf..0240cebda85f 100644 --- a/lldb/include/lldb/Target/SectionLoadHistory.h +++ b/lldb/include/lldb/Target/SectionLoadHistory.h @@ -24,7 +24,7 @@ public: eStopIDNow = UINT32_MAX }; // Constructors and Destructors - SectionLoadHistory() : m_stop_id_to_section_load_list(), m_mutex() {} + SectionLoadHistory() {} ~SectionLoadHistory() { // Call clear since this takes a lock and clears the section load list in diff --git a/lldb/include/lldb/Target/SectionLoadList.h b/lldb/include/lldb/Target/SectionLoadList.h index e8535e7ac51a..548d44a181a7 100644 --- a/lldb/include/lldb/Target/SectionLoadList.h +++ b/lldb/include/lldb/Target/SectionLoadList.h @@ -22,7 +22,7 @@ namespace lldb_private { class SectionLoadList { public: // Constructors and Destructors - SectionLoadList() : m_addr_to_sect(), m_sect_to_addr(), m_mutex() {} + SectionLoadList() {} SectionLoadList(const SectionLoadList &rhs); diff --git a/lldb/include/lldb/Target/StackFrame.h b/lldb/include/lldb/Target/StackFrame.h index 1a9aaad1a4db..1b0485b22cac 100644 --- a/lldb/include/lldb/Target/StackFrame.h +++ b/lldb/include/lldb/Target/StackFrame.h @@ -171,7 +171,7 @@ public: /// functions looking up symbolic information for a given pc value multiple /// times. /// - /// \params [in] resolve_scope + /// \param [in] resolve_scope /// Flags from the SymbolContextItem enumerated type which specify what /// type of symbol context is needed by this caller. /// @@ -408,10 +408,10 @@ public: /// Create a ValueObject for a given Variable in this StackFrame. /// - /// \params [in] variable_sp + /// \param [in] variable_sp /// The Variable to base this ValueObject on /// - /// \params [in] use_dynamic + /// \param [in] use_dynamic /// Whether the correct dynamic type of the variable should be /// determined before creating the ValueObject, or if the static type /// is sufficient. One of the DynamicValueType enumerated values. @@ -437,7 +437,7 @@ public: /// the current instruction. The ExpressionPath should indicate how to get /// to this value using "frame variable." /// - /// \params [in] addr + /// \param [in] addr /// The raw address. /// /// \return @@ -448,10 +448,10 @@ public: /// given register plus an offset. The ExpressionPath should indicate how /// to get to this value using "frame variable." /// - /// \params [in] reg + /// \param [in] reg /// The name of the register. /// - /// \params [in] offset + /// \param [in] offset /// The offset from the register. Particularly important for sp... /// /// \return @@ -465,7 +465,7 @@ public: /// PC in the stack frame and traverse through all parent blocks stopping at /// inlined function boundaries. /// - /// \params [in] name + /// \param [in] name /// The name of the variable. /// /// \return diff --git a/lldb/include/lldb/Target/Statistics.h b/lldb/include/lldb/Target/Statistics.h index 087fbee26328..d2b8f746a38c 100644 --- a/lldb/include/lldb/Target/Statistics.h +++ b/lldb/include/lldb/Target/Statistics.h @@ -9,20 +9,41 @@ #ifndef LLDB_TARGET_STATISTICS_H #define LLDB_TARGET_STATISTICS_H -#include <chrono> -#include <string> -#include <vector> - +#include "lldb/Utility/ConstString.h" #include "lldb/Utility/Stream.h" #include "lldb/lldb-forward.h" #include "llvm/Support/JSON.h" +#include <atomic> +#include <chrono> +#include <ratio> +#include <string> +#include <vector> namespace lldb_private { using StatsClock = std::chrono::high_resolution_clock; -using StatsDuration = std::chrono::duration<double>; using StatsTimepoint = std::chrono::time_point<StatsClock>; +class StatsDuration { +public: + using Duration = std::chrono::duration<double>; + + Duration get() const { + return Duration(InternalDuration(value.load(std::memory_order_relaxed))); + } + operator Duration() const { return get(); } + + StatsDuration &operator+=(Duration dur) { + value.fetch_add(std::chrono::duration_cast<InternalDuration>(dur).count(), + std::memory_order_relaxed); + return *this; + } + +private: + using InternalDuration = std::chrono::duration<uint64_t, std::micro>; + std::atomic<uint64_t> value{0}; +}; + /// A class that measures elapsed time in an exception safe way. /// /// This is a RAII class is designed to help gather timing statistics within @@ -54,7 +75,7 @@ public: m_start_time = StatsClock::now(); } ~ElapsedTime() { - StatsDuration elapsed = StatsClock::now() - m_start_time; + StatsClock::duration elapsed = StatsClock::now() - m_start_time; m_elapsed_time += elapsed; } }; @@ -84,6 +105,15 @@ struct ModuleStats { double debug_parse_time = 0.0; double debug_index_time = 0.0; uint64_t debug_info_size = 0; + bool symtab_loaded_from_cache = false; + bool symtab_saved_to_cache = false; + bool debug_info_index_loaded_from_cache = false; + bool debug_info_index_saved_to_cache = false; +}; + +struct ConstStringStats { + llvm::json::Value ToJSON() const; + ConstString::MemoryStats stats = ConstString::GetMemoryStats(); }; /// A class that represents statistics for a since lldb_private::Target. @@ -100,7 +130,7 @@ public: StatsSuccessFail &GetFrameVariableStats() { return m_frame_var; } protected: - StatsDuration m_create_time{0.0}; + StatsDuration m_create_time; llvm::Optional<StatsTimepoint> m_launch_or_attach_time; llvm::Optional<StatsTimepoint> m_first_private_stop_time; llvm::Optional<StatsTimepoint> m_first_public_stop_time; diff --git a/lldb/include/lldb/Target/Target.h b/lldb/include/lldb/Target/Target.h index b85839c15b2f..2c8b36d1e3d9 100644 --- a/lldb/include/lldb/Target/Target.h +++ b/lldb/include/lldb/Target/Target.h @@ -991,7 +991,7 @@ public: /// manually set following this function call). /// /// \return - /// \b true if the architecture was successfully set, \bfalse otherwise. + /// \b true if the architecture was successfully set, \b false otherwise. bool SetArchitecture(const ArchSpec &arch_spec, bool set_platform = false); bool MergeArchitecture(const ArchSpec &arch_spec); diff --git a/lldb/include/lldb/Target/Thread.h b/lldb/include/lldb/Target/Thread.h index 91feed310eb9..f1d4e6c7ef01 100644 --- a/lldb/include/lldb/Target/Thread.h +++ b/lldb/include/lldb/Target/Thread.h @@ -22,6 +22,7 @@ #include "lldb/Utility/CompletionRequest.h" #include "lldb/Utility/Event.h" #include "lldb/Utility/StructuredData.h" +#include "lldb/Utility/UnimplementedError.h" #include "lldb/Utility/UserID.h" #include "lldb/lldb-private.h" @@ -1184,6 +1185,11 @@ public: lldb::ThreadSP GetCurrentExceptionBacktrace(); + virtual llvm::Expected<std::unique_ptr<llvm::MemoryBuffer>> + GetSiginfo(size_t max_size) const { + return llvm::make_error<UnimplementedError>(); + } + protected: friend class ThreadPlan; friend class ThreadList; @@ -1244,7 +1250,7 @@ protected: // the stop info was checked against // the stop info override const uint32_t m_index_id; ///< A unique 1 based index assigned to each thread - ///for easy UI/command line access. + /// for easy UI/command line access. lldb::RegisterContextSP m_reg_context_sp; ///< The register context for this ///thread's current register state. lldb::StateType m_state; ///< The state of our process. diff --git a/lldb/include/lldb/Target/Unwind.h b/lldb/include/lldb/Target/Unwind.h index 3faef139b00a..105383ddae8a 100644 --- a/lldb/include/lldb/Target/Unwind.h +++ b/lldb/include/lldb/Target/Unwind.h @@ -18,7 +18,7 @@ namespace lldb_private { class Unwind { protected: // Classes that inherit from Unwind can see and modify these - Unwind(Thread &thread) : m_thread(thread), m_unwind_mutex() {} + Unwind(Thread &thread) : m_thread(thread) {} public: virtual ~Unwind() = default; diff --git a/lldb/include/lldb/Target/UnwindLLDB.h b/lldb/include/lldb/Target/UnwindLLDB.h index f6750171c54a..939226c8c5b9 100644 --- a/lldb/include/lldb/Target/UnwindLLDB.h +++ b/lldb/include/lldb/Target/UnwindLLDB.h @@ -119,7 +119,7 @@ private: RegisterContextLLDBSP reg_ctx_lldb_sp; // These are all RegisterContextUnwind's - Cursor() : sctx(), reg_ctx_lldb_sp() {} + Cursor() {} private: Cursor(const Cursor &) = delete; diff --git a/lldb/include/lldb/Utility/ConstString.h b/lldb/include/lldb/Utility/ConstString.h index 2756f1fd7203..31887d7f6115 100644 --- a/lldb/include/lldb/Utility/ConstString.h +++ b/lldb/include/lldb/Utility/ConstString.h @@ -394,19 +394,17 @@ public: /// /// \return /// The number of bytes that this object occupies in memory. - /// - /// \see ConstString::StaticMemorySize () size_t MemorySize() const { return sizeof(ConstString); } - /// Get the size in bytes of the current global string pool. - /// - /// Reports the size in bytes of all shared C string values, containers and - /// any other values as a byte size for the entire string pool. - /// - /// \return - /// The number of bytes that the global string pool occupies - /// in memory. - static size_t StaticMemorySize(); + struct MemoryStats { + size_t GetBytesTotal() const { return bytes_total; } + size_t GetBytesUsed() const { return bytes_used; } + size_t GetBytesUnused() const { return bytes_total - bytes_used; } + size_t bytes_total = 0; + size_t bytes_used = 0; + }; + + static MemoryStats GetMemoryStats(); protected: template <typename T, typename Enable> friend struct ::llvm::DenseMapInfo; diff --git a/lldb/include/lldb/Utility/Environment.h b/lldb/include/lldb/Utility/Environment.h index 24cbee246f83..c1549a3d60a6 100644 --- a/lldb/include/lldb/Utility/Environment.h +++ b/lldb/include/lldb/Utility/Environment.h @@ -56,7 +56,7 @@ public: using Base::try_emplace; using Base::operator[]; - Environment() : Base() {} + Environment() {} Environment(const Environment &RHS) : Base(RHS) {} Environment(Environment &&RHS) : Base(std::move(RHS)) {} Environment(char *const *Env) diff --git a/lldb/include/lldb/Utility/Event.h b/lldb/include/lldb/Utility/Event.h index 4e38f98a02f3..d3176216115a 100644 --- a/lldb/include/lldb/Utility/Event.h +++ b/lldb/include/lldb/Utility/Event.h @@ -99,7 +99,7 @@ private: class EventDataReceipt : public EventData { public: - EventDataReceipt() : EventData(), m_predicate(false) {} + EventDataReceipt() : m_predicate(false) {} ~EventDataReceipt() override = default; diff --git a/lldb/include/lldb/Utility/FileSpec.h b/lldb/include/lldb/Utility/FileSpec.h index 305cd04f95c0..ec473a2afeec 100644 --- a/lldb/include/lldb/Utility/FileSpec.h +++ b/lldb/include/lldb/Utility/FileSpec.h @@ -334,8 +334,6 @@ public: /// /// \return /// The number of bytes that this object occupies in memory. - /// - /// \see ConstString::StaticMemorySize () size_t MemorySize() const; /// Change the file specified with a new path. diff --git a/lldb/include/lldb/Utility/GDBRemote.h b/lldb/include/lldb/Utility/GDBRemote.h index f658818de806..451181624c87 100644 --- a/lldb/include/lldb/Utility/GDBRemote.h +++ b/lldb/include/lldb/Utility/GDBRemote.h @@ -55,7 +55,7 @@ struct GDBRemotePacket { enum Type { ePacketTypeInvalid = 0, ePacketTypeSend, ePacketTypeRecv }; - GDBRemotePacket() : packet() {} + GDBRemotePacket() {} void Clear() { packet.data.clear(); diff --git a/lldb/include/lldb/Utility/Instrumentation.h b/lldb/include/lldb/Utility/Instrumentation.h new file mode 100644 index 000000000000..ff6591d63437 --- /dev/null +++ b/lldb/include/lldb/Utility/Instrumentation.h @@ -0,0 +1,105 @@ +//===-- Instrumentation.h ---------------------------------------*- C++ -*-===// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef LLDB_UTILITY_INSTRUMENTATION_H +#define LLDB_UTILITY_INSTRUMENTATION_H + +#include "lldb/Utility/FileSpec.h" +#include "lldb/Utility/Log.h" +#include "lldb/Utility/Logging.h" + +#include "llvm/ADT/DenseMap.h" +#include "llvm/ADT/StringRef.h" +#include "llvm/Support/ErrorHandling.h" + +#include <map> +#include <thread> +#include <type_traits> + +namespace lldb_private { +namespace instrumentation { + +template <typename T, + typename std::enable_if<std::is_fundamental<T>::value, int>::type = 0> +inline void stringify_append(llvm::raw_string_ostream &ss, const T &t) { + ss << t; +} + +template <typename T, typename std::enable_if<!std::is_fundamental<T>::value, + int>::type = 0> +inline void stringify_append(llvm::raw_string_ostream &ss, const T &t) { + ss << &t; +} + +template <typename T> +inline void stringify_append(llvm::raw_string_ostream &ss, T *t) { + ss << reinterpret_cast<void *>(t); +} + +template <typename T> +inline void stringify_append(llvm::raw_string_ostream &ss, const T *t) { + ss << reinterpret_cast<const void *>(t); +} + +template <> +inline void stringify_append<char>(llvm::raw_string_ostream &ss, + const char *t) { + ss << '\"' << t << '\"'; +} + +template <> +inline void stringify_append<std::nullptr_t>(llvm::raw_string_ostream &ss, + const std::nullptr_t &t) { + ss << "\"nullptr\""; +} + +template <typename Head> +inline void stringify_helper(llvm::raw_string_ostream &ss, const Head &head) { + stringify_append(ss, head); +} + +template <typename Head, typename... Tail> +inline void stringify_helper(llvm::raw_string_ostream &ss, const Head &head, + const Tail &...tail) { + stringify_append(ss, head); + ss << ", "; + stringify_helper(ss, tail...); +} + +template <typename... Ts> inline std::string stringify_args(const Ts &...ts) { + std::string buffer; + llvm::raw_string_ostream ss(buffer); + stringify_helper(ss, ts...); + return ss.str(); +} + +/// RAII object for instrumenting LLDB API functions. +class Instrumenter { +public: + Instrumenter(llvm::StringRef pretty_func, std::string &&pretty_args = {}); + ~Instrumenter(); + +private: + void UpdateBoundary(); + + llvm::StringRef m_pretty_func; + + /// Whether this function call was the one crossing the API boundary. + bool m_local_boundary = false; +}; +} // namespace instrumentation +} // namespace lldb_private + +#define LLDB_INSTRUMENT() \ + lldb_private::instrumentation::Instrumenter _instr(LLVM_PRETTY_FUNCTION); + +#define LLDB_INSTRUMENT_VA(...) \ + lldb_private::instrumentation::Instrumenter _instr( \ + LLVM_PRETTY_FUNCTION, \ + lldb_private::instrumentation::stringify_args(__VA_ARGS__)); + +#endif // LLDB_UTILITY_INSTRUMENTATION_H diff --git a/lldb/include/lldb/Utility/Log.h b/lldb/include/lldb/Utility/Log.h index 01edec044565..09fd2cb3a7e6 100644 --- a/lldb/include/lldb/Utility/Log.h +++ b/lldb/include/lldb/Utility/Log.h @@ -10,7 +10,6 @@ #define LLDB_UTILITY_LOG_H #include "lldb/Utility/Flags.h" -#include "lldb/Utility/Logging.h" #include "lldb/lldb-defines.h" #include "llvm/ADT/ArrayRef.h" @@ -48,11 +47,31 @@ namespace lldb_private { class Log final { public: + /// The underlying type of all log channel enums. Declare them as: + /// enum class MyLog : MaskType { + /// Channel0 = Log::ChannelFlag<0>, + /// Channel1 = Log::ChannelFlag<1>, + /// ..., + /// LLVM_MARK_AS_BITMASK_ENUM(LastChannel), + /// }; + using MaskType = uint64_t; + + template <MaskType Bit> + static constexpr MaskType ChannelFlag = MaskType(1) << Bit; + // Description of a log channel category. struct Category { llvm::StringLiteral name; llvm::StringLiteral description; - uint32_t flag; + MaskType flag; + + template <typename Cat> + constexpr Category(llvm::StringLiteral name, + llvm::StringLiteral description, Cat mask) + : name(name), description(description), flag(MaskType(mask)) { + static_assert( + std::is_same<Log::MaskType, std::underlying_type_t<Cat>>::value, ""); + } }; // This class describes a log channel. It also encapsulates the behavior @@ -63,18 +82,22 @@ public: public: const llvm::ArrayRef<Category> categories; - const uint32_t default_flags; + const MaskType default_flags; + template <typename Cat> constexpr Channel(llvm::ArrayRef<Log::Category> categories, - uint32_t default_flags) + Cat default_flags) : log_ptr(nullptr), categories(categories), - default_flags(default_flags) {} + default_flags(MaskType(default_flags)) { + static_assert( + std::is_same<Log::MaskType, std::underlying_type_t<Cat>>::value, ""); + } // This function is safe to call at any time. If the channel is disabled // after (or concurrently with) this function returning a non-null Log // pointer, it is still safe to attempt to write to the Log object -- the // output will be discarded. - Log *GetLogIfAll(uint32_t mask) { + Log *GetLogIfAll(MaskType mask) { Log *log = log_ptr.load(std::memory_order_relaxed); if (log && log->GetMask().AllSet(mask)) return log; @@ -85,7 +108,7 @@ public: // after (or concurrently with) this function returning a non-null Log // pointer, it is still safe to attempt to write to the Log object -- the // output will be discarded. - Log *GetLogIfAny(uint32_t mask) { + Log *GetLogIfAny(MaskType mask) { Log *log = log_ptr.load(std::memory_order_relaxed); if (log && log->GetMask().AnySet(mask)) return log; @@ -180,7 +203,7 @@ private: std::shared_ptr<llvm::raw_ostream> m_stream_sp; std::atomic<uint32_t> m_options{0}; - std::atomic<uint32_t> m_mask{0}; + std::atomic<MaskType> m_mask{0}; void WriteHeader(llvm::raw_ostream &OS, llvm::StringRef file, llvm::StringRef function); @@ -211,12 +234,23 @@ private: static uint32_t GetFlags(llvm::raw_ostream &stream, const ChannelMap::value_type &entry, llvm::ArrayRef<const char *> categories); - static void DisableLoggingChild(); - Log(const Log &) = delete; void operator=(const Log &) = delete; }; +// Must be specialized for a particular log type. +template <typename Cat> Log::Channel &LogChannelFor() = delete; + +/// Retrieve the Log object for the channel associated with the given log enum. +/// +/// Returns a valid Log object if any of the provided categories are enabled. +/// Otherwise, returns nullptr. +template <typename Cat> Log *GetLog(Cat mask) { + static_assert(std::is_same<Log::MaskType, std::underlying_type_t<Cat>>::value, + ""); + return LogChannelFor<Cat>().GetLogIfAny(Log::MaskType(mask)); +} + } // namespace lldb_private /// The LLDB_LOG* macros defined below are the way to emit log messages. @@ -274,3 +308,6 @@ private: } while (0) #endif // LLDB_UTILITY_LOG_H + +// TODO: Remove this and fix includes everywhere. +#include "lldb/Utility/Logging.h" diff --git a/lldb/include/lldb/Utility/Logging.h b/lldb/include/lldb/Utility/Logging.h index 1a8a1022c5c0..db84da244954 100644 --- a/lldb/include/lldb/Utility/Logging.h +++ b/lldb/include/lldb/Utility/Logging.h @@ -9,57 +9,89 @@ #ifndef LLDB_UTILITY_LOGGING_H #define LLDB_UTILITY_LOGGING_H +#include "lldb/Utility/Log.h" +#include "llvm/ADT/BitmaskEnum.h" #include <cstdint> -// Log Bits specific to logging in lldb -#define LIBLLDB_LOG_PROCESS (1u << 1) -#define LIBLLDB_LOG_THREAD (1u << 2) -#define LIBLLDB_LOG_DYNAMIC_LOADER (1u << 3) -#define LIBLLDB_LOG_EVENTS (1u << 4) -#define LIBLLDB_LOG_BREAKPOINTS (1u << 5) -#define LIBLLDB_LOG_WATCHPOINTS (1u << 6) -#define LIBLLDB_LOG_STEP (1u << 7) -#define LIBLLDB_LOG_EXPRESSIONS (1u << 8) -#define LIBLLDB_LOG_TEMPORARY (1u << 9) -#define LIBLLDB_LOG_STATE (1u << 10) -#define LIBLLDB_LOG_OBJECT (1u << 11) -#define LIBLLDB_LOG_COMMUNICATION (1u << 12) -#define LIBLLDB_LOG_CONNECTION (1u << 13) -#define LIBLLDB_LOG_HOST (1u << 14) -#define LIBLLDB_LOG_UNWIND (1u << 15) -#define LIBLLDB_LOG_API (1u << 16) -#define LIBLLDB_LOG_SCRIPT (1u << 17) -#define LIBLLDB_LOG_COMMANDS (1U << 18) -#define LIBLLDB_LOG_TYPES (1u << 19) -#define LIBLLDB_LOG_SYMBOLS (1u << 20) -#define LIBLLDB_LOG_MODULES (1u << 21) -#define LIBLLDB_LOG_TARGET (1u << 22) -#define LIBLLDB_LOG_MMAP (1u << 23) -#define LIBLLDB_LOG_OS (1u << 24) -#define LIBLLDB_LOG_PLATFORM (1u << 25) -#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_DEMANGLE (1u << 30) -#define LIBLLDB_LOG_AST (1u << 31) -#define LIBLLDB_LOG_ALL (UINT32_MAX) -#define LIBLLDB_LOG_DEFAULT \ - (LIBLLDB_LOG_PROCESS | LIBLLDB_LOG_THREAD | LIBLLDB_LOG_DYNAMIC_LOADER | \ - LIBLLDB_LOG_BREAKPOINTS | LIBLLDB_LOG_WATCHPOINTS | LIBLLDB_LOG_STEP | \ - LIBLLDB_LOG_STATE | LIBLLDB_LOG_SYMBOLS | LIBLLDB_LOG_TARGET | \ - LIBLLDB_LOG_COMMANDS) - namespace lldb_private { -class Log; +enum class LLDBLog : Log::MaskType { + API = Log::ChannelFlag<0>, + AST = Log::ChannelFlag<1>, + Breakpoints = Log::ChannelFlag<2>, + Commands = Log::ChannelFlag<3>, + Communication = Log::ChannelFlag<4>, + Connection = Log::ChannelFlag<5>, + DataFormatters = Log::ChannelFlag<6>, + Demangle = Log::ChannelFlag<7>, + DynamicLoader = Log::ChannelFlag<8>, + Events = Log::ChannelFlag<9>, + Expressions = Log::ChannelFlag<10>, + Host = Log::ChannelFlag<11>, + JITLoader = Log::ChannelFlag<12>, + Language = Log::ChannelFlag<13>, + MMap = Log::ChannelFlag<14>, + Modules = Log::ChannelFlag<15>, + Object = Log::ChannelFlag<16>, + OS = Log::ChannelFlag<17>, + Platform = Log::ChannelFlag<18>, + Process = Log::ChannelFlag<19>, + Script = Log::ChannelFlag<20>, + State = Log::ChannelFlag<21>, + Step = Log::ChannelFlag<22>, + Symbols = Log::ChannelFlag<23>, + SystemRuntime = Log::ChannelFlag<24>, + Target = Log::ChannelFlag<25>, + Temporary = Log::ChannelFlag<26>, + Thread = Log::ChannelFlag<27>, + Types = Log::ChannelFlag<28>, + Unwind = Log::ChannelFlag<29>, + Watchpoints = Log::ChannelFlag<30>, + LLVM_MARK_AS_BITMASK_ENUM(Watchpoints), +}; + +LLVM_ENABLE_BITMASK_ENUMS_IN_NAMESPACE(); + +// Log Bits specific to logging in lldb +#define LIBLLDB_LOG_PROCESS ::lldb_private::LLDBLog::Process +#define LIBLLDB_LOG_THREAD ::lldb_private::LLDBLog::Thread +#define LIBLLDB_LOG_DYNAMIC_LOADER ::lldb_private::LLDBLog::DynamicLoader +#define LIBLLDB_LOG_EVENTS ::lldb_private::LLDBLog::Events +#define LIBLLDB_LOG_BREAKPOINTS ::lldb_private::LLDBLog::Breakpoints +#define LIBLLDB_LOG_WATCHPOINTS ::lldb_private::LLDBLog::Watchpoints +#define LIBLLDB_LOG_STEP ::lldb_private::LLDBLog::Step +#define LIBLLDB_LOG_EXPRESSIONS ::lldb_private::LLDBLog::Expressions +#define LIBLLDB_LOG_TEMPORARY ::lldb_private::LLDBLog::Temporary +#define LIBLLDB_LOG_STATE ::lldb_private::LLDBLog::State +#define LIBLLDB_LOG_OBJECT ::lldb_private::LLDBLog::Object +#define LIBLLDB_LOG_COMMUNICATION ::lldb_private::LLDBLog::Communication +#define LIBLLDB_LOG_CONNECTION ::lldb_private::LLDBLog::Connection +#define LIBLLDB_LOG_HOST ::lldb_private::LLDBLog::Host +#define LIBLLDB_LOG_UNWIND ::lldb_private::LLDBLog::Unwind +#define LIBLLDB_LOG_API ::lldb_private::LLDBLog::API +#define LIBLLDB_LOG_SCRIPT ::lldb_private::LLDBLog::Script +#define LIBLLDB_LOG_COMMANDS ::lldb_private::LLDBLog::Commands +#define LIBLLDB_LOG_TYPES ::lldb_private::LLDBLog::Types +#define LIBLLDB_LOG_SYMBOLS ::lldb_private::LLDBLog::Symbols +#define LIBLLDB_LOG_MODULES ::lldb_private::LLDBLog::Modules +#define LIBLLDB_LOG_TARGET ::lldb_private::LLDBLog::Target +#define LIBLLDB_LOG_MMAP ::lldb_private::LLDBLog::MMap +#define LIBLLDB_LOG_OS ::lldb_private::LLDBLog::OS +#define LIBLLDB_LOG_PLATFORM ::lldb_private::LLDBLog::Platform +#define LIBLLDB_LOG_SYSTEM_RUNTIME ::lldb_private::LLDBLog::SystemRuntime +#define LIBLLDB_LOG_JIT_LOADER ::lldb_private::LLDBLog::JITLoader +#define LIBLLDB_LOG_LANGUAGE ::lldb_private::LLDBLog::Language +#define LIBLLDB_LOG_DATAFORMATTERS ::lldb_private::LLDBLog::DataFormatters +#define LIBLLDB_LOG_DEMANGLE ::lldb_private::LLDBLog::Demangle +#define LIBLLDB_LOG_AST ::lldb_private::LLDBLog::AST -Log *GetLogIfAllCategoriesSet(uint32_t mask); +Log *GetLogIfAllCategoriesSet(LLDBLog mask); -Log *GetLogIfAnyCategoriesSet(uint32_t mask); +Log *GetLogIfAnyCategoriesSet(LLDBLog mask); void InitializeLldbChannel(); +template <> Log::Channel &LogChannelFor<LLDBLog>(); } // namespace lldb_private #endif // LLDB_UTILITY_LOGGING_H diff --git a/lldb/include/lldb/Utility/Predicate.h b/lldb/include/lldb/Utility/Predicate.h index af16abc1a1d3..e5d80acb11bc 100644 --- a/lldb/include/lldb/Utility/Predicate.h +++ b/lldb/include/lldb/Utility/Predicate.h @@ -44,7 +44,7 @@ public: /// /// Initializes the mutex, condition and value with their default /// constructors. - Predicate() : m_value(), m_mutex(), m_condition() {} + Predicate() : m_value() {} /// Construct with initial T value \a initial_value. /// @@ -53,8 +53,7 @@ public: /// /// \param[in] initial_value /// The initial value for our T object. - Predicate(T initial_value) - : m_value(initial_value), m_mutex(), m_condition() {} + Predicate(T initial_value) : m_value(initial_value) {} /// Destructor. /// diff --git a/lldb/include/lldb/Utility/ProcessInfo.h b/lldb/include/lldb/Utility/ProcessInfo.h index 3c5956926391..fc8b12768999 100644 --- a/lldb/include/lldb/Utility/ProcessInfo.h +++ b/lldb/include/lldb/Utility/ProcessInfo.h @@ -107,7 +107,7 @@ protected: // to that process. class ProcessInstanceInfo : public ProcessInfo { public: - ProcessInstanceInfo() : ProcessInfo() {} + ProcessInstanceInfo() {} ProcessInstanceInfo(const char *name, const ArchSpec &arch, lldb::pid_t pid) : ProcessInfo(name, arch, pid), m_euid(UINT32_MAX), m_egid(UINT32_MAX), @@ -162,12 +162,11 @@ typedef std::vector<ProcessInstanceInfo> ProcessInstanceInfoList; class ProcessInstanceInfoMatch { public: - ProcessInstanceInfoMatch() : m_match_info() {} + ProcessInstanceInfoMatch() {} ProcessInstanceInfoMatch(const char *process_name, NameMatch process_name_match_type) - : m_match_info(), m_name_match_type(process_name_match_type), - m_match_all_users(false) { + : m_name_match_type(process_name_match_type), m_match_all_users(false) { m_match_info.GetExecutableFile().SetFile(process_name, FileSpec::Style::native); } diff --git a/lldb/include/lldb/Utility/ReproducerInstrumentation.h b/lldb/include/lldb/Utility/ReproducerInstrumentation.h deleted file mode 100644 index 6c5d27879d36..000000000000 --- a/lldb/include/lldb/Utility/ReproducerInstrumentation.h +++ /dev/null @@ -1,1105 +0,0 @@ -//===-- ReproducerInstrumentation.h -----------------------------*- C++ -*-===// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef LLDB_UTILITY_REPRODUCERINSTRUMENTATION_H -#define LLDB_UTILITY_REPRODUCERINSTRUMENTATION_H - -#include "lldb/Utility/FileSpec.h" -#include "lldb/Utility/Log.h" -#include "lldb/Utility/Logging.h" - -#include "llvm/ADT/DenseMap.h" -#include "llvm/ADT/StringRef.h" -#include "llvm/Support/ErrorHandling.h" - -#include <map> -#include <thread> -#include <type_traits> - -template <typename T, - typename std::enable_if<std::is_fundamental<T>::value, int>::type = 0> -inline void stringify_append(llvm::raw_string_ostream &ss, const T &t) { - ss << t; -} - -template <typename T, typename std::enable_if<!std::is_fundamental<T>::value, - int>::type = 0> -inline void stringify_append(llvm::raw_string_ostream &ss, const T &t) { - ss << &t; -} - -template <typename T> -inline void stringify_append(llvm::raw_string_ostream &ss, T *t) { - ss << reinterpret_cast<void *>(t); -} - -template <typename T> -inline void stringify_append(llvm::raw_string_ostream &ss, const T *t) { - ss << reinterpret_cast<const void *>(t); -} - -template <> -inline void stringify_append<char>(llvm::raw_string_ostream &ss, - const char *t) { - ss << '\"' << t << '\"'; -} - -template <> -inline void stringify_append<std::nullptr_t>(llvm::raw_string_ostream &ss, - const std::nullptr_t &t) { - ss << "\"nullptr\""; -} - -template <typename Head> -inline void stringify_helper(llvm::raw_string_ostream &ss, const Head &head) { - stringify_append(ss, head); -} - -template <typename Head, typename... Tail> -inline void stringify_helper(llvm::raw_string_ostream &ss, const Head &head, - const Tail &... tail) { - stringify_append(ss, head); - ss << ", "; - stringify_helper(ss, tail...); -} - -template <typename... Ts> inline std::string stringify_args(const Ts &... ts) { - std::string buffer; - llvm::raw_string_ostream ss(buffer); - stringify_helper(ss, ts...); - return ss.str(); -} - -// Define LLDB_REPRO_INSTR_TRACE to trace to stderr instead of LLDB's log -// infrastructure. This is useful when you need to see traces before the logger -// is initialized or enabled. -// #define LLDB_REPRO_INSTR_TRACE - -#ifdef LLDB_REPRO_INSTR_TRACE -inline llvm::raw_ostream &this_thread_id() { - size_t tid = std::hash<std::thread::id>{}(std::this_thread::get_id()); - return llvm::errs().write_hex(tid) << " :: "; -} -#endif - -#define LLDB_REGISTER_CONSTRUCTOR(Class, Signature) \ - R.Register<Class * Signature>(&construct<Class Signature>::record, "", \ - #Class, #Class, #Signature) - -#define LLDB_REGISTER_METHOD(Result, Class, Method, Signature) \ - R.Register( \ - &invoke<Result(Class::*) Signature>::method<(&Class::Method)>::record, \ - #Result, #Class, #Method, #Signature) - -#define LLDB_REGISTER_METHOD_CONST(Result, Class, Method, Signature) \ - R.Register(&invoke<Result(Class::*) \ - Signature const>::method<(&Class::Method)>::record, \ - #Result, #Class, #Method, #Signature) - -#define LLDB_REGISTER_STATIC_METHOD(Result, Class, Method, Signature) \ - R.Register(&invoke<Result(*) Signature>::method<(&Class::Method)>::record, \ - #Result, #Class, #Method, #Signature) - -#define LLDB_REGISTER_CHAR_PTR_METHOD_STATIC(Result, Class, Method) \ - R.Register( \ - &invoke<Result (*)(char *, size_t)>::method<(&Class::Method)>::record, \ - &invoke_char_ptr<Result (*)(char *, \ - size_t)>::method<(&Class::Method)>::record, \ - #Result, #Class, #Method, "(char*, size_t"); - -#define LLDB_REGISTER_CHAR_PTR_METHOD(Result, Class, Method) \ - R.Register(&invoke<Result (Class::*)(char *, size_t)>::method<( \ - &Class::Method)>::record, \ - &invoke_char_ptr<Result (Class::*)(char *, size_t)>::method<( \ - &Class::Method)>::record, \ - #Result, #Class, #Method, "(char*, size_t"); - -#define LLDB_REGISTER_CHAR_PTR_METHOD_CONST(Result, Class, Method) \ - R.Register(&invoke<Result (Class::*)(char *, size_t) \ - const>::method<(&Class::Method)>::record, \ - &invoke_char_ptr<Result (Class::*)(char *, size_t) \ - const>::method<(&Class::Method)>::record, \ - #Result, #Class, #Method, "(char*, size_t"); - -#define LLDB_CONSTRUCT_(T, Class, ...) \ - lldb_private::repro::Recorder _recorder(LLVM_PRETTY_FUNCTION); \ - lldb_private::repro::construct<T>::handle(LLDB_GET_INSTRUMENTATION_DATA(), \ - _recorder, Class, __VA_ARGS__); - -#define LLDB_RECORD_CONSTRUCTOR(Class, Signature, ...) \ - LLDB_CONSTRUCT_(Class Signature, this, __VA_ARGS__) - -#define LLDB_RECORD_CONSTRUCTOR_NO_ARGS(Class) \ - LLDB_CONSTRUCT_(Class(), this, lldb_private::repro::EmptyArg()) - -#define LLDB_RECORD_(T1, T2, ...) \ - lldb_private::repro::Recorder _recorder(LLVM_PRETTY_FUNCTION, \ - stringify_args(__VA_ARGS__)); \ - if (lldb_private::repro::InstrumentationData _data = \ - LLDB_GET_INSTRUMENTATION_DATA()) { \ - if (lldb_private::repro::Serializer *_serializer = \ - _data.GetSerializer()) { \ - _recorder.Record(*_serializer, _data.GetRegistry(), \ - &lldb_private::repro::invoke<T1>::method<T2>::record, \ - __VA_ARGS__); \ - } else if (lldb_private::repro::Deserializer *_deserializer = \ - _data.GetDeserializer()) { \ - if (_recorder.ShouldCapture()) { \ - return lldb_private::repro::invoke<T1>::method<T2>::replay( \ - _recorder, *_deserializer, _data.GetRegistry()); \ - } \ - } \ - } - -#define LLDB_RECORD_METHOD(Result, Class, Method, Signature, ...) \ - LLDB_RECORD_(Result(Class::*) Signature, (&Class::Method), this, __VA_ARGS__) - -#define LLDB_RECORD_METHOD_CONST(Result, Class, Method, Signature, ...) \ - LLDB_RECORD_(Result(Class::*) Signature const, (&Class::Method), this, \ - __VA_ARGS__) - -#define LLDB_RECORD_METHOD_NO_ARGS(Result, Class, Method) \ - LLDB_RECORD_(Result (Class::*)(), (&Class::Method), this) - -#define LLDB_RECORD_METHOD_CONST_NO_ARGS(Result, Class, Method) \ - LLDB_RECORD_(Result (Class::*)() const, (&Class::Method), this) - -#define LLDB_RECORD_STATIC_METHOD(Result, Class, Method, Signature, ...) \ - LLDB_RECORD_(Result(*) Signature, (&Class::Method), __VA_ARGS__) - -#define LLDB_RECORD_STATIC_METHOD_NO_ARGS(Result, Class, Method) \ - LLDB_RECORD_(Result (*)(), (&Class::Method), lldb_private::repro::EmptyArg()) - -#define LLDB_RECORD_CHAR_PTR_(T1, T2, StrOut, ...) \ - lldb_private::repro::Recorder _recorder(LLVM_PRETTY_FUNCTION, \ - stringify_args(__VA_ARGS__)); \ - if (lldb_private::repro::InstrumentationData _data = \ - LLDB_GET_INSTRUMENTATION_DATA()) { \ - if (lldb_private::repro::Serializer *_serializer = \ - _data.GetSerializer()) { \ - _recorder.Record(*_serializer, _data.GetRegistry(), \ - &lldb_private::repro::invoke<T1>::method<(T2)>::record, \ - __VA_ARGS__); \ - } else if (lldb_private::repro::Deserializer *_deserializer = \ - _data.GetDeserializer()) { \ - if (_recorder.ShouldCapture()) { \ - return lldb_private::repro::invoke_char_ptr<T1>::method<T2>::replay( \ - _recorder, *_deserializer, _data.GetRegistry(), StrOut); \ - } \ - } \ - } - -#define LLDB_RECORD_CHAR_PTR_METHOD(Result, Class, Method, Signature, StrOut, \ - ...) \ - LLDB_RECORD_CHAR_PTR_(Result(Class::*) Signature, (&Class::Method), StrOut, \ - this, __VA_ARGS__) - -#define LLDB_RECORD_CHAR_PTR_METHOD_CONST(Result, Class, Method, Signature, \ - StrOut, ...) \ - LLDB_RECORD_CHAR_PTR_(Result(Class::*) Signature const, (&Class::Method), \ - StrOut, this, __VA_ARGS__) - -#define LLDB_RECORD_CHAR_PTR_STATIC_METHOD(Result, Class, Method, Signature, \ - StrOut, ...) \ - LLDB_RECORD_CHAR_PTR_(Result(*) Signature, (&Class::Method), StrOut, \ - __VA_ARGS__) - -#define LLDB_RECORD_RESULT(Result) _recorder.RecordResult(Result, true); - -/// The LLDB_RECORD_DUMMY macro is special because it doesn't actually record -/// anything. It's used to track API boundaries when we cannot record for -/// technical reasons. -#define LLDB_RECORD_DUMMY(Result, Class, Method, Signature, ...) \ - lldb_private::repro::Recorder _recorder; - -#define LLDB_RECORD_DUMMY_NO_ARGS(Result, Class, Method) \ - lldb_private::repro::Recorder _recorder; - -namespace lldb_private { -namespace repro { - -template <class T> -struct is_trivially_serializable - : std::integral_constant<bool, std::is_fundamental<T>::value || - std::is_enum<T>::value> {}; - -/// Mapping between serialized indices and their corresponding objects. -/// -/// This class is used during replay to map indices back to in-memory objects. -/// -/// When objects are constructed, they are added to this mapping using -/// AddObjectForIndex. -/// -/// When an object is passed to a function, its index is deserialized and -/// AddObjectForIndex returns the corresponding object. If there is no object -/// for the given index, a nullptr is returend. The latter is valid when custom -/// replay code is in place and the actual object is ignored. -class IndexToObject { -public: - /// Returns an object as a pointer for the given index or nullptr if not - /// present in the map. - template <typename T> T *GetObjectForIndex(unsigned idx) { - assert(idx != 0 && "Cannot get object for sentinel"); - void *object = GetObjectForIndexImpl(idx); - return static_cast<T *>(object); - } - - /// Adds a pointer to an object to the mapping for the given index. - template <typename T> T *AddObjectForIndex(unsigned idx, T *object) { - AddObjectForIndexImpl( - idx, static_cast<void *>( - const_cast<typename std::remove_const<T>::type *>(object))); - return object; - } - - /// Adds a reference to an object to the mapping for the given index. - template <typename T> T &AddObjectForIndex(unsigned idx, T &object) { - AddObjectForIndexImpl( - idx, static_cast<void *>( - const_cast<typename std::remove_const<T>::type *>(&object))); - return object; - } - - /// Get all objects sorted by their index. - std::vector<void *> GetAllObjects() const; - -private: - /// Helper method that does the actual lookup. The void* result is later cast - /// by the caller. - void *GetObjectForIndexImpl(unsigned idx); - - /// Helper method that does the actual insertion. - void AddObjectForIndexImpl(unsigned idx, void *object); - - /// Keeps a mapping between indices and their corresponding object. - llvm::DenseMap<unsigned, void *> m_mapping; -}; - -/// We need to differentiate between pointers to fundamental and -/// non-fundamental types. See the corresponding Deserializer::Read method -/// for the reason why. -struct PointerTag {}; -struct ReferenceTag {}; -struct ValueTag {}; -struct FundamentalPointerTag {}; -struct FundamentalReferenceTag {}; - -/// Return the deserialization tag for the given type T. -template <class T> struct serializer_tag { - typedef typename std::conditional<std::is_trivially_copyable<T>::value, - ValueTag, ReferenceTag>::type type; -}; -template <class T> struct serializer_tag<T *> { - typedef - typename std::conditional<std::is_fundamental<T>::value, - FundamentalPointerTag, PointerTag>::type type; -}; -template <class T> struct serializer_tag<T &> { - typedef typename std::conditional<std::is_fundamental<T>::value, - FundamentalReferenceTag, ReferenceTag>::type - type; -}; - -/// Deserializes data from a buffer. It is used to deserialize function indices -/// to replay, their arguments and return values. -/// -/// Fundamental types and strings are read by value. Objects are read by their -/// index, which get translated by the IndexToObject mapping maintained in -/// this class. -/// -/// Additional bookkeeping with regards to the IndexToObject is required to -/// deserialize objects. When a constructor is run or an object is returned by -/// value, we need to capture the object and add it to the index together with -/// its index. This is the job of HandleReplayResult(Void). -class Deserializer { -public: - Deserializer(llvm::StringRef buffer) : m_buffer(buffer) {} - - /// Returns true when the buffer has unread data. - bool HasData(unsigned size) { return size <= m_buffer.size(); } - - /// Deserialize and interpret value as T. - template <typename T> T Deserialize() { - T t = Read<T>(typename serializer_tag<T>::type()); -#ifdef LLDB_REPRO_INSTR_TRACE - llvm::errs() << "Deserializing with " << LLVM_PRETTY_FUNCTION << " -> " - << stringify_args(t) << "\n"; -#endif - return t; - } - - template <typename T> const T &HandleReplayResult(const T &t) { - CheckSequence(Deserialize<unsigned>()); - unsigned result = Deserialize<unsigned>(); - if (is_trivially_serializable<T>::value) - return t; - // We need to make a copy as the original object might go out of scope. - return *m_index_to_object.AddObjectForIndex(result, new T(t)); - } - - /// Store the returned value in the index-to-object mapping. - template <typename T> T &HandleReplayResult(T &t) { - CheckSequence(Deserialize<unsigned>()); - unsigned result = Deserialize<unsigned>(); - if (is_trivially_serializable<T>::value) - return t; - // We need to make a copy as the original object might go out of scope. - return *m_index_to_object.AddObjectForIndex(result, new T(t)); - } - - /// Store the returned value in the index-to-object mapping. - template <typename T> T *HandleReplayResult(T *t) { - CheckSequence(Deserialize<unsigned>()); - unsigned result = Deserialize<unsigned>(); - if (is_trivially_serializable<T>::value) - return t; - return m_index_to_object.AddObjectForIndex(result, t); - } - - /// All returned types are recorded, even when the function returns a void. - /// The latter requires special handling. - void HandleReplayResultVoid() { - CheckSequence(Deserialize<unsigned>()); - unsigned result = Deserialize<unsigned>(); - assert(result == 0); - (void)result; - } - - std::vector<void *> GetAllObjects() const { - return m_index_to_object.GetAllObjects(); - } - - void SetExpectedSequence(unsigned sequence) { - m_expected_sequence = sequence; - } - -private: - template <typename T> T Read(ValueTag) { - assert(HasData(sizeof(T))); - T t; - std::memcpy(reinterpret_cast<char *>(&t), m_buffer.data(), sizeof(T)); - m_buffer = m_buffer.drop_front(sizeof(T)); - return t; - } - - template <typename T> T Read(PointerTag) { - typedef typename std::remove_pointer<T>::type UnderlyingT; - return m_index_to_object.template GetObjectForIndex<UnderlyingT>( - Deserialize<unsigned>()); - } - - template <typename T> T Read(ReferenceTag) { - typedef typename std::remove_reference<T>::type UnderlyingT; - // If this is a reference to a fundamental type we just read its value. - return *m_index_to_object.template GetObjectForIndex<UnderlyingT>( - Deserialize<unsigned>()); - } - - /// This method is used to parse references to fundamental types. Because - /// they're not recorded in the object table we have serialized their value. - /// We read its value, allocate a copy on the heap, and return a pointer to - /// the copy. - template <typename T> T Read(FundamentalPointerTag) { - typedef typename std::remove_pointer<T>::type UnderlyingT; - return new UnderlyingT(Deserialize<UnderlyingT>()); - } - - /// This method is used to parse references to fundamental types. Because - /// they're not recorded in the object table we have serialized their value. - /// We read its value, allocate a copy on the heap, and return a reference to - /// the copy. - template <typename T> T Read(FundamentalReferenceTag) { - // If this is a reference to a fundamental type we just read its value. - typedef typename std::remove_reference<T>::type UnderlyingT; - return *(new UnderlyingT(Deserialize<UnderlyingT>())); - } - - /// Verify that the given sequence number matches what we expect. - void CheckSequence(unsigned sequence); - - /// Mapping of indices to objects. - IndexToObject m_index_to_object; - - /// Buffer containing the serialized data. - llvm::StringRef m_buffer; - - /// The result's expected sequence number. - llvm::Optional<unsigned> m_expected_sequence; -}; - -/// Partial specialization for C-style strings. We read the string value -/// instead of treating it as pointer. -template <> const char *Deserializer::Deserialize<const char *>(); -template <> const char **Deserializer::Deserialize<const char **>(); -template <> const uint8_t *Deserializer::Deserialize<const uint8_t *>(); -template <> const void *Deserializer::Deserialize<const void *>(); -template <> char *Deserializer::Deserialize<char *>(); -template <> void *Deserializer::Deserialize<void *>(); - -/// Helpers to auto-synthesize function replay code. It deserializes the replay -/// function's arguments one by one and finally calls the corresponding -/// function. -template <typename... Remaining> struct DeserializationHelper; - -template <typename Head, typename... Tail> -struct DeserializationHelper<Head, Tail...> { - template <typename Result, typename... Deserialized> struct deserialized { - static Result doit(Deserializer &deserializer, - Result (*f)(Deserialized..., Head, Tail...), - Deserialized... d) { - return DeserializationHelper<Tail...>:: - template deserialized<Result, Deserialized..., Head>::doit( - deserializer, f, d..., deserializer.Deserialize<Head>()); - } - }; -}; - -template <> struct DeserializationHelper<> { - template <typename Result, typename... Deserialized> struct deserialized { - static Result doit(Deserializer &deserializer, Result (*f)(Deserialized...), - Deserialized... d) { - return f(d...); - } - }; -}; - -/// The replayer interface. -struct Replayer { - virtual ~Replayer() = default; - virtual void operator()(Deserializer &deserializer) const = 0; -}; - -/// The default replayer deserializes the arguments and calls the function. -template <typename Signature> struct DefaultReplayer; -template <typename Result, typename... Args> -struct DefaultReplayer<Result(Args...)> : public Replayer { - DefaultReplayer(Result (*f)(Args...)) : Replayer(), f(f) {} - - void operator()(Deserializer &deserializer) const override { - Replay(deserializer); - } - - Result Replay(Deserializer &deserializer) const { - return deserializer.HandleReplayResult( - DeserializationHelper<Args...>::template deserialized<Result>::doit( - deserializer, f)); - } - - Result (*f)(Args...); -}; - -/// Partial specialization for function returning a void type. It ignores the -/// (absent) return value. -template <typename... Args> -struct DefaultReplayer<void(Args...)> : public Replayer { - DefaultReplayer(void (*f)(Args...)) : Replayer(), f(f) {} - - void operator()(Deserializer &deserializer) const override { - Replay(deserializer); - } - - void Replay(Deserializer &deserializer) const { - DeserializationHelper<Args...>::template deserialized<void>::doit( - deserializer, f); - deserializer.HandleReplayResultVoid(); - } - - void (*f)(Args...); -}; - -/// The registry contains a unique mapping between functions and their ID. The -/// IDs can be serialized and deserialized to replay a function. Functions need -/// to be registered with the registry for this to work. -class Registry { -private: - struct SignatureStr { - SignatureStr(llvm::StringRef result = {}, llvm::StringRef scope = {}, - llvm::StringRef name = {}, llvm::StringRef args = {}) - : result(result), scope(scope), name(name), args(args) {} - - std::string ToString() const; - - llvm::StringRef result; - llvm::StringRef scope; - llvm::StringRef name; - llvm::StringRef args; - }; - -public: - Registry() = default; - virtual ~Registry() = default; - - /// Register a default replayer for a function. - template <typename Signature> - void Register(Signature *f, llvm::StringRef result = {}, - llvm::StringRef scope = {}, llvm::StringRef name = {}, - llvm::StringRef args = {}) { - DoRegister(uintptr_t(f), std::make_unique<DefaultReplayer<Signature>>(f), - SignatureStr(result, scope, name, args)); - } - - /// Register a replayer that invokes a custom function with the same - /// signature as the replayed function. - template <typename Signature> - void Register(Signature *f, Signature *g, llvm::StringRef result = {}, - llvm::StringRef scope = {}, llvm::StringRef name = {}, - llvm::StringRef args = {}) { - DoRegister(uintptr_t(f), std::make_unique<DefaultReplayer<Signature>>(g), - SignatureStr(result, scope, name, args)); - } - - /// Replay functions from a file. - bool Replay(const FileSpec &file); - - /// Replay functions from a buffer. - bool Replay(llvm::StringRef buffer); - - /// Replay functions from a deserializer. - bool Replay(Deserializer &deserializer); - - /// Returns the ID for a given function address. - unsigned GetID(uintptr_t addr); - - /// Get the replayer matching the given ID. - Replayer *GetReplayer(unsigned id); - - std::string GetSignature(unsigned id); - - void CheckID(unsigned expected, unsigned actual); - -protected: - /// Register the given replayer for a function (and the ID mapping). - void DoRegister(uintptr_t RunID, std::unique_ptr<Replayer> replayer, - SignatureStr signature); - -private: - /// Mapping of function addresses to replayers and their ID. - std::map<uintptr_t, std::pair<std::unique_ptr<Replayer>, unsigned>> - m_replayers; - - /// Mapping of IDs to replayer instances. - std::map<unsigned, std::pair<Replayer *, SignatureStr>> m_ids; -}; - -/// Maps an object to an index for serialization. Indices are unique and -/// incremented for every new object. -/// -/// Indices start at 1 in order to differentiate with an invalid index (0) in -/// the serialized buffer. -class ObjectToIndex { -public: - template <typename T> unsigned GetIndexForObject(T *t) { - return GetIndexForObjectImpl(static_cast<const void *>(t)); - } - -private: - unsigned GetIndexForObjectImpl(const void *object); - - llvm::DenseMap<const void *, unsigned> m_mapping; -}; - -/// Serializes functions, their arguments and their return type to a stream. -class Serializer { -public: - Serializer(llvm::raw_ostream &stream = llvm::outs()) : m_stream(stream) {} - - /// Recursively serialize all the given arguments. - template <typename Head, typename... Tail> - void SerializeAll(const Head &head, const Tail &... tail) { - Serialize(head); - SerializeAll(tail...); - } - - void SerializeAll() { m_stream.flush(); } - -private: - /// Serialize pointers. We need to differentiate between pointers to - /// fundamental types (in which case we serialize its value) and pointer to - /// objects (in which case we serialize their index). - template <typename T> void Serialize(T *t) { -#ifdef LLDB_REPRO_INSTR_TRACE - this_thread_id() << "Serializing with " << LLVM_PRETTY_FUNCTION << " -> " - << stringify_args(t) << "\n"; -#endif - if (std::is_fundamental<T>::value) { - Serialize(*t); - } else { - unsigned idx = m_tracker.GetIndexForObject(t); - Serialize(idx); - } - } - - /// Serialize references. We need to differentiate between references to - /// fundamental types (in which case we serialize its value) and references - /// to objects (in which case we serialize their index). - template <typename T> void Serialize(T &t) { -#ifdef LLDB_REPRO_INSTR_TRACE - this_thread_id() << "Serializing with " << LLVM_PRETTY_FUNCTION << " -> " - << stringify_args(t) << "\n"; -#endif - if (is_trivially_serializable<T>::value) { - m_stream.write(reinterpret_cast<const char *>(&t), sizeof(T)); - } else { - unsigned idx = m_tracker.GetIndexForObject(&t); - Serialize(idx); - } - } - - void Serialize(const void *v) { - // FIXME: Support void* - } - - void Serialize(void *v) { - // FIXME: Support void* - } - - void Serialize(const char *t) { -#ifdef LLDB_REPRO_INSTR_TRACE - this_thread_id() << "Serializing with " << LLVM_PRETTY_FUNCTION << " -> " - << stringify_args(t) << "\n"; -#endif - const size_t size = t ? strlen(t) : std::numeric_limits<size_t>::max(); - Serialize(size); - if (t) { - m_stream << t; - m_stream.write(0x0); - } - } - - void Serialize(const char **t) { - size_t size = 0; - if (!t) { - Serialize(size); - return; - } - - // Compute the size of the array. - const char *const *temp = t; - while (*temp++) - size++; - Serialize(size); - - // Serialize the content of the array. - while (*t) - Serialize(*t++); - } - - /// Serialization stream. - llvm::raw_ostream &m_stream; - - /// Mapping of objects to indices. - ObjectToIndex m_tracker; -}; // namespace repro - -class InstrumentationData { -public: - Serializer *GetSerializer() { return m_serializer; } - Deserializer *GetDeserializer() { return m_deserializer; } - Registry &GetRegistry() { return *m_registry; } - - operator bool() { - return (m_serializer != nullptr || m_deserializer != nullptr) && - m_registry != nullptr; - } - - static void Initialize(Serializer &serializer, Registry ®istry); - static void Initialize(Deserializer &serializer, Registry ®istry); - static InstrumentationData &Instance(); - -protected: - friend llvm::optional_detail::OptionalStorage<InstrumentationData, true>; - friend llvm::Optional<InstrumentationData>; - - InstrumentationData() = default; - InstrumentationData(Serializer &serializer, Registry ®istry) - : m_serializer(&serializer), m_deserializer(nullptr), - m_registry(®istry) {} - InstrumentationData(Deserializer &deserializer, Registry ®istry) - : m_serializer(nullptr), m_deserializer(&deserializer), - m_registry(®istry) {} - -private: - static llvm::Optional<InstrumentationData> &InstanceImpl(); - - Serializer *m_serializer = nullptr; - Deserializer *m_deserializer = nullptr; - Registry *m_registry = nullptr; -}; - -struct EmptyArg {}; - -/// RAII object that records function invocations and their return value. -/// -/// API calls are only captured when the API boundary is crossed. Once we're in -/// the API layer, and another API function is called, it doesn't need to be -/// recorded. -/// -/// When a call is recored, its result is always recorded as well, even if the -/// function returns a void. For functions that return by value, RecordResult -/// should be used. Otherwise a sentinel value (0) will be serialized. -/// -/// Because of the functional overlap between logging and recording API calls, -/// this class is also used for logging. -class Recorder { -public: - Recorder(); - Recorder(llvm::StringRef pretty_func, std::string &&pretty_args = {}); - ~Recorder(); - - /// Records a single function call. - template <typename Result, typename... FArgs, typename... RArgs> - void Record(Serializer &serializer, Registry ®istry, Result (*f)(FArgs...), - const RArgs &... args) { - m_serializer = &serializer; - if (!ShouldCapture()) - return; - - std::lock_guard<std::mutex> lock(g_mutex); - unsigned sequence = GetSequenceNumber(); - unsigned id = registry.GetID(uintptr_t(f)); - -#ifdef LLDB_REPRO_INSTR_TRACE - Log(id); -#endif - - serializer.SerializeAll(sequence); - serializer.SerializeAll(id); - serializer.SerializeAll(args...); - - if (std::is_class<typename std::remove_pointer< - typename std::remove_reference<Result>::type>::type>::value) { - m_result_recorded = false; - } else { - serializer.SerializeAll(sequence); - serializer.SerializeAll(0); - m_result_recorded = true; - } - } - - /// Records a single function call. - template <typename... Args> - void Record(Serializer &serializer, Registry ®istry, void (*f)(Args...), - const Args &... args) { - m_serializer = &serializer; - if (!ShouldCapture()) - return; - - std::lock_guard<std::mutex> lock(g_mutex); - unsigned sequence = GetSequenceNumber(); - unsigned id = registry.GetID(uintptr_t(f)); - -#ifdef LLDB_REPRO_INSTR_TRACE - Log(id); -#endif - - serializer.SerializeAll(sequence); - serializer.SerializeAll(id); - serializer.SerializeAll(args...); - - // Record result. - serializer.SerializeAll(sequence); - serializer.SerializeAll(0); - m_result_recorded = true; - } - - /// Specializations for the no-argument methods. These are passed an empty - /// dummy argument so the same variadic macro can be used. These methods - /// strip the arguments before forwarding them. - template <typename Result> - void Record(Serializer &serializer, Registry ®istry, Result (*f)(), - const EmptyArg &arg) { - Record(serializer, registry, f); - } - - /// Record the result of a function call. - template <typename Result> - Result RecordResult(Result &&r, bool update_boundary) { - // When recording the result from the LLDB_RECORD_RESULT macro, we need to - // update the boundary so we capture the copy constructor. However, when - // called to record the this pointer of the (copy) constructor, the - // boundary should not be toggled, because it is called from the - // LLDB_RECORD_CONSTRUCTOR macro, which might be followed by other API - // calls. - if (update_boundary) - UpdateBoundary(); - if (m_serializer && ShouldCapture()) { - std::lock_guard<std::mutex> lock(g_mutex); - assert(!m_result_recorded); - m_serializer->SerializeAll(GetSequenceNumber()); - m_serializer->SerializeAll(r); - m_result_recorded = true; - } - return std::forward<Result>(r); - } - - template <typename Result, typename T> - Result Replay(Deserializer &deserializer, Registry ®istry, uintptr_t addr, - bool update_boundary) { - deserializer.SetExpectedSequence(deserializer.Deserialize<unsigned>()); - unsigned actual_id = registry.GetID(addr); - unsigned id = deserializer.Deserialize<unsigned>(); - registry.CheckID(id, actual_id); - return ReplayResult<Result>( - static_cast<DefaultReplayer<T> *>(registry.GetReplayer(id)) - ->Replay(deserializer), - update_boundary); - } - - void Replay(Deserializer &deserializer, Registry ®istry, uintptr_t addr) { - deserializer.SetExpectedSequence(deserializer.Deserialize<unsigned>()); - unsigned actual_id = registry.GetID(addr); - unsigned id = deserializer.Deserialize<unsigned>(); - registry.CheckID(id, actual_id); - registry.GetReplayer(id)->operator()(deserializer); - } - - template <typename Result> - Result ReplayResult(Result &&r, bool update_boundary) { - if (update_boundary) - UpdateBoundary(); - return std::forward<Result>(r); - } - - bool ShouldCapture() { return m_local_boundary; } - - /// Mark the current thread as a private thread and pretend that everything - /// on this thread is behind happening behind the API boundary. - static void PrivateThread(); - -private: - static unsigned GetNextSequenceNumber() { return g_sequence++; } - unsigned GetSequenceNumber() const; - - template <typename T> friend struct replay; - void UpdateBoundary(); - -#ifdef LLDB_REPRO_INSTR_TRACE - void Log(unsigned id) { - this_thread_id() << "Recording " << id << ": " << m_pretty_func << " (" - << m_pretty_args << ")\n"; - } -#endif - - Serializer *m_serializer = nullptr; - - /// Pretty function for logging. - llvm::StringRef m_pretty_func; - std::string m_pretty_args; - - /// Whether this function call was the one crossing the API boundary. - bool m_local_boundary = false; - - /// Whether the return value was recorded explicitly. - bool m_result_recorded = true; - - /// The sequence number for this pair of function and result. - unsigned m_sequence; - - /// Global mutex to protect concurrent access. - static std::mutex g_mutex; - - /// Unique, monotonically increasing sequence number. - static std::atomic<unsigned> g_sequence; -}; - -/// To be used as the "Runtime ID" of a constructor. It also invokes the -/// constructor when called. -template <typename Signature> struct construct; -template <typename Class, typename... Args> struct construct<Class(Args...)> { - static Class *handle(lldb_private::repro::InstrumentationData data, - lldb_private::repro::Recorder &recorder, Class *c, - const EmptyArg &) { - return handle(data, recorder, c); - } - - static Class *handle(lldb_private::repro::InstrumentationData data, - lldb_private::repro::Recorder &recorder, Class *c, - Args... args) { - if (!data) - return nullptr; - - if (Serializer *serializer = data.GetSerializer()) { - recorder.Record(*serializer, data.GetRegistry(), &record, args...); - recorder.RecordResult(c, false); - } else if (Deserializer *deserializer = data.GetDeserializer()) { - if (recorder.ShouldCapture()) { - replay(recorder, *deserializer, data.GetRegistry()); - } - } - - return nullptr; - } - - static Class *record(Args... args) { return new Class(args...); } - - static Class *replay(Recorder &recorder, Deserializer &deserializer, - Registry ®istry) { - return recorder.Replay<Class *, Class *(Args...)>( - deserializer, registry, uintptr_t(&record), false); - } -}; - -/// To be used as the "Runtime ID" of a member function. It also invokes the -/// member function when called. -template <typename Signature> struct invoke; -template <typename Result, typename Class, typename... Args> -struct invoke<Result (Class::*)(Args...)> { - template <Result (Class::*m)(Args...)> struct method { - static Result record(Class *c, Args... args) { return (c->*m)(args...); } - - static Result replay(Recorder &recorder, Deserializer &deserializer, - Registry ®istry) { - return recorder.Replay<Result, Result(Class *, Args...)>( - deserializer, registry, uintptr_t(&record), true); - } - }; -}; - -template <typename Class, typename... Args> -struct invoke<void (Class::*)(Args...)> { - template <void (Class::*m)(Args...)> struct method { - static void record(Class *c, Args... args) { (c->*m)(args...); } - static void replay(Recorder &recorder, Deserializer &deserializer, - Registry ®istry) { - recorder.Replay(deserializer, registry, uintptr_t(&record)); - } - }; -}; - -template <typename Result, typename Class, typename... Args> -struct invoke<Result (Class::*)(Args...) const> { - template <Result (Class::*m)(Args...) const> struct method { - static Result record(Class *c, Args... args) { return (c->*m)(args...); } - static Result replay(Recorder &recorder, Deserializer &deserializer, - Registry ®istry) { - return recorder.Replay<Result, Result(Class *, Args...)>( - deserializer, registry, uintptr_t(&record), true); - } - }; -}; - -template <typename Class, typename... Args> -struct invoke<void (Class::*)(Args...) const> { - template <void (Class::*m)(Args...) const> struct method { - static void record(Class *c, Args... args) { return (c->*m)(args...); } - static void replay(Recorder &recorder, Deserializer &deserializer, - Registry ®istry) { - recorder.Replay(deserializer, registry, uintptr_t(&record)); - } - }; -}; - -template <typename Signature> struct replay; - -template <typename Result, typename Class, typename... Args> -struct replay<Result (Class::*)(Args...)> { - template <Result (Class::*m)(Args...)> struct method {}; -}; - -template <typename Result, typename... Args> -struct invoke<Result (*)(Args...)> { - template <Result (*m)(Args...)> struct method { - static Result record(Args... args) { return (*m)(args...); } - static Result replay(Recorder &recorder, Deserializer &deserializer, - Registry ®istry) { - return recorder.Replay<Result, Result(Args...)>(deserializer, registry, - uintptr_t(&record), true); - } - }; -}; - -template <typename... Args> struct invoke<void (*)(Args...)> { - template <void (*m)(Args...)> struct method { - static void record(Args... args) { return (*m)(args...); } - static void replay(Recorder &recorder, Deserializer &deserializer, - Registry ®istry) { - recorder.Replay(deserializer, registry, uintptr_t(&record)); - } - }; -}; - -/// Special handling for functions returning strings as (char*, size_t). -/// { - -/// For inline replay, we ignore the arguments and use the ones from the -/// serializer instead. This doesn't work for methods that use a char* and a -/// size to return a string. For one these functions have a custom replayer to -/// prevent override the input buffer. Furthermore, the template-generated -/// deserialization is not easy to hook into. -/// -/// The specializations below hand-implement the serialization logic for the -/// inline replay. Instead of using the function from the registry, it uses the -/// one passed into the macro. -template <typename Signature> struct invoke_char_ptr; -template <typename Result, typename Class, typename... Args> -struct invoke_char_ptr<Result (Class::*)(Args...) const> { - template <Result (Class::*m)(Args...) const> struct method { - static Result record(Class *c, char *s, size_t l) { - char *buffer = reinterpret_cast<char *>(calloc(l, sizeof(char))); - return (c->*m)(buffer, l); - } - - static Result replay(Recorder &recorder, Deserializer &deserializer, - Registry ®istry, char *str) { - deserializer.SetExpectedSequence(deserializer.Deserialize<unsigned>()); - deserializer.Deserialize<unsigned>(); - Class *c = deserializer.Deserialize<Class *>(); - deserializer.Deserialize<const char *>(); - size_t l = deserializer.Deserialize<size_t>(); - return recorder.ReplayResult( - std::move(deserializer.HandleReplayResult((c->*m)(str, l))), true); - } - }; -}; - -template <typename Signature> struct invoke_char_ptr; -template <typename Result, typename Class, typename... Args> -struct invoke_char_ptr<Result (Class::*)(Args...)> { - template <Result (Class::*m)(Args...)> struct method { - static Result record(Class *c, char *s, size_t l) { - char *buffer = reinterpret_cast<char *>(calloc(l, sizeof(char))); - return (c->*m)(buffer, l); - } - - static Result replay(Recorder &recorder, Deserializer &deserializer, - Registry ®istry, char *str) { - deserializer.SetExpectedSequence(deserializer.Deserialize<unsigned>()); - deserializer.Deserialize<unsigned>(); - Class *c = deserializer.Deserialize<Class *>(); - deserializer.Deserialize<const char *>(); - size_t l = deserializer.Deserialize<size_t>(); - return recorder.ReplayResult( - std::move(deserializer.HandleReplayResult((c->*m)(str, l))), true); - } - }; -}; - -template <typename Result, typename... Args> -struct invoke_char_ptr<Result (*)(Args...)> { - template <Result (*m)(Args...)> struct method { - static Result record(char *s, size_t l) { - char *buffer = reinterpret_cast<char *>(calloc(l, sizeof(char))); - return (*m)(buffer, l); - } - - static Result replay(Recorder &recorder, Deserializer &deserializer, - Registry ®istry, char *str) { - deserializer.SetExpectedSequence(deserializer.Deserialize<unsigned>()); - deserializer.Deserialize<unsigned>(); - deserializer.Deserialize<const char *>(); - size_t l = deserializer.Deserialize<size_t>(); - return recorder.ReplayResult( - std::move(deserializer.HandleReplayResult((*m)(str, l))), true); - } - }; -}; -/// } - -} // namespace repro -} // namespace lldb_private - -#endif // LLDB_UTILITY_REPRODUCERINSTRUMENTATION_H diff --git a/lldb/include/lldb/Utility/ReproducerProvider.h b/lldb/include/lldb/Utility/ReproducerProvider.h index db7378069a87..56aadf92369e 100644 --- a/lldb/include/lldb/Utility/ReproducerProvider.h +++ b/lldb/include/lldb/Utility/ReproducerProvider.h @@ -222,8 +222,7 @@ public: /// Provider for mapping UUIDs to symbol and executable files. class SymbolFileProvider : public Provider<SymbolFileProvider> { public: - SymbolFileProvider(const FileSpec &directory) - : Provider(directory), m_symbol_files() {} + SymbolFileProvider(const FileSpec &directory) : Provider(directory) {} void AddSymbolFile(const UUID *uuid, const FileSpec &module_path, const FileSpec &symbol_path); diff --git a/lldb/include/lldb/Utility/SharedCluster.h b/lldb/include/lldb/Utility/SharedCluster.h index 375c1c131a09..b3f41dbaa64b 100644 --- a/lldb/include/lldb/Utility/SharedCluster.h +++ b/lldb/include/lldb/Utility/SharedCluster.h @@ -48,7 +48,7 @@ public: } private: - ClusterManager() : m_objects(), m_mutex() {} + ClusterManager() : m_objects() {} llvm::SmallVector<T *, 16> m_objects; std::mutex m_mutex; diff --git a/lldb/include/lldb/Utility/StreamTee.h b/lldb/include/lldb/Utility/StreamTee.h index b5d3b9679e91..5695586171f3 100644 --- a/lldb/include/lldb/Utility/StreamTee.h +++ b/lldb/include/lldb/Utility/StreamTee.h @@ -19,18 +19,15 @@ namespace lldb_private { class StreamTee : public Stream { public: - StreamTee(bool colors = false) - : Stream(colors), m_streams_mutex(), m_streams() {} + StreamTee(bool colors = false) : Stream(colors) {} - StreamTee(lldb::StreamSP &stream_sp) - : Stream(), m_streams_mutex(), m_streams() { + StreamTee(lldb::StreamSP &stream_sp) { // No need to lock mutex during construction if (stream_sp) m_streams.push_back(stream_sp); } - StreamTee(lldb::StreamSP &stream_sp, lldb::StreamSP &stream_2_sp) - : Stream(), m_streams_mutex(), m_streams() { + StreamTee(lldb::StreamSP &stream_sp, lldb::StreamSP &stream_2_sp) { // No need to lock mutex during construction if (stream_sp) m_streams.push_back(stream_sp); @@ -38,8 +35,7 @@ public: m_streams.push_back(stream_2_sp); } - StreamTee(const StreamTee &rhs) - : Stream(rhs), m_streams_mutex(), m_streams() { + StreamTee(const StreamTee &rhs) : Stream(rhs) { // Don't copy until we lock down "rhs" std::lock_guard<std::recursive_mutex> guard(rhs.m_streams_mutex); m_streams = rhs.m_streams; diff --git a/lldb/include/lldb/Utility/StringExtractorGDBRemote.h b/lldb/include/lldb/Utility/StringExtractorGDBRemote.h index 1712c113d396..459adae04452 100644 --- a/lldb/include/lldb/Utility/StringExtractorGDBRemote.h +++ b/lldb/include/lldb/Utility/StringExtractorGDBRemote.h @@ -23,7 +23,7 @@ public: typedef bool (*ResponseValidatorCallback)( void *baton, const StringExtractorGDBRemote &response); - StringExtractorGDBRemote() : StringExtractor() {} + StringExtractorGDBRemote() {} StringExtractorGDBRemote(llvm::StringRef str) : StringExtractor(str), m_validator(nullptr) {} diff --git a/lldb/include/lldb/Utility/StringList.h b/lldb/include/lldb/Utility/StringList.h index 70f4654a6ac9..1357cf17173a 100644 --- a/lldb/include/lldb/Utility/StringList.h +++ b/lldb/include/lldb/Utility/StringList.h @@ -10,6 +10,7 @@ #define LLDB_UTILITY_STRINGLIST_H #include "llvm/ADT/StringRef.h" +#include "llvm/ADT/Twine.h" #include <cstddef> #include <string> @@ -44,6 +45,8 @@ public: void AppendString(llvm::StringRef str); + void AppendString(const llvm::Twine &str); + void AppendList(const char **strv, int strc); void AppendList(StringList strings); diff --git a/lldb/include/lldb/Utility/StructuredData.h b/lldb/include/lldb/Utility/StructuredData.h index c1d136db1c2e..11eee92f8c3b 100644 --- a/lldb/include/lldb/Utility/StructuredData.h +++ b/lldb/include/lldb/Utility/StructuredData.h @@ -351,10 +351,9 @@ public: class Dictionary : public Object { public: - Dictionary() : Object(lldb::eStructuredDataTypeDictionary), m_dict() {} + Dictionary() : Object(lldb::eStructuredDataTypeDictionary) {} - Dictionary(ObjectSP obj_sp) - : Object(lldb::eStructuredDataTypeDictionary), m_dict() { + Dictionary(ObjectSP obj_sp) : Object(lldb::eStructuredDataTypeDictionary) { if (!obj_sp || obj_sp->GetType() != lldb::eStructuredDataTypeDictionary) { SetType(lldb::eStructuredDataTypeInvalid); return; diff --git a/lldb/include/lldb/Utility/UserIDResolver.h b/lldb/include/lldb/Utility/UserIDResolver.h index e0f7b69cc075..15afafd65a1a 100644 --- a/lldb/include/lldb/Utility/UserIDResolver.h +++ b/lldb/include/lldb/Utility/UserIDResolver.h @@ -10,6 +10,7 @@ #define LLDB_UTILITY_USERIDRESOLVER_H #include "llvm/ADT/DenseMap.h" +#include "llvm/ADT/Optional.h" #include "llvm/ADT/StringRef.h" #include <mutex> diff --git a/lldb/include/lldb/lldb-defines.h b/lldb/include/lldb/lldb-defines.h index 4bf01c3f86c6..339071bbfc31 100644 --- a/lldb/include/lldb/lldb-defines.h +++ b/lldb/include/lldb/lldb-defines.h @@ -11,18 +11,6 @@ #include "lldb/lldb-types.h" -#if defined(_WIN32) -#if defined(EXPORT_LIBLLDB) -#define LLDB_API __declspec(dllexport) -#elif defined(IMPORT_LIBLLDB) -#define LLDB_API __declspec(dllimport) -#else -#define LLDB_API -#endif -#else // defined (_WIN32) -#define LLDB_API -#endif - #if !defined(INT32_MAX) #define INT32_MAX 2147483647 #endif diff --git a/lldb/include/lldb/module.modulemap b/lldb/include/lldb/module.modulemap index c0d467a6505e..303d6b15e808 100644 --- a/lldb/include/lldb/module.modulemap +++ b/lldb/include/lldb/module.modulemap @@ -2,7 +2,7 @@ module lldb_API { requires cplusplus - textual header "Utility/ReproducerInstrumentation.h" + textual header "Utility/Instrumentation.h" umbrella "API" module * { export * } diff --git a/lldb/source/API/SBAddress.cpp b/lldb/source/API/SBAddress.cpp index 7c102270a87c..e519f0bcc83c 100644 --- a/lldb/source/API/SBAddress.cpp +++ b/lldb/source/API/SBAddress.cpp @@ -7,7 +7,6 @@ //===----------------------------------------------------------------------===// #include "lldb/API/SBAddress.h" -#include "SBReproducerPrivate.h" #include "Utils.h" #include "lldb/API/SBProcess.h" #include "lldb/API/SBSection.h" @@ -16,35 +15,34 @@ #include "lldb/Core/Module.h" #include "lldb/Symbol/LineEntry.h" #include "lldb/Target/Target.h" +#include "lldb/Utility/Instrumentation.h" #include "lldb/Utility/StreamString.h" using namespace lldb; using namespace lldb_private; SBAddress::SBAddress() : m_opaque_up(new Address()) { - LLDB_RECORD_CONSTRUCTOR_NO_ARGS(SBAddress); + LLDB_INSTRUMENT_VA(this); } SBAddress::SBAddress(const Address &address) : m_opaque_up(std::make_unique<Address>(address)) {} SBAddress::SBAddress(const SBAddress &rhs) : m_opaque_up(new Address()) { - LLDB_RECORD_CONSTRUCTOR(SBAddress, (const lldb::SBAddress &), rhs); + LLDB_INSTRUMENT_VA(this, rhs); m_opaque_up = clone(rhs.m_opaque_up); } SBAddress::SBAddress(lldb::SBSection section, lldb::addr_t offset) : m_opaque_up(new Address(section.GetSP(), offset)) { - LLDB_RECORD_CONSTRUCTOR(SBAddress, (lldb::SBSection, lldb::addr_t), section, - offset); + LLDB_INSTRUMENT_VA(this, section, offset); } // Create an address by resolving a load address using the supplied target SBAddress::SBAddress(lldb::addr_t load_addr, lldb::SBTarget &target) : m_opaque_up(new Address()) { - LLDB_RECORD_CONSTRUCTOR(SBAddress, (lldb::addr_t, lldb::SBTarget &), - load_addr, target); + LLDB_INSTRUMENT_VA(this, load_addr, target); SetLoadAddress(load_addr, target); } @@ -52,12 +50,11 @@ SBAddress::SBAddress(lldb::addr_t load_addr, lldb::SBTarget &target) SBAddress::~SBAddress() = default; const SBAddress &SBAddress::operator=(const SBAddress &rhs) { - LLDB_RECORD_METHOD(const lldb::SBAddress &, - SBAddress, operator=,(const lldb::SBAddress &), rhs); + LLDB_INSTRUMENT_VA(this, rhs); if (this != &rhs) m_opaque_up = clone(rhs.m_opaque_up); - return LLDB_RECORD_RESULT(*this); + return *this; } bool lldb::operator==(const SBAddress &lhs, const SBAddress &rhs) { @@ -67,31 +64,29 @@ bool lldb::operator==(const SBAddress &lhs, const SBAddress &rhs) { } bool SBAddress::operator!=(const SBAddress &rhs) const { - LLDB_RECORD_METHOD_CONST(bool, SBAddress, operator!=,(const SBAddress &), - &rhs); + LLDB_INSTRUMENT_VA(this, rhs); return !(*this == rhs); } bool SBAddress::IsValid() const { - LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBAddress, IsValid); + LLDB_INSTRUMENT_VA(this); return this->operator bool(); } SBAddress::operator bool() const { - LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBAddress, operator bool); + LLDB_INSTRUMENT_VA(this); return m_opaque_up != nullptr && m_opaque_up->IsValid(); } void SBAddress::Clear() { - LLDB_RECORD_METHOD_NO_ARGS(void, SBAddress, Clear); + LLDB_INSTRUMENT_VA(this); m_opaque_up = std::make_unique<Address>(); } void SBAddress::SetAddress(lldb::SBSection section, lldb::addr_t offset) { - LLDB_RECORD_METHOD(void, SBAddress, SetAddress, - (lldb::SBSection, lldb::addr_t), section, offset); + LLDB_INSTRUMENT_VA(this, section, offset); Address &addr = ref(); addr.SetSection(section.GetSP()); @@ -101,7 +96,7 @@ void SBAddress::SetAddress(lldb::SBSection section, lldb::addr_t offset) { void SBAddress::SetAddress(const Address &address) { ref() = address; } lldb::addr_t SBAddress::GetFileAddress() const { - LLDB_RECORD_METHOD_CONST_NO_ARGS(lldb::addr_t, SBAddress, GetFileAddress); + LLDB_INSTRUMENT_VA(this); if (m_opaque_up->IsValid()) return m_opaque_up->GetFileAddress(); @@ -110,8 +105,7 @@ lldb::addr_t SBAddress::GetFileAddress() const { } lldb::addr_t SBAddress::GetLoadAddress(const SBTarget &target) const { - LLDB_RECORD_METHOD_CONST(lldb::addr_t, SBAddress, GetLoadAddress, - (const lldb::SBTarget &), target); + LLDB_INSTRUMENT_VA(this, target); lldb::addr_t addr = LLDB_INVALID_ADDRESS; TargetSP target_sp(target.GetSP()); @@ -126,8 +120,7 @@ lldb::addr_t SBAddress::GetLoadAddress(const SBTarget &target) const { } void SBAddress::SetLoadAddress(lldb::addr_t load_addr, lldb::SBTarget &target) { - LLDB_RECORD_METHOD(void, SBAddress, SetLoadAddress, - (lldb::addr_t, lldb::SBTarget &), load_addr, target); + LLDB_INSTRUMENT_VA(this, load_addr, target); // Create the address object if we don't already have one ref(); @@ -144,7 +137,7 @@ void SBAddress::SetLoadAddress(lldb::addr_t load_addr, lldb::SBTarget &target) { } bool SBAddress::OffsetAddress(addr_t offset) { - LLDB_RECORD_METHOD(bool, SBAddress, OffsetAddress, (lldb::addr_t), offset); + LLDB_INSTRUMENT_VA(this, offset); if (m_opaque_up->IsValid()) { addr_t addr_offset = m_opaque_up->GetOffset(); @@ -157,16 +150,16 @@ bool SBAddress::OffsetAddress(addr_t offset) { } lldb::SBSection SBAddress::GetSection() { - LLDB_RECORD_METHOD_NO_ARGS(lldb::SBSection, SBAddress, GetSection); + LLDB_INSTRUMENT_VA(this); lldb::SBSection sb_section; if (m_opaque_up->IsValid()) sb_section.SetSP(m_opaque_up->GetSection()); - return LLDB_RECORD_RESULT(sb_section); + return sb_section; } lldb::addr_t SBAddress::GetOffset() { - LLDB_RECORD_METHOD_NO_ARGS(lldb::addr_t, SBAddress, GetOffset); + LLDB_INSTRUMENT_VA(this); if (m_opaque_up->IsValid()) return m_opaque_up->GetOffset(); @@ -193,8 +186,7 @@ const Address &SBAddress::ref() const { Address *SBAddress::get() { return m_opaque_up.get(); } bool SBAddress::GetDescription(SBStream &description) { - LLDB_RECORD_METHOD(bool, SBAddress, GetDescription, (lldb::SBStream &), - description); + LLDB_INSTRUMENT_VA(this, description); // Call "ref()" on the stream to make sure it creates a backing stream in // case there isn't one already... @@ -209,63 +201,62 @@ bool SBAddress::GetDescription(SBStream &description) { } SBModule SBAddress::GetModule() { - LLDB_RECORD_METHOD_NO_ARGS(lldb::SBModule, SBAddress, GetModule); + LLDB_INSTRUMENT_VA(this); SBModule sb_module; if (m_opaque_up->IsValid()) sb_module.SetSP(m_opaque_up->GetModule()); - return LLDB_RECORD_RESULT(sb_module); + return sb_module; } SBSymbolContext SBAddress::GetSymbolContext(uint32_t resolve_scope) { - LLDB_RECORD_METHOD(lldb::SBSymbolContext, SBAddress, GetSymbolContext, - (uint32_t), resolve_scope); + LLDB_INSTRUMENT_VA(this, resolve_scope); SBSymbolContext sb_sc; SymbolContextItem scope = static_cast<SymbolContextItem>(resolve_scope); if (m_opaque_up->IsValid()) m_opaque_up->CalculateSymbolContext(&sb_sc.ref(), scope); - return LLDB_RECORD_RESULT(sb_sc); + return sb_sc; } SBCompileUnit SBAddress::GetCompileUnit() { - LLDB_RECORD_METHOD_NO_ARGS(lldb::SBCompileUnit, SBAddress, GetCompileUnit); + LLDB_INSTRUMENT_VA(this); SBCompileUnit sb_comp_unit; if (m_opaque_up->IsValid()) sb_comp_unit.reset(m_opaque_up->CalculateSymbolContextCompileUnit()); - return LLDB_RECORD_RESULT(sb_comp_unit); + return sb_comp_unit; } SBFunction SBAddress::GetFunction() { - LLDB_RECORD_METHOD_NO_ARGS(lldb::SBFunction, SBAddress, GetFunction); + LLDB_INSTRUMENT_VA(this); SBFunction sb_function; if (m_opaque_up->IsValid()) sb_function.reset(m_opaque_up->CalculateSymbolContextFunction()); - return LLDB_RECORD_RESULT(sb_function); + return sb_function; } SBBlock SBAddress::GetBlock() { - LLDB_RECORD_METHOD_NO_ARGS(lldb::SBBlock, SBAddress, GetBlock); + LLDB_INSTRUMENT_VA(this); SBBlock sb_block; if (m_opaque_up->IsValid()) sb_block.SetPtr(m_opaque_up->CalculateSymbolContextBlock()); - return LLDB_RECORD_RESULT(sb_block); + return sb_block; } SBSymbol SBAddress::GetSymbol() { - LLDB_RECORD_METHOD_NO_ARGS(lldb::SBSymbol, SBAddress, GetSymbol); + LLDB_INSTRUMENT_VA(this); SBSymbol sb_symbol; if (m_opaque_up->IsValid()) sb_symbol.reset(m_opaque_up->CalculateSymbolContextSymbol()); - return LLDB_RECORD_RESULT(sb_symbol); + return sb_symbol; } SBLineEntry SBAddress::GetLineEntry() { - LLDB_RECORD_METHOD_NO_ARGS(lldb::SBLineEntry, SBAddress, GetLineEntry); + LLDB_INSTRUMENT_VA(this); SBLineEntry sb_line_entry; if (m_opaque_up->IsValid()) { @@ -273,45 +264,5 @@ SBLineEntry SBAddress::GetLineEntry() { if (m_opaque_up->CalculateSymbolContextLineEntry(line_entry)) sb_line_entry.SetLineEntry(line_entry); } - return LLDB_RECORD_RESULT(sb_line_entry); -} - -namespace lldb_private { -namespace repro { - -template <> -void RegisterMethods<SBAddress>(Registry &R) { - LLDB_REGISTER_CONSTRUCTOR(SBAddress, ()); - LLDB_REGISTER_CONSTRUCTOR(SBAddress, (const lldb::SBAddress &)); - LLDB_REGISTER_CONSTRUCTOR(SBAddress, (lldb::SBSection, lldb::addr_t)); - LLDB_REGISTER_CONSTRUCTOR(SBAddress, (lldb::addr_t, lldb::SBTarget &)); - LLDB_REGISTER_METHOD(const lldb::SBAddress &, - SBAddress, operator=,(const lldb::SBAddress &)); - LLDB_REGISTER_METHOD_CONST(bool, - SBAddress, operator!=,(const lldb::SBAddress &)); - LLDB_REGISTER_METHOD_CONST(bool, SBAddress, IsValid, ()); - LLDB_REGISTER_METHOD_CONST(bool, SBAddress, operator bool, ()); - LLDB_REGISTER_METHOD(void, SBAddress, Clear, ()); - LLDB_REGISTER_METHOD(void, SBAddress, SetAddress, - (lldb::SBSection, lldb::addr_t)); - LLDB_REGISTER_METHOD_CONST(lldb::addr_t, SBAddress, GetFileAddress, ()); - LLDB_REGISTER_METHOD_CONST(lldb::addr_t, SBAddress, GetLoadAddress, - (const lldb::SBTarget &)); - LLDB_REGISTER_METHOD(void, SBAddress, SetLoadAddress, - (lldb::addr_t, lldb::SBTarget &)); - LLDB_REGISTER_METHOD(bool, SBAddress, OffsetAddress, (lldb::addr_t)); - LLDB_REGISTER_METHOD(lldb::SBSection, SBAddress, GetSection, ()); - LLDB_REGISTER_METHOD(lldb::addr_t, SBAddress, GetOffset, ()); - LLDB_REGISTER_METHOD(bool, SBAddress, GetDescription, (lldb::SBStream &)); - LLDB_REGISTER_METHOD(lldb::SBModule, SBAddress, GetModule, ()); - LLDB_REGISTER_METHOD(lldb::SBSymbolContext, SBAddress, GetSymbolContext, - (uint32_t)); - LLDB_REGISTER_METHOD(lldb::SBCompileUnit, SBAddress, GetCompileUnit, ()); - LLDB_REGISTER_METHOD(lldb::SBFunction, SBAddress, GetFunction, ()); - LLDB_REGISTER_METHOD(lldb::SBBlock, SBAddress, GetBlock, ()); - LLDB_REGISTER_METHOD(lldb::SBSymbol, SBAddress, GetSymbol, ()); - LLDB_REGISTER_METHOD(lldb::SBLineEntry, SBAddress, GetLineEntry, ()); -} - -} + return sb_line_entry; } diff --git a/lldb/source/API/SBAttachInfo.cpp b/lldb/source/API/SBAttachInfo.cpp index b21589cf2708..edb4f7104d41 100644 --- a/lldb/source/API/SBAttachInfo.cpp +++ b/lldb/source/API/SBAttachInfo.cpp @@ -7,29 +7,29 @@ //===----------------------------------------------------------------------===// #include "lldb/API/SBAttachInfo.h" -#include "SBReproducerPrivate.h" #include "Utils.h" #include "lldb/API/SBFileSpec.h" #include "lldb/API/SBListener.h" #include "lldb/Target/Process.h" +#include "lldb/Utility/Instrumentation.h" using namespace lldb; using namespace lldb_private; SBAttachInfo::SBAttachInfo() : m_opaque_sp(new ProcessAttachInfo()) { - LLDB_RECORD_CONSTRUCTOR_NO_ARGS(SBAttachInfo); + LLDB_INSTRUMENT_VA(this); } SBAttachInfo::SBAttachInfo(lldb::pid_t pid) : m_opaque_sp(new ProcessAttachInfo()) { - LLDB_RECORD_CONSTRUCTOR(SBAttachInfo, (lldb::pid_t), pid); + LLDB_INSTRUMENT_VA(this, pid); m_opaque_sp->SetProcessID(pid); } SBAttachInfo::SBAttachInfo(const char *path, bool wait_for) : m_opaque_sp(new ProcessAttachInfo()) { - LLDB_RECORD_CONSTRUCTOR(SBAttachInfo, (const char *, bool), path, wait_for); + LLDB_INSTRUMENT_VA(this, path, wait_for); if (path && path[0]) m_opaque_sp->GetExecutableFile().SetFile(path, FileSpec::Style::native); @@ -38,8 +38,7 @@ SBAttachInfo::SBAttachInfo(const char *path, bool wait_for) SBAttachInfo::SBAttachInfo(const char *path, bool wait_for, bool async) : m_opaque_sp(new ProcessAttachInfo()) { - LLDB_RECORD_CONSTRUCTOR(SBAttachInfo, (const char *, bool, bool), path, - wait_for, async); + LLDB_INSTRUMENT_VA(this, path, wait_for, async); if (path && path[0]) m_opaque_sp->GetExecutableFile().SetFile(path, FileSpec::Style::native); @@ -49,7 +48,7 @@ SBAttachInfo::SBAttachInfo(const char *path, bool wait_for, bool async) SBAttachInfo::SBAttachInfo(const SBAttachInfo &rhs) : m_opaque_sp(new ProcessAttachInfo()) { - LLDB_RECORD_CONSTRUCTOR(SBAttachInfo, (const lldb::SBAttachInfo &), rhs); + LLDB_INSTRUMENT_VA(this, rhs); m_opaque_sp = clone(rhs.m_opaque_sp); } @@ -59,53 +58,51 @@ SBAttachInfo::~SBAttachInfo() = default; lldb_private::ProcessAttachInfo &SBAttachInfo::ref() { return *m_opaque_sp; } SBAttachInfo &SBAttachInfo::operator=(const SBAttachInfo &rhs) { - LLDB_RECORD_METHOD(lldb::SBAttachInfo &, - SBAttachInfo, operator=,(const lldb::SBAttachInfo &), rhs); + LLDB_INSTRUMENT_VA(this, rhs); if (this != &rhs) m_opaque_sp = clone(rhs.m_opaque_sp); - return LLDB_RECORD_RESULT(*this); + return *this; } lldb::pid_t SBAttachInfo::GetProcessID() { - LLDB_RECORD_METHOD_NO_ARGS(lldb::pid_t, SBAttachInfo, GetProcessID); + LLDB_INSTRUMENT_VA(this); return m_opaque_sp->GetProcessID(); } void SBAttachInfo::SetProcessID(lldb::pid_t pid) { - LLDB_RECORD_METHOD(void, SBAttachInfo, SetProcessID, (lldb::pid_t), pid); + LLDB_INSTRUMENT_VA(this, pid); m_opaque_sp->SetProcessID(pid); } uint32_t SBAttachInfo::GetResumeCount() { - LLDB_RECORD_METHOD_NO_ARGS(uint32_t, SBAttachInfo, GetResumeCount); + LLDB_INSTRUMENT_VA(this); return m_opaque_sp->GetResumeCount(); } void SBAttachInfo::SetResumeCount(uint32_t c) { - LLDB_RECORD_METHOD(void, SBAttachInfo, SetResumeCount, (uint32_t), c); + LLDB_INSTRUMENT_VA(this, c); m_opaque_sp->SetResumeCount(c); } const char *SBAttachInfo::GetProcessPluginName() { - LLDB_RECORD_METHOD_NO_ARGS(const char *, SBAttachInfo, GetProcessPluginName); + LLDB_INSTRUMENT_VA(this); return m_opaque_sp->GetProcessPluginName(); } void SBAttachInfo::SetProcessPluginName(const char *plugin_name) { - LLDB_RECORD_METHOD(void, SBAttachInfo, SetProcessPluginName, (const char *), - plugin_name); + LLDB_INSTRUMENT_VA(this, plugin_name); return m_opaque_sp->SetProcessPluginName(plugin_name); } void SBAttachInfo::SetExecutable(const char *path) { - LLDB_RECORD_METHOD(void, SBAttachInfo, SetExecutable, (const char *), path); + LLDB_INSTRUMENT_VA(this, path); if (path && path[0]) m_opaque_sp->GetExecutableFile().SetFile(path, FileSpec::Style::native); @@ -114,8 +111,7 @@ void SBAttachInfo::SetExecutable(const char *path) { } void SBAttachInfo::SetExecutable(SBFileSpec exe_file) { - LLDB_RECORD_METHOD(void, SBAttachInfo, SetExecutable, (lldb::SBFileSpec), - exe_file); + LLDB_INSTRUMENT_VA(this, exe_file); if (exe_file.IsValid()) m_opaque_sp->GetExecutableFile() = exe_file.ref(); @@ -124,185 +120,134 @@ void SBAttachInfo::SetExecutable(SBFileSpec exe_file) { } bool SBAttachInfo::GetWaitForLaunch() { - LLDB_RECORD_METHOD_NO_ARGS(bool, SBAttachInfo, GetWaitForLaunch); + LLDB_INSTRUMENT_VA(this); return m_opaque_sp->GetWaitForLaunch(); } void SBAttachInfo::SetWaitForLaunch(bool b) { - LLDB_RECORD_METHOD(void, SBAttachInfo, SetWaitForLaunch, (bool), b); + LLDB_INSTRUMENT_VA(this, b); m_opaque_sp->SetWaitForLaunch(b); } void SBAttachInfo::SetWaitForLaunch(bool b, bool async) { - LLDB_RECORD_METHOD(void, SBAttachInfo, SetWaitForLaunch, (bool, bool), b, - async); + LLDB_INSTRUMENT_VA(this, b, async); m_opaque_sp->SetWaitForLaunch(b); m_opaque_sp->SetAsync(async); } bool SBAttachInfo::GetIgnoreExisting() { - LLDB_RECORD_METHOD_NO_ARGS(bool, SBAttachInfo, GetIgnoreExisting); + LLDB_INSTRUMENT_VA(this); return m_opaque_sp->GetIgnoreExisting(); } void SBAttachInfo::SetIgnoreExisting(bool b) { - LLDB_RECORD_METHOD(void, SBAttachInfo, SetIgnoreExisting, (bool), b); + LLDB_INSTRUMENT_VA(this, b); m_opaque_sp->SetIgnoreExisting(b); } uint32_t SBAttachInfo::GetUserID() { - LLDB_RECORD_METHOD_NO_ARGS(uint32_t, SBAttachInfo, GetUserID); + LLDB_INSTRUMENT_VA(this); return m_opaque_sp->GetUserID(); } uint32_t SBAttachInfo::GetGroupID() { - LLDB_RECORD_METHOD_NO_ARGS(uint32_t, SBAttachInfo, GetGroupID); + LLDB_INSTRUMENT_VA(this); return m_opaque_sp->GetGroupID(); } bool SBAttachInfo::UserIDIsValid() { - LLDB_RECORD_METHOD_NO_ARGS(bool, SBAttachInfo, UserIDIsValid); + LLDB_INSTRUMENT_VA(this); return m_opaque_sp->UserIDIsValid(); } bool SBAttachInfo::GroupIDIsValid() { - LLDB_RECORD_METHOD_NO_ARGS(bool, SBAttachInfo, GroupIDIsValid); + LLDB_INSTRUMENT_VA(this); return m_opaque_sp->GroupIDIsValid(); } void SBAttachInfo::SetUserID(uint32_t uid) { - LLDB_RECORD_METHOD(void, SBAttachInfo, SetUserID, (uint32_t), uid); + LLDB_INSTRUMENT_VA(this, uid); m_opaque_sp->SetUserID(uid); } void SBAttachInfo::SetGroupID(uint32_t gid) { - LLDB_RECORD_METHOD(void, SBAttachInfo, SetGroupID, (uint32_t), gid); + LLDB_INSTRUMENT_VA(this, gid); m_opaque_sp->SetGroupID(gid); } uint32_t SBAttachInfo::GetEffectiveUserID() { - LLDB_RECORD_METHOD_NO_ARGS(uint32_t, SBAttachInfo, GetEffectiveUserID); + LLDB_INSTRUMENT_VA(this); return m_opaque_sp->GetEffectiveUserID(); } uint32_t SBAttachInfo::GetEffectiveGroupID() { - LLDB_RECORD_METHOD_NO_ARGS(uint32_t, SBAttachInfo, GetEffectiveGroupID); + LLDB_INSTRUMENT_VA(this); return m_opaque_sp->GetEffectiveGroupID(); } bool SBAttachInfo::EffectiveUserIDIsValid() { - LLDB_RECORD_METHOD_NO_ARGS(bool, SBAttachInfo, EffectiveUserIDIsValid); + LLDB_INSTRUMENT_VA(this); return m_opaque_sp->EffectiveUserIDIsValid(); } bool SBAttachInfo::EffectiveGroupIDIsValid() { - LLDB_RECORD_METHOD_NO_ARGS(bool, SBAttachInfo, EffectiveGroupIDIsValid); + LLDB_INSTRUMENT_VA(this); return m_opaque_sp->EffectiveGroupIDIsValid(); } void SBAttachInfo::SetEffectiveUserID(uint32_t uid) { - LLDB_RECORD_METHOD(void, SBAttachInfo, SetEffectiveUserID, (uint32_t), uid); + LLDB_INSTRUMENT_VA(this, uid); m_opaque_sp->SetEffectiveUserID(uid); } void SBAttachInfo::SetEffectiveGroupID(uint32_t gid) { - LLDB_RECORD_METHOD(void, SBAttachInfo, SetEffectiveGroupID, (uint32_t), gid); + LLDB_INSTRUMENT_VA(this, gid); m_opaque_sp->SetEffectiveGroupID(gid); } lldb::pid_t SBAttachInfo::GetParentProcessID() { - LLDB_RECORD_METHOD_NO_ARGS(lldb::pid_t, SBAttachInfo, GetParentProcessID); + LLDB_INSTRUMENT_VA(this); return m_opaque_sp->GetParentProcessID(); } void SBAttachInfo::SetParentProcessID(lldb::pid_t pid) { - LLDB_RECORD_METHOD(void, SBAttachInfo, SetParentProcessID, (lldb::pid_t), - pid); + LLDB_INSTRUMENT_VA(this, pid); m_opaque_sp->SetParentProcessID(pid); } bool SBAttachInfo::ParentProcessIDIsValid() { - LLDB_RECORD_METHOD_NO_ARGS(bool, SBAttachInfo, ParentProcessIDIsValid); + LLDB_INSTRUMENT_VA(this); return m_opaque_sp->ParentProcessIDIsValid(); } SBListener SBAttachInfo::GetListener() { - LLDB_RECORD_METHOD_NO_ARGS(lldb::SBListener, SBAttachInfo, GetListener); + LLDB_INSTRUMENT_VA(this); - return LLDB_RECORD_RESULT(SBListener(m_opaque_sp->GetListener())); + return SBListener(m_opaque_sp->GetListener()); } void SBAttachInfo::SetListener(SBListener &listener) { - LLDB_RECORD_METHOD(void, SBAttachInfo, SetListener, (lldb::SBListener &), - listener); + LLDB_INSTRUMENT_VA(this, listener); m_opaque_sp->SetListener(listener.GetSP()); } - -namespace lldb_private { -namespace repro { - -template <> -void RegisterMethods<SBAttachInfo>(Registry &R) { - LLDB_REGISTER_CONSTRUCTOR(SBAttachInfo, ()); - LLDB_REGISTER_CONSTRUCTOR(SBAttachInfo, (lldb::pid_t)); - LLDB_REGISTER_CONSTRUCTOR(SBAttachInfo, (const char *, bool)); - LLDB_REGISTER_CONSTRUCTOR(SBAttachInfo, (const char *, bool, bool)); - LLDB_REGISTER_CONSTRUCTOR(SBAttachInfo, (const lldb::SBAttachInfo &)); - LLDB_REGISTER_METHOD(lldb::SBAttachInfo &, - SBAttachInfo, operator=,(const lldb::SBAttachInfo &)); - LLDB_REGISTER_METHOD(lldb::pid_t, SBAttachInfo, GetProcessID, ()); - LLDB_REGISTER_METHOD(void, SBAttachInfo, SetProcessID, (lldb::pid_t)); - LLDB_REGISTER_METHOD(uint32_t, SBAttachInfo, GetResumeCount, ()); - LLDB_REGISTER_METHOD(void, SBAttachInfo, SetResumeCount, (uint32_t)); - LLDB_REGISTER_METHOD(const char *, SBAttachInfo, GetProcessPluginName, ()); - LLDB_REGISTER_METHOD(void, SBAttachInfo, SetProcessPluginName, - (const char *)); - LLDB_REGISTER_METHOD(void, SBAttachInfo, SetExecutable, (const char *)); - LLDB_REGISTER_METHOD(void, SBAttachInfo, SetExecutable, (lldb::SBFileSpec)); - LLDB_REGISTER_METHOD(bool, SBAttachInfo, GetWaitForLaunch, ()); - LLDB_REGISTER_METHOD(void, SBAttachInfo, SetWaitForLaunch, (bool)); - LLDB_REGISTER_METHOD(void, SBAttachInfo, SetWaitForLaunch, (bool, bool)); - LLDB_REGISTER_METHOD(bool, SBAttachInfo, GetIgnoreExisting, ()); - LLDB_REGISTER_METHOD(void, SBAttachInfo, SetIgnoreExisting, (bool)); - LLDB_REGISTER_METHOD(uint32_t, SBAttachInfo, GetUserID, ()); - LLDB_REGISTER_METHOD(uint32_t, SBAttachInfo, GetGroupID, ()); - LLDB_REGISTER_METHOD(bool, SBAttachInfo, UserIDIsValid, ()); - LLDB_REGISTER_METHOD(bool, SBAttachInfo, GroupIDIsValid, ()); - LLDB_REGISTER_METHOD(void, SBAttachInfo, SetUserID, (uint32_t)); - LLDB_REGISTER_METHOD(void, SBAttachInfo, SetGroupID, (uint32_t)); - LLDB_REGISTER_METHOD(uint32_t, SBAttachInfo, GetEffectiveUserID, ()); - LLDB_REGISTER_METHOD(uint32_t, SBAttachInfo, GetEffectiveGroupID, ()); - LLDB_REGISTER_METHOD(bool, SBAttachInfo, EffectiveUserIDIsValid, ()); - LLDB_REGISTER_METHOD(bool, SBAttachInfo, EffectiveGroupIDIsValid, ()); - LLDB_REGISTER_METHOD(void, SBAttachInfo, SetEffectiveUserID, (uint32_t)); - LLDB_REGISTER_METHOD(void, SBAttachInfo, SetEffectiveGroupID, (uint32_t)); - LLDB_REGISTER_METHOD(lldb::pid_t, SBAttachInfo, GetParentProcessID, ()); - LLDB_REGISTER_METHOD(void, SBAttachInfo, SetParentProcessID, (lldb::pid_t)); - LLDB_REGISTER_METHOD(bool, SBAttachInfo, ParentProcessIDIsValid, ()); - LLDB_REGISTER_METHOD(lldb::SBListener, SBAttachInfo, GetListener, ()); - LLDB_REGISTER_METHOD(void, SBAttachInfo, SetListener, (lldb::SBListener &)); -} - -} -} diff --git a/lldb/source/API/SBBlock.cpp b/lldb/source/API/SBBlock.cpp index 5c49053dd972..7d7565340836 100644 --- a/lldb/source/API/SBBlock.cpp +++ b/lldb/source/API/SBBlock.cpp @@ -7,7 +7,6 @@ //===----------------------------------------------------------------------===// #include "lldb/API/SBBlock.h" -#include "SBReproducerPrivate.h" #include "lldb/API/SBAddress.h" #include "lldb/API/SBFileSpec.h" #include "lldb/API/SBFrame.h" @@ -21,41 +20,41 @@ #include "lldb/Symbol/VariableList.h" #include "lldb/Target/StackFrame.h" #include "lldb/Target/Target.h" +#include "lldb/Utility/Instrumentation.h" using namespace lldb; using namespace lldb_private; -SBBlock::SBBlock() { LLDB_RECORD_CONSTRUCTOR_NO_ARGS(SBBlock); } +SBBlock::SBBlock() { LLDB_INSTRUMENT_VA(this); } SBBlock::SBBlock(lldb_private::Block *lldb_object_ptr) : m_opaque_ptr(lldb_object_ptr) {} SBBlock::SBBlock(const SBBlock &rhs) : m_opaque_ptr(rhs.m_opaque_ptr) { - LLDB_RECORD_CONSTRUCTOR(SBBlock, (const lldb::SBBlock &), rhs); + LLDB_INSTRUMENT_VA(this, rhs); } const SBBlock &SBBlock::operator=(const SBBlock &rhs) { - LLDB_RECORD_METHOD(const lldb::SBBlock &, - SBBlock, operator=,(const lldb::SBBlock &), rhs); + LLDB_INSTRUMENT_VA(this, rhs); m_opaque_ptr = rhs.m_opaque_ptr; - return LLDB_RECORD_RESULT(*this); + return *this; } SBBlock::~SBBlock() { m_opaque_ptr = nullptr; } bool SBBlock::IsValid() const { - LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBBlock, IsValid); + LLDB_INSTRUMENT_VA(this); return this->operator bool(); } SBBlock::operator bool() const { - LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBBlock, operator bool); + LLDB_INSTRUMENT_VA(this); return m_opaque_ptr != nullptr; } bool SBBlock::IsInlined() const { - LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBBlock, IsInlined); + LLDB_INSTRUMENT_VA(this); if (m_opaque_ptr) return m_opaque_ptr->GetInlinedFunctionInfo() != nullptr; @@ -63,7 +62,7 @@ bool SBBlock::IsInlined() const { } const char *SBBlock::GetInlinedName() const { - LLDB_RECORD_METHOD_CONST_NO_ARGS(const char *, SBBlock, GetInlinedName); + LLDB_INSTRUMENT_VA(this); if (m_opaque_ptr) { const InlineFunctionInfo *inlined_info = @@ -76,8 +75,7 @@ const char *SBBlock::GetInlinedName() const { } SBFileSpec SBBlock::GetInlinedCallSiteFile() const { - LLDB_RECORD_METHOD_CONST_NO_ARGS(lldb::SBFileSpec, SBBlock, - GetInlinedCallSiteFile); + LLDB_INSTRUMENT_VA(this); SBFileSpec sb_file; if (m_opaque_ptr) { @@ -86,11 +84,11 @@ SBFileSpec SBBlock::GetInlinedCallSiteFile() const { if (inlined_info) sb_file.SetFileSpec(inlined_info->GetCallSite().GetFile()); } - return LLDB_RECORD_RESULT(sb_file); + return sb_file; } uint32_t SBBlock::GetInlinedCallSiteLine() const { - LLDB_RECORD_METHOD_CONST_NO_ARGS(uint32_t, SBBlock, GetInlinedCallSiteLine); + LLDB_INSTRUMENT_VA(this); if (m_opaque_ptr) { const InlineFunctionInfo *inlined_info = @@ -102,7 +100,7 @@ uint32_t SBBlock::GetInlinedCallSiteLine() const { } uint32_t SBBlock::GetInlinedCallSiteColumn() const { - LLDB_RECORD_METHOD_CONST_NO_ARGS(uint32_t, SBBlock, GetInlinedCallSiteColumn); + LLDB_INSTRUMENT_VA(this); if (m_opaque_ptr) { const InlineFunctionInfo *inlined_info = @@ -123,39 +121,39 @@ void SBBlock::AppendVariables(bool can_create, bool get_parent_variables, } SBBlock SBBlock::GetParent() { - LLDB_RECORD_METHOD_NO_ARGS(lldb::SBBlock, SBBlock, GetParent); + LLDB_INSTRUMENT_VA(this); SBBlock sb_block; if (m_opaque_ptr) sb_block.m_opaque_ptr = m_opaque_ptr->GetParent(); - return LLDB_RECORD_RESULT(sb_block); + return sb_block; } lldb::SBBlock SBBlock::GetContainingInlinedBlock() { - LLDB_RECORD_METHOD_NO_ARGS(lldb::SBBlock, SBBlock, GetContainingInlinedBlock); + LLDB_INSTRUMENT_VA(this); SBBlock sb_block; if (m_opaque_ptr) sb_block.m_opaque_ptr = m_opaque_ptr->GetContainingInlinedBlock(); - return LLDB_RECORD_RESULT(sb_block); + return sb_block; } SBBlock SBBlock::GetSibling() { - LLDB_RECORD_METHOD_NO_ARGS(lldb::SBBlock, SBBlock, GetSibling); + LLDB_INSTRUMENT_VA(this); SBBlock sb_block; if (m_opaque_ptr) sb_block.m_opaque_ptr = m_opaque_ptr->GetSibling(); - return LLDB_RECORD_RESULT(sb_block); + return sb_block; } SBBlock SBBlock::GetFirstChild() { - LLDB_RECORD_METHOD_NO_ARGS(lldb::SBBlock, SBBlock, GetFirstChild); + LLDB_INSTRUMENT_VA(this); SBBlock sb_block; if (m_opaque_ptr) sb_block.m_opaque_ptr = m_opaque_ptr->GetFirstChild(); - return LLDB_RECORD_RESULT(sb_block); + return sb_block; } lldb_private::Block *SBBlock::GetPtr() { return m_opaque_ptr; } @@ -163,8 +161,7 @@ lldb_private::Block *SBBlock::GetPtr() { return m_opaque_ptr; } void SBBlock::SetPtr(lldb_private::Block *block) { m_opaque_ptr = block; } bool SBBlock::GetDescription(SBStream &description) { - LLDB_RECORD_METHOD(bool, SBBlock, GetDescription, (lldb::SBStream &), - description); + LLDB_INSTRUMENT_VA(this, description); Stream &strm = description.ref(); @@ -188,7 +185,7 @@ bool SBBlock::GetDescription(SBStream &description) { } uint32_t SBBlock::GetNumRanges() { - LLDB_RECORD_METHOD_NO_ARGS(uint32_t, SBBlock, GetNumRanges); + LLDB_INSTRUMENT_VA(this); if (m_opaque_ptr) return m_opaque_ptr->GetNumRanges(); @@ -196,8 +193,7 @@ uint32_t SBBlock::GetNumRanges() { } lldb::SBAddress SBBlock::GetRangeStartAddress(uint32_t idx) { - LLDB_RECORD_METHOD(lldb::SBAddress, SBBlock, GetRangeStartAddress, (uint32_t), - idx); + LLDB_INSTRUMENT_VA(this, idx); lldb::SBAddress sb_addr; if (m_opaque_ptr) { @@ -206,12 +202,11 @@ lldb::SBAddress SBBlock::GetRangeStartAddress(uint32_t idx) { sb_addr.ref() = range.GetBaseAddress(); } } - return LLDB_RECORD_RESULT(sb_addr); + return sb_addr; } lldb::SBAddress SBBlock::GetRangeEndAddress(uint32_t idx) { - LLDB_RECORD_METHOD(lldb::SBAddress, SBBlock, GetRangeEndAddress, (uint32_t), - idx); + LLDB_INSTRUMENT_VA(this, idx); lldb::SBAddress sb_addr; if (m_opaque_ptr) { @@ -221,12 +216,11 @@ lldb::SBAddress SBBlock::GetRangeEndAddress(uint32_t idx) { sb_addr.ref().Slide(range.GetByteSize()); } } - return LLDB_RECORD_RESULT(sb_addr); + return sb_addr; } uint32_t SBBlock::GetRangeIndexForBlockAddress(lldb::SBAddress block_addr) { - LLDB_RECORD_METHOD(uint32_t, SBBlock, GetRangeIndexForBlockAddress, - (lldb::SBAddress), block_addr); + LLDB_INSTRUMENT_VA(this, block_addr); if (m_opaque_ptr && block_addr.IsValid()) { return m_opaque_ptr->GetRangeIndexContainingAddress(block_addr.ref()); @@ -238,10 +232,7 @@ uint32_t SBBlock::GetRangeIndexForBlockAddress(lldb::SBAddress block_addr) { lldb::SBValueList SBBlock::GetVariables(lldb::SBFrame &frame, bool arguments, bool locals, bool statics, lldb::DynamicValueType use_dynamic) { - LLDB_RECORD_METHOD( - lldb::SBValueList, SBBlock, GetVariables, - (lldb::SBFrame &, bool, bool, bool, lldb::DynamicValueType), frame, - arguments, locals, statics, use_dynamic); + LLDB_INSTRUMENT_VA(this, frame, arguments, locals, statics, use_dynamic); Block *block = GetPtr(); SBValueList value_list; @@ -289,14 +280,12 @@ lldb::SBValueList SBBlock::GetVariables(lldb::SBFrame &frame, bool arguments, } } } - return LLDB_RECORD_RESULT(value_list); + return value_list; } lldb::SBValueList SBBlock::GetVariables(lldb::SBTarget &target, bool arguments, bool locals, bool statics) { - LLDB_RECORD_METHOD(lldb::SBValueList, SBBlock, GetVariables, - (lldb::SBTarget &, bool, bool, bool), target, arguments, - locals, statics); + LLDB_INSTRUMENT_VA(this, target, arguments, locals, statics); Block *block = GetPtr(); @@ -341,44 +330,5 @@ lldb::SBValueList SBBlock::GetVariables(lldb::SBTarget &target, bool arguments, } } } - return LLDB_RECORD_RESULT(value_list); -} - -namespace lldb_private { -namespace repro { - -template <> -void RegisterMethods<SBBlock>(Registry &R) { - LLDB_REGISTER_CONSTRUCTOR(SBBlock, ()); - LLDB_REGISTER_CONSTRUCTOR(SBBlock, (const lldb::SBBlock &)); - LLDB_REGISTER_METHOD(const lldb::SBBlock &, - SBBlock, operator=,(const lldb::SBBlock &)); - LLDB_REGISTER_METHOD_CONST(bool, SBBlock, IsValid, ()); - LLDB_REGISTER_METHOD_CONST(bool, SBBlock, operator bool, ()); - LLDB_REGISTER_METHOD_CONST(bool, SBBlock, IsInlined, ()); - LLDB_REGISTER_METHOD_CONST(const char *, SBBlock, GetInlinedName, ()); - LLDB_REGISTER_METHOD_CONST(lldb::SBFileSpec, SBBlock, - GetInlinedCallSiteFile, ()); - LLDB_REGISTER_METHOD_CONST(uint32_t, SBBlock, GetInlinedCallSiteLine, ()); - LLDB_REGISTER_METHOD_CONST(uint32_t, SBBlock, GetInlinedCallSiteColumn, ()); - LLDB_REGISTER_METHOD(lldb::SBBlock, SBBlock, GetParent, ()); - LLDB_REGISTER_METHOD(lldb::SBBlock, SBBlock, GetContainingInlinedBlock, ()); - LLDB_REGISTER_METHOD(lldb::SBBlock, SBBlock, GetSibling, ()); - LLDB_REGISTER_METHOD(lldb::SBBlock, SBBlock, GetFirstChild, ()); - LLDB_REGISTER_METHOD(bool, SBBlock, GetDescription, (lldb::SBStream &)); - LLDB_REGISTER_METHOD(uint32_t, SBBlock, GetNumRanges, ()); - LLDB_REGISTER_METHOD(lldb::SBAddress, SBBlock, GetRangeStartAddress, - (uint32_t)); - LLDB_REGISTER_METHOD(lldb::SBAddress, SBBlock, GetRangeEndAddress, - (uint32_t)); - LLDB_REGISTER_METHOD(uint32_t, SBBlock, GetRangeIndexForBlockAddress, - (lldb::SBAddress)); - LLDB_REGISTER_METHOD( - lldb::SBValueList, SBBlock, GetVariables, - (lldb::SBFrame &, bool, bool, bool, lldb::DynamicValueType)); - LLDB_REGISTER_METHOD(lldb::SBValueList, SBBlock, GetVariables, - (lldb::SBTarget &, bool, bool, bool)); -} - -} + return value_list; } diff --git a/lldb/source/API/SBBreakpoint.cpp b/lldb/source/API/SBBreakpoint.cpp index 0f0a93519993..5fe8f7fe0583 100644 --- a/lldb/source/API/SBBreakpoint.cpp +++ b/lldb/source/API/SBBreakpoint.cpp @@ -7,7 +7,6 @@ //===----------------------------------------------------------------------===// #include "lldb/API/SBBreakpoint.h" -#include "SBReproducerPrivate.h" #include "lldb/API/SBBreakpointLocation.h" #include "lldb/API/SBDebugger.h" #include "lldb/API/SBEvent.h" @@ -16,6 +15,7 @@ #include "lldb/API/SBStringList.h" #include "lldb/API/SBStructuredData.h" #include "lldb/API/SBThread.h" +#include "lldb/Utility/Instrumentation.h" #include "lldb/Breakpoint/Breakpoint.h" #include "lldb/Breakpoint/BreakpointIDList.h" @@ -45,54 +45,51 @@ using namespace lldb; using namespace lldb_private; -SBBreakpoint::SBBreakpoint() { LLDB_RECORD_CONSTRUCTOR_NO_ARGS(SBBreakpoint); } +SBBreakpoint::SBBreakpoint() { LLDB_INSTRUMENT_VA(this); } SBBreakpoint::SBBreakpoint(const SBBreakpoint &rhs) : m_opaque_wp(rhs.m_opaque_wp) { - LLDB_RECORD_CONSTRUCTOR(SBBreakpoint, (const lldb::SBBreakpoint &), rhs); + LLDB_INSTRUMENT_VA(this, rhs); } SBBreakpoint::SBBreakpoint(const lldb::BreakpointSP &bp_sp) : m_opaque_wp(bp_sp) { - LLDB_RECORD_CONSTRUCTOR(SBBreakpoint, (const lldb::BreakpointSP &), bp_sp); + LLDB_INSTRUMENT_VA(this, bp_sp); } SBBreakpoint::~SBBreakpoint() = default; const SBBreakpoint &SBBreakpoint::operator=(const SBBreakpoint &rhs) { - LLDB_RECORD_METHOD(const lldb::SBBreakpoint &, - SBBreakpoint, operator=,(const lldb::SBBreakpoint &), rhs); + LLDB_INSTRUMENT_VA(this, rhs); m_opaque_wp = rhs.m_opaque_wp; - return LLDB_RECORD_RESULT(*this); + return *this; } bool SBBreakpoint::operator==(const lldb::SBBreakpoint &rhs) { - LLDB_RECORD_METHOD( - bool, SBBreakpoint, operator==,(const lldb::SBBreakpoint &), rhs); + LLDB_INSTRUMENT_VA(this, rhs); return m_opaque_wp.lock() == rhs.m_opaque_wp.lock(); } bool SBBreakpoint::operator!=(const lldb::SBBreakpoint &rhs) { - LLDB_RECORD_METHOD( - bool, SBBreakpoint, operator!=,(const lldb::SBBreakpoint &), rhs); + LLDB_INSTRUMENT_VA(this, rhs); return m_opaque_wp.lock() != rhs.m_opaque_wp.lock(); } SBTarget SBBreakpoint::GetTarget() const { - LLDB_RECORD_METHOD_CONST_NO_ARGS(lldb::SBTarget, SBBreakpoint, GetTarget); + LLDB_INSTRUMENT_VA(this); BreakpointSP bkpt_sp = GetSP(); if (bkpt_sp) - return LLDB_RECORD_RESULT(SBTarget(bkpt_sp->GetTargetSP())); + return SBTarget(bkpt_sp->GetTargetSP()); - return LLDB_RECORD_RESULT(SBTarget()); + return SBTarget(); } break_id_t SBBreakpoint::GetID() const { - LLDB_RECORD_METHOD_CONST_NO_ARGS(lldb::break_id_t, SBBreakpoint, GetID); + LLDB_INSTRUMENT_VA(this); break_id_t break_id = LLDB_INVALID_BREAK_ID; BreakpointSP bkpt_sp = GetSP(); @@ -103,11 +100,11 @@ break_id_t SBBreakpoint::GetID() const { } bool SBBreakpoint::IsValid() const { - LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBBreakpoint, IsValid); + LLDB_INSTRUMENT_VA(this); return this->operator bool(); } SBBreakpoint::operator bool() const { - LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBBreakpoint, operator bool); + LLDB_INSTRUMENT_VA(this); BreakpointSP bkpt_sp = GetSP(); if (!bkpt_sp) @@ -119,7 +116,7 @@ SBBreakpoint::operator bool() const { } void SBBreakpoint::ClearAllBreakpointSites() { - LLDB_RECORD_METHOD_NO_ARGS(void, SBBreakpoint, ClearAllBreakpointSites); + LLDB_INSTRUMENT_VA(this); BreakpointSP bkpt_sp = GetSP(); if (bkpt_sp) { @@ -130,8 +127,7 @@ void SBBreakpoint::ClearAllBreakpointSites() { } SBBreakpointLocation SBBreakpoint::FindLocationByAddress(addr_t vm_addr) { - LLDB_RECORD_METHOD(lldb::SBBreakpointLocation, SBBreakpoint, - FindLocationByAddress, (lldb::addr_t), vm_addr); + LLDB_INSTRUMENT_VA(this, vm_addr); SBBreakpointLocation sb_bp_location; @@ -148,12 +144,11 @@ SBBreakpointLocation SBBreakpoint::FindLocationByAddress(addr_t vm_addr) { sb_bp_location.SetLocation(bkpt_sp->FindLocationByAddress(address)); } } - return LLDB_RECORD_RESULT(sb_bp_location); + return sb_bp_location; } break_id_t SBBreakpoint::FindLocationIDByAddress(addr_t vm_addr) { - LLDB_RECORD_METHOD(lldb::break_id_t, SBBreakpoint, FindLocationIDByAddress, - (lldb::addr_t), vm_addr); + LLDB_INSTRUMENT_VA(this, vm_addr); break_id_t break_id = LLDB_INVALID_BREAK_ID; BreakpointSP bkpt_sp = GetSP(); @@ -173,8 +168,7 @@ break_id_t SBBreakpoint::FindLocationIDByAddress(addr_t vm_addr) { } SBBreakpointLocation SBBreakpoint::FindLocationByID(break_id_t bp_loc_id) { - LLDB_RECORD_METHOD(lldb::SBBreakpointLocation, SBBreakpoint, FindLocationByID, - (lldb::break_id_t), bp_loc_id); + LLDB_INSTRUMENT_VA(this, bp_loc_id); SBBreakpointLocation sb_bp_location; BreakpointSP bkpt_sp = GetSP(); @@ -185,12 +179,11 @@ SBBreakpointLocation SBBreakpoint::FindLocationByID(break_id_t bp_loc_id) { sb_bp_location.SetLocation(bkpt_sp->FindLocationByID(bp_loc_id)); } - return LLDB_RECORD_RESULT(sb_bp_location); + return sb_bp_location; } SBBreakpointLocation SBBreakpoint::GetLocationAtIndex(uint32_t index) { - LLDB_RECORD_METHOD(lldb::SBBreakpointLocation, SBBreakpoint, - GetLocationAtIndex, (uint32_t), index); + LLDB_INSTRUMENT_VA(this, index); SBBreakpointLocation sb_bp_location; BreakpointSP bkpt_sp = GetSP(); @@ -201,11 +194,11 @@ SBBreakpointLocation SBBreakpoint::GetLocationAtIndex(uint32_t index) { sb_bp_location.SetLocation(bkpt_sp->GetLocationAtIndex(index)); } - return LLDB_RECORD_RESULT(sb_bp_location); + return sb_bp_location; } void SBBreakpoint::SetEnabled(bool enable) { - LLDB_RECORD_METHOD(void, SBBreakpoint, SetEnabled, (bool), enable); + LLDB_INSTRUMENT_VA(this, enable); BreakpointSP bkpt_sp = GetSP(); @@ -217,7 +210,7 @@ void SBBreakpoint::SetEnabled(bool enable) { } bool SBBreakpoint::IsEnabled() { - LLDB_RECORD_METHOD_NO_ARGS(bool, SBBreakpoint, IsEnabled); + LLDB_INSTRUMENT_VA(this); BreakpointSP bkpt_sp = GetSP(); if (bkpt_sp) { @@ -229,7 +222,7 @@ bool SBBreakpoint::IsEnabled() { } void SBBreakpoint::SetOneShot(bool one_shot) { - LLDB_RECORD_METHOD(void, SBBreakpoint, SetOneShot, (bool), one_shot); + LLDB_INSTRUMENT_VA(this, one_shot); BreakpointSP bkpt_sp = GetSP(); @@ -241,7 +234,7 @@ void SBBreakpoint::SetOneShot(bool one_shot) { } bool SBBreakpoint::IsOneShot() const { - LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBBreakpoint, IsOneShot); + LLDB_INSTRUMENT_VA(this); BreakpointSP bkpt_sp = GetSP(); if (bkpt_sp) { @@ -253,7 +246,7 @@ bool SBBreakpoint::IsOneShot() const { } bool SBBreakpoint::IsInternal() { - LLDB_RECORD_METHOD_NO_ARGS(bool, SBBreakpoint, IsInternal); + LLDB_INSTRUMENT_VA(this); BreakpointSP bkpt_sp = GetSP(); if (bkpt_sp) { @@ -265,7 +258,7 @@ bool SBBreakpoint::IsInternal() { } void SBBreakpoint::SetIgnoreCount(uint32_t count) { - LLDB_RECORD_METHOD(void, SBBreakpoint, SetIgnoreCount, (uint32_t), count); + LLDB_INSTRUMENT_VA(this, count); BreakpointSP bkpt_sp = GetSP(); @@ -277,8 +270,7 @@ void SBBreakpoint::SetIgnoreCount(uint32_t count) { } void SBBreakpoint::SetCondition(const char *condition) { - LLDB_RECORD_METHOD(void, SBBreakpoint, SetCondition, (const char *), - condition); + LLDB_INSTRUMENT_VA(this, condition); BreakpointSP bkpt_sp = GetSP(); if (bkpt_sp) { @@ -289,7 +281,7 @@ void SBBreakpoint::SetCondition(const char *condition) { } const char *SBBreakpoint::GetCondition() { - LLDB_RECORD_METHOD_NO_ARGS(const char *, SBBreakpoint, GetCondition); + LLDB_INSTRUMENT_VA(this); BreakpointSP bkpt_sp = GetSP(); if (bkpt_sp) { @@ -301,8 +293,7 @@ const char *SBBreakpoint::GetCondition() { } void SBBreakpoint::SetAutoContinue(bool auto_continue) { - LLDB_RECORD_METHOD(void, SBBreakpoint, SetAutoContinue, (bool), - auto_continue); + LLDB_INSTRUMENT_VA(this, auto_continue); BreakpointSP bkpt_sp = GetSP(); if (bkpt_sp) { @@ -313,7 +304,7 @@ void SBBreakpoint::SetAutoContinue(bool auto_continue) { } bool SBBreakpoint::GetAutoContinue() { - LLDB_RECORD_METHOD_NO_ARGS(bool, SBBreakpoint, GetAutoContinue); + LLDB_INSTRUMENT_VA(this); BreakpointSP bkpt_sp = GetSP(); if (bkpt_sp) { @@ -325,7 +316,7 @@ bool SBBreakpoint::GetAutoContinue() { } uint32_t SBBreakpoint::GetHitCount() const { - LLDB_RECORD_METHOD_CONST_NO_ARGS(uint32_t, SBBreakpoint, GetHitCount); + LLDB_INSTRUMENT_VA(this); uint32_t count = 0; BreakpointSP bkpt_sp = GetSP(); @@ -339,7 +330,7 @@ uint32_t SBBreakpoint::GetHitCount() const { } uint32_t SBBreakpoint::GetIgnoreCount() const { - LLDB_RECORD_METHOD_CONST_NO_ARGS(uint32_t, SBBreakpoint, GetIgnoreCount); + LLDB_INSTRUMENT_VA(this); uint32_t count = 0; BreakpointSP bkpt_sp = GetSP(); @@ -353,7 +344,7 @@ uint32_t SBBreakpoint::GetIgnoreCount() const { } void SBBreakpoint::SetThreadID(tid_t tid) { - LLDB_RECORD_METHOD(void, SBBreakpoint, SetThreadID, (lldb::tid_t), tid); + LLDB_INSTRUMENT_VA(this, tid); BreakpointSP bkpt_sp = GetSP(); if (bkpt_sp) { @@ -364,7 +355,7 @@ void SBBreakpoint::SetThreadID(tid_t tid) { } tid_t SBBreakpoint::GetThreadID() { - LLDB_RECORD_METHOD_NO_ARGS(lldb::tid_t, SBBreakpoint, GetThreadID); + LLDB_INSTRUMENT_VA(this); tid_t tid = LLDB_INVALID_THREAD_ID; BreakpointSP bkpt_sp = GetSP(); @@ -378,7 +369,7 @@ tid_t SBBreakpoint::GetThreadID() { } void SBBreakpoint::SetThreadIndex(uint32_t index) { - LLDB_RECORD_METHOD(void, SBBreakpoint, SetThreadIndex, (uint32_t), index); + LLDB_INSTRUMENT_VA(this, index); BreakpointSP bkpt_sp = GetSP(); if (bkpt_sp) { @@ -389,7 +380,7 @@ void SBBreakpoint::SetThreadIndex(uint32_t index) { } uint32_t SBBreakpoint::GetThreadIndex() const { - LLDB_RECORD_METHOD_CONST_NO_ARGS(uint32_t, SBBreakpoint, GetThreadIndex); + LLDB_INSTRUMENT_VA(this); uint32_t thread_idx = UINT32_MAX; BreakpointSP bkpt_sp = GetSP(); @@ -406,8 +397,7 @@ uint32_t SBBreakpoint::GetThreadIndex() const { } void SBBreakpoint::SetThreadName(const char *thread_name) { - LLDB_RECORD_METHOD(void, SBBreakpoint, SetThreadName, (const char *), - thread_name); + LLDB_INSTRUMENT_VA(this, thread_name); BreakpointSP bkpt_sp = GetSP(); @@ -419,7 +409,7 @@ void SBBreakpoint::SetThreadName(const char *thread_name) { } const char *SBBreakpoint::GetThreadName() const { - LLDB_RECORD_METHOD_CONST_NO_ARGS(const char *, SBBreakpoint, GetThreadName); + LLDB_INSTRUMENT_VA(this); const char *name = nullptr; BreakpointSP bkpt_sp = GetSP(); @@ -436,8 +426,7 @@ const char *SBBreakpoint::GetThreadName() const { } void SBBreakpoint::SetQueueName(const char *queue_name) { - LLDB_RECORD_METHOD(void, SBBreakpoint, SetQueueName, (const char *), - queue_name); + LLDB_INSTRUMENT_VA(this, queue_name); BreakpointSP bkpt_sp = GetSP(); if (bkpt_sp) { @@ -448,7 +437,7 @@ void SBBreakpoint::SetQueueName(const char *queue_name) { } const char *SBBreakpoint::GetQueueName() const { - LLDB_RECORD_METHOD_CONST_NO_ARGS(const char *, SBBreakpoint, GetQueueName); + LLDB_INSTRUMENT_VA(this); const char *name = nullptr; BreakpointSP bkpt_sp = GetSP(); @@ -465,8 +454,7 @@ const char *SBBreakpoint::GetQueueName() const { } size_t SBBreakpoint::GetNumResolvedLocations() const { - LLDB_RECORD_METHOD_CONST_NO_ARGS(size_t, SBBreakpoint, - GetNumResolvedLocations); + LLDB_INSTRUMENT_VA(this); size_t num_resolved = 0; BreakpointSP bkpt_sp = GetSP(); @@ -479,7 +467,7 @@ size_t SBBreakpoint::GetNumResolvedLocations() const { } size_t SBBreakpoint::GetNumLocations() const { - LLDB_RECORD_METHOD_CONST_NO_ARGS(size_t, SBBreakpoint, GetNumLocations); + LLDB_INSTRUMENT_VA(this); BreakpointSP bkpt_sp = GetSP(); size_t num_locs = 0; @@ -492,8 +480,7 @@ size_t SBBreakpoint::GetNumLocations() const { } void SBBreakpoint::SetCommandLineCommands(SBStringList &commands) { - LLDB_RECORD_METHOD(void, SBBreakpoint, SetCommandLineCommands, - (lldb::SBStringList &), commands); + LLDB_INSTRUMENT_VA(this, commands); BreakpointSP bkpt_sp = GetSP(); if (!bkpt_sp) @@ -510,8 +497,7 @@ void SBBreakpoint::SetCommandLineCommands(SBStringList &commands) { } bool SBBreakpoint::GetCommandLineCommands(SBStringList &commands) { - LLDB_RECORD_METHOD(bool, SBBreakpoint, GetCommandLineCommands, - (lldb::SBStringList &), commands); + LLDB_INSTRUMENT_VA(this, commands); BreakpointSP bkpt_sp = GetSP(); if (!bkpt_sp) @@ -525,14 +511,13 @@ bool SBBreakpoint::GetCommandLineCommands(SBStringList &commands) { } bool SBBreakpoint::GetDescription(SBStream &s) { - LLDB_RECORD_METHOD(bool, SBBreakpoint, GetDescription, (lldb::SBStream &), s); + LLDB_INSTRUMENT_VA(this, s); return GetDescription(s, true); } bool SBBreakpoint::GetDescription(SBStream &s, bool include_locations) { - LLDB_RECORD_METHOD(bool, SBBreakpoint, GetDescription, - (lldb::SBStream &, bool), s, include_locations); + LLDB_INSTRUMENT_VA(this, s, include_locations); BreakpointSP bkpt_sp = GetSP(); if (bkpt_sp) { @@ -552,25 +537,24 @@ bool SBBreakpoint::GetDescription(SBStream &s, bool include_locations) { } SBError SBBreakpoint::AddLocation(SBAddress &address) { - LLDB_RECORD_METHOD(lldb::SBError, SBBreakpoint, AddLocation, - (lldb::SBAddress &), address); + LLDB_INSTRUMENT_VA(this, address); BreakpointSP bkpt_sp = GetSP(); SBError error; if (!address.IsValid()) { error.SetErrorString("Can't add an invalid address."); - return LLDB_RECORD_RESULT(error); + return error; } if (!bkpt_sp) { error.SetErrorString("No breakpoint to add a location to."); - return LLDB_RECORD_RESULT(error); + return error; } if (!llvm::isa<BreakpointResolverScripted>(bkpt_sp->GetResolver().get())) { error.SetErrorString("Only a scripted resolver can add locations."); - return LLDB_RECORD_RESULT(error); + return error; } if (bkpt_sp->GetSearchFilter()->AddressPasses(address.ref())) @@ -582,27 +566,25 @@ SBError SBBreakpoint::AddLocation(SBAddress &address) { error.SetErrorStringWithFormat("Address: %s didn't pass the filter.", s.GetData()); } - return LLDB_RECORD_RESULT(error); + return error; } SBStructuredData SBBreakpoint::SerializeToStructuredData() { - LLDB_RECORD_METHOD_NO_ARGS(lldb::SBStructuredData, SBBreakpoint, - SerializeToStructuredData); + LLDB_INSTRUMENT_VA(this); SBStructuredData data; BreakpointSP bkpt_sp = GetSP(); if (!bkpt_sp) - return LLDB_RECORD_RESULT(data); + return data; StructuredData::ObjectSP bkpt_dict = bkpt_sp->SerializeToStructuredData(); data.m_impl_up->SetObjectSP(bkpt_dict); - return LLDB_RECORD_RESULT(data); + return data; } void SBBreakpoint::SetCallback(SBBreakpointHitCallback callback, void *baton) { - LLDB_RECORD_DUMMY(void, SBBreakpoint, SetCallback, - (lldb::SBBreakpointHitCallback, void *), callback, baton); + LLDB_INSTRUMENT_VA(this, callback, baton); BreakpointSP bkpt_sp = GetSP(); @@ -618,8 +600,7 @@ void SBBreakpoint::SetCallback(SBBreakpointHitCallback callback, void *baton) { void SBBreakpoint::SetScriptCallbackFunction( const char *callback_function_name) { -LLDB_RECORD_METHOD(void, SBBreakpoint, SetScriptCallbackFunction, - (const char *), callback_function_name); + LLDB_INSTRUMENT_VA(this, callback_function_name); SBStructuredData empty_args; SetScriptCallbackFunction(callback_function_name, empty_args); } @@ -627,8 +608,7 @@ LLDB_RECORD_METHOD(void, SBBreakpoint, SetScriptCallbackFunction, SBError SBBreakpoint::SetScriptCallbackFunction( const char *callback_function_name, SBStructuredData &extra_args) { - LLDB_RECORD_METHOD(SBError, SBBreakpoint, SetScriptCallbackFunction, - (const char *, SBStructuredData &), callback_function_name, extra_args); + LLDB_INSTRUMENT_VA(this, callback_function_name, extra_args); SBError sb_error; BreakpointSP bkpt_sp = GetSP(); @@ -647,13 +627,12 @@ SBError SBBreakpoint::SetScriptCallbackFunction( sb_error.SetError(error); } else sb_error.SetErrorString("invalid breakpoint"); - - return LLDB_RECORD_RESULT(sb_error); + + return sb_error; } SBError SBBreakpoint::SetScriptCallbackBody(const char *callback_body_text) { - LLDB_RECORD_METHOD(lldb::SBError, SBBreakpoint, SetScriptCallbackBody, - (const char *), callback_body_text); + LLDB_INSTRUMENT_VA(this, callback_body_text); BreakpointSP bkpt_sp = GetSP(); @@ -671,19 +650,18 @@ SBError SBBreakpoint::SetScriptCallbackBody(const char *callback_body_text) { } else sb_error.SetErrorString("invalid breakpoint"); - return LLDB_RECORD_RESULT(sb_error); + return sb_error; } bool SBBreakpoint::AddName(const char *new_name) { - LLDB_RECORD_METHOD(bool, SBBreakpoint, AddName, (const char *), new_name); + LLDB_INSTRUMENT_VA(this, new_name); SBError status = AddNameWithErrorHandling(new_name); return status.Success(); } SBError SBBreakpoint::AddNameWithErrorHandling(const char *new_name) { - LLDB_RECORD_METHOD(SBError, SBBreakpoint, AddNameWithErrorHandling, - (const char *), new_name); + LLDB_INSTRUMENT_VA(this, new_name); BreakpointSP bkpt_sp = GetSP(); @@ -698,12 +676,11 @@ SBError SBBreakpoint::AddNameWithErrorHandling(const char *new_name) { status.SetErrorString("invalid breakpoint"); } - return LLDB_RECORD_RESULT(status); + return status; } void SBBreakpoint::RemoveName(const char *name_to_remove) { - LLDB_RECORD_METHOD(void, SBBreakpoint, RemoveName, (const char *), - name_to_remove); + LLDB_INSTRUMENT_VA(this, name_to_remove); BreakpointSP bkpt_sp = GetSP(); @@ -716,7 +693,7 @@ void SBBreakpoint::RemoveName(const char *name_to_remove) { } bool SBBreakpoint::MatchesName(const char *name) { - LLDB_RECORD_METHOD(bool, SBBreakpoint, MatchesName, (const char *), name); + LLDB_INSTRUMENT_VA(this, name); BreakpointSP bkpt_sp = GetSP(); @@ -730,8 +707,7 @@ bool SBBreakpoint::MatchesName(const char *name) { } void SBBreakpoint::GetNames(SBStringList &names) { - LLDB_RECORD_METHOD(void, SBBreakpoint, GetNames, (lldb::SBStringList &), - names); + LLDB_INSTRUMENT_VA(this, names); BreakpointSP bkpt_sp = GetSP(); @@ -747,8 +723,7 @@ void SBBreakpoint::GetNames(SBStringList &names) { } bool SBBreakpoint::EventIsBreakpointEvent(const lldb::SBEvent &event) { - LLDB_RECORD_STATIC_METHOD(bool, SBBreakpoint, EventIsBreakpointEvent, - (const lldb::SBEvent &), event); + LLDB_INSTRUMENT_VA(event); return Breakpoint::BreakpointEventData::GetEventDataFromEvent(event.get()) != nullptr; @@ -756,9 +731,7 @@ bool SBBreakpoint::EventIsBreakpointEvent(const lldb::SBEvent &event) { BreakpointEventType SBBreakpoint::GetBreakpointEventTypeFromEvent(const SBEvent &event) { - LLDB_RECORD_STATIC_METHOD(lldb::BreakpointEventType, SBBreakpoint, - GetBreakpointEventTypeFromEvent, - (const lldb::SBEvent &), event); + LLDB_INSTRUMENT_VA(event); if (event.IsValid()) return Breakpoint::BreakpointEventData::GetBreakpointEventTypeFromEvent( @@ -767,37 +740,30 @@ SBBreakpoint::GetBreakpointEventTypeFromEvent(const SBEvent &event) { } SBBreakpoint SBBreakpoint::GetBreakpointFromEvent(const lldb::SBEvent &event) { - LLDB_RECORD_STATIC_METHOD(lldb::SBBreakpoint, SBBreakpoint, - GetBreakpointFromEvent, (const lldb::SBEvent &), - event); + LLDB_INSTRUMENT_VA(event); if (event.IsValid()) - return LLDB_RECORD_RESULT( - SBBreakpoint(Breakpoint::BreakpointEventData::GetBreakpointFromEvent( - event.GetSP()))); - return LLDB_RECORD_RESULT(SBBreakpoint()); + return SBBreakpoint( + Breakpoint::BreakpointEventData::GetBreakpointFromEvent(event.GetSP())); + return SBBreakpoint(); } SBBreakpointLocation SBBreakpoint::GetBreakpointLocationAtIndexFromEvent(const lldb::SBEvent &event, uint32_t loc_idx) { - LLDB_RECORD_STATIC_METHOD(lldb::SBBreakpointLocation, SBBreakpoint, - GetBreakpointLocationAtIndexFromEvent, - (const lldb::SBEvent &, uint32_t), event, loc_idx); + LLDB_INSTRUMENT_VA(event, loc_idx); SBBreakpointLocation sb_breakpoint_loc; if (event.IsValid()) sb_breakpoint_loc.SetLocation( Breakpoint::BreakpointEventData::GetBreakpointLocationAtIndexFromEvent( event.GetSP(), loc_idx)); - return LLDB_RECORD_RESULT(sb_breakpoint_loc); + return sb_breakpoint_loc; } uint32_t SBBreakpoint::GetNumBreakpointLocationsFromEvent(const lldb::SBEvent &event) { - LLDB_RECORD_STATIC_METHOD(uint32_t, SBBreakpoint, - GetNumBreakpointLocationsFromEvent, - (const lldb::SBEvent &), event); + LLDB_INSTRUMENT_VA(event); uint32_t num_locations = 0; if (event.IsValid()) @@ -808,7 +774,7 @@ SBBreakpoint::GetNumBreakpointLocationsFromEvent(const lldb::SBEvent &event) { } bool SBBreakpoint::IsHardware() const { - LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBBreakpoint, IsHardware); + LLDB_INSTRUMENT_VA(this); BreakpointSP bkpt_sp = GetSP(); if (bkpt_sp) @@ -821,7 +787,7 @@ BreakpointSP SBBreakpoint::GetSP() const { return m_opaque_wp.lock(); } // This is simple collection of breakpoint id's and their target. class SBBreakpointListImpl { public: - SBBreakpointListImpl(lldb::TargetSP target_sp) : m_target_wp() { + SBBreakpointListImpl(lldb::TargetSP target_sp) { if (target_sp && target_sp->IsValid()) m_target_wp = target_sp; } @@ -904,13 +870,13 @@ private: SBBreakpointList::SBBreakpointList(SBTarget &target) : m_opaque_sp(new SBBreakpointListImpl(target.GetSP())) { - LLDB_RECORD_CONSTRUCTOR(SBBreakpointList, (lldb::SBTarget &), target); + LLDB_INSTRUMENT_VA(this, target); } SBBreakpointList::~SBBreakpointList() = default; size_t SBBreakpointList::GetSize() const { - LLDB_RECORD_METHOD_CONST_NO_ARGS(size_t, SBBreakpointList, GetSize); + LLDB_INSTRUMENT_VA(this); if (!m_opaque_sp) return 0; @@ -919,29 +885,26 @@ size_t SBBreakpointList::GetSize() const { } SBBreakpoint SBBreakpointList::GetBreakpointAtIndex(size_t idx) { - LLDB_RECORD_METHOD(lldb::SBBreakpoint, SBBreakpointList, GetBreakpointAtIndex, - (size_t), idx); + LLDB_INSTRUMENT_VA(this, idx); if (!m_opaque_sp) - return LLDB_RECORD_RESULT(SBBreakpoint()); + return SBBreakpoint(); BreakpointSP bkpt_sp = m_opaque_sp->GetBreakpointAtIndex(idx); - return LLDB_RECORD_RESULT(SBBreakpoint(bkpt_sp)); + return SBBreakpoint(bkpt_sp); } SBBreakpoint SBBreakpointList::FindBreakpointByID(lldb::break_id_t id) { - LLDB_RECORD_METHOD(lldb::SBBreakpoint, SBBreakpointList, FindBreakpointByID, - (lldb::break_id_t), id); + LLDB_INSTRUMENT_VA(this, id); if (!m_opaque_sp) - return LLDB_RECORD_RESULT(SBBreakpoint()); + return SBBreakpoint(); BreakpointSP bkpt_sp = m_opaque_sp->FindBreakpointByID(id); - return LLDB_RECORD_RESULT(SBBreakpoint(bkpt_sp)); + return SBBreakpoint(bkpt_sp); } void SBBreakpointList::Append(const SBBreakpoint &sb_bkpt) { - LLDB_RECORD_METHOD(void, SBBreakpointList, Append, - (const lldb::SBBreakpoint &), sb_bkpt); + LLDB_INSTRUMENT_VA(this, sb_bkpt); if (!sb_bkpt.IsValid()) return; @@ -951,8 +914,7 @@ void SBBreakpointList::Append(const SBBreakpoint &sb_bkpt) { } void SBBreakpointList::AppendByID(lldb::break_id_t id) { - LLDB_RECORD_METHOD(void, SBBreakpointList, AppendByID, (lldb::break_id_t), - id); + LLDB_INSTRUMENT_VA(this, id); if (!m_opaque_sp) return; @@ -960,8 +922,7 @@ void SBBreakpointList::AppendByID(lldb::break_id_t id) { } bool SBBreakpointList::AppendIfUnique(const SBBreakpoint &sb_bkpt) { - LLDB_RECORD_METHOD(bool, SBBreakpointList, AppendIfUnique, - (const lldb::SBBreakpoint &), sb_bkpt); + LLDB_INSTRUMENT_VA(this, sb_bkpt); if (!sb_bkpt.IsValid()) return false; @@ -971,7 +932,7 @@ bool SBBreakpointList::AppendIfUnique(const SBBreakpoint &sb_bkpt) { } void SBBreakpointList::Clear() { - LLDB_RECORD_METHOD_NO_ARGS(void, SBBreakpointList, Clear); + LLDB_INSTRUMENT_VA(this); if (m_opaque_sp) m_opaque_sp->Clear(); @@ -982,114 +943,3 @@ void SBBreakpointList::CopyToBreakpointIDList( if (m_opaque_sp) m_opaque_sp->CopyToBreakpointIDList(bp_id_list); } - -namespace lldb_private { -namespace repro { - -template <> -void RegisterMethods<SBBreakpoint>(Registry &R) { - LLDB_REGISTER_CONSTRUCTOR(SBBreakpoint, ()); - LLDB_REGISTER_CONSTRUCTOR(SBBreakpoint, (const lldb::SBBreakpoint &)); - LLDB_REGISTER_CONSTRUCTOR(SBBreakpoint, (const lldb::BreakpointSP &)); - LLDB_REGISTER_METHOD(const lldb::SBBreakpoint &, - SBBreakpoint, operator=,(const lldb::SBBreakpoint &)); - LLDB_REGISTER_METHOD(bool, - SBBreakpoint, operator==,(const lldb::SBBreakpoint &)); - LLDB_REGISTER_METHOD(bool, - SBBreakpoint, operator!=,(const lldb::SBBreakpoint &)); - LLDB_REGISTER_METHOD_CONST(lldb::SBTarget, SBBreakpoint, GetTarget, ()); - LLDB_REGISTER_METHOD_CONST(lldb::break_id_t, SBBreakpoint, GetID, ()); - LLDB_REGISTER_METHOD_CONST(bool, SBBreakpoint, IsValid, ()); - LLDB_REGISTER_METHOD_CONST(bool, SBBreakpoint, operator bool, ()); - LLDB_REGISTER_METHOD(void, SBBreakpoint, ClearAllBreakpointSites, ()); - LLDB_REGISTER_METHOD(lldb::SBBreakpointLocation, SBBreakpoint, - FindLocationByAddress, (lldb::addr_t)); - LLDB_REGISTER_METHOD(lldb::break_id_t, SBBreakpoint, - FindLocationIDByAddress, (lldb::addr_t)); - LLDB_REGISTER_METHOD(lldb::SBBreakpointLocation, SBBreakpoint, - FindLocationByID, (lldb::break_id_t)); - LLDB_REGISTER_METHOD(lldb::SBBreakpointLocation, SBBreakpoint, - GetLocationAtIndex, (uint32_t)); - LLDB_REGISTER_METHOD(void, SBBreakpoint, SetEnabled, (bool)); - LLDB_REGISTER_METHOD(bool, SBBreakpoint, IsEnabled, ()); - LLDB_REGISTER_METHOD(void, SBBreakpoint, SetOneShot, (bool)); - LLDB_REGISTER_METHOD_CONST(bool, SBBreakpoint, IsOneShot, ()); - LLDB_REGISTER_METHOD(bool, SBBreakpoint, IsInternal, ()); - LLDB_REGISTER_METHOD(void, SBBreakpoint, SetIgnoreCount, (uint32_t)); - LLDB_REGISTER_METHOD(void, SBBreakpoint, SetCondition, (const char *)); - LLDB_REGISTER_METHOD(const char *, SBBreakpoint, GetCondition, ()); - LLDB_REGISTER_METHOD(void, SBBreakpoint, SetAutoContinue, (bool)); - LLDB_REGISTER_METHOD(bool, SBBreakpoint, GetAutoContinue, ()); - LLDB_REGISTER_METHOD_CONST(uint32_t, SBBreakpoint, GetHitCount, ()); - LLDB_REGISTER_METHOD_CONST(uint32_t, SBBreakpoint, GetIgnoreCount, ()); - LLDB_REGISTER_METHOD(void, SBBreakpoint, SetThreadID, (lldb::tid_t)); - LLDB_REGISTER_METHOD(lldb::tid_t, SBBreakpoint, GetThreadID, ()); - LLDB_REGISTER_METHOD(void, SBBreakpoint, SetThreadIndex, (uint32_t)); - LLDB_REGISTER_METHOD_CONST(uint32_t, SBBreakpoint, GetThreadIndex, ()); - LLDB_REGISTER_METHOD(void, SBBreakpoint, SetThreadName, (const char *)); - LLDB_REGISTER_METHOD_CONST(const char *, SBBreakpoint, GetThreadName, ()); - LLDB_REGISTER_METHOD(void, SBBreakpoint, SetQueueName, (const char *)); - LLDB_REGISTER_METHOD_CONST(const char *, SBBreakpoint, GetQueueName, ()); - LLDB_REGISTER_METHOD_CONST(size_t, SBBreakpoint, GetNumResolvedLocations, - ()); - LLDB_REGISTER_METHOD_CONST(size_t, SBBreakpoint, GetNumLocations, ()); - LLDB_REGISTER_METHOD(void, SBBreakpoint, SetCommandLineCommands, - (lldb::SBStringList &)); - LLDB_REGISTER_METHOD(bool, SBBreakpoint, GetCommandLineCommands, - (lldb::SBStringList &)); - LLDB_REGISTER_METHOD(bool, SBBreakpoint, GetDescription, - (lldb::SBStream &)); - LLDB_REGISTER_METHOD(bool, SBBreakpoint, GetDescription, - (lldb::SBStream &, bool)); - LLDB_REGISTER_METHOD(lldb::SBError, SBBreakpoint, AddLocation, - (lldb::SBAddress &)); - LLDB_REGISTER_METHOD(lldb::SBStructuredData, SBBreakpoint, - SerializeToStructuredData, ()); - LLDB_REGISTER_METHOD(void, SBBreakpoint, SetScriptCallbackFunction, - (const char *)); - LLDB_REGISTER_METHOD(lldb::SBError, SBBreakpoint, SetScriptCallbackFunction, - (const char *, SBStructuredData &)); - LLDB_REGISTER_METHOD(lldb::SBError, SBBreakpoint, SetScriptCallbackBody, - (const char *)); - LLDB_REGISTER_METHOD(bool, SBBreakpoint, AddName, (const char *)); - LLDB_REGISTER_METHOD(lldb::SBError, SBBreakpoint, AddNameWithErrorHandling, - (const char *)); - LLDB_REGISTER_METHOD(void, SBBreakpoint, RemoveName, (const char *)); - LLDB_REGISTER_METHOD(bool, SBBreakpoint, MatchesName, (const char *)); - LLDB_REGISTER_METHOD(void, SBBreakpoint, GetNames, (lldb::SBStringList &)); - LLDB_REGISTER_STATIC_METHOD(bool, SBBreakpoint, EventIsBreakpointEvent, - (const lldb::SBEvent &)); - LLDB_REGISTER_STATIC_METHOD(lldb::BreakpointEventType, SBBreakpoint, - GetBreakpointEventTypeFromEvent, - (const lldb::SBEvent &)); - LLDB_REGISTER_STATIC_METHOD(lldb::SBBreakpoint, SBBreakpoint, - GetBreakpointFromEvent, - (const lldb::SBEvent &)); - LLDB_REGISTER_STATIC_METHOD(lldb::SBBreakpointLocation, SBBreakpoint, - GetBreakpointLocationAtIndexFromEvent, - (const lldb::SBEvent &, uint32_t)); - LLDB_REGISTER_STATIC_METHOD(uint32_t, SBBreakpoint, - GetNumBreakpointLocationsFromEvent, - (const lldb::SBEvent &)); - LLDB_REGISTER_METHOD_CONST(bool, SBBreakpoint, IsHardware, ()); -} - -template <> -void RegisterMethods<SBBreakpointList>(Registry &R) { - LLDB_REGISTER_CONSTRUCTOR(SBBreakpointList, (lldb::SBTarget &)); - LLDB_REGISTER_METHOD_CONST(size_t, SBBreakpointList, GetSize, ()); - LLDB_REGISTER_METHOD(lldb::SBBreakpoint, SBBreakpointList, - GetBreakpointAtIndex, (size_t)); - LLDB_REGISTER_METHOD(lldb::SBBreakpoint, SBBreakpointList, - FindBreakpointByID, (lldb::break_id_t)); - LLDB_REGISTER_METHOD(void, SBBreakpointList, Append, - (const lldb::SBBreakpoint &)); - LLDB_REGISTER_METHOD(void, SBBreakpointList, AppendByID, - (lldb::break_id_t)); - LLDB_REGISTER_METHOD(bool, SBBreakpointList, AppendIfUnique, - (const lldb::SBBreakpoint &)); - LLDB_REGISTER_METHOD(void, SBBreakpointList, Clear, ()); -} - -} -} diff --git a/lldb/source/API/SBBreakpointLocation.cpp b/lldb/source/API/SBBreakpointLocation.cpp index 175120429925..914317437723 100644 --- a/lldb/source/API/SBBreakpointLocation.cpp +++ b/lldb/source/API/SBBreakpointLocation.cpp @@ -7,13 +7,13 @@ //===----------------------------------------------------------------------===// #include "lldb/API/SBBreakpointLocation.h" -#include "SBReproducerPrivate.h" #include "lldb/API/SBAddress.h" #include "lldb/API/SBDebugger.h" #include "lldb/API/SBDefines.h" #include "lldb/API/SBStream.h" -#include "lldb/API/SBStructuredData.h" #include "lldb/API/SBStringList.h" +#include "lldb/API/SBStructuredData.h" +#include "lldb/Utility/Instrumentation.h" #include "lldb/Breakpoint/Breakpoint.h" #include "lldb/Breakpoint/BreakpointLocation.h" @@ -31,32 +31,25 @@ using namespace lldb; using namespace lldb_private; -SBBreakpointLocation::SBBreakpointLocation() { - LLDB_RECORD_CONSTRUCTOR_NO_ARGS(SBBreakpointLocation); -} +SBBreakpointLocation::SBBreakpointLocation() { LLDB_INSTRUMENT_VA(this); } SBBreakpointLocation::SBBreakpointLocation( const lldb::BreakpointLocationSP &break_loc_sp) : m_opaque_wp(break_loc_sp) { - LLDB_RECORD_CONSTRUCTOR(SBBreakpointLocation, - (const lldb::BreakpointLocationSP &), break_loc_sp); + LLDB_INSTRUMENT_VA(this, break_loc_sp); } SBBreakpointLocation::SBBreakpointLocation(const SBBreakpointLocation &rhs) : m_opaque_wp(rhs.m_opaque_wp) { - LLDB_RECORD_CONSTRUCTOR(SBBreakpointLocation, - (const lldb::SBBreakpointLocation &), rhs); + LLDB_INSTRUMENT_VA(this, rhs); } const SBBreakpointLocation &SBBreakpointLocation:: operator=(const SBBreakpointLocation &rhs) { - LLDB_RECORD_METHOD( - const lldb::SBBreakpointLocation &, - SBBreakpointLocation, operator=,(const lldb::SBBreakpointLocation &), - rhs); + LLDB_INSTRUMENT_VA(this, rhs); m_opaque_wp = rhs.m_opaque_wp; - return LLDB_RECORD_RESULT(*this); + return *this; } SBBreakpointLocation::~SBBreakpointLocation() = default; @@ -66,29 +59,28 @@ BreakpointLocationSP SBBreakpointLocation::GetSP() const { } bool SBBreakpointLocation::IsValid() const { - LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBBreakpointLocation, IsValid); + LLDB_INSTRUMENT_VA(this); return this->operator bool(); } SBBreakpointLocation::operator bool() const { - LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBBreakpointLocation, operator bool); + LLDB_INSTRUMENT_VA(this); return bool(GetSP()); } SBAddress SBBreakpointLocation::GetAddress() { - LLDB_RECORD_METHOD_NO_ARGS(lldb::SBAddress, SBBreakpointLocation, GetAddress); + LLDB_INSTRUMENT_VA(this); BreakpointLocationSP loc_sp = GetSP(); if (loc_sp) { - return LLDB_RECORD_RESULT(SBAddress(loc_sp->GetAddress())); + return SBAddress(loc_sp->GetAddress()); } - return LLDB_RECORD_RESULT(SBAddress()); + return SBAddress(); } addr_t SBBreakpointLocation::GetLoadAddress() { - LLDB_RECORD_METHOD_NO_ARGS(lldb::addr_t, SBBreakpointLocation, - GetLoadAddress); + LLDB_INSTRUMENT_VA(this); addr_t ret_addr = LLDB_INVALID_ADDRESS; BreakpointLocationSP loc_sp = GetSP(); @@ -103,7 +95,7 @@ addr_t SBBreakpointLocation::GetLoadAddress() { } void SBBreakpointLocation::SetEnabled(bool enabled) { - LLDB_RECORD_METHOD(void, SBBreakpointLocation, SetEnabled, (bool), enabled); + LLDB_INSTRUMENT_VA(this, enabled); BreakpointLocationSP loc_sp = GetSP(); if (loc_sp) { @@ -114,7 +106,7 @@ void SBBreakpointLocation::SetEnabled(bool enabled) { } bool SBBreakpointLocation::IsEnabled() { - LLDB_RECORD_METHOD_NO_ARGS(bool, SBBreakpointLocation, IsEnabled); + LLDB_INSTRUMENT_VA(this); BreakpointLocationSP loc_sp = GetSP(); if (loc_sp) { @@ -126,7 +118,7 @@ bool SBBreakpointLocation::IsEnabled() { } uint32_t SBBreakpointLocation::GetHitCount() { - LLDB_RECORD_METHOD_NO_ARGS(uint32_t, SBBreakpointLocation, GetHitCount); + LLDB_INSTRUMENT_VA(this); BreakpointLocationSP loc_sp = GetSP(); if (loc_sp) { @@ -138,7 +130,7 @@ uint32_t SBBreakpointLocation::GetHitCount() { } uint32_t SBBreakpointLocation::GetIgnoreCount() { - LLDB_RECORD_METHOD_NO_ARGS(uint32_t, SBBreakpointLocation, GetIgnoreCount); + LLDB_INSTRUMENT_VA(this); BreakpointLocationSP loc_sp = GetSP(); if (loc_sp) { @@ -150,7 +142,7 @@ uint32_t SBBreakpointLocation::GetIgnoreCount() { } void SBBreakpointLocation::SetIgnoreCount(uint32_t n) { - LLDB_RECORD_METHOD(void, SBBreakpointLocation, SetIgnoreCount, (uint32_t), n); + LLDB_INSTRUMENT_VA(this, n); BreakpointLocationSP loc_sp = GetSP(); if (loc_sp) { @@ -161,8 +153,7 @@ void SBBreakpointLocation::SetIgnoreCount(uint32_t n) { } void SBBreakpointLocation::SetCondition(const char *condition) { - LLDB_RECORD_METHOD(void, SBBreakpointLocation, SetCondition, (const char *), - condition); + LLDB_INSTRUMENT_VA(this, condition); BreakpointLocationSP loc_sp = GetSP(); if (loc_sp) { @@ -173,7 +164,7 @@ void SBBreakpointLocation::SetCondition(const char *condition) { } const char *SBBreakpointLocation::GetCondition() { - LLDB_RECORD_METHOD_NO_ARGS(const char *, SBBreakpointLocation, GetCondition); + LLDB_INSTRUMENT_VA(this); BreakpointLocationSP loc_sp = GetSP(); if (loc_sp) { @@ -185,8 +176,7 @@ const char *SBBreakpointLocation::GetCondition() { } void SBBreakpointLocation::SetAutoContinue(bool auto_continue) { - LLDB_RECORD_METHOD(void, SBBreakpointLocation, SetAutoContinue, (bool), - auto_continue); + LLDB_INSTRUMENT_VA(this, auto_continue); BreakpointLocationSP loc_sp = GetSP(); if (loc_sp) { @@ -197,7 +187,7 @@ void SBBreakpointLocation::SetAutoContinue(bool auto_continue) { } bool SBBreakpointLocation::GetAutoContinue() { - LLDB_RECORD_METHOD_NO_ARGS(bool, SBBreakpointLocation, GetAutoContinue); + LLDB_INSTRUMENT_VA(this); BreakpointLocationSP loc_sp = GetSP(); if (loc_sp) { @@ -210,16 +200,13 @@ bool SBBreakpointLocation::GetAutoContinue() { void SBBreakpointLocation::SetScriptCallbackFunction( const char *callback_function_name) { -LLDB_RECORD_METHOD(void, SBBreakpointLocation, SetScriptCallbackFunction, - (const char *), callback_function_name); + LLDB_INSTRUMENT_VA(this, callback_function_name); } SBError SBBreakpointLocation::SetScriptCallbackFunction( const char *callback_function_name, SBStructuredData &extra_args) { - LLDB_RECORD_METHOD(SBError, SBBreakpointLocation, SetScriptCallbackFunction, - (const char *, SBStructuredData &), callback_function_name, - extra_args); + LLDB_INSTRUMENT_VA(this, callback_function_name, extra_args); SBError sb_error; BreakpointLocationSP loc_sp = GetSP(); @@ -240,13 +227,12 @@ SBError SBBreakpointLocation::SetScriptCallbackFunction( } else sb_error.SetErrorString("invalid breakpoint"); - return LLDB_RECORD_RESULT(sb_error); + return sb_error; } SBError SBBreakpointLocation::SetScriptCallbackBody(const char *callback_body_text) { - LLDB_RECORD_METHOD(lldb::SBError, SBBreakpointLocation, SetScriptCallbackBody, - (const char *), callback_body_text); + LLDB_INSTRUMENT_VA(this, callback_body_text); BreakpointLocationSP loc_sp = GetSP(); @@ -265,12 +251,11 @@ SBBreakpointLocation::SetScriptCallbackBody(const char *callback_body_text) { } else sb_error.SetErrorString("invalid breakpoint"); - return LLDB_RECORD_RESULT(sb_error); + return sb_error; } void SBBreakpointLocation::SetCommandLineCommands(SBStringList &commands) { - LLDB_RECORD_METHOD(void, SBBreakpointLocation, SetCommandLineCommands, - (lldb::SBStringList &), commands); + LLDB_INSTRUMENT_VA(this, commands); BreakpointLocationSP loc_sp = GetSP(); if (!loc_sp) @@ -287,8 +272,7 @@ void SBBreakpointLocation::SetCommandLineCommands(SBStringList &commands) { } bool SBBreakpointLocation::GetCommandLineCommands(SBStringList &commands) { - LLDB_RECORD_METHOD(bool, SBBreakpointLocation, GetCommandLineCommands, - (lldb::SBStringList &), commands); + LLDB_INSTRUMENT_VA(this, commands); BreakpointLocationSP loc_sp = GetSP(); if (!loc_sp) @@ -302,8 +286,7 @@ bool SBBreakpointLocation::GetCommandLineCommands(SBStringList &commands) { } void SBBreakpointLocation::SetThreadID(tid_t thread_id) { - LLDB_RECORD_METHOD(void, SBBreakpointLocation, SetThreadID, (lldb::tid_t), - thread_id); + LLDB_INSTRUMENT_VA(this, thread_id); BreakpointLocationSP loc_sp = GetSP(); if (loc_sp) { @@ -314,7 +297,7 @@ void SBBreakpointLocation::SetThreadID(tid_t thread_id) { } tid_t SBBreakpointLocation::GetThreadID() { - LLDB_RECORD_METHOD_NO_ARGS(lldb::tid_t, SBBreakpointLocation, GetThreadID); + LLDB_INSTRUMENT_VA(this); tid_t tid = LLDB_INVALID_THREAD_ID; BreakpointLocationSP loc_sp = GetSP(); @@ -327,8 +310,7 @@ tid_t SBBreakpointLocation::GetThreadID() { } void SBBreakpointLocation::SetThreadIndex(uint32_t index) { - LLDB_RECORD_METHOD(void, SBBreakpointLocation, SetThreadIndex, (uint32_t), - index); + LLDB_INSTRUMENT_VA(this, index); BreakpointLocationSP loc_sp = GetSP(); if (loc_sp) { @@ -339,8 +321,7 @@ void SBBreakpointLocation::SetThreadIndex(uint32_t index) { } uint32_t SBBreakpointLocation::GetThreadIndex() const { - LLDB_RECORD_METHOD_CONST_NO_ARGS(uint32_t, SBBreakpointLocation, - GetThreadIndex); + LLDB_INSTRUMENT_VA(this); uint32_t thread_idx = UINT32_MAX; BreakpointLocationSP loc_sp = GetSP(); @@ -353,8 +334,7 @@ uint32_t SBBreakpointLocation::GetThreadIndex() const { } void SBBreakpointLocation::SetThreadName(const char *thread_name) { - LLDB_RECORD_METHOD(void, SBBreakpointLocation, SetThreadName, (const char *), - thread_name); + LLDB_INSTRUMENT_VA(this, thread_name); BreakpointLocationSP loc_sp = GetSP(); if (loc_sp) { @@ -365,8 +345,7 @@ void SBBreakpointLocation::SetThreadName(const char *thread_name) { } const char *SBBreakpointLocation::GetThreadName() const { - LLDB_RECORD_METHOD_CONST_NO_ARGS(const char *, SBBreakpointLocation, - GetThreadName); + LLDB_INSTRUMENT_VA(this); BreakpointLocationSP loc_sp = GetSP(); if (loc_sp) { @@ -378,8 +357,7 @@ const char *SBBreakpointLocation::GetThreadName() const { } void SBBreakpointLocation::SetQueueName(const char *queue_name) { - LLDB_RECORD_METHOD(void, SBBreakpointLocation, SetQueueName, (const char *), - queue_name); + LLDB_INSTRUMENT_VA(this, queue_name); BreakpointLocationSP loc_sp = GetSP(); if (loc_sp) { @@ -390,8 +368,7 @@ void SBBreakpointLocation::SetQueueName(const char *queue_name) { } const char *SBBreakpointLocation::GetQueueName() const { - LLDB_RECORD_METHOD_CONST_NO_ARGS(const char *, SBBreakpointLocation, - GetQueueName); + LLDB_INSTRUMENT_VA(this); BreakpointLocationSP loc_sp = GetSP(); if (loc_sp) { @@ -403,7 +380,7 @@ const char *SBBreakpointLocation::GetQueueName() const { } bool SBBreakpointLocation::IsResolved() { - LLDB_RECORD_METHOD_NO_ARGS(bool, SBBreakpointLocation, IsResolved); + LLDB_INSTRUMENT_VA(this); BreakpointLocationSP loc_sp = GetSP(); if (loc_sp) { @@ -422,9 +399,7 @@ void SBBreakpointLocation::SetLocation( bool SBBreakpointLocation::GetDescription(SBStream &description, DescriptionLevel level) { - LLDB_RECORD_METHOD(bool, SBBreakpointLocation, GetDescription, - (lldb::SBStream &, lldb::DescriptionLevel), description, - level); + LLDB_INSTRUMENT_VA(this, description, level); Stream &strm = description.ref(); BreakpointLocationSP loc_sp = GetSP(); @@ -441,7 +416,7 @@ bool SBBreakpointLocation::GetDescription(SBStream &description, } break_id_t SBBreakpointLocation::GetID() { - LLDB_RECORD_METHOD_NO_ARGS(lldb::break_id_t, SBBreakpointLocation, GetID); + LLDB_INSTRUMENT_VA(this); BreakpointLocationSP loc_sp = GetSP(); if (loc_sp) { @@ -453,8 +428,7 @@ break_id_t SBBreakpointLocation::GetID() { } SBBreakpoint SBBreakpointLocation::GetBreakpoint() { - LLDB_RECORD_METHOD_NO_ARGS(lldb::SBBreakpoint, SBBreakpointLocation, - GetBreakpoint); + LLDB_INSTRUMENT_VA(this); BreakpointLocationSP loc_sp = GetSP(); @@ -465,70 +439,5 @@ SBBreakpoint SBBreakpointLocation::GetBreakpoint() { sb_bp = loc_sp->GetBreakpoint().shared_from_this(); } - return LLDB_RECORD_RESULT(sb_bp); -} - -namespace lldb_private { -namespace repro { - -template <> -void RegisterMethods<SBBreakpointLocation>(Registry &R) { - LLDB_REGISTER_CONSTRUCTOR(SBBreakpointLocation, ()); - LLDB_REGISTER_CONSTRUCTOR(SBBreakpointLocation, - (const lldb::BreakpointLocationSP &)); - LLDB_REGISTER_CONSTRUCTOR(SBBreakpointLocation, - (const lldb::SBBreakpointLocation &)); - LLDB_REGISTER_METHOD( - const lldb::SBBreakpointLocation &, - SBBreakpointLocation, operator=,(const lldb::SBBreakpointLocation &)); - LLDB_REGISTER_METHOD_CONST(bool, SBBreakpointLocation, IsValid, ()); - LLDB_REGISTER_METHOD_CONST(bool, SBBreakpointLocation, operator bool, ()); - LLDB_REGISTER_METHOD(lldb::SBAddress, SBBreakpointLocation, GetAddress, ()); - LLDB_REGISTER_METHOD(lldb::addr_t, SBBreakpointLocation, GetLoadAddress, - ()); - LLDB_REGISTER_METHOD(void, SBBreakpointLocation, SetEnabled, (bool)); - LLDB_REGISTER_METHOD(bool, SBBreakpointLocation, IsEnabled, ()); - LLDB_REGISTER_METHOD(uint32_t, SBBreakpointLocation, GetHitCount, ()); - LLDB_REGISTER_METHOD(uint32_t, SBBreakpointLocation, GetIgnoreCount, ()); - LLDB_REGISTER_METHOD(void, SBBreakpointLocation, SetIgnoreCount, - (uint32_t)); - LLDB_REGISTER_METHOD(void, SBBreakpointLocation, SetCondition, - (const char *)); - LLDB_REGISTER_METHOD(const char *, SBBreakpointLocation, GetCondition, ()); - LLDB_REGISTER_METHOD(void, SBBreakpointLocation, SetAutoContinue, (bool)); - LLDB_REGISTER_METHOD(bool, SBBreakpointLocation, GetAutoContinue, ()); - LLDB_REGISTER_METHOD(void, SBBreakpointLocation, SetScriptCallbackFunction, - (const char *)); - LLDB_REGISTER_METHOD(SBError, SBBreakpointLocation, SetScriptCallbackFunction, - (const char *, SBStructuredData &)); - LLDB_REGISTER_METHOD(lldb::SBError, SBBreakpointLocation, - SetScriptCallbackBody, (const char *)); - LLDB_REGISTER_METHOD(void, SBBreakpointLocation, SetCommandLineCommands, - (lldb::SBStringList &)); - LLDB_REGISTER_METHOD(bool, SBBreakpointLocation, GetCommandLineCommands, - (lldb::SBStringList &)); - LLDB_REGISTER_METHOD(void, SBBreakpointLocation, SetThreadID, - (lldb::tid_t)); - LLDB_REGISTER_METHOD(lldb::tid_t, SBBreakpointLocation, GetThreadID, ()); - LLDB_REGISTER_METHOD(void, SBBreakpointLocation, SetThreadIndex, - (uint32_t)); - LLDB_REGISTER_METHOD_CONST(uint32_t, SBBreakpointLocation, GetThreadIndex, - ()); - LLDB_REGISTER_METHOD(void, SBBreakpointLocation, SetThreadName, - (const char *)); - LLDB_REGISTER_METHOD_CONST(const char *, SBBreakpointLocation, - GetThreadName, ()); - LLDB_REGISTER_METHOD(void, SBBreakpointLocation, SetQueueName, - (const char *)); - LLDB_REGISTER_METHOD_CONST(const char *, SBBreakpointLocation, GetQueueName, - ()); - LLDB_REGISTER_METHOD(bool, SBBreakpointLocation, IsResolved, ()); - LLDB_REGISTER_METHOD(bool, SBBreakpointLocation, GetDescription, - (lldb::SBStream &, lldb::DescriptionLevel)); - LLDB_REGISTER_METHOD(lldb::break_id_t, SBBreakpointLocation, GetID, ()); - LLDB_REGISTER_METHOD(lldb::SBBreakpoint, SBBreakpointLocation, - GetBreakpoint, ()); -} - -} + return sb_bp; } diff --git a/lldb/source/API/SBBreakpointName.cpp b/lldb/source/API/SBBreakpointName.cpp index b5c700c78bbb..796229d04ce4 100644 --- a/lldb/source/API/SBBreakpointName.cpp +++ b/lldb/source/API/SBBreakpointName.cpp @@ -7,13 +7,13 @@ //===----------------------------------------------------------------------===// #include "lldb/API/SBBreakpointName.h" -#include "SBReproducerPrivate.h" #include "lldb/API/SBDebugger.h" #include "lldb/API/SBError.h" #include "lldb/API/SBStream.h" #include "lldb/API/SBStringList.h" #include "lldb/API/SBStructuredData.h" #include "lldb/API/SBTarget.h" +#include "lldb/Utility/Instrumentation.h" #include "lldb/Breakpoint/BreakpointName.h" #include "lldb/Breakpoint/StoppointCallbackContext.h" @@ -107,13 +107,10 @@ lldb_private::BreakpointName *SBBreakpointNameImpl::GetBreakpointName() const { } // namespace lldb -SBBreakpointName::SBBreakpointName() { - LLDB_RECORD_CONSTRUCTOR_NO_ARGS(SBBreakpointName); -} +SBBreakpointName::SBBreakpointName() { LLDB_INSTRUMENT_VA(this); } SBBreakpointName::SBBreakpointName(SBTarget &sb_target, const char *name) { - LLDB_RECORD_CONSTRUCTOR(SBBreakpointName, (lldb::SBTarget &, const char *), - sb_target, name); + LLDB_INSTRUMENT_VA(this, sb_target, name); m_impl_up = std::make_unique<SBBreakpointNameImpl>(sb_target, name); // Call FindBreakpointName here to make sure the name is valid, reset if not: @@ -123,8 +120,7 @@ SBBreakpointName::SBBreakpointName(SBTarget &sb_target, const char *name) { } SBBreakpointName::SBBreakpointName(SBBreakpoint &sb_bkpt, const char *name) { - LLDB_RECORD_CONSTRUCTOR(SBBreakpointName, - (lldb::SBBreakpoint &, const char *), sb_bkpt, name); + LLDB_INSTRUMENT_VA(this, sb_bkpt, name); if (!sb_bkpt.IsValid()) { m_impl_up.reset(); @@ -149,8 +145,7 @@ SBBreakpointName::SBBreakpointName(SBBreakpoint &sb_bkpt, const char *name) { } SBBreakpointName::SBBreakpointName(const SBBreakpointName &rhs) { - LLDB_RECORD_CONSTRUCTOR(SBBreakpointName, (const lldb::SBBreakpointName &), - rhs); + LLDB_INSTRUMENT_VA(this, rhs); if (!rhs.m_impl_up) return; @@ -163,40 +158,36 @@ SBBreakpointName::~SBBreakpointName() = default; const SBBreakpointName &SBBreakpointName:: operator=(const SBBreakpointName &rhs) { - LLDB_RECORD_METHOD( - const lldb::SBBreakpointName &, - SBBreakpointName, operator=,(const lldb::SBBreakpointName &), rhs); + LLDB_INSTRUMENT_VA(this, rhs); if (!rhs.m_impl_up) { m_impl_up.reset(); - return LLDB_RECORD_RESULT(*this); + return *this; } m_impl_up = std::make_unique<SBBreakpointNameImpl>(rhs.m_impl_up->GetTarget(), rhs.m_impl_up->GetName()); - return LLDB_RECORD_RESULT(*this); + return *this; } bool SBBreakpointName::operator==(const lldb::SBBreakpointName &rhs) { - LLDB_RECORD_METHOD( - bool, SBBreakpointName, operator==,(const lldb::SBBreakpointName &), rhs); + LLDB_INSTRUMENT_VA(this, rhs); return *m_impl_up == *rhs.m_impl_up; } bool SBBreakpointName::operator!=(const lldb::SBBreakpointName &rhs) { - LLDB_RECORD_METHOD( - bool, SBBreakpointName, operator!=,(const lldb::SBBreakpointName &), rhs); + LLDB_INSTRUMENT_VA(this, rhs); return *m_impl_up != *rhs.m_impl_up; } bool SBBreakpointName::IsValid() const { - LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBBreakpointName, IsValid); + LLDB_INSTRUMENT_VA(this); return this->operator bool(); } SBBreakpointName::operator bool() const { - LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBBreakpointName, operator bool); + LLDB_INSTRUMENT_VA(this); if (!m_impl_up) return false; @@ -204,7 +195,7 @@ SBBreakpointName::operator bool() const { } const char *SBBreakpointName::GetName() const { - LLDB_RECORD_METHOD_CONST_NO_ARGS(const char *, SBBreakpointName, GetName); + LLDB_INSTRUMENT_VA(this); if (!m_impl_up) return "<Invalid Breakpoint Name Object>"; @@ -212,7 +203,7 @@ const char *SBBreakpointName::GetName() const { } void SBBreakpointName::SetEnabled(bool enable) { - LLDB_RECORD_METHOD(void, SBBreakpointName, SetEnabled, (bool), enable); + LLDB_INSTRUMENT_VA(this, enable); BreakpointName *bp_name = GetBreakpointName(); if (!bp_name) @@ -236,7 +227,7 @@ void SBBreakpointName::UpdateName(BreakpointName &bp_name) { } bool SBBreakpointName::IsEnabled() { - LLDB_RECORD_METHOD_NO_ARGS(bool, SBBreakpointName, IsEnabled); + LLDB_INSTRUMENT_VA(this); BreakpointName *bp_name = GetBreakpointName(); if (!bp_name) @@ -249,7 +240,7 @@ bool SBBreakpointName::IsEnabled() { } void SBBreakpointName::SetOneShot(bool one_shot) { - LLDB_RECORD_METHOD(void, SBBreakpointName, SetOneShot, (bool), one_shot); + LLDB_INSTRUMENT_VA(this, one_shot); BreakpointName *bp_name = GetBreakpointName(); if (!bp_name) @@ -263,7 +254,7 @@ void SBBreakpointName::SetOneShot(bool one_shot) { } bool SBBreakpointName::IsOneShot() const { - LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBBreakpointName, IsOneShot); + LLDB_INSTRUMENT_VA(this); const BreakpointName *bp_name = GetBreakpointName(); if (!bp_name) @@ -276,7 +267,7 @@ bool SBBreakpointName::IsOneShot() const { } void SBBreakpointName::SetIgnoreCount(uint32_t count) { - LLDB_RECORD_METHOD(void, SBBreakpointName, SetIgnoreCount, (uint32_t), count); + LLDB_INSTRUMENT_VA(this, count); BreakpointName *bp_name = GetBreakpointName(); if (!bp_name) @@ -290,7 +281,7 @@ void SBBreakpointName::SetIgnoreCount(uint32_t count) { } uint32_t SBBreakpointName::GetIgnoreCount() const { - LLDB_RECORD_METHOD_CONST_NO_ARGS(uint32_t, SBBreakpointName, GetIgnoreCount); + LLDB_INSTRUMENT_VA(this); BreakpointName *bp_name = GetBreakpointName(); if (!bp_name) @@ -303,8 +294,7 @@ uint32_t SBBreakpointName::GetIgnoreCount() const { } void SBBreakpointName::SetCondition(const char *condition) { - LLDB_RECORD_METHOD(void, SBBreakpointName, SetCondition, (const char *), - condition); + LLDB_INSTRUMENT_VA(this, condition); BreakpointName *bp_name = GetBreakpointName(); if (!bp_name) @@ -318,7 +308,7 @@ void SBBreakpointName::SetCondition(const char *condition) { } const char *SBBreakpointName::GetCondition() { - LLDB_RECORD_METHOD_NO_ARGS(const char *, SBBreakpointName, GetCondition); + LLDB_INSTRUMENT_VA(this); BreakpointName *bp_name = GetBreakpointName(); if (!bp_name) @@ -331,8 +321,7 @@ const char *SBBreakpointName::GetCondition() { } void SBBreakpointName::SetAutoContinue(bool auto_continue) { - LLDB_RECORD_METHOD(void, SBBreakpointName, SetAutoContinue, (bool), - auto_continue); + LLDB_INSTRUMENT_VA(this, auto_continue); BreakpointName *bp_name = GetBreakpointName(); if (!bp_name) @@ -346,7 +335,7 @@ void SBBreakpointName::SetAutoContinue(bool auto_continue) { } bool SBBreakpointName::GetAutoContinue() { - LLDB_RECORD_METHOD_NO_ARGS(bool, SBBreakpointName, GetAutoContinue); + LLDB_INSTRUMENT_VA(this); BreakpointName *bp_name = GetBreakpointName(); if (!bp_name) @@ -359,7 +348,7 @@ bool SBBreakpointName::GetAutoContinue() { } void SBBreakpointName::SetThreadID(tid_t tid) { - LLDB_RECORD_METHOD(void, SBBreakpointName, SetThreadID, (lldb::tid_t), tid); + LLDB_INSTRUMENT_VA(this, tid); BreakpointName *bp_name = GetBreakpointName(); if (!bp_name) @@ -373,7 +362,7 @@ void SBBreakpointName::SetThreadID(tid_t tid) { } tid_t SBBreakpointName::GetThreadID() { - LLDB_RECORD_METHOD_NO_ARGS(lldb::tid_t, SBBreakpointName, GetThreadID); + LLDB_INSTRUMENT_VA(this); BreakpointName *bp_name = GetBreakpointName(); if (!bp_name) @@ -386,7 +375,7 @@ tid_t SBBreakpointName::GetThreadID() { } void SBBreakpointName::SetThreadIndex(uint32_t index) { - LLDB_RECORD_METHOD(void, SBBreakpointName, SetThreadIndex, (uint32_t), index); + LLDB_INSTRUMENT_VA(this, index); BreakpointName *bp_name = GetBreakpointName(); if (!bp_name) @@ -400,7 +389,7 @@ void SBBreakpointName::SetThreadIndex(uint32_t index) { } uint32_t SBBreakpointName::GetThreadIndex() const { - LLDB_RECORD_METHOD_CONST_NO_ARGS(uint32_t, SBBreakpointName, GetThreadIndex); + LLDB_INSTRUMENT_VA(this); BreakpointName *bp_name = GetBreakpointName(); if (!bp_name) @@ -413,8 +402,7 @@ uint32_t SBBreakpointName::GetThreadIndex() const { } void SBBreakpointName::SetThreadName(const char *thread_name) { - LLDB_RECORD_METHOD(void, SBBreakpointName, SetThreadName, (const char *), - thread_name); + LLDB_INSTRUMENT_VA(this, thread_name); BreakpointName *bp_name = GetBreakpointName(); if (!bp_name) @@ -428,8 +416,7 @@ void SBBreakpointName::SetThreadName(const char *thread_name) { } const char *SBBreakpointName::GetThreadName() const { - LLDB_RECORD_METHOD_CONST_NO_ARGS(const char *, SBBreakpointName, - GetThreadName); + LLDB_INSTRUMENT_VA(this); BreakpointName *bp_name = GetBreakpointName(); if (!bp_name) @@ -442,8 +429,7 @@ const char *SBBreakpointName::GetThreadName() const { } void SBBreakpointName::SetQueueName(const char *queue_name) { - LLDB_RECORD_METHOD(void, SBBreakpointName, SetQueueName, (const char *), - queue_name); + LLDB_INSTRUMENT_VA(this, queue_name); BreakpointName *bp_name = GetBreakpointName(); if (!bp_name) @@ -457,8 +443,7 @@ void SBBreakpointName::SetQueueName(const char *queue_name) { } const char *SBBreakpointName::GetQueueName() const { - LLDB_RECORD_METHOD_CONST_NO_ARGS(const char *, SBBreakpointName, - GetQueueName); + LLDB_INSTRUMENT_VA(this); BreakpointName *bp_name = GetBreakpointName(); if (!bp_name) @@ -471,8 +456,7 @@ const char *SBBreakpointName::GetQueueName() const { } void SBBreakpointName::SetCommandLineCommands(SBStringList &commands) { - LLDB_RECORD_METHOD(void, SBBreakpointName, SetCommandLineCommands, - (lldb::SBStringList &), commands); + LLDB_INSTRUMENT_VA(this, commands); BreakpointName *bp_name = GetBreakpointName(); if (!bp_name) @@ -491,8 +475,7 @@ void SBBreakpointName::SetCommandLineCommands(SBStringList &commands) { } bool SBBreakpointName::GetCommandLineCommands(SBStringList &commands) { - LLDB_RECORD_METHOD(bool, SBBreakpointName, GetCommandLineCommands, - (lldb::SBStringList &), commands); + LLDB_INSTRUMENT_VA(this, commands); BreakpointName *bp_name = GetBreakpointName(); if (!bp_name) @@ -507,8 +490,7 @@ bool SBBreakpointName::GetCommandLineCommands(SBStringList &commands) { } const char *SBBreakpointName::GetHelpString() const { - LLDB_RECORD_METHOD_CONST_NO_ARGS(const char *, SBBreakpointName, - GetHelpString); + LLDB_INSTRUMENT_VA(this); BreakpointName *bp_name = GetBreakpointName(); if (!bp_name) @@ -518,8 +500,7 @@ const char *SBBreakpointName::GetHelpString() const { } void SBBreakpointName::SetHelpString(const char *help_string) { - LLDB_RECORD_METHOD(void, SBBreakpointName, SetHelpString, (const char *), - help_string); + LLDB_INSTRUMENT_VA(this, help_string); BreakpointName *bp_name = GetBreakpointName(); if (!bp_name) @@ -532,8 +513,7 @@ void SBBreakpointName::SetHelpString(const char *help_string) { } bool SBBreakpointName::GetDescription(SBStream &s) { - LLDB_RECORD_METHOD(bool, SBBreakpointName, GetDescription, (lldb::SBStream &), - s); + LLDB_INSTRUMENT_VA(this, s); BreakpointName *bp_name = GetBreakpointName(); if (!bp_name) @@ -550,8 +530,7 @@ bool SBBreakpointName::GetDescription(SBStream &s) { void SBBreakpointName::SetCallback(SBBreakpointHitCallback callback, void *baton) { - LLDB_RECORD_DUMMY(void, SBBreakpointName, SetCallback, - (lldb::SBBreakpointHitCallback, void *), callback, baton); + LLDB_INSTRUMENT_VA(this, callback, baton); BreakpointName *bp_name = GetBreakpointName(); if (!bp_name) @@ -569,8 +548,7 @@ void SBBreakpointName::SetCallback(SBBreakpointHitCallback callback, void SBBreakpointName::SetScriptCallbackFunction( const char *callback_function_name) { -LLDB_RECORD_METHOD(void, SBBreakpointName, SetScriptCallbackFunction, - (const char *), callback_function_name); + LLDB_INSTRUMENT_VA(this, callback_function_name); SBStructuredData empty_args; SetScriptCallbackFunction(callback_function_name, empty_args); } @@ -578,14 +556,12 @@ LLDB_RECORD_METHOD(void, SBBreakpointName, SetScriptCallbackFunction, SBError SBBreakpointName::SetScriptCallbackFunction( const char *callback_function_name, SBStructuredData &extra_args) { - LLDB_RECORD_METHOD(SBError, SBBreakpointName, SetScriptCallbackFunction, - (const char *, SBStructuredData &), - callback_function_name, extra_args); + LLDB_INSTRUMENT_VA(this, callback_function_name, extra_args); SBError sb_error; BreakpointName *bp_name = GetBreakpointName(); if (!bp_name) { sb_error.SetErrorString("unrecognized breakpoint name"); - return LLDB_RECORD_RESULT(sb_error); + return sb_error; } std::lock_guard<std::recursive_mutex> guard( @@ -601,18 +577,17 @@ SBError SBBreakpointName::SetScriptCallbackFunction( extra_args.m_impl_up->GetObjectSP()); sb_error.SetError(error); UpdateName(*bp_name); - return LLDB_RECORD_RESULT(sb_error); + return sb_error; } SBError SBBreakpointName::SetScriptCallbackBody(const char *callback_body_text) { - LLDB_RECORD_METHOD(lldb::SBError, SBBreakpointName, SetScriptCallbackBody, - (const char *), callback_body_text); + LLDB_INSTRUMENT_VA(this, callback_body_text); SBError sb_error; BreakpointName *bp_name = GetBreakpointName(); if (!bp_name) - return LLDB_RECORD_RESULT(sb_error); + return sb_error; std::lock_guard<std::recursive_mutex> guard( m_impl_up->GetTarget()->GetAPIMutex()); @@ -627,11 +602,11 @@ SBBreakpointName::SetScriptCallbackBody(const char *callback_body_text) { if (!sb_error.Fail()) UpdateName(*bp_name); - return LLDB_RECORD_RESULT(sb_error); + return sb_error; } bool SBBreakpointName::GetAllowList() const { - LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBBreakpointName, GetAllowList); + LLDB_INSTRUMENT_VA(this); BreakpointName *bp_name = GetBreakpointName(); if (!bp_name) @@ -640,8 +615,7 @@ bool SBBreakpointName::GetAllowList() const { } void SBBreakpointName::SetAllowList(bool value) { - LLDB_RECORD_METHOD(void, SBBreakpointName, SetAllowList, (bool), value); - + LLDB_INSTRUMENT_VA(this, value); BreakpointName *bp_name = GetBreakpointName(); if (!bp_name) @@ -650,7 +624,7 @@ void SBBreakpointName::SetAllowList(bool value) { } bool SBBreakpointName::GetAllowDelete() { - LLDB_RECORD_METHOD_NO_ARGS(bool, SBBreakpointName, GetAllowDelete); + LLDB_INSTRUMENT_VA(this); BreakpointName *bp_name = GetBreakpointName(); if (!bp_name) @@ -659,8 +633,7 @@ bool SBBreakpointName::GetAllowDelete() { } void SBBreakpointName::SetAllowDelete(bool value) { - LLDB_RECORD_METHOD(void, SBBreakpointName, SetAllowDelete, (bool), value); - + LLDB_INSTRUMENT_VA(this, value); BreakpointName *bp_name = GetBreakpointName(); if (!bp_name) @@ -669,7 +642,7 @@ void SBBreakpointName::SetAllowDelete(bool value) { } bool SBBreakpointName::GetAllowDisable() { - LLDB_RECORD_METHOD_NO_ARGS(bool, SBBreakpointName, GetAllowDisable); + LLDB_INSTRUMENT_VA(this); BreakpointName *bp_name = GetBreakpointName(); if (!bp_name) @@ -678,7 +651,7 @@ bool SBBreakpointName::GetAllowDisable() { } void SBBreakpointName::SetAllowDisable(bool value) { - LLDB_RECORD_METHOD(void, SBBreakpointName, SetAllowDisable, (bool), value); + LLDB_INSTRUMENT_VA(this, value); BreakpointName *bp_name = GetBreakpointName(); if (!bp_name) @@ -692,72 +665,3 @@ lldb_private::BreakpointName *SBBreakpointName::GetBreakpointName() const return nullptr; return m_impl_up->GetBreakpointName(); } - - -namespace lldb_private { -namespace repro { - -template <> -void RegisterMethods<SBBreakpointName>(Registry &R) { - LLDB_REGISTER_CONSTRUCTOR(SBBreakpointName, ()); - LLDB_REGISTER_CONSTRUCTOR(SBBreakpointName, - (lldb::SBTarget &, const char *)); - LLDB_REGISTER_CONSTRUCTOR(SBBreakpointName, - (lldb::SBBreakpoint &, const char *)); - LLDB_REGISTER_CONSTRUCTOR(SBBreakpointName, - (const lldb::SBBreakpointName &)); - LLDB_REGISTER_METHOD( - const lldb::SBBreakpointName &, - SBBreakpointName, operator=,(const lldb::SBBreakpointName &)); - LLDB_REGISTER_METHOD( - bool, SBBreakpointName, operator==,(const lldb::SBBreakpointName &)); - LLDB_REGISTER_METHOD( - bool, SBBreakpointName, operator!=,(const lldb::SBBreakpointName &)); - LLDB_REGISTER_METHOD_CONST(bool, SBBreakpointName, IsValid, ()); - LLDB_REGISTER_METHOD_CONST(bool, SBBreakpointName, operator bool, ()); - LLDB_REGISTER_METHOD_CONST(const char *, SBBreakpointName, GetName, ()); - LLDB_REGISTER_METHOD(void, SBBreakpointName, SetEnabled, (bool)); - LLDB_REGISTER_METHOD(bool, SBBreakpointName, IsEnabled, ()); - LLDB_REGISTER_METHOD(void, SBBreakpointName, SetOneShot, (bool)); - LLDB_REGISTER_METHOD_CONST(bool, SBBreakpointName, IsOneShot, ()); - LLDB_REGISTER_METHOD(void, SBBreakpointName, SetIgnoreCount, (uint32_t)); - LLDB_REGISTER_METHOD_CONST(uint32_t, SBBreakpointName, GetIgnoreCount, ()); - LLDB_REGISTER_METHOD(void, SBBreakpointName, SetCondition, (const char *)); - LLDB_REGISTER_METHOD(const char *, SBBreakpointName, GetCondition, ()); - LLDB_REGISTER_METHOD(void, SBBreakpointName, SetAutoContinue, (bool)); - LLDB_REGISTER_METHOD(bool, SBBreakpointName, GetAutoContinue, ()); - LLDB_REGISTER_METHOD(void, SBBreakpointName, SetThreadID, (lldb::tid_t)); - LLDB_REGISTER_METHOD(lldb::tid_t, SBBreakpointName, GetThreadID, ()); - LLDB_REGISTER_METHOD(void, SBBreakpointName, SetThreadIndex, (uint32_t)); - LLDB_REGISTER_METHOD_CONST(uint32_t, SBBreakpointName, GetThreadIndex, ()); - LLDB_REGISTER_METHOD(void, SBBreakpointName, SetThreadName, (const char *)); - LLDB_REGISTER_METHOD_CONST(const char *, SBBreakpointName, GetThreadName, - ()); - LLDB_REGISTER_METHOD(void, SBBreakpointName, SetQueueName, (const char *)); - LLDB_REGISTER_METHOD_CONST(const char *, SBBreakpointName, GetQueueName, - ()); - LLDB_REGISTER_METHOD(void, SBBreakpointName, SetCommandLineCommands, - (lldb::SBStringList &)); - LLDB_REGISTER_METHOD(bool, SBBreakpointName, GetCommandLineCommands, - (lldb::SBStringList &)); - LLDB_REGISTER_METHOD_CONST(const char *, SBBreakpointName, GetHelpString, - ()); - LLDB_REGISTER_METHOD(void, SBBreakpointName, SetHelpString, (const char *)); - LLDB_REGISTER_METHOD(bool, SBBreakpointName, GetDescription, - (lldb::SBStream &)); - LLDB_REGISTER_METHOD(void, SBBreakpointName, SetScriptCallbackFunction, - (const char *)); - LLDB_REGISTER_METHOD(SBError, SBBreakpointName, SetScriptCallbackFunction, - (const char *, SBStructuredData &)); - LLDB_REGISTER_METHOD(lldb::SBError, SBBreakpointName, SetScriptCallbackBody, - (const char *)); - LLDB_REGISTER_METHOD_CONST(bool, SBBreakpointName, GetAllowList, ()); - LLDB_REGISTER_METHOD(void, SBBreakpointName, SetAllowList, (bool)); - LLDB_REGISTER_METHOD(bool, SBBreakpointName, GetAllowDelete, ()); - LLDB_REGISTER_METHOD(void, SBBreakpointName, SetAllowDelete, (bool)); - LLDB_REGISTER_METHOD(bool, SBBreakpointName, GetAllowDisable, ()); - LLDB_REGISTER_METHOD(void, SBBreakpointName, SetAllowDisable, (bool)); -} - -} -} diff --git a/lldb/source/API/SBBreakpointOptionCommon.cpp b/lldb/source/API/SBBreakpointOptionCommon.cpp index 2ee47ff7795c..685ed172c820 100644 --- a/lldb/source/API/SBBreakpointOptionCommon.cpp +++ b/lldb/source/API/SBBreakpointOptionCommon.cpp @@ -26,6 +26,7 @@ #include "lldb/Target/Target.h" #include "lldb/Target/Thread.h" #include "lldb/Target/ThreadSpec.h" +#include "lldb/Utility/Instrumentation.h" #include "lldb/Utility/Log.h" #include "lldb/Utility/Stream.h" @@ -38,19 +39,18 @@ using namespace lldb; using namespace lldb_private; -SBBreakpointCallbackBaton::SBBreakpointCallbackBaton(SBBreakpointHitCallback - callback, - void *baton) - : TypedBaton(std::make_unique<CallbackData>()) { - getItem()->callback = callback; - getItem()->callback_baton = baton; - } +SBBreakpointCallbackBaton::SBBreakpointCallbackBaton( + SBBreakpointHitCallback callback, void *baton) + : TypedBaton(std::make_unique<CallbackData>()) { + LLDB_INSTRUMENT_VA(this, callback, baton); + getItem()->callback = callback; + getItem()->callback_baton = baton; +} - bool SBBreakpointCallbackBaton::PrivateBreakpointHitCallback(void *baton, - StoppointCallbackContext *ctx, - lldb::user_id_t break_id, - lldb::user_id_t break_loc_id) -{ +bool SBBreakpointCallbackBaton::PrivateBreakpointHitCallback( + void *baton, StoppointCallbackContext *ctx, lldb::user_id_t break_id, + lldb::user_id_t break_loc_id) { + LLDB_INSTRUMENT_VA(baton, ctx, break_id, break_loc_id); ExecutionContext exe_ctx(ctx->exe_ctx_ref); BreakpointSP bp_sp( exe_ctx.GetTargetRef().GetBreakpointList().FindBreakpointByID(break_id)); diff --git a/lldb/source/API/SBBroadcaster.cpp b/lldb/source/API/SBBroadcaster.cpp index 2e6d837f102b..f145bc6e99d8 100644 --- a/lldb/source/API/SBBroadcaster.cpp +++ b/lldb/source/API/SBBroadcaster.cpp @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#include "SBReproducerPrivate.h" #include "lldb/Utility/Broadcaster.h" +#include "lldb/Utility/Instrumentation.h" #include "lldb/API/SBBroadcaster.h" #include "lldb/API/SBEvent.h" @@ -16,13 +16,11 @@ using namespace lldb; using namespace lldb_private; -SBBroadcaster::SBBroadcaster() : m_opaque_sp() { - LLDB_RECORD_CONSTRUCTOR_NO_ARGS(SBBroadcaster); -} +SBBroadcaster::SBBroadcaster() { LLDB_INSTRUMENT_VA(this); } SBBroadcaster::SBBroadcaster(const char *name) : m_opaque_sp(new Broadcaster(nullptr, name)), m_opaque_ptr(nullptr) { - LLDB_RECORD_CONSTRUCTOR(SBBroadcaster, (const char *), name); + LLDB_INSTRUMENT_VA(this, name); m_opaque_ptr = m_opaque_sp.get(); } @@ -32,26 +30,23 @@ SBBroadcaster::SBBroadcaster(lldb_private::Broadcaster *broadcaster, bool owns) SBBroadcaster::SBBroadcaster(const SBBroadcaster &rhs) : m_opaque_sp(rhs.m_opaque_sp), m_opaque_ptr(rhs.m_opaque_ptr) { - LLDB_RECORD_CONSTRUCTOR(SBBroadcaster, (const lldb::SBBroadcaster &), rhs); + LLDB_INSTRUMENT_VA(this, rhs); } const SBBroadcaster &SBBroadcaster::operator=(const SBBroadcaster &rhs) { - LLDB_RECORD_METHOD(const lldb::SBBroadcaster &, - SBBroadcaster, operator=,(const lldb::SBBroadcaster &), - rhs); + LLDB_INSTRUMENT_VA(this, rhs); if (this != &rhs) { m_opaque_sp = rhs.m_opaque_sp; m_opaque_ptr = rhs.m_opaque_ptr; } - return LLDB_RECORD_RESULT(*this); + return *this; } SBBroadcaster::~SBBroadcaster() { reset(nullptr, false); } void SBBroadcaster::BroadcastEventByType(uint32_t event_type, bool unique) { - LLDB_RECORD_METHOD(void, SBBroadcaster, BroadcastEventByType, - (uint32_t, bool), event_type, unique); + LLDB_INSTRUMENT_VA(this, event_type, unique); if (m_opaque_ptr == nullptr) return; @@ -63,8 +58,7 @@ void SBBroadcaster::BroadcastEventByType(uint32_t event_type, bool unique) { } void SBBroadcaster::BroadcastEvent(const SBEvent &event, bool unique) { - LLDB_RECORD_METHOD(void, SBBroadcaster, BroadcastEvent, - (const lldb::SBEvent &, bool), event, unique); + LLDB_INSTRUMENT_VA(this, event, unique); if (m_opaque_ptr == nullptr) return; @@ -78,9 +72,7 @@ void SBBroadcaster::BroadcastEvent(const SBEvent &event, bool unique) { void SBBroadcaster::AddInitialEventsToListener(const SBListener &listener, uint32_t requested_events) { - LLDB_RECORD_METHOD(void, SBBroadcaster, AddInitialEventsToListener, - (const lldb::SBListener &, uint32_t), listener, - requested_events); + LLDB_INSTRUMENT_VA(this, listener, requested_events); if (m_opaque_ptr) m_opaque_ptr->AddInitialEventsToListener(listener.m_opaque_sp, @@ -89,9 +81,7 @@ void SBBroadcaster::AddInitialEventsToListener(const SBListener &listener, uint32_t SBBroadcaster::AddListener(const SBListener &listener, uint32_t event_mask) { - LLDB_RECORD_METHOD(uint32_t, SBBroadcaster, AddListener, - (const lldb::SBListener &, uint32_t), listener, - event_mask); + LLDB_INSTRUMENT_VA(this, listener, event_mask); if (m_opaque_ptr) return m_opaque_ptr->AddListener(listener.m_opaque_sp, event_mask); @@ -99,7 +89,7 @@ uint32_t SBBroadcaster::AddListener(const SBListener &listener, } const char *SBBroadcaster::GetName() const { - LLDB_RECORD_METHOD_CONST_NO_ARGS(const char *, SBBroadcaster, GetName); + LLDB_INSTRUMENT_VA(this); if (m_opaque_ptr) return m_opaque_ptr->GetBroadcasterName().GetCString(); @@ -107,8 +97,7 @@ const char *SBBroadcaster::GetName() const { } bool SBBroadcaster::EventTypeHasListeners(uint32_t event_type) { - LLDB_RECORD_METHOD(bool, SBBroadcaster, EventTypeHasListeners, (uint32_t), - event_type); + LLDB_INSTRUMENT_VA(this, event_type); if (m_opaque_ptr) return m_opaque_ptr->EventTypeHasListeners(event_type); @@ -117,9 +106,7 @@ bool SBBroadcaster::EventTypeHasListeners(uint32_t event_type) { bool SBBroadcaster::RemoveListener(const SBListener &listener, uint32_t event_mask) { - LLDB_RECORD_METHOD(bool, SBBroadcaster, RemoveListener, - (const lldb::SBListener &, uint32_t), listener, - event_mask); + LLDB_INSTRUMENT_VA(this, listener, event_mask); if (m_opaque_ptr) return m_opaque_ptr->RemoveListener(listener.m_opaque_sp, event_mask); @@ -137,77 +124,36 @@ void SBBroadcaster::reset(Broadcaster *broadcaster, bool owns) { } bool SBBroadcaster::IsValid() const { - LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBBroadcaster, IsValid); + LLDB_INSTRUMENT_VA(this); return this->operator bool(); } SBBroadcaster::operator bool() const { - LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBBroadcaster, operator bool); + LLDB_INSTRUMENT_VA(this); return m_opaque_ptr != nullptr; } void SBBroadcaster::Clear() { - LLDB_RECORD_METHOD_NO_ARGS(void, SBBroadcaster, Clear); + LLDB_INSTRUMENT_VA(this); m_opaque_sp.reset(); m_opaque_ptr = nullptr; } bool SBBroadcaster::operator==(const SBBroadcaster &rhs) const { - LLDB_RECORD_METHOD_CONST( - bool, SBBroadcaster, operator==,(const lldb::SBBroadcaster &), rhs); + LLDB_INSTRUMENT_VA(this, rhs); return m_opaque_ptr == rhs.m_opaque_ptr; } bool SBBroadcaster::operator!=(const SBBroadcaster &rhs) const { - LLDB_RECORD_METHOD_CONST( - bool, SBBroadcaster, operator!=,(const lldb::SBBroadcaster &), rhs); + LLDB_INSTRUMENT_VA(this, rhs); return m_opaque_ptr != rhs.m_opaque_ptr; } bool SBBroadcaster::operator<(const SBBroadcaster &rhs) const { - LLDB_RECORD_METHOD_CONST( - bool, SBBroadcaster, operator<,(const lldb::SBBroadcaster &), rhs); + LLDB_INSTRUMENT_VA(this, rhs); return m_opaque_ptr < rhs.m_opaque_ptr; } - -namespace lldb_private { -namespace repro { - -template <> -void RegisterMethods<SBBroadcaster>(Registry &R) { - LLDB_REGISTER_CONSTRUCTOR(SBBroadcaster, ()); - LLDB_REGISTER_CONSTRUCTOR(SBBroadcaster, (const char *)); - LLDB_REGISTER_CONSTRUCTOR(SBBroadcaster, (const lldb::SBBroadcaster &)); - LLDB_REGISTER_METHOD( - const lldb::SBBroadcaster &, - SBBroadcaster, operator=,(const lldb::SBBroadcaster &)); - LLDB_REGISTER_METHOD(void, SBBroadcaster, BroadcastEventByType, - (uint32_t, bool)); - LLDB_REGISTER_METHOD(void, SBBroadcaster, BroadcastEvent, - (const lldb::SBEvent &, bool)); - LLDB_REGISTER_METHOD(void, SBBroadcaster, AddInitialEventsToListener, - (const lldb::SBListener &, uint32_t)); - LLDB_REGISTER_METHOD(uint32_t, SBBroadcaster, AddListener, - (const lldb::SBListener &, uint32_t)); - LLDB_REGISTER_METHOD_CONST(const char *, SBBroadcaster, GetName, ()); - LLDB_REGISTER_METHOD(bool, SBBroadcaster, EventTypeHasListeners, - (uint32_t)); - LLDB_REGISTER_METHOD(bool, SBBroadcaster, RemoveListener, - (const lldb::SBListener &, uint32_t)); - LLDB_REGISTER_METHOD_CONST(bool, SBBroadcaster, IsValid, ()); - LLDB_REGISTER_METHOD_CONST(bool, SBBroadcaster, operator bool, ()); - LLDB_REGISTER_METHOD(void, SBBroadcaster, Clear, ()); - LLDB_REGISTER_METHOD_CONST( - bool, SBBroadcaster, operator==,(const lldb::SBBroadcaster &)); - LLDB_REGISTER_METHOD_CONST( - bool, SBBroadcaster, operator!=,(const lldb::SBBroadcaster &)); - LLDB_REGISTER_METHOD_CONST( - bool, SBBroadcaster, operator<,(const lldb::SBBroadcaster &)); -} - -} -} diff --git a/lldb/source/API/SBCommandInterpreter.cpp b/lldb/source/API/SBCommandInterpreter.cpp index 3830f6ed80ba..073c1a1b042c 100644 --- a/lldb/source/API/SBCommandInterpreter.cpp +++ b/lldb/source/API/SBCommandInterpreter.cpp @@ -8,11 +8,11 @@ #include "lldb/lldb-types.h" -#include "SBReproducerPrivate.h" #include "lldb/Interpreter/CommandInterpreter.h" #include "lldb/Interpreter/CommandObjectMultiword.h" #include "lldb/Interpreter/CommandReturnObject.h" #include "lldb/Target/Target.h" +#include "lldb/Utility/Instrumentation.h" #include "lldb/Utility/Listener.h" #include "lldb/API/SBBroadcaster.h" @@ -78,71 +78,62 @@ protected: SBCommandInterpreter::SBCommandInterpreter(CommandInterpreter *interpreter) : m_opaque_ptr(interpreter) { - LLDB_RECORD_CONSTRUCTOR(SBCommandInterpreter, - (lldb_private::CommandInterpreter *), interpreter); - + LLDB_INSTRUMENT_VA(this, interpreter); } SBCommandInterpreter::SBCommandInterpreter(const SBCommandInterpreter &rhs) : m_opaque_ptr(rhs.m_opaque_ptr) { - LLDB_RECORD_CONSTRUCTOR(SBCommandInterpreter, - (const lldb::SBCommandInterpreter &), rhs); + LLDB_INSTRUMENT_VA(this, rhs); } SBCommandInterpreter::~SBCommandInterpreter() = default; const SBCommandInterpreter &SBCommandInterpreter:: operator=(const SBCommandInterpreter &rhs) { - LLDB_RECORD_METHOD( - const lldb::SBCommandInterpreter &, - SBCommandInterpreter, operator=,(const lldb::SBCommandInterpreter &), - rhs); + LLDB_INSTRUMENT_VA(this, rhs); m_opaque_ptr = rhs.m_opaque_ptr; - return LLDB_RECORD_RESULT(*this); + return *this; } bool SBCommandInterpreter::IsValid() const { - LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBCommandInterpreter, IsValid); + LLDB_INSTRUMENT_VA(this); return this->operator bool(); } SBCommandInterpreter::operator bool() const { - LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBCommandInterpreter, operator bool); + LLDB_INSTRUMENT_VA(this); return m_opaque_ptr != nullptr; } bool SBCommandInterpreter::CommandExists(const char *cmd) { - LLDB_RECORD_METHOD(bool, SBCommandInterpreter, CommandExists, (const char *), - cmd); + LLDB_INSTRUMENT_VA(this, cmd); return (((cmd != nullptr) && IsValid()) ? m_opaque_ptr->CommandExists(cmd) : false); } bool SBCommandInterpreter::AliasExists(const char *cmd) { - LLDB_RECORD_METHOD(bool, SBCommandInterpreter, AliasExists, (const char *), - cmd); + LLDB_INSTRUMENT_VA(this, cmd); return (((cmd != nullptr) && IsValid()) ? m_opaque_ptr->AliasExists(cmd) : false); } bool SBCommandInterpreter::IsActive() { - LLDB_RECORD_METHOD_NO_ARGS(bool, SBCommandInterpreter, IsActive); + LLDB_INSTRUMENT_VA(this); return (IsValid() ? m_opaque_ptr->IsActive() : false); } bool SBCommandInterpreter::WasInterrupted() const { - LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBCommandInterpreter, WasInterrupted); + LLDB_INSTRUMENT_VA(this); return (IsValid() ? m_opaque_ptr->WasInterrupted() : false); } const char *SBCommandInterpreter::GetIOHandlerControlSequence(char ch) { - LLDB_RECORD_METHOD(const char *, SBCommandInterpreter, - GetIOHandlerControlSequence, (char), ch); + LLDB_INSTRUMENT_VA(this, ch); return (IsValid() ? m_opaque_ptr->GetDebugger() @@ -155,9 +146,7 @@ lldb::ReturnStatus SBCommandInterpreter::HandleCommand(const char *command_line, SBCommandReturnObject &result, bool add_to_history) { - LLDB_RECORD_METHOD(lldb::ReturnStatus, SBCommandInterpreter, HandleCommand, - (const char *, lldb::SBCommandReturnObject &, bool), - command_line, result, add_to_history); + LLDB_INSTRUMENT_VA(this, command_line, result, add_to_history); SBExecutionContext sb_exe_ctx; return HandleCommand(command_line, sb_exe_ctx, result, add_to_history); @@ -166,10 +155,8 @@ SBCommandInterpreter::HandleCommand(const char *command_line, lldb::ReturnStatus SBCommandInterpreter::HandleCommand( const char *command_line, SBExecutionContext &override_context, SBCommandReturnObject &result, bool add_to_history) { - LLDB_RECORD_METHOD(lldb::ReturnStatus, SBCommandInterpreter, HandleCommand, - (const char *, lldb::SBExecutionContext &, - lldb::SBCommandReturnObject &, bool), - command_line, override_context, result, add_to_history); + LLDB_INSTRUMENT_VA(this, command_line, override_context, result, + add_to_history); result.Clear(); if (command_line && IsValid()) { @@ -194,11 +181,7 @@ void SBCommandInterpreter::HandleCommandsFromFile( lldb::SBFileSpec &file, lldb::SBExecutionContext &override_context, lldb::SBCommandInterpreterRunOptions &options, lldb::SBCommandReturnObject result) { - LLDB_RECORD_METHOD(void, SBCommandInterpreter, HandleCommandsFromFile, - (lldb::SBFileSpec &, lldb::SBExecutionContext &, - lldb::SBCommandInterpreterRunOptions &, - lldb::SBCommandReturnObject), - file, override_context, options, result); + LLDB_INSTRUMENT_VA(this, file, override_context, options, result); if (!IsValid()) { result->AppendError("SBCommandInterpreter is not valid."); @@ -225,10 +208,7 @@ void SBCommandInterpreter::HandleCommandsFromFile( int SBCommandInterpreter::HandleCompletion( const char *current_line, const char *cursor, const char *last_char, int match_start_point, int max_return_elements, SBStringList &matches) { - LLDB_RECORD_METHOD(int, SBCommandInterpreter, HandleCompletion, - (const char *, const char *, const char *, int, int, - lldb::SBStringList &), - current_line, cursor, last_char, match_start_point, + LLDB_INSTRUMENT_VA(this, current_line, cursor, last_char, match_start_point, max_return_elements, matches); SBStringList dummy_descriptions; @@ -241,11 +221,7 @@ int SBCommandInterpreter::HandleCompletionWithDescriptions( const char *current_line, const char *cursor, const char *last_char, int match_start_point, int max_return_elements, SBStringList &matches, SBStringList &descriptions) { - LLDB_RECORD_METHOD(int, SBCommandInterpreter, - HandleCompletionWithDescriptions, - (const char *, const char *, const char *, int, int, - lldb::SBStringList &, lldb::SBStringList &), - current_line, cursor, last_char, match_start_point, + LLDB_INSTRUMENT_VA(this, current_line, cursor, last_char, match_start_point, max_return_elements, matches, descriptions); // Sanity check the arguments that are passed in: cursor & last_char have to @@ -311,11 +287,7 @@ int SBCommandInterpreter::HandleCompletionWithDescriptions( const char *current_line, uint32_t cursor_pos, int match_start_point, int max_return_elements, SBStringList &matches, SBStringList &descriptions) { - LLDB_RECORD_METHOD(int, SBCommandInterpreter, - HandleCompletionWithDescriptions, - (const char *, uint32_t, int, int, lldb::SBStringList &, - lldb::SBStringList &), - current_line, cursor_pos, match_start_point, + LLDB_INSTRUMENT_VA(this, current_line, cursor_pos, match_start_point, max_return_elements, matches, descriptions); const char *cursor = current_line + cursor_pos; @@ -330,9 +302,7 @@ int SBCommandInterpreter::HandleCompletion(const char *current_line, int match_start_point, int max_return_elements, lldb::SBStringList &matches) { - LLDB_RECORD_METHOD(int, SBCommandInterpreter, HandleCompletion, - (const char *, uint32_t, int, int, lldb::SBStringList &), - current_line, cursor_pos, match_start_point, + LLDB_INSTRUMENT_VA(this, current_line, cursor_pos, match_start_point, max_return_elements, matches); const char *cursor = current_line + cursor_pos; @@ -342,25 +312,25 @@ int SBCommandInterpreter::HandleCompletion(const char *current_line, } bool SBCommandInterpreter::HasCommands() { - LLDB_RECORD_METHOD_NO_ARGS(bool, SBCommandInterpreter, HasCommands); + LLDB_INSTRUMENT_VA(this); return (IsValid() ? m_opaque_ptr->HasCommands() : false); } bool SBCommandInterpreter::HasAliases() { - LLDB_RECORD_METHOD_NO_ARGS(bool, SBCommandInterpreter, HasAliases); + LLDB_INSTRUMENT_VA(this); return (IsValid() ? m_opaque_ptr->HasAliases() : false); } bool SBCommandInterpreter::HasAliasOptions() { - LLDB_RECORD_METHOD_NO_ARGS(bool, SBCommandInterpreter, HasAliasOptions); + LLDB_INSTRUMENT_VA(this); return (IsValid() ? m_opaque_ptr->HasAliasOptions() : false); } SBProcess SBCommandInterpreter::GetProcess() { - LLDB_RECORD_METHOD_NO_ARGS(lldb::SBProcess, SBCommandInterpreter, GetProcess); + LLDB_INSTRUMENT_VA(this); SBProcess sb_process; ProcessSP process_sp; @@ -373,43 +343,41 @@ SBProcess SBCommandInterpreter::GetProcess() { } } - return LLDB_RECORD_RESULT(sb_process); + return sb_process; } SBDebugger SBCommandInterpreter::GetDebugger() { - LLDB_RECORD_METHOD_NO_ARGS(lldb::SBDebugger, SBCommandInterpreter, - GetDebugger); + LLDB_INSTRUMENT_VA(this); SBDebugger sb_debugger; if (IsValid()) sb_debugger.reset(m_opaque_ptr->GetDebugger().shared_from_this()); - return LLDB_RECORD_RESULT(sb_debugger); + return sb_debugger; } bool SBCommandInterpreter::GetPromptOnQuit() { - LLDB_RECORD_METHOD_NO_ARGS(bool, SBCommandInterpreter, GetPromptOnQuit); + LLDB_INSTRUMENT_VA(this); return (IsValid() ? m_opaque_ptr->GetPromptOnQuit() : false); } void SBCommandInterpreter::SetPromptOnQuit(bool b) { - LLDB_RECORD_METHOD(void, SBCommandInterpreter, SetPromptOnQuit, (bool), b); + LLDB_INSTRUMENT_VA(this, b); if (IsValid()) m_opaque_ptr->SetPromptOnQuit(b); } void SBCommandInterpreter::AllowExitCodeOnQuit(bool allow) { - LLDB_RECORD_METHOD(void, SBCommandInterpreter, AllowExitCodeOnQuit, (bool), - allow); + LLDB_INSTRUMENT_VA(this, allow); if (m_opaque_ptr) m_opaque_ptr->AllowExitCodeOnQuit(allow); } bool SBCommandInterpreter::HasCustomQuitExitCode() { - LLDB_RECORD_METHOD_NO_ARGS(bool, SBCommandInterpreter, HasCustomQuitExitCode); + LLDB_INSTRUMENT_VA(this); bool exited = false; if (m_opaque_ptr) @@ -418,7 +386,7 @@ bool SBCommandInterpreter::HasCustomQuitExitCode() { } int SBCommandInterpreter::GetQuitStatus() { - LLDB_RECORD_METHOD_NO_ARGS(int, SBCommandInterpreter, GetQuitStatus); + LLDB_INSTRUMENT_VA(this); bool exited = false; return (m_opaque_ptr ? m_opaque_ptr->GetQuitExitCode(exited) : 0); @@ -426,9 +394,7 @@ int SBCommandInterpreter::GetQuitStatus() { void SBCommandInterpreter::ResolveCommand(const char *command_line, SBCommandReturnObject &result) { - LLDB_RECORD_METHOD(void, SBCommandInterpreter, ResolveCommand, - (const char *, lldb::SBCommandReturnObject &), - command_line, result); + LLDB_INSTRUMENT_VA(this, command_line, result); result.Clear(); if (command_line && IsValid()) { @@ -453,8 +419,7 @@ void SBCommandInterpreter::reset( void SBCommandInterpreter::SourceInitFileInHomeDirectory( SBCommandReturnObject &result) { - LLDB_RECORD_METHOD(void, SBCommandInterpreter, SourceInitFileInHomeDirectory, - (lldb::SBCommandReturnObject &), result); + LLDB_INSTRUMENT_VA(this, result); result.Clear(); if (IsValid()) { @@ -470,8 +435,7 @@ void SBCommandInterpreter::SourceInitFileInHomeDirectory( void SBCommandInterpreter::SourceInitFileInHomeDirectory( SBCommandReturnObject &result, bool is_repl) { - LLDB_RECORD_METHOD(void, SBCommandInterpreter, SourceInitFileInHomeDirectory, - (lldb::SBCommandReturnObject &, bool), result, is_repl); + LLDB_INSTRUMENT_VA(this, result, is_repl); result.Clear(); if (IsValid()) { @@ -487,9 +451,7 @@ void SBCommandInterpreter::SourceInitFileInHomeDirectory( void SBCommandInterpreter::SourceInitFileInCurrentWorkingDirectory( SBCommandReturnObject &result) { - LLDB_RECORD_METHOD(void, SBCommandInterpreter, - SourceInitFileInCurrentWorkingDirectory, - (lldb::SBCommandReturnObject &), result); + LLDB_INSTRUMENT_VA(this, result); result.Clear(); if (IsValid()) { @@ -504,46 +466,36 @@ void SBCommandInterpreter::SourceInitFileInCurrentWorkingDirectory( } SBBroadcaster SBCommandInterpreter::GetBroadcaster() { - LLDB_RECORD_METHOD_NO_ARGS(lldb::SBBroadcaster, SBCommandInterpreter, - GetBroadcaster); - + LLDB_INSTRUMENT_VA(this); SBBroadcaster broadcaster(m_opaque_ptr, false); - - return LLDB_RECORD_RESULT(broadcaster); + return broadcaster; } const char *SBCommandInterpreter::GetBroadcasterClass() { - LLDB_RECORD_STATIC_METHOD_NO_ARGS(const char *, SBCommandInterpreter, - GetBroadcasterClass); + LLDB_INSTRUMENT(); return CommandInterpreter::GetStaticBroadcasterClass().AsCString(); } const char *SBCommandInterpreter::GetArgumentTypeAsCString( const lldb::CommandArgumentType arg_type) { - LLDB_RECORD_STATIC_METHOD(const char *, SBCommandInterpreter, - GetArgumentTypeAsCString, - (const lldb::CommandArgumentType), arg_type); + LLDB_INSTRUMENT_VA(arg_type); return CommandObject::GetArgumentTypeAsCString(arg_type); } const char *SBCommandInterpreter::GetArgumentDescriptionAsCString( const lldb::CommandArgumentType arg_type) { - LLDB_RECORD_STATIC_METHOD(const char *, SBCommandInterpreter, - GetArgumentDescriptionAsCString, - (const lldb::CommandArgumentType), arg_type); + LLDB_INSTRUMENT_VA(arg_type); return CommandObject::GetArgumentDescriptionAsCString(arg_type); } bool SBCommandInterpreter::EventIsCommandInterpreterEvent( const lldb::SBEvent &event) { - LLDB_RECORD_STATIC_METHOD(bool, SBCommandInterpreter, - EventIsCommandInterpreterEvent, - (const lldb::SBEvent &), event); + LLDB_INSTRUMENT_VA(event); return event.GetBroadcasterClass() == SBCommandInterpreter::GetBroadcasterClass(); @@ -552,9 +504,7 @@ bool SBCommandInterpreter::EventIsCommandInterpreterEvent( bool SBCommandInterpreter::SetCommandOverrideCallback( const char *command_name, lldb::CommandOverrideCallback callback, void *baton) { - LLDB_RECORD_DUMMY(bool, SBCommandInterpreter, SetCommandOverrideCallback, - (const char *, lldb::CommandOverrideCallback, void *), - command_name, callback, baton); + LLDB_INSTRUMENT_VA(this, command_name, callback, baton); if (command_name && command_name[0] && IsValid()) { llvm::StringRef command_name_str = command_name; @@ -571,48 +521,37 @@ bool SBCommandInterpreter::SetCommandOverrideCallback( lldb::SBCommand SBCommandInterpreter::AddMultiwordCommand(const char *name, const char *help) { - LLDB_RECORD_METHOD(lldb::SBCommand, SBCommandInterpreter, AddMultiwordCommand, - (const char *, const char *), name, help); + LLDB_INSTRUMENT_VA(this, name, help); lldb::CommandObjectSP new_command_sp( new CommandObjectMultiword(*m_opaque_ptr, name, help)); new_command_sp->GetAsMultiwordCommand()->SetRemovable(true); Status add_error = m_opaque_ptr->AddUserCommand(name, new_command_sp, true); if (add_error.Success()) - return LLDB_RECORD_RESULT(lldb::SBCommand(new_command_sp)); - return LLDB_RECORD_RESULT(lldb::SBCommand()); + return lldb::SBCommand(new_command_sp); + return lldb::SBCommand(); } lldb::SBCommand SBCommandInterpreter::AddCommand( const char *name, lldb::SBCommandPluginInterface *impl, const char *help) { - LLDB_RECORD_METHOD( - lldb::SBCommand, SBCommandInterpreter, AddCommand, - (const char *, lldb::SBCommandPluginInterface *, const char *), name, - impl, help); + LLDB_INSTRUMENT_VA(this, name, impl, help); - return LLDB_RECORD_RESULT(AddCommand(name, impl, help, /*syntax=*/nullptr, - /*auto_repeat_command=*/"")) + return AddCommand(name, impl, help, /*syntax=*/nullptr, + /*auto_repeat_command=*/""); } lldb::SBCommand SBCommandInterpreter::AddCommand(const char *name, lldb::SBCommandPluginInterface *impl, const char *help, const char *syntax) { - LLDB_RECORD_METHOD(lldb::SBCommand, SBCommandInterpreter, AddCommand, - (const char *, lldb::SBCommandPluginInterface *, - const char *, const char *), - name, impl, help, syntax); - return LLDB_RECORD_RESULT( - AddCommand(name, impl, help, syntax, /*auto_repeat_command=*/"")) + LLDB_INSTRUMENT_VA(this, name, impl, help, syntax); + return AddCommand(name, impl, help, syntax, /*auto_repeat_command=*/""); } lldb::SBCommand SBCommandInterpreter::AddCommand( const char *name, lldb::SBCommandPluginInterface *impl, const char *help, const char *syntax, const char *auto_repeat_command) { - LLDB_RECORD_METHOD(lldb::SBCommand, SBCommandInterpreter, AddCommand, - (const char *, lldb::SBCommandPluginInterface *, - const char *, const char *, const char *), - name, impl, help, syntax, auto_repeat_command); + LLDB_INSTRUMENT_VA(this, name, impl, help, syntax, auto_repeat_command); lldb::CommandObjectSP new_command_sp; new_command_sp = std::make_shared<CommandPluginInterfaceImplementation>( @@ -621,53 +560,53 @@ lldb::SBCommand SBCommandInterpreter::AddCommand( Status add_error = m_opaque_ptr->AddUserCommand(name, new_command_sp, true); if (add_error.Success()) - return LLDB_RECORD_RESULT(lldb::SBCommand(new_command_sp)); - return LLDB_RECORD_RESULT(lldb::SBCommand()); + return lldb::SBCommand(new_command_sp); + return lldb::SBCommand(); } -SBCommand::SBCommand() { LLDB_RECORD_CONSTRUCTOR_NO_ARGS(SBCommand); } +SBCommand::SBCommand() { LLDB_INSTRUMENT_VA(this); } SBCommand::SBCommand(lldb::CommandObjectSP cmd_sp) : m_opaque_sp(cmd_sp) {} bool SBCommand::IsValid() { - LLDB_RECORD_METHOD_NO_ARGS(bool, SBCommand, IsValid); + LLDB_INSTRUMENT_VA(this); return this->operator bool(); } SBCommand::operator bool() const { - LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBCommand, operator bool); + LLDB_INSTRUMENT_VA(this); return m_opaque_sp.get() != nullptr; } const char *SBCommand::GetName() { - LLDB_RECORD_METHOD_NO_ARGS(const char *, SBCommand, GetName); + LLDB_INSTRUMENT_VA(this); return (IsValid() ? ConstString(m_opaque_sp->GetCommandName()).AsCString() : nullptr); } const char *SBCommand::GetHelp() { - LLDB_RECORD_METHOD_NO_ARGS(const char *, SBCommand, GetHelp); + LLDB_INSTRUMENT_VA(this); return (IsValid() ? ConstString(m_opaque_sp->GetHelp()).AsCString() : nullptr); } const char *SBCommand::GetHelpLong() { - LLDB_RECORD_METHOD_NO_ARGS(const char *, SBCommand, GetHelpLong); + LLDB_INSTRUMENT_VA(this); return (IsValid() ? ConstString(m_opaque_sp->GetHelpLong()).AsCString() : nullptr); } void SBCommand::SetHelp(const char *help) { - LLDB_RECORD_METHOD(void, SBCommand, SetHelp, (const char *), help); + LLDB_INSTRUMENT_VA(this, help); if (IsValid()) m_opaque_sp->SetHelp(help); } void SBCommand::SetHelpLong(const char *help) { - LLDB_RECORD_METHOD(void, SBCommand, SetHelpLong, (const char *), help); + LLDB_INSTRUMENT_VA(this, help); if (IsValid()) m_opaque_sp->SetHelpLong(help); @@ -675,193 +614,64 @@ void SBCommand::SetHelpLong(const char *help) { lldb::SBCommand SBCommand::AddMultiwordCommand(const char *name, const char *help) { - LLDB_RECORD_METHOD(lldb::SBCommand, SBCommand, AddMultiwordCommand, - (const char *, const char *), name, help); + LLDB_INSTRUMENT_VA(this, name, help); if (!IsValid()) - return LLDB_RECORD_RESULT(lldb::SBCommand()); + return lldb::SBCommand(); if (!m_opaque_sp->IsMultiwordObject()) - return LLDB_RECORD_RESULT(lldb::SBCommand()); + return lldb::SBCommand(); CommandObjectMultiword *new_command = new CommandObjectMultiword( m_opaque_sp->GetCommandInterpreter(), name, help); new_command->SetRemovable(true); lldb::CommandObjectSP new_command_sp(new_command); if (new_command_sp && m_opaque_sp->LoadSubCommand(name, new_command_sp)) - return LLDB_RECORD_RESULT(lldb::SBCommand(new_command_sp)); - return LLDB_RECORD_RESULT(lldb::SBCommand()); + return lldb::SBCommand(new_command_sp); + return lldb::SBCommand(); } lldb::SBCommand SBCommand::AddCommand(const char *name, lldb::SBCommandPluginInterface *impl, const char *help) { - LLDB_RECORD_METHOD( - lldb::SBCommand, SBCommand, AddCommand, - (const char *, lldb::SBCommandPluginInterface *, const char *), name, - impl, help); - return LLDB_RECORD_RESULT(AddCommand(name, impl, help, /*syntax=*/nullptr, - /*auto_repeat_command=*/"")) + LLDB_INSTRUMENT_VA(this, name, impl, help); + return AddCommand(name, impl, help, /*syntax=*/nullptr, + /*auto_repeat_command=*/""); } lldb::SBCommand SBCommand::AddCommand(const char *name, lldb::SBCommandPluginInterface *impl, const char *help, const char *syntax) { - LLDB_RECORD_METHOD(lldb::SBCommand, SBCommand, AddCommand, - (const char *, lldb::SBCommandPluginInterface *, - const char *, const char *), - name, impl, help, syntax); - return LLDB_RECORD_RESULT( - AddCommand(name, impl, help, syntax, /*auto_repeat_command=*/"")) + LLDB_INSTRUMENT_VA(this, name, impl, help, syntax); + return AddCommand(name, impl, help, syntax, /*auto_repeat_command=*/""); } lldb::SBCommand SBCommand::AddCommand(const char *name, lldb::SBCommandPluginInterface *impl, const char *help, const char *syntax, const char *auto_repeat_command) { - LLDB_RECORD_METHOD(lldb::SBCommand, SBCommand, AddCommand, - (const char *, lldb::SBCommandPluginInterface *, - const char *, const char *, const char *), - name, impl, help, syntax, auto_repeat_command); + LLDB_INSTRUMENT_VA(this, name, impl, help, syntax, auto_repeat_command); if (!IsValid()) - return LLDB_RECORD_RESULT(lldb::SBCommand()); + return lldb::SBCommand(); if (!m_opaque_sp->IsMultiwordObject()) - return LLDB_RECORD_RESULT(lldb::SBCommand()); + return lldb::SBCommand(); lldb::CommandObjectSP new_command_sp; new_command_sp = std::make_shared<CommandPluginInterfaceImplementation>( m_opaque_sp->GetCommandInterpreter(), name, impl, help, syntax, /*flags=*/0, auto_repeat_command); if (new_command_sp && m_opaque_sp->LoadSubCommand(name, new_command_sp)) - return LLDB_RECORD_RESULT(lldb::SBCommand(new_command_sp)); - return LLDB_RECORD_RESULT(lldb::SBCommand()); + return lldb::SBCommand(new_command_sp); + return lldb::SBCommand(); } uint32_t SBCommand::GetFlags() { - LLDB_RECORD_METHOD_NO_ARGS(uint32_t, SBCommand, GetFlags); + LLDB_INSTRUMENT_VA(this); return (IsValid() ? m_opaque_sp->GetFlags().Get() : 0); } void SBCommand::SetFlags(uint32_t flags) { - LLDB_RECORD_METHOD(void, SBCommand, SetFlags, (uint32_t), flags); + LLDB_INSTRUMENT_VA(this, flags); if (IsValid()) m_opaque_sp->GetFlags().Set(flags); } - -namespace lldb_private { -namespace repro { - -template <> void RegisterMethods<SBCommandInterpreter>(Registry &R) { - LLDB_REGISTER_CONSTRUCTOR(SBCommandInterpreter, - (lldb_private::CommandInterpreter *)); - LLDB_REGISTER_CONSTRUCTOR(SBCommandInterpreter, - (const lldb::SBCommandInterpreter &)); - LLDB_REGISTER_METHOD( - const lldb::SBCommandInterpreter &, - SBCommandInterpreter, operator=,(const lldb::SBCommandInterpreter &)); - LLDB_REGISTER_METHOD_CONST(bool, SBCommandInterpreter, IsValid, ()); - LLDB_REGISTER_METHOD_CONST(bool, SBCommandInterpreter, operator bool, ()); - LLDB_REGISTER_METHOD(bool, SBCommandInterpreter, CommandExists, - (const char *)); - LLDB_REGISTER_METHOD(bool, SBCommandInterpreter, AliasExists, - (const char *)); - LLDB_REGISTER_METHOD(bool, SBCommandInterpreter, IsActive, ()); - LLDB_REGISTER_METHOD_CONST(bool, SBCommandInterpreter, WasInterrupted, ()); - LLDB_REGISTER_METHOD(const char *, SBCommandInterpreter, - GetIOHandlerControlSequence, (char)); - LLDB_REGISTER_METHOD(lldb::ReturnStatus, SBCommandInterpreter, - HandleCommand, - (const char *, lldb::SBCommandReturnObject &, bool)); - LLDB_REGISTER_METHOD(lldb::ReturnStatus, SBCommandInterpreter, - HandleCommand, - (const char *, lldb::SBExecutionContext &, - lldb::SBCommandReturnObject &, bool)); - LLDB_REGISTER_METHOD(void, SBCommandInterpreter, HandleCommandsFromFile, - (lldb::SBFileSpec &, lldb::SBExecutionContext &, - lldb::SBCommandInterpreterRunOptions &, - lldb::SBCommandReturnObject)); - LLDB_REGISTER_METHOD(int, SBCommandInterpreter, HandleCompletion, - (const char *, const char *, const char *, int, int, - lldb::SBStringList &)); - LLDB_REGISTER_METHOD(int, SBCommandInterpreter, - HandleCompletionWithDescriptions, - (const char *, const char *, const char *, int, int, - lldb::SBStringList &, lldb::SBStringList &)); - LLDB_REGISTER_METHOD(int, SBCommandInterpreter, - HandleCompletionWithDescriptions, - (const char *, uint32_t, int, int, - lldb::SBStringList &, lldb::SBStringList &)); - LLDB_REGISTER_METHOD( - int, SBCommandInterpreter, HandleCompletion, - (const char *, uint32_t, int, int, lldb::SBStringList &)); - LLDB_REGISTER_METHOD(bool, SBCommandInterpreter, HasCommands, ()); - LLDB_REGISTER_METHOD(bool, SBCommandInterpreter, HasAliases, ()); - LLDB_REGISTER_METHOD(bool, SBCommandInterpreter, HasAliasOptions, ()); - LLDB_REGISTER_METHOD(lldb::SBProcess, SBCommandInterpreter, GetProcess, ()); - LLDB_REGISTER_METHOD(lldb::SBDebugger, SBCommandInterpreter, GetDebugger, - ()); - LLDB_REGISTER_METHOD(bool, SBCommandInterpreter, GetPromptOnQuit, ()); - LLDB_REGISTER_METHOD(void, SBCommandInterpreter, SetPromptOnQuit, (bool)); - LLDB_REGISTER_METHOD(void, SBCommandInterpreter, AllowExitCodeOnQuit, - (bool)); - LLDB_REGISTER_METHOD(bool, SBCommandInterpreter, HasCustomQuitExitCode, ()); - LLDB_REGISTER_METHOD(int, SBCommandInterpreter, GetQuitStatus, ()); - LLDB_REGISTER_METHOD(void, SBCommandInterpreter, ResolveCommand, - (const char *, lldb::SBCommandReturnObject &)); - LLDB_REGISTER_METHOD(void, SBCommandInterpreter, - SourceInitFileInHomeDirectory, - (lldb::SBCommandReturnObject &)); - LLDB_REGISTER_METHOD(void, SBCommandInterpreter, - SourceInitFileInHomeDirectory, - (lldb::SBCommandReturnObject &, bool)); - LLDB_REGISTER_METHOD(void, SBCommandInterpreter, - SourceInitFileInCurrentWorkingDirectory, - (lldb::SBCommandReturnObject &)); - LLDB_REGISTER_METHOD(lldb::SBBroadcaster, SBCommandInterpreter, - GetBroadcaster, ()); - LLDB_REGISTER_STATIC_METHOD(const char *, SBCommandInterpreter, - GetBroadcasterClass, ()); - LLDB_REGISTER_STATIC_METHOD(const char *, SBCommandInterpreter, - GetArgumentTypeAsCString, - (const lldb::CommandArgumentType)); - LLDB_REGISTER_STATIC_METHOD(const char *, SBCommandInterpreter, - GetArgumentDescriptionAsCString, - (const lldb::CommandArgumentType)); - LLDB_REGISTER_STATIC_METHOD(bool, SBCommandInterpreter, - EventIsCommandInterpreterEvent, - (const lldb::SBEvent &)); - LLDB_REGISTER_METHOD(lldb::SBCommand, SBCommandInterpreter, - AddMultiwordCommand, (const char *, const char *)); - LLDB_REGISTER_METHOD( - lldb::SBCommand, SBCommandInterpreter, AddCommand, - (const char *, lldb::SBCommandPluginInterface *, const char *)); - LLDB_REGISTER_METHOD(lldb::SBCommand, SBCommandInterpreter, AddCommand, - (const char *, lldb::SBCommandPluginInterface *, - const char *, const char *)); - LLDB_REGISTER_METHOD(lldb::SBCommand, SBCommandInterpreter, AddCommand, - (const char *, lldb::SBCommandPluginInterface *, - const char *, const char *, const char *)); - LLDB_REGISTER_CONSTRUCTOR(SBCommand, ()); - LLDB_REGISTER_METHOD(bool, SBCommand, IsValid, ()); - LLDB_REGISTER_METHOD_CONST(bool, SBCommand, operator bool, ()); - LLDB_REGISTER_METHOD(const char *, SBCommand, GetName, ()); - LLDB_REGISTER_METHOD(const char *, SBCommand, GetHelp, ()); - LLDB_REGISTER_METHOD(const char *, SBCommand, GetHelpLong, ()); - LLDB_REGISTER_METHOD(void, SBCommand, SetHelp, (const char *)); - LLDB_REGISTER_METHOD(void, SBCommand, SetHelpLong, (const char *)); - LLDB_REGISTER_METHOD(lldb::SBCommand, SBCommand, AddMultiwordCommand, - (const char *, const char *)); - LLDB_REGISTER_METHOD( - lldb::SBCommand, SBCommand, AddCommand, - (const char *, lldb::SBCommandPluginInterface *, const char *)); - LLDB_REGISTER_METHOD(lldb::SBCommand, SBCommand, AddCommand, - (const char *, lldb::SBCommandPluginInterface *, - const char *, const char *)); - LLDB_REGISTER_METHOD(lldb::SBCommand, SBCommand, AddCommand, - (const char *, lldb::SBCommandPluginInterface *, - const char *, const char *, const char *)); - LLDB_REGISTER_METHOD(uint32_t, SBCommand, GetFlags, ()); - LLDB_REGISTER_METHOD(void, SBCommand, SetFlags, (uint32_t)); -} -} -} diff --git a/lldb/source/API/SBCommandInterpreterRunOptions.cpp b/lldb/source/API/SBCommandInterpreterRunOptions.cpp index 317ec6d37127..6c6b2aa15a79 100644 --- a/lldb/source/API/SBCommandInterpreterRunOptions.cpp +++ b/lldb/source/API/SBCommandInterpreterRunOptions.cpp @@ -8,7 +8,7 @@ #include "lldb/lldb-types.h" -#include "SBReproducerPrivate.h" +#include "lldb/Utility/Instrumentation.h" #include "lldb/API/SBCommandInterpreterRunOptions.h" #include "lldb/Interpreter/CommandInterpreter.h" @@ -19,16 +19,14 @@ using namespace lldb; using namespace lldb_private; SBCommandInterpreterRunOptions::SBCommandInterpreterRunOptions() { - LLDB_RECORD_CONSTRUCTOR_NO_ARGS(SBCommandInterpreterRunOptions); + LLDB_INSTRUMENT_VA(this); m_opaque_up = std::make_unique<CommandInterpreterRunOptions>(); } SBCommandInterpreterRunOptions::SBCommandInterpreterRunOptions( - const SBCommandInterpreterRunOptions &rhs) - : m_opaque_up() { - LLDB_RECORD_CONSTRUCTOR(SBCommandInterpreterRunOptions, - (const lldb::SBCommandInterpreterRunOptions &), rhs); + const SBCommandInterpreterRunOptions &rhs) { + LLDB_INSTRUMENT_VA(this, rhs); m_opaque_up = std::make_unique<CommandInterpreterRunOptions>(rhs.ref()); } @@ -37,153 +35,131 @@ SBCommandInterpreterRunOptions::~SBCommandInterpreterRunOptions() = default; SBCommandInterpreterRunOptions &SBCommandInterpreterRunOptions::operator=( const SBCommandInterpreterRunOptions &rhs) { - LLDB_RECORD_METHOD(lldb::SBCommandInterpreterRunOptions &, - SBCommandInterpreterRunOptions, operator=, - (const lldb::SBCommandInterpreterRunOptions &), rhs); + LLDB_INSTRUMENT_VA(this, rhs); if (this == &rhs) - return LLDB_RECORD_RESULT(*this); + return *this; *m_opaque_up = *rhs.m_opaque_up; - return LLDB_RECORD_RESULT(*this); + return *this; } bool SBCommandInterpreterRunOptions::GetStopOnContinue() const { - LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBCommandInterpreterRunOptions, - GetStopOnContinue); + LLDB_INSTRUMENT_VA(this); return m_opaque_up->GetStopOnContinue(); } void SBCommandInterpreterRunOptions::SetStopOnContinue(bool stop_on_continue) { - LLDB_RECORD_METHOD(void, SBCommandInterpreterRunOptions, SetStopOnContinue, - (bool), stop_on_continue); + LLDB_INSTRUMENT_VA(this, stop_on_continue); m_opaque_up->SetStopOnContinue(stop_on_continue); } bool SBCommandInterpreterRunOptions::GetStopOnError() const { - LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBCommandInterpreterRunOptions, - GetStopOnError); + LLDB_INSTRUMENT_VA(this); return m_opaque_up->GetStopOnError(); } void SBCommandInterpreterRunOptions::SetStopOnError(bool stop_on_error) { - LLDB_RECORD_METHOD(void, SBCommandInterpreterRunOptions, SetStopOnError, - (bool), stop_on_error); + LLDB_INSTRUMENT_VA(this, stop_on_error); m_opaque_up->SetStopOnError(stop_on_error); } bool SBCommandInterpreterRunOptions::GetStopOnCrash() const { - LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBCommandInterpreterRunOptions, - GetStopOnCrash); + LLDB_INSTRUMENT_VA(this); return m_opaque_up->GetStopOnCrash(); } void SBCommandInterpreterRunOptions::SetStopOnCrash(bool stop_on_crash) { - LLDB_RECORD_METHOD(void, SBCommandInterpreterRunOptions, SetStopOnCrash, - (bool), stop_on_crash); + LLDB_INSTRUMENT_VA(this, stop_on_crash); m_opaque_up->SetStopOnCrash(stop_on_crash); } bool SBCommandInterpreterRunOptions::GetEchoCommands() const { - LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBCommandInterpreterRunOptions, - GetEchoCommands); + LLDB_INSTRUMENT_VA(this); return m_opaque_up->GetEchoCommands(); } void SBCommandInterpreterRunOptions::SetEchoCommands(bool echo_commands) { - LLDB_RECORD_METHOD(void, SBCommandInterpreterRunOptions, SetEchoCommands, - (bool), echo_commands); + LLDB_INSTRUMENT_VA(this, echo_commands); m_opaque_up->SetEchoCommands(echo_commands); } bool SBCommandInterpreterRunOptions::GetEchoCommentCommands() const { - LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBCommandInterpreterRunOptions, - GetEchoCommentCommands); + LLDB_INSTRUMENT_VA(this); return m_opaque_up->GetEchoCommentCommands(); } void SBCommandInterpreterRunOptions::SetEchoCommentCommands(bool echo) { - LLDB_RECORD_METHOD(void, SBCommandInterpreterRunOptions, - SetEchoCommentCommands, (bool), echo); + LLDB_INSTRUMENT_VA(this, echo); m_opaque_up->SetEchoCommentCommands(echo); } bool SBCommandInterpreterRunOptions::GetPrintResults() const { - LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBCommandInterpreterRunOptions, - GetPrintResults); + LLDB_INSTRUMENT_VA(this); return m_opaque_up->GetPrintResults(); } void SBCommandInterpreterRunOptions::SetPrintResults(bool print_results) { - LLDB_RECORD_METHOD(void, SBCommandInterpreterRunOptions, SetPrintResults, - (bool), print_results); + LLDB_INSTRUMENT_VA(this, print_results); m_opaque_up->SetPrintResults(print_results); } bool SBCommandInterpreterRunOptions::GetPrintErrors() const { - LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBCommandInterpreterRunOptions, - GetPrintErrors); + LLDB_INSTRUMENT_VA(this); return m_opaque_up->GetPrintErrors(); } void SBCommandInterpreterRunOptions::SetPrintErrors(bool print_errors) { - LLDB_RECORD_METHOD(void, SBCommandInterpreterRunOptions, SetPrintErrors, - (bool), print_errors); + LLDB_INSTRUMENT_VA(this, print_errors); m_opaque_up->SetPrintErrors(print_errors); } bool SBCommandInterpreterRunOptions::GetAddToHistory() const { - LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBCommandInterpreterRunOptions, - GetAddToHistory); + LLDB_INSTRUMENT_VA(this); return m_opaque_up->GetAddToHistory(); } void SBCommandInterpreterRunOptions::SetAddToHistory(bool add_to_history) { - LLDB_RECORD_METHOD(void, SBCommandInterpreterRunOptions, SetAddToHistory, - (bool), add_to_history); + LLDB_INSTRUMENT_VA(this, add_to_history); m_opaque_up->SetAddToHistory(add_to_history); } bool SBCommandInterpreterRunOptions::GetAutoHandleEvents() const { - LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBCommandInterpreterRunOptions, - GetAutoHandleEvents); + LLDB_INSTRUMENT_VA(this); return m_opaque_up->GetAutoHandleEvents(); } void SBCommandInterpreterRunOptions::SetAutoHandleEvents( bool auto_handle_events) { - LLDB_RECORD_METHOD(void, SBCommandInterpreterRunOptions, SetAutoHandleEvents, - (bool), auto_handle_events); + LLDB_INSTRUMENT_VA(this, auto_handle_events); m_opaque_up->SetAutoHandleEvents(auto_handle_events); } bool SBCommandInterpreterRunOptions::GetSpawnThread() const { - LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBCommandInterpreterRunOptions, - GetSpawnThread); + LLDB_INSTRUMENT_VA(this); return m_opaque_up->GetSpawnThread(); } void SBCommandInterpreterRunOptions::SetSpawnThread(bool spawn_thread) { - LLDB_RECORD_METHOD(void, SBCommandInterpreterRunOptions, SetSpawnThread, - (bool), spawn_thread); + LLDB_INSTRUMENT_VA(this, spawn_thread); m_opaque_up->SetSpawnThread(spawn_thread); } @@ -202,21 +178,19 @@ SBCommandInterpreterRunResult::SBCommandInterpreterRunResult() : m_opaque_up(new CommandInterpreterRunResult()) { - LLDB_RECORD_CONSTRUCTOR_NO_ARGS(SBCommandInterpreterRunResult); + LLDB_INSTRUMENT_VA(this); } SBCommandInterpreterRunResult::SBCommandInterpreterRunResult( const SBCommandInterpreterRunResult &rhs) : m_opaque_up(new CommandInterpreterRunResult()) { - LLDB_RECORD_CONSTRUCTOR(SBCommandInterpreterRunResult, - (const lldb::SBCommandInterpreterRunResult &), rhs); + LLDB_INSTRUMENT_VA(this, rhs); *m_opaque_up = *rhs.m_opaque_up; } SBCommandInterpreterRunResult::SBCommandInterpreterRunResult( - const CommandInterpreterRunResult &rhs) - : m_opaque_up() { + const CommandInterpreterRunResult &rhs) { m_opaque_up = std::make_unique<CommandInterpreterRunResult>(rhs); } @@ -224,92 +198,23 @@ SBCommandInterpreterRunResult::~SBCommandInterpreterRunResult() = default; SBCommandInterpreterRunResult &SBCommandInterpreterRunResult::operator=( const SBCommandInterpreterRunResult &rhs) { - LLDB_RECORD_METHOD(lldb::SBCommandInterpreterRunResult &, - SBCommandInterpreterRunResult, operator=, - (const lldb::SBCommandInterpreterRunResult &), rhs); + LLDB_INSTRUMENT_VA(this, rhs); if (this == &rhs) - return LLDB_RECORD_RESULT(*this); + return *this; *m_opaque_up = *rhs.m_opaque_up; - return LLDB_RECORD_RESULT(*this); + return *this; } int SBCommandInterpreterRunResult::GetNumberOfErrors() const { - LLDB_RECORD_METHOD_CONST_NO_ARGS(int, SBCommandInterpreterRunResult, - GetNumberOfErrors); + LLDB_INSTRUMENT_VA(this); return m_opaque_up->GetNumErrors(); } lldb::CommandInterpreterResult SBCommandInterpreterRunResult::GetResult() const { - LLDB_RECORD_METHOD_CONST_NO_ARGS(lldb::CommandInterpreterResult, - SBCommandInterpreterRunResult, GetResult); + LLDB_INSTRUMENT_VA(this); return m_opaque_up->GetResult(); } - -namespace lldb_private { -namespace repro { - -template <> void RegisterMethods<SBCommandInterpreterRunOptions>(Registry &R) { - LLDB_REGISTER_CONSTRUCTOR(SBCommandInterpreterRunOptions, ()); - LLDB_REGISTER_CONSTRUCTOR(SBCommandInterpreterRunOptions, - (const lldb::SBCommandInterpreterRunOptions &)); - LLDB_REGISTER_METHOD(lldb::SBCommandInterpreterRunOptions &, - SBCommandInterpreterRunOptions, operator=, - (const lldb::SBCommandInterpreterRunOptions &)); - LLDB_REGISTER_METHOD_CONST(bool, SBCommandInterpreterRunOptions, - GetStopOnContinue, ()); - LLDB_REGISTER_METHOD(void, SBCommandInterpreterRunOptions, SetStopOnContinue, - (bool)); - LLDB_REGISTER_METHOD_CONST(bool, SBCommandInterpreterRunOptions, - GetStopOnError, ()); - LLDB_REGISTER_METHOD(void, SBCommandInterpreterRunOptions, SetStopOnError, - (bool)); - LLDB_REGISTER_METHOD_CONST(bool, SBCommandInterpreterRunOptions, - GetStopOnCrash, ()); - LLDB_REGISTER_METHOD(void, SBCommandInterpreterRunOptions, SetStopOnCrash, - (bool)); - LLDB_REGISTER_METHOD_CONST(bool, SBCommandInterpreterRunOptions, - GetEchoCommands, ()); - LLDB_REGISTER_METHOD(void, SBCommandInterpreterRunOptions, SetEchoCommands, - (bool)); - LLDB_REGISTER_METHOD_CONST(bool, SBCommandInterpreterRunOptions, - GetEchoCommentCommands, ()); - LLDB_REGISTER_METHOD(void, SBCommandInterpreterRunOptions, - SetEchoCommentCommands, (bool)); - LLDB_REGISTER_METHOD_CONST(bool, SBCommandInterpreterRunOptions, - GetPrintResults, ()); - LLDB_REGISTER_METHOD(void, SBCommandInterpreterRunOptions, SetPrintResults, - (bool)); - LLDB_REGISTER_METHOD_CONST(bool, SBCommandInterpreterRunOptions, - GetPrintErrors, ()); - LLDB_REGISTER_METHOD(void, SBCommandInterpreterRunOptions, SetPrintErrors, - (bool)); - LLDB_REGISTER_METHOD_CONST(bool, SBCommandInterpreterRunOptions, - GetAddToHistory, ()); - LLDB_REGISTER_METHOD(void, SBCommandInterpreterRunOptions, SetAddToHistory, - (bool)); - LLDB_REGISTER_METHOD_CONST(bool, SBCommandInterpreterRunOptions, - GetAutoHandleEvents, ()); - LLDB_REGISTER_METHOD(void, SBCommandInterpreterRunOptions, - SetAutoHandleEvents, (bool)); - LLDB_REGISTER_METHOD_CONST(bool, SBCommandInterpreterRunOptions, - GetSpawnThread, ()); - LLDB_REGISTER_METHOD(void, SBCommandInterpreterRunOptions, SetSpawnThread, - (bool)); - LLDB_REGISTER_CONSTRUCTOR(SBCommandInterpreterRunResult, ()); - LLDB_REGISTER_CONSTRUCTOR(SBCommandInterpreterRunResult, - (const lldb::SBCommandInterpreterRunResult &)); - LLDB_REGISTER_METHOD(lldb::SBCommandInterpreterRunResult &, - SBCommandInterpreterRunResult, operator=, - (const lldb::SBCommandInterpreterRunResult &)); - LLDB_REGISTER_METHOD_CONST(int, SBCommandInterpreterRunResult, - GetNumberOfErrors, ()); - LLDB_REGISTER_METHOD_CONST(lldb::CommandInterpreterResult, - SBCommandInterpreterRunResult, GetResult, ()); -} - -} // namespace repro -} // namespace lldb_private diff --git a/lldb/source/API/SBCommandReturnObject.cpp b/lldb/source/API/SBCommandReturnObject.cpp index 00150d198fca..7d2c102b3d8c 100644 --- a/lldb/source/API/SBCommandReturnObject.cpp +++ b/lldb/source/API/SBCommandReturnObject.cpp @@ -7,13 +7,13 @@ //===----------------------------------------------------------------------===// #include "lldb/API/SBCommandReturnObject.h" -#include "SBReproducerPrivate.h" #include "Utils.h" #include "lldb/API/SBError.h" #include "lldb/API/SBFile.h" #include "lldb/API/SBStream.h" #include "lldb/Interpreter/CommandReturnObject.h" #include "lldb/Utility/ConstString.h" +#include "lldb/Utility/Instrumentation.h" #include "lldb/Utility/Status.h" using namespace lldb; @@ -46,76 +46,70 @@ private: SBCommandReturnObject::SBCommandReturnObject() : m_opaque_up(new SBCommandReturnObjectImpl()) { - LLDB_RECORD_CONSTRUCTOR_NO_ARGS(SBCommandReturnObject); + LLDB_INSTRUMENT_VA(this); } SBCommandReturnObject::SBCommandReturnObject(CommandReturnObject &ref) : m_opaque_up(new SBCommandReturnObjectImpl(ref)) { - LLDB_RECORD_CONSTRUCTOR(SBCommandReturnObject, - (lldb_private::CommandReturnObject &), ref); + LLDB_INSTRUMENT_VA(this, ref); } -SBCommandReturnObject::SBCommandReturnObject(const SBCommandReturnObject &rhs) - : m_opaque_up() { - LLDB_RECORD_CONSTRUCTOR(SBCommandReturnObject, - (const lldb::SBCommandReturnObject &), rhs); +SBCommandReturnObject::SBCommandReturnObject(const SBCommandReturnObject &rhs) { + LLDB_INSTRUMENT_VA(this, rhs); m_opaque_up = clone(rhs.m_opaque_up); } SBCommandReturnObject &SBCommandReturnObject:: operator=(const SBCommandReturnObject &rhs) { - LLDB_RECORD_METHOD( - lldb::SBCommandReturnObject &, - SBCommandReturnObject, operator=,(const lldb::SBCommandReturnObject &), - rhs); + LLDB_INSTRUMENT_VA(this, rhs); if (this != &rhs) m_opaque_up = clone(rhs.m_opaque_up); - return LLDB_RECORD_RESULT(*this); + return *this; } SBCommandReturnObject::~SBCommandReturnObject() = default; bool SBCommandReturnObject::IsValid() const { - LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBCommandReturnObject, IsValid); + LLDB_INSTRUMENT_VA(this); return this->operator bool(); } SBCommandReturnObject::operator bool() const { - LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBCommandReturnObject, operator bool); + LLDB_INSTRUMENT_VA(this); // This method is not useful but it needs to stay to keep SB API stable. return true; } const char *SBCommandReturnObject::GetOutput() { - LLDB_RECORD_METHOD_NO_ARGS(const char *, SBCommandReturnObject, GetOutput); + LLDB_INSTRUMENT_VA(this); ConstString output(ref().GetOutputData()); return output.AsCString(/*value_if_empty*/ ""); } const char *SBCommandReturnObject::GetError() { - LLDB_RECORD_METHOD_NO_ARGS(const char *, SBCommandReturnObject, GetError); + LLDB_INSTRUMENT_VA(this); ConstString output(ref().GetErrorData()); return output.AsCString(/*value_if_empty*/ ""); } size_t SBCommandReturnObject::GetOutputSize() { - LLDB_RECORD_METHOD_NO_ARGS(size_t, SBCommandReturnObject, GetOutputSize); + LLDB_INSTRUMENT_VA(this); return ref().GetOutputData().size(); } size_t SBCommandReturnObject::GetErrorSize() { - LLDB_RECORD_METHOD_NO_ARGS(size_t, SBCommandReturnObject, GetErrorSize); + LLDB_INSTRUMENT_VA(this); return ref().GetErrorData().size(); } size_t SBCommandReturnObject::PutOutput(FILE *fh) { - LLDB_RECORD_DUMMY(size_t, SBCommandReturnObject, PutOutput, (FILE *), fh); + LLDB_INSTRUMENT_VA(this, fh); if (fh) { size_t num_bytes = GetOutputSize(); if (num_bytes) @@ -125,22 +119,21 @@ size_t SBCommandReturnObject::PutOutput(FILE *fh) { } size_t SBCommandReturnObject::PutOutput(FileSP file_sp) { - LLDB_RECORD_METHOD(size_t, SBCommandReturnObject, PutOutput, (FileSP), - file_sp); + LLDB_INSTRUMENT_VA(this, file_sp); if (!file_sp) return 0; return file_sp->Printf("%s", GetOutput()); } size_t SBCommandReturnObject::PutOutput(SBFile file) { - LLDB_RECORD_METHOD(size_t, SBCommandReturnObject, PutOutput, (SBFile), file); + LLDB_INSTRUMENT_VA(this, file); if (!file.m_opaque_sp) return 0; return file.m_opaque_sp->Printf("%s", GetOutput()); } size_t SBCommandReturnObject::PutError(FILE *fh) { - LLDB_RECORD_DUMMY(size_t, SBCommandReturnObject, PutError, (FILE *), fh); + LLDB_INSTRUMENT_VA(this, fh); if (fh) { size_t num_bytes = GetErrorSize(); if (num_bytes) @@ -150,62 +143,57 @@ size_t SBCommandReturnObject::PutError(FILE *fh) { } size_t SBCommandReturnObject::PutError(FileSP file_sp) { - LLDB_RECORD_METHOD(size_t, SBCommandReturnObject, PutError, (FileSP), - file_sp); + LLDB_INSTRUMENT_VA(this, file_sp); if (!file_sp) return 0; return file_sp->Printf("%s", GetError()); } size_t SBCommandReturnObject::PutError(SBFile file) { - LLDB_RECORD_METHOD(size_t, SBCommandReturnObject, PutError, (SBFile), file); + LLDB_INSTRUMENT_VA(this, file); if (!file.m_opaque_sp) return 0; return file.m_opaque_sp->Printf("%s", GetError()); } void SBCommandReturnObject::Clear() { - LLDB_RECORD_METHOD_NO_ARGS(void, SBCommandReturnObject, Clear); + LLDB_INSTRUMENT_VA(this); ref().Clear(); } lldb::ReturnStatus SBCommandReturnObject::GetStatus() { - LLDB_RECORD_METHOD_NO_ARGS(lldb::ReturnStatus, SBCommandReturnObject, - GetStatus); + LLDB_INSTRUMENT_VA(this); return ref().GetStatus(); } void SBCommandReturnObject::SetStatus(lldb::ReturnStatus status) { - LLDB_RECORD_METHOD(void, SBCommandReturnObject, SetStatus, - (lldb::ReturnStatus), status); + LLDB_INSTRUMENT_VA(this, status); ref().SetStatus(status); } bool SBCommandReturnObject::Succeeded() { - LLDB_RECORD_METHOD_NO_ARGS(bool, SBCommandReturnObject, Succeeded); + LLDB_INSTRUMENT_VA(this); return ref().Succeeded(); } bool SBCommandReturnObject::HasResult() { - LLDB_RECORD_METHOD_NO_ARGS(bool, SBCommandReturnObject, HasResult); + LLDB_INSTRUMENT_VA(this); return ref().HasResult(); } void SBCommandReturnObject::AppendMessage(const char *message) { - LLDB_RECORD_METHOD(void, SBCommandReturnObject, AppendMessage, (const char *), - message); + LLDB_INSTRUMENT_VA(this, message); ref().AppendMessage(message); } void SBCommandReturnObject::AppendWarning(const char *message) { - LLDB_RECORD_METHOD(void, SBCommandReturnObject, AppendWarning, (const char *), - message); + LLDB_INSTRUMENT_VA(this, message); ref().AppendWarning(message); } @@ -227,8 +215,7 @@ CommandReturnObject &SBCommandReturnObject::ref() const { } bool SBCommandReturnObject::GetDescription(SBStream &description) { - LLDB_RECORD_METHOD(bool, SBCommandReturnObject, GetDescription, - (lldb::SBStream &), description); + LLDB_INSTRUMENT_VA(this, description); Stream &strm = description.ref(); @@ -253,62 +240,53 @@ bool SBCommandReturnObject::GetDescription(SBStream &description) { } void SBCommandReturnObject::SetImmediateOutputFile(FILE *fh) { - LLDB_RECORD_DUMMY(void, SBCommandReturnObject, SetImmediateOutputFile, - (FILE *), fh); + LLDB_INSTRUMENT_VA(this, fh); SetImmediateOutputFile(fh, false); } void SBCommandReturnObject::SetImmediateErrorFile(FILE *fh) { - LLDB_RECORD_DUMMY(void, SBCommandReturnObject, SetImmediateErrorFile, - (FILE *), fh); + LLDB_INSTRUMENT_VA(this, fh); SetImmediateErrorFile(fh, false); } void SBCommandReturnObject::SetImmediateOutputFile(FILE *fh, bool transfer_ownership) { - LLDB_RECORD_DUMMY(void, SBCommandReturnObject, SetImmediateOutputFile, - (FILE *, bool), fh, transfer_ownership); + LLDB_INSTRUMENT_VA(this, fh, transfer_ownership); FileSP file = std::make_shared<NativeFile>(fh, transfer_ownership); ref().SetImmediateOutputFile(file); } void SBCommandReturnObject::SetImmediateErrorFile(FILE *fh, bool transfer_ownership) { - LLDB_RECORD_DUMMY(void, SBCommandReturnObject, SetImmediateErrorFile, - (FILE *, bool), fh, transfer_ownership); + LLDB_INSTRUMENT_VA(this, fh, transfer_ownership); FileSP file = std::make_shared<NativeFile>(fh, transfer_ownership); ref().SetImmediateErrorFile(file); } void SBCommandReturnObject::SetImmediateOutputFile(SBFile file) { - LLDB_RECORD_METHOD(void, SBCommandReturnObject, SetImmediateOutputFile, - (SBFile), file); + LLDB_INSTRUMENT_VA(this, file); ref().SetImmediateOutputFile(file.m_opaque_sp); } void SBCommandReturnObject::SetImmediateErrorFile(SBFile file) { - LLDB_RECORD_METHOD(void, SBCommandReturnObject, SetImmediateErrorFile, - (SBFile), file); + LLDB_INSTRUMENT_VA(this, file); ref().SetImmediateErrorFile(file.m_opaque_sp); } void SBCommandReturnObject::SetImmediateOutputFile(FileSP file_sp) { - LLDB_RECORD_METHOD(void, SBCommandReturnObject, SetImmediateOutputFile, - (FileSP), file_sp); + LLDB_INSTRUMENT_VA(this, file_sp); SetImmediateOutputFile(SBFile(file_sp)); } void SBCommandReturnObject::SetImmediateErrorFile(FileSP file_sp) { - LLDB_RECORD_METHOD(void, SBCommandReturnObject, SetImmediateErrorFile, - (FileSP), file_sp); + LLDB_INSTRUMENT_VA(this, file_sp); SetImmediateErrorFile(SBFile(file_sp)); } void SBCommandReturnObject::PutCString(const char *string, int len) { - LLDB_RECORD_METHOD(void, SBCommandReturnObject, PutCString, - (const char *, int), string, len); + LLDB_INSTRUMENT_VA(this, string, len); if (len == 0 || string == nullptr || *string == 0) { return; @@ -320,8 +298,7 @@ void SBCommandReturnObject::PutCString(const char *string, int len) { } const char *SBCommandReturnObject::GetOutput(bool only_if_no_immediate) { - LLDB_RECORD_METHOD(const char *, SBCommandReturnObject, GetOutput, (bool), - only_if_no_immediate); + LLDB_INSTRUMENT_VA(this, only_if_no_immediate); if (!only_if_no_immediate || ref().GetImmediateOutputStream().get() == nullptr) @@ -330,8 +307,7 @@ const char *SBCommandReturnObject::GetOutput(bool only_if_no_immediate) { } const char *SBCommandReturnObject::GetError(bool only_if_no_immediate) { - LLDB_RECORD_METHOD(const char *, SBCommandReturnObject, GetError, (bool), - only_if_no_immediate); + LLDB_INSTRUMENT_VA(this, only_if_no_immediate); if (!only_if_no_immediate || ref().GetImmediateErrorStream().get() == nullptr) return GetError(); @@ -348,9 +324,7 @@ size_t SBCommandReturnObject::Printf(const char *format, ...) { void SBCommandReturnObject::SetError(lldb::SBError &error, const char *fallback_error_cstr) { - LLDB_RECORD_METHOD(void, SBCommandReturnObject, SetError, - (lldb::SBError &, const char *), error, - fallback_error_cstr); + LLDB_INSTRUMENT_VA(this, error, fallback_error_cstr); if (error.IsValid()) ref().SetError(error.ref(), fallback_error_cstr); @@ -359,76 +333,8 @@ void SBCommandReturnObject::SetError(lldb::SBError &error, } void SBCommandReturnObject::SetError(const char *error_cstr) { - LLDB_RECORD_METHOD(void, SBCommandReturnObject, SetError, (const char *), - error_cstr); + LLDB_INSTRUMENT_VA(this, error_cstr); if (error_cstr) ref().AppendError(error_cstr); } - -namespace lldb_private { -namespace repro { - -template <> -void RegisterMethods<SBCommandReturnObject>(Registry &R) { - LLDB_REGISTER_CONSTRUCTOR(SBCommandReturnObject, ()); - LLDB_REGISTER_CONSTRUCTOR(SBCommandReturnObject, - (lldb_private::CommandReturnObject &)); - LLDB_REGISTER_CONSTRUCTOR(SBCommandReturnObject, - (const lldb::SBCommandReturnObject &)); - LLDB_REGISTER_METHOD( - lldb::SBCommandReturnObject &, - SBCommandReturnObject, operator=,(const lldb::SBCommandReturnObject &)); - LLDB_REGISTER_METHOD_CONST(bool, SBCommandReturnObject, IsValid, ()); - LLDB_REGISTER_METHOD_CONST(bool, SBCommandReturnObject, operator bool, ()); - LLDB_REGISTER_METHOD(const char *, SBCommandReturnObject, GetOutput, ()); - LLDB_REGISTER_METHOD(const char *, SBCommandReturnObject, GetError, ()); - LLDB_REGISTER_METHOD(size_t, SBCommandReturnObject, GetOutputSize, ()); - LLDB_REGISTER_METHOD(size_t, SBCommandReturnObject, GetErrorSize, ()); - LLDB_REGISTER_METHOD(size_t, SBCommandReturnObject, PutOutput, (FILE *)); - LLDB_REGISTER_METHOD(size_t, SBCommandReturnObject, PutError, (FILE *)); - LLDB_REGISTER_METHOD(size_t, SBCommandReturnObject, PutOutput, (SBFile)); - LLDB_REGISTER_METHOD(size_t, SBCommandReturnObject, PutError, (SBFile)); - LLDB_REGISTER_METHOD(size_t, SBCommandReturnObject, PutOutput, (FileSP)); - LLDB_REGISTER_METHOD(size_t, SBCommandReturnObject, PutError, (FileSP)); - LLDB_REGISTER_METHOD(void, SBCommandReturnObject, Clear, ()); - LLDB_REGISTER_METHOD(lldb::ReturnStatus, SBCommandReturnObject, GetStatus, - ()); - LLDB_REGISTER_METHOD(void, SBCommandReturnObject, SetStatus, - (lldb::ReturnStatus)); - LLDB_REGISTER_METHOD(bool, SBCommandReturnObject, Succeeded, ()); - LLDB_REGISTER_METHOD(bool, SBCommandReturnObject, HasResult, ()); - LLDB_REGISTER_METHOD(void, SBCommandReturnObject, AppendMessage, - (const char *)); - LLDB_REGISTER_METHOD(void, SBCommandReturnObject, AppendWarning, - (const char *)); - LLDB_REGISTER_METHOD(bool, SBCommandReturnObject, GetDescription, - (lldb::SBStream &)); - LLDB_REGISTER_METHOD(void, SBCommandReturnObject, SetImmediateOutputFile, - (FILE *)); - LLDB_REGISTER_METHOD(void, SBCommandReturnObject, SetImmediateErrorFile, - (FILE *)); - LLDB_REGISTER_METHOD(void, SBCommandReturnObject, SetImmediateOutputFile, - (SBFile)); - LLDB_REGISTER_METHOD(void, SBCommandReturnObject, SetImmediateErrorFile, - (SBFile)); - LLDB_REGISTER_METHOD(void, SBCommandReturnObject, SetImmediateOutputFile, - (FileSP)); - LLDB_REGISTER_METHOD(void, SBCommandReturnObject, SetImmediateErrorFile, - (FileSP)); - LLDB_REGISTER_METHOD(void, SBCommandReturnObject, SetImmediateOutputFile, - (FILE *, bool)); - LLDB_REGISTER_METHOD(void, SBCommandReturnObject, SetImmediateErrorFile, - (FILE *, bool)); - LLDB_REGISTER_METHOD(void, SBCommandReturnObject, PutCString, - (const char *, int)); - LLDB_REGISTER_METHOD(const char *, SBCommandReturnObject, GetOutput, - (bool)); - LLDB_REGISTER_METHOD(const char *, SBCommandReturnObject, GetError, (bool)); - LLDB_REGISTER_METHOD(void, SBCommandReturnObject, SetError, - (lldb::SBError &, const char *)); - LLDB_REGISTER_METHOD(void, SBCommandReturnObject, SetError, (const char *)); -} - -} -} diff --git a/lldb/source/API/SBCommunication.cpp b/lldb/source/API/SBCommunication.cpp index 9a2ab89d5e4e..0a1dad1e2e8f 100644 --- a/lldb/source/API/SBCommunication.cpp +++ b/lldb/source/API/SBCommunication.cpp @@ -7,22 +7,20 @@ //===----------------------------------------------------------------------===// #include "lldb/API/SBCommunication.h" -#include "SBReproducerPrivate.h" #include "lldb/API/SBBroadcaster.h" #include "lldb/Core/Communication.h" #include "lldb/Host/ConnectionFileDescriptor.h" #include "lldb/Host/Host.h" +#include "lldb/Utility/Instrumentation.h" using namespace lldb; using namespace lldb_private; -SBCommunication::SBCommunication() { - LLDB_RECORD_CONSTRUCTOR_NO_ARGS(SBCommunication); -} +SBCommunication::SBCommunication() { LLDB_INSTRUMENT_VA(this); } SBCommunication::SBCommunication(const char *broadcaster_name) : m_opaque(new Communication(broadcaster_name)), m_opaque_owned(true) { - LLDB_RECORD_CONSTRUCTOR(SBCommunication, (const char *), broadcaster_name); + LLDB_INSTRUMENT_VA(this, broadcaster_name); } SBCommunication::~SBCommunication() { @@ -33,17 +31,17 @@ SBCommunication::~SBCommunication() { } bool SBCommunication::IsValid() const { - LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBCommunication, IsValid); + LLDB_INSTRUMENT_VA(this); return this->operator bool(); } SBCommunication::operator bool() const { - LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBCommunication, operator bool); + LLDB_INSTRUMENT_VA(this); return m_opaque != nullptr; } bool SBCommunication::GetCloseOnEOF() { - LLDB_RECORD_METHOD_NO_ARGS(bool, SBCommunication, GetCloseOnEOF); + LLDB_INSTRUMENT_VA(this); if (m_opaque) return m_opaque->GetCloseOnEOF(); @@ -51,15 +49,14 @@ bool SBCommunication::GetCloseOnEOF() { } void SBCommunication::SetCloseOnEOF(bool b) { - LLDB_RECORD_METHOD(void, SBCommunication, SetCloseOnEOF, (bool), b); + LLDB_INSTRUMENT_VA(this, b); if (m_opaque) m_opaque->SetCloseOnEOF(b); } ConnectionStatus SBCommunication::Connect(const char *url) { - LLDB_RECORD_METHOD(lldb::ConnectionStatus, SBCommunication, Connect, - (const char *), url); + LLDB_INSTRUMENT_VA(this, url); if (m_opaque) { if (!m_opaque->HasConnection()) @@ -70,8 +67,7 @@ ConnectionStatus SBCommunication::Connect(const char *url) { } ConnectionStatus SBCommunication::AdoptFileDesriptor(int fd, bool owns_fd) { - LLDB_RECORD_METHOD(lldb::ConnectionStatus, SBCommunication, - AdoptFileDesriptor, (int, bool), fd, owns_fd); + LLDB_INSTRUMENT_VA(this, fd, owns_fd); ConnectionStatus status = eConnectionStatusNoConnection; if (m_opaque) { @@ -90,8 +86,7 @@ ConnectionStatus SBCommunication::AdoptFileDesriptor(int fd, bool owns_fd) { } ConnectionStatus SBCommunication::Disconnect() { - LLDB_RECORD_METHOD_NO_ARGS(lldb::ConnectionStatus, SBCommunication, - Disconnect); + LLDB_INSTRUMENT_VA(this); ConnectionStatus status = eConnectionStatusNoConnection; if (m_opaque) @@ -100,16 +95,14 @@ ConnectionStatus SBCommunication::Disconnect() { } bool SBCommunication::IsConnected() const { - LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBCommunication, IsConnected); + LLDB_INSTRUMENT_VA(this); return m_opaque ? m_opaque->IsConnected() : false; } size_t SBCommunication::Read(void *dst, size_t dst_len, uint32_t timeout_usec, ConnectionStatus &status) { - LLDB_RECORD_DUMMY(size_t, SBCommunication, Read, - (void *, size_t, uint32_t, lldb::ConnectionStatus &), dst, - dst_len, timeout_usec, status); + LLDB_INSTRUMENT_VA(this, dst, dst_len, timeout_usec, status); size_t bytes_read = 0; Timeout<std::micro> timeout = timeout_usec == UINT32_MAX @@ -125,9 +118,7 @@ size_t SBCommunication::Read(void *dst, size_t dst_len, uint32_t timeout_usec, size_t SBCommunication::Write(const void *src, size_t src_len, ConnectionStatus &status) { - LLDB_RECORD_DUMMY(size_t, SBCommunication, Write, - (const void *, size_t, lldb::ConnectionStatus &), src, - src_len, status); + LLDB_INSTRUMENT_VA(this, src, src_len, status); size_t bytes_written = 0; if (m_opaque) @@ -139,28 +130,26 @@ size_t SBCommunication::Write(const void *src, size_t src_len, } bool SBCommunication::ReadThreadStart() { - LLDB_RECORD_METHOD_NO_ARGS(bool, SBCommunication, ReadThreadStart); + LLDB_INSTRUMENT_VA(this); return m_opaque ? m_opaque->StartReadThread() : false; } bool SBCommunication::ReadThreadStop() { - LLDB_RECORD_METHOD_NO_ARGS(bool, SBCommunication, ReadThreadStop); + LLDB_INSTRUMENT_VA(this); return m_opaque ? m_opaque->StopReadThread() : false; } bool SBCommunication::ReadThreadIsRunning() { - LLDB_RECORD_METHOD_NO_ARGS(bool, SBCommunication, ReadThreadIsRunning); + LLDB_INSTRUMENT_VA(this); return m_opaque ? m_opaque->ReadThreadIsRunning() : false; } bool SBCommunication::SetReadThreadBytesReceivedCallback( ReadThreadBytesReceived callback, void *callback_baton) { - LLDB_RECORD_DUMMY(bool, SBCommunication, SetReadThreadBytesReceivedCallback, - (lldb::SBCommunication::ReadThreadBytesReceived, void *), - callback, callback_baton); + LLDB_INSTRUMENT_VA(this, callback, callback_baton); bool result = false; if (m_opaque) { @@ -171,46 +160,14 @@ bool SBCommunication::SetReadThreadBytesReceivedCallback( } SBBroadcaster SBCommunication::GetBroadcaster() { - LLDB_RECORD_METHOD_NO_ARGS(lldb::SBBroadcaster, SBCommunication, - GetBroadcaster); + LLDB_INSTRUMENT_VA(this); SBBroadcaster broadcaster(m_opaque, false); - return LLDB_RECORD_RESULT(broadcaster); + return broadcaster; } const char *SBCommunication::GetBroadcasterClass() { - LLDB_RECORD_STATIC_METHOD_NO_ARGS(const char *, SBCommunication, - GetBroadcasterClass); + LLDB_INSTRUMENT(); return Communication::GetStaticBroadcasterClass().AsCString(); } - -namespace lldb_private { -namespace repro { - -template <> -void RegisterMethods<SBCommunication>(Registry &R) { - LLDB_REGISTER_CONSTRUCTOR(SBCommunication, ()); - LLDB_REGISTER_CONSTRUCTOR(SBCommunication, (const char *)); - LLDB_REGISTER_METHOD_CONST(bool, SBCommunication, IsValid, ()); - LLDB_REGISTER_METHOD_CONST(bool, SBCommunication, operator bool, ()); - LLDB_REGISTER_METHOD(bool, SBCommunication, GetCloseOnEOF, ()); - LLDB_REGISTER_METHOD(void, SBCommunication, SetCloseOnEOF, (bool)); - LLDB_REGISTER_METHOD(lldb::ConnectionStatus, SBCommunication, Connect, - (const char *)); - LLDB_REGISTER_METHOD(lldb::ConnectionStatus, SBCommunication, - AdoptFileDesriptor, (int, bool)); - LLDB_REGISTER_METHOD(lldb::ConnectionStatus, SBCommunication, Disconnect, - ()); - LLDB_REGISTER_METHOD_CONST(bool, SBCommunication, IsConnected, ()); - LLDB_REGISTER_METHOD(bool, SBCommunication, ReadThreadStart, ()); - LLDB_REGISTER_METHOD(bool, SBCommunication, ReadThreadStop, ()); - LLDB_REGISTER_METHOD(bool, SBCommunication, ReadThreadIsRunning, ()); - LLDB_REGISTER_METHOD(lldb::SBBroadcaster, SBCommunication, GetBroadcaster, - ()); - LLDB_REGISTER_STATIC_METHOD(const char *, SBCommunication, - GetBroadcasterClass, ()); -} - -} -} diff --git a/lldb/source/API/SBCompileUnit.cpp b/lldb/source/API/SBCompileUnit.cpp index a44d3b897110..46a319c6b7a3 100644 --- a/lldb/source/API/SBCompileUnit.cpp +++ b/lldb/source/API/SBCompileUnit.cpp @@ -7,7 +7,6 @@ //===----------------------------------------------------------------------===// #include "lldb/API/SBCompileUnit.h" -#include "SBReproducerPrivate.h" #include "lldb/API/SBLineEntry.h" #include "lldb/API/SBStream.h" #include "lldb/Core/Module.h" @@ -17,45 +16,41 @@ #include "lldb/Symbol/SymbolFile.h" #include "lldb/Symbol/Type.h" #include "lldb/Symbol/TypeList.h" +#include "lldb/Utility/Instrumentation.h" using namespace lldb; using namespace lldb_private; -SBCompileUnit::SBCompileUnit() { - LLDB_RECORD_CONSTRUCTOR_NO_ARGS(SBCompileUnit); -} +SBCompileUnit::SBCompileUnit() { LLDB_INSTRUMENT_VA(this); } SBCompileUnit::SBCompileUnit(lldb_private::CompileUnit *lldb_object_ptr) : m_opaque_ptr(lldb_object_ptr) {} SBCompileUnit::SBCompileUnit(const SBCompileUnit &rhs) : m_opaque_ptr(rhs.m_opaque_ptr) { - LLDB_RECORD_CONSTRUCTOR(SBCompileUnit, (const lldb::SBCompileUnit &), rhs); + LLDB_INSTRUMENT_VA(this, rhs); } const SBCompileUnit &SBCompileUnit::operator=(const SBCompileUnit &rhs) { - LLDB_RECORD_METHOD(const lldb::SBCompileUnit &, - SBCompileUnit, operator=,(const lldb::SBCompileUnit &), - rhs); + LLDB_INSTRUMENT_VA(this, rhs); m_opaque_ptr = rhs.m_opaque_ptr; - return LLDB_RECORD_RESULT(*this); + return *this; } SBCompileUnit::~SBCompileUnit() { m_opaque_ptr = nullptr; } SBFileSpec SBCompileUnit::GetFileSpec() const { - LLDB_RECORD_METHOD_CONST_NO_ARGS(lldb::SBFileSpec, SBCompileUnit, - GetFileSpec); + LLDB_INSTRUMENT_VA(this); SBFileSpec file_spec; if (m_opaque_ptr) file_spec.SetFileSpec(m_opaque_ptr->GetPrimaryFile()); - return LLDB_RECORD_RESULT(file_spec); + return file_spec; } uint32_t SBCompileUnit::GetNumLineEntries() const { - LLDB_RECORD_METHOD_CONST_NO_ARGS(uint32_t, SBCompileUnit, GetNumLineEntries); + LLDB_INSTRUMENT_VA(this); if (m_opaque_ptr) { LineTable *line_table = m_opaque_ptr->GetLineTable(); @@ -67,8 +62,7 @@ uint32_t SBCompileUnit::GetNumLineEntries() const { } SBLineEntry SBCompileUnit::GetLineEntryAtIndex(uint32_t idx) const { - LLDB_RECORD_METHOD_CONST(lldb::SBLineEntry, SBCompileUnit, - GetLineEntryAtIndex, (uint32_t), idx); + LLDB_INSTRUMENT_VA(this, idx); SBLineEntry sb_line_entry; if (m_opaque_ptr) { @@ -80,14 +74,12 @@ SBLineEntry SBCompileUnit::GetLineEntryAtIndex(uint32_t idx) const { } } - return LLDB_RECORD_RESULT(sb_line_entry); + return sb_line_entry; } uint32_t SBCompileUnit::FindLineEntryIndex(uint32_t start_idx, uint32_t line, SBFileSpec *inline_file_spec) const { - LLDB_RECORD_METHOD_CONST(uint32_t, SBCompileUnit, FindLineEntryIndex, - (uint32_t, uint32_t, lldb::SBFileSpec *), start_idx, - line, inline_file_spec); + LLDB_INSTRUMENT_VA(this, start_idx, line, inline_file_spec); const bool exact = true; return FindLineEntryIndex(start_idx, line, inline_file_spec, exact); @@ -96,9 +88,7 @@ uint32_t SBCompileUnit::FindLineEntryIndex(uint32_t start_idx, uint32_t line, uint32_t SBCompileUnit::FindLineEntryIndex(uint32_t start_idx, uint32_t line, SBFileSpec *inline_file_spec, bool exact) const { - LLDB_RECORD_METHOD_CONST(uint32_t, SBCompileUnit, FindLineEntryIndex, - (uint32_t, uint32_t, lldb::SBFileSpec *, bool), - start_idx, line, inline_file_spec, exact); + LLDB_INSTRUMENT_VA(this, start_idx, line, inline_file_spec, exact); uint32_t index = UINT32_MAX; if (m_opaque_ptr) { @@ -118,7 +108,7 @@ uint32_t SBCompileUnit::FindLineEntryIndex(uint32_t start_idx, uint32_t line, } uint32_t SBCompileUnit::GetNumSupportFiles() const { - LLDB_RECORD_METHOD_CONST_NO_ARGS(uint32_t, SBCompileUnit, GetNumSupportFiles); + LLDB_INSTRUMENT_VA(this); if (m_opaque_ptr) return m_opaque_ptr->GetSupportFiles().GetSize(); @@ -127,32 +117,30 @@ uint32_t SBCompileUnit::GetNumSupportFiles() const { } lldb::SBTypeList SBCompileUnit::GetTypes(uint32_t type_mask) { - LLDB_RECORD_METHOD(lldb::SBTypeList, SBCompileUnit, GetTypes, (uint32_t), - type_mask); + LLDB_INSTRUMENT_VA(this, type_mask); SBTypeList sb_type_list; if (!m_opaque_ptr) - return LLDB_RECORD_RESULT(sb_type_list); + return sb_type_list; ModuleSP module_sp(m_opaque_ptr->GetModule()); if (!module_sp) - return LLDB_RECORD_RESULT(sb_type_list); + return sb_type_list; SymbolFile *symfile = module_sp->GetSymbolFile(); if (!symfile) - return LLDB_RECORD_RESULT(sb_type_list); + return sb_type_list; TypeClass type_class = static_cast<TypeClass>(type_mask); TypeList type_list; symfile->GetTypes(m_opaque_ptr, type_class, type_list); sb_type_list.m_opaque_up->Append(type_list); - return LLDB_RECORD_RESULT(sb_type_list); + return sb_type_list; } SBFileSpec SBCompileUnit::GetSupportFileAtIndex(uint32_t idx) const { - LLDB_RECORD_METHOD_CONST(lldb::SBFileSpec, SBCompileUnit, - GetSupportFileAtIndex, (uint32_t), idx); + LLDB_INSTRUMENT_VA(this, idx); SBFileSpec sb_file_spec; if (m_opaque_ptr) { @@ -160,16 +148,13 @@ SBFileSpec SBCompileUnit::GetSupportFileAtIndex(uint32_t idx) const { sb_file_spec.SetFileSpec(spec); } - - return LLDB_RECORD_RESULT(sb_file_spec); + return sb_file_spec; } uint32_t SBCompileUnit::FindSupportFileIndex(uint32_t start_idx, const SBFileSpec &sb_file, bool full) { - LLDB_RECORD_METHOD(uint32_t, SBCompileUnit, FindSupportFileIndex, - (uint32_t, const lldb::SBFileSpec &, bool), start_idx, - sb_file, full); + LLDB_INSTRUMENT_VA(this, start_idx, sb_file, full); if (m_opaque_ptr) { const FileSpecList &support_files = m_opaque_ptr->GetSupportFiles(); @@ -179,7 +164,7 @@ uint32_t SBCompileUnit::FindSupportFileIndex(uint32_t start_idx, } lldb::LanguageType SBCompileUnit::GetLanguage() { - LLDB_RECORD_METHOD_NO_ARGS(lldb::LanguageType, SBCompileUnit, GetLanguage); + LLDB_INSTRUMENT_VA(this); if (m_opaque_ptr) return m_opaque_ptr->GetLanguage(); @@ -187,25 +172,23 @@ lldb::LanguageType SBCompileUnit::GetLanguage() { } bool SBCompileUnit::IsValid() const { - LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBCompileUnit, IsValid); + LLDB_INSTRUMENT_VA(this); return this->operator bool(); } SBCompileUnit::operator bool() const { - LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBCompileUnit, operator bool); + LLDB_INSTRUMENT_VA(this); return m_opaque_ptr != nullptr; } bool SBCompileUnit::operator==(const SBCompileUnit &rhs) const { - LLDB_RECORD_METHOD_CONST( - bool, SBCompileUnit, operator==,(const lldb::SBCompileUnit &), rhs); + LLDB_INSTRUMENT_VA(this, rhs); return m_opaque_ptr == rhs.m_opaque_ptr; } bool SBCompileUnit::operator!=(const SBCompileUnit &rhs) const { - LLDB_RECORD_METHOD_CONST( - bool, SBCompileUnit, operator!=,(const lldb::SBCompileUnit &), rhs); + LLDB_INSTRUMENT_VA(this, rhs); return m_opaque_ptr != rhs.m_opaque_ptr; } @@ -225,8 +208,7 @@ void SBCompileUnit::reset(lldb_private::CompileUnit *lldb_object_ptr) { } bool SBCompileUnit::GetDescription(SBStream &description) { - LLDB_RECORD_METHOD(bool, SBCompileUnit, GetDescription, (lldb::SBStream &), - description); + LLDB_INSTRUMENT_VA(this, description); Stream &strm = description.ref(); @@ -237,42 +219,3 @@ bool SBCompileUnit::GetDescription(SBStream &description) { return true; } - -namespace lldb_private { -namespace repro { - -template <> -void RegisterMethods<SBCompileUnit>(Registry &R) { - LLDB_REGISTER_CONSTRUCTOR(SBCompileUnit, ()); - LLDB_REGISTER_CONSTRUCTOR(SBCompileUnit, (const lldb::SBCompileUnit &)); - LLDB_REGISTER_METHOD( - const lldb::SBCompileUnit &, - SBCompileUnit, operator=,(const lldb::SBCompileUnit &)); - LLDB_REGISTER_METHOD_CONST(lldb::SBFileSpec, SBCompileUnit, GetFileSpec, - ()); - LLDB_REGISTER_METHOD_CONST(uint32_t, SBCompileUnit, GetNumLineEntries, ()); - LLDB_REGISTER_METHOD_CONST(lldb::SBLineEntry, SBCompileUnit, - GetLineEntryAtIndex, (uint32_t)); - LLDB_REGISTER_METHOD_CONST(uint32_t, SBCompileUnit, FindLineEntryIndex, - (uint32_t, uint32_t, lldb::SBFileSpec *)); - LLDB_REGISTER_METHOD_CONST(uint32_t, SBCompileUnit, FindLineEntryIndex, - (uint32_t, uint32_t, lldb::SBFileSpec *, bool)); - LLDB_REGISTER_METHOD_CONST(uint32_t, SBCompileUnit, GetNumSupportFiles, ()); - LLDB_REGISTER_METHOD(lldb::SBTypeList, SBCompileUnit, GetTypes, (uint32_t)); - LLDB_REGISTER_METHOD_CONST(lldb::SBFileSpec, SBCompileUnit, - GetSupportFileAtIndex, (uint32_t)); - LLDB_REGISTER_METHOD(uint32_t, SBCompileUnit, FindSupportFileIndex, - (uint32_t, const lldb::SBFileSpec &, bool)); - LLDB_REGISTER_METHOD(lldb::LanguageType, SBCompileUnit, GetLanguage, ()); - LLDB_REGISTER_METHOD_CONST(bool, SBCompileUnit, IsValid, ()); - LLDB_REGISTER_METHOD_CONST(bool, SBCompileUnit, operator bool, ()); - LLDB_REGISTER_METHOD_CONST( - bool, SBCompileUnit, operator==,(const lldb::SBCompileUnit &)); - LLDB_REGISTER_METHOD_CONST( - bool, SBCompileUnit, operator!=,(const lldb::SBCompileUnit &)); - LLDB_REGISTER_METHOD(bool, SBCompileUnit, GetDescription, - (lldb::SBStream &)); -} - -} -} diff --git a/lldb/source/API/SBData.cpp b/lldb/source/API/SBData.cpp index 9fc590578bce..5232bdde1ded 100644 --- a/lldb/source/API/SBData.cpp +++ b/lldb/source/API/SBData.cpp @@ -7,9 +7,9 @@ //===----------------------------------------------------------------------===// #include "lldb/API/SBData.h" -#include "SBReproducerPrivate.h" #include "lldb/API/SBError.h" #include "lldb/API/SBStream.h" +#include "lldb/Utility/Instrumentation.h" #include "lldb/Core/DumpDataExtractor.h" #include "lldb/Utility/DataBufferHeap.h" @@ -23,22 +23,21 @@ using namespace lldb; using namespace lldb_private; SBData::SBData() : m_opaque_sp(new DataExtractor()) { - LLDB_RECORD_CONSTRUCTOR_NO_ARGS(SBData); + LLDB_INSTRUMENT_VA(this); } SBData::SBData(const lldb::DataExtractorSP &data_sp) : m_opaque_sp(data_sp) {} SBData::SBData(const SBData &rhs) : m_opaque_sp(rhs.m_opaque_sp) { - LLDB_RECORD_CONSTRUCTOR(SBData, (const lldb::SBData &), rhs); + LLDB_INSTRUMENT_VA(this, rhs); } const SBData &SBData::operator=(const SBData &rhs) { - LLDB_RECORD_METHOD(const lldb::SBData &, - SBData, operator=,(const lldb::SBData &), rhs); + LLDB_INSTRUMENT_VA(this, rhs); if (this != &rhs) m_opaque_sp = rhs.m_opaque_sp; - return LLDB_RECORD_RESULT(*this); + return *this; } SBData::~SBData() = default; @@ -58,17 +57,17 @@ lldb::DataExtractorSP &SBData::operator*() { return m_opaque_sp; } const lldb::DataExtractorSP &SBData::operator*() const { return m_opaque_sp; } bool SBData::IsValid() { - LLDB_RECORD_METHOD_NO_ARGS(bool, SBData, IsValid); + LLDB_INSTRUMENT_VA(this); return this->operator bool(); } SBData::operator bool() const { - LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBData, operator bool); + LLDB_INSTRUMENT_VA(this); return m_opaque_sp.get() != nullptr; } uint8_t SBData::GetAddressByteSize() { - LLDB_RECORD_METHOD_NO_ARGS(uint8_t, SBData, GetAddressByteSize); + LLDB_INSTRUMENT_VA(this); uint8_t value = 0; if (m_opaque_sp.get()) @@ -77,22 +76,21 @@ uint8_t SBData::GetAddressByteSize() { } void SBData::SetAddressByteSize(uint8_t addr_byte_size) { - LLDB_RECORD_METHOD(void, SBData, SetAddressByteSize, (uint8_t), - addr_byte_size); + LLDB_INSTRUMENT_VA(this, addr_byte_size); if (m_opaque_sp.get()) m_opaque_sp->SetAddressByteSize(addr_byte_size); } void SBData::Clear() { - LLDB_RECORD_METHOD_NO_ARGS(void, SBData, Clear); + LLDB_INSTRUMENT_VA(this); if (m_opaque_sp.get()) m_opaque_sp->Clear(); } size_t SBData::GetByteSize() { - LLDB_RECORD_METHOD_NO_ARGS(size_t, SBData, GetByteSize); + LLDB_INSTRUMENT_VA(this); size_t value = 0; if (m_opaque_sp.get()) @@ -101,7 +99,7 @@ size_t SBData::GetByteSize() { } lldb::ByteOrder SBData::GetByteOrder() { - LLDB_RECORD_METHOD_NO_ARGS(lldb::ByteOrder, SBData, GetByteOrder); + LLDB_INSTRUMENT_VA(this); lldb::ByteOrder value = eByteOrderInvalid; if (m_opaque_sp.get()) @@ -110,15 +108,14 @@ lldb::ByteOrder SBData::GetByteOrder() { } void SBData::SetByteOrder(lldb::ByteOrder endian) { - LLDB_RECORD_METHOD(void, SBData, SetByteOrder, (lldb::ByteOrder), endian); + LLDB_INSTRUMENT_VA(this, endian); if (m_opaque_sp.get()) m_opaque_sp->SetByteOrder(endian); } float SBData::GetFloat(lldb::SBError &error, lldb::offset_t offset) { - LLDB_RECORD_METHOD(float, SBData, GetFloat, (lldb::SBError &, lldb::offset_t), - error, offset); + LLDB_INSTRUMENT_VA(this, error, offset); float value = 0; if (!m_opaque_sp.get()) { @@ -133,8 +130,7 @@ float SBData::GetFloat(lldb::SBError &error, lldb::offset_t offset) { } double SBData::GetDouble(lldb::SBError &error, lldb::offset_t offset) { - LLDB_RECORD_METHOD(double, SBData, GetDouble, - (lldb::SBError &, lldb::offset_t), error, offset); + LLDB_INSTRUMENT_VA(this, error, offset); double value = 0; if (!m_opaque_sp.get()) { @@ -149,8 +145,7 @@ double SBData::GetDouble(lldb::SBError &error, lldb::offset_t offset) { } long double SBData::GetLongDouble(lldb::SBError &error, lldb::offset_t offset) { - LLDB_RECORD_METHOD(long double, SBData, GetLongDouble, - (lldb::SBError &, lldb::offset_t), error, offset); + LLDB_INSTRUMENT_VA(this, error, offset); long double value = 0; if (!m_opaque_sp.get()) { @@ -165,8 +160,7 @@ long double SBData::GetLongDouble(lldb::SBError &error, lldb::offset_t offset) { } lldb::addr_t SBData::GetAddress(lldb::SBError &error, lldb::offset_t offset) { - LLDB_RECORD_METHOD(lldb::addr_t, SBData, GetAddress, - (lldb::SBError &, lldb::offset_t), error, offset); + LLDB_INSTRUMENT_VA(this, error, offset); lldb::addr_t value = 0; if (!m_opaque_sp.get()) { @@ -181,8 +175,7 @@ lldb::addr_t SBData::GetAddress(lldb::SBError &error, lldb::offset_t offset) { } uint8_t SBData::GetUnsignedInt8(lldb::SBError &error, lldb::offset_t offset) { - LLDB_RECORD_METHOD(uint8_t, SBData, GetUnsignedInt8, - (lldb::SBError &, lldb::offset_t), error, offset); + LLDB_INSTRUMENT_VA(this, error, offset); uint8_t value = 0; if (!m_opaque_sp.get()) { @@ -197,8 +190,7 @@ uint8_t SBData::GetUnsignedInt8(lldb::SBError &error, lldb::offset_t offset) { } uint16_t SBData::GetUnsignedInt16(lldb::SBError &error, lldb::offset_t offset) { - LLDB_RECORD_METHOD(uint16_t, SBData, GetUnsignedInt16, - (lldb::SBError &, lldb::offset_t), error, offset); + LLDB_INSTRUMENT_VA(this, error, offset); uint16_t value = 0; if (!m_opaque_sp.get()) { @@ -213,8 +205,7 @@ uint16_t SBData::GetUnsignedInt16(lldb::SBError &error, lldb::offset_t offset) { } uint32_t SBData::GetUnsignedInt32(lldb::SBError &error, lldb::offset_t offset) { - LLDB_RECORD_METHOD(uint32_t, SBData, GetUnsignedInt32, - (lldb::SBError &, lldb::offset_t), error, offset); + LLDB_INSTRUMENT_VA(this, error, offset); uint32_t value = 0; if (!m_opaque_sp.get()) { @@ -229,8 +220,7 @@ uint32_t SBData::GetUnsignedInt32(lldb::SBError &error, lldb::offset_t offset) { } uint64_t SBData::GetUnsignedInt64(lldb::SBError &error, lldb::offset_t offset) { - LLDB_RECORD_METHOD(uint64_t, SBData, GetUnsignedInt64, - (lldb::SBError &, lldb::offset_t), error, offset); + LLDB_INSTRUMENT_VA(this, error, offset); uint64_t value = 0; if (!m_opaque_sp.get()) { @@ -245,8 +235,7 @@ uint64_t SBData::GetUnsignedInt64(lldb::SBError &error, lldb::offset_t offset) { } int8_t SBData::GetSignedInt8(lldb::SBError &error, lldb::offset_t offset) { - LLDB_RECORD_METHOD(int8_t, SBData, GetSignedInt8, - (lldb::SBError &, lldb::offset_t), error, offset); + LLDB_INSTRUMENT_VA(this, error, offset); int8_t value = 0; if (!m_opaque_sp.get()) { @@ -261,8 +250,7 @@ int8_t SBData::GetSignedInt8(lldb::SBError &error, lldb::offset_t offset) { } int16_t SBData::GetSignedInt16(lldb::SBError &error, lldb::offset_t offset) { - LLDB_RECORD_METHOD(int16_t, SBData, GetSignedInt16, - (lldb::SBError &, lldb::offset_t), error, offset); + LLDB_INSTRUMENT_VA(this, error, offset); int16_t value = 0; if (!m_opaque_sp.get()) { @@ -277,8 +265,7 @@ int16_t SBData::GetSignedInt16(lldb::SBError &error, lldb::offset_t offset) { } int32_t SBData::GetSignedInt32(lldb::SBError &error, lldb::offset_t offset) { - LLDB_RECORD_METHOD(int32_t, SBData, GetSignedInt32, - (lldb::SBError &, lldb::offset_t), error, offset); + LLDB_INSTRUMENT_VA(this, error, offset); int32_t value = 0; if (!m_opaque_sp.get()) { @@ -293,8 +280,7 @@ int32_t SBData::GetSignedInt32(lldb::SBError &error, lldb::offset_t offset) { } int64_t SBData::GetSignedInt64(lldb::SBError &error, lldb::offset_t offset) { - LLDB_RECORD_METHOD(int64_t, SBData, GetSignedInt64, - (lldb::SBError &, lldb::offset_t), error, offset); + LLDB_INSTRUMENT_VA(this, error, offset); int64_t value = 0; if (!m_opaque_sp.get()) { @@ -309,8 +295,7 @@ int64_t SBData::GetSignedInt64(lldb::SBError &error, lldb::offset_t offset) { } const char *SBData::GetString(lldb::SBError &error, lldb::offset_t offset) { - LLDB_RECORD_METHOD(const char *, SBData, GetString, - (lldb::SBError &, lldb::offset_t), error, offset); + LLDB_INSTRUMENT_VA(this, error, offset); const char *value = nullptr; if (!m_opaque_sp.get()) { @@ -326,8 +311,7 @@ const char *SBData::GetString(lldb::SBError &error, lldb::offset_t offset) { bool SBData::GetDescription(lldb::SBStream &description, lldb::addr_t base_addr) { - LLDB_RECORD_METHOD(bool, SBData, GetDescription, - (lldb::SBStream &, lldb::addr_t), description, base_addr); + LLDB_INSTRUMENT_VA(this, description, base_addr); Stream &strm = description.ref(); @@ -342,9 +326,7 @@ bool SBData::GetDescription(lldb::SBStream &description, size_t SBData::ReadRawData(lldb::SBError &error, lldb::offset_t offset, void *buf, size_t size) { - LLDB_RECORD_DUMMY(size_t, SBData, ReadRawData, - (lldb::SBError &, lldb::offset_t, void *, size_t), error, - offset, buf, size); + LLDB_INSTRUMENT_VA(this, error, offset, buf, size); void *ok = nullptr; if (!m_opaque_sp.get()) { @@ -360,10 +342,7 @@ size_t SBData::ReadRawData(lldb::SBError &error, lldb::offset_t offset, void SBData::SetData(lldb::SBError &error, const void *buf, size_t size, lldb::ByteOrder endian, uint8_t addr_size) { - LLDB_RECORD_DUMMY( - void, SBData, SetData, - (lldb::SBError &, const void *, size_t, lldb::ByteOrder, uint8_t), error, - buf, size, endian, addr_size); + LLDB_INSTRUMENT_VA(this, error, buf, size, endian, addr_size); if (!m_opaque_sp.get()) m_opaque_sp = std::make_shared<DataExtractor>(buf, size, endian, addr_size); @@ -377,10 +356,7 @@ void SBData::SetData(lldb::SBError &error, const void *buf, size_t size, void SBData::SetDataWithOwnership(lldb::SBError &error, const void *buf, size_t size, lldb::ByteOrder endian, uint8_t addr_size) { - LLDB_RECORD_DUMMY( - void, SBData, SetData, - (lldb::SBError &, const void *, size_t, lldb::ByteOrder, uint8_t, bool), - error, buf, size, endian, addr_size, copy); + LLDB_INSTRUMENT_VA(this, error, buf, size, endian, addr_size); lldb::DataBufferSP buffer_sp = std::make_shared<DataBufferHeap>(buf, size); @@ -394,7 +370,7 @@ void SBData::SetDataWithOwnership(lldb::SBError &error, const void *buf, } bool SBData::Append(const SBData &rhs) { - LLDB_RECORD_METHOD(bool, SBData, Append, (const lldb::SBData &), rhs); + LLDB_INSTRUMENT_VA(this, rhs); bool value = false; if (m_opaque_sp.get() && rhs.m_opaque_sp.get()) @@ -405,12 +381,10 @@ bool SBData::Append(const SBData &rhs) { lldb::SBData SBData::CreateDataFromCString(lldb::ByteOrder endian, uint32_t addr_byte_size, const char *data) { - LLDB_RECORD_STATIC_METHOD(lldb::SBData, SBData, CreateDataFromCString, - (lldb::ByteOrder, uint32_t, const char *), endian, - addr_byte_size, data); + LLDB_INSTRUMENT_VA(endian, addr_byte_size, data); if (!data || !data[0]) - return LLDB_RECORD_RESULT(SBData()); + return SBData(); uint32_t data_len = strlen(data); @@ -420,19 +394,17 @@ lldb::SBData SBData::CreateDataFromCString(lldb::ByteOrder endian, SBData ret(data_sp); - return LLDB_RECORD_RESULT(ret); + return ret; } lldb::SBData SBData::CreateDataFromUInt64Array(lldb::ByteOrder endian, uint32_t addr_byte_size, uint64_t *array, size_t array_len) { - LLDB_RECORD_STATIC_METHOD(lldb::SBData, SBData, CreateDataFromUInt64Array, - (lldb::ByteOrder, uint32_t, uint64_t *, size_t), - endian, addr_byte_size, array, array_len); + LLDB_INSTRUMENT_VA(endian, addr_byte_size, array, array_len); if (!array || array_len == 0) - return LLDB_RECORD_RESULT(SBData()); + return SBData(); size_t data_len = array_len * sizeof(uint64_t); @@ -442,19 +414,17 @@ lldb::SBData SBData::CreateDataFromUInt64Array(lldb::ByteOrder endian, SBData ret(data_sp); - return LLDB_RECORD_RESULT(ret); + return ret; } lldb::SBData SBData::CreateDataFromUInt32Array(lldb::ByteOrder endian, uint32_t addr_byte_size, uint32_t *array, size_t array_len) { - LLDB_RECORD_STATIC_METHOD(lldb::SBData, SBData, CreateDataFromUInt32Array, - (lldb::ByteOrder, uint32_t, uint32_t *, size_t), - endian, addr_byte_size, array, array_len); + LLDB_INSTRUMENT_VA(endian, addr_byte_size, array, array_len); if (!array || array_len == 0) - return LLDB_RECORD_RESULT(SBData()); + return SBData(); size_t data_len = array_len * sizeof(uint32_t); @@ -464,19 +434,17 @@ lldb::SBData SBData::CreateDataFromUInt32Array(lldb::ByteOrder endian, SBData ret(data_sp); - return LLDB_RECORD_RESULT(ret); + return ret; } lldb::SBData SBData::CreateDataFromSInt64Array(lldb::ByteOrder endian, uint32_t addr_byte_size, int64_t *array, size_t array_len) { - LLDB_RECORD_STATIC_METHOD(lldb::SBData, SBData, CreateDataFromSInt64Array, - (lldb::ByteOrder, uint32_t, int64_t *, size_t), - endian, addr_byte_size, array, array_len); + LLDB_INSTRUMENT_VA(endian, addr_byte_size, array, array_len); if (!array || array_len == 0) - return LLDB_RECORD_RESULT(SBData()); + return SBData(); size_t data_len = array_len * sizeof(int64_t); @@ -486,19 +454,17 @@ lldb::SBData SBData::CreateDataFromSInt64Array(lldb::ByteOrder endian, SBData ret(data_sp); - return LLDB_RECORD_RESULT(ret); + return ret; } lldb::SBData SBData::CreateDataFromSInt32Array(lldb::ByteOrder endian, uint32_t addr_byte_size, int32_t *array, size_t array_len) { - LLDB_RECORD_STATIC_METHOD(lldb::SBData, SBData, CreateDataFromSInt32Array, - (lldb::ByteOrder, uint32_t, int32_t *, size_t), - endian, addr_byte_size, array, array_len); + LLDB_INSTRUMENT_VA(endian, addr_byte_size, array, array_len); if (!array || array_len == 0) - return LLDB_RECORD_RESULT(SBData()); + return SBData(); size_t data_len = array_len * sizeof(int32_t); @@ -508,19 +474,17 @@ lldb::SBData SBData::CreateDataFromSInt32Array(lldb::ByteOrder endian, SBData ret(data_sp); - return LLDB_RECORD_RESULT(ret); + return ret; } lldb::SBData SBData::CreateDataFromDoubleArray(lldb::ByteOrder endian, uint32_t addr_byte_size, double *array, size_t array_len) { - LLDB_RECORD_STATIC_METHOD(lldb::SBData, SBData, CreateDataFromDoubleArray, - (lldb::ByteOrder, uint32_t, double *, size_t), - endian, addr_byte_size, array, array_len); + LLDB_INSTRUMENT_VA(endian, addr_byte_size, array, array_len); if (!array || array_len == 0) - return LLDB_RECORD_RESULT(SBData()); + return SBData(); size_t data_len = array_len * sizeof(double); @@ -530,12 +494,11 @@ lldb::SBData SBData::CreateDataFromDoubleArray(lldb::ByteOrder endian, SBData ret(data_sp); - return LLDB_RECORD_RESULT(ret); + return ret; } bool SBData::SetDataFromCString(const char *data) { - LLDB_RECORD_METHOD(bool, SBData, SetDataFromCString, (const char *), data); - + LLDB_INSTRUMENT_VA(this, data); if (!data) { return false; @@ -556,9 +519,7 @@ bool SBData::SetDataFromCString(const char *data) { } bool SBData::SetDataFromUInt64Array(uint64_t *array, size_t array_len) { - LLDB_RECORD_METHOD(bool, SBData, SetDataFromUInt64Array, (uint64_t *, size_t), - array, array_len); - + LLDB_INSTRUMENT_VA(this, array, array_len); if (!array || array_len == 0) { return false; @@ -579,9 +540,7 @@ bool SBData::SetDataFromUInt64Array(uint64_t *array, size_t array_len) { } bool SBData::SetDataFromUInt32Array(uint32_t *array, size_t array_len) { - LLDB_RECORD_METHOD(bool, SBData, SetDataFromUInt32Array, (uint32_t *, size_t), - array, array_len); - + LLDB_INSTRUMENT_VA(this, array, array_len); if (!array || array_len == 0) { return false; @@ -601,9 +560,7 @@ bool SBData::SetDataFromUInt32Array(uint32_t *array, size_t array_len) { } bool SBData::SetDataFromSInt64Array(int64_t *array, size_t array_len) { - LLDB_RECORD_METHOD(bool, SBData, SetDataFromSInt64Array, (int64_t *, size_t), - array, array_len); - + LLDB_INSTRUMENT_VA(this, array, array_len); if (!array || array_len == 0) { return false; @@ -623,9 +580,7 @@ bool SBData::SetDataFromSInt64Array(int64_t *array, size_t array_len) { } bool SBData::SetDataFromSInt32Array(int32_t *array, size_t array_len) { - LLDB_RECORD_METHOD(bool, SBData, SetDataFromSInt32Array, (int32_t *, size_t), - array, array_len); - + LLDB_INSTRUMENT_VA(this, array, array_len); if (!array || array_len == 0) { return false; @@ -645,9 +600,7 @@ bool SBData::SetDataFromSInt32Array(int32_t *array, size_t array_len) { } bool SBData::SetDataFromDoubleArray(double *array, size_t array_len) { - LLDB_RECORD_METHOD(bool, SBData, SetDataFromDoubleArray, (double *, size_t), - array, array_len); - + LLDB_INSTRUMENT_VA(this, array, array_len); if (!array || array_len == 0) { return false; @@ -665,79 +618,3 @@ bool SBData::SetDataFromDoubleArray(double *array, size_t array_len) { return true; } - -namespace lldb_private { -namespace repro { - -template <> -void RegisterMethods<SBData>(Registry &R) { - LLDB_REGISTER_CONSTRUCTOR(SBData, ()); - LLDB_REGISTER_CONSTRUCTOR(SBData, (const lldb::SBData &)); - LLDB_REGISTER_METHOD(const lldb::SBData &, - SBData, operator=,(const lldb::SBData &)); - LLDB_REGISTER_METHOD(bool, SBData, IsValid, ()); - LLDB_REGISTER_METHOD_CONST(bool, SBData, operator bool, ()); - LLDB_REGISTER_METHOD(uint8_t, SBData, GetAddressByteSize, ()); - LLDB_REGISTER_METHOD(void, SBData, SetAddressByteSize, (uint8_t)); - LLDB_REGISTER_METHOD(void, SBData, Clear, ()); - LLDB_REGISTER_METHOD(size_t, SBData, GetByteSize, ()); - LLDB_REGISTER_METHOD(lldb::ByteOrder, SBData, GetByteOrder, ()); - LLDB_REGISTER_METHOD(void, SBData, SetByteOrder, (lldb::ByteOrder)); - LLDB_REGISTER_METHOD(float, SBData, GetFloat, - (lldb::SBError &, lldb::offset_t)); - LLDB_REGISTER_METHOD(double, SBData, GetDouble, - (lldb::SBError &, lldb::offset_t)); - LLDB_REGISTER_METHOD(long double, SBData, GetLongDouble, - (lldb::SBError &, lldb::offset_t)); - LLDB_REGISTER_METHOD(lldb::addr_t, SBData, GetAddress, - (lldb::SBError &, lldb::offset_t)); - LLDB_REGISTER_METHOD(uint8_t, SBData, GetUnsignedInt8, - (lldb::SBError &, lldb::offset_t)); - LLDB_REGISTER_METHOD(uint16_t, SBData, GetUnsignedInt16, - (lldb::SBError &, lldb::offset_t)); - LLDB_REGISTER_METHOD(uint32_t, SBData, GetUnsignedInt32, - (lldb::SBError &, lldb::offset_t)); - LLDB_REGISTER_METHOD(uint64_t, SBData, GetUnsignedInt64, - (lldb::SBError &, lldb::offset_t)); - LLDB_REGISTER_METHOD(int8_t, SBData, GetSignedInt8, - (lldb::SBError &, lldb::offset_t)); - LLDB_REGISTER_METHOD(int16_t, SBData, GetSignedInt16, - (lldb::SBError &, lldb::offset_t)); - LLDB_REGISTER_METHOD(int32_t, SBData, GetSignedInt32, - (lldb::SBError &, lldb::offset_t)); - LLDB_REGISTER_METHOD(int64_t, SBData, GetSignedInt64, - (lldb::SBError &, lldb::offset_t)); - LLDB_REGISTER_METHOD(const char *, SBData, GetString, - (lldb::SBError &, lldb::offset_t)); - LLDB_REGISTER_METHOD(bool, SBData, GetDescription, - (lldb::SBStream &, lldb::addr_t)); - LLDB_REGISTER_METHOD(bool, SBData, Append, (const lldb::SBData &)); - LLDB_REGISTER_STATIC_METHOD(lldb::SBData, SBData, CreateDataFromCString, - (lldb::ByteOrder, uint32_t, const char *)); - LLDB_REGISTER_STATIC_METHOD( - lldb::SBData, SBData, CreateDataFromUInt64Array, - (lldb::ByteOrder, uint32_t, uint64_t *, size_t)); - LLDB_REGISTER_STATIC_METHOD( - lldb::SBData, SBData, CreateDataFromUInt32Array, - (lldb::ByteOrder, uint32_t, uint32_t *, size_t)); - LLDB_REGISTER_STATIC_METHOD(lldb::SBData, SBData, CreateDataFromSInt64Array, - (lldb::ByteOrder, uint32_t, int64_t *, size_t)); - LLDB_REGISTER_STATIC_METHOD(lldb::SBData, SBData, CreateDataFromSInt32Array, - (lldb::ByteOrder, uint32_t, int32_t *, size_t)); - LLDB_REGISTER_STATIC_METHOD(lldb::SBData, SBData, CreateDataFromDoubleArray, - (lldb::ByteOrder, uint32_t, double *, size_t)); - LLDB_REGISTER_METHOD(bool, SBData, SetDataFromCString, (const char *)); - LLDB_REGISTER_METHOD(bool, SBData, SetDataFromUInt64Array, - (uint64_t *, size_t)); - LLDB_REGISTER_METHOD(bool, SBData, SetDataFromUInt32Array, - (uint32_t *, size_t)); - LLDB_REGISTER_METHOD(bool, SBData, SetDataFromSInt64Array, - (int64_t *, size_t)); - LLDB_REGISTER_METHOD(bool, SBData, SetDataFromSInt32Array, - (int32_t *, size_t)); - LLDB_REGISTER_METHOD(bool, SBData, SetDataFromDoubleArray, - (double *, size_t)); -} - -} -} diff --git a/lldb/source/API/SBDebugger.cpp b/lldb/source/API/SBDebugger.cpp index fa5dcb57de7e..8b09d6a8e435 100644 --- a/lldb/source/API/SBDebugger.cpp +++ b/lldb/source/API/SBDebugger.cpp @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#include "SBReproducerPrivate.h" #include "SystemInitializerFull.h" +#include "lldb/Utility/Instrumentation.h" #include "lldb/API/SBDebugger.h" @@ -105,53 +105,43 @@ SBError SBInputReader::Initialize( unsigned long), void *a, lldb::InputReaderGranularity b, char const *c, char const *d, bool e) { - LLDB_RECORD_DUMMY( - lldb::SBError, SBInputReader, Initialize, - (lldb::SBDebugger &, - unsigned long (*)(void *, lldb::SBInputReader *, lldb::InputReaderAction, - const char *, unsigned long), - void *, lldb::InputReaderGranularity, const char *, const char *, bool), - sb_debugger, callback, a, b, c, d, e); + LLDB_INSTRUMENT_VA(this, sb_debugger, callback, a, b, c, d, e); return SBError(); } -void SBInputReader::SetIsDone(bool b) { - LLDB_RECORD_METHOD(void, SBInputReader, SetIsDone, (bool), b); -} +void SBInputReader::SetIsDone(bool b) { LLDB_INSTRUMENT_VA(this, b); } bool SBInputReader::IsActive() const { - LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBInputReader, IsActive); + LLDB_INSTRUMENT_VA(this); return false; } -SBDebugger::SBDebugger() { LLDB_RECORD_CONSTRUCTOR_NO_ARGS(SBDebugger); } +SBDebugger::SBDebugger() { LLDB_INSTRUMENT_VA(this); } SBDebugger::SBDebugger(const lldb::DebuggerSP &debugger_sp) : m_opaque_sp(debugger_sp) { - LLDB_RECORD_CONSTRUCTOR(SBDebugger, (const lldb::DebuggerSP &), debugger_sp); + LLDB_INSTRUMENT_VA(this, debugger_sp); } SBDebugger::SBDebugger(const SBDebugger &rhs) : m_opaque_sp(rhs.m_opaque_sp) { - LLDB_RECORD_CONSTRUCTOR(SBDebugger, (const lldb::SBDebugger &), rhs); + LLDB_INSTRUMENT_VA(this, rhs); } SBDebugger::~SBDebugger() = default; SBDebugger &SBDebugger::operator=(const SBDebugger &rhs) { - LLDB_RECORD_METHOD(lldb::SBDebugger &, - SBDebugger, operator=,(const lldb::SBDebugger &), rhs); + LLDB_INSTRUMENT_VA(this, rhs); if (this != &rhs) { m_opaque_sp = rhs.m_opaque_sp; } - return LLDB_RECORD_RESULT(*this); + return *this; } const char *SBDebugger::GetBroadcasterClass() { - LLDB_RECORD_STATIC_METHOD_NO_ARGS(const char *, SBDebugger, - GetBroadcasterClass); + LLDB_INSTRUMENT(); return Debugger::GetStaticBroadcasterClass().AsCString(); } @@ -161,6 +151,8 @@ const char *SBDebugger::GetProgressFromEvent(const lldb::SBEvent &event, uint64_t &completed, uint64_t &total, bool &is_debugger_specific) { + LLDB_INSTRUMENT_VA(event, progress_id, completed, total, + is_debugger_specific); const Debugger::ProgressEventData *progress_data = Debugger::ProgressEventData::GetEventDataFromEvent(event.get()); if (progress_data == nullptr) @@ -169,46 +161,39 @@ const char *SBDebugger::GetProgressFromEvent(const lldb::SBEvent &event, completed = progress_data->GetCompleted(); total = progress_data->GetTotal(); is_debugger_specific = progress_data->IsDebuggerSpecific(); - // We must record the static method _after_ the out parameters have been - // filled in. - LLDB_RECORD_STATIC_METHOD( - const char *, SBDebugger, GetProgressFromEvent, - (const lldb::SBEvent &, uint64_t &, uint64_t &, uint64_t &, bool &), - event, progress_id, completed, total, is_debugger_specific); - return LLDB_RECORD_RESULT(progress_data->GetMessage().c_str()) + return progress_data->GetMessage().c_str(); } SBBroadcaster SBDebugger::GetBroadcaster() { - LLDB_RECORD_METHOD_NO_ARGS(lldb::SBBroadcaster, SBDebugger, GetBroadcaster); + LLDB_INSTRUMENT_VA(this); SBBroadcaster broadcaster(&m_opaque_sp->GetBroadcaster(), false); - return LLDB_RECORD_RESULT(broadcaster); + return broadcaster; } void SBDebugger::Initialize() { - LLDB_RECORD_STATIC_METHOD_NO_ARGS(void, SBDebugger, Initialize); + LLDB_INSTRUMENT(); SBError ignored = SBDebugger::InitializeWithErrorHandling(); } lldb::SBError SBDebugger::InitializeWithErrorHandling() { - LLDB_RECORD_STATIC_METHOD_NO_ARGS(lldb::SBError, SBDebugger, - InitializeWithErrorHandling); + LLDB_INSTRUMENT(); SBError error; if (auto e = g_debugger_lifetime->Initialize( std::make_unique<SystemInitializerFull>(), LoadPlugin)) { error.SetError(Status(std::move(e))); } - return LLDB_RECORD_RESULT(error); + return error; } void SBDebugger::Terminate() { - LLDB_RECORD_STATIC_METHOD_NO_ARGS(void, SBDebugger, Terminate); + LLDB_INSTRUMENT(); g_debugger_lifetime->Terminate(); } void SBDebugger::Clear() { - LLDB_RECORD_METHOD_NO_ARGS(void, SBDebugger, Clear); + LLDB_INSTRUMENT_VA(this); if (m_opaque_sp) m_opaque_sp->ClearIOHandlers(); @@ -217,26 +202,22 @@ void SBDebugger::Clear() { } SBDebugger SBDebugger::Create() { - LLDB_RECORD_STATIC_METHOD_NO_ARGS(lldb::SBDebugger, SBDebugger, Create); + LLDB_INSTRUMENT(); - return LLDB_RECORD_RESULT(SBDebugger::Create(false, nullptr, nullptr)); + return SBDebugger::Create(false, nullptr, nullptr); } SBDebugger SBDebugger::Create(bool source_init_files) { - LLDB_RECORD_STATIC_METHOD(lldb::SBDebugger, SBDebugger, Create, (bool), - source_init_files); + LLDB_INSTRUMENT_VA(source_init_files); - return LLDB_RECORD_RESULT( - SBDebugger::Create(source_init_files, nullptr, nullptr)); + return SBDebugger::Create(source_init_files, nullptr, nullptr); } SBDebugger SBDebugger::Create(bool source_init_files, lldb::LogOutputCallback callback, void *baton) { - LLDB_RECORD_DUMMY(lldb::SBDebugger, SBDebugger, Create, - (bool, lldb::LogOutputCallback, void *), source_init_files, - callback, baton); + LLDB_INSTRUMENT_VA(source_init_files, callback, baton); SBDebugger debugger; @@ -264,8 +245,7 @@ SBDebugger SBDebugger::Create(bool source_init_files, } void SBDebugger::Destroy(SBDebugger &debugger) { - LLDB_RECORD_STATIC_METHOD(void, SBDebugger, Destroy, (lldb::SBDebugger &), - debugger); + LLDB_INSTRUMENT_VA(debugger); Debugger::Destroy(debugger.m_opaque_sp); @@ -274,7 +254,7 @@ void SBDebugger::Destroy(SBDebugger &debugger) { } void SBDebugger::MemoryPressureDetected() { - LLDB_RECORD_STATIC_METHOD_NO_ARGS(void, SBDebugger, MemoryPressureDetected); + LLDB_INSTRUMENT(); // Since this function can be call asynchronously, we allow it to be non- // mandatory. We have seen deadlocks with this function when called so we @@ -287,226 +267,222 @@ void SBDebugger::MemoryPressureDetected() { } bool SBDebugger::IsValid() const { - LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBDebugger, IsValid); + LLDB_INSTRUMENT_VA(this); return this->operator bool(); } SBDebugger::operator bool() const { - LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBDebugger, operator bool); + LLDB_INSTRUMENT_VA(this); return m_opaque_sp.get() != nullptr; } void SBDebugger::SetAsync(bool b) { - LLDB_RECORD_METHOD(void, SBDebugger, SetAsync, (bool), b); + LLDB_INSTRUMENT_VA(this, b); if (m_opaque_sp) m_opaque_sp->SetAsyncExecution(b); } bool SBDebugger::GetAsync() { - LLDB_RECORD_METHOD_NO_ARGS(bool, SBDebugger, GetAsync); + LLDB_INSTRUMENT_VA(this); return (m_opaque_sp ? m_opaque_sp->GetAsyncExecution() : false); } void SBDebugger::SkipLLDBInitFiles(bool b) { - LLDB_RECORD_METHOD(void, SBDebugger, SkipLLDBInitFiles, (bool), b); + LLDB_INSTRUMENT_VA(this, b); if (m_opaque_sp) m_opaque_sp->GetCommandInterpreter().SkipLLDBInitFiles(b); } void SBDebugger::SkipAppInitFiles(bool b) { - LLDB_RECORD_METHOD(void, SBDebugger, SkipAppInitFiles, (bool), b); + LLDB_INSTRUMENT_VA(this, b); if (m_opaque_sp) m_opaque_sp->GetCommandInterpreter().SkipAppInitFiles(b); } void SBDebugger::SetInputFileHandle(FILE *fh, bool transfer_ownership) { - LLDB_RECORD_METHOD(void, SBDebugger, SetInputFileHandle, (FILE *, bool), fh, - transfer_ownership); + LLDB_INSTRUMENT_VA(this, fh, transfer_ownership); if (m_opaque_sp) m_opaque_sp->SetInputFile( (FileSP)std::make_shared<NativeFile>(fh, transfer_ownership)); } SBError SBDebugger::SetInputString(const char *data) { - LLDB_RECORD_METHOD(SBError, SBDebugger, SetInputString, (const char *), data); + LLDB_INSTRUMENT_VA(this, data); SBError sb_error; if (data == nullptr) { sb_error.SetErrorString("String data is null"); - return LLDB_RECORD_RESULT(sb_error); + return sb_error; } size_t size = strlen(data); if (size == 0) { sb_error.SetErrorString("String data is empty"); - return LLDB_RECORD_RESULT(sb_error); + return sb_error; } if (!m_opaque_sp) { sb_error.SetErrorString("invalid debugger"); - return LLDB_RECORD_RESULT(sb_error); + return sb_error; } sb_error.SetError(m_opaque_sp->SetInputString(data)); - return LLDB_RECORD_RESULT(sb_error); + return sb_error; } // Shouldn't really be settable after initialization as this could cause lots // of problems; don't want users trying to switch modes in the middle of a // debugging session. SBError SBDebugger::SetInputFile(SBFile file) { - LLDB_RECORD_METHOD(SBError, SBDebugger, SetInputFile, (SBFile), file); + LLDB_INSTRUMENT_VA(this, file); SBError error; if (!m_opaque_sp) { error.ref().SetErrorString("invalid debugger"); - return LLDB_RECORD_RESULT(error); + return error; } error.SetError(m_opaque_sp->SetInputFile(file.m_opaque_sp)); - return LLDB_RECORD_RESULT(error); + return error; } SBError SBDebugger::SetInputFile(FileSP file_sp) { - LLDB_RECORD_METHOD(SBError, SBDebugger, SetInputFile, (FileSP), file_sp); - return LLDB_RECORD_RESULT(SetInputFile(SBFile(file_sp))); + LLDB_INSTRUMENT_VA(this, file_sp); + return SetInputFile(SBFile(file_sp)); } SBError SBDebugger::SetOutputFile(FileSP file_sp) { - LLDB_RECORD_METHOD(SBError, SBDebugger, SetOutputFile, (FileSP), file_sp); - return LLDB_RECORD_RESULT(SetOutputFile(SBFile(file_sp))); + LLDB_INSTRUMENT_VA(this, file_sp); + return SetOutputFile(SBFile(file_sp)); } void SBDebugger::SetOutputFileHandle(FILE *fh, bool transfer_ownership) { - LLDB_RECORD_METHOD(void, SBDebugger, SetOutputFileHandle, (FILE *, bool), fh, - transfer_ownership); + LLDB_INSTRUMENT_VA(this, fh, transfer_ownership); SetOutputFile((FileSP)std::make_shared<NativeFile>(fh, transfer_ownership)); } SBError SBDebugger::SetOutputFile(SBFile file) { - LLDB_RECORD_METHOD(SBError, SBDebugger, SetOutputFile, (SBFile file), file); + LLDB_INSTRUMENT_VA(this, file); SBError error; if (!m_opaque_sp) { error.ref().SetErrorString("invalid debugger"); - return LLDB_RECORD_RESULT(error); + return error; } if (!file) { error.ref().SetErrorString("invalid file"); - return LLDB_RECORD_RESULT(error); + return error; } m_opaque_sp->SetOutputFile(file.m_opaque_sp); - return LLDB_RECORD_RESULT(error); + return error; } void SBDebugger::SetErrorFileHandle(FILE *fh, bool transfer_ownership) { - LLDB_RECORD_METHOD(void, SBDebugger, SetErrorFileHandle, (FILE *, bool), fh, - transfer_ownership); + LLDB_INSTRUMENT_VA(this, fh, transfer_ownership); SetErrorFile((FileSP)std::make_shared<NativeFile>(fh, transfer_ownership)); } SBError SBDebugger::SetErrorFile(FileSP file_sp) { - LLDB_RECORD_METHOD(SBError, SBDebugger, SetErrorFile, (FileSP), file_sp); - return LLDB_RECORD_RESULT(SetErrorFile(SBFile(file_sp))); + LLDB_INSTRUMENT_VA(this, file_sp); + return SetErrorFile(SBFile(file_sp)); } SBError SBDebugger::SetErrorFile(SBFile file) { - LLDB_RECORD_METHOD(SBError, SBDebugger, SetErrorFile, (SBFile file), file); + LLDB_INSTRUMENT_VA(this, file); SBError error; if (!m_opaque_sp) { error.ref().SetErrorString("invalid debugger"); - return LLDB_RECORD_RESULT(error); + return error; } if (!file) { error.ref().SetErrorString("invalid file"); - return LLDB_RECORD_RESULT(error); + return error; } m_opaque_sp->SetErrorFile(file.m_opaque_sp); - return LLDB_RECORD_RESULT(error); + return error; } FILE *SBDebugger::GetInputFileHandle() { - LLDB_RECORD_METHOD_NO_ARGS(FILE *, SBDebugger, GetInputFileHandle); + LLDB_INSTRUMENT_VA(this); if (m_opaque_sp) { File &file_sp = m_opaque_sp->GetInputFile(); - return LLDB_RECORD_RESULT(file_sp.GetStream()); + return file_sp.GetStream(); } - return LLDB_RECORD_RESULT(nullptr); + return nullptr; } SBFile SBDebugger::GetInputFile() { - LLDB_RECORD_METHOD_NO_ARGS(SBFile, SBDebugger, GetInputFile); + LLDB_INSTRUMENT_VA(this); if (m_opaque_sp) { - return LLDB_RECORD_RESULT(SBFile(m_opaque_sp->GetInputFileSP())); + return SBFile(m_opaque_sp->GetInputFileSP()); } - return LLDB_RECORD_RESULT(SBFile()); + return SBFile(); } FILE *SBDebugger::GetOutputFileHandle() { - LLDB_RECORD_METHOD_NO_ARGS(FILE *, SBDebugger, GetOutputFileHandle); + LLDB_INSTRUMENT_VA(this); if (m_opaque_sp) { StreamFile &stream_file = m_opaque_sp->GetOutputStream(); - return LLDB_RECORD_RESULT(stream_file.GetFile().GetStream()); + return stream_file.GetFile().GetStream(); } - return LLDB_RECORD_RESULT(nullptr); + return nullptr; } SBFile SBDebugger::GetOutputFile() { - LLDB_RECORD_METHOD_NO_ARGS(SBFile, SBDebugger, GetOutputFile); + LLDB_INSTRUMENT_VA(this); if (m_opaque_sp) { SBFile file(m_opaque_sp->GetOutputStream().GetFileSP()); - return LLDB_RECORD_RESULT(file); + return file; } - return LLDB_RECORD_RESULT(SBFile()); + return SBFile(); } FILE *SBDebugger::GetErrorFileHandle() { - LLDB_RECORD_METHOD_NO_ARGS(FILE *, SBDebugger, GetErrorFileHandle); + LLDB_INSTRUMENT_VA(this); if (m_opaque_sp) { StreamFile &stream_file = m_opaque_sp->GetErrorStream(); - return LLDB_RECORD_RESULT(stream_file.GetFile().GetStream()); + return stream_file.GetFile().GetStream(); } - return LLDB_RECORD_RESULT(nullptr); + return nullptr; } SBFile SBDebugger::GetErrorFile() { - LLDB_RECORD_METHOD_NO_ARGS(SBFile, SBDebugger, GetErrorFile); + LLDB_INSTRUMENT_VA(this); SBFile file; if (m_opaque_sp) { SBFile file(m_opaque_sp->GetErrorStream().GetFileSP()); - return LLDB_RECORD_RESULT(file); + return file; } - return LLDB_RECORD_RESULT(SBFile()); + return SBFile(); } void SBDebugger::SaveInputTerminalState() { - LLDB_RECORD_DUMMY_NO_ARGS(void, SBDebugger, SaveInputTerminalState); + LLDB_INSTRUMENT_VA(this); if (m_opaque_sp) m_opaque_sp->SaveInputTerminalState(); } void SBDebugger::RestoreInputTerminalState() { - LLDB_RECORD_DUMMY_NO_ARGS(void, SBDebugger, RestoreInputTerminalState); + LLDB_INSTRUMENT_VA(this); if (m_opaque_sp) m_opaque_sp->RestoreInputTerminalState(); } SBCommandInterpreter SBDebugger::GetCommandInterpreter() { - LLDB_RECORD_METHOD_NO_ARGS(lldb::SBCommandInterpreter, SBDebugger, - GetCommandInterpreter); + LLDB_INSTRUMENT_VA(this); SBCommandInterpreter sb_interpreter; if (m_opaque_sp) sb_interpreter.reset(&m_opaque_sp->GetCommandInterpreter()); - return LLDB_RECORD_RESULT(sb_interpreter); + return sb_interpreter; } void SBDebugger::HandleCommand(const char *command) { - LLDB_RECORD_METHOD(void, SBDebugger, HandleCommand, (const char *), command); + LLDB_INSTRUMENT_VA(this, command); if (m_opaque_sp) { TargetSP target_sp(m_opaque_sp->GetSelectedTarget()); @@ -539,22 +515,19 @@ void SBDebugger::HandleCommand(const char *command) { } SBListener SBDebugger::GetListener() { - LLDB_RECORD_METHOD_NO_ARGS(lldb::SBListener, SBDebugger, GetListener); + LLDB_INSTRUMENT_VA(this); SBListener sb_listener; if (m_opaque_sp) sb_listener.reset(m_opaque_sp->GetListener()); - return LLDB_RECORD_RESULT(sb_listener); + return sb_listener; } void SBDebugger::HandleProcessEvent(const SBProcess &process, const SBEvent &event, SBFile out, SBFile err) { - LLDB_RECORD_METHOD( - void, SBDebugger, HandleProcessEvent, - (const lldb::SBProcess &, const lldb::SBEvent &, SBFile, SBFile), process, - event, out, err); + LLDB_INSTRUMENT_VA(this, process, event, out, err); return HandleProcessEvent(process, event, out.m_opaque_sp, err.m_opaque_sp); } @@ -562,10 +535,7 @@ void SBDebugger::HandleProcessEvent(const SBProcess &process, void SBDebugger::HandleProcessEvent(const SBProcess &process, const SBEvent &event, FILE *out, FILE *err) { - LLDB_RECORD_METHOD( - void, SBDebugger, HandleProcessEvent, - (const lldb::SBProcess &, const lldb::SBEvent &, FILE *, FILE *), process, - event, out, err); + LLDB_INSTRUMENT_VA(this, process, event, out, err); FileSP outfile = std::make_shared<NativeFile>(out, false); FileSP errfile = std::make_shared<NativeFile>(err, false); @@ -576,10 +546,7 @@ void SBDebugger::HandleProcessEvent(const SBProcess &process, const SBEvent &event, FileSP out_sp, FileSP err_sp) { - LLDB_RECORD_METHOD( - void, SBDebugger, HandleProcessEvent, - (const lldb::SBProcess &, const lldb::SBEvent &, FileSP, FileSP), process, - event, out_sp, err_sp); + LLDB_INSTRUMENT_VA(this, process, event, out_sp, err_sp); if (!process.IsValid()) return; @@ -623,17 +590,14 @@ void SBDebugger::HandleProcessEvent(const SBProcess &process, } SBSourceManager SBDebugger::GetSourceManager() { - LLDB_RECORD_METHOD_NO_ARGS(lldb::SBSourceManager, SBDebugger, - GetSourceManager); + LLDB_INSTRUMENT_VA(this); SBSourceManager sb_source_manager(*this); - return LLDB_RECORD_RESULT(sb_source_manager); + return sb_source_manager; } bool SBDebugger::GetDefaultArchitecture(char *arch_name, size_t arch_name_len) { - LLDB_RECORD_CHAR_PTR_STATIC_METHOD(bool, SBDebugger, GetDefaultArchitecture, - (char *, size_t), arch_name, "", - arch_name_len); + LLDB_INSTRUMENT_VA(arch_name, arch_name_len); if (arch_name && arch_name_len) { ArchSpec default_arch = Target::GetDefaultArchitecture(); @@ -654,8 +618,7 @@ bool SBDebugger::GetDefaultArchitecture(char *arch_name, size_t arch_name_len) { } bool SBDebugger::SetDefaultArchitecture(const char *arch_name) { - LLDB_RECORD_STATIC_METHOD(bool, SBDebugger, SetDefaultArchitecture, - (const char *), arch_name); + LLDB_INSTRUMENT_VA(arch_name); if (arch_name) { ArchSpec arch(arch_name); @@ -669,8 +632,7 @@ bool SBDebugger::SetDefaultArchitecture(const char *arch_name) { ScriptLanguage SBDebugger::GetScriptingLanguage(const char *script_language_name) { - LLDB_RECORD_METHOD(lldb::ScriptLanguage, SBDebugger, GetScriptingLanguage, - (const char *), script_language_name); + LLDB_INSTRUMENT_VA(this, script_language_name); if (!script_language_name) return eScriptLanguageDefault; @@ -680,8 +642,7 @@ SBDebugger::GetScriptingLanguage(const char *script_language_name) { SBStructuredData SBDebugger::GetScriptInterpreterInfo(lldb::ScriptLanguage language) { - LLDB_RECORD_METHOD(SBStructuredData, SBDebugger, GetScriptInterpreterInfo, - (lldb::ScriptLanguage), language); + LLDB_INSTRUMENT_VA(this, language); SBStructuredData data; if (m_opaque_sp) { lldb_private::ScriptInterpreter *interp = @@ -690,18 +651,17 @@ SBDebugger::GetScriptInterpreterInfo(lldb::ScriptLanguage language) { data.m_impl_up->SetObjectSP(interp->GetInterpreterInfo()); } } - return LLDB_RECORD_RESULT(data); + return data; } const char *SBDebugger::GetVersionString() { - LLDB_RECORD_STATIC_METHOD_NO_ARGS(const char *, SBDebugger, GetVersionString); + LLDB_INSTRUMENT(); return lldb_private::GetVersion(); } const char *SBDebugger::StateAsCString(StateType state) { - LLDB_RECORD_STATIC_METHOD(const char *, SBDebugger, StateAsCString, - (lldb::StateType), state); + LLDB_INSTRUMENT_VA(state); return lldb_private::StateAsCString(state); } @@ -727,8 +687,7 @@ static void AddLLVMTargets(StructuredData::Dictionary &dict) { } SBStructuredData SBDebugger::GetBuildConfiguration() { - LLDB_RECORD_STATIC_METHOD_NO_ARGS(lldb::SBStructuredData, SBDebugger, - GetBuildConfiguration); + LLDB_INSTRUMENT(); auto config_up = std::make_unique<StructuredData::Dictionary>(); AddBoolConfigEntry( @@ -756,12 +715,11 @@ SBStructuredData SBDebugger::GetBuildConfiguration() { SBStructuredData data; data.m_impl_up->SetObjectSP(std::move(config_up)); - return LLDB_RECORD_RESULT(data); + return data; } bool SBDebugger::StateIsRunningState(StateType state) { - LLDB_RECORD_STATIC_METHOD(bool, SBDebugger, StateIsRunningState, - (lldb::StateType), state); + LLDB_INSTRUMENT_VA(state); const bool result = lldb_private::StateIsRunningState(state); @@ -769,8 +727,7 @@ bool SBDebugger::StateIsRunningState(StateType state) { } bool SBDebugger::StateIsStoppedState(StateType state) { - LLDB_RECORD_STATIC_METHOD(bool, SBDebugger, StateIsStoppedState, - (lldb::StateType), state); + LLDB_INSTRUMENT_VA(state); const bool result = lldb_private::StateIsStoppedState(state, false); @@ -782,10 +739,8 @@ lldb::SBTarget SBDebugger::CreateTarget(const char *filename, const char *platform_name, bool add_dependent_modules, lldb::SBError &sb_error) { - LLDB_RECORD_METHOD( - lldb::SBTarget, SBDebugger, CreateTarget, - (const char *, const char *, const char *, bool, lldb::SBError &), - filename, target_triple, platform_name, add_dependent_modules, sb_error); + LLDB_INSTRUMENT_VA(this, filename, target_triple, platform_name, + add_dependent_modules, sb_error); SBTarget sb_target; TargetSP target_sp; @@ -814,15 +769,13 @@ lldb::SBTarget SBDebugger::CreateTarget(const char *filename, platform_name, add_dependent_modules, sb_error.GetCString(), static_cast<void *>(target_sp.get())); - return LLDB_RECORD_RESULT(sb_target); + return sb_target; } SBTarget SBDebugger::CreateTargetWithFileAndTargetTriple(const char *filename, const char *target_triple) { - LLDB_RECORD_METHOD(lldb::SBTarget, SBDebugger, - CreateTargetWithFileAndTargetTriple, - (const char *, const char *), filename, target_triple); + LLDB_INSTRUMENT_VA(this, filename, target_triple); SBTarget sb_target; TargetSP target_sp; @@ -842,13 +795,12 @@ SBDebugger::CreateTargetWithFileAndTargetTriple(const char *filename, static_cast<void *>(m_opaque_sp.get()), filename, target_triple, static_cast<void *>(target_sp.get())); - return LLDB_RECORD_RESULT(sb_target); + return sb_target; } SBTarget SBDebugger::CreateTargetWithFileAndArch(const char *filename, const char *arch_cstr) { - LLDB_RECORD_METHOD(lldb::SBTarget, SBDebugger, CreateTargetWithFileAndArch, - (const char *, const char *), filename, arch_cstr); + LLDB_INSTRUMENT_VA(this, filename, arch_cstr); Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); @@ -860,16 +812,18 @@ SBTarget SBDebugger::CreateTargetWithFileAndArch(const char *filename, // The version of CreateTarget that takes an ArchSpec won't accept an // empty ArchSpec, so when the arch hasn't been specified, we need to // call the target triple version. - error = m_opaque_sp->GetTargetList().CreateTarget(*m_opaque_sp, filename, - arch_cstr, eLoadDependentsYes, nullptr, target_sp); + error = m_opaque_sp->GetTargetList().CreateTarget( + *m_opaque_sp, filename, arch_cstr, eLoadDependentsYes, nullptr, + target_sp); } else { - PlatformSP platform_sp = m_opaque_sp->GetPlatformList() - .GetSelectedPlatform(); - ArchSpec arch = Platform::GetAugmentedArchSpec(platform_sp.get(), - arch_cstr); + PlatformSP platform_sp = + m_opaque_sp->GetPlatformList().GetSelectedPlatform(); + ArchSpec arch = + Platform::GetAugmentedArchSpec(platform_sp.get(), arch_cstr); if (arch.IsValid()) - error = m_opaque_sp->GetTargetList().CreateTarget(*m_opaque_sp, filename, - arch, eLoadDependentsYes, platform_sp, target_sp); + error = m_opaque_sp->GetTargetList().CreateTarget( + *m_opaque_sp, filename, arch, eLoadDependentsYes, platform_sp, + target_sp); else error.SetErrorStringWithFormat("invalid arch_cstr: %s", arch_cstr); } @@ -885,12 +839,11 @@ SBTarget SBDebugger::CreateTargetWithFileAndArch(const char *filename, arch_cstr ? arch_cstr : "<unspecified>", static_cast<void *>(target_sp.get())); - return LLDB_RECORD_RESULT(sb_target); + return sb_target; } SBTarget SBDebugger::CreateTarget(const char *filename) { - LLDB_RECORD_METHOD(lldb::SBTarget, SBDebugger, CreateTarget, (const char *), - filename); + LLDB_INSTRUMENT_VA(this, filename); SBTarget sb_target; TargetSP target_sp; @@ -910,11 +863,11 @@ SBTarget SBDebugger::CreateTarget(const char *filename) { "SBDebugger(%p)::CreateTarget (filename=\"%s\") => SBTarget(%p)", static_cast<void *>(m_opaque_sp.get()), filename, static_cast<void *>(target_sp.get())); - return LLDB_RECORD_RESULT(sb_target); + return sb_target; } SBTarget SBDebugger::GetDummyTarget() { - LLDB_RECORD_METHOD_NO_ARGS(lldb::SBTarget, SBDebugger, GetDummyTarget); + LLDB_INSTRUMENT_VA(this); SBTarget sb_target; if (m_opaque_sp) { @@ -924,12 +877,11 @@ SBTarget SBDebugger::GetDummyTarget() { LLDB_LOGF(log, "SBDebugger(%p)::GetDummyTarget() => SBTarget(%p)", static_cast<void *>(m_opaque_sp.get()), static_cast<void *>(sb_target.GetSP().get())); - return LLDB_RECORD_RESULT(sb_target); + return sb_target; } bool SBDebugger::DeleteTarget(lldb::SBTarget &target) { - LLDB_RECORD_METHOD(bool, SBDebugger, DeleteTarget, (lldb::SBTarget &), - target); + LLDB_INSTRUMENT_VA(this, target); bool result = false; if (m_opaque_sp) { @@ -951,20 +903,18 @@ bool SBDebugger::DeleteTarget(lldb::SBTarget &target) { } SBTarget SBDebugger::GetTargetAtIndex(uint32_t idx) { - LLDB_RECORD_METHOD(lldb::SBTarget, SBDebugger, GetTargetAtIndex, (uint32_t), - idx); + LLDB_INSTRUMENT_VA(this, idx); SBTarget sb_target; if (m_opaque_sp) { // No need to lock, the target list is thread safe sb_target.SetSP(m_opaque_sp->GetTargetList().GetTargetAtIndex(idx)); } - return LLDB_RECORD_RESULT(sb_target); + return sb_target; } uint32_t SBDebugger::GetIndexOfTarget(lldb::SBTarget target) { - LLDB_RECORD_METHOD(uint32_t, SBDebugger, GetIndexOfTarget, (lldb::SBTarget), - target); + LLDB_INSTRUMENT_VA(this, target); lldb::TargetSP target_sp = target.GetSP(); if (!target_sp) @@ -977,21 +927,19 @@ uint32_t SBDebugger::GetIndexOfTarget(lldb::SBTarget target) { } SBTarget SBDebugger::FindTargetWithProcessID(lldb::pid_t pid) { - LLDB_RECORD_METHOD(lldb::SBTarget, SBDebugger, FindTargetWithProcessID, - (lldb::pid_t), pid); + LLDB_INSTRUMENT_VA(this, pid); SBTarget sb_target; if (m_opaque_sp) { // No need to lock, the target list is thread safe sb_target.SetSP(m_opaque_sp->GetTargetList().FindTargetWithProcessID(pid)); } - return LLDB_RECORD_RESULT(sb_target); + return sb_target; } SBTarget SBDebugger::FindTargetWithFileAndArch(const char *filename, const char *arch_name) { - LLDB_RECORD_METHOD(lldb::SBTarget, SBDebugger, FindTargetWithFileAndArch, - (const char *, const char *), filename, arch_name); + LLDB_INSTRUMENT_VA(this, filename, arch_name); SBTarget sb_target; if (m_opaque_sp && filename && filename[0]) { @@ -1003,7 +951,7 @@ SBTarget SBDebugger::FindTargetWithFileAndArch(const char *filename, FileSpec(filename), arch_name ? &arch : nullptr)); sb_target.SetSP(target_sp); } - return LLDB_RECORD_RESULT(sb_target); + return sb_target; } SBTarget SBDebugger::FindTargetWithLLDBProcess(const ProcessSP &process_sp) { @@ -1017,7 +965,7 @@ SBTarget SBDebugger::FindTargetWithLLDBProcess(const ProcessSP &process_sp) { } uint32_t SBDebugger::GetNumTargets() { - LLDB_RECORD_METHOD_NO_ARGS(uint32_t, SBDebugger, GetNumTargets); + LLDB_INSTRUMENT_VA(this); if (m_opaque_sp) { // No need to lock, the target list is thread safe @@ -1027,7 +975,7 @@ uint32_t SBDebugger::GetNumTargets() { } SBTarget SBDebugger::GetSelectedTarget() { - LLDB_RECORD_METHOD_NO_ARGS(lldb::SBTarget, SBDebugger, GetSelectedTarget); + LLDB_INSTRUMENT_VA(this); Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); @@ -1047,12 +995,11 @@ SBTarget SBDebugger::GetSelectedTarget() { static_cast<void *>(target_sp.get()), sstr.GetData()); } - return LLDB_RECORD_RESULT(sb_target); + return sb_target; } void SBDebugger::SetSelectedTarget(SBTarget &sb_target) { - LLDB_RECORD_METHOD(void, SBDebugger, SetSelectedTarget, (lldb::SBTarget &), - sb_target); + LLDB_INSTRUMENT_VA(this, sb_target); Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); @@ -1070,7 +1017,7 @@ void SBDebugger::SetSelectedTarget(SBTarget &sb_target) { } SBPlatform SBDebugger::GetSelectedPlatform() { - LLDB_RECORD_METHOD_NO_ARGS(lldb::SBPlatform, SBDebugger, GetSelectedPlatform); + LLDB_INSTRUMENT_VA(this); Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); @@ -1083,12 +1030,11 @@ SBPlatform SBDebugger::GetSelectedPlatform() { static_cast<void *>(m_opaque_sp.get()), static_cast<void *>(sb_platform.GetSP().get()), sb_platform.GetName()); - return LLDB_RECORD_RESULT(sb_platform); + return sb_platform; } void SBDebugger::SetSelectedPlatform(SBPlatform &sb_platform) { - LLDB_RECORD_METHOD(void, SBDebugger, SetSelectedPlatform, - (lldb::SBPlatform &), sb_platform); + LLDB_INSTRUMENT_VA(this, sb_platform); Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); @@ -1104,7 +1050,7 @@ void SBDebugger::SetSelectedPlatform(SBPlatform &sb_platform) { } uint32_t SBDebugger::GetNumPlatforms() { - LLDB_RECORD_METHOD_NO_ARGS(uint32_t, SBDebugger, GetNumPlatforms); + LLDB_INSTRUMENT_VA(this); if (m_opaque_sp) { // No need to lock, the platform list is thread safe @@ -1114,19 +1060,18 @@ uint32_t SBDebugger::GetNumPlatforms() { } SBPlatform SBDebugger::GetPlatformAtIndex(uint32_t idx) { - LLDB_RECORD_METHOD(lldb::SBPlatform, SBDebugger, GetPlatformAtIndex, - (uint32_t), idx); + LLDB_INSTRUMENT_VA(this, idx); SBPlatform sb_platform; if (m_opaque_sp) { // No need to lock, the platform list is thread safe sb_platform.SetSP(m_opaque_sp->GetPlatformList().GetAtIndex(idx)); } - return LLDB_RECORD_RESULT(sb_platform); + return sb_platform; } uint32_t SBDebugger::GetNumAvailablePlatforms() { - LLDB_RECORD_METHOD_NO_ARGS(uint32_t, SBDebugger, GetNumAvailablePlatforms); + LLDB_INSTRUMENT_VA(this); uint32_t idx = 0; while (true) { @@ -1140,8 +1085,7 @@ uint32_t SBDebugger::GetNumAvailablePlatforms() { } SBStructuredData SBDebugger::GetAvailablePlatformInfoAtIndex(uint32_t idx) { - LLDB_RECORD_METHOD(lldb::SBStructuredData, SBDebugger, - GetAvailablePlatformInfoAtIndex, (uint32_t), idx); + LLDB_INSTRUMENT_VA(this, idx); SBStructuredData data; auto platform_dict = std::make_unique<StructuredData::Dictionary>(); @@ -1156,7 +1100,7 @@ SBStructuredData SBDebugger::GetAvailablePlatformInfoAtIndex(uint32_t idx) { llvm::StringRef plugin_name = PluginManager::GetPlatformPluginNameAtIndex(idx - 1); if (plugin_name.empty()) { - return LLDB_RECORD_RESULT(data); + return data; } platform_dict->AddStringItem(name_str, llvm::StringRef(plugin_name)); @@ -1167,19 +1111,17 @@ SBStructuredData SBDebugger::GetAvailablePlatformInfoAtIndex(uint32_t idx) { data.m_impl_up->SetObjectSP( StructuredData::ObjectSP(platform_dict.release())); - return LLDB_RECORD_RESULT(data); + return data; } void SBDebugger::DispatchInput(void *baton, const void *data, size_t data_len) { - LLDB_RECORD_DUMMY(void, SBDebugger, DispatchInput, - (void *, const void *, size_t), baton, data, data_len); + LLDB_INSTRUMENT_VA(this, baton, data, data_len); DispatchInput(data, data_len); } void SBDebugger::DispatchInput(const void *data, size_t data_len) { - LLDB_RECORD_DUMMY(void, SBDebugger, DispatchInput, (const void *, size_t), - data, data_len); + LLDB_INSTRUMENT_VA(this, data, data_len); // Log *log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); // @@ -1196,28 +1138,26 @@ void SBDebugger::DispatchInput(const void *data, size_t data_len) { } void SBDebugger::DispatchInputInterrupt() { - LLDB_RECORD_DUMMY_NO_ARGS(void, SBDebugger, DispatchInputInterrupt); + LLDB_INSTRUMENT_VA(this); if (m_opaque_sp) m_opaque_sp->DispatchInputInterrupt(); } void SBDebugger::DispatchInputEndOfFile() { - LLDB_RECORD_METHOD_NO_ARGS(void, SBDebugger, DispatchInputEndOfFile); + LLDB_INSTRUMENT_VA(this); if (m_opaque_sp) m_opaque_sp->DispatchInputEndOfFile(); } void SBDebugger::PushInputReader(SBInputReader &reader) { - LLDB_RECORD_METHOD(void, SBDebugger, PushInputReader, (lldb::SBInputReader &), - reader); + LLDB_INSTRUMENT_VA(this, reader); } void SBDebugger::RunCommandInterpreter(bool auto_handle_events, bool spawn_thread) { - LLDB_RECORD_METHOD(void, SBDebugger, RunCommandInterpreter, (bool, bool), - auto_handle_events, spawn_thread); + LLDB_INSTRUMENT_VA(this, auto_handle_events, spawn_thread); if (m_opaque_sp) { CommandInterpreterRunOptions options; @@ -1234,11 +1174,8 @@ void SBDebugger::RunCommandInterpreter(bool auto_handle_events, bool &stopped_for_crash) { - LLDB_RECORD_METHOD(void, SBDebugger, RunCommandInterpreter, - (bool, bool, lldb::SBCommandInterpreterRunOptions &, int &, - bool &, bool &), - auto_handle_events, spawn_thread, options, num_errors, - quit_requested, stopped_for_crash); + LLDB_INSTRUMENT_VA(this, auto_handle_events, spawn_thread, options, + num_errors, quit_requested, stopped_for_crash); if (m_opaque_sp) { options.SetAutoHandleEvents(auto_handle_events); @@ -1256,32 +1193,28 @@ void SBDebugger::RunCommandInterpreter(bool auto_handle_events, SBCommandInterpreterRunResult SBDebugger::RunCommandInterpreter( const SBCommandInterpreterRunOptions &options) { - LLDB_RECORD_METHOD(lldb::SBCommandInterpreterRunResult, SBDebugger, - RunCommandInterpreter, - (const lldb::SBCommandInterpreterRunOptions &), options); + LLDB_INSTRUMENT_VA(this, options); if (!m_opaque_sp) - return LLDB_RECORD_RESULT(SBCommandInterpreterRunResult()); + return SBCommandInterpreterRunResult(); CommandInterpreter &interp = m_opaque_sp->GetCommandInterpreter(); CommandInterpreterRunResult result = interp.RunCommandInterpreter(options.ref()); - return LLDB_RECORD_RESULT(SBCommandInterpreterRunResult(result)); + return SBCommandInterpreterRunResult(result); } SBError SBDebugger::RunREPL(lldb::LanguageType language, const char *repl_options) { - LLDB_RECORD_METHOD(lldb::SBError, SBDebugger, RunREPL, - (lldb::LanguageType, const char *), language, - repl_options); + LLDB_INSTRUMENT_VA(this, language, repl_options); SBError error; if (m_opaque_sp) error.ref() = m_opaque_sp->RunREPL(language, repl_options); else error.SetErrorString("invalid debugger"); - return LLDB_RECORD_RESULT(error); + return error; } void SBDebugger::reset(const DebuggerSP &debugger_sp) { @@ -1298,28 +1231,25 @@ Debugger &SBDebugger::ref() const { const lldb::DebuggerSP &SBDebugger::get_sp() const { return m_opaque_sp; } SBDebugger SBDebugger::FindDebuggerWithID(int id) { - LLDB_RECORD_STATIC_METHOD(lldb::SBDebugger, SBDebugger, FindDebuggerWithID, - (int), id); + LLDB_INSTRUMENT_VA(id); // No need to lock, the debugger list is thread safe SBDebugger sb_debugger; DebuggerSP debugger_sp = Debugger::FindDebuggerWithID(id); if (debugger_sp) sb_debugger.reset(debugger_sp); - return LLDB_RECORD_RESULT(sb_debugger); + return sb_debugger; } const char *SBDebugger::GetInstanceName() { - LLDB_RECORD_METHOD_NO_ARGS(const char *, SBDebugger, GetInstanceName); + LLDB_INSTRUMENT_VA(this); return (m_opaque_sp ? m_opaque_sp->GetInstanceName().AsCString() : nullptr); } SBError SBDebugger::SetInternalVariable(const char *var_name, const char *value, const char *debugger_instance_name) { - LLDB_RECORD_STATIC_METHOD(lldb::SBError, SBDebugger, SetInternalVariable, - (const char *, const char *, const char *), - var_name, value, debugger_instance_name); + LLDB_INSTRUMENT_VA(var_name, value, debugger_instance_name); SBError sb_error; DebuggerSP debugger_sp(Debugger::FindDebuggerWithInstanceName( @@ -1336,15 +1266,13 @@ SBError SBDebugger::SetInternalVariable(const char *var_name, const char *value, } if (error.Fail()) sb_error.SetError(error); - return LLDB_RECORD_RESULT(sb_error); + return sb_error; } SBStringList SBDebugger::GetInternalVariableValue(const char *var_name, const char *debugger_instance_name) { - LLDB_RECORD_STATIC_METHOD( - lldb::SBStringList, SBDebugger, GetInternalVariableValue, - (const char *, const char *), var_name, debugger_instance_name); + LLDB_INSTRUMENT_VA(var_name, debugger_instance_name); DebuggerSP debugger_sp(Debugger::FindDebuggerWithInstanceName( ConstString(debugger_instance_name))); @@ -1361,28 +1289,28 @@ SBDebugger::GetInternalVariableValue(const char *var_name, if (!value_str.empty()) { StringList string_list; string_list.SplitIntoLines(value_str); - return LLDB_RECORD_RESULT(SBStringList(&string_list)); + return SBStringList(&string_list); } } } - return LLDB_RECORD_RESULT(SBStringList()); + return SBStringList(); } uint32_t SBDebugger::GetTerminalWidth() const { - LLDB_RECORD_METHOD_CONST_NO_ARGS(uint32_t, SBDebugger, GetTerminalWidth); + LLDB_INSTRUMENT_VA(this); return (m_opaque_sp ? m_opaque_sp->GetTerminalWidth() : 0); } void SBDebugger::SetTerminalWidth(uint32_t term_width) { - LLDB_RECORD_DUMMY(void, SBDebugger, SetTerminalWidth, (uint32_t), term_width); + LLDB_INSTRUMENT_VA(this, term_width); if (m_opaque_sp) m_opaque_sp->SetTerminalWidth(term_width); } const char *SBDebugger::GetPrompt() const { - LLDB_RECORD_METHOD_CONST_NO_ARGS(const char *, SBDebugger, GetPrompt); + LLDB_INSTRUMENT_VA(this); Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); @@ -1395,14 +1323,14 @@ const char *SBDebugger::GetPrompt() const { } void SBDebugger::SetPrompt(const char *prompt) { - LLDB_RECORD_METHOD(void, SBDebugger, SetPrompt, (const char *), prompt); + LLDB_INSTRUMENT_VA(this, prompt); if (m_opaque_sp) m_opaque_sp->SetPrompt(llvm::StringRef(prompt)); } const char *SBDebugger::GetReproducerPath() const { - LLDB_RECORD_METHOD_CONST_NO_ARGS(const char *, SBDebugger, GetReproducerPath); + LLDB_INSTRUMENT_VA(this); return (m_opaque_sp ? ConstString(m_opaque_sp->GetReproducerPath()).GetCString() @@ -1410,60 +1338,71 @@ const char *SBDebugger::GetReproducerPath() const { } ScriptLanguage SBDebugger::GetScriptLanguage() const { - LLDB_RECORD_METHOD_CONST_NO_ARGS(lldb::ScriptLanguage, SBDebugger, - GetScriptLanguage); + LLDB_INSTRUMENT_VA(this); return (m_opaque_sp ? m_opaque_sp->GetScriptLanguage() : eScriptLanguageNone); } void SBDebugger::SetScriptLanguage(ScriptLanguage script_lang) { - LLDB_RECORD_METHOD(void, SBDebugger, SetScriptLanguage, - (lldb::ScriptLanguage), script_lang); + LLDB_INSTRUMENT_VA(this, script_lang); if (m_opaque_sp) { m_opaque_sp->SetScriptLanguage(script_lang); } } +LanguageType SBDebugger::GetREPLLanguage() const { + LLDB_INSTRUMENT_VA(this); + + return (m_opaque_sp ? m_opaque_sp->GetREPLLanguage() : eLanguageTypeUnknown); +} + +void SBDebugger::SetREPLLanguage(LanguageType repl_lang) { + LLDB_INSTRUMENT_VA(this, repl_lang); + + if (m_opaque_sp) { + m_opaque_sp->SetREPLLanguage(repl_lang); + } +} + bool SBDebugger::SetUseExternalEditor(bool value) { - LLDB_RECORD_METHOD(bool, SBDebugger, SetUseExternalEditor, (bool), value); + LLDB_INSTRUMENT_VA(this, value); return (m_opaque_sp ? m_opaque_sp->SetUseExternalEditor(value) : false); } bool SBDebugger::GetUseExternalEditor() { - LLDB_RECORD_METHOD_NO_ARGS(bool, SBDebugger, GetUseExternalEditor); + LLDB_INSTRUMENT_VA(this); return (m_opaque_sp ? m_opaque_sp->GetUseExternalEditor() : false); } bool SBDebugger::SetUseColor(bool value) { - LLDB_RECORD_METHOD(bool, SBDebugger, SetUseColor, (bool), value); + LLDB_INSTRUMENT_VA(this, value); return (m_opaque_sp ? m_opaque_sp->SetUseColor(value) : false); } bool SBDebugger::GetUseColor() const { - LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBDebugger, GetUseColor); + LLDB_INSTRUMENT_VA(this); return (m_opaque_sp ? m_opaque_sp->GetUseColor() : false); } bool SBDebugger::SetUseSourceCache(bool value) { - LLDB_RECORD_METHOD(bool, SBDebugger, SetUseSourceCache, (bool), value); + LLDB_INSTRUMENT_VA(this, value); return (m_opaque_sp ? m_opaque_sp->SetUseSourceCache(value) : false); } bool SBDebugger::GetUseSourceCache() const { - LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBDebugger, GetUseSourceCache); + LLDB_INSTRUMENT_VA(this); return (m_opaque_sp ? m_opaque_sp->GetUseSourceCache() : false); } bool SBDebugger::GetDescription(SBStream &description) { - LLDB_RECORD_METHOD(bool, SBDebugger, GetDescription, (lldb::SBStream &), - description); + LLDB_INSTRUMENT_VA(this, description); Stream &strm = description.ref(); @@ -1478,14 +1417,13 @@ bool SBDebugger::GetDescription(SBStream &description) { } user_id_t SBDebugger::GetID() { - LLDB_RECORD_METHOD_NO_ARGS(lldb::user_id_t, SBDebugger, GetID); + LLDB_INSTRUMENT_VA(this); return (m_opaque_sp ? m_opaque_sp->GetID() : LLDB_INVALID_UID); } SBError SBDebugger::SetCurrentPlatform(const char *platform_name_cstr) { - LLDB_RECORD_METHOD(lldb::SBError, SBDebugger, SetCurrentPlatform, - (const char *), platform_name_cstr); + LLDB_INSTRUMENT_VA(this, platform_name_cstr); SBError sb_error; if (m_opaque_sp) { @@ -1511,91 +1449,77 @@ SBError SBDebugger::SetCurrentPlatform(const char *platform_name_cstr) { } else { sb_error.ref().SetErrorString("invalid debugger"); } - return LLDB_RECORD_RESULT(sb_error); + return sb_error; } bool SBDebugger::SetCurrentPlatformSDKRoot(const char *sysroot) { - LLDB_RECORD_METHOD(bool, SBDebugger, SetCurrentPlatformSDKRoot, - (const char *), sysroot); + LLDB_INSTRUMENT_VA(this, sysroot); - Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); - if (m_opaque_sp) { - PlatformSP platform_sp( - m_opaque_sp->GetPlatformList().GetSelectedPlatform()); - - if (platform_sp) { - if (log && sysroot) - LLDB_LOGF(log, "SBDebugger::SetCurrentPlatformSDKRoot (\"%s\")", - sysroot); - platform_sp->SetSDKRootDirectory(ConstString(sysroot)); - return true; - } + if (SBPlatform platform = GetSelectedPlatform()) { + platform.SetSDKRoot(sysroot); + return true; } return false; } bool SBDebugger::GetCloseInputOnEOF() const { - LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBDebugger, GetCloseInputOnEOF); + LLDB_INSTRUMENT_VA(this); return (m_opaque_sp ? m_opaque_sp->GetCloseInputOnEOF() : false); } void SBDebugger::SetCloseInputOnEOF(bool b) { - LLDB_RECORD_METHOD(void, SBDebugger, SetCloseInputOnEOF, (bool), b); + LLDB_INSTRUMENT_VA(this, b); if (m_opaque_sp) m_opaque_sp->SetCloseInputOnEOF(b); } SBTypeCategory SBDebugger::GetCategory(const char *category_name) { - LLDB_RECORD_METHOD(lldb::SBTypeCategory, SBDebugger, GetCategory, - (const char *), category_name); + LLDB_INSTRUMENT_VA(this, category_name); if (!category_name || *category_name == 0) - return LLDB_RECORD_RESULT(SBTypeCategory()); + return SBTypeCategory(); TypeCategoryImplSP category_sp; if (DataVisualization::Categories::GetCategory(ConstString(category_name), category_sp, false)) { - return LLDB_RECORD_RESULT(SBTypeCategory(category_sp)); + return SBTypeCategory(category_sp); } else { - return LLDB_RECORD_RESULT(SBTypeCategory()); + return SBTypeCategory(); } } SBTypeCategory SBDebugger::GetCategory(lldb::LanguageType lang_type) { - LLDB_RECORD_METHOD(lldb::SBTypeCategory, SBDebugger, GetCategory, - (lldb::LanguageType), lang_type); + LLDB_INSTRUMENT_VA(this, lang_type); TypeCategoryImplSP category_sp; if (DataVisualization::Categories::GetCategory(lang_type, category_sp)) { - return LLDB_RECORD_RESULT(SBTypeCategory(category_sp)); + return SBTypeCategory(category_sp); } else { - return LLDB_RECORD_RESULT(SBTypeCategory()); + return SBTypeCategory(); } } SBTypeCategory SBDebugger::CreateCategory(const char *category_name) { - LLDB_RECORD_METHOD(lldb::SBTypeCategory, SBDebugger, CreateCategory, - (const char *), category_name); + LLDB_INSTRUMENT_VA(this, category_name); if (!category_name || *category_name == 0) - return LLDB_RECORD_RESULT(SBTypeCategory()); + return SBTypeCategory(); TypeCategoryImplSP category_sp; if (DataVisualization::Categories::GetCategory(ConstString(category_name), category_sp, true)) { - return LLDB_RECORD_RESULT(SBTypeCategory(category_sp)); + return SBTypeCategory(category_sp); } else { - return LLDB_RECORD_RESULT(SBTypeCategory()); + return SBTypeCategory(); } } bool SBDebugger::DeleteCategory(const char *category_name) { - LLDB_RECORD_METHOD(bool, SBDebugger, DeleteCategory, (const char *), - category_name); + LLDB_INSTRUMENT_VA(this, category_name); if (!category_name || *category_name == 0) return false; @@ -1604,64 +1528,56 @@ bool SBDebugger::DeleteCategory(const char *category_name) { } uint32_t SBDebugger::GetNumCategories() { - LLDB_RECORD_METHOD_NO_ARGS(uint32_t, SBDebugger, GetNumCategories); + LLDB_INSTRUMENT_VA(this); return DataVisualization::Categories::GetCount(); } SBTypeCategory SBDebugger::GetCategoryAtIndex(uint32_t index) { - LLDB_RECORD_METHOD(lldb::SBTypeCategory, SBDebugger, GetCategoryAtIndex, - (uint32_t), index); + LLDB_INSTRUMENT_VA(this, index); - return LLDB_RECORD_RESULT( - SBTypeCategory(DataVisualization::Categories::GetCategoryAtIndex(index))); + return SBTypeCategory( + DataVisualization::Categories::GetCategoryAtIndex(index)); } SBTypeCategory SBDebugger::GetDefaultCategory() { - LLDB_RECORD_METHOD_NO_ARGS(lldb::SBTypeCategory, SBDebugger, - GetDefaultCategory); + LLDB_INSTRUMENT_VA(this); - return LLDB_RECORD_RESULT(GetCategory("default")); + return GetCategory("default"); } SBTypeFormat SBDebugger::GetFormatForType(SBTypeNameSpecifier type_name) { - LLDB_RECORD_METHOD(lldb::SBTypeFormat, SBDebugger, GetFormatForType, - (lldb::SBTypeNameSpecifier), type_name); + LLDB_INSTRUMENT_VA(this, type_name); SBTypeCategory default_category_sb = GetDefaultCategory(); if (default_category_sb.GetEnabled()) - return LLDB_RECORD_RESULT(default_category_sb.GetFormatForType(type_name)); - return LLDB_RECORD_RESULT(SBTypeFormat()); + return default_category_sb.GetFormatForType(type_name); + return SBTypeFormat(); } SBTypeSummary SBDebugger::GetSummaryForType(SBTypeNameSpecifier type_name) { - LLDB_RECORD_METHOD(lldb::SBTypeSummary, SBDebugger, GetSummaryForType, - (lldb::SBTypeNameSpecifier), type_name); + LLDB_INSTRUMENT_VA(this, type_name); if (!type_name.IsValid()) - return LLDB_RECORD_RESULT(SBTypeSummary()); - return LLDB_RECORD_RESULT( - SBTypeSummary(DataVisualization::GetSummaryForType(type_name.GetSP()))); + return SBTypeSummary(); + return SBTypeSummary(DataVisualization::GetSummaryForType(type_name.GetSP())); } SBTypeFilter SBDebugger::GetFilterForType(SBTypeNameSpecifier type_name) { - LLDB_RECORD_METHOD(lldb::SBTypeFilter, SBDebugger, GetFilterForType, - (lldb::SBTypeNameSpecifier), type_name); + LLDB_INSTRUMENT_VA(this, type_name); if (!type_name.IsValid()) - return LLDB_RECORD_RESULT(SBTypeFilter()); - return LLDB_RECORD_RESULT( - SBTypeFilter(DataVisualization::GetFilterForType(type_name.GetSP()))); + return SBTypeFilter(); + return SBTypeFilter(DataVisualization::GetFilterForType(type_name.GetSP())); } SBTypeSynthetic SBDebugger::GetSyntheticForType(SBTypeNameSpecifier type_name) { - LLDB_RECORD_METHOD(lldb::SBTypeSynthetic, SBDebugger, GetSyntheticForType, - (lldb::SBTypeNameSpecifier), type_name); + LLDB_INSTRUMENT_VA(this, type_name); if (!type_name.IsValid()) - return LLDB_RECORD_RESULT(SBTypeSynthetic()); - return LLDB_RECORD_RESULT(SBTypeSynthetic( - DataVisualization::GetSyntheticForType(type_name.GetSP()))); + return SBTypeSynthetic(); + return SBTypeSynthetic( + DataVisualization::GetSyntheticForType(type_name.GetSP())); } static llvm::ArrayRef<const char *> GetCategoryArray(const char **categories) { @@ -1674,8 +1590,7 @@ static llvm::ArrayRef<const char *> GetCategoryArray(const char **categories) { } bool SBDebugger::EnableLog(const char *channel, const char **categories) { - LLDB_RECORD_METHOD(bool, SBDebugger, EnableLog, (const char *, const char **), - channel, categories); + LLDB_INSTRUMENT_VA(this, channel, categories); if (m_opaque_sp) { uint32_t log_options = @@ -1690,224 +1605,9 @@ bool SBDebugger::EnableLog(const char *channel, const char **categories) { void SBDebugger::SetLoggingCallback(lldb::LogOutputCallback log_callback, void *baton) { - LLDB_RECORD_DUMMY(void, SBDebugger, SetLoggingCallback, - (lldb::LogOutputCallback, void *), log_callback, baton); + LLDB_INSTRUMENT_VA(this, log_callback, baton); if (m_opaque_sp) { return m_opaque_sp->SetLoggingCallback(log_callback, baton); } } - -namespace lldb_private { -namespace repro { - -template <> void RegisterMethods<SBInputReader>(Registry &R) { - LLDB_REGISTER_METHOD(void, SBInputReader, SetIsDone, (bool)); - LLDB_REGISTER_METHOD_CONST(bool, SBInputReader, IsActive, ()); -} - -static void SetFileHandleRedirect(SBDebugger *, FILE *, bool) { - // Do nothing. -} - -static SBError SetFileRedirect(SBDebugger *, SBFile file) { return SBError(); } - -static SBError SetFileRedirect(SBDebugger *, FileSP file) { return SBError(); } - -template <> void RegisterMethods<SBDebugger>(Registry &R) { - // Custom implementation. - R.Register(&invoke<void (SBDebugger::*)(FILE *, bool)>::method< - &SBDebugger::SetErrorFileHandle>::record, - &SetFileHandleRedirect); - R.Register(&invoke<void (SBDebugger::*)(FILE *, bool)>::method< - &SBDebugger::SetOutputFileHandle>::record, - &SetFileHandleRedirect); - - R.Register(&invoke<SBError (SBDebugger::*)( - SBFile)>::method<&SBDebugger::SetInputFile>::record, - &SetFileRedirect); - R.Register(&invoke<SBError (SBDebugger::*)( - SBFile)>::method<&SBDebugger::SetOutputFile>::record, - &SetFileRedirect); - R.Register(&invoke<SBError (SBDebugger::*)( - SBFile)>::method<&SBDebugger::SetErrorFile>::record, - &SetFileRedirect); - - R.Register(&invoke<SBError (SBDebugger::*)( - FileSP)>::method<&SBDebugger::SetInputFile>::record, - &SetFileRedirect); - R.Register(&invoke<SBError (SBDebugger::*)( - FileSP)>::method<&SBDebugger::SetOutputFile>::record, - &SetFileRedirect); - R.Register(&invoke<SBError (SBDebugger::*)( - FileSP)>::method<&SBDebugger::SetErrorFile>::record, - &SetFileRedirect); - - LLDB_REGISTER_CHAR_PTR_METHOD_STATIC(bool, SBDebugger, - GetDefaultArchitecture); - - LLDB_REGISTER_CONSTRUCTOR(SBDebugger, ()); - LLDB_REGISTER_CONSTRUCTOR(SBDebugger, (const lldb::DebuggerSP &)); - LLDB_REGISTER_CONSTRUCTOR(SBDebugger, (const lldb::SBDebugger &)); - LLDB_REGISTER_METHOD(lldb::SBDebugger &, - SBDebugger, operator=,(const lldb::SBDebugger &)); - LLDB_REGISTER_STATIC_METHOD(void, SBDebugger, Initialize, ()); - LLDB_REGISTER_STATIC_METHOD(lldb::SBError, SBDebugger, - InitializeWithErrorHandling, ()); - LLDB_REGISTER_STATIC_METHOD(void, SBDebugger, Terminate, ()); - LLDB_REGISTER_METHOD(void, SBDebugger, Clear, ()); - LLDB_REGISTER_STATIC_METHOD(lldb::SBDebugger, SBDebugger, Create, ()); - LLDB_REGISTER_STATIC_METHOD(lldb::SBDebugger, SBDebugger, Create, (bool)); - LLDB_REGISTER_STATIC_METHOD( - const char *, SBDebugger, GetProgressFromEvent, - (const lldb::SBEvent &, uint64_t &, uint64_t &, uint64_t &, bool &)); - LLDB_REGISTER_STATIC_METHOD(const char *, SBDebugger, GetBroadcasterClass, - ()); - LLDB_REGISTER_METHOD(SBBroadcaster, SBDebugger, GetBroadcaster, ()); - LLDB_REGISTER_STATIC_METHOD(void, SBDebugger, Destroy, (lldb::SBDebugger &)); - LLDB_REGISTER_STATIC_METHOD(void, SBDebugger, MemoryPressureDetected, ()); - LLDB_REGISTER_METHOD_CONST(bool, SBDebugger, IsValid, ()); - LLDB_REGISTER_METHOD_CONST(bool, SBDebugger, operator bool,()); - LLDB_REGISTER_METHOD(void, SBDebugger, SetAsync, (bool)); - LLDB_REGISTER_METHOD(bool, SBDebugger, GetAsync, ()); - LLDB_REGISTER_METHOD(void, SBDebugger, SkipLLDBInitFiles, (bool)); - LLDB_REGISTER_METHOD(void, SBDebugger, SkipAppInitFiles, (bool)); - LLDB_REGISTER_METHOD(SBError, SBDebugger, SetInputString, (const char *)); - LLDB_REGISTER_METHOD(void, SBDebugger, SetInputFileHandle, (FILE *, bool)); - LLDB_REGISTER_METHOD(FILE *, SBDebugger, GetInputFileHandle, ()); - LLDB_REGISTER_METHOD(FILE *, SBDebugger, GetOutputFileHandle, ()); - LLDB_REGISTER_METHOD(FILE *, SBDebugger, GetErrorFileHandle, ()); - LLDB_REGISTER_METHOD(SBFile, SBDebugger, GetInputFile, ()); - LLDB_REGISTER_METHOD(SBFile, SBDebugger, GetOutputFile, ()); - LLDB_REGISTER_METHOD(SBFile, SBDebugger, GetErrorFile, ()); - LLDB_REGISTER_METHOD(void, SBDebugger, SaveInputTerminalState, ()); - LLDB_REGISTER_METHOD(void, SBDebugger, RestoreInputTerminalState, ()); - LLDB_REGISTER_METHOD(lldb::SBCommandInterpreter, SBDebugger, - GetCommandInterpreter, ()); - LLDB_REGISTER_METHOD(void, SBDebugger, HandleCommand, (const char *)); - LLDB_REGISTER_METHOD(lldb::SBListener, SBDebugger, GetListener, ()); - LLDB_REGISTER_METHOD( - void, SBDebugger, HandleProcessEvent, - (const lldb::SBProcess &, const lldb::SBEvent &, FILE *, FILE *)); - LLDB_REGISTER_METHOD( - void, SBDebugger, HandleProcessEvent, - (const lldb::SBProcess &, const lldb::SBEvent &, SBFile, SBFile)); - LLDB_REGISTER_METHOD( - void, SBDebugger, HandleProcessEvent, - (const lldb::SBProcess &, const lldb::SBEvent &, FileSP, FileSP)); - LLDB_REGISTER_METHOD(lldb::SBSourceManager, SBDebugger, GetSourceManager, ()); - LLDB_REGISTER_STATIC_METHOD(bool, SBDebugger, SetDefaultArchitecture, - (const char *)); - LLDB_REGISTER_METHOD(lldb::ScriptLanguage, SBDebugger, GetScriptingLanguage, - (const char *)); - LLDB_REGISTER_METHOD(SBStructuredData, SBDebugger, GetScriptInterpreterInfo, - (lldb::ScriptLanguage)); - LLDB_REGISTER_STATIC_METHOD(const char *, SBDebugger, GetVersionString, ()); - LLDB_REGISTER_STATIC_METHOD(const char *, SBDebugger, StateAsCString, - (lldb::StateType)); - LLDB_REGISTER_STATIC_METHOD(lldb::SBStructuredData, SBDebugger, - GetBuildConfiguration, ()); - LLDB_REGISTER_STATIC_METHOD(bool, SBDebugger, StateIsRunningState, - (lldb::StateType)); - LLDB_REGISTER_STATIC_METHOD(bool, SBDebugger, StateIsStoppedState, - (lldb::StateType)); - LLDB_REGISTER_METHOD( - lldb::SBTarget, SBDebugger, CreateTarget, - (const char *, const char *, const char *, bool, lldb::SBError &)); - LLDB_REGISTER_METHOD(lldb::SBTarget, SBDebugger, - CreateTargetWithFileAndTargetTriple, - (const char *, const char *)); - LLDB_REGISTER_METHOD(lldb::SBTarget, SBDebugger, CreateTargetWithFileAndArch, - (const char *, const char *)); - LLDB_REGISTER_METHOD(lldb::SBTarget, SBDebugger, CreateTarget, - (const char *)); - LLDB_REGISTER_METHOD(lldb::SBTarget, SBDebugger, GetDummyTarget, ()); - LLDB_REGISTER_METHOD(bool, SBDebugger, DeleteTarget, (lldb::SBTarget &)); - LLDB_REGISTER_METHOD(lldb::SBTarget, SBDebugger, GetTargetAtIndex, - (uint32_t)); - LLDB_REGISTER_METHOD(uint32_t, SBDebugger, GetIndexOfTarget, - (lldb::SBTarget)); - LLDB_REGISTER_METHOD(lldb::SBTarget, SBDebugger, FindTargetWithProcessID, - (lldb::pid_t)); - LLDB_REGISTER_METHOD(lldb::SBTarget, SBDebugger, FindTargetWithFileAndArch, - (const char *, const char *)); - LLDB_REGISTER_METHOD(uint32_t, SBDebugger, GetNumTargets, ()); - LLDB_REGISTER_METHOD(lldb::SBTarget, SBDebugger, GetSelectedTarget, ()); - LLDB_REGISTER_METHOD(void, SBDebugger, SetSelectedTarget, (lldb::SBTarget &)); - LLDB_REGISTER_METHOD(lldb::SBPlatform, SBDebugger, GetSelectedPlatform, ()); - LLDB_REGISTER_METHOD(void, SBDebugger, SetSelectedPlatform, - (lldb::SBPlatform &)); - LLDB_REGISTER_METHOD(uint32_t, SBDebugger, GetNumPlatforms, ()); - LLDB_REGISTER_METHOD(lldb::SBPlatform, SBDebugger, GetPlatformAtIndex, - (uint32_t)); - LLDB_REGISTER_METHOD(uint32_t, SBDebugger, GetNumAvailablePlatforms, ()); - LLDB_REGISTER_METHOD(lldb::SBStructuredData, SBDebugger, - GetAvailablePlatformInfoAtIndex, (uint32_t)); - LLDB_REGISTER_METHOD(void, SBDebugger, DispatchInputInterrupt, ()); - LLDB_REGISTER_METHOD(void, SBDebugger, DispatchInputEndOfFile, ()); - LLDB_REGISTER_METHOD(void, SBDebugger, PushInputReader, - (lldb::SBInputReader &)); - LLDB_REGISTER_METHOD(void, SBDebugger, RunCommandInterpreter, (bool, bool)); - LLDB_REGISTER_METHOD(void, SBDebugger, RunCommandInterpreter, - (bool, bool, lldb::SBCommandInterpreterRunOptions &, - int &, bool &, bool &)); - LLDB_REGISTER_METHOD(lldb::SBError, SBDebugger, RunREPL, - (lldb::LanguageType, const char *)); - LLDB_REGISTER_STATIC_METHOD(lldb::SBDebugger, SBDebugger, FindDebuggerWithID, - (int)); - LLDB_REGISTER_METHOD(const char *, SBDebugger, GetInstanceName, ()); - LLDB_REGISTER_STATIC_METHOD(lldb::SBError, SBDebugger, SetInternalVariable, - (const char *, const char *, const char *)); - LLDB_REGISTER_STATIC_METHOD(lldb::SBStringList, SBDebugger, - GetInternalVariableValue, - (const char *, const char *)); - LLDB_REGISTER_METHOD_CONST(uint32_t, SBDebugger, GetTerminalWidth, ()); - LLDB_REGISTER_METHOD(void, SBDebugger, SetTerminalWidth, (uint32_t)); - LLDB_REGISTER_METHOD_CONST(const char *, SBDebugger, GetPrompt, ()); - LLDB_REGISTER_METHOD(void, SBDebugger, SetPrompt, (const char *)); - LLDB_REGISTER_METHOD_CONST(const char *, SBDebugger, GetReproducerPath, ()); - LLDB_REGISTER_METHOD_CONST(lldb::ScriptLanguage, SBDebugger, - GetScriptLanguage, ()); - LLDB_REGISTER_METHOD(void, SBDebugger, SetScriptLanguage, - (lldb::ScriptLanguage)); - LLDB_REGISTER_METHOD(bool, SBDebugger, SetUseExternalEditor, (bool)); - LLDB_REGISTER_METHOD(bool, SBDebugger, GetUseExternalEditor, ()); - LLDB_REGISTER_METHOD(bool, SBDebugger, SetUseColor, (bool)); - LLDB_REGISTER_METHOD_CONST(bool, SBDebugger, GetUseColor, ()); - LLDB_REGISTER_METHOD(bool, SBDebugger, GetDescription, (lldb::SBStream &)); - LLDB_REGISTER_METHOD(lldb::user_id_t, SBDebugger, GetID, ()); - LLDB_REGISTER_METHOD(lldb::SBError, SBDebugger, SetCurrentPlatform, - (const char *)); - LLDB_REGISTER_METHOD(bool, SBDebugger, SetCurrentPlatformSDKRoot, - (const char *)); - LLDB_REGISTER_METHOD_CONST(bool, SBDebugger, GetCloseInputOnEOF, ()); - LLDB_REGISTER_METHOD(void, SBDebugger, SetCloseInputOnEOF, (bool)); - LLDB_REGISTER_METHOD(lldb::SBTypeCategory, SBDebugger, GetCategory, - (const char *)); - LLDB_REGISTER_METHOD(lldb::SBTypeCategory, SBDebugger, GetCategory, - (lldb::LanguageType)); - LLDB_REGISTER_METHOD(lldb::SBTypeCategory, SBDebugger, CreateCategory, - (const char *)); - LLDB_REGISTER_METHOD(bool, SBDebugger, DeleteCategory, (const char *)); - LLDB_REGISTER_METHOD(uint32_t, SBDebugger, GetNumCategories, ()); - LLDB_REGISTER_METHOD(lldb::SBTypeCategory, SBDebugger, GetCategoryAtIndex, - (uint32_t)); - LLDB_REGISTER_METHOD(lldb::SBTypeCategory, SBDebugger, GetDefaultCategory, - ()); - LLDB_REGISTER_METHOD(lldb::SBTypeFormat, SBDebugger, GetFormatForType, - (lldb::SBTypeNameSpecifier)); - LLDB_REGISTER_METHOD(lldb::SBTypeSummary, SBDebugger, GetSummaryForType, - (lldb::SBTypeNameSpecifier)); - LLDB_REGISTER_METHOD(lldb::SBTypeSynthetic, SBDebugger, GetSyntheticForType, - (lldb::SBTypeNameSpecifier)); - LLDB_REGISTER_METHOD(lldb::SBTypeFilter, SBDebugger, GetFilterForType, - (lldb::SBTypeNameSpecifier)); - LLDB_REGISTER_METHOD(bool, SBDebugger, EnableLog, - (const char *, const char **)); - LLDB_REGISTER_METHOD(lldb::SBCommandInterpreterRunResult, SBDebugger, - RunCommandInterpreter, - (const lldb::SBCommandInterpreterRunOptions &)); -} - -} // namespace repro -} // namespace lldb_private diff --git a/lldb/source/API/SBDeclaration.cpp b/lldb/source/API/SBDeclaration.cpp index 1496096e46d1..5b7def09b5cc 100644 --- a/lldb/source/API/SBDeclaration.cpp +++ b/lldb/source/API/SBDeclaration.cpp @@ -7,11 +7,11 @@ //===----------------------------------------------------------------------===// #include "lldb/API/SBDeclaration.h" -#include "SBReproducerPrivate.h" #include "Utils.h" #include "lldb/API/SBStream.h" #include "lldb/Core/Declaration.h" #include "lldb/Host/PosixApi.h" +#include "lldb/Utility/Instrumentation.h" #include "lldb/Utility/Stream.h" #include <climits> @@ -19,30 +19,25 @@ using namespace lldb; using namespace lldb_private; -SBDeclaration::SBDeclaration() : m_opaque_up() { - LLDB_RECORD_CONSTRUCTOR_NO_ARGS(SBDeclaration); -} +SBDeclaration::SBDeclaration() { LLDB_INSTRUMENT_VA(this); } -SBDeclaration::SBDeclaration(const SBDeclaration &rhs) : m_opaque_up() { - LLDB_RECORD_CONSTRUCTOR(SBDeclaration, (const lldb::SBDeclaration &), rhs); +SBDeclaration::SBDeclaration(const SBDeclaration &rhs) { + LLDB_INSTRUMENT_VA(this, rhs); m_opaque_up = clone(rhs.m_opaque_up); } -SBDeclaration::SBDeclaration(const lldb_private::Declaration *lldb_object_ptr) - : m_opaque_up() { +SBDeclaration::SBDeclaration(const lldb_private::Declaration *lldb_object_ptr) { if (lldb_object_ptr) m_opaque_up = std::make_unique<Declaration>(*lldb_object_ptr); } const SBDeclaration &SBDeclaration::operator=(const SBDeclaration &rhs) { - LLDB_RECORD_METHOD(const lldb::SBDeclaration &, - SBDeclaration, operator=,(const lldb::SBDeclaration &), - rhs); + LLDB_INSTRUMENT_VA(this, rhs); if (this != &rhs) m_opaque_up = clone(rhs.m_opaque_up); - return LLDB_RECORD_RESULT(*this); + return *this; } void SBDeclaration::SetDeclaration( @@ -53,31 +48,27 @@ void SBDeclaration::SetDeclaration( SBDeclaration::~SBDeclaration() = default; bool SBDeclaration::IsValid() const { - LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBDeclaration, IsValid); + LLDB_INSTRUMENT_VA(this); return this->operator bool(); } SBDeclaration::operator bool() const { - LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBDeclaration, operator bool); + LLDB_INSTRUMENT_VA(this); return m_opaque_up.get() && m_opaque_up->IsValid(); } SBFileSpec SBDeclaration::GetFileSpec() const { - LLDB_RECORD_METHOD_CONST_NO_ARGS(lldb::SBFileSpec, SBDeclaration, - GetFileSpec); - + LLDB_INSTRUMENT_VA(this); SBFileSpec sb_file_spec; if (m_opaque_up.get() && m_opaque_up->GetFile()) sb_file_spec.SetFileSpec(m_opaque_up->GetFile()); - - return LLDB_RECORD_RESULT(sb_file_spec); + return sb_file_spec; } uint32_t SBDeclaration::GetLine() const { - LLDB_RECORD_METHOD_CONST_NO_ARGS(uint32_t, SBDeclaration, GetLine); - + LLDB_INSTRUMENT_VA(this); uint32_t line = 0; if (m_opaque_up) @@ -88,7 +79,7 @@ uint32_t SBDeclaration::GetLine() const { } uint32_t SBDeclaration::GetColumn() const { - LLDB_RECORD_METHOD_CONST_NO_ARGS(uint32_t, SBDeclaration, GetColumn); + LLDB_INSTRUMENT_VA(this); if (m_opaque_up) return m_opaque_up->GetColumn(); @@ -96,8 +87,7 @@ uint32_t SBDeclaration::GetColumn() const { } void SBDeclaration::SetFileSpec(lldb::SBFileSpec filespec) { - LLDB_RECORD_METHOD(void, SBDeclaration, SetFileSpec, (lldb::SBFileSpec), - filespec); + LLDB_INSTRUMENT_VA(this, filespec); if (filespec.IsValid()) ref().SetFile(filespec.ref()); @@ -105,20 +95,19 @@ void SBDeclaration::SetFileSpec(lldb::SBFileSpec filespec) { ref().SetFile(FileSpec()); } void SBDeclaration::SetLine(uint32_t line) { - LLDB_RECORD_METHOD(void, SBDeclaration, SetLine, (uint32_t), line); + LLDB_INSTRUMENT_VA(this, line); ref().SetLine(line); } void SBDeclaration::SetColumn(uint32_t column) { - LLDB_RECORD_METHOD(void, SBDeclaration, SetColumn, (uint32_t), column); + LLDB_INSTRUMENT_VA(this, column); ref().SetColumn(column); } bool SBDeclaration::operator==(const SBDeclaration &rhs) const { - LLDB_RECORD_METHOD_CONST( - bool, SBDeclaration, operator==,(const lldb::SBDeclaration &), rhs); + LLDB_INSTRUMENT_VA(this, rhs); lldb_private::Declaration *lhs_ptr = m_opaque_up.get(); lldb_private::Declaration *rhs_ptr = rhs.m_opaque_up.get(); @@ -130,8 +119,7 @@ bool SBDeclaration::operator==(const SBDeclaration &rhs) const { } bool SBDeclaration::operator!=(const SBDeclaration &rhs) const { - LLDB_RECORD_METHOD_CONST( - bool, SBDeclaration, operator!=,(const lldb::SBDeclaration &), rhs); + LLDB_INSTRUMENT_VA(this, rhs); lldb_private::Declaration *lhs_ptr = m_opaque_up.get(); lldb_private::Declaration *rhs_ptr = rhs.m_opaque_up.get(); @@ -157,8 +145,7 @@ const lldb_private::Declaration &SBDeclaration::ref() const { } bool SBDeclaration::GetDescription(SBStream &description) { - LLDB_RECORD_METHOD(bool, SBDeclaration, GetDescription, (lldb::SBStream &), - description); + LLDB_INSTRUMENT_VA(this, description); Stream &strm = description.ref(); @@ -175,33 +162,3 @@ bool SBDeclaration::GetDescription(SBStream &description) { } lldb_private::Declaration *SBDeclaration::get() { return m_opaque_up.get(); } - -namespace lldb_private { -namespace repro { - -template <> -void RegisterMethods<SBDeclaration>(Registry &R) { - LLDB_REGISTER_CONSTRUCTOR(SBDeclaration, ()); - LLDB_REGISTER_CONSTRUCTOR(SBDeclaration, (const lldb::SBDeclaration &)); - LLDB_REGISTER_METHOD( - const lldb::SBDeclaration &, - SBDeclaration, operator=,(const lldb::SBDeclaration &)); - LLDB_REGISTER_METHOD_CONST(bool, SBDeclaration, IsValid, ()); - LLDB_REGISTER_METHOD_CONST(bool, SBDeclaration, operator bool, ()); - LLDB_REGISTER_METHOD_CONST(lldb::SBFileSpec, SBDeclaration, GetFileSpec, - ()); - LLDB_REGISTER_METHOD_CONST(uint32_t, SBDeclaration, GetLine, ()); - LLDB_REGISTER_METHOD_CONST(uint32_t, SBDeclaration, GetColumn, ()); - LLDB_REGISTER_METHOD(void, SBDeclaration, SetFileSpec, (lldb::SBFileSpec)); - LLDB_REGISTER_METHOD(void, SBDeclaration, SetLine, (uint32_t)); - LLDB_REGISTER_METHOD(void, SBDeclaration, SetColumn, (uint32_t)); - LLDB_REGISTER_METHOD_CONST( - bool, SBDeclaration, operator==,(const lldb::SBDeclaration &)); - LLDB_REGISTER_METHOD_CONST( - bool, SBDeclaration, operator!=,(const lldb::SBDeclaration &)); - LLDB_REGISTER_METHOD(bool, SBDeclaration, GetDescription, - (lldb::SBStream &)); -} - -} -} diff --git a/lldb/source/API/SBEnvironment.cpp b/lldb/source/API/SBEnvironment.cpp index d4de89c32567..5fafabe02e01 100644 --- a/lldb/source/API/SBEnvironment.cpp +++ b/lldb/source/API/SBEnvironment.cpp @@ -7,22 +7,22 @@ //===----------------------------------------------------------------------===// #include "lldb/API/SBEnvironment.h" -#include "SBReproducerPrivate.h" #include "Utils.h" #include "lldb/API/SBStringList.h" #include "lldb/Utility/ConstString.h" #include "lldb/Utility/Environment.h" +#include "lldb/Utility/Instrumentation.h" using namespace lldb; using namespace lldb_private; SBEnvironment::SBEnvironment() : m_opaque_up(new Environment()) { - LLDB_RECORD_CONSTRUCTOR_NO_ARGS(SBEnvironment); + LLDB_INSTRUMENT_VA(this); } SBEnvironment::SBEnvironment(const SBEnvironment &rhs) : m_opaque_up(clone(rhs.m_opaque_up)) { - LLDB_RECORD_CONSTRUCTOR(SBEnvironment, (const lldb::SBEnvironment &), rhs); + LLDB_INSTRUMENT_VA(this, rhs); } SBEnvironment::SBEnvironment(Environment rhs) @@ -31,23 +31,21 @@ SBEnvironment::SBEnvironment(Environment rhs) SBEnvironment::~SBEnvironment() = default; const SBEnvironment &SBEnvironment::operator=(const SBEnvironment &rhs) { - LLDB_RECORD_METHOD(const lldb::SBEnvironment &, - SBEnvironment, operator=,(const lldb::SBEnvironment &), - rhs); + LLDB_INSTRUMENT_VA(this, rhs); if (this != &rhs) m_opaque_up = clone(rhs.m_opaque_up); - return LLDB_RECORD_RESULT(*this); + return *this; } size_t SBEnvironment::GetNumValues() { - LLDB_RECORD_METHOD_NO_ARGS(size_t, SBEnvironment, GetNumValues); + LLDB_INSTRUMENT_VA(this); return m_opaque_up->size(); } const char *SBEnvironment::Get(const char *name) { - LLDB_RECORD_METHOD(const char *, SBEnvironment, Get, (const char *), name); + LLDB_INSTRUMENT_VA(this, name); auto entry = m_opaque_up->find(name); if (entry == m_opaque_up->end()) { @@ -57,8 +55,7 @@ const char *SBEnvironment::Get(const char *name) { } const char *SBEnvironment::GetNameAtIndex(size_t index) { - LLDB_RECORD_METHOD(const char *, SBEnvironment, GetNameAtIndex, (size_t), - index); + LLDB_INSTRUMENT_VA(this, index); if (index >= GetNumValues()) return nullptr; @@ -67,8 +64,7 @@ const char *SBEnvironment::GetNameAtIndex(size_t index) { } const char *SBEnvironment::GetValueAtIndex(size_t index) { - LLDB_RECORD_METHOD(const char *, SBEnvironment, GetValueAtIndex, (size_t), - index); + LLDB_INSTRUMENT_VA(this, index); if (index >= GetNumValues()) return nullptr; @@ -77,9 +73,7 @@ const char *SBEnvironment::GetValueAtIndex(size_t index) { } bool SBEnvironment::Set(const char *name, const char *value, bool overwrite) { - LLDB_RECORD_METHOD(bool, SBEnvironment, Set, - (const char *, const char *, bool), name, value, - overwrite); + LLDB_INSTRUMENT_VA(this, name, value, overwrite); if (overwrite) { m_opaque_up->insert_or_assign(name, std::string(value)); @@ -89,32 +83,30 @@ bool SBEnvironment::Set(const char *name, const char *value, bool overwrite) { } bool SBEnvironment::Unset(const char *name) { - LLDB_RECORD_METHOD(bool, SBEnvironment, Unset, (const char *), name); + LLDB_INSTRUMENT_VA(this, name); return m_opaque_up->erase(name); } SBStringList SBEnvironment::GetEntries() { - LLDB_RECORD_METHOD_NO_ARGS(lldb::SBStringList, SBEnvironment, GetEntries); + LLDB_INSTRUMENT_VA(this); SBStringList entries; for (const auto &KV : *m_opaque_up) { entries.AppendString(Environment::compose(KV).c_str()); } - return LLDB_RECORD_RESULT(entries); + return entries; } void SBEnvironment::PutEntry(const char *name_and_value) { - LLDB_RECORD_METHOD(void, SBEnvironment, PutEntry, (const char *), - name_and_value); + LLDB_INSTRUMENT_VA(this, name_and_value); auto split = llvm::StringRef(name_and_value).split('='); m_opaque_up->insert_or_assign(split.first.str(), split.second.str()); } void SBEnvironment::SetEntries(const SBStringList &entries, bool append) { - LLDB_RECORD_METHOD(void, SBEnvironment, SetEntries, - (const lldb::SBStringList &, bool), entries, append); + LLDB_INSTRUMENT_VA(this, entries, append); if (!append) m_opaque_up->clear(); @@ -124,32 +116,9 @@ void SBEnvironment::SetEntries(const SBStringList &entries, bool append) { } void SBEnvironment::Clear() { - LLDB_RECORD_METHOD_NO_ARGS(void, SBEnvironment, Clear); + LLDB_INSTRUMENT_VA(this); m_opaque_up->clear(); } Environment &SBEnvironment::ref() const { return *m_opaque_up; } - -namespace lldb_private { -namespace repro { -template <> void RegisterMethods<SBEnvironment>(Registry &R) { - LLDB_REGISTER_CONSTRUCTOR(SBEnvironment, ()); - LLDB_REGISTER_CONSTRUCTOR(SBEnvironment, (const lldb::SBEnvironment &)); - LLDB_REGISTER_METHOD(const lldb::SBEnvironment &, - SBEnvironment, operator=,(const lldb::SBEnvironment &)); - LLDB_REGISTER_METHOD(size_t, SBEnvironment, GetNumValues, ()); - LLDB_REGISTER_METHOD(const char *, SBEnvironment, Get, (const char *)); - LLDB_REGISTER_METHOD(const char *, SBEnvironment, GetNameAtIndex, (size_t)); - LLDB_REGISTER_METHOD(const char *, SBEnvironment, GetValueAtIndex, (size_t)); - LLDB_REGISTER_METHOD(bool, SBEnvironment, Set, - (const char *, const char *, bool)); - LLDB_REGISTER_METHOD(bool, SBEnvironment, Unset, (const char *)); - LLDB_REGISTER_METHOD(lldb::SBStringList, SBEnvironment, GetEntries, ()); - LLDB_REGISTER_METHOD(void, SBEnvironment, PutEntry, (const char *)); - LLDB_REGISTER_METHOD(void, SBEnvironment, SetEntries, - (const lldb::SBStringList &, bool)); - LLDB_REGISTER_METHOD(void, SBEnvironment, Clear, ()); -} -} // namespace repro -} // namespace lldb_private diff --git a/lldb/source/API/SBError.cpp b/lldb/source/API/SBError.cpp index 89b5f26fd80c..ef4f7266f083 100644 --- a/lldb/source/API/SBError.cpp +++ b/lldb/source/API/SBError.cpp @@ -7,9 +7,9 @@ //===----------------------------------------------------------------------===// #include "lldb/API/SBError.h" -#include "SBReproducerPrivate.h" #include "Utils.h" #include "lldb/API/SBStream.h" +#include "lldb/Utility/Instrumentation.h" #include "lldb/Utility/Status.h" #include <cstdarg> @@ -17,10 +17,10 @@ using namespace lldb; using namespace lldb_private; -SBError::SBError() : m_opaque_up() { LLDB_RECORD_CONSTRUCTOR_NO_ARGS(SBError); } +SBError::SBError() { LLDB_INSTRUMENT_VA(this); } -SBError::SBError(const SBError &rhs) : m_opaque_up() { - LLDB_RECORD_CONSTRUCTOR(SBError, (const lldb::SBError &), rhs); +SBError::SBError(const SBError &rhs) { + LLDB_INSTRUMENT_VA(this, rhs); m_opaque_up = clone(rhs.m_opaque_up); } @@ -28,16 +28,15 @@ SBError::SBError(const SBError &rhs) : m_opaque_up() { SBError::~SBError() = default; const SBError &SBError::operator=(const SBError &rhs) { - LLDB_RECORD_METHOD(const lldb::SBError &, - SBError, operator=,(const lldb::SBError &), rhs); + LLDB_INSTRUMENT_VA(this, rhs); if (this != &rhs) m_opaque_up = clone(rhs.m_opaque_up); - return LLDB_RECORD_RESULT(*this); + return *this; } const char *SBError::GetCString() const { - LLDB_RECORD_METHOD_CONST_NO_ARGS(const char *, SBError, GetCString); + LLDB_INSTRUMENT_VA(this); if (m_opaque_up) return m_opaque_up->AsCString(); @@ -45,14 +44,14 @@ const char *SBError::GetCString() const { } void SBError::Clear() { - LLDB_RECORD_METHOD_NO_ARGS(void, SBError, Clear); + LLDB_INSTRUMENT_VA(this); if (m_opaque_up) m_opaque_up->Clear(); } bool SBError::Fail() const { - LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBError, Fail); + LLDB_INSTRUMENT_VA(this); bool ret_value = false; if (m_opaque_up) @@ -63,7 +62,7 @@ bool SBError::Fail() const { } bool SBError::Success() const { - LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBError, Success); + LLDB_INSTRUMENT_VA(this); bool ret_value = true; if (m_opaque_up) @@ -73,8 +72,7 @@ bool SBError::Success() const { } uint32_t SBError::GetError() const { - LLDB_RECORD_METHOD_CONST_NO_ARGS(uint32_t, SBError, GetError); - + LLDB_INSTRUMENT_VA(this); uint32_t err = 0; if (m_opaque_up) @@ -85,7 +83,7 @@ uint32_t SBError::GetError() const { } ErrorType SBError::GetType() const { - LLDB_RECORD_METHOD_CONST_NO_ARGS(lldb::ErrorType, SBError, GetType); + LLDB_INSTRUMENT_VA(this); ErrorType err_type = eErrorTypeInvalid; if (m_opaque_up) @@ -95,8 +93,7 @@ ErrorType SBError::GetType() const { } void SBError::SetError(uint32_t err, ErrorType type) { - LLDB_RECORD_METHOD(void, SBError, SetError, (uint32_t, lldb::ErrorType), err, - type); + LLDB_INSTRUMENT_VA(this, err, type); CreateIfNeeded(); m_opaque_up->SetError(err, type); @@ -108,21 +105,21 @@ void SBError::SetError(const Status &lldb_error) { } void SBError::SetErrorToErrno() { - LLDB_RECORD_METHOD_NO_ARGS(void, SBError, SetErrorToErrno); + LLDB_INSTRUMENT_VA(this); CreateIfNeeded(); m_opaque_up->SetErrorToErrno(); } void SBError::SetErrorToGenericError() { - LLDB_RECORD_METHOD_NO_ARGS(void, SBError, SetErrorToGenericError); + LLDB_INSTRUMENT_VA(this); CreateIfNeeded(); m_opaque_up->SetErrorToGenericError(); } void SBError::SetErrorString(const char *err_str) { - LLDB_RECORD_METHOD(void, SBError, SetErrorString, (const char *), err_str); + LLDB_INSTRUMENT_VA(this, err_str); CreateIfNeeded(); m_opaque_up->SetErrorString(err_str); @@ -138,11 +135,11 @@ int SBError::SetErrorStringWithFormat(const char *format, ...) { } bool SBError::IsValid() const { - LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBError, IsValid); + LLDB_INSTRUMENT_VA(this); return this->operator bool(); } SBError::operator bool() const { - LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBError, operator bool); + LLDB_INSTRUMENT_VA(this); return m_opaque_up != nullptr; } @@ -167,8 +164,7 @@ const lldb_private::Status &SBError::operator*() const { } bool SBError::GetDescription(SBStream &description) { - LLDB_RECORD_METHOD(bool, SBError, GetDescription, (lldb::SBStream &), - description); + LLDB_INSTRUMENT_VA(this, description); if (m_opaque_up) { if (m_opaque_up->Success()) @@ -183,30 +179,3 @@ bool SBError::GetDescription(SBStream &description) { return true; } - -namespace lldb_private { -namespace repro { - -template <> -void RegisterMethods<SBError>(Registry &R) { - LLDB_REGISTER_CONSTRUCTOR(SBError, ()); - LLDB_REGISTER_CONSTRUCTOR(SBError, (const lldb::SBError &)); - LLDB_REGISTER_METHOD(const lldb::SBError &, - SBError, operator=,(const lldb::SBError &)); - LLDB_REGISTER_METHOD_CONST(const char *, SBError, GetCString, ()); - LLDB_REGISTER_METHOD(void, SBError, Clear, ()); - LLDB_REGISTER_METHOD_CONST(bool, SBError, Fail, ()); - LLDB_REGISTER_METHOD_CONST(bool, SBError, Success, ()); - LLDB_REGISTER_METHOD_CONST(uint32_t, SBError, GetError, ()); - LLDB_REGISTER_METHOD_CONST(lldb::ErrorType, SBError, GetType, ()); - LLDB_REGISTER_METHOD(void, SBError, SetError, (uint32_t, lldb::ErrorType)); - LLDB_REGISTER_METHOD(void, SBError, SetErrorToErrno, ()); - LLDB_REGISTER_METHOD(void, SBError, SetErrorToGenericError, ()); - LLDB_REGISTER_METHOD(void, SBError, SetErrorString, (const char *)); - LLDB_REGISTER_METHOD_CONST(bool, SBError, IsValid, ()); - LLDB_REGISTER_METHOD_CONST(bool, SBError, operator bool, ()); - LLDB_REGISTER_METHOD(bool, SBError, GetDescription, (lldb::SBStream &)); -} - -} -} diff --git a/lldb/source/API/SBEvent.cpp b/lldb/source/API/SBEvent.cpp index a0b606e3812e..536680bd1c5e 100644 --- a/lldb/source/API/SBEvent.cpp +++ b/lldb/source/API/SBEvent.cpp @@ -7,9 +7,9 @@ //===----------------------------------------------------------------------===// #include "lldb/API/SBEvent.h" -#include "SBReproducerPrivate.h" #include "lldb/API/SBBroadcaster.h" #include "lldb/API/SBStream.h" +#include "lldb/Utility/Instrumentation.h" #include "lldb/Breakpoint/Breakpoint.h" #include "lldb/Core/StreamFile.h" @@ -22,44 +22,42 @@ using namespace lldb; using namespace lldb_private; -SBEvent::SBEvent() : m_event_sp() { LLDB_RECORD_CONSTRUCTOR_NO_ARGS(SBEvent); } +SBEvent::SBEvent() { LLDB_INSTRUMENT_VA(this); } SBEvent::SBEvent(uint32_t event_type, const char *cstr, uint32_t cstr_len) : m_event_sp(new Event(event_type, new EventDataBytes(cstr, cstr_len))), m_opaque_ptr(m_event_sp.get()) { - LLDB_RECORD_CONSTRUCTOR(SBEvent, (uint32_t, const char *, uint32_t), - event_type, cstr, cstr_len); + LLDB_INSTRUMENT_VA(this, event_type, cstr, cstr_len); } SBEvent::SBEvent(EventSP &event_sp) : m_event_sp(event_sp), m_opaque_ptr(event_sp.get()) { - LLDB_RECORD_CONSTRUCTOR(SBEvent, (lldb::EventSP &), event_sp); + LLDB_INSTRUMENT_VA(this, event_sp); } -SBEvent::SBEvent(Event *event_ptr) : m_event_sp(), m_opaque_ptr(event_ptr) { - LLDB_RECORD_CONSTRUCTOR(SBEvent, (lldb_private::Event *), event_ptr); +SBEvent::SBEvent(Event *event_ptr) : m_opaque_ptr(event_ptr) { + LLDB_INSTRUMENT_VA(this, event_ptr); } SBEvent::SBEvent(const SBEvent &rhs) : m_event_sp(rhs.m_event_sp), m_opaque_ptr(rhs.m_opaque_ptr) { - LLDB_RECORD_CONSTRUCTOR(SBEvent, (const lldb::SBEvent &), rhs); + LLDB_INSTRUMENT_VA(this, rhs); } const SBEvent &SBEvent::operator=(const SBEvent &rhs) { - LLDB_RECORD_METHOD(const lldb::SBEvent &, - SBEvent, operator=,(const lldb::SBEvent &), rhs); + LLDB_INSTRUMENT_VA(this, rhs); if (this != &rhs) { m_event_sp = rhs.m_event_sp; m_opaque_ptr = rhs.m_opaque_ptr; } - return LLDB_RECORD_RESULT(*this); + return *this; } SBEvent::~SBEvent() = default; const char *SBEvent::GetDataFlavor() { - LLDB_RECORD_METHOD_NO_ARGS(const char *, SBEvent, GetDataFlavor); + LLDB_INSTRUMENT_VA(this); Event *lldb_event = get(); if (lldb_event) { @@ -71,8 +69,7 @@ const char *SBEvent::GetDataFlavor() { } uint32_t SBEvent::GetType() const { - LLDB_RECORD_METHOD_CONST_NO_ARGS(uint32_t, SBEvent, GetType); - + LLDB_INSTRUMENT_VA(this); const Event *lldb_event = get(); uint32_t event_type = 0; @@ -84,18 +81,17 @@ uint32_t SBEvent::GetType() const { } SBBroadcaster SBEvent::GetBroadcaster() const { - LLDB_RECORD_METHOD_CONST_NO_ARGS(lldb::SBBroadcaster, SBEvent, - GetBroadcaster); + LLDB_INSTRUMENT_VA(this); SBBroadcaster broadcaster; const Event *lldb_event = get(); if (lldb_event) broadcaster.reset(lldb_event->GetBroadcaster(), false); - return LLDB_RECORD_RESULT(broadcaster); + return broadcaster; } const char *SBEvent::GetBroadcasterClass() const { - LLDB_RECORD_METHOD_CONST_NO_ARGS(const char *, SBEvent, GetBroadcasterClass); + LLDB_INSTRUMENT_VA(this); const Event *lldb_event = get(); if (lldb_event) @@ -105,8 +101,7 @@ const char *SBEvent::GetBroadcasterClass() const { } bool SBEvent::BroadcasterMatchesPtr(const SBBroadcaster *broadcaster) { - LLDB_RECORD_METHOD(bool, SBEvent, BroadcasterMatchesPtr, - (const lldb::SBBroadcaster *), broadcaster); + LLDB_INSTRUMENT_VA(this, broadcaster); if (broadcaster) return BroadcasterMatchesRef(*broadcaster); @@ -114,8 +109,7 @@ bool SBEvent::BroadcasterMatchesPtr(const SBBroadcaster *broadcaster) { } bool SBEvent::BroadcasterMatchesRef(const SBBroadcaster &broadcaster) { - LLDB_RECORD_METHOD(bool, SBEvent, BroadcasterMatchesRef, - (const lldb::SBBroadcaster &), broadcaster); + LLDB_INSTRUMENT_VA(this, broadcaster); Event *lldb_event = get(); bool success = false; @@ -127,7 +121,7 @@ bool SBEvent::BroadcasterMatchesRef(const SBBroadcaster &broadcaster) { } void SBEvent::Clear() { - LLDB_RECORD_METHOD_NO_ARGS(void, SBEvent, Clear); + LLDB_INSTRUMENT_VA(this); Event *lldb_event = get(); if (lldb_event) @@ -158,11 +152,11 @@ void SBEvent::reset(Event *event_ptr) { } bool SBEvent::IsValid() const { - LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBEvent, IsValid); + LLDB_INSTRUMENT_VA(this); return this->operator bool(); } SBEvent::operator bool() const { - LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBEvent, operator bool); + LLDB_INSTRUMENT_VA(this); // Do NOT use m_opaque_ptr directly!!! Must use the SBEvent::get() accessor. // See comments in SBEvent::get().... @@ -170,16 +164,14 @@ SBEvent::operator bool() const { } const char *SBEvent::GetCStringFromEvent(const SBEvent &event) { - LLDB_RECORD_STATIC_METHOD(const char *, SBEvent, GetCStringFromEvent, - (const lldb::SBEvent &), event); + LLDB_INSTRUMENT_VA(event); return static_cast<const char *>( EventDataBytes::GetBytesFromEvent(event.get())); } bool SBEvent::GetDescription(SBStream &description) { - LLDB_RECORD_METHOD(bool, SBEvent, GetDescription, (lldb::SBStream &), - description); + LLDB_INSTRUMENT_VA(this, description); Stream &strm = description.ref(); @@ -192,8 +184,7 @@ bool SBEvent::GetDescription(SBStream &description) { } bool SBEvent::GetDescription(SBStream &description) const { - LLDB_RECORD_METHOD_CONST(bool, SBEvent, GetDescription, (lldb::SBStream &), - description); + LLDB_INSTRUMENT_VA(this, description); Stream &strm = description.ref(); @@ -204,37 +195,3 @@ bool SBEvent::GetDescription(SBStream &description) const { return true; } - -namespace lldb_private { -namespace repro { - -template <> -void RegisterMethods<SBEvent>(Registry &R) { - LLDB_REGISTER_CONSTRUCTOR(SBEvent, ()); - LLDB_REGISTER_CONSTRUCTOR(SBEvent, (uint32_t, const char *, uint32_t)); - LLDB_REGISTER_CONSTRUCTOR(SBEvent, (lldb::EventSP &)); - LLDB_REGISTER_CONSTRUCTOR(SBEvent, (lldb_private::Event *)); - LLDB_REGISTER_CONSTRUCTOR(SBEvent, (const lldb::SBEvent &)); - LLDB_REGISTER_METHOD(const lldb::SBEvent &, - SBEvent, operator=,(const lldb::SBEvent &)); - LLDB_REGISTER_METHOD(const char *, SBEvent, GetDataFlavor, ()); - LLDB_REGISTER_METHOD_CONST(uint32_t, SBEvent, GetType, ()); - LLDB_REGISTER_METHOD_CONST(lldb::SBBroadcaster, SBEvent, GetBroadcaster, - ()); - LLDB_REGISTER_METHOD_CONST(const char *, SBEvent, GetBroadcasterClass, ()); - LLDB_REGISTER_METHOD(bool, SBEvent, BroadcasterMatchesPtr, - (const lldb::SBBroadcaster *)); - LLDB_REGISTER_METHOD(bool, SBEvent, BroadcasterMatchesRef, - (const lldb::SBBroadcaster &)); - LLDB_REGISTER_METHOD(void, SBEvent, Clear, ()); - LLDB_REGISTER_METHOD_CONST(bool, SBEvent, IsValid, ()); - LLDB_REGISTER_METHOD_CONST(bool, SBEvent, operator bool, ()); - LLDB_REGISTER_STATIC_METHOD(const char *, SBEvent, GetCStringFromEvent, - (const lldb::SBEvent &)); - LLDB_REGISTER_METHOD(bool, SBEvent, GetDescription, (lldb::SBStream &)); - LLDB_REGISTER_METHOD_CONST(bool, SBEvent, GetDescription, - (lldb::SBStream &)); -} - -} -} diff --git a/lldb/source/API/SBExecutionContext.cpp b/lldb/source/API/SBExecutionContext.cpp index caf02b4164ea..a0b68e6efe38 100644 --- a/lldb/source/API/SBExecutionContext.cpp +++ b/lldb/source/API/SBExecutionContext.cpp @@ -7,7 +7,7 @@ //===----------------------------------------------------------------------===// #include "lldb/API/SBExecutionContext.h" -#include "SBReproducerPrivate.h" +#include "lldb/Utility/Instrumentation.h" #include "lldb/API/SBFrame.h" #include "lldb/API/SBProcess.h" @@ -19,48 +19,43 @@ using namespace lldb; using namespace lldb_private; -SBExecutionContext::SBExecutionContext() : m_exe_ctx_sp() { - LLDB_RECORD_CONSTRUCTOR_NO_ARGS(SBExecutionContext); -} +SBExecutionContext::SBExecutionContext() { LLDB_INSTRUMENT_VA(this); } SBExecutionContext::SBExecutionContext(const lldb::SBExecutionContext &rhs) : m_exe_ctx_sp(rhs.m_exe_ctx_sp) { - LLDB_RECORD_CONSTRUCTOR(SBExecutionContext, - (const lldb::SBExecutionContext &), rhs); + LLDB_INSTRUMENT_VA(this, rhs); } SBExecutionContext::SBExecutionContext( lldb::ExecutionContextRefSP exe_ctx_ref_sp) : m_exe_ctx_sp(exe_ctx_ref_sp) { - LLDB_RECORD_CONSTRUCTOR(SBExecutionContext, (lldb::ExecutionContextRefSP), - exe_ctx_ref_sp); + LLDB_INSTRUMENT_VA(this, exe_ctx_ref_sp); } SBExecutionContext::SBExecutionContext(const lldb::SBTarget &target) : m_exe_ctx_sp(new ExecutionContextRef()) { - LLDB_RECORD_CONSTRUCTOR(SBExecutionContext, (const lldb::SBTarget &), target); + LLDB_INSTRUMENT_VA(this, target); m_exe_ctx_sp->SetTargetSP(target.GetSP()); } SBExecutionContext::SBExecutionContext(const lldb::SBProcess &process) : m_exe_ctx_sp(new ExecutionContextRef()) { - LLDB_RECORD_CONSTRUCTOR(SBExecutionContext, (const lldb::SBProcess &), - process); + LLDB_INSTRUMENT_VA(this, process); m_exe_ctx_sp->SetProcessSP(process.GetSP()); } SBExecutionContext::SBExecutionContext(lldb::SBThread thread) : m_exe_ctx_sp(new ExecutionContextRef()) { - LLDB_RECORD_CONSTRUCTOR(SBExecutionContext, (lldb::SBThread), thread); + LLDB_INSTRUMENT_VA(this, thread); m_exe_ctx_sp->SetThreadPtr(thread.get()); } SBExecutionContext::SBExecutionContext(const lldb::SBFrame &frame) : m_exe_ctx_sp(new ExecutionContextRef()) { - LLDB_RECORD_CONSTRUCTOR(SBExecutionContext, (const lldb::SBFrame &), frame); + LLDB_INSTRUMENT_VA(this, frame); m_exe_ctx_sp->SetFrameSP(frame.GetFrameSP()); } @@ -69,12 +64,10 @@ SBExecutionContext::~SBExecutionContext() = default; const SBExecutionContext &SBExecutionContext:: operator=(const lldb::SBExecutionContext &rhs) { - LLDB_RECORD_METHOD( - const lldb::SBExecutionContext &, - SBExecutionContext, operator=,(const lldb::SBExecutionContext &), rhs); + LLDB_INSTRUMENT_VA(this, rhs); m_exe_ctx_sp = rhs.m_exe_ctx_sp; - return LLDB_RECORD_RESULT(*this); + return *this; } ExecutionContextRef *SBExecutionContext::get() const { @@ -82,8 +75,7 @@ ExecutionContextRef *SBExecutionContext::get() const { } SBTarget SBExecutionContext::GetTarget() const { - LLDB_RECORD_METHOD_CONST_NO_ARGS(lldb::SBTarget, SBExecutionContext, - GetTarget); + LLDB_INSTRUMENT_VA(this); SBTarget sb_target; if (m_exe_ctx_sp) { @@ -91,12 +83,11 @@ SBTarget SBExecutionContext::GetTarget() const { if (target_sp) sb_target.SetSP(target_sp); } - return LLDB_RECORD_RESULT(sb_target); + return sb_target; } SBProcess SBExecutionContext::GetProcess() const { - LLDB_RECORD_METHOD_CONST_NO_ARGS(lldb::SBProcess, SBExecutionContext, - GetProcess); + LLDB_INSTRUMENT_VA(this); SBProcess sb_process; if (m_exe_ctx_sp) { @@ -104,12 +95,11 @@ SBProcess SBExecutionContext::GetProcess() const { if (process_sp) sb_process.SetSP(process_sp); } - return LLDB_RECORD_RESULT(sb_process); + return sb_process; } SBThread SBExecutionContext::GetThread() const { - LLDB_RECORD_METHOD_CONST_NO_ARGS(lldb::SBThread, SBExecutionContext, - GetThread); + LLDB_INSTRUMENT_VA(this); SBThread sb_thread; if (m_exe_ctx_sp) { @@ -117,11 +107,11 @@ SBThread SBExecutionContext::GetThread() const { if (thread_sp) sb_thread.SetThread(thread_sp); } - return LLDB_RECORD_RESULT(sb_thread); + return sb_thread; } SBFrame SBExecutionContext::GetFrame() const { - LLDB_RECORD_METHOD_CONST_NO_ARGS(lldb::SBFrame, SBExecutionContext, GetFrame); + LLDB_INSTRUMENT_VA(this); SBFrame sb_frame; if (m_exe_ctx_sp) { @@ -129,34 +119,5 @@ SBFrame SBExecutionContext::GetFrame() const { if (frame_sp) sb_frame.SetFrameSP(frame_sp); } - return LLDB_RECORD_RESULT(sb_frame); -} - -namespace lldb_private { -namespace repro { - -template <> -void RegisterMethods<SBExecutionContext>(Registry &R) { - LLDB_REGISTER_CONSTRUCTOR(SBExecutionContext, ()); - LLDB_REGISTER_CONSTRUCTOR(SBExecutionContext, - (const lldb::SBExecutionContext &)); - LLDB_REGISTER_CONSTRUCTOR(SBExecutionContext, - (lldb::ExecutionContextRefSP)); - LLDB_REGISTER_CONSTRUCTOR(SBExecutionContext, (const lldb::SBTarget &)); - LLDB_REGISTER_CONSTRUCTOR(SBExecutionContext, (const lldb::SBProcess &)); - LLDB_REGISTER_CONSTRUCTOR(SBExecutionContext, (lldb::SBThread)); - LLDB_REGISTER_CONSTRUCTOR(SBExecutionContext, (const lldb::SBFrame &)); - LLDB_REGISTER_METHOD( - const lldb::SBExecutionContext &, - SBExecutionContext, operator=,(const lldb::SBExecutionContext &)); - LLDB_REGISTER_METHOD_CONST(lldb::SBTarget, SBExecutionContext, GetTarget, - ()); - LLDB_REGISTER_METHOD_CONST(lldb::SBProcess, SBExecutionContext, GetProcess, - ()); - LLDB_REGISTER_METHOD_CONST(lldb::SBThread, SBExecutionContext, GetThread, - ()); - LLDB_REGISTER_METHOD_CONST(lldb::SBFrame, SBExecutionContext, GetFrame, ()); -} - -} + return sb_frame; } diff --git a/lldb/source/API/SBExpressionOptions.cpp b/lldb/source/API/SBExpressionOptions.cpp index 217e8ad5c21b..191e38fe5cfc 100644 --- a/lldb/source/API/SBExpressionOptions.cpp +++ b/lldb/source/API/SBExpressionOptions.cpp @@ -7,113 +7,99 @@ //===----------------------------------------------------------------------===// #include "lldb/API/SBExpressionOptions.h" -#include "SBReproducerPrivate.h" #include "Utils.h" #include "lldb/API/SBStream.h" #include "lldb/Target/Target.h" +#include "lldb/Utility/Instrumentation.h" using namespace lldb; using namespace lldb_private; SBExpressionOptions::SBExpressionOptions() : m_opaque_up(new EvaluateExpressionOptions()) { - LLDB_RECORD_CONSTRUCTOR_NO_ARGS(SBExpressionOptions); + LLDB_INSTRUMENT_VA(this); } -SBExpressionOptions::SBExpressionOptions(const SBExpressionOptions &rhs) - : m_opaque_up() { - LLDB_RECORD_CONSTRUCTOR(SBExpressionOptions, - (const lldb::SBExpressionOptions &), rhs); +SBExpressionOptions::SBExpressionOptions(const SBExpressionOptions &rhs) { + LLDB_INSTRUMENT_VA(this, rhs); m_opaque_up = clone(rhs.m_opaque_up); } const SBExpressionOptions &SBExpressionOptions:: operator=(const SBExpressionOptions &rhs) { - LLDB_RECORD_METHOD( - const lldb::SBExpressionOptions &, - SBExpressionOptions, operator=,(const lldb::SBExpressionOptions &), rhs); + LLDB_INSTRUMENT_VA(this, rhs); if (this != &rhs) m_opaque_up = clone(rhs.m_opaque_up); - return LLDB_RECORD_RESULT(*this); + return *this; } SBExpressionOptions::~SBExpressionOptions() = default; bool SBExpressionOptions::GetCoerceResultToId() const { - LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBExpressionOptions, - GetCoerceResultToId); + LLDB_INSTRUMENT_VA(this); return m_opaque_up->DoesCoerceToId(); } void SBExpressionOptions::SetCoerceResultToId(bool coerce) { - LLDB_RECORD_METHOD(void, SBExpressionOptions, SetCoerceResultToId, (bool), - coerce); + LLDB_INSTRUMENT_VA(this, coerce); m_opaque_up->SetCoerceToId(coerce); } bool SBExpressionOptions::GetUnwindOnError() const { - LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBExpressionOptions, GetUnwindOnError); + LLDB_INSTRUMENT_VA(this); return m_opaque_up->DoesUnwindOnError(); } void SBExpressionOptions::SetUnwindOnError(bool unwind) { - LLDB_RECORD_METHOD(void, SBExpressionOptions, SetUnwindOnError, (bool), - unwind); + LLDB_INSTRUMENT_VA(this, unwind); m_opaque_up->SetUnwindOnError(unwind); } bool SBExpressionOptions::GetIgnoreBreakpoints() const { - LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBExpressionOptions, - GetIgnoreBreakpoints); + LLDB_INSTRUMENT_VA(this); return m_opaque_up->DoesIgnoreBreakpoints(); } void SBExpressionOptions::SetIgnoreBreakpoints(bool ignore) { - LLDB_RECORD_METHOD(void, SBExpressionOptions, SetIgnoreBreakpoints, (bool), - ignore); + LLDB_INSTRUMENT_VA(this, ignore); m_opaque_up->SetIgnoreBreakpoints(ignore); } lldb::DynamicValueType SBExpressionOptions::GetFetchDynamicValue() const { - LLDB_RECORD_METHOD_CONST_NO_ARGS(lldb::DynamicValueType, SBExpressionOptions, - GetFetchDynamicValue); + LLDB_INSTRUMENT_VA(this); return m_opaque_up->GetUseDynamic(); } void SBExpressionOptions::SetFetchDynamicValue(lldb::DynamicValueType dynamic) { - LLDB_RECORD_METHOD(void, SBExpressionOptions, SetFetchDynamicValue, - (lldb::DynamicValueType), dynamic); + LLDB_INSTRUMENT_VA(this, dynamic); m_opaque_up->SetUseDynamic(dynamic); } uint32_t SBExpressionOptions::GetTimeoutInMicroSeconds() const { - LLDB_RECORD_METHOD_CONST_NO_ARGS(uint32_t, SBExpressionOptions, - GetTimeoutInMicroSeconds); + LLDB_INSTRUMENT_VA(this); return m_opaque_up->GetTimeout() ? m_opaque_up->GetTimeout()->count() : 0; } void SBExpressionOptions::SetTimeoutInMicroSeconds(uint32_t timeout) { - LLDB_RECORD_METHOD(void, SBExpressionOptions, SetTimeoutInMicroSeconds, - (uint32_t), timeout); + LLDB_INSTRUMENT_VA(this, timeout); m_opaque_up->SetTimeout(timeout == 0 ? Timeout<std::micro>(llvm::None) : std::chrono::microseconds(timeout)); } uint32_t SBExpressionOptions::GetOneThreadTimeoutInMicroSeconds() const { - LLDB_RECORD_METHOD_CONST_NO_ARGS(uint32_t, SBExpressionOptions, - GetOneThreadTimeoutInMicroSeconds); + LLDB_INSTRUMENT_VA(this); return m_opaque_up->GetOneThreadTimeout() ? m_opaque_up->GetOneThreadTimeout()->count() @@ -121,8 +107,7 @@ uint32_t SBExpressionOptions::GetOneThreadTimeoutInMicroSeconds() const { } void SBExpressionOptions::SetOneThreadTimeoutInMicroSeconds(uint32_t timeout) { - LLDB_RECORD_METHOD(void, SBExpressionOptions, - SetOneThreadTimeoutInMicroSeconds, (uint32_t), timeout); + LLDB_INSTRUMENT_VA(this, timeout); m_opaque_up->SetOneThreadTimeout(timeout == 0 ? Timeout<std::micro>(llvm::None) @@ -130,148 +115,135 @@ void SBExpressionOptions::SetOneThreadTimeoutInMicroSeconds(uint32_t timeout) { } bool SBExpressionOptions::GetTryAllThreads() const { - LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBExpressionOptions, GetTryAllThreads); + LLDB_INSTRUMENT_VA(this); return m_opaque_up->GetTryAllThreads(); } void SBExpressionOptions::SetTryAllThreads(bool run_others) { - LLDB_RECORD_METHOD(void, SBExpressionOptions, SetTryAllThreads, (bool), - run_others); + LLDB_INSTRUMENT_VA(this, run_others); m_opaque_up->SetTryAllThreads(run_others); } bool SBExpressionOptions::GetStopOthers() const { - LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBExpressionOptions, GetStopOthers); + LLDB_INSTRUMENT_VA(this); return m_opaque_up->GetStopOthers(); } void SBExpressionOptions::SetStopOthers(bool run_others) { - LLDB_RECORD_METHOD(void, SBExpressionOptions, SetStopOthers, (bool), - run_others); + LLDB_INSTRUMENT_VA(this, run_others); m_opaque_up->SetStopOthers(run_others); } bool SBExpressionOptions::GetTrapExceptions() const { - LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBExpressionOptions, - GetTrapExceptions); + LLDB_INSTRUMENT_VA(this); return m_opaque_up->GetTrapExceptions(); } void SBExpressionOptions::SetTrapExceptions(bool trap_exceptions) { - LLDB_RECORD_METHOD(void, SBExpressionOptions, SetTrapExceptions, (bool), - trap_exceptions); + LLDB_INSTRUMENT_VA(this, trap_exceptions); m_opaque_up->SetTrapExceptions(trap_exceptions); } void SBExpressionOptions::SetLanguage(lldb::LanguageType language) { - LLDB_RECORD_METHOD(void, SBExpressionOptions, SetLanguage, - (lldb::LanguageType), language); + LLDB_INSTRUMENT_VA(this, language); m_opaque_up->SetLanguage(language); } void SBExpressionOptions::SetCancelCallback( lldb::ExpressionCancelCallback callback, void *baton) { - LLDB_RECORD_DUMMY(void, SBExpressionOptions, SetCancelCallback, - (lldb::ExpressionCancelCallback, void *), callback, baton); + LLDB_INSTRUMENT_VA(this, callback, baton); m_opaque_up->SetCancelCallback(callback, baton); } bool SBExpressionOptions::GetGenerateDebugInfo() { - LLDB_RECORD_METHOD_NO_ARGS(bool, SBExpressionOptions, GetGenerateDebugInfo); + LLDB_INSTRUMENT_VA(this); return m_opaque_up->GetGenerateDebugInfo(); } void SBExpressionOptions::SetGenerateDebugInfo(bool b) { - LLDB_RECORD_METHOD(void, SBExpressionOptions, SetGenerateDebugInfo, (bool), - b); + LLDB_INSTRUMENT_VA(this, b); return m_opaque_up->SetGenerateDebugInfo(b); } bool SBExpressionOptions::GetSuppressPersistentResult() { - LLDB_RECORD_METHOD_NO_ARGS(bool, SBExpressionOptions, - GetSuppressPersistentResult); + LLDB_INSTRUMENT_VA(this); return m_opaque_up->GetResultIsInternal(); } void SBExpressionOptions::SetSuppressPersistentResult(bool b) { - LLDB_RECORD_METHOD(void, SBExpressionOptions, SetSuppressPersistentResult, - (bool), b); + LLDB_INSTRUMENT_VA(this, b); return m_opaque_up->SetResultIsInternal(b); } const char *SBExpressionOptions::GetPrefix() const { - LLDB_RECORD_METHOD_CONST_NO_ARGS(const char *, SBExpressionOptions, - GetPrefix); + LLDB_INSTRUMENT_VA(this); return m_opaque_up->GetPrefix(); } void SBExpressionOptions::SetPrefix(const char *prefix) { - LLDB_RECORD_METHOD(void, SBExpressionOptions, SetPrefix, (const char *), - prefix); + LLDB_INSTRUMENT_VA(this, prefix); return m_opaque_up->SetPrefix(prefix); } bool SBExpressionOptions::GetAutoApplyFixIts() { - LLDB_RECORD_METHOD_NO_ARGS(bool, SBExpressionOptions, GetAutoApplyFixIts); + LLDB_INSTRUMENT_VA(this); return m_opaque_up->GetAutoApplyFixIts(); } void SBExpressionOptions::SetAutoApplyFixIts(bool b) { - LLDB_RECORD_METHOD(void, SBExpressionOptions, SetAutoApplyFixIts, (bool), b); + LLDB_INSTRUMENT_VA(this, b); return m_opaque_up->SetAutoApplyFixIts(b); } uint64_t SBExpressionOptions::GetRetriesWithFixIts() { - LLDB_RECORD_METHOD_NO_ARGS(uint64_t, SBExpressionOptions, - GetRetriesWithFixIts); + LLDB_INSTRUMENT_VA(this); return m_opaque_up->GetRetriesWithFixIts(); } void SBExpressionOptions::SetRetriesWithFixIts(uint64_t retries) { - LLDB_RECORD_METHOD(void, SBExpressionOptions, SetRetriesWithFixIts, - (uint64_t), retries); + LLDB_INSTRUMENT_VA(this, retries); return m_opaque_up->SetRetriesWithFixIts(retries); } bool SBExpressionOptions::GetTopLevel() { - LLDB_RECORD_METHOD_NO_ARGS(bool, SBExpressionOptions, GetTopLevel); + LLDB_INSTRUMENT_VA(this); return m_opaque_up->GetExecutionPolicy() == eExecutionPolicyTopLevel; } void SBExpressionOptions::SetTopLevel(bool b) { - LLDB_RECORD_METHOD(void, SBExpressionOptions, SetTopLevel, (bool), b); + LLDB_INSTRUMENT_VA(this, b); m_opaque_up->SetExecutionPolicy(b ? eExecutionPolicyTopLevel : m_opaque_up->default_execution_policy); } bool SBExpressionOptions::GetAllowJIT() { - LLDB_RECORD_METHOD_NO_ARGS(bool, SBExpressionOptions, GetAllowJIT); + LLDB_INSTRUMENT_VA(this); return m_opaque_up->GetExecutionPolicy() != eExecutionPolicyNever; } void SBExpressionOptions::SetAllowJIT(bool allow) { - LLDB_RECORD_METHOD(void, SBExpressionOptions, SetAllowJIT, (bool), allow); + LLDB_INSTRUMENT_VA(this, allow); m_opaque_up->SetExecutionPolicy(allow ? m_opaque_up->default_execution_policy : eExecutionPolicyNever); @@ -284,69 +256,3 @@ EvaluateExpressionOptions *SBExpressionOptions::get() const { EvaluateExpressionOptions &SBExpressionOptions::ref() const { return *(m_opaque_up.get()); } - -namespace lldb_private { -namespace repro { - -template <> -void RegisterMethods<SBExpressionOptions>(Registry &R) { - LLDB_REGISTER_CONSTRUCTOR(SBExpressionOptions, ()); - LLDB_REGISTER_CONSTRUCTOR(SBExpressionOptions, - (const lldb::SBExpressionOptions &)); - LLDB_REGISTER_METHOD( - const lldb::SBExpressionOptions &, - SBExpressionOptions, operator=,(const lldb::SBExpressionOptions &)); - LLDB_REGISTER_METHOD_CONST(bool, SBExpressionOptions, GetCoerceResultToId, - ()); - LLDB_REGISTER_METHOD(void, SBExpressionOptions, SetCoerceResultToId, - (bool)); - LLDB_REGISTER_METHOD_CONST(bool, SBExpressionOptions, GetUnwindOnError, ()); - LLDB_REGISTER_METHOD(void, SBExpressionOptions, SetUnwindOnError, (bool)); - LLDB_REGISTER_METHOD_CONST(bool, SBExpressionOptions, GetIgnoreBreakpoints, - ()); - LLDB_REGISTER_METHOD(void, SBExpressionOptions, SetIgnoreBreakpoints, - (bool)); - LLDB_REGISTER_METHOD_CONST(lldb::DynamicValueType, SBExpressionOptions, - GetFetchDynamicValue, ()); - LLDB_REGISTER_METHOD(void, SBExpressionOptions, SetFetchDynamicValue, - (lldb::DynamicValueType)); - LLDB_REGISTER_METHOD_CONST(uint32_t, SBExpressionOptions, - GetTimeoutInMicroSeconds, ()); - LLDB_REGISTER_METHOD(void, SBExpressionOptions, SetTimeoutInMicroSeconds, - (uint32_t)); - LLDB_REGISTER_METHOD_CONST(uint32_t, SBExpressionOptions, - GetOneThreadTimeoutInMicroSeconds, ()); - LLDB_REGISTER_METHOD(void, SBExpressionOptions, - SetOneThreadTimeoutInMicroSeconds, (uint32_t)); - LLDB_REGISTER_METHOD_CONST(bool, SBExpressionOptions, GetTryAllThreads, ()); - LLDB_REGISTER_METHOD(void, SBExpressionOptions, SetTryAllThreads, (bool)); - LLDB_REGISTER_METHOD_CONST(bool, SBExpressionOptions, GetStopOthers, ()); - LLDB_REGISTER_METHOD(void, SBExpressionOptions, SetStopOthers, (bool)); - LLDB_REGISTER_METHOD_CONST(bool, SBExpressionOptions, GetTrapExceptions, - ()); - LLDB_REGISTER_METHOD(void, SBExpressionOptions, SetTrapExceptions, (bool)); - LLDB_REGISTER_METHOD(void, SBExpressionOptions, SetLanguage, - (lldb::LanguageType)); - LLDB_REGISTER_METHOD(bool, SBExpressionOptions, GetGenerateDebugInfo, ()); - LLDB_REGISTER_METHOD(void, SBExpressionOptions, SetGenerateDebugInfo, - (bool)); - LLDB_REGISTER_METHOD(bool, SBExpressionOptions, GetSuppressPersistentResult, - ()); - LLDB_REGISTER_METHOD(void, SBExpressionOptions, SetSuppressPersistentResult, - (bool)); - LLDB_REGISTER_METHOD_CONST(const char *, SBExpressionOptions, GetPrefix, - ()); - LLDB_REGISTER_METHOD(void, SBExpressionOptions, SetPrefix, (const char *)); - LLDB_REGISTER_METHOD(bool, SBExpressionOptions, GetAutoApplyFixIts, ()); - LLDB_REGISTER_METHOD(void, SBExpressionOptions, SetAutoApplyFixIts, (bool)); - LLDB_REGISTER_METHOD(bool, SBExpressionOptions, GetTopLevel, ()); - LLDB_REGISTER_METHOD(void, SBExpressionOptions, SetTopLevel, (bool)); - LLDB_REGISTER_METHOD(bool, SBExpressionOptions, GetAllowJIT, ()); - LLDB_REGISTER_METHOD(void, SBExpressionOptions, SetAllowJIT, (bool)); - LLDB_REGISTER_METHOD(uint64_t, SBExpressionOptions, GetRetriesWithFixIts, ()); - LLDB_REGISTER_METHOD(void, SBExpressionOptions, SetRetriesWithFixIts, - (uint64_t)); -} - -} -} diff --git a/lldb/source/API/SBFile.cpp b/lldb/source/API/SBFile.cpp index 41ccdbe76b91..0db859c3b746 100644 --- a/lldb/source/API/SBFile.cpp +++ b/lldb/source/API/SBFile.cpp @@ -7,9 +7,9 @@ //===----------------------------------------------------------------------===// #include "lldb/API/SBFile.h" -#include "SBReproducerPrivate.h" #include "lldb/API/SBError.h" #include "lldb/Host/File.h" +#include "lldb/Utility/Instrumentation.h" using namespace lldb; using namespace lldb_private; @@ -19,33 +19,31 @@ SBFile::~SBFile() = default; SBFile::SBFile(FileSP file_sp) : m_opaque_sp(file_sp) { // We have no way to capture the incoming FileSP as the class isn't // instrumented, so pretend that it's always null. - LLDB_RECORD_CONSTRUCTOR(SBFile, (lldb::FileSP), nullptr); + LLDB_INSTRUMENT_VA(this, file_sp); } SBFile::SBFile(const SBFile &rhs) : m_opaque_sp(rhs.m_opaque_sp) { - LLDB_RECORD_CONSTRUCTOR(SBFile, (const lldb::SBFile&), rhs); + LLDB_INSTRUMENT_VA(this, rhs); } SBFile &SBFile ::operator=(const SBFile &rhs) { - LLDB_RECORD_METHOD(lldb::SBFile &, - SBFile, operator=,(const lldb::SBFile &), rhs); + LLDB_INSTRUMENT_VA(this, rhs); if (this != &rhs) m_opaque_sp = rhs.m_opaque_sp; - return LLDB_RECORD_RESULT(*this); + return *this; } -SBFile::SBFile() { LLDB_RECORD_CONSTRUCTOR_NO_ARGS(SBFile); } +SBFile::SBFile() { LLDB_INSTRUMENT_VA(this); } SBFile::SBFile(FILE *file, bool transfer_ownership) { - LLDB_RECORD_CONSTRUCTOR(SBFile, (FILE *, bool), file, transfer_ownership); + LLDB_INSTRUMENT_VA(this, file, transfer_ownership); m_opaque_sp = std::make_shared<NativeFile>(file, transfer_ownership); } SBFile::SBFile(int fd, const char *mode, bool transfer_owndership) { - LLDB_RECORD_CONSTRUCTOR(SBFile, (int, const char *, bool), fd, mode, - transfer_owndership); + LLDB_INSTRUMENT_VA(this, fd, mode, transfer_owndership); auto options = File::GetOptionsFromMode(mode); if (!options) { @@ -57,8 +55,7 @@ SBFile::SBFile(int fd, const char *mode, bool transfer_owndership) { } SBError SBFile::Read(uint8_t *buf, size_t num_bytes, size_t *bytes_read) { - LLDB_RECORD_METHOD(lldb::SBError, SBFile, Read, (uint8_t *, size_t, size_t *), - buf, num_bytes, bytes_read); + LLDB_INSTRUMENT_VA(this, buf, num_bytes, bytes_read); SBError error; if (!m_opaque_sp) { @@ -69,14 +66,12 @@ SBError SBFile::Read(uint8_t *buf, size_t num_bytes, size_t *bytes_read) { error.SetError(status); *bytes_read = num_bytes; } - return LLDB_RECORD_RESULT(error); + return error; } SBError SBFile::Write(const uint8_t *buf, size_t num_bytes, size_t *bytes_written) { - LLDB_RECORD_METHOD(lldb::SBError, SBFile, Write, - (const uint8_t *, size_t, size_t *), buf, num_bytes, - bytes_written); + LLDB_INSTRUMENT_VA(this, buf, num_bytes, bytes_written); SBError error; if (!m_opaque_sp) { @@ -87,11 +82,11 @@ SBError SBFile::Write(const uint8_t *buf, size_t num_bytes, error.SetError(status); *bytes_written = num_bytes; } - return LLDB_RECORD_RESULT(error); + return error; } SBError SBFile::Flush() { - LLDB_RECORD_METHOD_NO_ARGS(lldb::SBError, SBFile, Flush); + LLDB_INSTRUMENT_VA(this); SBError error; if (!m_opaque_sp) { @@ -100,59 +95,35 @@ SBError SBFile::Flush() { Status status = m_opaque_sp->Flush(); error.SetError(status); } - return LLDB_RECORD_RESULT(error); + return error; } bool SBFile::IsValid() const { - LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBFile, IsValid); + LLDB_INSTRUMENT_VA(this); return m_opaque_sp && m_opaque_sp->IsValid(); } SBError SBFile::Close() { - LLDB_RECORD_METHOD_NO_ARGS(lldb::SBError, SBFile, Close); + LLDB_INSTRUMENT_VA(this); SBError error; if (m_opaque_sp) { Status status = m_opaque_sp->Close(); error.SetError(status); } - return LLDB_RECORD_RESULT(error); + return error; } SBFile::operator bool() const { - LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBFile, operator bool); + LLDB_INSTRUMENT_VA(this); return IsValid(); } bool SBFile::operator!() const { - LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBFile, operator!); + LLDB_INSTRUMENT_VA(this); return !IsValid(); } FileSP SBFile::GetFile() const { - LLDB_RECORD_METHOD_CONST_NO_ARGS(FileSP, SBFile, GetFile); - return LLDB_RECORD_RESULT(m_opaque_sp); + LLDB_INSTRUMENT_VA(this); + return m_opaque_sp; } - -namespace lldb_private { -namespace repro { - -template <> void RegisterMethods<SBFile>(Registry &R) { - LLDB_REGISTER_CONSTRUCTOR(SBFile, ()); - LLDB_REGISTER_CONSTRUCTOR(SBFile, (FileSP)); - LLDB_REGISTER_CONSTRUCTOR(SBFile, (const SBFile&)); - LLDB_REGISTER_CONSTRUCTOR(SBFile, (FILE *, bool)); - LLDB_REGISTER_CONSTRUCTOR(SBFile, (int, const char *, bool)); - LLDB_REGISTER_METHOD(SBFile&, SBFile, operator=,(const SBFile&)); - LLDB_REGISTER_METHOD(lldb::SBError, SBFile, Flush, ()); - LLDB_REGISTER_METHOD(lldb::SBError, SBFile, Read, - (uint8_t *, size_t, size_t *)); - LLDB_REGISTER_METHOD(lldb::SBError, SBFile, Write, - (const uint8_t *, size_t, size_t *)); - LLDB_REGISTER_METHOD_CONST(bool, SBFile, IsValid, ()); - LLDB_REGISTER_METHOD_CONST(bool, SBFile, operator bool,()); - LLDB_REGISTER_METHOD_CONST(bool, SBFile, operator!,()); - LLDB_REGISTER_METHOD_CONST(FileSP, SBFile, GetFile, ()); - LLDB_REGISTER_METHOD(lldb::SBError, SBFile, Close, ()); -} -} // namespace repro -} // namespace lldb_private diff --git a/lldb/source/API/SBFileSpec.cpp b/lldb/source/API/SBFileSpec.cpp index 0a6b63bb460c..2bec9a7a1e77 100644 --- a/lldb/source/API/SBFileSpec.cpp +++ b/lldb/source/API/SBFileSpec.cpp @@ -7,12 +7,12 @@ //===----------------------------------------------------------------------===// #include "lldb/API/SBFileSpec.h" -#include "SBReproducerPrivate.h" #include "Utils.h" #include "lldb/API/SBStream.h" #include "lldb/Host/FileSystem.h" #include "lldb/Host/PosixApi.h" #include "lldb/Utility/FileSpec.h" +#include "lldb/Utility/Instrumentation.h" #include "lldb/Utility/Stream.h" #include "llvm/ADT/SmallString.h" @@ -24,11 +24,11 @@ using namespace lldb; using namespace lldb_private; SBFileSpec::SBFileSpec() : m_opaque_up(new lldb_private::FileSpec()) { - LLDB_RECORD_CONSTRUCTOR_NO_ARGS(SBFileSpec); + LLDB_INSTRUMENT_VA(this); } -SBFileSpec::SBFileSpec(const SBFileSpec &rhs) : m_opaque_up() { - LLDB_RECORD_CONSTRUCTOR(SBFileSpec, (const lldb::SBFileSpec &), rhs); +SBFileSpec::SBFileSpec(const SBFileSpec &rhs) { + LLDB_INSTRUMENT_VA(this, rhs); m_opaque_up = clone(rhs.m_opaque_up); } @@ -38,14 +38,14 @@ SBFileSpec::SBFileSpec(const lldb_private::FileSpec &fspec) // Deprecated!!! SBFileSpec::SBFileSpec(const char *path) : m_opaque_up(new FileSpec(path)) { - LLDB_RECORD_CONSTRUCTOR(SBFileSpec, (const char *), path); + LLDB_INSTRUMENT_VA(this, path); FileSystem::Instance().Resolve(*m_opaque_up); } SBFileSpec::SBFileSpec(const char *path, bool resolve) : m_opaque_up(new FileSpec(path)) { - LLDB_RECORD_CONSTRUCTOR(SBFileSpec, (const char *, bool), path, resolve); + LLDB_INSTRUMENT_VA(this, path, resolve); if (resolve) FileSystem::Instance().Resolve(*m_opaque_up); @@ -54,55 +54,50 @@ SBFileSpec::SBFileSpec(const char *path, bool resolve) SBFileSpec::~SBFileSpec() = default; const SBFileSpec &SBFileSpec::operator=(const SBFileSpec &rhs) { - LLDB_RECORD_METHOD(const lldb::SBFileSpec &, - SBFileSpec, operator=,(const lldb::SBFileSpec &), rhs); + LLDB_INSTRUMENT_VA(this, rhs); if (this != &rhs) m_opaque_up = clone(rhs.m_opaque_up); - return LLDB_RECORD_RESULT(*this); + return *this; } bool SBFileSpec::operator==(const SBFileSpec &rhs) const { - LLDB_RECORD_METHOD_CONST(bool, SBFileSpec, operator==,(const SBFileSpec &rhs), - rhs); + LLDB_INSTRUMENT_VA(this, rhs); return ref() == rhs.ref(); } bool SBFileSpec::operator!=(const SBFileSpec &rhs) const { - LLDB_RECORD_METHOD_CONST(bool, SBFileSpec, operator!=,(const SBFileSpec &rhs), - rhs); + LLDB_INSTRUMENT_VA(this, rhs); return !(*this == rhs); } bool SBFileSpec::IsValid() const { - LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBFileSpec, IsValid); + LLDB_INSTRUMENT_VA(this); return this->operator bool(); } SBFileSpec::operator bool() const { - LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBFileSpec, operator bool); + LLDB_INSTRUMENT_VA(this); return m_opaque_up->operator bool(); } bool SBFileSpec::Exists() const { - LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBFileSpec, Exists); + LLDB_INSTRUMENT_VA(this); return FileSystem::Instance().Exists(*m_opaque_up); } bool SBFileSpec::ResolveExecutableLocation() { - LLDB_RECORD_METHOD_NO_ARGS(bool, SBFileSpec, ResolveExecutableLocation); + LLDB_INSTRUMENT_VA(this); return FileSystem::Instance().ResolveExecutableLocation(*m_opaque_up); } int SBFileSpec::ResolvePath(const char *src_path, char *dst_path, size_t dst_len) { - LLDB_RECORD_STATIC_METHOD(int, SBFileSpec, ResolvePath, - (const char *, char *, size_t), src_path, dst_path, - dst_len); + LLDB_INSTRUMENT_VA(src_path, dst_path, dst_len); llvm::SmallString<64> result(src_path); FileSystem::Instance().Resolve(result); @@ -111,13 +106,13 @@ int SBFileSpec::ResolvePath(const char *src_path, char *dst_path, } const char *SBFileSpec::GetFilename() const { - LLDB_RECORD_METHOD_CONST_NO_ARGS(const char *, SBFileSpec, GetFilename); + LLDB_INSTRUMENT_VA(this); return m_opaque_up->GetFilename().AsCString(); } const char *SBFileSpec::GetDirectory() const { - LLDB_RECORD_METHOD_CONST_NO_ARGS(const char *, SBFileSpec, GetDirectory); + LLDB_INSTRUMENT_VA(this); FileSpec directory{*m_opaque_up}; directory.GetFilename().Clear(); @@ -125,7 +120,7 @@ const char *SBFileSpec::GetDirectory() const { } void SBFileSpec::SetFilename(const char *filename) { - LLDB_RECORD_METHOD(void, SBFileSpec, SetFilename, (const char *), filename); + LLDB_INSTRUMENT_VA(this, filename); if (filename && filename[0]) m_opaque_up->GetFilename().SetCString(filename); @@ -134,7 +129,7 @@ void SBFileSpec::SetFilename(const char *filename) { } void SBFileSpec::SetDirectory(const char *directory) { - LLDB_RECORD_METHOD(void, SBFileSpec, SetDirectory, (const char *), directory); + LLDB_INSTRUMENT_VA(this, directory); if (directory && directory[0]) m_opaque_up->GetDirectory().SetCString(directory); @@ -143,8 +138,7 @@ void SBFileSpec::SetDirectory(const char *directory) { } uint32_t SBFileSpec::GetPath(char *dst_path, size_t dst_len) const { - LLDB_RECORD_CHAR_PTR_METHOD_CONST(uint32_t, SBFileSpec, GetPath, - (char *, size_t), dst_path, "", dst_len); + LLDB_INSTRUMENT_VA(this, dst_path, dst_len); uint32_t result = m_opaque_up->GetPath(dst_path, dst_len); @@ -172,8 +166,7 @@ void SBFileSpec::SetFileSpec(const lldb_private::FileSpec &fs) { } bool SBFileSpec::GetDescription(SBStream &description) const { - LLDB_RECORD_METHOD_CONST(bool, SBFileSpec, GetDescription, (lldb::SBStream &), - description); + LLDB_INSTRUMENT_VA(this, description); Stream &strm = description.ref(); char path[PATH_MAX]; @@ -183,41 +176,7 @@ bool SBFileSpec::GetDescription(SBStream &description) const { } void SBFileSpec::AppendPathComponent(const char *fn) { - LLDB_RECORD_METHOD(void, SBFileSpec, AppendPathComponent, (const char *), fn); + LLDB_INSTRUMENT_VA(this, fn); m_opaque_up->AppendPathComponent(fn); } - -namespace lldb_private { -namespace repro { - -template <> -void RegisterMethods<SBFileSpec>(Registry &R) { - LLDB_REGISTER_CONSTRUCTOR(SBFileSpec, ()); - LLDB_REGISTER_CONSTRUCTOR(SBFileSpec, (const lldb::SBFileSpec &)); - LLDB_REGISTER_CONSTRUCTOR(SBFileSpec, (const char *)); - LLDB_REGISTER_CONSTRUCTOR(SBFileSpec, (const char *, bool)); - LLDB_REGISTER_METHOD(const lldb::SBFileSpec &, - SBFileSpec, operator=,(const lldb::SBFileSpec &)); - LLDB_REGISTER_METHOD_CONST(bool, - SBFileSpec, operator==,(const lldb::SBFileSpec &)); - LLDB_REGISTER_METHOD_CONST(bool, - SBFileSpec, operator!=,(const lldb::SBFileSpec &)); - LLDB_REGISTER_METHOD_CONST(bool, SBFileSpec, IsValid, ()); - LLDB_REGISTER_METHOD_CONST(bool, SBFileSpec, operator bool, ()); - LLDB_REGISTER_METHOD_CONST(bool, SBFileSpec, Exists, ()); - LLDB_REGISTER_METHOD(bool, SBFileSpec, ResolveExecutableLocation, ()); - LLDB_REGISTER_STATIC_METHOD(int, SBFileSpec, ResolvePath, - (const char *, char *, size_t)); - LLDB_REGISTER_METHOD_CONST(const char *, SBFileSpec, GetFilename, ()); - LLDB_REGISTER_METHOD_CONST(const char *, SBFileSpec, GetDirectory, ()); - LLDB_REGISTER_METHOD(void, SBFileSpec, SetFilename, (const char *)); - LLDB_REGISTER_METHOD(void, SBFileSpec, SetDirectory, (const char *)); - LLDB_REGISTER_METHOD_CONST(bool, SBFileSpec, GetDescription, - (lldb::SBStream &)); - LLDB_REGISTER_METHOD(void, SBFileSpec, AppendPathComponent, (const char *)); - LLDB_REGISTER_CHAR_PTR_METHOD_CONST(uint32_t, SBFileSpec, GetPath); -} - -} -} diff --git a/lldb/source/API/SBFileSpecList.cpp b/lldb/source/API/SBFileSpecList.cpp index 768ff0affd15..cf81c4234087 100644 --- a/lldb/source/API/SBFileSpecList.cpp +++ b/lldb/source/API/SBFileSpecList.cpp @@ -7,13 +7,13 @@ //===----------------------------------------------------------------------===// #include "lldb/API/SBFileSpecList.h" -#include "SBReproducerPrivate.h" #include "Utils.h" #include "lldb/API/SBFileSpec.h" #include "lldb/API/SBStream.h" #include "lldb/Core/FileSpecList.h" #include "lldb/Host/PosixApi.h" #include "lldb/Utility/FileSpec.h" +#include "lldb/Utility/Instrumentation.h" #include "lldb/Utility/Stream.h" #include <climits> @@ -22,12 +22,11 @@ using namespace lldb; using namespace lldb_private; SBFileSpecList::SBFileSpecList() : m_opaque_up(new FileSpecList()) { - LLDB_RECORD_CONSTRUCTOR_NO_ARGS(SBFileSpecList); + LLDB_INSTRUMENT_VA(this); } -SBFileSpecList::SBFileSpecList(const SBFileSpecList &rhs) : m_opaque_up() { - LLDB_RECORD_CONSTRUCTOR(SBFileSpecList, (const lldb::SBFileSpecList &), rhs); - +SBFileSpecList::SBFileSpecList(const SBFileSpecList &rhs) { + LLDB_INSTRUMENT_VA(this, rhs); m_opaque_up = clone(rhs.m_opaque_up); } @@ -35,57 +34,50 @@ SBFileSpecList::SBFileSpecList(const SBFileSpecList &rhs) : m_opaque_up() { SBFileSpecList::~SBFileSpecList() = default; const SBFileSpecList &SBFileSpecList::operator=(const SBFileSpecList &rhs) { - LLDB_RECORD_METHOD(const lldb::SBFileSpecList &, - SBFileSpecList, operator=,(const lldb::SBFileSpecList &), - rhs); + LLDB_INSTRUMENT_VA(this, rhs); if (this != &rhs) m_opaque_up = clone(rhs.m_opaque_up); - return LLDB_RECORD_RESULT(*this); + return *this; } uint32_t SBFileSpecList::GetSize() const { - LLDB_RECORD_METHOD_CONST_NO_ARGS(uint32_t, SBFileSpecList, GetSize); + LLDB_INSTRUMENT_VA(this); return m_opaque_up->GetSize(); } void SBFileSpecList::Append(const SBFileSpec &sb_file) { - LLDB_RECORD_METHOD(void, SBFileSpecList, Append, (const lldb::SBFileSpec &), - sb_file); + LLDB_INSTRUMENT_VA(this, sb_file); m_opaque_up->Append(sb_file.ref()); } bool SBFileSpecList::AppendIfUnique(const SBFileSpec &sb_file) { - LLDB_RECORD_METHOD(bool, SBFileSpecList, AppendIfUnique, - (const lldb::SBFileSpec &), sb_file); + LLDB_INSTRUMENT_VA(this, sb_file); return m_opaque_up->AppendIfUnique(sb_file.ref()); } void SBFileSpecList::Clear() { - LLDB_RECORD_METHOD_NO_ARGS(void, SBFileSpecList, Clear); + LLDB_INSTRUMENT_VA(this); m_opaque_up->Clear(); } uint32_t SBFileSpecList::FindFileIndex(uint32_t idx, const SBFileSpec &sb_file, bool full) { - LLDB_RECORD_METHOD(uint32_t, SBFileSpecList, FindFileIndex, - (uint32_t, const lldb::SBFileSpec &, bool), idx, sb_file, - full); + LLDB_INSTRUMENT_VA(this, idx, sb_file, full); return m_opaque_up->FindFileIndex(idx, sb_file.ref(), full); } const SBFileSpec SBFileSpecList::GetFileSpecAtIndex(uint32_t idx) const { - LLDB_RECORD_METHOD_CONST(const lldb::SBFileSpec, SBFileSpecList, - GetFileSpecAtIndex, (uint32_t), idx); + LLDB_INSTRUMENT_VA(this, idx); SBFileSpec new_spec; new_spec.SetFileSpec(m_opaque_up->GetFileSpecAtIndex(idx)); - return LLDB_RECORD_RESULT(new_spec); + return new_spec; } const lldb_private::FileSpecList *SBFileSpecList::operator->() const { @@ -105,8 +97,7 @@ const lldb_private::FileSpecList &SBFileSpecList::ref() const { } bool SBFileSpecList::GetDescription(SBStream &description) const { - LLDB_RECORD_METHOD_CONST(bool, SBFileSpecList, GetDescription, - (lldb::SBStream &), description); + LLDB_INSTRUMENT_VA(this, description); Stream &strm = description.ref(); @@ -123,30 +114,3 @@ bool SBFileSpecList::GetDescription(SBStream &description) const { return true; } - -namespace lldb_private { -namespace repro { - -template <> -void RegisterMethods<SBFileSpecList>(Registry &R) { - LLDB_REGISTER_CONSTRUCTOR(SBFileSpecList, ()); - LLDB_REGISTER_CONSTRUCTOR(SBFileSpecList, (const lldb::SBFileSpecList &)); - LLDB_REGISTER_METHOD( - const lldb::SBFileSpecList &, - SBFileSpecList, operator=,(const lldb::SBFileSpecList &)); - LLDB_REGISTER_METHOD_CONST(uint32_t, SBFileSpecList, GetSize, ()); - LLDB_REGISTER_METHOD(void, SBFileSpecList, Append, - (const lldb::SBFileSpec &)); - LLDB_REGISTER_METHOD(bool, SBFileSpecList, AppendIfUnique, - (const lldb::SBFileSpec &)); - LLDB_REGISTER_METHOD(void, SBFileSpecList, Clear, ()); - LLDB_REGISTER_METHOD(uint32_t, SBFileSpecList, FindFileIndex, - (uint32_t, const lldb::SBFileSpec &, bool)); - LLDB_REGISTER_METHOD_CONST(const lldb::SBFileSpec, SBFileSpecList, - GetFileSpecAtIndex, (uint32_t)); - LLDB_REGISTER_METHOD_CONST(bool, SBFileSpecList, GetDescription, - (lldb::SBStream &)); -} - -} -} diff --git a/lldb/source/API/SBFrame.cpp b/lldb/source/API/SBFrame.cpp index c6bc3288c4b2..ffbbed00f8e2 100644 --- a/lldb/source/API/SBFrame.cpp +++ b/lldb/source/API/SBFrame.cpp @@ -14,7 +14,6 @@ #include "lldb/lldb-types.h" -#include "SBReproducerPrivate.h" #include "Utils.h" #include "lldb/Core/Address.h" #include "lldb/Core/StreamFile.h" @@ -38,6 +37,7 @@ #include "lldb/Target/Target.h" #include "lldb/Target/Thread.h" #include "lldb/Utility/ConstString.h" +#include "lldb/Utility/Instrumentation.h" #include "lldb/Utility/Stream.h" #include "lldb/API/SBAddress.h" @@ -55,17 +55,16 @@ using namespace lldb; using namespace lldb_private; SBFrame::SBFrame() : m_opaque_sp(new ExecutionContextRef()) { - LLDB_RECORD_CONSTRUCTOR_NO_ARGS(SBFrame); + LLDB_INSTRUMENT_VA(this); } SBFrame::SBFrame(const StackFrameSP &lldb_object_sp) : m_opaque_sp(new ExecutionContextRef(lldb_object_sp)) { - LLDB_RECORD_CONSTRUCTOR(SBFrame, (const lldb::StackFrameSP &), - lldb_object_sp); + LLDB_INSTRUMENT_VA(this, lldb_object_sp); } -SBFrame::SBFrame(const SBFrame &rhs) : m_opaque_sp() { - LLDB_RECORD_CONSTRUCTOR(SBFrame, (const lldb::SBFrame &), rhs); +SBFrame::SBFrame(const SBFrame &rhs) { + LLDB_INSTRUMENT_VA(this, rhs); m_opaque_sp = clone(rhs.m_opaque_sp); } @@ -73,12 +72,11 @@ SBFrame::SBFrame(const SBFrame &rhs) : m_opaque_sp() { SBFrame::~SBFrame() = default; const SBFrame &SBFrame::operator=(const SBFrame &rhs) { - LLDB_RECORD_METHOD(const lldb::SBFrame &, - SBFrame, operator=,(const lldb::SBFrame &), rhs); + LLDB_INSTRUMENT_VA(this, rhs); if (this != &rhs) m_opaque_sp = clone(rhs.m_opaque_sp); - return LLDB_RECORD_RESULT(*this); + return *this; } StackFrameSP SBFrame::GetFrameSP() const { @@ -90,11 +88,11 @@ void SBFrame::SetFrameSP(const StackFrameSP &lldb_object_sp) { } bool SBFrame::IsValid() const { - LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBFrame, IsValid); + LLDB_INSTRUMENT_VA(this); return this->operator bool(); } SBFrame::operator bool() const { - LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBFrame, operator bool); + LLDB_INSTRUMENT_VA(this); std::unique_lock<std::recursive_mutex> lock; ExecutionContext exe_ctx(m_opaque_sp.get(), lock); @@ -112,8 +110,7 @@ SBFrame::operator bool() const { } SBSymbolContext SBFrame::GetSymbolContext(uint32_t resolve_scope) const { - LLDB_RECORD_METHOD_CONST(lldb::SBSymbolContext, SBFrame, GetSymbolContext, - (uint32_t), resolve_scope); + LLDB_INSTRUMENT_VA(this, resolve_scope); SBSymbolContext sb_sym_ctx; std::unique_lock<std::recursive_mutex> lock; @@ -129,11 +126,11 @@ SBSymbolContext SBFrame::GetSymbolContext(uint32_t resolve_scope) const { } } - return LLDB_RECORD_RESULT(sb_sym_ctx); + return sb_sym_ctx; } SBModule SBFrame::GetModule() const { - LLDB_RECORD_METHOD_CONST_NO_ARGS(lldb::SBModule, SBFrame, GetModule); + LLDB_INSTRUMENT_VA(this); SBModule sb_module; ModuleSP module_sp; @@ -154,12 +151,11 @@ SBModule SBFrame::GetModule() const { } } - return LLDB_RECORD_RESULT(sb_module); + return sb_module; } SBCompileUnit SBFrame::GetCompileUnit() const { - LLDB_RECORD_METHOD_CONST_NO_ARGS(lldb::SBCompileUnit, SBFrame, - GetCompileUnit); + LLDB_INSTRUMENT_VA(this); SBCompileUnit sb_comp_unit; std::unique_lock<std::recursive_mutex> lock; @@ -179,11 +175,11 @@ SBCompileUnit SBFrame::GetCompileUnit() const { } } - return LLDB_RECORD_RESULT(sb_comp_unit); + return sb_comp_unit; } SBFunction SBFrame::GetFunction() const { - LLDB_RECORD_METHOD_CONST_NO_ARGS(lldb::SBFunction, SBFrame, GetFunction); + LLDB_INSTRUMENT_VA(this); SBFunction sb_function; std::unique_lock<std::recursive_mutex> lock; @@ -203,11 +199,11 @@ SBFunction SBFrame::GetFunction() const { } } - return LLDB_RECORD_RESULT(sb_function); + return sb_function; } SBSymbol SBFrame::GetSymbol() const { - LLDB_RECORD_METHOD_CONST_NO_ARGS(lldb::SBSymbol, SBFrame, GetSymbol); + LLDB_INSTRUMENT_VA(this); SBSymbol sb_symbol; std::unique_lock<std::recursive_mutex> lock; @@ -226,11 +222,11 @@ SBSymbol SBFrame::GetSymbol() const { } } - return LLDB_RECORD_RESULT(sb_symbol); + return sb_symbol; } SBBlock SBFrame::GetBlock() const { - LLDB_RECORD_METHOD_CONST_NO_ARGS(lldb::SBBlock, SBFrame, GetBlock); + LLDB_INSTRUMENT_VA(this); SBBlock sb_block; std::unique_lock<std::recursive_mutex> lock; @@ -247,11 +243,11 @@ SBBlock SBFrame::GetBlock() const { sb_block.SetPtr(frame->GetSymbolContext(eSymbolContextBlock).block); } } - return LLDB_RECORD_RESULT(sb_block); + return sb_block; } SBBlock SBFrame::GetFrameBlock() const { - LLDB_RECORD_METHOD_CONST_NO_ARGS(lldb::SBBlock, SBFrame, GetFrameBlock); + LLDB_INSTRUMENT_VA(this); SBBlock sb_block; std::unique_lock<std::recursive_mutex> lock; @@ -268,11 +264,11 @@ SBBlock SBFrame::GetFrameBlock() const { sb_block.SetPtr(frame->GetFrameBlock()); } } - return LLDB_RECORD_RESULT(sb_block); + return sb_block; } SBLineEntry SBFrame::GetLineEntry() const { - LLDB_RECORD_METHOD_CONST_NO_ARGS(lldb::SBLineEntry, SBFrame, GetLineEntry); + LLDB_INSTRUMENT_VA(this); SBLineEntry sb_line_entry; std::unique_lock<std::recursive_mutex> lock; @@ -291,11 +287,11 @@ SBLineEntry SBFrame::GetLineEntry() const { } } } - return LLDB_RECORD_RESULT(sb_line_entry); + return sb_line_entry; } uint32_t SBFrame::GetFrameID() const { - LLDB_RECORD_METHOD_CONST_NO_ARGS(uint32_t, SBFrame, GetFrameID); + LLDB_INSTRUMENT_VA(this); uint32_t frame_idx = UINT32_MAX; @@ -310,7 +306,7 @@ uint32_t SBFrame::GetFrameID() const { } lldb::addr_t SBFrame::GetCFA() const { - LLDB_RECORD_METHOD_CONST_NO_ARGS(lldb::addr_t, SBFrame, GetCFA); + LLDB_INSTRUMENT_VA(this); std::unique_lock<std::recursive_mutex> lock; ExecutionContext exe_ctx(m_opaque_sp.get(), lock); @@ -322,7 +318,7 @@ lldb::addr_t SBFrame::GetCFA() const { } addr_t SBFrame::GetPC() const { - LLDB_RECORD_METHOD_CONST_NO_ARGS(lldb::addr_t, SBFrame, GetPC); + LLDB_INSTRUMENT_VA(this); addr_t addr = LLDB_INVALID_ADDRESS; std::unique_lock<std::recursive_mutex> lock; @@ -346,7 +342,7 @@ addr_t SBFrame::GetPC() const { } bool SBFrame::SetPC(addr_t new_pc) { - LLDB_RECORD_METHOD(bool, SBFrame, SetPC, (lldb::addr_t), new_pc); + LLDB_INSTRUMENT_VA(this, new_pc); bool ret_val = false; std::unique_lock<std::recursive_mutex> lock; @@ -369,7 +365,7 @@ bool SBFrame::SetPC(addr_t new_pc) { } addr_t SBFrame::GetSP() const { - LLDB_RECORD_METHOD_CONST_NO_ARGS(lldb::addr_t, SBFrame, GetSP); + LLDB_INSTRUMENT_VA(this); addr_t addr = LLDB_INVALID_ADDRESS; std::unique_lock<std::recursive_mutex> lock; @@ -392,7 +388,7 @@ addr_t SBFrame::GetSP() const { } addr_t SBFrame::GetFP() const { - LLDB_RECORD_METHOD_CONST_NO_ARGS(lldb::addr_t, SBFrame, GetFP); + LLDB_INSTRUMENT_VA(this); addr_t addr = LLDB_INVALID_ADDRESS; std::unique_lock<std::recursive_mutex> lock; @@ -415,7 +411,7 @@ addr_t SBFrame::GetFP() const { } SBAddress SBFrame::GetPCAddress() const { - LLDB_RECORD_METHOD_CONST_NO_ARGS(lldb::SBAddress, SBFrame, GetPCAddress); + LLDB_INSTRUMENT_VA(this); SBAddress sb_addr; std::unique_lock<std::recursive_mutex> lock; @@ -432,18 +428,17 @@ SBAddress SBFrame::GetPCAddress() const { sb_addr.SetAddress(frame->GetFrameCodeAddress()); } } - return LLDB_RECORD_RESULT(sb_addr); + return sb_addr; } void SBFrame::Clear() { - LLDB_RECORD_METHOD_NO_ARGS(void, SBFrame, Clear); + LLDB_INSTRUMENT_VA(this); m_opaque_sp->Clear(); } lldb::SBValue SBFrame::GetValueForVariablePath(const char *var_path) { - LLDB_RECORD_METHOD(lldb::SBValue, SBFrame, GetValueForVariablePath, - (const char *), var_path); + LLDB_INSTRUMENT_VA(this, var_path); SBValue sb_value; std::unique_lock<std::recursive_mutex> lock; @@ -456,18 +451,16 @@ lldb::SBValue SBFrame::GetValueForVariablePath(const char *var_path) { frame->CalculateTarget()->GetPreferDynamicValue(); sb_value = GetValueForVariablePath(var_path, use_dynamic); } - return LLDB_RECORD_RESULT(sb_value); + return sb_value; } lldb::SBValue SBFrame::GetValueForVariablePath(const char *var_path, DynamicValueType use_dynamic) { - LLDB_RECORD_METHOD(lldb::SBValue, SBFrame, GetValueForVariablePath, - (const char *, lldb::DynamicValueType), var_path, - use_dynamic); + LLDB_INSTRUMENT_VA(this, var_path, use_dynamic); SBValue sb_value; if (var_path == nullptr || var_path[0] == '\0') { - return LLDB_RECORD_RESULT(sb_value); + return sb_value; } std::unique_lock<std::recursive_mutex> lock; @@ -492,12 +485,11 @@ lldb::SBValue SBFrame::GetValueForVariablePath(const char *var_path, } } } - return LLDB_RECORD_RESULT(sb_value); + return sb_value; } SBValue SBFrame::FindVariable(const char *name) { - LLDB_RECORD_METHOD(lldb::SBValue, SBFrame, FindVariable, (const char *), - name); + LLDB_INSTRUMENT_VA(this, name); SBValue value; std::unique_lock<std::recursive_mutex> lock; @@ -510,19 +502,18 @@ SBValue SBFrame::FindVariable(const char *name) { frame->CalculateTarget()->GetPreferDynamicValue(); value = FindVariable(name, use_dynamic); } - return LLDB_RECORD_RESULT(value); + return value; } SBValue SBFrame::FindVariable(const char *name, lldb::DynamicValueType use_dynamic) { - LLDB_RECORD_METHOD(lldb::SBValue, SBFrame, FindVariable, - (const char *, lldb::DynamicValueType), name, use_dynamic); + LLDB_INSTRUMENT_VA(this, name, use_dynamic); VariableSP var_sp; SBValue sb_value; if (name == nullptr || name[0] == '\0') { - return LLDB_RECORD_RESULT(sb_value); + return sb_value; } ValueObjectSP value_sp; @@ -545,12 +536,11 @@ SBValue SBFrame::FindVariable(const char *name, } } - return LLDB_RECORD_RESULT(sb_value); + return sb_value; } SBValue SBFrame::FindValue(const char *name, ValueType value_type) { - LLDB_RECORD_METHOD(lldb::SBValue, SBFrame, FindValue, - (const char *, lldb::ValueType), name, value_type); + LLDB_INSTRUMENT_VA(this, name, value_type); SBValue value; std::unique_lock<std::recursive_mutex> lock; @@ -563,19 +553,17 @@ SBValue SBFrame::FindValue(const char *name, ValueType value_type) { frame->CalculateTarget()->GetPreferDynamicValue(); value = FindValue(name, value_type, use_dynamic); } - return LLDB_RECORD_RESULT(value); + return value; } SBValue SBFrame::FindValue(const char *name, ValueType value_type, lldb::DynamicValueType use_dynamic) { - LLDB_RECORD_METHOD(lldb::SBValue, SBFrame, FindValue, - (const char *, lldb::ValueType, lldb::DynamicValueType), - name, value_type, use_dynamic); + LLDB_INSTRUMENT_VA(this, name, value_type, use_dynamic); SBValue sb_value; if (name == nullptr || name[0] == '\0') { - return LLDB_RECORD_RESULT(sb_value); + return sb_value; } ValueObjectSP value_sp; @@ -678,12 +666,11 @@ SBValue SBFrame::FindValue(const char *name, ValueType value_type, } } - return LLDB_RECORD_RESULT(sb_value); + return sb_value; } bool SBFrame::IsEqual(const SBFrame &that) const { - LLDB_RECORD_METHOD_CONST(bool, SBFrame, IsEqual, (const lldb::SBFrame &), - that); + LLDB_INSTRUMENT_VA(this, that); lldb::StackFrameSP this_sp = GetFrameSP(); lldb::StackFrameSP that_sp = that.GetFrameSP(); @@ -691,21 +678,19 @@ bool SBFrame::IsEqual(const SBFrame &that) const { } bool SBFrame::operator==(const SBFrame &rhs) const { - LLDB_RECORD_METHOD_CONST(bool, SBFrame, operator==,(const lldb::SBFrame &), - rhs); + LLDB_INSTRUMENT_VA(this, rhs); return IsEqual(rhs); } bool SBFrame::operator!=(const SBFrame &rhs) const { - LLDB_RECORD_METHOD_CONST(bool, SBFrame, operator!=,(const lldb::SBFrame &), - rhs); + LLDB_INSTRUMENT_VA(this, rhs); return !IsEqual(rhs); } SBThread SBFrame::GetThread() const { - LLDB_RECORD_METHOD_CONST_NO_ARGS(lldb::SBThread, SBFrame, GetThread); + LLDB_INSTRUMENT_VA(this); std::unique_lock<std::recursive_mutex> lock; ExecutionContext exe_ctx(m_opaque_sp.get(), lock); @@ -713,11 +698,11 @@ SBThread SBFrame::GetThread() const { ThreadSP thread_sp(exe_ctx.GetThreadSP()); SBThread sb_thread(thread_sp); - return LLDB_RECORD_RESULT(sb_thread); + return sb_thread; } const char *SBFrame::Disassemble() const { - LLDB_RECORD_METHOD_CONST_NO_ARGS(const char *, SBFrame, Disassemble); + LLDB_INSTRUMENT_VA(this); const char *disassembly = nullptr; std::unique_lock<std::recursive_mutex> lock; @@ -741,9 +726,7 @@ const char *SBFrame::Disassemble() const { SBValueList SBFrame::GetVariables(bool arguments, bool locals, bool statics, bool in_scope_only) { - LLDB_RECORD_METHOD(lldb::SBValueList, SBFrame, GetVariables, - (bool, bool, bool, bool), arguments, locals, statics, - in_scope_only); + LLDB_INSTRUMENT_VA(this, arguments, locals, statics, in_scope_only); SBValueList value_list; std::unique_lock<std::recursive_mutex> lock; @@ -767,15 +750,14 @@ SBValueList SBFrame::GetVariables(bool arguments, bool locals, bool statics, value_list = GetVariables(options); } - return LLDB_RECORD_RESULT(value_list); + return value_list; } lldb::SBValueList SBFrame::GetVariables(bool arguments, bool locals, bool statics, bool in_scope_only, lldb::DynamicValueType use_dynamic) { - LLDB_RECORD_METHOD(lldb::SBValueList, SBFrame, GetVariables, - (bool, bool, bool, bool, lldb::DynamicValueType), - arguments, locals, statics, in_scope_only, use_dynamic); + LLDB_INSTRUMENT_VA(this, arguments, locals, statics, in_scope_only, + use_dynamic); std::unique_lock<std::recursive_mutex> lock; ExecutionContext exe_ctx(m_opaque_sp.get(), lock); @@ -790,12 +772,11 @@ lldb::SBValueList SBFrame::GetVariables(bool arguments, bool locals, options.SetInScopeOnly(in_scope_only); options.SetIncludeRuntimeSupportValues(include_runtime_support_values); options.SetUseDynamic(use_dynamic); - return LLDB_RECORD_RESULT(GetVariables(options)); + return GetVariables(options); } SBValueList SBFrame::GetVariables(const lldb::SBVariablesOptions &options) { - LLDB_RECORD_METHOD(lldb::SBValueList, SBFrame, GetVariables, - (const lldb::SBVariablesOptions &), options); + LLDB_INSTRUMENT_VA(this, options); SBValueList value_list; std::unique_lock<std::recursive_mutex> lock; @@ -891,11 +872,11 @@ SBValueList SBFrame::GetVariables(const lldb::SBVariablesOptions &options) { } } - return LLDB_RECORD_RESULT(value_list); + return value_list; } SBValueList SBFrame::GetRegisters() { - LLDB_RECORD_METHOD_NO_ARGS(lldb::SBValueList, SBFrame, GetRegisters); + LLDB_INSTRUMENT_VA(this); SBValueList value_list; std::unique_lock<std::recursive_mutex> lock; @@ -921,12 +902,11 @@ SBValueList SBFrame::GetRegisters() { } } - return LLDB_RECORD_RESULT(value_list); + return value_list; } SBValue SBFrame::FindRegister(const char *name) { - LLDB_RECORD_METHOD(lldb::SBValue, SBFrame, FindRegister, (const char *), - name); + LLDB_INSTRUMENT_VA(this, name); SBValue result; ValueObjectSP value_sp; @@ -953,12 +933,11 @@ SBValue SBFrame::FindRegister(const char *name) { } } - return LLDB_RECORD_RESULT(result); + return result; } bool SBFrame::GetDescription(SBStream &description) { - LLDB_RECORD_METHOD(bool, SBFrame, GetDescription, (lldb::SBStream &), - description); + LLDB_INSTRUMENT_VA(this, description); Stream &strm = description.ref(); @@ -984,8 +963,7 @@ bool SBFrame::GetDescription(SBStream &description) { } SBValue SBFrame::EvaluateExpression(const char *expr) { - LLDB_RECORD_METHOD(lldb::SBValue, SBFrame, EvaluateExpression, (const char *), - expr); + LLDB_INSTRUMENT_VA(this, expr); SBValue result; std::unique_lock<std::recursive_mutex> lock; @@ -1004,17 +982,15 @@ SBValue SBFrame::EvaluateExpression(const char *expr) { options.SetLanguage(target->GetLanguage()); else options.SetLanguage(frame->GetLanguage()); - return LLDB_RECORD_RESULT(EvaluateExpression(expr, options)); + return EvaluateExpression(expr, options); } - return LLDB_RECORD_RESULT(result); + return result; } SBValue SBFrame::EvaluateExpression(const char *expr, lldb::DynamicValueType fetch_dynamic_value) { - LLDB_RECORD_METHOD(lldb::SBValue, SBFrame, EvaluateExpression, - (const char *, lldb::DynamicValueType), expr, - fetch_dynamic_value); + LLDB_INSTRUMENT_VA(this, expr, fetch_dynamic_value); SBExpressionOptions options; options.SetFetchDynamicValue(fetch_dynamic_value); @@ -1029,15 +1005,13 @@ SBFrame::EvaluateExpression(const char *expr, options.SetLanguage(target->GetLanguage()); else if (frame) options.SetLanguage(frame->GetLanguage()); - return LLDB_RECORD_RESULT(EvaluateExpression(expr, options)); + return EvaluateExpression(expr, options); } SBValue SBFrame::EvaluateExpression(const char *expr, lldb::DynamicValueType fetch_dynamic_value, bool unwind_on_error) { - LLDB_RECORD_METHOD(lldb::SBValue, SBFrame, EvaluateExpression, - (const char *, lldb::DynamicValueType, bool), expr, - fetch_dynamic_value, unwind_on_error); + LLDB_INSTRUMENT_VA(this, expr, fetch_dynamic_value, unwind_on_error); SBExpressionOptions options; std::unique_lock<std::recursive_mutex> lock; @@ -1052,21 +1026,19 @@ SBValue SBFrame::EvaluateExpression(const char *expr, options.SetLanguage(target->GetLanguage()); else if (frame) options.SetLanguage(frame->GetLanguage()); - return LLDB_RECORD_RESULT(EvaluateExpression(expr, options)); + return EvaluateExpression(expr, options); } lldb::SBValue SBFrame::EvaluateExpression(const char *expr, const SBExpressionOptions &options) { - LLDB_RECORD_METHOD(lldb::SBValue, SBFrame, EvaluateExpression, - (const char *, const lldb::SBExpressionOptions &), expr, - options); + LLDB_INSTRUMENT_VA(this, expr, options); Log *expr_log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS)); SBValue expr_result; if (expr == nullptr || expr[0] == '\0') { - return LLDB_RECORD_RESULT(expr_result); + return expr_result; } ValueObjectSP expr_value_sp; @@ -1106,17 +1078,17 @@ lldb::SBValue SBFrame::EvaluateExpression(const char *expr, "%s, summary %s **", expr_result.GetValue(), expr_result.GetSummary()); - return LLDB_RECORD_RESULT(expr_result); + return expr_result; } bool SBFrame::IsInlined() { - LLDB_RECORD_METHOD_NO_ARGS(bool, SBFrame, IsInlined); + LLDB_INSTRUMENT_VA(this); return static_cast<const SBFrame *>(this)->IsInlined(); } bool SBFrame::IsInlined() const { - LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBFrame, IsInlined); + LLDB_INSTRUMENT_VA(this); std::unique_lock<std::recursive_mutex> lock; ExecutionContext exe_ctx(m_opaque_sp.get(), lock); @@ -1140,13 +1112,13 @@ bool SBFrame::IsInlined() const { } bool SBFrame::IsArtificial() { - LLDB_RECORD_METHOD_NO_ARGS(bool, SBFrame, IsArtificial); + LLDB_INSTRUMENT_VA(this); return static_cast<const SBFrame *>(this)->IsArtificial(); } bool SBFrame::IsArtificial() const { - LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBFrame, IsArtificial); + LLDB_INSTRUMENT_VA(this); std::unique_lock<std::recursive_mutex> lock; ExecutionContext exe_ctx(m_opaque_sp.get(), lock); @@ -1159,13 +1131,13 @@ bool SBFrame::IsArtificial() const { } const char *SBFrame::GetFunctionName() { - LLDB_RECORD_METHOD_NO_ARGS(const char *, SBFrame, GetFunctionName); + LLDB_INSTRUMENT_VA(this); return static_cast<const SBFrame *>(this)->GetFunctionName(); } lldb::LanguageType SBFrame::GuessLanguage() const { - LLDB_RECORD_METHOD_CONST_NO_ARGS(lldb::LanguageType, SBFrame, GuessLanguage); + LLDB_INSTRUMENT_VA(this); std::unique_lock<std::recursive_mutex> lock; ExecutionContext exe_ctx(m_opaque_sp.get(), lock); @@ -1186,7 +1158,7 @@ lldb::LanguageType SBFrame::GuessLanguage() const { } const char *SBFrame::GetFunctionName() const { - LLDB_RECORD_METHOD_CONST_NO_ARGS(const char *, SBFrame, GetFunctionName); + LLDB_INSTRUMENT_VA(this); const char *name = nullptr; std::unique_lock<std::recursive_mutex> lock; @@ -1228,7 +1200,7 @@ const char *SBFrame::GetFunctionName() const { } const char *SBFrame::GetDisplayFunctionName() { - LLDB_RECORD_METHOD_NO_ARGS(const char *, SBFrame, GetDisplayFunctionName); + LLDB_INSTRUMENT_VA(this); const char *name = nullptr; @@ -1269,82 +1241,3 @@ const char *SBFrame::GetDisplayFunctionName() { } return name; } - -namespace lldb_private { -namespace repro { - -template <> -void RegisterMethods<SBFrame>(Registry &R) { - LLDB_REGISTER_CONSTRUCTOR(SBFrame, ()); - LLDB_REGISTER_CONSTRUCTOR(SBFrame, (const lldb::StackFrameSP &)); - LLDB_REGISTER_CONSTRUCTOR(SBFrame, (const lldb::SBFrame &)); - LLDB_REGISTER_METHOD(const lldb::SBFrame &, - SBFrame, operator=,(const lldb::SBFrame &)); - LLDB_REGISTER_METHOD_CONST(bool, SBFrame, IsValid, ()); - LLDB_REGISTER_METHOD_CONST(bool, SBFrame, operator bool, ()); - LLDB_REGISTER_METHOD_CONST(lldb::SBSymbolContext, SBFrame, GetSymbolContext, - (uint32_t)); - LLDB_REGISTER_METHOD_CONST(lldb::SBModule, SBFrame, GetModule, ()); - LLDB_REGISTER_METHOD_CONST(lldb::SBCompileUnit, SBFrame, GetCompileUnit, - ()); - LLDB_REGISTER_METHOD_CONST(lldb::SBFunction, SBFrame, GetFunction, ()); - LLDB_REGISTER_METHOD_CONST(lldb::SBSymbol, SBFrame, GetSymbol, ()); - LLDB_REGISTER_METHOD_CONST(lldb::SBBlock, SBFrame, GetBlock, ()); - LLDB_REGISTER_METHOD_CONST(lldb::SBBlock, SBFrame, GetFrameBlock, ()); - LLDB_REGISTER_METHOD_CONST(lldb::SBLineEntry, SBFrame, GetLineEntry, ()); - LLDB_REGISTER_METHOD_CONST(uint32_t, SBFrame, GetFrameID, ()); - LLDB_REGISTER_METHOD_CONST(lldb::addr_t, SBFrame, GetCFA, ()); - LLDB_REGISTER_METHOD_CONST(lldb::addr_t, SBFrame, GetPC, ()); - LLDB_REGISTER_METHOD(bool, SBFrame, SetPC, (lldb::addr_t)); - LLDB_REGISTER_METHOD_CONST(lldb::addr_t, SBFrame, GetSP, ()); - LLDB_REGISTER_METHOD_CONST(lldb::addr_t, SBFrame, GetFP, ()); - LLDB_REGISTER_METHOD_CONST(lldb::SBAddress, SBFrame, GetPCAddress, ()); - LLDB_REGISTER_METHOD(void, SBFrame, Clear, ()); - LLDB_REGISTER_METHOD(lldb::SBValue, SBFrame, GetValueForVariablePath, - (const char *)); - LLDB_REGISTER_METHOD(lldb::SBValue, SBFrame, GetValueForVariablePath, - (const char *, lldb::DynamicValueType)); - LLDB_REGISTER_METHOD(lldb::SBValue, SBFrame, FindVariable, (const char *)); - LLDB_REGISTER_METHOD(lldb::SBValue, SBFrame, FindVariable, - (const char *, lldb::DynamicValueType)); - LLDB_REGISTER_METHOD(lldb::SBValue, SBFrame, FindValue, - (const char *, lldb::ValueType)); - LLDB_REGISTER_METHOD( - lldb::SBValue, SBFrame, FindValue, - (const char *, lldb::ValueType, lldb::DynamicValueType)); - LLDB_REGISTER_METHOD_CONST(bool, SBFrame, IsEqual, (const lldb::SBFrame &)); - LLDB_REGISTER_METHOD_CONST(bool, - SBFrame, operator==,(const lldb::SBFrame &)); - LLDB_REGISTER_METHOD_CONST(bool, - SBFrame, operator!=,(const lldb::SBFrame &)); - LLDB_REGISTER_METHOD_CONST(lldb::SBThread, SBFrame, GetThread, ()); - LLDB_REGISTER_METHOD_CONST(const char *, SBFrame, Disassemble, ()); - LLDB_REGISTER_METHOD(lldb::SBValueList, SBFrame, GetVariables, - (bool, bool, bool, bool)); - LLDB_REGISTER_METHOD(lldb::SBValueList, SBFrame, GetVariables, - (bool, bool, bool, bool, lldb::DynamicValueType)); - LLDB_REGISTER_METHOD(lldb::SBValueList, SBFrame, GetVariables, - (const lldb::SBVariablesOptions &)); - LLDB_REGISTER_METHOD(lldb::SBValueList, SBFrame, GetRegisters, ()); - LLDB_REGISTER_METHOD(lldb::SBValue, SBFrame, FindRegister, (const char *)); - LLDB_REGISTER_METHOD(bool, SBFrame, GetDescription, (lldb::SBStream &)); - LLDB_REGISTER_METHOD(lldb::SBValue, SBFrame, EvaluateExpression, - (const char *)); - LLDB_REGISTER_METHOD(lldb::SBValue, SBFrame, EvaluateExpression, - (const char *, lldb::DynamicValueType)); - LLDB_REGISTER_METHOD(lldb::SBValue, SBFrame, EvaluateExpression, - (const char *, lldb::DynamicValueType, bool)); - LLDB_REGISTER_METHOD(lldb::SBValue, SBFrame, EvaluateExpression, - (const char *, const lldb::SBExpressionOptions &)); - LLDB_REGISTER_METHOD(bool, SBFrame, IsInlined, ()); - LLDB_REGISTER_METHOD_CONST(bool, SBFrame, IsInlined, ()); - LLDB_REGISTER_METHOD(bool, SBFrame, IsArtificial, ()); - LLDB_REGISTER_METHOD_CONST(bool, SBFrame, IsArtificial, ()); - LLDB_REGISTER_METHOD(const char *, SBFrame, GetFunctionName, ()); - LLDB_REGISTER_METHOD_CONST(lldb::LanguageType, SBFrame, GuessLanguage, ()); - LLDB_REGISTER_METHOD_CONST(const char *, SBFrame, GetFunctionName, ()); - LLDB_REGISTER_METHOD(const char *, SBFrame, GetDisplayFunctionName, ()); -} - -} -} diff --git a/lldb/source/API/SBFunction.cpp b/lldb/source/API/SBFunction.cpp index 2d0cb239de75..562cae4e8906 100644 --- a/lldb/source/API/SBFunction.cpp +++ b/lldb/source/API/SBFunction.cpp @@ -7,7 +7,6 @@ //===----------------------------------------------------------------------===// #include "lldb/API/SBFunction.h" -#include "SBReproducerPrivate.h" #include "lldb/API/SBProcess.h" #include "lldb/API/SBStream.h" #include "lldb/Core/Disassembler.h" @@ -18,42 +17,42 @@ #include "lldb/Symbol/VariableList.h" #include "lldb/Target/ExecutionContext.h" #include "lldb/Target/Target.h" +#include "lldb/Utility/Instrumentation.h" using namespace lldb; using namespace lldb_private; -SBFunction::SBFunction() { LLDB_RECORD_CONSTRUCTOR_NO_ARGS(SBFunction); } +SBFunction::SBFunction() { LLDB_INSTRUMENT_VA(this); } SBFunction::SBFunction(lldb_private::Function *lldb_object_ptr) : m_opaque_ptr(lldb_object_ptr) {} SBFunction::SBFunction(const lldb::SBFunction &rhs) : m_opaque_ptr(rhs.m_opaque_ptr) { - LLDB_RECORD_CONSTRUCTOR(SBFunction, (const lldb::SBFunction &), rhs); + LLDB_INSTRUMENT_VA(this, rhs); } const SBFunction &SBFunction::operator=(const SBFunction &rhs) { - LLDB_RECORD_METHOD(const lldb::SBFunction &, - SBFunction, operator=,(const lldb::SBFunction &), rhs); + LLDB_INSTRUMENT_VA(this, rhs); m_opaque_ptr = rhs.m_opaque_ptr; - return LLDB_RECORD_RESULT(*this); + return *this; } SBFunction::~SBFunction() { m_opaque_ptr = nullptr; } bool SBFunction::IsValid() const { - LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBFunction, IsValid); + LLDB_INSTRUMENT_VA(this); return this->operator bool(); } SBFunction::operator bool() const { - LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBFunction, operator bool); + LLDB_INSTRUMENT_VA(this); return m_opaque_ptr != nullptr; } const char *SBFunction::GetName() const { - LLDB_RECORD_METHOD_CONST_NO_ARGS(const char *, SBFunction, GetName); + LLDB_INSTRUMENT_VA(this); const char *cstr = nullptr; if (m_opaque_ptr) @@ -63,7 +62,7 @@ const char *SBFunction::GetName() const { } const char *SBFunction::GetDisplayName() const { - LLDB_RECORD_METHOD_CONST_NO_ARGS(const char *, SBFunction, GetDisplayName); + LLDB_INSTRUMENT_VA(this); const char *cstr = nullptr; if (m_opaque_ptr) @@ -73,7 +72,7 @@ const char *SBFunction::GetDisplayName() const { } const char *SBFunction::GetMangledName() const { - LLDB_RECORD_METHOD_CONST_NO_ARGS(const char *, SBFunction, GetMangledName); + LLDB_INSTRUMENT_VA(this); const char *cstr = nullptr; if (m_opaque_ptr) @@ -82,21 +81,19 @@ const char *SBFunction::GetMangledName() const { } bool SBFunction::operator==(const SBFunction &rhs) const { - LLDB_RECORD_METHOD_CONST( - bool, SBFunction, operator==,(const lldb::SBFunction &), rhs); + LLDB_INSTRUMENT_VA(this, rhs); return m_opaque_ptr == rhs.m_opaque_ptr; } bool SBFunction::operator!=(const SBFunction &rhs) const { - LLDB_RECORD_METHOD_CONST( - bool, SBFunction, operator!=,(const lldb::SBFunction &), rhs); + LLDB_INSTRUMENT_VA(this, rhs); return m_opaque_ptr != rhs.m_opaque_ptr; } bool SBFunction::GetDescription(SBStream &s) { - LLDB_RECORD_METHOD(bool, SBFunction, GetDescription, (lldb::SBStream &), s); + LLDB_INSTRUMENT_VA(this, s); if (m_opaque_ptr) { s.Printf("SBFunction: id = 0x%8.8" PRIx64 ", name = %s", @@ -111,16 +108,14 @@ bool SBFunction::GetDescription(SBStream &s) { } SBInstructionList SBFunction::GetInstructions(SBTarget target) { - LLDB_RECORD_METHOD(lldb::SBInstructionList, SBFunction, GetInstructions, - (lldb::SBTarget), target); + LLDB_INSTRUMENT_VA(this, target); - return LLDB_RECORD_RESULT(GetInstructions(target, nullptr)); + return GetInstructions(target, nullptr); } SBInstructionList SBFunction::GetInstructions(SBTarget target, const char *flavor) { - LLDB_RECORD_METHOD(lldb::SBInstructionList, SBFunction, GetInstructions, - (lldb::SBTarget, const char *), target, flavor); + LLDB_INSTRUMENT_VA(this, target, flavor); SBInstructionList sb_instructions; if (m_opaque_ptr) { @@ -136,7 +131,7 @@ SBInstructionList SBFunction::GetInstructions(SBTarget target, m_opaque_ptr->GetAddressRange(), force_live_memory)); } } - return LLDB_RECORD_RESULT(sb_instructions); + return sb_instructions; } lldb_private::Function *SBFunction::get() { return m_opaque_ptr; } @@ -146,16 +141,16 @@ void SBFunction::reset(lldb_private::Function *lldb_object_ptr) { } SBAddress SBFunction::GetStartAddress() { - LLDB_RECORD_METHOD_NO_ARGS(lldb::SBAddress, SBFunction, GetStartAddress); + LLDB_INSTRUMENT_VA(this); SBAddress addr; if (m_opaque_ptr) addr.SetAddress(m_opaque_ptr->GetAddressRange().GetBaseAddress()); - return LLDB_RECORD_RESULT(addr); + return addr; } SBAddress SBFunction::GetEndAddress() { - LLDB_RECORD_METHOD_NO_ARGS(lldb::SBAddress, SBFunction, GetEndAddress); + LLDB_INSTRUMENT_VA(this); SBAddress addr; if (m_opaque_ptr) { @@ -165,12 +160,11 @@ SBAddress SBFunction::GetEndAddress() { addr->Slide(byte_size); } } - return LLDB_RECORD_RESULT(addr); + return addr; } const char *SBFunction::GetArgumentName(uint32_t arg_idx) { - LLDB_RECORD_METHOD(const char *, SBFunction, GetArgumentName, (uint32_t), - arg_idx); + LLDB_INSTRUMENT_VA(this, arg_idx); if (m_opaque_ptr) { Block &block = m_opaque_ptr->GetBlock(true); @@ -188,7 +182,7 @@ const char *SBFunction::GetArgumentName(uint32_t arg_idx) { } uint32_t SBFunction::GetPrologueByteSize() { - LLDB_RECORD_METHOD_NO_ARGS(uint32_t, SBFunction, GetPrologueByteSize); + LLDB_INSTRUMENT_VA(this); if (m_opaque_ptr) return m_opaque_ptr->GetPrologueByteSize(); @@ -196,7 +190,7 @@ uint32_t SBFunction::GetPrologueByteSize() { } SBType SBFunction::GetType() { - LLDB_RECORD_METHOD_NO_ARGS(lldb::SBType, SBFunction, GetType); + LLDB_INSTRUMENT_VA(this); SBType sb_type; if (m_opaque_ptr) { @@ -204,20 +198,20 @@ SBType SBFunction::GetType() { if (function_type) sb_type.ref().SetType(function_type->shared_from_this()); } - return LLDB_RECORD_RESULT(sb_type); + return sb_type; } SBBlock SBFunction::GetBlock() { - LLDB_RECORD_METHOD_NO_ARGS(lldb::SBBlock, SBFunction, GetBlock); + LLDB_INSTRUMENT_VA(this); SBBlock sb_block; if (m_opaque_ptr) sb_block.SetPtr(&m_opaque_ptr->GetBlock(true)); - return LLDB_RECORD_RESULT(sb_block); + return sb_block; } lldb::LanguageType SBFunction::GetLanguage() { - LLDB_RECORD_METHOD_NO_ARGS(lldb::LanguageType, SBFunction, GetLanguage); + LLDB_INSTRUMENT_VA(this); if (m_opaque_ptr) { if (m_opaque_ptr->GetCompileUnit()) @@ -227,7 +221,7 @@ lldb::LanguageType SBFunction::GetLanguage() { } bool SBFunction::GetIsOptimized() { - LLDB_RECORD_METHOD_NO_ARGS(bool, SBFunction, GetIsOptimized); + LLDB_INSTRUMENT_VA(this); if (m_opaque_ptr) { if (m_opaque_ptr->GetCompileUnit()) @@ -235,39 +229,3 @@ bool SBFunction::GetIsOptimized() { } return false; } - -namespace lldb_private { -namespace repro { - -template <> -void RegisterMethods<SBFunction>(Registry &R) { - LLDB_REGISTER_CONSTRUCTOR(SBFunction, ()); - LLDB_REGISTER_CONSTRUCTOR(SBFunction, (const lldb::SBFunction &)); - LLDB_REGISTER_METHOD(const lldb::SBFunction &, - SBFunction, operator=,(const lldb::SBFunction &)); - LLDB_REGISTER_METHOD_CONST(bool, SBFunction, IsValid, ()); - LLDB_REGISTER_METHOD_CONST(bool, SBFunction, operator bool, ()); - LLDB_REGISTER_METHOD_CONST(const char *, SBFunction, GetName, ()); - LLDB_REGISTER_METHOD_CONST(const char *, SBFunction, GetDisplayName, ()); - LLDB_REGISTER_METHOD_CONST(const char *, SBFunction, GetMangledName, ()); - LLDB_REGISTER_METHOD_CONST( - bool, SBFunction, operator==,(const lldb::SBFunction &)); - LLDB_REGISTER_METHOD_CONST( - bool, SBFunction, operator!=,(const lldb::SBFunction &)); - LLDB_REGISTER_METHOD(bool, SBFunction, GetDescription, (lldb::SBStream &)); - LLDB_REGISTER_METHOD(lldb::SBInstructionList, SBFunction, GetInstructions, - (lldb::SBTarget)); - LLDB_REGISTER_METHOD(lldb::SBInstructionList, SBFunction, GetInstructions, - (lldb::SBTarget, const char *)); - LLDB_REGISTER_METHOD(lldb::SBAddress, SBFunction, GetStartAddress, ()); - LLDB_REGISTER_METHOD(lldb::SBAddress, SBFunction, GetEndAddress, ()); - LLDB_REGISTER_METHOD(const char *, SBFunction, GetArgumentName, (uint32_t)); - LLDB_REGISTER_METHOD(uint32_t, SBFunction, GetPrologueByteSize, ()); - LLDB_REGISTER_METHOD(lldb::SBType, SBFunction, GetType, ()); - LLDB_REGISTER_METHOD(lldb::SBBlock, SBFunction, GetBlock, ()); - LLDB_REGISTER_METHOD(lldb::LanguageType, SBFunction, GetLanguage, ()); - LLDB_REGISTER_METHOD(bool, SBFunction, GetIsOptimized, ()); -} - -} -} diff --git a/lldb/source/API/SBHostOS.cpp b/lldb/source/API/SBHostOS.cpp index deca4ac81a1a..06cf654031a1 100644 --- a/lldb/source/API/SBHostOS.cpp +++ b/lldb/source/API/SBHostOS.cpp @@ -7,7 +7,6 @@ //===----------------------------------------------------------------------===// #include "lldb/API/SBHostOS.h" -#include "SBReproducerPrivate.h" #include "lldb/API/SBError.h" #include "lldb/Host/Config.h" #include "lldb/Host/FileSystem.h" @@ -17,6 +16,7 @@ #include "lldb/Host/HostThread.h" #include "lldb/Host/ThreadLauncher.h" #include "lldb/Utility/FileSpec.h" +#include "lldb/Utility/Instrumentation.h" #include "Plugins/ExpressionParser/Clang/ClangHost.h" #if LLDB_ENABLE_PYTHON @@ -30,24 +30,21 @@ using namespace lldb; using namespace lldb_private; SBFileSpec SBHostOS::GetProgramFileSpec() { - LLDB_RECORD_STATIC_METHOD_NO_ARGS(lldb::SBFileSpec, SBHostOS, - GetProgramFileSpec); + LLDB_INSTRUMENT(); SBFileSpec sb_filespec; sb_filespec.SetFileSpec(HostInfo::GetProgramFileSpec()); - return LLDB_RECORD_RESULT(sb_filespec); + return sb_filespec; } SBFileSpec SBHostOS::GetLLDBPythonPath() { - LLDB_RECORD_STATIC_METHOD_NO_ARGS(lldb::SBFileSpec, SBHostOS, - GetLLDBPythonPath); + LLDB_INSTRUMENT(); - return LLDB_RECORD_RESULT(GetLLDBPath(ePathTypePythonDir)); + return GetLLDBPath(ePathTypePythonDir); } SBFileSpec SBHostOS::GetLLDBPath(lldb::PathType path_type) { - LLDB_RECORD_STATIC_METHOD(lldb::SBFileSpec, SBHostOS, GetLLDBPath, - (lldb::PathType), path_type); + LLDB_INSTRUMENT_VA(path_type); FileSpec fspec; switch (path_type) { @@ -84,12 +81,11 @@ SBFileSpec SBHostOS::GetLLDBPath(lldb::PathType path_type) { SBFileSpec sb_fspec; sb_fspec.SetFileSpec(fspec); - return LLDB_RECORD_RESULT(sb_fspec); + return sb_fspec; } SBFileSpec SBHostOS::GetUserHomeDirectory() { - LLDB_RECORD_STATIC_METHOD_NO_ARGS(lldb::SBFileSpec, SBHostOS, - GetUserHomeDirectory); + LLDB_INSTRUMENT(); FileSpec homedir; FileSystem::Instance().GetHomeDirectory(homedir); @@ -98,15 +94,13 @@ SBFileSpec SBHostOS::GetUserHomeDirectory() { SBFileSpec sb_fspec; sb_fspec.SetFileSpec(homedir); - return LLDB_RECORD_RESULT(sb_fspec); + return sb_fspec; } lldb::thread_t SBHostOS::ThreadCreate(const char *name, lldb::thread_func_t thread_function, void *thread_arg, SBError *error_ptr) { - LLDB_RECORD_DUMMY(lldb::thread_t, SBHostOS, ThreadCreate, - (lldb::thread_func_t, void *, SBError *), name, - thread_function, thread_arg, error_ptr); + LLDB_INSTRUMENT_VA(name, thread_function, thread_arg, error_ptr); llvm::Expected<HostThread> thread = ThreadLauncher::LaunchThread(name, thread_function, thread_arg); if (!thread) { @@ -120,15 +114,10 @@ lldb::thread_t SBHostOS::ThreadCreate(const char *name, return thread->Release(); } -void SBHostOS::ThreadCreated(const char *name) { - LLDB_RECORD_STATIC_METHOD(void, SBHostOS, ThreadCreated, (const char *), - name); -} +void SBHostOS::ThreadCreated(const char *name) { LLDB_INSTRUMENT_VA(name); } bool SBHostOS::ThreadCancel(lldb::thread_t thread, SBError *error_ptr) { - LLDB_RECORD_DUMMY(bool, SBHostOS, ThreadCancel, - (lldb::thread_t, lldb::SBError *), thread, - error_ptr); + LLDB_INSTRUMENT_VA(thread, error_ptr); Status error; HostThread host_thread(thread); @@ -140,9 +129,7 @@ bool SBHostOS::ThreadCancel(lldb::thread_t thread, SBError *error_ptr) { } bool SBHostOS::ThreadDetach(lldb::thread_t thread, SBError *error_ptr) { - LLDB_RECORD_DUMMY(bool, SBHostOS, ThreadDetach, - (lldb::thread_t, lldb::SBError *), thread, - error_ptr); + LLDB_INSTRUMENT_VA(thread, error_ptr); Status error; #if defined(_WIN32) @@ -160,10 +147,7 @@ bool SBHostOS::ThreadDetach(lldb::thread_t thread, SBError *error_ptr) { bool SBHostOS::ThreadJoin(lldb::thread_t thread, lldb::thread_result_t *result, SBError *error_ptr) { - LLDB_RECORD_DUMMY( - bool, SBHostOS, ThreadJoin, - (lldb::thread_t, lldb::thread_result_t *, lldb::SBError *), thread, - result, error_ptr); + LLDB_INSTRUMENT_VA(thread, result, error_ptr); Status error; HostThread host_thread(thread); @@ -173,22 +157,3 @@ bool SBHostOS::ThreadJoin(lldb::thread_t thread, lldb::thread_result_t *result, host_thread.Release(); return error.Success(); } - -namespace lldb_private { -namespace repro { - -template <> -void RegisterMethods<SBHostOS>(Registry &R) { - LLDB_REGISTER_STATIC_METHOD(lldb::SBFileSpec, SBHostOS, GetProgramFileSpec, - ()); - LLDB_REGISTER_STATIC_METHOD(lldb::SBFileSpec, SBHostOS, GetLLDBPythonPath, - ()); - LLDB_REGISTER_STATIC_METHOD(lldb::SBFileSpec, SBHostOS, GetLLDBPath, - (lldb::PathType)); - LLDB_REGISTER_STATIC_METHOD(lldb::SBFileSpec, SBHostOS, - GetUserHomeDirectory, ()); - LLDB_REGISTER_STATIC_METHOD(void, SBHostOS, ThreadCreated, (const char *)); -} - -} -} diff --git a/lldb/source/API/SBInstruction.cpp b/lldb/source/API/SBInstruction.cpp index 579ddf84cf45..6cb9e5dbc1af 100644 --- a/lldb/source/API/SBInstruction.cpp +++ b/lldb/source/API/SBInstruction.cpp @@ -7,7 +7,7 @@ //===----------------------------------------------------------------------===// #include "lldb/API/SBInstruction.h" -#include "SBReproducerPrivate.h" +#include "lldb/Utility/Instrumentation.h" #include "lldb/API/SBAddress.h" #include "lldb/API/SBFrame.h" @@ -66,9 +66,7 @@ protected: using namespace lldb; using namespace lldb_private; -SBInstruction::SBInstruction() : m_opaque_sp() { - LLDB_RECORD_CONSTRUCTOR_NO_ARGS(SBInstruction); -} +SBInstruction::SBInstruction() { LLDB_INSTRUMENT_VA(this); } SBInstruction::SBInstruction(const lldb::DisassemblerSP &disasm_sp, const lldb::InstructionSP &inst_sp) @@ -76,44 +74,41 @@ SBInstruction::SBInstruction(const lldb::DisassemblerSP &disasm_sp, SBInstruction::SBInstruction(const SBInstruction &rhs) : m_opaque_sp(rhs.m_opaque_sp) { - LLDB_RECORD_CONSTRUCTOR(SBInstruction, (const lldb::SBInstruction &), rhs); + LLDB_INSTRUMENT_VA(this, rhs); } const SBInstruction &SBInstruction::operator=(const SBInstruction &rhs) { - LLDB_RECORD_METHOD(const lldb::SBInstruction &, - SBInstruction, operator=,(const lldb::SBInstruction &), - rhs); + LLDB_INSTRUMENT_VA(this, rhs); if (this != &rhs) m_opaque_sp = rhs.m_opaque_sp; - return LLDB_RECORD_RESULT(*this); + return *this; } SBInstruction::~SBInstruction() = default; bool SBInstruction::IsValid() { - LLDB_RECORD_METHOD_NO_ARGS(bool, SBInstruction, IsValid); + LLDB_INSTRUMENT_VA(this); return this->operator bool(); } SBInstruction::operator bool() const { - LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBInstruction, operator bool); + LLDB_INSTRUMENT_VA(this); return m_opaque_sp && m_opaque_sp->IsValid(); } SBAddress SBInstruction::GetAddress() { - LLDB_RECORD_METHOD_NO_ARGS(lldb::SBAddress, SBInstruction, GetAddress); + LLDB_INSTRUMENT_VA(this); SBAddress sb_addr; lldb::InstructionSP inst_sp(GetOpaque()); if (inst_sp && inst_sp->GetAddress().IsValid()) sb_addr.SetAddress(inst_sp->GetAddress()); - return LLDB_RECORD_RESULT(sb_addr); + return sb_addr; } const char *SBInstruction::GetMnemonic(SBTarget target) { - LLDB_RECORD_METHOD(const char *, SBInstruction, GetMnemonic, (lldb::SBTarget), - target); + LLDB_INSTRUMENT_VA(this, target); lldb::InstructionSP inst_sp(GetOpaque()); if (inst_sp) { @@ -132,8 +127,7 @@ const char *SBInstruction::GetMnemonic(SBTarget target) { } const char *SBInstruction::GetOperands(SBTarget target) { - LLDB_RECORD_METHOD(const char *, SBInstruction, GetOperands, (lldb::SBTarget), - target); + LLDB_INSTRUMENT_VA(this, target); lldb::InstructionSP inst_sp(GetOpaque()); if (inst_sp) { @@ -152,8 +146,7 @@ const char *SBInstruction::GetOperands(SBTarget target) { } const char *SBInstruction::GetComment(SBTarget target) { - LLDB_RECORD_METHOD(const char *, SBInstruction, GetComment, (lldb::SBTarget), - target); + LLDB_INSTRUMENT_VA(this, target); lldb::InstructionSP inst_sp(GetOpaque()); if (inst_sp) { @@ -172,7 +165,7 @@ const char *SBInstruction::GetComment(SBTarget target) { } size_t SBInstruction::GetByteSize() { - LLDB_RECORD_METHOD_NO_ARGS(size_t, SBInstruction, GetByteSize); + LLDB_INSTRUMENT_VA(this); lldb::InstructionSP inst_sp(GetOpaque()); if (inst_sp) @@ -181,8 +174,7 @@ size_t SBInstruction::GetByteSize() { } SBData SBInstruction::GetData(SBTarget target) { - LLDB_RECORD_METHOD(lldb::SBData, SBInstruction, GetData, (lldb::SBTarget), - target); + LLDB_INSTRUMENT_VA(this, target); lldb::SBData sb_data; lldb::InstructionSP inst_sp(GetOpaque()); @@ -192,11 +184,11 @@ SBData SBInstruction::GetData(SBTarget target) { sb_data.SetOpaque(data_extractor_sp); } } - return LLDB_RECORD_RESULT(sb_data); + return sb_data; } bool SBInstruction::DoesBranch() { - LLDB_RECORD_METHOD_NO_ARGS(bool, SBInstruction, DoesBranch); + LLDB_INSTRUMENT_VA(this); lldb::InstructionSP inst_sp(GetOpaque()); if (inst_sp) @@ -205,7 +197,7 @@ bool SBInstruction::DoesBranch() { } bool SBInstruction::HasDelaySlot() { - LLDB_RECORD_METHOD_NO_ARGS(bool, SBInstruction, HasDelaySlot); + LLDB_INSTRUMENT_VA(this); lldb::InstructionSP inst_sp(GetOpaque()); if (inst_sp) @@ -214,7 +206,7 @@ bool SBInstruction::HasDelaySlot() { } bool SBInstruction::CanSetBreakpoint() { - LLDB_RECORD_METHOD_NO_ARGS(bool, SBInstruction, CanSetBreakpoint); + LLDB_INSTRUMENT_VA(this); lldb::InstructionSP inst_sp(GetOpaque()); if (inst_sp) @@ -235,8 +227,7 @@ void SBInstruction::SetOpaque(const lldb::DisassemblerSP &disasm_sp, } bool SBInstruction::GetDescription(lldb::SBStream &s) { - LLDB_RECORD_METHOD(bool, SBInstruction, GetDescription, (lldb::SBStream &), - s); + LLDB_INSTRUMENT_VA(this, s); lldb::InstructionSP inst_sp(GetOpaque()); if (inst_sp) { @@ -257,18 +248,18 @@ bool SBInstruction::GetDescription(lldb::SBStream &s) { } void SBInstruction::Print(FILE *outp) { - LLDB_RECORD_METHOD(void, SBInstruction, Print, (FILE *), outp); + LLDB_INSTRUMENT_VA(this, outp); FileSP out = std::make_shared<NativeFile>(outp, /*take_ownership=*/false); Print(out); } void SBInstruction::Print(SBFile out) { - LLDB_RECORD_METHOD(void, SBInstruction, Print, (SBFile), out); + LLDB_INSTRUMENT_VA(this, out); Print(out.m_opaque_sp); } void SBInstruction::Print(FileSP out_sp) { - LLDB_RECORD_METHOD(void, SBInstruction, Print, (FileSP), out_sp); + LLDB_INSTRUMENT_VA(this, out_sp); if (!out_sp || !out_sp->IsValid()) return; @@ -291,8 +282,7 @@ void SBInstruction::Print(FileSP out_sp) { bool SBInstruction::EmulateWithFrame(lldb::SBFrame &frame, uint32_t evaluate_options) { - LLDB_RECORD_METHOD(bool, SBInstruction, EmulateWithFrame, - (lldb::SBFrame &, uint32_t), frame, evaluate_options); + LLDB_INSTRUMENT_VA(this, frame, evaluate_options); lldb::InstructionSP inst_sp(GetOpaque()); if (inst_sp) { @@ -316,8 +306,7 @@ bool SBInstruction::EmulateWithFrame(lldb::SBFrame &frame, } bool SBInstruction::DumpEmulation(const char *triple) { - LLDB_RECORD_METHOD(bool, SBInstruction, DumpEmulation, (const char *), - triple); + LLDB_INSTRUMENT_VA(this, triple); lldb::InstructionSP inst_sp(GetOpaque()); if (inst_sp && triple) { @@ -328,9 +317,7 @@ bool SBInstruction::DumpEmulation(const char *triple) { bool SBInstruction::TestEmulation(lldb::SBStream &output_stream, const char *test_file) { - LLDB_RECORD_METHOD(bool, SBInstruction, TestEmulation, - (lldb::SBStream &, const char *), output_stream, - test_file); + LLDB_INSTRUMENT_VA(this, output_stream, test_file); if (!m_opaque_sp) SetOpaque(lldb::DisassemblerSP(), @@ -341,43 +328,3 @@ bool SBInstruction::TestEmulation(lldb::SBStream &output_stream, return inst_sp->TestEmulation(output_stream.get(), test_file); return false; } - -namespace lldb_private { -namespace repro { - -template <> -void RegisterMethods<SBInstruction>(Registry &R) { - LLDB_REGISTER_CONSTRUCTOR(SBInstruction, ()); - LLDB_REGISTER_CONSTRUCTOR(SBInstruction, (const lldb::SBInstruction &)); - LLDB_REGISTER_METHOD( - const lldb::SBInstruction &, - SBInstruction, operator=,(const lldb::SBInstruction &)); - LLDB_REGISTER_METHOD(bool, SBInstruction, IsValid, ()); - LLDB_REGISTER_METHOD_CONST(bool, SBInstruction, operator bool, ()); - LLDB_REGISTER_METHOD(lldb::SBAddress, SBInstruction, GetAddress, ()); - LLDB_REGISTER_METHOD(const char *, SBInstruction, GetMnemonic, - (lldb::SBTarget)); - LLDB_REGISTER_METHOD(const char *, SBInstruction, GetOperands, - (lldb::SBTarget)); - LLDB_REGISTER_METHOD(const char *, SBInstruction, GetComment, - (lldb::SBTarget)); - LLDB_REGISTER_METHOD(size_t, SBInstruction, GetByteSize, ()); - LLDB_REGISTER_METHOD(lldb::SBData, SBInstruction, GetData, - (lldb::SBTarget)); - LLDB_REGISTER_METHOD(bool, SBInstruction, DoesBranch, ()); - LLDB_REGISTER_METHOD(bool, SBInstruction, HasDelaySlot, ()); - LLDB_REGISTER_METHOD(bool, SBInstruction, CanSetBreakpoint, ()); - LLDB_REGISTER_METHOD(bool, SBInstruction, GetDescription, - (lldb::SBStream &)); - LLDB_REGISTER_METHOD(void, SBInstruction, Print, (FILE *)); - LLDB_REGISTER_METHOD(void, SBInstruction, Print, (SBFile)); - LLDB_REGISTER_METHOD(void, SBInstruction, Print, (FileSP)); - LLDB_REGISTER_METHOD(bool, SBInstruction, EmulateWithFrame, - (lldb::SBFrame &, uint32_t)); - LLDB_REGISTER_METHOD(bool, SBInstruction, DumpEmulation, (const char *)); - LLDB_REGISTER_METHOD(bool, SBInstruction, TestEmulation, - (lldb::SBStream &, const char *)); -} - -} -} diff --git a/lldb/source/API/SBInstructionList.cpp b/lldb/source/API/SBInstructionList.cpp index a0c6fbe7e338..e289e8e9343d 100644 --- a/lldb/source/API/SBInstructionList.cpp +++ b/lldb/source/API/SBInstructionList.cpp @@ -7,55 +7,50 @@ //===----------------------------------------------------------------------===// #include "lldb/API/SBInstructionList.h" -#include "SBReproducerPrivate.h" #include "lldb/API/SBAddress.h" +#include "lldb/API/SBFile.h" #include "lldb/API/SBInstruction.h" #include "lldb/API/SBStream.h" -#include "lldb/API/SBFile.h" #include "lldb/Core/Disassembler.h" #include "lldb/Core/Module.h" #include "lldb/Core/StreamFile.h" #include "lldb/Symbol/SymbolContext.h" +#include "lldb/Utility/Instrumentation.h" #include "lldb/Utility/Stream.h" using namespace lldb; using namespace lldb_private; -SBInstructionList::SBInstructionList() : m_opaque_sp() { - LLDB_RECORD_CONSTRUCTOR_NO_ARGS(SBInstructionList); -} +SBInstructionList::SBInstructionList() { LLDB_INSTRUMENT_VA(this); } SBInstructionList::SBInstructionList(const SBInstructionList &rhs) : m_opaque_sp(rhs.m_opaque_sp) { - LLDB_RECORD_CONSTRUCTOR(SBInstructionList, (const lldb::SBInstructionList &), - rhs); + LLDB_INSTRUMENT_VA(this, rhs); } const SBInstructionList &SBInstructionList:: operator=(const SBInstructionList &rhs) { - LLDB_RECORD_METHOD( - const lldb::SBInstructionList &, - SBInstructionList, operator=,(const lldb::SBInstructionList &), rhs); + LLDB_INSTRUMENT_VA(this, rhs); if (this != &rhs) m_opaque_sp = rhs.m_opaque_sp; - return LLDB_RECORD_RESULT(*this); + return *this; } SBInstructionList::~SBInstructionList() = default; bool SBInstructionList::IsValid() const { - LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBInstructionList, IsValid); + LLDB_INSTRUMENT_VA(this); return this->operator bool(); } SBInstructionList::operator bool() const { - LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBInstructionList, operator bool); + LLDB_INSTRUMENT_VA(this); return m_opaque_sp.get() != nullptr; } size_t SBInstructionList::GetSize() { - LLDB_RECORD_METHOD_NO_ARGS(size_t, SBInstructionList, GetSize); + LLDB_INSTRUMENT_VA(this); if (m_opaque_sp) return m_opaque_sp->GetInstructionList().GetSize(); @@ -63,23 +58,20 @@ size_t SBInstructionList::GetSize() { } SBInstruction SBInstructionList::GetInstructionAtIndex(uint32_t idx) { - LLDB_RECORD_METHOD(lldb::SBInstruction, SBInstructionList, - GetInstructionAtIndex, (uint32_t), idx); + LLDB_INSTRUMENT_VA(this, idx); SBInstruction inst; if (m_opaque_sp && idx < m_opaque_sp->GetInstructionList().GetSize()) inst.SetOpaque( m_opaque_sp, m_opaque_sp->GetInstructionList().GetInstructionAtIndex(idx)); - return LLDB_RECORD_RESULT(inst); + return inst; } size_t SBInstructionList::GetInstructionsCount(const SBAddress &start, const SBAddress &end, bool canSetBreakpoint) { - LLDB_RECORD_METHOD(size_t, SBInstructionList, GetInstructionsCount, - (const lldb::SBAddress &, const lldb::SBAddress &, bool), - start, end, canSetBreakpoint); + LLDB_INSTRUMENT_VA(this, start, end, canSetBreakpoint); size_t num_instructions = GetSize(); size_t i = 0; @@ -104,14 +96,13 @@ size_t SBInstructionList::GetInstructionsCount(const SBAddress &start, } void SBInstructionList::Clear() { - LLDB_RECORD_METHOD_NO_ARGS(void, SBInstructionList, Clear); + LLDB_INSTRUMENT_VA(this); m_opaque_sp.reset(); } void SBInstructionList::AppendInstruction(SBInstruction insn) { - LLDB_RECORD_METHOD(void, SBInstructionList, AppendInstruction, - (lldb::SBInstruction), insn); + LLDB_INSTRUMENT_VA(this, insn); } void SBInstructionList::SetDisassembler(const lldb::DisassemblerSP &opaque_sp) { @@ -119,7 +110,7 @@ void SBInstructionList::SetDisassembler(const lldb::DisassemblerSP &opaque_sp) { } void SBInstructionList::Print(FILE *out) { - LLDB_RECORD_METHOD(void, SBInstructionList, Print, (FILE *), out); + LLDB_INSTRUMENT_VA(this, out); if (out == nullptr) return; StreamFile stream(out, false); @@ -127,7 +118,7 @@ void SBInstructionList::Print(FILE *out) { } void SBInstructionList::Print(SBFile out) { - LLDB_RECORD_METHOD(void, SBInstructionList, Print, (SBFile), out); + LLDB_INSTRUMENT_VA(this, out); if (!out.IsValid()) return; StreamFile stream(out.m_opaque_sp); @@ -135,7 +126,7 @@ void SBInstructionList::Print(SBFile out) { } void SBInstructionList::Print(FileSP out_sp) { - LLDB_RECORD_METHOD(void, SBInstructionList, Print, (FileSP), out_sp); + LLDB_INSTRUMENT_VA(this, out_sp); if (!out_sp || !out_sp->IsValid()) return; StreamFile stream(out_sp); @@ -143,8 +134,7 @@ void SBInstructionList::Print(FileSP out_sp) { } bool SBInstructionList::GetDescription(lldb::SBStream &stream) { - LLDB_RECORD_METHOD(bool, SBInstructionList, GetDescription, - (lldb::SBStream &), stream); + LLDB_INSTRUMENT_VA(this, stream); return GetDescription(stream.ref()); } @@ -186,8 +176,7 @@ bool SBInstructionList::GetDescription(Stream &sref) { } bool SBInstructionList::DumpEmulationForAllInstructions(const char *triple) { - LLDB_RECORD_METHOD(bool, SBInstructionList, DumpEmulationForAllInstructions, - (const char *), triple); + LLDB_INSTRUMENT_VA(this, triple); if (m_opaque_sp) { size_t len = GetSize(); @@ -198,37 +187,3 @@ bool SBInstructionList::DumpEmulationForAllInstructions(const char *triple) { } return true; } - -namespace lldb_private { -namespace repro { - -template <> -void RegisterMethods<SBInstructionList>(Registry &R) { - LLDB_REGISTER_CONSTRUCTOR(SBInstructionList, ()); - LLDB_REGISTER_CONSTRUCTOR(SBInstructionList, - (const lldb::SBInstructionList &)); - LLDB_REGISTER_METHOD( - const lldb::SBInstructionList &, - SBInstructionList, operator=,(const lldb::SBInstructionList &)); - LLDB_REGISTER_METHOD_CONST(bool, SBInstructionList, IsValid, ()); - LLDB_REGISTER_METHOD_CONST(bool, SBInstructionList, operator bool, ()); - LLDB_REGISTER_METHOD(size_t, SBInstructionList, GetSize, ()); - LLDB_REGISTER_METHOD(lldb::SBInstruction, SBInstructionList, - GetInstructionAtIndex, (uint32_t)); - LLDB_REGISTER_METHOD( - size_t, SBInstructionList, GetInstructionsCount, - (const lldb::SBAddress &, const lldb::SBAddress &, bool)); - LLDB_REGISTER_METHOD(void, SBInstructionList, Clear, ()); - LLDB_REGISTER_METHOD(void, SBInstructionList, AppendInstruction, - (lldb::SBInstruction)); - LLDB_REGISTER_METHOD(void, SBInstructionList, Print, (FILE *)); - LLDB_REGISTER_METHOD(void, SBInstructionList, Print, (SBFile)); - LLDB_REGISTER_METHOD(void, SBInstructionList, Print, (FileSP)); - LLDB_REGISTER_METHOD(bool, SBInstructionList, GetDescription, - (lldb::SBStream &)); - LLDB_REGISTER_METHOD(bool, SBInstructionList, - DumpEmulationForAllInstructions, (const char *)); -} - -} -} diff --git a/lldb/source/API/SBLanguageRuntime.cpp b/lldb/source/API/SBLanguageRuntime.cpp index e65b58270517..d571f282fce0 100644 --- a/lldb/source/API/SBLanguageRuntime.cpp +++ b/lldb/source/API/SBLanguageRuntime.cpp @@ -7,39 +7,22 @@ //===----------------------------------------------------------------------===// #include "lldb/API/SBLanguageRuntime.h" -#include "SBReproducerPrivate.h" #include "lldb/Target/Language.h" +#include "lldb/Utility/Instrumentation.h" using namespace lldb; using namespace lldb_private; lldb::LanguageType SBLanguageRuntime::GetLanguageTypeFromString(const char *string) { - LLDB_RECORD_STATIC_METHOD(lldb::LanguageType, SBLanguageRuntime, - GetLanguageTypeFromString, (const char *), string); + LLDB_INSTRUMENT_VA(string); return Language::GetLanguageTypeFromString(llvm::StringRef(string)); } const char * SBLanguageRuntime::GetNameForLanguageType(lldb::LanguageType language) { - LLDB_RECORD_STATIC_METHOD(const char *, SBLanguageRuntime, - GetNameForLanguageType, (lldb::LanguageType), - language); + LLDB_INSTRUMENT_VA(language); return Language::GetNameForLanguageType(language); } - -namespace lldb_private { -namespace repro { - -template <> -void RegisterMethods<SBLanguageRuntime>(Registry &R) { - LLDB_REGISTER_STATIC_METHOD(lldb::LanguageType, SBLanguageRuntime, - GetLanguageTypeFromString, (const char *)); - LLDB_REGISTER_STATIC_METHOD(const char *, SBLanguageRuntime, - GetNameForLanguageType, (lldb::LanguageType)); -} - -} -} diff --git a/lldb/source/API/SBLaunchInfo.cpp b/lldb/source/API/SBLaunchInfo.cpp index 0735e62a16cf..5149feba5e0b 100644 --- a/lldb/source/API/SBLaunchInfo.cpp +++ b/lldb/source/API/SBLaunchInfo.cpp @@ -7,7 +7,7 @@ //===----------------------------------------------------------------------===// #include "lldb/API/SBLaunchInfo.h" -#include "SBReproducerPrivate.h" +#include "lldb/Utility/Instrumentation.h" #include "lldb/API/SBEnvironment.h" #include "lldb/API/SBError.h" @@ -23,8 +23,7 @@ using namespace lldb_private; class lldb_private::SBLaunchInfoImpl : public ProcessLaunchInfo { public: - SBLaunchInfoImpl() - : ProcessLaunchInfo(), m_envp(GetEnvironment().getEnvp()) {} + SBLaunchInfoImpl() : m_envp(GetEnvironment().getEnvp()) {} const char *const *GetEnvp() const { return m_envp; } void RegenerateEnvp() { m_envp = GetEnvironment().getEnvp(); } @@ -41,7 +40,7 @@ private: SBLaunchInfo::SBLaunchInfo(const char **argv) : m_opaque_sp(new SBLaunchInfoImpl()) { - LLDB_RECORD_CONSTRUCTOR(SBLaunchInfo, (const char **), argv); + LLDB_INSTRUMENT_VA(this, argv); m_opaque_sp->GetFlags().Reset(eLaunchFlagDebug | eLaunchFlagDisableASLR); if (argv && argv[0]) @@ -49,17 +48,16 @@ SBLaunchInfo::SBLaunchInfo(const char **argv) } SBLaunchInfo::SBLaunchInfo(const SBLaunchInfo &rhs) { - LLDB_RECORD_CONSTRUCTOR(SBLaunchInfo, (const lldb::SBLaunchInfo &), rhs); + LLDB_INSTRUMENT_VA(this, rhs); m_opaque_sp = rhs.m_opaque_sp; } SBLaunchInfo &SBLaunchInfo::operator=(const SBLaunchInfo &rhs) { - LLDB_RECORD_METHOD(SBLaunchInfo &, - SBLaunchInfo, operator=,(const lldb::SBLaunchInfo &), rhs); + LLDB_INSTRUMENT_VA(this, rhs); m_opaque_sp = rhs.m_opaque_sp; - return LLDB_RECORD_RESULT(*this); + return *this; } SBLaunchInfo::~SBLaunchInfo() = default; @@ -73,90 +71,86 @@ void SBLaunchInfo::set_ref(const ProcessLaunchInfo &info) { } lldb::pid_t SBLaunchInfo::GetProcessID() { - LLDB_RECORD_METHOD_NO_ARGS(lldb::pid_t, SBLaunchInfo, GetProcessID); + LLDB_INSTRUMENT_VA(this); return m_opaque_sp->GetProcessID(); } uint32_t SBLaunchInfo::GetUserID() { - LLDB_RECORD_METHOD_NO_ARGS(uint32_t, SBLaunchInfo, GetUserID); + LLDB_INSTRUMENT_VA(this); return m_opaque_sp->GetUserID(); } uint32_t SBLaunchInfo::GetGroupID() { - LLDB_RECORD_METHOD_NO_ARGS(uint32_t, SBLaunchInfo, GetGroupID); + LLDB_INSTRUMENT_VA(this); return m_opaque_sp->GetGroupID(); } bool SBLaunchInfo::UserIDIsValid() { - LLDB_RECORD_METHOD_NO_ARGS(bool, SBLaunchInfo, UserIDIsValid); + LLDB_INSTRUMENT_VA(this); return m_opaque_sp->UserIDIsValid(); } bool SBLaunchInfo::GroupIDIsValid() { - LLDB_RECORD_METHOD_NO_ARGS(bool, SBLaunchInfo, GroupIDIsValid); + LLDB_INSTRUMENT_VA(this); return m_opaque_sp->GroupIDIsValid(); } void SBLaunchInfo::SetUserID(uint32_t uid) { - LLDB_RECORD_METHOD(void, SBLaunchInfo, SetUserID, (uint32_t), uid); + LLDB_INSTRUMENT_VA(this, uid); m_opaque_sp->SetUserID(uid); } void SBLaunchInfo::SetGroupID(uint32_t gid) { - LLDB_RECORD_METHOD(void, SBLaunchInfo, SetGroupID, (uint32_t), gid); + LLDB_INSTRUMENT_VA(this, gid); m_opaque_sp->SetGroupID(gid); } SBFileSpec SBLaunchInfo::GetExecutableFile() { - LLDB_RECORD_METHOD_NO_ARGS(lldb::SBFileSpec, SBLaunchInfo, GetExecutableFile); + LLDB_INSTRUMENT_VA(this); - return LLDB_RECORD_RESULT(SBFileSpec(m_opaque_sp->GetExecutableFile())); + return SBFileSpec(m_opaque_sp->GetExecutableFile()); } void SBLaunchInfo::SetExecutableFile(SBFileSpec exe_file, bool add_as_first_arg) { - LLDB_RECORD_METHOD(void, SBLaunchInfo, SetExecutableFile, - (lldb::SBFileSpec, bool), exe_file, add_as_first_arg); + LLDB_INSTRUMENT_VA(this, exe_file, add_as_first_arg); m_opaque_sp->SetExecutableFile(exe_file.ref(), add_as_first_arg); } SBListener SBLaunchInfo::GetListener() { - LLDB_RECORD_METHOD_NO_ARGS(lldb::SBListener, SBLaunchInfo, GetListener); + LLDB_INSTRUMENT_VA(this); - return LLDB_RECORD_RESULT(SBListener(m_opaque_sp->GetListener())); + return SBListener(m_opaque_sp->GetListener()); } void SBLaunchInfo::SetListener(SBListener &listener) { - LLDB_RECORD_METHOD(void, SBLaunchInfo, SetListener, (lldb::SBListener &), - listener); + LLDB_INSTRUMENT_VA(this, listener); m_opaque_sp->SetListener(listener.GetSP()); } uint32_t SBLaunchInfo::GetNumArguments() { - LLDB_RECORD_METHOD_NO_ARGS(uint32_t, SBLaunchInfo, GetNumArguments); + LLDB_INSTRUMENT_VA(this); return m_opaque_sp->GetArguments().GetArgumentCount(); } const char *SBLaunchInfo::GetArgumentAtIndex(uint32_t idx) { - LLDB_RECORD_METHOD(const char *, SBLaunchInfo, GetArgumentAtIndex, (uint32_t), - idx); + LLDB_INSTRUMENT_VA(this, idx); return m_opaque_sp->GetArguments().GetArgumentAtIndex(idx); } void SBLaunchInfo::SetArguments(const char **argv, bool append) { - LLDB_RECORD_METHOD(void, SBLaunchInfo, SetArguments, (const char **, bool), - argv, append); + LLDB_INSTRUMENT_VA(this, argv, append); if (append) { if (argv) @@ -170,14 +164,13 @@ void SBLaunchInfo::SetArguments(const char **argv, bool append) { } uint32_t SBLaunchInfo::GetNumEnvironmentEntries() { - LLDB_RECORD_METHOD_NO_ARGS(uint32_t, SBLaunchInfo, GetNumEnvironmentEntries); + LLDB_INSTRUMENT_VA(this); return m_opaque_sp->GetEnvironment().size(); } const char *SBLaunchInfo::GetEnvironmentEntryAtIndex(uint32_t idx) { - LLDB_RECORD_METHOD(const char *, SBLaunchInfo, GetEnvironmentEntryAtIndex, - (uint32_t), idx); + LLDB_INSTRUMENT_VA(this, idx); if (idx > GetNumEnvironmentEntries()) return nullptr; @@ -185,14 +178,12 @@ const char *SBLaunchInfo::GetEnvironmentEntryAtIndex(uint32_t idx) { } void SBLaunchInfo::SetEnvironmentEntries(const char **envp, bool append) { - LLDB_RECORD_METHOD(void, SBLaunchInfo, SetEnvironmentEntries, - (const char **, bool), envp, append); + LLDB_INSTRUMENT_VA(this, envp, append); SetEnvironment(SBEnvironment(Environment(envp)), append); } void SBLaunchInfo::SetEnvironment(const SBEnvironment &env, bool append) { - LLDB_RECORD_METHOD(void, SBLaunchInfo, SetEnvironment, - (const lldb::SBEnvironment &, bool), env, append); + LLDB_INSTRUMENT_VA(this, env, append); Environment &refEnv = env.ref(); if (append) { for (auto &KV : refEnv) @@ -203,58 +194,54 @@ void SBLaunchInfo::SetEnvironment(const SBEnvironment &env, bool append) { } SBEnvironment SBLaunchInfo::GetEnvironment() { - LLDB_RECORD_METHOD_NO_ARGS(lldb::SBEnvironment, SBLaunchInfo, GetEnvironment); - return LLDB_RECORD_RESULT( - SBEnvironment(Environment(m_opaque_sp->GetEnvironment()))); + LLDB_INSTRUMENT_VA(this); + return SBEnvironment(Environment(m_opaque_sp->GetEnvironment())); } void SBLaunchInfo::Clear() { - LLDB_RECORD_METHOD_NO_ARGS(void, SBLaunchInfo, Clear); + LLDB_INSTRUMENT_VA(this); m_opaque_sp->Clear(); } const char *SBLaunchInfo::GetWorkingDirectory() const { - LLDB_RECORD_METHOD_CONST_NO_ARGS(const char *, SBLaunchInfo, - GetWorkingDirectory); + LLDB_INSTRUMENT_VA(this); return m_opaque_sp->GetWorkingDirectory().GetCString(); } void SBLaunchInfo::SetWorkingDirectory(const char *working_dir) { - LLDB_RECORD_METHOD(void, SBLaunchInfo, SetWorkingDirectory, (const char *), - working_dir); + LLDB_INSTRUMENT_VA(this, working_dir); m_opaque_sp->SetWorkingDirectory(FileSpec(working_dir)); } uint32_t SBLaunchInfo::GetLaunchFlags() { - LLDB_RECORD_METHOD_NO_ARGS(uint32_t, SBLaunchInfo, GetLaunchFlags); + LLDB_INSTRUMENT_VA(this); return m_opaque_sp->GetFlags().Get(); } void SBLaunchInfo::SetLaunchFlags(uint32_t flags) { - LLDB_RECORD_METHOD(void, SBLaunchInfo, SetLaunchFlags, (uint32_t), flags); + LLDB_INSTRUMENT_VA(this, flags); m_opaque_sp->GetFlags().Reset(flags); } const char *SBLaunchInfo::GetProcessPluginName() { - LLDB_RECORD_METHOD_NO_ARGS(const char *, SBLaunchInfo, GetProcessPluginName); + LLDB_INSTRUMENT_VA(this); return m_opaque_sp->GetProcessPluginName(); } void SBLaunchInfo::SetProcessPluginName(const char *plugin_name) { - LLDB_RECORD_METHOD(void, SBLaunchInfo, SetProcessPluginName, (const char *), - plugin_name); + LLDB_INSTRUMENT_VA(this, plugin_name); return m_opaque_sp->SetProcessPluginName(plugin_name); } const char *SBLaunchInfo::GetShell() { - LLDB_RECORD_METHOD_NO_ARGS(const char *, SBLaunchInfo, GetShell); + LLDB_INSTRUMENT_VA(this); // Constify this string so that it is saved in the string pool. Otherwise it // would be freed when this function goes out of scope. @@ -263,93 +250,86 @@ const char *SBLaunchInfo::GetShell() { } void SBLaunchInfo::SetShell(const char *path) { - LLDB_RECORD_METHOD(void, SBLaunchInfo, SetShell, (const char *), path); + LLDB_INSTRUMENT_VA(this, path); m_opaque_sp->SetShell(FileSpec(path)); } bool SBLaunchInfo::GetShellExpandArguments() { - LLDB_RECORD_METHOD_NO_ARGS(bool, SBLaunchInfo, GetShellExpandArguments); + LLDB_INSTRUMENT_VA(this); return m_opaque_sp->GetShellExpandArguments(); } void SBLaunchInfo::SetShellExpandArguments(bool expand) { - LLDB_RECORD_METHOD(void, SBLaunchInfo, SetShellExpandArguments, (bool), - expand); + LLDB_INSTRUMENT_VA(this, expand); m_opaque_sp->SetShellExpandArguments(expand); } uint32_t SBLaunchInfo::GetResumeCount() { - LLDB_RECORD_METHOD_NO_ARGS(uint32_t, SBLaunchInfo, GetResumeCount); + LLDB_INSTRUMENT_VA(this); return m_opaque_sp->GetResumeCount(); } void SBLaunchInfo::SetResumeCount(uint32_t c) { - LLDB_RECORD_METHOD(void, SBLaunchInfo, SetResumeCount, (uint32_t), c); + LLDB_INSTRUMENT_VA(this, c); m_opaque_sp->SetResumeCount(c); } bool SBLaunchInfo::AddCloseFileAction(int fd) { - LLDB_RECORD_METHOD(bool, SBLaunchInfo, AddCloseFileAction, (int), fd); + LLDB_INSTRUMENT_VA(this, fd); return m_opaque_sp->AppendCloseFileAction(fd); } bool SBLaunchInfo::AddDuplicateFileAction(int fd, int dup_fd) { - LLDB_RECORD_METHOD(bool, SBLaunchInfo, AddDuplicateFileAction, (int, int), fd, - dup_fd); + LLDB_INSTRUMENT_VA(this, fd, dup_fd); return m_opaque_sp->AppendDuplicateFileAction(fd, dup_fd); } bool SBLaunchInfo::AddOpenFileAction(int fd, const char *path, bool read, bool write) { - LLDB_RECORD_METHOD(bool, SBLaunchInfo, AddOpenFileAction, - (int, const char *, bool, bool), fd, path, read, write); + LLDB_INSTRUMENT_VA(this, fd, path, read, write); return m_opaque_sp->AppendOpenFileAction(fd, FileSpec(path), read, write); } bool SBLaunchInfo::AddSuppressFileAction(int fd, bool read, bool write) { - LLDB_RECORD_METHOD(bool, SBLaunchInfo, AddSuppressFileAction, - (int, bool, bool), fd, read, write); + LLDB_INSTRUMENT_VA(this, fd, read, write); return m_opaque_sp->AppendSuppressFileAction(fd, read, write); } void SBLaunchInfo::SetLaunchEventData(const char *data) { - LLDB_RECORD_METHOD(void, SBLaunchInfo, SetLaunchEventData, (const char *), - data); + LLDB_INSTRUMENT_VA(this, data); m_opaque_sp->SetLaunchEventData(data); } const char *SBLaunchInfo::GetLaunchEventData() const { - LLDB_RECORD_METHOD_CONST_NO_ARGS(const char *, SBLaunchInfo, - GetLaunchEventData); + LLDB_INSTRUMENT_VA(this); return m_opaque_sp->GetLaunchEventData(); } void SBLaunchInfo::SetDetachOnError(bool enable) { - LLDB_RECORD_METHOD(void, SBLaunchInfo, SetDetachOnError, (bool), enable); + LLDB_INSTRUMENT_VA(this, enable); m_opaque_sp->SetDetachOnError(enable); } bool SBLaunchInfo::GetDetachOnError() const { - LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBLaunchInfo, GetDetachOnError); + LLDB_INSTRUMENT_VA(this); return m_opaque_sp->GetDetachOnError(); } const char *SBLaunchInfo::GetScriptedProcessClassName() const { - LLDB_RECORD_METHOD_CONST_NO_ARGS(const char *, SBLaunchInfo, - GetScriptedProcessClassName); + LLDB_INSTRUMENT_VA(this); // Constify this string so that it is saved in the string pool. Otherwise it // would be freed when this function goes out of scope. @@ -358,15 +338,13 @@ const char *SBLaunchInfo::GetScriptedProcessClassName() const { } void SBLaunchInfo::SetScriptedProcessClassName(const char *class_name) { - LLDB_RECORD_METHOD(void, SBLaunchInfo, SetScriptedProcessClassName, - (const char *), class_name); + LLDB_INSTRUMENT_VA(this, class_name); m_opaque_sp->SetScriptedProcessClassName(class_name); } lldb::SBStructuredData SBLaunchInfo::GetScriptedProcessDictionary() const { - LLDB_RECORD_METHOD_CONST_NO_ARGS(lldb::SBStructuredData, SBLaunchInfo, - GetScriptedProcessDictionary); + LLDB_INSTRUMENT_VA(this); lldb_private::StructuredData::DictionarySP dict_sp = m_opaque_sp->GetScriptedProcessDictionarySP(); @@ -374,12 +352,11 @@ lldb::SBStructuredData SBLaunchInfo::GetScriptedProcessDictionary() const { SBStructuredData data; data.m_impl_up->SetObjectSP(dict_sp); - return LLDB_RECORD_RESULT(data); + return data; } void SBLaunchInfo::SetScriptedProcessDictionary(lldb::SBStructuredData dict) { - LLDB_RECORD_METHOD(void, SBLaunchInfo, SetScriptedProcessDictionary, - (lldb::SBStructuredData), dict); + LLDB_INSTRUMENT_VA(this, dict); if (!dict.IsValid() || !dict.m_impl_up) return; @@ -395,79 +372,3 @@ void SBLaunchInfo::SetScriptedProcessDictionary(lldb::SBStructuredData dict) { m_opaque_sp->SetScriptedProcessDictionarySP(dict_sp); } - -namespace lldb_private { -namespace repro { - -template <> -void RegisterMethods<SBLaunchInfo>(Registry &R) { - LLDB_REGISTER_CONSTRUCTOR(SBLaunchInfo, (const char **)); - LLDB_REGISTER_CONSTRUCTOR(SBLaunchInfo, (const lldb::SBLaunchInfo &)); - LLDB_REGISTER_METHOD(SBLaunchInfo &, - SBLaunchInfo, operator=,(const lldb::SBLaunchInfo &)); - LLDB_REGISTER_METHOD(lldb::pid_t, SBLaunchInfo, GetProcessID, ()); - LLDB_REGISTER_METHOD(uint32_t, SBLaunchInfo, GetUserID, ()); - LLDB_REGISTER_METHOD(uint32_t, SBLaunchInfo, GetGroupID, ()); - LLDB_REGISTER_METHOD(bool, SBLaunchInfo, UserIDIsValid, ()); - LLDB_REGISTER_METHOD(bool, SBLaunchInfo, GroupIDIsValid, ()); - LLDB_REGISTER_METHOD(void, SBLaunchInfo, SetUserID, (uint32_t)); - LLDB_REGISTER_METHOD(void, SBLaunchInfo, SetGroupID, (uint32_t)); - LLDB_REGISTER_METHOD(lldb::SBFileSpec, SBLaunchInfo, GetExecutableFile, ()); - LLDB_REGISTER_METHOD(void, SBLaunchInfo, SetExecutableFile, - (lldb::SBFileSpec, bool)); - LLDB_REGISTER_METHOD(lldb::SBListener, SBLaunchInfo, GetListener, ()); - LLDB_REGISTER_METHOD(void, SBLaunchInfo, SetListener, (lldb::SBListener &)); - LLDB_REGISTER_METHOD(uint32_t, SBLaunchInfo, GetNumArguments, ()); - LLDB_REGISTER_METHOD(const char *, SBLaunchInfo, GetArgumentAtIndex, - (uint32_t)); - LLDB_REGISTER_METHOD(void, SBLaunchInfo, SetArguments, - (const char **, bool)); - LLDB_REGISTER_METHOD(uint32_t, SBLaunchInfo, GetNumEnvironmentEntries, ()); - LLDB_REGISTER_METHOD(const char *, SBLaunchInfo, GetEnvironmentEntryAtIndex, - (uint32_t)); - LLDB_REGISTER_METHOD(void, SBLaunchInfo, SetEnvironmentEntries, - (const char **, bool)); - LLDB_REGISTER_METHOD(void, SBLaunchInfo, Clear, ()); - LLDB_REGISTER_METHOD_CONST(const char *, SBLaunchInfo, GetWorkingDirectory, - ()); - LLDB_REGISTER_METHOD(void, SBLaunchInfo, SetWorkingDirectory, - (const char *)); - LLDB_REGISTER_METHOD(uint32_t, SBLaunchInfo, GetLaunchFlags, ()); - LLDB_REGISTER_METHOD(void, SBLaunchInfo, SetLaunchFlags, (uint32_t)); - LLDB_REGISTER_METHOD(const char *, SBLaunchInfo, GetProcessPluginName, ()); - LLDB_REGISTER_METHOD(void, SBLaunchInfo, SetProcessPluginName, - (const char *)); - LLDB_REGISTER_METHOD(const char *, SBLaunchInfo, GetShell, ()); - LLDB_REGISTER_METHOD(void, SBLaunchInfo, SetShell, (const char *)); - LLDB_REGISTER_METHOD(bool, SBLaunchInfo, GetShellExpandArguments, ()); - LLDB_REGISTER_METHOD(void, SBLaunchInfo, SetShellExpandArguments, (bool)); - LLDB_REGISTER_METHOD(uint32_t, SBLaunchInfo, GetResumeCount, ()); - LLDB_REGISTER_METHOD(void, SBLaunchInfo, SetResumeCount, (uint32_t)); - LLDB_REGISTER_METHOD(bool, SBLaunchInfo, AddCloseFileAction, (int)); - LLDB_REGISTER_METHOD(bool, SBLaunchInfo, AddDuplicateFileAction, - (int, int)); - LLDB_REGISTER_METHOD(bool, SBLaunchInfo, AddOpenFileAction, - (int, const char *, bool, bool)); - LLDB_REGISTER_METHOD(bool, SBLaunchInfo, AddSuppressFileAction, - (int, bool, bool)); - LLDB_REGISTER_METHOD(void, SBLaunchInfo, SetLaunchEventData, - (const char *)); - LLDB_REGISTER_METHOD_CONST(const char *, SBLaunchInfo, GetLaunchEventData, - ()); - LLDB_REGISTER_METHOD(void, SBLaunchInfo, SetDetachOnError, (bool)); - LLDB_REGISTER_METHOD_CONST(bool, SBLaunchInfo, GetDetachOnError, ()); - LLDB_REGISTER_METHOD_CONST(const char *, SBLaunchInfo, - GetScriptedProcessClassName, ()); - LLDB_REGISTER_METHOD(void, SBLaunchInfo, SetScriptedProcessClassName, - (const char *)); - LLDB_REGISTER_METHOD_CONST(lldb::SBStructuredData, SBLaunchInfo, - GetScriptedProcessDictionary, ()); - LLDB_REGISTER_METHOD(void, SBLaunchInfo, SetScriptedProcessDictionary, - (lldb::SBStructuredData)); - LLDB_REGISTER_METHOD(void, SBLaunchInfo, SetEnvironment, - (const lldb::SBEnvironment &, bool)); - LLDB_REGISTER_METHOD(lldb::SBEnvironment, SBLaunchInfo, GetEnvironment, ()); -} - -} -} diff --git a/lldb/source/API/SBLineEntry.cpp b/lldb/source/API/SBLineEntry.cpp index 29ffda9b0471..28d12e65fdaf 100644 --- a/lldb/source/API/SBLineEntry.cpp +++ b/lldb/source/API/SBLineEntry.cpp @@ -7,11 +7,11 @@ //===----------------------------------------------------------------------===// #include "lldb/API/SBLineEntry.h" -#include "SBReproducerPrivate.h" #include "Utils.h" #include "lldb/API/SBStream.h" #include "lldb/Host/PosixApi.h" #include "lldb/Symbol/LineEntry.h" +#include "lldb/Utility/Instrumentation.h" #include "lldb/Utility/StreamString.h" #include <climits> @@ -19,29 +19,25 @@ using namespace lldb; using namespace lldb_private; -SBLineEntry::SBLineEntry() : m_opaque_up() { - LLDB_RECORD_CONSTRUCTOR_NO_ARGS(SBLineEntry); -} +SBLineEntry::SBLineEntry() { LLDB_INSTRUMENT_VA(this); } -SBLineEntry::SBLineEntry(const SBLineEntry &rhs) : m_opaque_up() { - LLDB_RECORD_CONSTRUCTOR(SBLineEntry, (const lldb::SBLineEntry &), rhs); +SBLineEntry::SBLineEntry(const SBLineEntry &rhs) { + LLDB_INSTRUMENT_VA(this, rhs); m_opaque_up = clone(rhs.m_opaque_up); } -SBLineEntry::SBLineEntry(const lldb_private::LineEntry *lldb_object_ptr) - : m_opaque_up() { +SBLineEntry::SBLineEntry(const lldb_private::LineEntry *lldb_object_ptr) { if (lldb_object_ptr) m_opaque_up = std::make_unique<LineEntry>(*lldb_object_ptr); } const SBLineEntry &SBLineEntry::operator=(const SBLineEntry &rhs) { - LLDB_RECORD_METHOD(const lldb::SBLineEntry &, - SBLineEntry, operator=,(const lldb::SBLineEntry &), rhs); + LLDB_INSTRUMENT_VA(this, rhs); if (this != &rhs) m_opaque_up = clone(rhs.m_opaque_up); - return LLDB_RECORD_RESULT(*this); + return *this; } void SBLineEntry::SetLineEntry(const lldb_private::LineEntry &lldb_object_ref) { @@ -51,49 +47,48 @@ void SBLineEntry::SetLineEntry(const lldb_private::LineEntry &lldb_object_ref) { SBLineEntry::~SBLineEntry() = default; SBAddress SBLineEntry::GetStartAddress() const { - LLDB_RECORD_METHOD_CONST_NO_ARGS(lldb::SBAddress, SBLineEntry, - GetStartAddress); + LLDB_INSTRUMENT_VA(this); SBAddress sb_address; if (m_opaque_up) sb_address.SetAddress(m_opaque_up->range.GetBaseAddress()); - return LLDB_RECORD_RESULT(sb_address); + return sb_address; } SBAddress SBLineEntry::GetEndAddress() const { - LLDB_RECORD_METHOD_CONST_NO_ARGS(lldb::SBAddress, SBLineEntry, GetEndAddress); + LLDB_INSTRUMENT_VA(this); SBAddress sb_address; if (m_opaque_up) { sb_address.SetAddress(m_opaque_up->range.GetBaseAddress()); sb_address.OffsetAddress(m_opaque_up->range.GetByteSize()); } - return LLDB_RECORD_RESULT(sb_address); + return sb_address; } bool SBLineEntry::IsValid() const { - LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBLineEntry, IsValid); + LLDB_INSTRUMENT_VA(this); return this->operator bool(); } SBLineEntry::operator bool() const { - LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBLineEntry, operator bool); + LLDB_INSTRUMENT_VA(this); return m_opaque_up.get() && m_opaque_up->IsValid(); } SBFileSpec SBLineEntry::GetFileSpec() const { - LLDB_RECORD_METHOD_CONST_NO_ARGS(lldb::SBFileSpec, SBLineEntry, GetFileSpec); + LLDB_INSTRUMENT_VA(this); SBFileSpec sb_file_spec; if (m_opaque_up.get() && m_opaque_up->file) sb_file_spec.SetFileSpec(m_opaque_up->file); - return LLDB_RECORD_RESULT(sb_file_spec); + return sb_file_spec; } uint32_t SBLineEntry::GetLine() const { - LLDB_RECORD_METHOD_CONST_NO_ARGS(uint32_t, SBLineEntry, GetLine); + LLDB_INSTRUMENT_VA(this); uint32_t line = 0; if (m_opaque_up) @@ -103,7 +98,7 @@ uint32_t SBLineEntry::GetLine() const { } uint32_t SBLineEntry::GetColumn() const { - LLDB_RECORD_METHOD_CONST_NO_ARGS(uint32_t, SBLineEntry, GetColumn); + LLDB_INSTRUMENT_VA(this); if (m_opaque_up) return m_opaque_up->column; @@ -111,8 +106,7 @@ uint32_t SBLineEntry::GetColumn() const { } void SBLineEntry::SetFileSpec(lldb::SBFileSpec filespec) { - LLDB_RECORD_METHOD(void, SBLineEntry, SetFileSpec, (lldb::SBFileSpec), - filespec); + LLDB_INSTRUMENT_VA(this, filespec); if (filespec.IsValid()) ref().file = filespec.ref(); @@ -120,20 +114,19 @@ void SBLineEntry::SetFileSpec(lldb::SBFileSpec filespec) { ref().file.Clear(); } void SBLineEntry::SetLine(uint32_t line) { - LLDB_RECORD_METHOD(void, SBLineEntry, SetLine, (uint32_t), line); + LLDB_INSTRUMENT_VA(this, line); ref().line = line; } void SBLineEntry::SetColumn(uint32_t column) { - LLDB_RECORD_METHOD(void, SBLineEntry, SetColumn, (uint32_t), column); + LLDB_INSTRUMENT_VA(this, column); ref().line = column; } bool SBLineEntry::operator==(const SBLineEntry &rhs) const { - LLDB_RECORD_METHOD_CONST( - bool, SBLineEntry, operator==,(const lldb::SBLineEntry &), rhs); + LLDB_INSTRUMENT_VA(this, rhs); lldb_private::LineEntry *lhs_ptr = m_opaque_up.get(); lldb_private::LineEntry *rhs_ptr = rhs.m_opaque_up.get(); @@ -145,8 +138,7 @@ bool SBLineEntry::operator==(const SBLineEntry &rhs) const { } bool SBLineEntry::operator!=(const SBLineEntry &rhs) const { - LLDB_RECORD_METHOD_CONST( - bool, SBLineEntry, operator!=,(const lldb::SBLineEntry &), rhs); + LLDB_INSTRUMENT_VA(this, rhs); lldb_private::LineEntry *lhs_ptr = m_opaque_up.get(); lldb_private::LineEntry *rhs_ptr = rhs.m_opaque_up.get(); @@ -170,8 +162,7 @@ lldb_private::LineEntry &SBLineEntry::ref() { const lldb_private::LineEntry &SBLineEntry::ref() const { return *m_opaque_up; } bool SBLineEntry::GetDescription(SBStream &description) { - LLDB_RECORD_METHOD(bool, SBLineEntry, GetDescription, (lldb::SBStream &), - description); + LLDB_INSTRUMENT_VA(this, description); Stream &strm = description.ref(); @@ -188,33 +179,3 @@ bool SBLineEntry::GetDescription(SBStream &description) { } lldb_private::LineEntry *SBLineEntry::get() { return m_opaque_up.get(); } - -namespace lldb_private { -namespace repro { - -template <> -void RegisterMethods<SBLineEntry>(Registry &R) { - LLDB_REGISTER_CONSTRUCTOR(SBLineEntry, ()); - LLDB_REGISTER_CONSTRUCTOR(SBLineEntry, (const lldb::SBLineEntry &)); - LLDB_REGISTER_METHOD(const lldb::SBLineEntry &, - SBLineEntry, operator=,(const lldb::SBLineEntry &)); - LLDB_REGISTER_METHOD_CONST(lldb::SBAddress, SBLineEntry, GetStartAddress, - ()); - LLDB_REGISTER_METHOD_CONST(lldb::SBAddress, SBLineEntry, GetEndAddress, ()); - LLDB_REGISTER_METHOD_CONST(bool, SBLineEntry, IsValid, ()); - LLDB_REGISTER_METHOD_CONST(bool, SBLineEntry, operator bool, ()); - LLDB_REGISTER_METHOD_CONST(lldb::SBFileSpec, SBLineEntry, GetFileSpec, ()); - LLDB_REGISTER_METHOD_CONST(uint32_t, SBLineEntry, GetLine, ()); - LLDB_REGISTER_METHOD_CONST(uint32_t, SBLineEntry, GetColumn, ()); - LLDB_REGISTER_METHOD(void, SBLineEntry, SetFileSpec, (lldb::SBFileSpec)); - LLDB_REGISTER_METHOD(void, SBLineEntry, SetLine, (uint32_t)); - LLDB_REGISTER_METHOD(void, SBLineEntry, SetColumn, (uint32_t)); - LLDB_REGISTER_METHOD_CONST( - bool, SBLineEntry, operator==,(const lldb::SBLineEntry &)); - LLDB_REGISTER_METHOD_CONST( - bool, SBLineEntry, operator!=,(const lldb::SBLineEntry &)); - LLDB_REGISTER_METHOD(bool, SBLineEntry, GetDescription, (lldb::SBStream &)); -} - -} -} diff --git a/lldb/source/API/SBListener.cpp b/lldb/source/API/SBListener.cpp index 6e5e15de7b3d..2ce17a5f521d 100644 --- a/lldb/source/API/SBListener.cpp +++ b/lldb/source/API/SBListener.cpp @@ -7,42 +7,39 @@ //===----------------------------------------------------------------------===// #include "lldb/API/SBListener.h" -#include "SBReproducerPrivate.h" #include "lldb/API/SBBroadcaster.h" #include "lldb/API/SBDebugger.h" #include "lldb/API/SBEvent.h" #include "lldb/API/SBStream.h" #include "lldb/Core/Debugger.h" #include "lldb/Utility/Broadcaster.h" +#include "lldb/Utility/Instrumentation.h" #include "lldb/Utility/Listener.h" #include "lldb/Utility/StreamString.h" using namespace lldb; using namespace lldb_private; -SBListener::SBListener() : m_opaque_sp() { - LLDB_RECORD_CONSTRUCTOR_NO_ARGS(SBListener); -} +SBListener::SBListener() { LLDB_INSTRUMENT_VA(this); } SBListener::SBListener(const char *name) : m_opaque_sp(Listener::MakeListener(name)), m_unused_ptr(nullptr) { - LLDB_RECORD_CONSTRUCTOR(SBListener, (const char *), name); + LLDB_INSTRUMENT_VA(this, name); } SBListener::SBListener(const SBListener &rhs) : m_opaque_sp(rhs.m_opaque_sp), m_unused_ptr(nullptr) { - LLDB_RECORD_CONSTRUCTOR(SBListener, (const lldb::SBListener &), rhs); + LLDB_INSTRUMENT_VA(this, rhs); } const lldb::SBListener &SBListener::operator=(const lldb::SBListener &rhs) { - LLDB_RECORD_METHOD(const lldb::SBListener &, - SBListener, operator=,(const lldb::SBListener &), rhs); + LLDB_INSTRUMENT_VA(this, rhs); if (this != &rhs) { m_opaque_sp = rhs.m_opaque_sp; m_unused_ptr = nullptr; } - return LLDB_RECORD_RESULT(*this); + return *this; } SBListener::SBListener(const lldb::ListenerSP &listener_sp) @@ -51,18 +48,17 @@ SBListener::SBListener(const lldb::ListenerSP &listener_sp) SBListener::~SBListener() = default; bool SBListener::IsValid() const { - LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBListener, IsValid); + LLDB_INSTRUMENT_VA(this); return this->operator bool(); } SBListener::operator bool() const { - LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBListener, operator bool); + LLDB_INSTRUMENT_VA(this); return m_opaque_sp != nullptr; } void SBListener::AddEvent(const SBEvent &event) { - LLDB_RECORD_METHOD(void, SBListener, AddEvent, (const lldb::SBEvent &), - event); + LLDB_INSTRUMENT_VA(this, event); EventSP &event_sp = event.GetSP(); if (event_sp) @@ -70,7 +66,7 @@ void SBListener::AddEvent(const SBEvent &event) { } void SBListener::Clear() { - LLDB_RECORD_METHOD_NO_ARGS(void, SBListener, Clear); + LLDB_INSTRUMENT_VA(this); if (m_opaque_sp) m_opaque_sp->Clear(); @@ -79,9 +75,7 @@ void SBListener::Clear() { uint32_t SBListener::StartListeningForEventClass(SBDebugger &debugger, const char *broadcaster_class, uint32_t event_mask) { - LLDB_RECORD_METHOD(uint32_t, SBListener, StartListeningForEventClass, - (lldb::SBDebugger &, const char *, uint32_t), debugger, - broadcaster_class, event_mask); + LLDB_INSTRUMENT_VA(this, debugger, broadcaster_class, event_mask); if (m_opaque_sp) { Debugger *lldb_debugger = debugger.get(); @@ -97,9 +91,7 @@ uint32_t SBListener::StartListeningForEventClass(SBDebugger &debugger, bool SBListener::StopListeningForEventClass(SBDebugger &debugger, const char *broadcaster_class, uint32_t event_mask) { - LLDB_RECORD_METHOD(bool, SBListener, StopListeningForEventClass, - (lldb::SBDebugger &, const char *, uint32_t), debugger, - broadcaster_class, event_mask); + LLDB_INSTRUMENT_VA(this, debugger, broadcaster_class, event_mask); if (m_opaque_sp) { Debugger *lldb_debugger = debugger.get(); @@ -114,9 +106,7 @@ bool SBListener::StopListeningForEventClass(SBDebugger &debugger, uint32_t SBListener::StartListeningForEvents(const SBBroadcaster &broadcaster, uint32_t event_mask) { - LLDB_RECORD_METHOD(uint32_t, SBListener, StartListeningForEvents, - (const lldb::SBBroadcaster &, uint32_t), broadcaster, - event_mask); + LLDB_INSTRUMENT_VA(this, broadcaster, event_mask); uint32_t acquired_event_mask = 0; if (m_opaque_sp && broadcaster.IsValid()) { @@ -129,9 +119,7 @@ uint32_t SBListener::StartListeningForEvents(const SBBroadcaster &broadcaster, bool SBListener::StopListeningForEvents(const SBBroadcaster &broadcaster, uint32_t event_mask) { - LLDB_RECORD_METHOD(bool, SBListener, StopListeningForEvents, - (const lldb::SBBroadcaster &, uint32_t), broadcaster, - event_mask); + LLDB_INSTRUMENT_VA(this, broadcaster, event_mask); if (m_opaque_sp && broadcaster.IsValid()) { return m_opaque_sp->StopListeningForEvents(broadcaster.get(), event_mask); @@ -140,8 +128,7 @@ bool SBListener::StopListeningForEvents(const SBBroadcaster &broadcaster, } bool SBListener::WaitForEvent(uint32_t timeout_secs, SBEvent &event) { - LLDB_RECORD_METHOD(bool, SBListener, WaitForEvent, - (uint32_t, lldb::SBEvent &), timeout_secs, event); + LLDB_INSTRUMENT_VA(this, timeout_secs, event); bool success = false; @@ -167,9 +154,7 @@ bool SBListener::WaitForEvent(uint32_t timeout_secs, SBEvent &event) { bool SBListener::WaitForEventForBroadcaster(uint32_t num_seconds, const SBBroadcaster &broadcaster, SBEvent &event) { - LLDB_RECORD_METHOD(bool, SBListener, WaitForEventForBroadcaster, - (uint32_t, const lldb::SBBroadcaster &, lldb::SBEvent &), - num_seconds, broadcaster, event); + LLDB_INSTRUMENT_VA(this, num_seconds, broadcaster, event); if (m_opaque_sp && broadcaster.IsValid()) { Timeout<std::micro> timeout(llvm::None); @@ -189,10 +174,7 @@ bool SBListener::WaitForEventForBroadcaster(uint32_t num_seconds, bool SBListener::WaitForEventForBroadcasterWithType( uint32_t num_seconds, const SBBroadcaster &broadcaster, uint32_t event_type_mask, SBEvent &event) { - LLDB_RECORD_METHOD( - bool, SBListener, WaitForEventForBroadcasterWithType, - (uint32_t, const lldb::SBBroadcaster &, uint32_t, lldb::SBEvent &), - num_seconds, broadcaster, event_type_mask, event); + LLDB_INSTRUMENT_VA(this, num_seconds, broadcaster, event_type_mask, event); if (m_opaque_sp && broadcaster.IsValid()) { Timeout<std::micro> timeout(llvm::None); @@ -210,8 +192,7 @@ bool SBListener::WaitForEventForBroadcasterWithType( } bool SBListener::PeekAtNextEvent(SBEvent &event) { - LLDB_RECORD_METHOD(bool, SBListener, PeekAtNextEvent, (lldb::SBEvent &), - event); + LLDB_INSTRUMENT_VA(this, event); if (m_opaque_sp) { event.reset(m_opaque_sp->PeekAtNextEvent()); @@ -223,9 +204,7 @@ bool SBListener::PeekAtNextEvent(SBEvent &event) { bool SBListener::PeekAtNextEventForBroadcaster(const SBBroadcaster &broadcaster, SBEvent &event) { - LLDB_RECORD_METHOD(bool, SBListener, PeekAtNextEventForBroadcaster, - (const lldb::SBBroadcaster &, lldb::SBEvent &), - broadcaster, event); + LLDB_INSTRUMENT_VA(this, broadcaster, event); if (m_opaque_sp && broadcaster.IsValid()) { event.reset(m_opaque_sp->PeekAtNextEventForBroadcaster(broadcaster.get())); @@ -238,9 +217,7 @@ bool SBListener::PeekAtNextEventForBroadcaster(const SBBroadcaster &broadcaster, bool SBListener::PeekAtNextEventForBroadcasterWithType( const SBBroadcaster &broadcaster, uint32_t event_type_mask, SBEvent &event) { - LLDB_RECORD_METHOD(bool, SBListener, PeekAtNextEventForBroadcasterWithType, - (const lldb::SBBroadcaster &, uint32_t, lldb::SBEvent &), - broadcaster, event_type_mask, event); + LLDB_INSTRUMENT_VA(this, broadcaster, event_type_mask, event); if (m_opaque_sp && broadcaster.IsValid()) { event.reset(m_opaque_sp->PeekAtNextEventForBroadcasterWithType( @@ -252,7 +229,7 @@ bool SBListener::PeekAtNextEventForBroadcasterWithType( } bool SBListener::GetNextEvent(SBEvent &event) { - LLDB_RECORD_METHOD(bool, SBListener, GetNextEvent, (lldb::SBEvent &), event); + LLDB_INSTRUMENT_VA(this, event); if (m_opaque_sp) { EventSP event_sp; @@ -267,9 +244,7 @@ bool SBListener::GetNextEvent(SBEvent &event) { bool SBListener::GetNextEventForBroadcaster(const SBBroadcaster &broadcaster, SBEvent &event) { - LLDB_RECORD_METHOD(bool, SBListener, GetNextEventForBroadcaster, - (const lldb::SBBroadcaster &, lldb::SBEvent &), - broadcaster, event); + LLDB_INSTRUMENT_VA(this, broadcaster, event); if (m_opaque_sp && broadcaster.IsValid()) { EventSP event_sp; @@ -286,9 +261,7 @@ bool SBListener::GetNextEventForBroadcaster(const SBBroadcaster &broadcaster, bool SBListener::GetNextEventForBroadcasterWithType( const SBBroadcaster &broadcaster, uint32_t event_type_mask, SBEvent &event) { - LLDB_RECORD_METHOD(bool, SBListener, GetNextEventForBroadcasterWithType, - (const lldb::SBBroadcaster &, uint32_t, lldb::SBEvent &), - broadcaster, event_type_mask, event); + LLDB_INSTRUMENT_VA(this, broadcaster, event_type_mask, event); if (m_opaque_sp && broadcaster.IsValid()) { EventSP event_sp; @@ -304,8 +277,7 @@ bool SBListener::GetNextEventForBroadcasterWithType( } bool SBListener::HandleBroadcastEvent(const SBEvent &event) { - LLDB_RECORD_METHOD(bool, SBListener, HandleBroadcastEvent, - (const lldb::SBEvent &), event); + LLDB_INSTRUMENT_VA(this, event); if (m_opaque_sp) return m_opaque_sp->HandleBroadcastEvent(event.GetSP()); @@ -322,52 +294,3 @@ void SBListener::reset(ListenerSP listener_sp) { m_opaque_sp = listener_sp; m_unused_ptr = nullptr; } - -namespace lldb_private { -namespace repro { - -template <> -void RegisterMethods<SBListener>(Registry &R) { - LLDB_REGISTER_CONSTRUCTOR(SBListener, ()); - LLDB_REGISTER_CONSTRUCTOR(SBListener, (const char *)); - LLDB_REGISTER_CONSTRUCTOR(SBListener, (const lldb::SBListener &)); - LLDB_REGISTER_METHOD(const lldb::SBListener &, - SBListener, operator=,(const lldb::SBListener &)); - LLDB_REGISTER_METHOD_CONST(bool, SBListener, IsValid, ()); - LLDB_REGISTER_METHOD_CONST(bool, SBListener, operator bool, ()); - LLDB_REGISTER_METHOD(void, SBListener, AddEvent, (const lldb::SBEvent &)); - LLDB_REGISTER_METHOD(void, SBListener, Clear, ()); - LLDB_REGISTER_METHOD(uint32_t, SBListener, StartListeningForEventClass, - (lldb::SBDebugger &, const char *, uint32_t)); - LLDB_REGISTER_METHOD(bool, SBListener, StopListeningForEventClass, - (lldb::SBDebugger &, const char *, uint32_t)); - LLDB_REGISTER_METHOD(uint32_t, SBListener, StartListeningForEvents, - (const lldb::SBBroadcaster &, uint32_t)); - LLDB_REGISTER_METHOD(bool, SBListener, StopListeningForEvents, - (const lldb::SBBroadcaster &, uint32_t)); - LLDB_REGISTER_METHOD(bool, SBListener, WaitForEvent, - (uint32_t, lldb::SBEvent &)); - LLDB_REGISTER_METHOD( - bool, SBListener, WaitForEventForBroadcaster, - (uint32_t, const lldb::SBBroadcaster &, lldb::SBEvent &)); - LLDB_REGISTER_METHOD( - bool, SBListener, WaitForEventForBroadcasterWithType, - (uint32_t, const lldb::SBBroadcaster &, uint32_t, lldb::SBEvent &)); - LLDB_REGISTER_METHOD(bool, SBListener, PeekAtNextEvent, (lldb::SBEvent &)); - LLDB_REGISTER_METHOD(bool, SBListener, PeekAtNextEventForBroadcaster, - (const lldb::SBBroadcaster &, lldb::SBEvent &)); - LLDB_REGISTER_METHOD( - bool, SBListener, PeekAtNextEventForBroadcasterWithType, - (const lldb::SBBroadcaster &, uint32_t, lldb::SBEvent &)); - LLDB_REGISTER_METHOD(bool, SBListener, GetNextEvent, (lldb::SBEvent &)); - LLDB_REGISTER_METHOD(bool, SBListener, GetNextEventForBroadcaster, - (const lldb::SBBroadcaster &, lldb::SBEvent &)); - LLDB_REGISTER_METHOD( - bool, SBListener, GetNextEventForBroadcasterWithType, - (const lldb::SBBroadcaster &, uint32_t, lldb::SBEvent &)); - LLDB_REGISTER_METHOD(bool, SBListener, HandleBroadcastEvent, - (const lldb::SBEvent &)); -} - -} -} diff --git a/lldb/source/API/SBMemoryRegionInfo.cpp b/lldb/source/API/SBMemoryRegionInfo.cpp index 9cf7874b54a3..7d9db478dde1 100644 --- a/lldb/source/API/SBMemoryRegionInfo.cpp +++ b/lldb/source/API/SBMemoryRegionInfo.cpp @@ -7,29 +7,26 @@ //===----------------------------------------------------------------------===// #include "lldb/API/SBMemoryRegionInfo.h" -#include "SBReproducerPrivate.h" #include "Utils.h" #include "lldb/API/SBDefines.h" #include "lldb/API/SBError.h" #include "lldb/API/SBStream.h" #include "lldb/Target/MemoryRegionInfo.h" +#include "lldb/Utility/Instrumentation.h" #include "lldb/Utility/StreamString.h" using namespace lldb; using namespace lldb_private; SBMemoryRegionInfo::SBMemoryRegionInfo() : m_opaque_up(new MemoryRegionInfo()) { - LLDB_RECORD_CONSTRUCTOR_NO_ARGS(SBMemoryRegionInfo); + LLDB_INSTRUMENT_VA(this); } SBMemoryRegionInfo::SBMemoryRegionInfo(const char *name, lldb::addr_t begin, lldb::addr_t end, uint32_t permissions, bool mapped, bool stack_memory) : SBMemoryRegionInfo() { - LLDB_RECORD_CONSTRUCTOR( - SBMemoryRegionInfo, - (const char *, lldb::addr_t, lldb::addr_t, uint32_t, bool, bool), name, - begin, end, permissions, mapped, stack_memory); + LLDB_INSTRUMENT_VA(this, name, begin, end, permissions, mapped, stack_memory); m_opaque_up->SetName(name); m_opaque_up->GetRange().SetRangeBase(begin); m_opaque_up->GetRange().SetRangeEnd(end); @@ -46,44 +43,36 @@ SBMemoryRegionInfo::SBMemoryRegionInfo(const MemoryRegionInfo *lldb_object_ptr) ref() = *lldb_object_ptr; } -SBMemoryRegionInfo::SBMemoryRegionInfo(const SBMemoryRegionInfo &rhs) - : m_opaque_up() { - LLDB_RECORD_CONSTRUCTOR(SBMemoryRegionInfo, - (const lldb::SBMemoryRegionInfo &), rhs); +SBMemoryRegionInfo::SBMemoryRegionInfo(const SBMemoryRegionInfo &rhs) { + LLDB_INSTRUMENT_VA(this, rhs); m_opaque_up = clone(rhs.m_opaque_up); } const SBMemoryRegionInfo &SBMemoryRegionInfo:: operator=(const SBMemoryRegionInfo &rhs) { - LLDB_RECORD_METHOD( - const lldb::SBMemoryRegionInfo &, - SBMemoryRegionInfo, operator=,(const lldb::SBMemoryRegionInfo &), rhs); + LLDB_INSTRUMENT_VA(this, rhs); if (this != &rhs) m_opaque_up = clone(rhs.m_opaque_up); - return LLDB_RECORD_RESULT(*this); + return *this; } SBMemoryRegionInfo::~SBMemoryRegionInfo() = default; void SBMemoryRegionInfo::Clear() { - LLDB_RECORD_METHOD_NO_ARGS(void, SBMemoryRegionInfo, Clear); + LLDB_INSTRUMENT_VA(this); m_opaque_up->Clear(); } bool SBMemoryRegionInfo::operator==(const SBMemoryRegionInfo &rhs) const { - LLDB_RECORD_METHOD_CONST( - bool, SBMemoryRegionInfo, operator==,(const lldb::SBMemoryRegionInfo &), - rhs); + LLDB_INSTRUMENT_VA(this, rhs); return ref() == rhs.ref(); } bool SBMemoryRegionInfo::operator!=(const SBMemoryRegionInfo &rhs) const { - LLDB_RECORD_METHOD_CONST( - bool, SBMemoryRegionInfo, operator!=,(const lldb::SBMemoryRegionInfo &), - rhs); + LLDB_INSTRUMENT_VA(this, rhs); return ref() != rhs.ref(); } @@ -93,55 +82,55 @@ MemoryRegionInfo &SBMemoryRegionInfo::ref() { return *m_opaque_up; } const MemoryRegionInfo &SBMemoryRegionInfo::ref() const { return *m_opaque_up; } lldb::addr_t SBMemoryRegionInfo::GetRegionBase() { - LLDB_RECORD_METHOD_NO_ARGS(lldb::addr_t, SBMemoryRegionInfo, GetRegionBase); + LLDB_INSTRUMENT_VA(this); return m_opaque_up->GetRange().GetRangeBase(); } lldb::addr_t SBMemoryRegionInfo::GetRegionEnd() { - LLDB_RECORD_METHOD_NO_ARGS(lldb::addr_t, SBMemoryRegionInfo, GetRegionEnd); + LLDB_INSTRUMENT_VA(this); return m_opaque_up->GetRange().GetRangeEnd(); } bool SBMemoryRegionInfo::IsReadable() { - LLDB_RECORD_METHOD_NO_ARGS(bool, SBMemoryRegionInfo, IsReadable); + LLDB_INSTRUMENT_VA(this); return m_opaque_up->GetReadable() == MemoryRegionInfo::eYes; } bool SBMemoryRegionInfo::IsWritable() { - LLDB_RECORD_METHOD_NO_ARGS(bool, SBMemoryRegionInfo, IsWritable); + LLDB_INSTRUMENT_VA(this); return m_opaque_up->GetWritable() == MemoryRegionInfo::eYes; } bool SBMemoryRegionInfo::IsExecutable() { - LLDB_RECORD_METHOD_NO_ARGS(bool, SBMemoryRegionInfo, IsExecutable); + LLDB_INSTRUMENT_VA(this); return m_opaque_up->GetExecutable() == MemoryRegionInfo::eYes; } bool SBMemoryRegionInfo::IsMapped() { - LLDB_RECORD_METHOD_NO_ARGS(bool, SBMemoryRegionInfo, IsMapped); + LLDB_INSTRUMENT_VA(this); return m_opaque_up->GetMapped() == MemoryRegionInfo::eYes; } const char *SBMemoryRegionInfo::GetName() { - LLDB_RECORD_METHOD_NO_ARGS(const char *, SBMemoryRegionInfo, GetName); + LLDB_INSTRUMENT_VA(this); return m_opaque_up->GetName().AsCString(); } bool SBMemoryRegionInfo::HasDirtyMemoryPageList() { - LLDB_RECORD_METHOD_NO_ARGS(bool, SBMemoryRegionInfo, HasDirtyMemoryPageList); + LLDB_INSTRUMENT_VA(this); return m_opaque_up->GetDirtyPageList().hasValue(); } uint32_t SBMemoryRegionInfo::GetNumDirtyPages() { - LLDB_RECORD_METHOD_NO_ARGS(uint32_t, SBMemoryRegionInfo, GetNumDirtyPages); + LLDB_INSTRUMENT_VA(this); uint32_t num_dirty_pages = 0; llvm::Optional<std::vector<addr_t>> dirty_page_list = @@ -153,8 +142,7 @@ uint32_t SBMemoryRegionInfo::GetNumDirtyPages() { } addr_t SBMemoryRegionInfo::GetDirtyPageAddressAtIndex(uint32_t idx) { - LLDB_RECORD_METHOD(lldb::addr_t, SBMemoryRegionInfo, - GetDirtyPageAddressAtIndex, (uint32_t), idx); + LLDB_INSTRUMENT_VA(this, idx); addr_t dirty_page_addr = LLDB_INVALID_ADDRESS; const llvm::Optional<std::vector<addr_t>> &dirty_page_list = @@ -166,14 +154,13 @@ addr_t SBMemoryRegionInfo::GetDirtyPageAddressAtIndex(uint32_t idx) { } int SBMemoryRegionInfo::GetPageSize() { - LLDB_RECORD_METHOD_NO_ARGS(int, SBMemoryRegionInfo, GetPageSize); + LLDB_INSTRUMENT_VA(this); return m_opaque_up->GetPageSize(); } bool SBMemoryRegionInfo::GetDescription(SBStream &description) { - LLDB_RECORD_METHOD(bool, SBMemoryRegionInfo, GetDescription, - (lldb::SBStream &), description); + LLDB_INSTRUMENT_VA(this, description); Stream &strm = description.ref(); const addr_t load_addr = m_opaque_up->GetRange().base; @@ -187,42 +174,3 @@ bool SBMemoryRegionInfo::GetDescription(SBStream &description) { return true; } - -namespace lldb_private { -namespace repro { - -template <> -void RegisterMethods<SBMemoryRegionInfo>(Registry &R) { - LLDB_REGISTER_CONSTRUCTOR(SBMemoryRegionInfo, ()); - LLDB_REGISTER_CONSTRUCTOR(SBMemoryRegionInfo, - (const lldb::SBMemoryRegionInfo &)); - LLDB_REGISTER_CONSTRUCTOR( - SBMemoryRegionInfo, - (const char *, lldb::addr_t, lldb::addr_t, uint32_t, bool, bool)); - LLDB_REGISTER_METHOD( - const lldb::SBMemoryRegionInfo &, - SBMemoryRegionInfo, operator=,(const lldb::SBMemoryRegionInfo &)); - LLDB_REGISTER_METHOD(void, SBMemoryRegionInfo, Clear, ()); - LLDB_REGISTER_METHOD_CONST( - bool, - SBMemoryRegionInfo, operator==,(const lldb::SBMemoryRegionInfo &)); - LLDB_REGISTER_METHOD_CONST( - bool, - SBMemoryRegionInfo, operator!=,(const lldb::SBMemoryRegionInfo &)); - LLDB_REGISTER_METHOD(lldb::addr_t, SBMemoryRegionInfo, GetRegionBase, ()); - LLDB_REGISTER_METHOD(lldb::addr_t, SBMemoryRegionInfo, GetRegionEnd, ()); - LLDB_REGISTER_METHOD(bool, SBMemoryRegionInfo, IsReadable, ()); - LLDB_REGISTER_METHOD(bool, SBMemoryRegionInfo, IsWritable, ()); - LLDB_REGISTER_METHOD(bool, SBMemoryRegionInfo, IsExecutable, ()); - LLDB_REGISTER_METHOD(bool, SBMemoryRegionInfo, IsMapped, ()); - LLDB_REGISTER_METHOD(const char *, SBMemoryRegionInfo, GetName, ()); - LLDB_REGISTER_METHOD(bool, SBMemoryRegionInfo, GetDescription, - (lldb::SBStream &)); - LLDB_REGISTER_METHOD(bool, SBMemoryRegionInfo, HasDirtyMemoryPageList, ()); - LLDB_REGISTER_METHOD(uint32_t, SBMemoryRegionInfo, GetNumDirtyPages, ()); - LLDB_REGISTER_METHOD(lldb::addr_t, SBMemoryRegionInfo, GetDirtyPageAddressAtIndex, (uint32_t)); - LLDB_REGISTER_METHOD(int, SBMemoryRegionInfo, GetPageSize, ()); -} - -} -} diff --git a/lldb/source/API/SBMemoryRegionInfoList.cpp b/lldb/source/API/SBMemoryRegionInfoList.cpp index cd8fc00ffce0..39dee86dc300 100644 --- a/lldb/source/API/SBMemoryRegionInfoList.cpp +++ b/lldb/source/API/SBMemoryRegionInfoList.cpp @@ -7,10 +7,10 @@ //===----------------------------------------------------------------------===// #include "lldb/API/SBMemoryRegionInfoList.h" -#include "SBReproducerPrivate.h" #include "lldb/API/SBMemoryRegionInfo.h" #include "lldb/API/SBStream.h" #include "lldb/Target/MemoryRegionInfo.h" +#include "lldb/Utility/Instrumentation.h" #include <vector> @@ -83,70 +83,61 @@ const MemoryRegionInfos &SBMemoryRegionInfoList::ref() const { SBMemoryRegionInfoList::SBMemoryRegionInfoList() : m_opaque_up(new MemoryRegionInfoListImpl()) { - LLDB_RECORD_CONSTRUCTOR_NO_ARGS(SBMemoryRegionInfoList); + LLDB_INSTRUMENT_VA(this); } SBMemoryRegionInfoList::SBMemoryRegionInfoList( const SBMemoryRegionInfoList &rhs) : m_opaque_up(new MemoryRegionInfoListImpl(*rhs.m_opaque_up)) { - LLDB_RECORD_CONSTRUCTOR(SBMemoryRegionInfoList, - (const lldb::SBMemoryRegionInfoList &), rhs); + LLDB_INSTRUMENT_VA(this, rhs); } SBMemoryRegionInfoList::~SBMemoryRegionInfoList() = default; const SBMemoryRegionInfoList &SBMemoryRegionInfoList:: operator=(const SBMemoryRegionInfoList &rhs) { - LLDB_RECORD_METHOD( - const lldb::SBMemoryRegionInfoList &, - SBMemoryRegionInfoList, operator=,(const lldb::SBMemoryRegionInfoList &), - rhs); + LLDB_INSTRUMENT_VA(this, rhs); if (this != &rhs) { *m_opaque_up = *rhs.m_opaque_up; } - return LLDB_RECORD_RESULT(*this); + return *this; } uint32_t SBMemoryRegionInfoList::GetSize() const { - LLDB_RECORD_METHOD_CONST_NO_ARGS(uint32_t, SBMemoryRegionInfoList, GetSize); + LLDB_INSTRUMENT_VA(this); return m_opaque_up->GetSize(); } bool SBMemoryRegionInfoList::GetMemoryRegionContainingAddress( lldb::addr_t addr, SBMemoryRegionInfo ®ion_info) { - LLDB_RECORD_METHOD( - bool, SBMemoryRegionInfoList, GetMemoryRegionContainingAddress, - (lldb::addr_t, lldb::SBMemoryRegionInfo &), addr, region_info); + LLDB_INSTRUMENT_VA(this, addr, region_info); return m_opaque_up->GetMemoryRegionContainingAddress(addr, region_info.ref()); } bool SBMemoryRegionInfoList::GetMemoryRegionAtIndex( uint32_t idx, SBMemoryRegionInfo ®ion_info) { - LLDB_RECORD_METHOD(bool, SBMemoryRegionInfoList, GetMemoryRegionAtIndex, - (uint32_t, lldb::SBMemoryRegionInfo &), idx, region_info); + LLDB_INSTRUMENT_VA(this, idx, region_info); return m_opaque_up->GetMemoryRegionInfoAtIndex(idx, region_info.ref()); } void SBMemoryRegionInfoList::Clear() { - LLDB_RECORD_METHOD_NO_ARGS(void, SBMemoryRegionInfoList, Clear); + LLDB_INSTRUMENT_VA(this); m_opaque_up->Clear(); } void SBMemoryRegionInfoList::Append(SBMemoryRegionInfo &sb_region) { - LLDB_RECORD_METHOD(void, SBMemoryRegionInfoList, Append, - (lldb::SBMemoryRegionInfo &), sb_region); + LLDB_INSTRUMENT_VA(this, sb_region); m_opaque_up->Append(sb_region.ref()); } void SBMemoryRegionInfoList::Append(SBMemoryRegionInfoList &sb_region_list) { - LLDB_RECORD_METHOD(void, SBMemoryRegionInfoList, Append, - (lldb::SBMemoryRegionInfoList &), sb_region_list); + LLDB_INSTRUMENT_VA(this, sb_region_list); m_opaque_up->Append(*sb_region_list); } @@ -159,31 +150,3 @@ const MemoryRegionInfoListImpl &SBMemoryRegionInfoList::operator*() const { assert(m_opaque_up.get()); return *m_opaque_up; } - -namespace lldb_private { -namespace repro { - -template <> -void RegisterMethods<SBMemoryRegionInfoList>(Registry &R) { - LLDB_REGISTER_CONSTRUCTOR(SBMemoryRegionInfoList, ()); - LLDB_REGISTER_CONSTRUCTOR(SBMemoryRegionInfoList, - (const lldb::SBMemoryRegionInfoList &)); - LLDB_REGISTER_METHOD( - const lldb::SBMemoryRegionInfoList &, - SBMemoryRegionInfoList, operator=,( - const lldb::SBMemoryRegionInfoList &)); - LLDB_REGISTER_METHOD_CONST(uint32_t, SBMemoryRegionInfoList, GetSize, ()); - LLDB_REGISTER_METHOD(bool, SBMemoryRegionInfoList, - GetMemoryRegionContainingAddress, - (lldb::addr_t, lldb::SBMemoryRegionInfo &)); - LLDB_REGISTER_METHOD(bool, SBMemoryRegionInfoList, GetMemoryRegionAtIndex, - (uint32_t, lldb::SBMemoryRegionInfo &)); - LLDB_REGISTER_METHOD(void, SBMemoryRegionInfoList, Clear, ()); - LLDB_REGISTER_METHOD(void, SBMemoryRegionInfoList, Append, - (lldb::SBMemoryRegionInfo &)); - LLDB_REGISTER_METHOD(void, SBMemoryRegionInfoList, Append, - (lldb::SBMemoryRegionInfoList &)); -} - -} -} diff --git a/lldb/source/API/SBModule.cpp b/lldb/source/API/SBModule.cpp index 710ee8551bd6..1454012d3eb9 100644 --- a/lldb/source/API/SBModule.cpp +++ b/lldb/source/API/SBModule.cpp @@ -7,7 +7,6 @@ //===----------------------------------------------------------------------===// #include "lldb/API/SBModule.h" -#include "SBReproducerPrivate.h" #include "lldb/API/SBAddress.h" #include "lldb/API/SBFileSpec.h" #include "lldb/API/SBModuleSpec.h" @@ -24,19 +23,18 @@ #include "lldb/Symbol/TypeSystem.h" #include "lldb/Symbol/VariableList.h" #include "lldb/Target/Target.h" +#include "lldb/Utility/Instrumentation.h" #include "lldb/Utility/StreamString.h" using namespace lldb; using namespace lldb_private; -SBModule::SBModule() : m_opaque_sp() { - LLDB_RECORD_CONSTRUCTOR_NO_ARGS(SBModule); -} +SBModule::SBModule() { LLDB_INSTRUMENT_VA(this); } SBModule::SBModule(const lldb::ModuleSP &module_sp) : m_opaque_sp(module_sp) {} -SBModule::SBModule(const SBModuleSpec &module_spec) : m_opaque_sp() { - LLDB_RECORD_CONSTRUCTOR(SBModule, (const lldb::SBModuleSpec &), module_spec); +SBModule::SBModule(const SBModuleSpec &module_spec) { + LLDB_INSTRUMENT_VA(this, module_spec); ModuleSP module_sp; Status error = ModuleList::GetSharedModule( @@ -46,13 +44,11 @@ SBModule::SBModule(const SBModuleSpec &module_spec) : m_opaque_sp() { } SBModule::SBModule(const SBModule &rhs) : m_opaque_sp(rhs.m_opaque_sp) { - LLDB_RECORD_CONSTRUCTOR(SBModule, (const lldb::SBModule &), rhs); + LLDB_INSTRUMENT_VA(this, rhs); } -SBModule::SBModule(lldb::SBProcess &process, lldb::addr_t header_addr) - : m_opaque_sp() { - LLDB_RECORD_CONSTRUCTOR(SBModule, (lldb::SBProcess &, lldb::addr_t), process, - header_addr); +SBModule::SBModule(lldb::SBProcess &process, lldb::addr_t header_addr) { + LLDB_INSTRUMENT_VA(this, process, header_addr); ProcessSP process_sp(process.GetSP()); if (process_sp) { @@ -67,58 +63,69 @@ SBModule::SBModule(lldb::SBProcess &process, lldb::addr_t header_addr) } const SBModule &SBModule::operator=(const SBModule &rhs) { - LLDB_RECORD_METHOD(const lldb::SBModule &, SBModule, operator=, - (const lldb::SBModule &), rhs); + LLDB_INSTRUMENT_VA(this, rhs); if (this != &rhs) m_opaque_sp = rhs.m_opaque_sp; - return LLDB_RECORD_RESULT(*this); + return *this; } SBModule::~SBModule() = default; bool SBModule::IsValid() const { - LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBModule, IsValid); + LLDB_INSTRUMENT_VA(this); return this->operator bool(); } SBModule::operator bool() const { - LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBModule, operator bool); + LLDB_INSTRUMENT_VA(this); return m_opaque_sp.get() != nullptr; } void SBModule::Clear() { - LLDB_RECORD_METHOD_NO_ARGS(void, SBModule, Clear); + LLDB_INSTRUMENT_VA(this); m_opaque_sp.reset(); } +bool SBModule::IsFileBacked() const { + LLDB_INSTRUMENT_VA(this); + + ModuleSP module_sp(GetSP()); + if (!module_sp) + return false; + + ObjectFile *obj_file = module_sp->GetObjectFile(); + if (!obj_file) + return false; + + return !obj_file->IsInMemory(); +} + SBFileSpec SBModule::GetFileSpec() const { - LLDB_RECORD_METHOD_CONST_NO_ARGS(lldb::SBFileSpec, SBModule, GetFileSpec); + LLDB_INSTRUMENT_VA(this); SBFileSpec file_spec; ModuleSP module_sp(GetSP()); if (module_sp) file_spec.SetFileSpec(module_sp->GetFileSpec()); - return LLDB_RECORD_RESULT(file_spec); + return file_spec; } lldb::SBFileSpec SBModule::GetPlatformFileSpec() const { - LLDB_RECORD_METHOD_CONST_NO_ARGS(lldb::SBFileSpec, SBModule, - GetPlatformFileSpec); + LLDB_INSTRUMENT_VA(this); SBFileSpec file_spec; ModuleSP module_sp(GetSP()); if (module_sp) file_spec.SetFileSpec(module_sp->GetPlatformFileSpec()); - return LLDB_RECORD_RESULT(file_spec); + return file_spec; } bool SBModule::SetPlatformFileSpec(const lldb::SBFileSpec &platform_file) { - LLDB_RECORD_METHOD(bool, SBModule, SetPlatformFileSpec, - (const lldb::SBFileSpec &), platform_file); + LLDB_INSTRUMENT_VA(this, platform_file); bool result = false; @@ -132,19 +139,17 @@ bool SBModule::SetPlatformFileSpec(const lldb::SBFileSpec &platform_file) { } lldb::SBFileSpec SBModule::GetRemoteInstallFileSpec() { - LLDB_RECORD_METHOD_NO_ARGS(lldb::SBFileSpec, SBModule, - GetRemoteInstallFileSpec); + LLDB_INSTRUMENT_VA(this); SBFileSpec sb_file_spec; ModuleSP module_sp(GetSP()); if (module_sp) sb_file_spec.SetFileSpec(module_sp->GetRemoteInstallFileSpec()); - return LLDB_RECORD_RESULT(sb_file_spec); + return sb_file_spec; } bool SBModule::SetRemoteInstallFileSpec(lldb::SBFileSpec &file) { - LLDB_RECORD_METHOD(bool, SBModule, SetRemoteInstallFileSpec, - (lldb::SBFileSpec &), file); + LLDB_INSTRUMENT_VA(this, file); ModuleSP module_sp(GetSP()); if (module_sp) { @@ -155,7 +160,7 @@ bool SBModule::SetRemoteInstallFileSpec(lldb::SBFileSpec &file) { } const uint8_t *SBModule::GetUUIDBytes() const { - LLDB_RECORD_METHOD_CONST_NO_ARGS(const uint8_t *, SBModule, GetUUIDBytes); + LLDB_INSTRUMENT_VA(this); const uint8_t *uuid_bytes = nullptr; ModuleSP module_sp(GetSP()); @@ -166,7 +171,7 @@ const uint8_t *SBModule::GetUUIDBytes() const { } const char *SBModule::GetUUIDString() const { - LLDB_RECORD_METHOD_CONST_NO_ARGS(const char *, SBModule, GetUUIDString); + LLDB_INSTRUMENT_VA(this); const char *uuid_cstr = nullptr; ModuleSP module_sp(GetSP()); @@ -186,8 +191,7 @@ const char *SBModule::GetUUIDString() const { } bool SBModule::operator==(const SBModule &rhs) const { - LLDB_RECORD_METHOD_CONST(bool, SBModule, operator==, (const lldb::SBModule &), - rhs); + LLDB_INSTRUMENT_VA(this, rhs); if (m_opaque_sp) return m_opaque_sp.get() == rhs.m_opaque_sp.get(); @@ -195,8 +199,7 @@ bool SBModule::operator==(const SBModule &rhs) const { } bool SBModule::operator!=(const SBModule &rhs) const { - LLDB_RECORD_METHOD_CONST(bool, SBModule, operator!=, (const lldb::SBModule &), - rhs); + LLDB_INSTRUMENT_VA(this, rhs); if (m_opaque_sp) return m_opaque_sp.get() != rhs.m_opaque_sp.get(); @@ -208,8 +211,7 @@ ModuleSP SBModule::GetSP() const { return m_opaque_sp; } void SBModule::SetSP(const ModuleSP &module_sp) { m_opaque_sp = module_sp; } SBAddress SBModule::ResolveFileAddress(lldb::addr_t vm_addr) { - LLDB_RECORD_METHOD(lldb::SBAddress, SBModule, ResolveFileAddress, - (lldb::addr_t), vm_addr); + LLDB_INSTRUMENT_VA(this, vm_addr); lldb::SBAddress sb_addr; ModuleSP module_sp(GetSP()); @@ -218,27 +220,24 @@ SBAddress SBModule::ResolveFileAddress(lldb::addr_t vm_addr) { if (module_sp->ResolveFileAddress(vm_addr, addr)) sb_addr.ref() = addr; } - return LLDB_RECORD_RESULT(sb_addr); + return sb_addr; } SBSymbolContext SBModule::ResolveSymbolContextForAddress(const SBAddress &addr, uint32_t resolve_scope) { - LLDB_RECORD_METHOD(lldb::SBSymbolContext, SBModule, - ResolveSymbolContextForAddress, - (const lldb::SBAddress &, uint32_t), addr, resolve_scope); + LLDB_INSTRUMENT_VA(this, addr, resolve_scope); SBSymbolContext sb_sc; ModuleSP module_sp(GetSP()); SymbolContextItem scope = static_cast<SymbolContextItem>(resolve_scope); if (module_sp && addr.IsValid()) module_sp->ResolveSymbolContextForAddress(addr.ref(), scope, *sb_sc); - return LLDB_RECORD_RESULT(sb_sc); + return sb_sc; } bool SBModule::GetDescription(SBStream &description) { - LLDB_RECORD_METHOD(bool, SBModule, GetDescription, (lldb::SBStream &), - description); + LLDB_INSTRUMENT_VA(this, description); Stream &strm = description.ref(); @@ -252,7 +251,7 @@ bool SBModule::GetDescription(SBStream &description) { } uint32_t SBModule::GetNumCompileUnits() { - LLDB_RECORD_METHOD_NO_ARGS(uint32_t, SBModule, GetNumCompileUnits); + LLDB_INSTRUMENT_VA(this); ModuleSP module_sp(GetSP()); if (module_sp) { @@ -262,8 +261,7 @@ uint32_t SBModule::GetNumCompileUnits() { } SBCompileUnit SBModule::GetCompileUnitAtIndex(uint32_t index) { - LLDB_RECORD_METHOD(lldb::SBCompileUnit, SBModule, GetCompileUnitAtIndex, - (uint32_t), index); + LLDB_INSTRUMENT_VA(this, index); SBCompileUnit sb_cu; ModuleSP module_sp(GetSP()); @@ -271,19 +269,18 @@ SBCompileUnit SBModule::GetCompileUnitAtIndex(uint32_t index) { CompUnitSP cu_sp = module_sp->GetCompileUnitAtIndex(index); sb_cu.reset(cu_sp.get()); } - return LLDB_RECORD_RESULT(sb_cu); + return sb_cu; } SBSymbolContextList SBModule::FindCompileUnits(const SBFileSpec &sb_file_spec) { - LLDB_RECORD_METHOD(lldb::SBSymbolContextList, SBModule, FindCompileUnits, - (const lldb::SBFileSpec &), sb_file_spec); + LLDB_INSTRUMENT_VA(this, sb_file_spec); SBSymbolContextList sb_sc_list; const ModuleSP module_sp(GetSP()); if (sb_file_spec.IsValid() && module_sp) { module_sp->FindCompileUnits(*sb_file_spec, *sb_sc_list); } - return LLDB_RECORD_RESULT(sb_sc_list); + return sb_sc_list; } static Symtab *GetUnifiedSymbolTable(const lldb::ModuleSP &module_sp) { @@ -293,7 +290,7 @@ static Symtab *GetUnifiedSymbolTable(const lldb::ModuleSP &module_sp) { } size_t SBModule::GetNumSymbols() { - LLDB_RECORD_METHOD_NO_ARGS(size_t, SBModule, GetNumSymbols); + LLDB_INSTRUMENT_VA(this); ModuleSP module_sp(GetSP()); if (Symtab *symtab = GetUnifiedSymbolTable(module_sp)) @@ -302,20 +299,19 @@ size_t SBModule::GetNumSymbols() { } SBSymbol SBModule::GetSymbolAtIndex(size_t idx) { - LLDB_RECORD_METHOD(lldb::SBSymbol, SBModule, GetSymbolAtIndex, (size_t), idx); + LLDB_INSTRUMENT_VA(this, idx); SBSymbol sb_symbol; ModuleSP module_sp(GetSP()); Symtab *symtab = GetUnifiedSymbolTable(module_sp); if (symtab) sb_symbol.SetSymbol(symtab->SymbolAtIndex(idx)); - return LLDB_RECORD_RESULT(sb_symbol); + return sb_symbol; } lldb::SBSymbol SBModule::FindSymbol(const char *name, lldb::SymbolType symbol_type) { - LLDB_RECORD_METHOD(lldb::SBSymbol, SBModule, FindSymbol, - (const char *, lldb::SymbolType), name, symbol_type); + LLDB_INSTRUMENT_VA(this, name, symbol_type); SBSymbol sb_symbol; if (name && name[0]) { @@ -326,13 +322,12 @@ lldb::SBSymbol SBModule::FindSymbol(const char *name, ConstString(name), symbol_type, Symtab::eDebugAny, Symtab::eVisibilityAny)); } - return LLDB_RECORD_RESULT(sb_symbol); + return sb_symbol; } lldb::SBSymbolContextList SBModule::FindSymbols(const char *name, lldb::SymbolType symbol_type) { - LLDB_RECORD_METHOD(lldb::SBSymbolContextList, SBModule, FindSymbols, - (const char *, lldb::SymbolType), name, symbol_type); + LLDB_INSTRUMENT_VA(this, name, symbol_type); SBSymbolContextList sb_sc_list; if (name && name[0]) { @@ -355,11 +350,11 @@ lldb::SBSymbolContextList SBModule::FindSymbols(const char *name, } } } - return LLDB_RECORD_RESULT(sb_sc_list); + return sb_sc_list; } size_t SBModule::GetNumSections() { - LLDB_RECORD_METHOD_NO_ARGS(size_t, SBModule, GetNumSections); + LLDB_INSTRUMENT_VA(this); ModuleSP module_sp(GetSP()); if (module_sp) { @@ -373,8 +368,7 @@ size_t SBModule::GetNumSections() { } SBSection SBModule::GetSectionAtIndex(size_t idx) { - LLDB_RECORD_METHOD(lldb::SBSection, SBModule, GetSectionAtIndex, (size_t), - idx); + LLDB_INSTRUMENT_VA(this, idx); SBSection sb_section; ModuleSP module_sp(GetSP()); @@ -386,13 +380,12 @@ SBSection SBModule::GetSectionAtIndex(size_t idx) { if (section_list) sb_section.SetSP(section_list->GetSectionAtIndex(idx)); } - return LLDB_RECORD_RESULT(sb_section); + return sb_section; } lldb::SBSymbolContextList SBModule::FindFunctions(const char *name, uint32_t name_type_mask) { - LLDB_RECORD_METHOD(lldb::SBSymbolContextList, SBModule, FindFunctions, - (const char *, uint32_t), name, name_type_mask); + LLDB_INSTRUMENT_VA(this, name, name_type_mask); lldb::SBSymbolContextList sb_sc_list; ModuleSP module_sp(GetSP()); @@ -405,14 +398,12 @@ lldb::SBSymbolContextList SBModule::FindFunctions(const char *name, module_sp->FindFunctions(ConstString(name), CompilerDeclContext(), type, function_options, *sb_sc_list); } - return LLDB_RECORD_RESULT(sb_sc_list); + return sb_sc_list; } SBValueList SBModule::FindGlobalVariables(SBTarget &target, const char *name, uint32_t max_matches) { - LLDB_RECORD_METHOD(lldb::SBValueList, SBModule, FindGlobalVariables, - (lldb::SBTarget &, const char *, uint32_t), target, name, - max_matches); + LLDB_INSTRUMENT_VA(this, target, name, max_matches); SBValueList sb_value_list; ModuleSP module_sp(GetSP()); @@ -429,23 +420,21 @@ SBValueList SBModule::FindGlobalVariables(SBTarget &target, const char *name, } } - return LLDB_RECORD_RESULT(sb_value_list); + return sb_value_list; } lldb::SBValue SBModule::FindFirstGlobalVariable(lldb::SBTarget &target, const char *name) { - LLDB_RECORD_METHOD(lldb::SBValue, SBModule, FindFirstGlobalVariable, - (lldb::SBTarget &, const char *), target, name); + LLDB_INSTRUMENT_VA(this, target, name); SBValueList sb_value_list(FindGlobalVariables(target, name, 1)); if (sb_value_list.IsValid() && sb_value_list.GetSize() > 0) - return LLDB_RECORD_RESULT(sb_value_list.GetValueAtIndex(0)); - return LLDB_RECORD_RESULT(SBValue()); + return sb_value_list.GetValueAtIndex(0); + return SBValue(); } lldb::SBType SBModule::FindFirstType(const char *name_cstr) { - LLDB_RECORD_METHOD(lldb::SBType, SBModule, FindFirstType, (const char *), - name_cstr); + LLDB_INSTRUMENT_VA(this, name_cstr); SBType sb_type; ModuleSP module_sp(GetSP()); @@ -461,17 +450,16 @@ lldb::SBType SBModule::FindFirstType(const char *name_cstr) { module_sp->GetTypeSystemForLanguage(eLanguageTypeC); if (auto err = type_system_or_err.takeError()) { llvm::consumeError(std::move(err)); - return LLDB_RECORD_RESULT(SBType()); + return SBType(); } sb_type = SBType(type_system_or_err->GetBuiltinTypeByName(name)); } } - return LLDB_RECORD_RESULT(sb_type); + return sb_type; } lldb::SBType SBModule::GetBasicType(lldb::BasicType type) { - LLDB_RECORD_METHOD(lldb::SBType, SBModule, GetBasicType, (lldb::BasicType), - type); + LLDB_INSTRUMENT_VA(this, type); ModuleSP module_sp(GetSP()); if (module_sp) { @@ -480,16 +468,14 @@ lldb::SBType SBModule::GetBasicType(lldb::BasicType type) { if (auto err = type_system_or_err.takeError()) { llvm::consumeError(std::move(err)); } else { - return LLDB_RECORD_RESULT( - SBType(type_system_or_err->GetBasicTypeFromAST(type))); + return SBType(type_system_or_err->GetBasicTypeFromAST(type)); } } - return LLDB_RECORD_RESULT(SBType()); + return SBType(); } lldb::SBTypeList SBModule::FindTypes(const char *type) { - LLDB_RECORD_METHOD(lldb::SBTypeList, SBModule, FindTypes, (const char *), - type); + LLDB_INSTRUMENT_VA(this, type); SBTypeList retval; @@ -521,47 +507,44 @@ lldb::SBTypeList SBModule::FindTypes(const char *type) { } } } - return LLDB_RECORD_RESULT(retval); + return retval; } lldb::SBType SBModule::GetTypeByID(lldb::user_id_t uid) { - LLDB_RECORD_METHOD(lldb::SBType, SBModule, GetTypeByID, (lldb::user_id_t), - uid); + LLDB_INSTRUMENT_VA(this, uid); ModuleSP module_sp(GetSP()); if (module_sp) { if (SymbolFile *symfile = module_sp->GetSymbolFile()) { Type *type_ptr = symfile->ResolveTypeUID(uid); if (type_ptr) - return LLDB_RECORD_RESULT(SBType(type_ptr->shared_from_this())); + return SBType(type_ptr->shared_from_this()); } } - return LLDB_RECORD_RESULT(SBType()); + return SBType(); } lldb::SBTypeList SBModule::GetTypes(uint32_t type_mask) { - LLDB_RECORD_METHOD(lldb::SBTypeList, SBModule, GetTypes, (uint32_t), - type_mask); + LLDB_INSTRUMENT_VA(this, type_mask); SBTypeList sb_type_list; ModuleSP module_sp(GetSP()); if (!module_sp) - return LLDB_RECORD_RESULT(sb_type_list); + return sb_type_list; SymbolFile *symfile = module_sp->GetSymbolFile(); if (!symfile) - return LLDB_RECORD_RESULT(sb_type_list); + return sb_type_list; TypeClass type_class = static_cast<TypeClass>(type_mask); TypeList type_list; symfile->GetTypes(nullptr, type_class, type_list); sb_type_list.m_opaque_up->Append(type_list); - return LLDB_RECORD_RESULT(sb_type_list); + return sb_type_list; } SBSection SBModule::FindSection(const char *sect_name) { - LLDB_RECORD_METHOD(lldb::SBSection, SBModule, FindSection, (const char *), - sect_name); + LLDB_INSTRUMENT_VA(this, sect_name); SBSection sb_section; @@ -578,11 +561,11 @@ SBSection SBModule::FindSection(const char *sect_name) { } } } - return LLDB_RECORD_RESULT(sb_section); + return sb_section; } lldb::ByteOrder SBModule::GetByteOrder() { - LLDB_RECORD_METHOD_NO_ARGS(lldb::ByteOrder, SBModule, GetByteOrder); + LLDB_INSTRUMENT_VA(this); ModuleSP module_sp(GetSP()); if (module_sp) @@ -591,7 +574,7 @@ lldb::ByteOrder SBModule::GetByteOrder() { } const char *SBModule::GetTriple() { - LLDB_RECORD_METHOD_NO_ARGS(const char *, SBModule, GetTriple); + LLDB_INSTRUMENT_VA(this); ModuleSP module_sp(GetSP()); if (module_sp) { @@ -606,7 +589,7 @@ const char *SBModule::GetTriple() { } uint32_t SBModule::GetAddressByteSize() { - LLDB_RECORD_METHOD_NO_ARGS(uint32_t, SBModule, GetAddressByteSize); + LLDB_INSTRUMENT_VA(this); ModuleSP module_sp(GetSP()); if (module_sp) @@ -615,8 +598,7 @@ uint32_t SBModule::GetAddressByteSize() { } uint32_t SBModule::GetVersion(uint32_t *versions, uint32_t num_versions) { - LLDB_RECORD_METHOD(uint32_t, SBModule, GetVersion, (uint32_t *, uint32_t), - versions, num_versions); + LLDB_INSTRUMENT_VA(this, versions, num_versions); llvm::VersionTuple version; if (ModuleSP module_sp = GetSP()) @@ -644,8 +626,7 @@ uint32_t SBModule::GetVersion(uint32_t *versions, uint32_t num_versions) { } lldb::SBFileSpec SBModule::GetSymbolFileSpec() const { - LLDB_RECORD_METHOD_CONST_NO_ARGS(lldb::SBFileSpec, SBModule, - GetSymbolFileSpec); + LLDB_INSTRUMENT_VA(this); lldb::SBFileSpec sb_file_spec; ModuleSP module_sp(GetSP()); @@ -653,12 +634,11 @@ lldb::SBFileSpec SBModule::GetSymbolFileSpec() const { if (SymbolFile *symfile = module_sp->GetSymbolFile()) sb_file_spec.SetFileSpec(symfile->GetObjectFile()->GetFileSpec()); } - return LLDB_RECORD_RESULT(sb_file_spec); + return sb_file_spec; } lldb::SBAddress SBModule::GetObjectFileHeaderAddress() const { - LLDB_RECORD_METHOD_CONST_NO_ARGS(lldb::SBAddress, SBModule, - GetObjectFileHeaderAddress); + LLDB_INSTRUMENT_VA(this); lldb::SBAddress sb_addr; ModuleSP module_sp(GetSP()); @@ -667,12 +647,11 @@ lldb::SBAddress SBModule::GetObjectFileHeaderAddress() const { if (objfile_ptr) sb_addr.ref() = objfile_ptr->GetBaseAddress(); } - return LLDB_RECORD_RESULT(sb_addr); + return sb_addr; } lldb::SBAddress SBModule::GetObjectFileEntryPointAddress() const { - LLDB_RECORD_METHOD_CONST_NO_ARGS(lldb::SBAddress, SBModule, - GetObjectFileEntryPointAddress); + LLDB_INSTRUMENT_VA(this); lldb::SBAddress sb_addr; ModuleSP module_sp(GetSP()); @@ -681,96 +660,18 @@ lldb::SBAddress SBModule::GetObjectFileEntryPointAddress() const { if (objfile_ptr) sb_addr.ref() = objfile_ptr->GetEntryPointAddress(); } - return LLDB_RECORD_RESULT(sb_addr); + return sb_addr; } uint32_t SBModule::GetNumberAllocatedModules() { - LLDB_RECORD_STATIC_METHOD_NO_ARGS(uint32_t, SBModule, - GetNumberAllocatedModules); + LLDB_INSTRUMENT(); return Module::GetNumberAllocatedModules(); } void SBModule::GarbageCollectAllocatedModules() { - LLDB_RECORD_STATIC_METHOD_NO_ARGS(void, SBModule, - GarbageCollectAllocatedModules); + LLDB_INSTRUMENT(); const bool mandatory = false; ModuleList::RemoveOrphanSharedModules(mandatory); } - -namespace lldb_private { -namespace repro { - -template <> void RegisterMethods<SBModule>(Registry &R) { - LLDB_REGISTER_CONSTRUCTOR(SBModule, ()); - LLDB_REGISTER_CONSTRUCTOR(SBModule, (const lldb::SBModuleSpec &)); - LLDB_REGISTER_CONSTRUCTOR(SBModule, (const lldb::SBModule &)); - LLDB_REGISTER_CONSTRUCTOR(SBModule, (lldb::SBProcess &, lldb::addr_t)); - LLDB_REGISTER_METHOD(const lldb::SBModule &, SBModule, operator=, - (const lldb::SBModule &)); - LLDB_REGISTER_METHOD_CONST(bool, SBModule, IsValid, ()); - LLDB_REGISTER_METHOD_CONST(bool, SBModule, operator bool, ()); - LLDB_REGISTER_METHOD(void, SBModule, Clear, ()); - LLDB_REGISTER_METHOD_CONST(lldb::SBFileSpec, SBModule, GetFileSpec, ()); - LLDB_REGISTER_METHOD_CONST(lldb::SBFileSpec, SBModule, GetPlatformFileSpec, - ()); - LLDB_REGISTER_METHOD(bool, SBModule, SetPlatformFileSpec, - (const lldb::SBFileSpec &)); - LLDB_REGISTER_METHOD(lldb::SBFileSpec, SBModule, GetRemoteInstallFileSpec, - ()); - LLDB_REGISTER_METHOD(bool, SBModule, SetRemoteInstallFileSpec, - (lldb::SBFileSpec &)); - LLDB_REGISTER_METHOD_CONST(const char *, SBModule, GetUUIDString, ()); - LLDB_REGISTER_METHOD_CONST(bool, SBModule, operator==, - (const lldb::SBModule &)); - LLDB_REGISTER_METHOD_CONST(bool, SBModule, operator!=, - (const lldb::SBModule &)); - LLDB_REGISTER_METHOD(lldb::SBAddress, SBModule, ResolveFileAddress, - (lldb::addr_t)); - LLDB_REGISTER_METHOD(lldb::SBSymbolContext, SBModule, - ResolveSymbolContextForAddress, - (const lldb::SBAddress &, uint32_t)); - LLDB_REGISTER_METHOD(bool, SBModule, GetDescription, (lldb::SBStream &)); - LLDB_REGISTER_METHOD(uint32_t, SBModule, GetNumCompileUnits, ()); - LLDB_REGISTER_METHOD(lldb::SBCompileUnit, SBModule, GetCompileUnitAtIndex, - (uint32_t)); - LLDB_REGISTER_METHOD(lldb::SBSymbolContextList, SBModule, FindCompileUnits, - (const lldb::SBFileSpec &)); - LLDB_REGISTER_METHOD(size_t, SBModule, GetNumSymbols, ()); - LLDB_REGISTER_METHOD(lldb::SBSymbol, SBModule, GetSymbolAtIndex, (size_t)); - LLDB_REGISTER_METHOD(lldb::SBSymbol, SBModule, FindSymbol, - (const char *, lldb::SymbolType)); - LLDB_REGISTER_METHOD(lldb::SBSymbolContextList, SBModule, FindSymbols, - (const char *, lldb::SymbolType)); - LLDB_REGISTER_METHOD(size_t, SBModule, GetNumSections, ()); - LLDB_REGISTER_METHOD(lldb::SBSection, SBModule, GetSectionAtIndex, (size_t)); - LLDB_REGISTER_METHOD(lldb::SBSymbolContextList, SBModule, FindFunctions, - (const char *, uint32_t)); - LLDB_REGISTER_METHOD(lldb::SBValueList, SBModule, FindGlobalVariables, - (lldb::SBTarget &, const char *, uint32_t)); - LLDB_REGISTER_METHOD(lldb::SBValue, SBModule, FindFirstGlobalVariable, - (lldb::SBTarget &, const char *)); - LLDB_REGISTER_METHOD(lldb::SBType, SBModule, FindFirstType, (const char *)); - LLDB_REGISTER_METHOD(lldb::SBType, SBModule, GetBasicType, (lldb::BasicType)); - LLDB_REGISTER_METHOD(lldb::SBTypeList, SBModule, FindTypes, (const char *)); - LLDB_REGISTER_METHOD(lldb::SBType, SBModule, GetTypeByID, (lldb::user_id_t)); - LLDB_REGISTER_METHOD(lldb::SBTypeList, SBModule, GetTypes, (uint32_t)); - LLDB_REGISTER_METHOD(lldb::SBSection, SBModule, FindSection, (const char *)); - LLDB_REGISTER_METHOD(lldb::ByteOrder, SBModule, GetByteOrder, ()); - LLDB_REGISTER_METHOD(const char *, SBModule, GetTriple, ()); - LLDB_REGISTER_METHOD(uint32_t, SBModule, GetAddressByteSize, ()); - LLDB_REGISTER_METHOD(uint32_t, SBModule, GetVersion, (uint32_t *, uint32_t)); - LLDB_REGISTER_METHOD_CONST(lldb::SBFileSpec, SBModule, GetSymbolFileSpec, ()); - LLDB_REGISTER_METHOD_CONST(lldb::SBAddress, SBModule, - GetObjectFileHeaderAddress, ()); - LLDB_REGISTER_METHOD_CONST(lldb::SBAddress, SBModule, - GetObjectFileEntryPointAddress, ()); - LLDB_REGISTER_STATIC_METHOD(uint32_t, SBModule, GetNumberAllocatedModules, - ()); - LLDB_REGISTER_STATIC_METHOD(void, SBModule, GarbageCollectAllocatedModules, - ()); -} - -} // namespace repro -} // namespace lldb_private diff --git a/lldb/source/API/SBModuleSpec.cpp b/lldb/source/API/SBModuleSpec.cpp index 5d88272a399b..7deba8e971f8 100644 --- a/lldb/source/API/SBModuleSpec.cpp +++ b/lldb/source/API/SBModuleSpec.cpp @@ -7,110 +7,105 @@ //===----------------------------------------------------------------------===// #include "lldb/API/SBModuleSpec.h" -#include "SBReproducerPrivate.h" #include "Utils.h" #include "lldb/API/SBStream.h" #include "lldb/Core/Module.h" #include "lldb/Core/ModuleSpec.h" #include "lldb/Host/Host.h" #include "lldb/Symbol/ObjectFile.h" +#include "lldb/Utility/Instrumentation.h" #include "lldb/Utility/Stream.h" using namespace lldb; using namespace lldb_private; SBModuleSpec::SBModuleSpec() : m_opaque_up(new lldb_private::ModuleSpec()) { - LLDB_RECORD_CONSTRUCTOR_NO_ARGS(SBModuleSpec); + LLDB_INSTRUMENT_VA(this); } -SBModuleSpec::SBModuleSpec(const SBModuleSpec &rhs) : m_opaque_up() { - LLDB_RECORD_CONSTRUCTOR(SBModuleSpec, (const lldb::SBModuleSpec &), rhs); +SBModuleSpec::SBModuleSpec(const SBModuleSpec &rhs) { + LLDB_INSTRUMENT_VA(this, rhs); m_opaque_up = clone(rhs.m_opaque_up); } const SBModuleSpec &SBModuleSpec::operator=(const SBModuleSpec &rhs) { - LLDB_RECORD_METHOD(const lldb::SBModuleSpec &, - SBModuleSpec, operator=,(const lldb::SBModuleSpec &), rhs); + LLDB_INSTRUMENT_VA(this, rhs); if (this != &rhs) m_opaque_up = clone(rhs.m_opaque_up); - return LLDB_RECORD_RESULT(*this); + return *this; } SBModuleSpec::~SBModuleSpec() = default; bool SBModuleSpec::IsValid() const { - LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBModuleSpec, IsValid); + LLDB_INSTRUMENT_VA(this); return this->operator bool(); } SBModuleSpec::operator bool() const { - LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBModuleSpec, operator bool); + LLDB_INSTRUMENT_VA(this); return m_opaque_up->operator bool(); } void SBModuleSpec::Clear() { - LLDB_RECORD_METHOD_NO_ARGS(void, SBModuleSpec, Clear); + LLDB_INSTRUMENT_VA(this); m_opaque_up->Clear(); } SBFileSpec SBModuleSpec::GetFileSpec() { - LLDB_RECORD_METHOD_NO_ARGS(lldb::SBFileSpec, SBModuleSpec, GetFileSpec); + LLDB_INSTRUMENT_VA(this); SBFileSpec sb_spec(m_opaque_up->GetFileSpec()); - return LLDB_RECORD_RESULT(sb_spec); + return sb_spec; } void SBModuleSpec::SetFileSpec(const lldb::SBFileSpec &sb_spec) { - LLDB_RECORD_METHOD(void, SBModuleSpec, SetFileSpec, - (const lldb::SBFileSpec &), sb_spec); + LLDB_INSTRUMENT_VA(this, sb_spec); m_opaque_up->GetFileSpec() = *sb_spec; } lldb::SBFileSpec SBModuleSpec::GetPlatformFileSpec() { - LLDB_RECORD_METHOD_NO_ARGS(lldb::SBFileSpec, SBModuleSpec, - GetPlatformFileSpec); + LLDB_INSTRUMENT_VA(this); - return LLDB_RECORD_RESULT(SBFileSpec(m_opaque_up->GetPlatformFileSpec())); + return SBFileSpec(m_opaque_up->GetPlatformFileSpec()); } void SBModuleSpec::SetPlatformFileSpec(const lldb::SBFileSpec &sb_spec) { - LLDB_RECORD_METHOD(void, SBModuleSpec, SetPlatformFileSpec, - (const lldb::SBFileSpec &), sb_spec); + LLDB_INSTRUMENT_VA(this, sb_spec); m_opaque_up->GetPlatformFileSpec() = *sb_spec; } lldb::SBFileSpec SBModuleSpec::GetSymbolFileSpec() { - LLDB_RECORD_METHOD_NO_ARGS(lldb::SBFileSpec, SBModuleSpec, GetSymbolFileSpec); + LLDB_INSTRUMENT_VA(this); - return LLDB_RECORD_RESULT(SBFileSpec(m_opaque_up->GetSymbolFileSpec())); + return SBFileSpec(m_opaque_up->GetSymbolFileSpec()); } void SBModuleSpec::SetSymbolFileSpec(const lldb::SBFileSpec &sb_spec) { - LLDB_RECORD_METHOD(void, SBModuleSpec, SetSymbolFileSpec, - (const lldb::SBFileSpec &), sb_spec); + LLDB_INSTRUMENT_VA(this, sb_spec); m_opaque_up->GetSymbolFileSpec() = *sb_spec; } const char *SBModuleSpec::GetObjectName() { - LLDB_RECORD_METHOD_NO_ARGS(const char *, SBModuleSpec, GetObjectName); + LLDB_INSTRUMENT_VA(this); return m_opaque_up->GetObjectName().GetCString(); } void SBModuleSpec::SetObjectName(const char *name) { - LLDB_RECORD_METHOD(void, SBModuleSpec, SetObjectName, (const char *), name); + LLDB_INSTRUMENT_VA(this, name); m_opaque_up->GetObjectName().SetCString(name); } const char *SBModuleSpec::GetTriple() { - LLDB_RECORD_METHOD_NO_ARGS(const char *, SBModuleSpec, GetTriple); + LLDB_INSTRUMENT_VA(this); std::string triple(m_opaque_up->GetArchitecture().GetTriple().str()); // Unique the string so we don't run into ownership issues since the const @@ -121,180 +116,114 @@ const char *SBModuleSpec::GetTriple() { } void SBModuleSpec::SetTriple(const char *triple) { - LLDB_RECORD_METHOD(void, SBModuleSpec, SetTriple, (const char *), triple); + LLDB_INSTRUMENT_VA(this, triple); m_opaque_up->GetArchitecture().SetTriple(triple); } const uint8_t *SBModuleSpec::GetUUIDBytes() { + LLDB_INSTRUMENT_VA(this) return m_opaque_up->GetUUID().GetBytes().data(); } size_t SBModuleSpec::GetUUIDLength() { - LLDB_RECORD_METHOD_NO_ARGS(size_t, SBModuleSpec, GetUUIDLength); + LLDB_INSTRUMENT_VA(this); return m_opaque_up->GetUUID().GetBytes().size(); } bool SBModuleSpec::SetUUIDBytes(const uint8_t *uuid, size_t uuid_len) { + LLDB_INSTRUMENT_VA(this, uuid, uuid_len) m_opaque_up->GetUUID() = UUID::fromOptionalData(uuid, uuid_len); return m_opaque_up->GetUUID().IsValid(); } bool SBModuleSpec::GetDescription(lldb::SBStream &description) { - LLDB_RECORD_METHOD(bool, SBModuleSpec, GetDescription, (lldb::SBStream &), - description); + LLDB_INSTRUMENT_VA(this, description); m_opaque_up->Dump(description.ref()); return true; } SBModuleSpecList::SBModuleSpecList() : m_opaque_up(new ModuleSpecList()) { - LLDB_RECORD_CONSTRUCTOR_NO_ARGS(SBModuleSpecList); + LLDB_INSTRUMENT_VA(this); } SBModuleSpecList::SBModuleSpecList(const SBModuleSpecList &rhs) : m_opaque_up(new ModuleSpecList(*rhs.m_opaque_up)) { - LLDB_RECORD_CONSTRUCTOR(SBModuleSpecList, (const lldb::SBModuleSpecList &), - rhs); + LLDB_INSTRUMENT_VA(this, rhs); } SBModuleSpecList &SBModuleSpecList::operator=(const SBModuleSpecList &rhs) { - LLDB_RECORD_METHOD( - lldb::SBModuleSpecList &, - SBModuleSpecList, operator=,(const lldb::SBModuleSpecList &), rhs); + LLDB_INSTRUMENT_VA(this, rhs); if (this != &rhs) *m_opaque_up = *rhs.m_opaque_up; - return LLDB_RECORD_RESULT(*this); + return *this; } SBModuleSpecList::~SBModuleSpecList() = default; SBModuleSpecList SBModuleSpecList::GetModuleSpecifications(const char *path) { - LLDB_RECORD_STATIC_METHOD(lldb::SBModuleSpecList, SBModuleSpecList, - GetModuleSpecifications, (const char *), path); + LLDB_INSTRUMENT_VA(path); SBModuleSpecList specs; FileSpec file_spec(path); FileSystem::Instance().Resolve(file_spec); Host::ResolveExecutableInBundle(file_spec); ObjectFile::GetModuleSpecifications(file_spec, 0, 0, *specs.m_opaque_up); - return LLDB_RECORD_RESULT(specs); + return specs; } void SBModuleSpecList::Append(const SBModuleSpec &spec) { - LLDB_RECORD_METHOD(void, SBModuleSpecList, Append, - (const lldb::SBModuleSpec &), spec); + LLDB_INSTRUMENT_VA(this, spec); m_opaque_up->Append(*spec.m_opaque_up); } void SBModuleSpecList::Append(const SBModuleSpecList &spec_list) { - LLDB_RECORD_METHOD(void, SBModuleSpecList, Append, - (const lldb::SBModuleSpecList &), spec_list); + LLDB_INSTRUMENT_VA(this, spec_list); m_opaque_up->Append(*spec_list.m_opaque_up); } size_t SBModuleSpecList::GetSize() { - LLDB_RECORD_METHOD_NO_ARGS(size_t, SBModuleSpecList, GetSize); + LLDB_INSTRUMENT_VA(this); return m_opaque_up->GetSize(); } SBModuleSpec SBModuleSpecList::GetSpecAtIndex(size_t i) { - LLDB_RECORD_METHOD(lldb::SBModuleSpec, SBModuleSpecList, GetSpecAtIndex, - (size_t), i); + LLDB_INSTRUMENT_VA(this, i); SBModuleSpec sb_module_spec; m_opaque_up->GetModuleSpecAtIndex(i, *sb_module_spec.m_opaque_up); - return LLDB_RECORD_RESULT(sb_module_spec); + return sb_module_spec; } SBModuleSpec SBModuleSpecList::FindFirstMatchingSpec(const SBModuleSpec &match_spec) { - LLDB_RECORD_METHOD(lldb::SBModuleSpec, SBModuleSpecList, - FindFirstMatchingSpec, (const lldb::SBModuleSpec &), - match_spec); + LLDB_INSTRUMENT_VA(this, match_spec); SBModuleSpec sb_module_spec; m_opaque_up->FindMatchingModuleSpec(*match_spec.m_opaque_up, *sb_module_spec.m_opaque_up); - return LLDB_RECORD_RESULT(sb_module_spec); + return sb_module_spec; } SBModuleSpecList SBModuleSpecList::FindMatchingSpecs(const SBModuleSpec &match_spec) { - LLDB_RECORD_METHOD(lldb::SBModuleSpecList, SBModuleSpecList, - FindMatchingSpecs, (const lldb::SBModuleSpec &), - match_spec); + LLDB_INSTRUMENT_VA(this, match_spec); SBModuleSpecList specs; m_opaque_up->FindMatchingModuleSpecs(*match_spec.m_opaque_up, *specs.m_opaque_up); - return LLDB_RECORD_RESULT(specs); + return specs; } bool SBModuleSpecList::GetDescription(lldb::SBStream &description) { - LLDB_RECORD_METHOD(bool, SBModuleSpecList, GetDescription, (lldb::SBStream &), - description); + LLDB_INSTRUMENT_VA(this, description); m_opaque_up->Dump(description.ref()); return true; } - -namespace lldb_private { -namespace repro { - -template <> -void RegisterMethods<SBModuleSpec>(Registry &R) { - LLDB_REGISTER_CONSTRUCTOR(SBModuleSpec, ()); - LLDB_REGISTER_CONSTRUCTOR(SBModuleSpec, (const lldb::SBModuleSpec &)); - LLDB_REGISTER_METHOD(const lldb::SBModuleSpec &, - SBModuleSpec, operator=,(const lldb::SBModuleSpec &)); - LLDB_REGISTER_METHOD_CONST(bool, SBModuleSpec, IsValid, ()); - LLDB_REGISTER_METHOD_CONST(bool, SBModuleSpec, operator bool, ()); - LLDB_REGISTER_METHOD(void, SBModuleSpec, Clear, ()); - LLDB_REGISTER_METHOD(lldb::SBFileSpec, SBModuleSpec, GetFileSpec, ()); - LLDB_REGISTER_METHOD(void, SBModuleSpec, SetFileSpec, - (const lldb::SBFileSpec &)); - LLDB_REGISTER_METHOD(lldb::SBFileSpec, SBModuleSpec, GetPlatformFileSpec, - ()); - LLDB_REGISTER_METHOD(void, SBModuleSpec, SetPlatformFileSpec, - (const lldb::SBFileSpec &)); - LLDB_REGISTER_METHOD(lldb::SBFileSpec, SBModuleSpec, GetSymbolFileSpec, ()); - LLDB_REGISTER_METHOD(void, SBModuleSpec, SetSymbolFileSpec, - (const lldb::SBFileSpec &)); - LLDB_REGISTER_METHOD(const char *, SBModuleSpec, GetObjectName, ()); - LLDB_REGISTER_METHOD(void, SBModuleSpec, SetObjectName, (const char *)); - LLDB_REGISTER_METHOD(const char *, SBModuleSpec, GetTriple, ()); - LLDB_REGISTER_METHOD(void, SBModuleSpec, SetTriple, (const char *)); - LLDB_REGISTER_METHOD(size_t, SBModuleSpec, GetUUIDLength, ()); - LLDB_REGISTER_METHOD(bool, SBModuleSpec, GetDescription, - (lldb::SBStream &)); - LLDB_REGISTER_CONSTRUCTOR(SBModuleSpecList, ()); - LLDB_REGISTER_CONSTRUCTOR(SBModuleSpecList, - (const lldb::SBModuleSpecList &)); - LLDB_REGISTER_METHOD( - lldb::SBModuleSpecList &, - SBModuleSpecList, operator=,(const lldb::SBModuleSpecList &)); - LLDB_REGISTER_STATIC_METHOD(lldb::SBModuleSpecList, SBModuleSpecList, - GetModuleSpecifications, (const char *)); - LLDB_REGISTER_METHOD(void, SBModuleSpecList, Append, - (const lldb::SBModuleSpec &)); - LLDB_REGISTER_METHOD(void, SBModuleSpecList, Append, - (const lldb::SBModuleSpecList &)); - LLDB_REGISTER_METHOD(size_t, SBModuleSpecList, GetSize, ()); - LLDB_REGISTER_METHOD(lldb::SBModuleSpec, SBModuleSpecList, GetSpecAtIndex, - (size_t)); - LLDB_REGISTER_METHOD(lldb::SBModuleSpec, SBModuleSpecList, - FindFirstMatchingSpec, (const lldb::SBModuleSpec &)); - LLDB_REGISTER_METHOD(lldb::SBModuleSpecList, SBModuleSpecList, - FindMatchingSpecs, (const lldb::SBModuleSpec &)); - LLDB_REGISTER_METHOD(bool, SBModuleSpecList, GetDescription, - (lldb::SBStream &)); -} - -} -} diff --git a/lldb/source/API/SBPlatform.cpp b/lldb/source/API/SBPlatform.cpp index d7a86f0ad1dd..d521a38b30e8 100644 --- a/lldb/source/API/SBPlatform.cpp +++ b/lldb/source/API/SBPlatform.cpp @@ -7,7 +7,6 @@ //===----------------------------------------------------------------------===// #include "lldb/API/SBPlatform.h" -#include "SBReproducerPrivate.h" #include "lldb/API/SBEnvironment.h" #include "lldb/API/SBError.h" #include "lldb/API/SBFileSpec.h" @@ -19,6 +18,7 @@ #include "lldb/Target/Target.h" #include "lldb/Utility/ArchSpec.h" #include "lldb/Utility/Args.h" +#include "lldb/Utility/Instrumentation.h" #include "lldb/Utility/Status.h" #include "llvm/Support/FileSystem.h" @@ -30,10 +30,7 @@ using namespace lldb_private; // PlatformConnectOptions struct PlatformConnectOptions { - PlatformConnectOptions(const char *url = nullptr) - : m_url(), m_rsync_options(), m_rsync_remote_path_prefix(), - - m_local_cache_directory() { + PlatformConnectOptions(const char *url = nullptr) { if (url && url[0]) m_url = url; } @@ -52,7 +49,7 @@ struct PlatformConnectOptions { struct PlatformShellCommand { PlatformShellCommand(llvm::StringRef shell_interpreter, llvm::StringRef shell_command) - : m_command(), m_working_dir(), m_status(0), m_signo(0) { + : m_status(0), m_signo(0) { if (!shell_interpreter.empty()) m_shell = shell_interpreter.str(); @@ -60,8 +57,7 @@ struct PlatformShellCommand { m_command = shell_command.str(); } - PlatformShellCommand(llvm::StringRef shell_command = llvm::StringRef()) - : m_shell(), m_command(), m_working_dir() { + PlatformShellCommand(llvm::StringRef shell_command = llvm::StringRef()) { if (!shell_command.empty()) m_command = shell_command.str(); } @@ -79,14 +75,13 @@ struct PlatformShellCommand { // SBPlatformConnectOptions SBPlatformConnectOptions::SBPlatformConnectOptions(const char *url) : m_opaque_ptr(new PlatformConnectOptions(url)) { - LLDB_RECORD_CONSTRUCTOR(SBPlatformConnectOptions, (const char *), url); + LLDB_INSTRUMENT_VA(this, url); } SBPlatformConnectOptions::SBPlatformConnectOptions( const SBPlatformConnectOptions &rhs) : m_opaque_ptr(new PlatformConnectOptions()) { - LLDB_RECORD_CONSTRUCTOR(SBPlatformConnectOptions, - (const lldb::SBPlatformConnectOptions &), rhs); + LLDB_INSTRUMENT_VA(this, rhs); *m_opaque_ptr = *rhs.m_opaque_ptr; } @@ -95,18 +90,14 @@ SBPlatformConnectOptions::~SBPlatformConnectOptions() { delete m_opaque_ptr; } SBPlatformConnectOptions & SBPlatformConnectOptions::operator=(const SBPlatformConnectOptions &rhs) { - LLDB_RECORD_METHOD( - SBPlatformConnectOptions &, - SBPlatformConnectOptions, operator=,( - const lldb::SBPlatformConnectOptions &), - rhs); + LLDB_INSTRUMENT_VA(this, rhs); *m_opaque_ptr = *rhs.m_opaque_ptr; - return LLDB_RECORD_RESULT(*this); + return *this; } const char *SBPlatformConnectOptions::GetURL() { - LLDB_RECORD_METHOD_NO_ARGS(const char *, SBPlatformConnectOptions, GetURL); + LLDB_INSTRUMENT_VA(this); if (m_opaque_ptr->m_url.empty()) return nullptr; @@ -114,8 +105,7 @@ const char *SBPlatformConnectOptions::GetURL() { } void SBPlatformConnectOptions::SetURL(const char *url) { - LLDB_RECORD_METHOD(void, SBPlatformConnectOptions, SetURL, (const char *), - url); + LLDB_INSTRUMENT_VA(this, url); if (url && url[0]) m_opaque_ptr->m_url = url; @@ -124,7 +114,7 @@ void SBPlatformConnectOptions::SetURL(const char *url) { } bool SBPlatformConnectOptions::GetRsyncEnabled() { - LLDB_RECORD_METHOD_NO_ARGS(bool, SBPlatformConnectOptions, GetRsyncEnabled); + LLDB_INSTRUMENT_VA(this); return m_opaque_ptr->m_rsync_enabled; } @@ -132,9 +122,8 @@ bool SBPlatformConnectOptions::GetRsyncEnabled() { void SBPlatformConnectOptions::EnableRsync( const char *options, const char *remote_path_prefix, bool omit_hostname_from_remote_path) { - LLDB_RECORD_METHOD(void, SBPlatformConnectOptions, EnableRsync, - (const char *, const char *, bool), options, - remote_path_prefix, omit_hostname_from_remote_path); + LLDB_INSTRUMENT_VA(this, options, remote_path_prefix, + omit_hostname_from_remote_path); m_opaque_ptr->m_rsync_enabled = true; m_opaque_ptr->m_rsync_omit_hostname_from_remote_path = @@ -151,21 +140,19 @@ void SBPlatformConnectOptions::EnableRsync( } void SBPlatformConnectOptions::DisableRsync() { - LLDB_RECORD_METHOD_NO_ARGS(void, SBPlatformConnectOptions, DisableRsync); + LLDB_INSTRUMENT_VA(this); m_opaque_ptr->m_rsync_enabled = false; } const char *SBPlatformConnectOptions::GetLocalCacheDirectory() { - LLDB_RECORD_METHOD_NO_ARGS(const char *, SBPlatformConnectOptions, - GetLocalCacheDirectory); + LLDB_INSTRUMENT_VA(this); return m_opaque_ptr->m_local_cache_directory.GetCString(); } void SBPlatformConnectOptions::SetLocalCacheDirectory(const char *path) { - LLDB_RECORD_METHOD(void, SBPlatformConnectOptions, SetLocalCacheDirectory, - (const char *), path); + LLDB_INSTRUMENT_VA(this, path); if (path && path[0]) m_opaque_ptr->m_local_cache_directory.SetCString(path); @@ -177,21 +164,18 @@ void SBPlatformConnectOptions::SetLocalCacheDirectory(const char *path) { SBPlatformShellCommand::SBPlatformShellCommand(const char *shell_interpreter, const char *shell_command) : m_opaque_ptr(new PlatformShellCommand(shell_interpreter, shell_command)) { - LLDB_RECORD_CONSTRUCTOR(SBPlatformShellCommand, (const char *, const char *), - shell_interpreter, shell_command); + LLDB_INSTRUMENT_VA(this, shell_interpreter, shell_command); } SBPlatformShellCommand::SBPlatformShellCommand(const char *shell_command) : m_opaque_ptr(new PlatformShellCommand(shell_command)) { - LLDB_RECORD_CONSTRUCTOR(SBPlatformShellCommand, (const char *), - shell_command); + LLDB_INSTRUMENT_VA(this, shell_command); } SBPlatformShellCommand::SBPlatformShellCommand( const SBPlatformShellCommand &rhs) : m_opaque_ptr(new PlatformShellCommand()) { - LLDB_RECORD_CONSTRUCTOR(SBPlatformShellCommand, - (const lldb::SBPlatformShellCommand &), rhs); + LLDB_INSTRUMENT_VA(this, rhs); *m_opaque_ptr = *rhs.m_opaque_ptr; } @@ -199,19 +183,16 @@ SBPlatformShellCommand::SBPlatformShellCommand( SBPlatformShellCommand & SBPlatformShellCommand::operator=(const SBPlatformShellCommand &rhs) { - LLDB_RECORD_METHOD( - SBPlatformShellCommand &, - SBPlatformShellCommand, operator=,(const lldb::SBPlatformShellCommand &), - rhs); + LLDB_INSTRUMENT_VA(this, rhs); *m_opaque_ptr = *rhs.m_opaque_ptr; - return LLDB_RECORD_RESULT(*this); + return *this; } SBPlatformShellCommand::~SBPlatformShellCommand() { delete m_opaque_ptr; } void SBPlatformShellCommand::Clear() { - LLDB_RECORD_METHOD_NO_ARGS(void, SBPlatformShellCommand, Clear); + LLDB_INSTRUMENT_VA(this); m_opaque_ptr->m_output = std::string(); m_opaque_ptr->m_status = 0; @@ -219,7 +200,7 @@ void SBPlatformShellCommand::Clear() { } const char *SBPlatformShellCommand::GetShell() { - LLDB_RECORD_METHOD_NO_ARGS(const char *, SBPlatformShellCommand, GetShell); + LLDB_INSTRUMENT_VA(this); if (m_opaque_ptr->m_shell.empty()) return nullptr; @@ -227,8 +208,7 @@ const char *SBPlatformShellCommand::GetShell() { } void SBPlatformShellCommand::SetShell(const char *shell_interpreter) { - LLDB_RECORD_METHOD(void, SBPlatformShellCommand, SetShell, (const char *), - shell_interpreter); + LLDB_INSTRUMENT_VA(this, shell_interpreter); if (shell_interpreter && shell_interpreter[0]) m_opaque_ptr->m_shell = shell_interpreter; @@ -237,7 +217,7 @@ void SBPlatformShellCommand::SetShell(const char *shell_interpreter) { } const char *SBPlatformShellCommand::GetCommand() { - LLDB_RECORD_METHOD_NO_ARGS(const char *, SBPlatformShellCommand, GetCommand); + LLDB_INSTRUMENT_VA(this); if (m_opaque_ptr->m_command.empty()) return nullptr; @@ -245,8 +225,7 @@ const char *SBPlatformShellCommand::GetCommand() { } void SBPlatformShellCommand::SetCommand(const char *shell_command) { - LLDB_RECORD_METHOD(void, SBPlatformShellCommand, SetCommand, (const char *), - shell_command); + LLDB_INSTRUMENT_VA(this, shell_command); if (shell_command && shell_command[0]) m_opaque_ptr->m_command = shell_command; @@ -255,8 +234,7 @@ void SBPlatformShellCommand::SetCommand(const char *shell_command) { } const char *SBPlatformShellCommand::GetWorkingDirectory() { - LLDB_RECORD_METHOD_NO_ARGS(const char *, SBPlatformShellCommand, - GetWorkingDirectory); + LLDB_INSTRUMENT_VA(this); if (m_opaque_ptr->m_working_dir.empty()) return nullptr; @@ -264,8 +242,7 @@ const char *SBPlatformShellCommand::GetWorkingDirectory() { } void SBPlatformShellCommand::SetWorkingDirectory(const char *path) { - LLDB_RECORD_METHOD(void, SBPlatformShellCommand, SetWorkingDirectory, - (const char *), path); + LLDB_INSTRUMENT_VA(this, path); if (path && path[0]) m_opaque_ptr->m_working_dir = path; @@ -274,8 +251,7 @@ void SBPlatformShellCommand::SetWorkingDirectory(const char *path) { } uint32_t SBPlatformShellCommand::GetTimeoutSeconds() { - LLDB_RECORD_METHOD_NO_ARGS(uint32_t, SBPlatformShellCommand, - GetTimeoutSeconds); + LLDB_INSTRUMENT_VA(this); if (m_opaque_ptr->m_timeout) return m_opaque_ptr->m_timeout->count(); @@ -283,8 +259,7 @@ uint32_t SBPlatformShellCommand::GetTimeoutSeconds() { } void SBPlatformShellCommand::SetTimeoutSeconds(uint32_t sec) { - LLDB_RECORD_METHOD(void, SBPlatformShellCommand, SetTimeoutSeconds, - (uint32_t), sec); + LLDB_INSTRUMENT_VA(this, sec); if (sec == UINT32_MAX) m_opaque_ptr->m_timeout = llvm::None; @@ -293,19 +268,19 @@ void SBPlatformShellCommand::SetTimeoutSeconds(uint32_t sec) { } int SBPlatformShellCommand::GetSignal() { - LLDB_RECORD_METHOD_NO_ARGS(int, SBPlatformShellCommand, GetSignal); + LLDB_INSTRUMENT_VA(this); return m_opaque_ptr->m_signo; } int SBPlatformShellCommand::GetStatus() { - LLDB_RECORD_METHOD_NO_ARGS(int, SBPlatformShellCommand, GetStatus); + LLDB_INSTRUMENT_VA(this); return m_opaque_ptr->m_status; } const char *SBPlatformShellCommand::GetOutput() { - LLDB_RECORD_METHOD_NO_ARGS(const char *, SBPlatformShellCommand, GetOutput); + LLDB_INSTRUMENT_VA(this); if (m_opaque_ptr->m_output.empty()) return nullptr; @@ -313,12 +288,10 @@ const char *SBPlatformShellCommand::GetOutput() { } // SBPlatform -SBPlatform::SBPlatform() : m_opaque_sp() { - LLDB_RECORD_CONSTRUCTOR_NO_ARGS(SBPlatform); -} +SBPlatform::SBPlatform() { LLDB_INSTRUMENT_VA(this); } -SBPlatform::SBPlatform(const char *platform_name) : m_opaque_sp() { - LLDB_RECORD_CONSTRUCTOR(SBPlatform, (const char *), platform_name); +SBPlatform::SBPlatform(const char *platform_name) { + LLDB_INSTRUMENT_VA(this, platform_name); Status error; if (platform_name && platform_name[0]) @@ -326,48 +299,46 @@ SBPlatform::SBPlatform(const char *platform_name) : m_opaque_sp() { } SBPlatform::SBPlatform(const SBPlatform &rhs) { - LLDB_RECORD_CONSTRUCTOR(SBPlatform, (const lldb::SBPlatform &), rhs); + LLDB_INSTRUMENT_VA(this, rhs); m_opaque_sp = rhs.m_opaque_sp; } SBPlatform &SBPlatform::operator=(const SBPlatform &rhs) { - LLDB_RECORD_METHOD(SBPlatform &, - SBPlatform, operator=,(const lldb::SBPlatform &), rhs); + LLDB_INSTRUMENT_VA(this, rhs); m_opaque_sp = rhs.m_opaque_sp; - return LLDB_RECORD_RESULT(*this); + return *this; } SBPlatform::~SBPlatform() = default; SBPlatform SBPlatform::GetHostPlatform() { - LLDB_RECORD_STATIC_METHOD_NO_ARGS(lldb::SBPlatform, SBPlatform, - GetHostPlatform); + LLDB_INSTRUMENT(); SBPlatform host_platform; host_platform.m_opaque_sp = Platform::GetHostPlatform(); - return LLDB_RECORD_RESULT(host_platform); + return host_platform; } bool SBPlatform::IsValid() const { - LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBPlatform, IsValid); + LLDB_INSTRUMENT_VA(this); return this->operator bool(); } SBPlatform::operator bool() const { - LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBPlatform, operator bool); + LLDB_INSTRUMENT_VA(this); return m_opaque_sp.get() != nullptr; } void SBPlatform::Clear() { - LLDB_RECORD_METHOD_NO_ARGS(void, SBPlatform, Clear); + LLDB_INSTRUMENT_VA(this); m_opaque_sp.reset(); } const char *SBPlatform::GetName() { - LLDB_RECORD_METHOD_NO_ARGS(const char *, SBPlatform, GetName); + LLDB_INSTRUMENT_VA(this); PlatformSP platform_sp(GetSP()); if (platform_sp) @@ -382,7 +353,7 @@ void SBPlatform::SetSP(const lldb::PlatformSP &platform_sp) { } const char *SBPlatform::GetWorkingDirectory() { - LLDB_RECORD_METHOD_NO_ARGS(const char *, SBPlatform, GetWorkingDirectory); + LLDB_INSTRUMENT_VA(this); PlatformSP platform_sp(GetSP()); if (platform_sp) @@ -391,8 +362,7 @@ const char *SBPlatform::GetWorkingDirectory() { } bool SBPlatform::SetWorkingDirectory(const char *path) { - LLDB_RECORD_METHOD(bool, SBPlatform, SetWorkingDirectory, (const char *), - path); + LLDB_INSTRUMENT_VA(this, path); PlatformSP platform_sp(GetSP()); if (platform_sp) { @@ -406,8 +376,7 @@ bool SBPlatform::SetWorkingDirectory(const char *path) { } SBError SBPlatform::ConnectRemote(SBPlatformConnectOptions &connect_options) { - LLDB_RECORD_METHOD(lldb::SBError, SBPlatform, ConnectRemote, - (lldb::SBPlatformConnectOptions &), connect_options); + LLDB_INSTRUMENT_VA(this, connect_options); SBError sb_error; PlatformSP platform_sp(GetSP()); @@ -418,11 +387,11 @@ SBError SBPlatform::ConnectRemote(SBPlatformConnectOptions &connect_options) { } else { sb_error.SetErrorString("invalid platform"); } - return LLDB_RECORD_RESULT(sb_error); + return sb_error; } void SBPlatform::DisconnectRemote() { - LLDB_RECORD_METHOD_NO_ARGS(void, SBPlatform, DisconnectRemote); + LLDB_INSTRUMENT_VA(this); PlatformSP platform_sp(GetSP()); if (platform_sp) @@ -430,7 +399,7 @@ void SBPlatform::DisconnectRemote() { } bool SBPlatform::IsConnected() { - LLDB_RECORD_METHOD_NO_ARGS(bool, SBPlatform, IsConnected); + LLDB_INSTRUMENT_VA(this); PlatformSP platform_sp(GetSP()); if (platform_sp) @@ -439,7 +408,7 @@ bool SBPlatform::IsConnected() { } const char *SBPlatform::GetTriple() { - LLDB_RECORD_METHOD_NO_ARGS(const char *, SBPlatform, GetTriple); + LLDB_INSTRUMENT_VA(this); PlatformSP platform_sp(GetSP()); if (platform_sp) { @@ -454,7 +423,7 @@ const char *SBPlatform::GetTriple() { } const char *SBPlatform::GetOSBuild() { - LLDB_RECORD_METHOD_NO_ARGS(const char *, SBPlatform, GetOSBuild); + LLDB_INSTRUMENT_VA(this); PlatformSP platform_sp(GetSP()); if (platform_sp) { @@ -469,7 +438,7 @@ const char *SBPlatform::GetOSBuild() { } const char *SBPlatform::GetOSDescription() { - LLDB_RECORD_METHOD_NO_ARGS(const char *, SBPlatform, GetOSDescription); + LLDB_INSTRUMENT_VA(this); PlatformSP platform_sp(GetSP()); if (platform_sp) { @@ -484,7 +453,7 @@ const char *SBPlatform::GetOSDescription() { } const char *SBPlatform::GetHostname() { - LLDB_RECORD_METHOD_NO_ARGS(const char *, SBPlatform, GetHostname); + LLDB_INSTRUMENT_VA(this); PlatformSP platform_sp(GetSP()); if (platform_sp) @@ -493,7 +462,7 @@ const char *SBPlatform::GetHostname() { } uint32_t SBPlatform::GetOSMajorVersion() { - LLDB_RECORD_METHOD_NO_ARGS(uint32_t, SBPlatform, GetOSMajorVersion); + LLDB_INSTRUMENT_VA(this); llvm::VersionTuple version; if (PlatformSP platform_sp = GetSP()) @@ -502,7 +471,7 @@ uint32_t SBPlatform::GetOSMajorVersion() { } uint32_t SBPlatform::GetOSMinorVersion() { - LLDB_RECORD_METHOD_NO_ARGS(uint32_t, SBPlatform, GetOSMinorVersion); + LLDB_INSTRUMENT_VA(this); llvm::VersionTuple version; if (PlatformSP platform_sp = GetSP()) @@ -511,7 +480,7 @@ uint32_t SBPlatform::GetOSMinorVersion() { } uint32_t SBPlatform::GetOSUpdateVersion() { - LLDB_RECORD_METHOD_NO_ARGS(uint32_t, SBPlatform, GetOSUpdateVersion); + LLDB_INSTRUMENT_VA(this); llvm::VersionTuple version; if (PlatformSP platform_sp = GetSP()) @@ -519,9 +488,14 @@ uint32_t SBPlatform::GetOSUpdateVersion() { return version.getSubminor().getValueOr(UINT32_MAX); } +void SBPlatform::SetSDKRoot(const char *sysroot) { + LLDB_INSTRUMENT_VA(this, sysroot); + if (PlatformSP platform_sp = GetSP()) + platform_sp->SetSDKRootDirectory(ConstString(sysroot)); +} + SBError SBPlatform::Get(SBFileSpec &src, SBFileSpec &dst) { - LLDB_RECORD_METHOD(lldb::SBError, SBPlatform, Get, - (lldb::SBFileSpec &, lldb::SBFileSpec &), src, dst); + LLDB_INSTRUMENT_VA(this, src, dst); SBError sb_error; PlatformSP platform_sp(GetSP()); @@ -530,54 +504,48 @@ SBError SBPlatform::Get(SBFileSpec &src, SBFileSpec &dst) { } else { sb_error.SetErrorString("invalid platform"); } - return LLDB_RECORD_RESULT(sb_error); + return sb_error; } SBError SBPlatform::Put(SBFileSpec &src, SBFileSpec &dst) { - LLDB_RECORD_METHOD(lldb::SBError, SBPlatform, Put, - (lldb::SBFileSpec &, lldb::SBFileSpec &), src, dst); - return LLDB_RECORD_RESULT( - ExecuteConnected([&](const lldb::PlatformSP &platform_sp) { - if (src.Exists()) { - uint32_t permissions = - FileSystem::Instance().GetPermissions(src.ref()); - if (permissions == 0) { - if (FileSystem::Instance().IsDirectory(src.ref())) - permissions = eFilePermissionsDirectoryDefault; - else - permissions = eFilePermissionsFileDefault; - } - - return platform_sp->PutFile(src.ref(), dst.ref(), permissions); - } + LLDB_INSTRUMENT_VA(this, src, dst); + return ExecuteConnected([&](const lldb::PlatformSP &platform_sp) { + if (src.Exists()) { + uint32_t permissions = FileSystem::Instance().GetPermissions(src.ref()); + if (permissions == 0) { + if (FileSystem::Instance().IsDirectory(src.ref())) + permissions = eFilePermissionsDirectoryDefault; + else + permissions = eFilePermissionsFileDefault; + } + + return platform_sp->PutFile(src.ref(), dst.ref(), permissions); + } - Status error; - error.SetErrorStringWithFormat("'src' argument doesn't exist: '%s'", - src.ref().GetPath().c_str()); - return error; - })); + Status error; + error.SetErrorStringWithFormat("'src' argument doesn't exist: '%s'", + src.ref().GetPath().c_str()); + return error; + }); } SBError SBPlatform::Install(SBFileSpec &src, SBFileSpec &dst) { - LLDB_RECORD_METHOD(lldb::SBError, SBPlatform, Install, - (lldb::SBFileSpec &, lldb::SBFileSpec &), src, dst); - return LLDB_RECORD_RESULT( - ExecuteConnected([&](const lldb::PlatformSP &platform_sp) { - if (src.Exists()) - return platform_sp->Install(src.ref(), dst.ref()); + LLDB_INSTRUMENT_VA(this, src, dst); + return ExecuteConnected([&](const lldb::PlatformSP &platform_sp) { + if (src.Exists()) + return platform_sp->Install(src.ref(), dst.ref()); - Status error; - error.SetErrorStringWithFormat("'src' argument doesn't exist: '%s'", - src.ref().GetPath().c_str()); - return error; - })); + Status error; + error.SetErrorStringWithFormat("'src' argument doesn't exist: '%s'", + src.ref().GetPath().c_str()); + return error; + }); } SBError SBPlatform::Run(SBPlatformShellCommand &shell_command) { - LLDB_RECORD_METHOD(lldb::SBError, SBPlatform, Run, - (lldb::SBPlatformShellCommand &), shell_command); - return LLDB_RECORD_RESULT( - ExecuteConnected([&](const lldb::PlatformSP &platform_sp) { + LLDB_INSTRUMENT_VA(this, shell_command); + return ExecuteConnected( + [&](const lldb::PlatformSP &platform_sp) { const char *command = shell_command.GetCommand(); if (!command) return Status("invalid shell command (empty)"); @@ -594,27 +562,24 @@ SBError SBPlatform::Run(SBPlatformShellCommand &shell_command) { &shell_command.m_opaque_ptr->m_signo, &shell_command.m_opaque_ptr->m_output, shell_command.m_opaque_ptr->m_timeout); - })); + }); } SBError SBPlatform::Launch(SBLaunchInfo &launch_info) { - LLDB_RECORD_METHOD(lldb::SBError, SBPlatform, Launch, (lldb::SBLaunchInfo &), - launch_info); - return LLDB_RECORD_RESULT( - ExecuteConnected([&](const lldb::PlatformSP &platform_sp) { - ProcessLaunchInfo info = launch_info.ref(); - Status error = platform_sp->LaunchProcess(info); - launch_info.set_ref(info); - return error; - })); + LLDB_INSTRUMENT_VA(this, launch_info); + return ExecuteConnected([&](const lldb::PlatformSP &platform_sp) { + ProcessLaunchInfo info = launch_info.ref(); + Status error = platform_sp->LaunchProcess(info); + launch_info.set_ref(info); + return error; + }); } SBError SBPlatform::Kill(const lldb::pid_t pid) { - LLDB_RECORD_METHOD(lldb::SBError, SBPlatform, Kill, (const lldb::pid_t), pid); - return LLDB_RECORD_RESULT( - ExecuteConnected([&](const lldb::PlatformSP &platform_sp) { - return platform_sp->KillProcess(pid); - })); + LLDB_INSTRUMENT_VA(this, pid); + return ExecuteConnected([&](const lldb::PlatformSP &platform_sp) { + return platform_sp->KillProcess(pid); + }); } SBError SBPlatform::ExecuteConnected( @@ -633,8 +598,7 @@ SBError SBPlatform::ExecuteConnected( } SBError SBPlatform::MakeDirectory(const char *path, uint32_t file_permissions) { - LLDB_RECORD_METHOD(lldb::SBError, SBPlatform, MakeDirectory, - (const char *, uint32_t), path, file_permissions); + LLDB_INSTRUMENT_VA(this, path, file_permissions); SBError sb_error; PlatformSP platform_sp(GetSP()); @@ -644,12 +608,11 @@ SBError SBPlatform::MakeDirectory(const char *path, uint32_t file_permissions) { } else { sb_error.SetErrorString("invalid platform"); } - return LLDB_RECORD_RESULT(sb_error); + return sb_error; } uint32_t SBPlatform::GetFilePermissions(const char *path) { - LLDB_RECORD_METHOD(uint32_t, SBPlatform, GetFilePermissions, (const char *), - path); + LLDB_INSTRUMENT_VA(this, path); PlatformSP platform_sp(GetSP()); if (platform_sp) { @@ -662,8 +625,7 @@ uint32_t SBPlatform::GetFilePermissions(const char *path) { SBError SBPlatform::SetFilePermissions(const char *path, uint32_t file_permissions) { - LLDB_RECORD_METHOD(lldb::SBError, SBPlatform, SetFilePermissions, - (const char *, uint32_t), path, file_permissions); + LLDB_INSTRUMENT_VA(this, path, file_permissions); SBError sb_error; PlatformSP platform_sp(GetSP()); @@ -673,126 +635,25 @@ SBError SBPlatform::SetFilePermissions(const char *path, } else { sb_error.SetErrorString("invalid platform"); } - return LLDB_RECORD_RESULT(sb_error); + return sb_error; } SBUnixSignals SBPlatform::GetUnixSignals() const { - LLDB_RECORD_METHOD_CONST_NO_ARGS(lldb::SBUnixSignals, SBPlatform, - GetUnixSignals); + LLDB_INSTRUMENT_VA(this); if (auto platform_sp = GetSP()) - return LLDB_RECORD_RESULT(SBUnixSignals{platform_sp}); + return SBUnixSignals{platform_sp}; - return LLDB_RECORD_RESULT(SBUnixSignals()); + return SBUnixSignals(); } SBEnvironment SBPlatform::GetEnvironment() { - LLDB_RECORD_METHOD_NO_ARGS(lldb::SBEnvironment, SBPlatform, GetEnvironment); + LLDB_INSTRUMENT_VA(this); PlatformSP platform_sp(GetSP()); if (platform_sp) { - return LLDB_RECORD_RESULT(SBEnvironment(platform_sp->GetEnvironment())); + return SBEnvironment(platform_sp->GetEnvironment()); } - return LLDB_RECORD_RESULT(SBEnvironment()); -} - -namespace lldb_private { -namespace repro { - -template <> void RegisterMethods<SBPlatformConnectOptions>(Registry &R) { - LLDB_REGISTER_CONSTRUCTOR(SBPlatformConnectOptions, (const char *)); - LLDB_REGISTER_CONSTRUCTOR(SBPlatformConnectOptions, - (const lldb::SBPlatformConnectOptions &)); - LLDB_REGISTER_METHOD( - SBPlatformConnectOptions &, - SBPlatformConnectOptions, operator=,( - const lldb::SBPlatformConnectOptions &)); - LLDB_REGISTER_METHOD(const char *, SBPlatformConnectOptions, GetURL, ()); - LLDB_REGISTER_METHOD(void, SBPlatformConnectOptions, SetURL, (const char *)); - LLDB_REGISTER_METHOD(bool, SBPlatformConnectOptions, GetRsyncEnabled, ()); - LLDB_REGISTER_METHOD(void, SBPlatformConnectOptions, EnableRsync, - (const char *, const char *, bool)); - LLDB_REGISTER_METHOD(void, SBPlatformConnectOptions, DisableRsync, ()); - LLDB_REGISTER_METHOD(const char *, SBPlatformConnectOptions, - GetLocalCacheDirectory, ()); - LLDB_REGISTER_METHOD(void, SBPlatformConnectOptions, SetLocalCacheDirectory, - (const char *)); -} - -template <> void RegisterMethods<SBPlatformShellCommand>(Registry &R) { - LLDB_REGISTER_CONSTRUCTOR(SBPlatformShellCommand, (const char *)); - LLDB_REGISTER_CONSTRUCTOR(SBPlatformShellCommand, - (const lldb::SBPlatformShellCommand &)); - LLDB_REGISTER_METHOD( - SBPlatformShellCommand &, - SBPlatformShellCommand, operator=,(const lldb::SBPlatformShellCommand &)); - LLDB_REGISTER_METHOD(void, SBPlatformShellCommand, Clear, ()); - LLDB_REGISTER_METHOD(const char *, SBPlatformShellCommand, GetShell, ()); - LLDB_REGISTER_METHOD(void, SBPlatformShellCommand, SetShell, (const char *)); - LLDB_REGISTER_METHOD(const char *, SBPlatformShellCommand, GetCommand, ()); - LLDB_REGISTER_METHOD(void, SBPlatformShellCommand, SetCommand, - (const char *)); - LLDB_REGISTER_METHOD(const char *, SBPlatformShellCommand, - GetWorkingDirectory, ()); - LLDB_REGISTER_METHOD(void, SBPlatformShellCommand, SetWorkingDirectory, - (const char *)); - LLDB_REGISTER_METHOD(uint32_t, SBPlatformShellCommand, GetTimeoutSeconds, ()); - LLDB_REGISTER_METHOD(void, SBPlatformShellCommand, SetTimeoutSeconds, - (uint32_t)); - LLDB_REGISTER_METHOD(int, SBPlatformShellCommand, GetSignal, ()); - LLDB_REGISTER_METHOD(int, SBPlatformShellCommand, GetStatus, ()); - LLDB_REGISTER_METHOD(const char *, SBPlatformShellCommand, GetOutput, ()); -} - -template <> void RegisterMethods<SBPlatform>(Registry &R) { - LLDB_REGISTER_CONSTRUCTOR(SBPlatform, ()); - LLDB_REGISTER_CONSTRUCTOR(SBPlatform, (const char *)); - LLDB_REGISTER_CONSTRUCTOR(SBPlatform, (const lldb::SBPlatform &)); - LLDB_REGISTER_CONSTRUCTOR(SBPlatformShellCommand, - (const char *, const char *)); - LLDB_REGISTER_METHOD(SBPlatform &, - SBPlatform, operator=,(const lldb::SBPlatform &)); - LLDB_REGISTER_METHOD_CONST(bool, SBPlatform, IsValid, ()); - LLDB_REGISTER_METHOD_CONST(bool, SBPlatform, operator bool,()); - LLDB_REGISTER_METHOD(void, SBPlatform, Clear, ()); - LLDB_REGISTER_METHOD(const char *, SBPlatform, GetName, ()); - LLDB_REGISTER_METHOD(const char *, SBPlatform, GetWorkingDirectory, ()); - LLDB_REGISTER_METHOD(bool, SBPlatform, SetWorkingDirectory, (const char *)); - LLDB_REGISTER_METHOD(lldb::SBError, SBPlatform, ConnectRemote, - (lldb::SBPlatformConnectOptions &)); - LLDB_REGISTER_METHOD(void, SBPlatform, DisconnectRemote, ()); - LLDB_REGISTER_METHOD(bool, SBPlatform, IsConnected, ()); - LLDB_REGISTER_METHOD(const char *, SBPlatform, GetTriple, ()); - LLDB_REGISTER_METHOD(const char *, SBPlatform, GetOSBuild, ()); - LLDB_REGISTER_METHOD(const char *, SBPlatform, GetOSDescription, ()); - LLDB_REGISTER_METHOD(const char *, SBPlatform, GetHostname, ()); - LLDB_REGISTER_METHOD(uint32_t, SBPlatform, GetOSMajorVersion, ()); - LLDB_REGISTER_METHOD(uint32_t, SBPlatform, GetOSMinorVersion, ()); - LLDB_REGISTER_METHOD(uint32_t, SBPlatform, GetOSUpdateVersion, ()); - LLDB_REGISTER_METHOD(lldb::SBError, SBPlatform, Get, - (lldb::SBFileSpec &, lldb::SBFileSpec &)); - LLDB_REGISTER_METHOD(lldb::SBError, SBPlatform, Put, - (lldb::SBFileSpec &, lldb::SBFileSpec &)); - LLDB_REGISTER_METHOD(lldb::SBError, SBPlatform, Install, - (lldb::SBFileSpec &, lldb::SBFileSpec &)); - LLDB_REGISTER_METHOD(lldb::SBError, SBPlatform, Run, - (lldb::SBPlatformShellCommand &)); - LLDB_REGISTER_METHOD(lldb::SBError, SBPlatform, Launch, - (lldb::SBLaunchInfo &)); - LLDB_REGISTER_METHOD(lldb::SBError, SBPlatform, Kill, (const lldb::pid_t)); - LLDB_REGISTER_METHOD(lldb::SBError, SBPlatform, MakeDirectory, - (const char *, uint32_t)); - LLDB_REGISTER_METHOD(uint32_t, SBPlatform, GetFilePermissions, - (const char *)); - LLDB_REGISTER_METHOD(lldb::SBError, SBPlatform, SetFilePermissions, - (const char *, uint32_t)); - LLDB_REGISTER_METHOD(lldb::SBEnvironment, SBPlatform, GetEnvironment, ()); - LLDB_REGISTER_METHOD_CONST(lldb::SBUnixSignals, SBPlatform, GetUnixSignals, - ()); - LLDB_REGISTER_STATIC_METHOD(lldb::SBPlatform, SBPlatform, GetHostPlatform, - ()); -} - -} // namespace repro -} // namespace lldb_private + return SBEnvironment(); +} diff --git a/lldb/source/API/SBProcess.cpp b/lldb/source/API/SBProcess.cpp index 797e19462800..2538013412b6 100644 --- a/lldb/source/API/SBProcess.cpp +++ b/lldb/source/API/SBProcess.cpp @@ -7,7 +7,7 @@ //===----------------------------------------------------------------------===// #include "lldb/API/SBProcess.h" -#include "SBReproducerPrivate.h" +#include "lldb/Utility/Instrumentation.h" #include <cinttypes> @@ -49,42 +49,38 @@ using namespace lldb; using namespace lldb_private; -SBProcess::SBProcess() : m_opaque_wp() { - LLDB_RECORD_CONSTRUCTOR_NO_ARGS(SBProcess); -} +SBProcess::SBProcess() { LLDB_INSTRUMENT_VA(this); } // SBProcess constructor SBProcess::SBProcess(const SBProcess &rhs) : m_opaque_wp(rhs.m_opaque_wp) { - LLDB_RECORD_CONSTRUCTOR(SBProcess, (const lldb::SBProcess &), rhs); + LLDB_INSTRUMENT_VA(this, rhs); } SBProcess::SBProcess(const lldb::ProcessSP &process_sp) : m_opaque_wp(process_sp) { - LLDB_RECORD_CONSTRUCTOR(SBProcess, (const lldb::ProcessSP &), process_sp); + LLDB_INSTRUMENT_VA(this, process_sp); } const SBProcess &SBProcess::operator=(const SBProcess &rhs) { - LLDB_RECORD_METHOD(const lldb::SBProcess &, - SBProcess, operator=,(const lldb::SBProcess &), rhs); + LLDB_INSTRUMENT_VA(this, rhs); if (this != &rhs) m_opaque_wp = rhs.m_opaque_wp; - return LLDB_RECORD_RESULT(*this); + return *this; } // Destructor SBProcess::~SBProcess() = default; const char *SBProcess::GetBroadcasterClassName() { - LLDB_RECORD_STATIC_METHOD_NO_ARGS(const char *, SBProcess, - GetBroadcasterClassName); + LLDB_INSTRUMENT(); return Process::GetStaticBroadcasterClass().AsCString(); } const char *SBProcess::GetPluginName() { - LLDB_RECORD_METHOD_NO_ARGS(const char *, SBProcess, GetPluginName); + LLDB_INSTRUMENT_VA(this); ProcessSP process_sp(GetSP()); if (process_sp) { @@ -94,7 +90,7 @@ const char *SBProcess::GetPluginName() { } const char *SBProcess::GetShortPluginName() { - LLDB_RECORD_METHOD_NO_ARGS(const char *, SBProcess, GetShortPluginName); + LLDB_INSTRUMENT_VA(this); ProcessSP process_sp(GetSP()); if (process_sp) { @@ -108,17 +104,17 @@ lldb::ProcessSP SBProcess::GetSP() const { return m_opaque_wp.lock(); } void SBProcess::SetSP(const ProcessSP &process_sp) { m_opaque_wp = process_sp; } void SBProcess::Clear() { - LLDB_RECORD_METHOD_NO_ARGS(void, SBProcess, Clear); + LLDB_INSTRUMENT_VA(this); m_opaque_wp.reset(); } bool SBProcess::IsValid() const { - LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBProcess, IsValid); + LLDB_INSTRUMENT_VA(this); return this->operator bool(); } SBProcess::operator bool() const { - LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBProcess, operator bool); + LLDB_INSTRUMENT_VA(this); ProcessSP process_sp(m_opaque_wp.lock()); return ((bool)process_sp && process_sp->IsValid()); @@ -130,11 +126,7 @@ bool SBProcess::RemoteLaunch(char const **argv, char const **envp, const char *working_directory, uint32_t launch_flags, bool stop_at_entry, lldb::SBError &error) { - LLDB_RECORD_METHOD(bool, SBProcess, RemoteLaunch, - (const char **, const char **, const char *, const char *, - const char *, const char *, uint32_t, bool, - lldb::SBError &), - argv, envp, stdin_path, stdout_path, stderr_path, + LLDB_INSTRUMENT_VA(this, argv, envp, stdin_path, stdout_path, stderr_path, working_directory, launch_flags, stop_at_entry, error); ProcessSP process_sp(GetSP()); @@ -167,8 +159,7 @@ bool SBProcess::RemoteLaunch(char const **argv, char const **envp, bool SBProcess::RemoteAttachToProcessWithID(lldb::pid_t pid, lldb::SBError &error) { - LLDB_RECORD_METHOD(bool, SBProcess, RemoteAttachToProcessWithID, - (lldb::pid_t, lldb::SBError &), pid, error); + LLDB_INSTRUMENT_VA(this, pid, error); ProcessSP process_sp(GetSP()); if (process_sp) { @@ -190,7 +181,7 @@ bool SBProcess::RemoteAttachToProcessWithID(lldb::pid_t pid, } uint32_t SBProcess::GetNumThreads() { - LLDB_RECORD_METHOD_NO_ARGS(uint32_t, SBProcess, GetNumThreads); + LLDB_INSTRUMENT_VA(this); uint32_t num_threads = 0; ProcessSP process_sp(GetSP()); @@ -207,8 +198,7 @@ uint32_t SBProcess::GetNumThreads() { } SBThread SBProcess::GetSelectedThread() const { - LLDB_RECORD_METHOD_CONST_NO_ARGS(lldb::SBThread, SBProcess, - GetSelectedThread); + LLDB_INSTRUMENT_VA(this); SBThread sb_thread; ThreadSP thread_sp; @@ -220,13 +210,12 @@ SBThread SBProcess::GetSelectedThread() const { sb_thread.SetThread(thread_sp); } - return LLDB_RECORD_RESULT(sb_thread); + return sb_thread; } SBThread SBProcess::CreateOSPluginThread(lldb::tid_t tid, lldb::addr_t context) { - LLDB_RECORD_METHOD(lldb::SBThread, SBProcess, CreateOSPluginThread, - (lldb::tid_t, lldb::addr_t), tid, context); + LLDB_INSTRUMENT_VA(this, tid, context); SBThread sb_thread; ThreadSP thread_sp; @@ -238,11 +227,11 @@ SBThread SBProcess::CreateOSPluginThread(lldb::tid_t tid, sb_thread.SetThread(thread_sp); } - return LLDB_RECORD_RESULT(sb_thread); + return sb_thread; } SBTarget SBProcess::GetTarget() const { - LLDB_RECORD_METHOD_CONST_NO_ARGS(lldb::SBTarget, SBProcess, GetTarget); + LLDB_INSTRUMENT_VA(this); SBTarget sb_target; TargetSP target_sp; @@ -252,12 +241,11 @@ SBTarget SBProcess::GetTarget() const { sb_target.SetSP(target_sp); } - return LLDB_RECORD_RESULT(sb_target); + return sb_target; } size_t SBProcess::PutSTDIN(const char *src, size_t src_len) { - LLDB_RECORD_METHOD(size_t, SBProcess, PutSTDIN, (const char *, size_t), src, - src_len); + LLDB_INSTRUMENT_VA(this, src, src_len); size_t ret_val = 0; ProcessSP process_sp(GetSP()); @@ -270,8 +258,7 @@ size_t SBProcess::PutSTDIN(const char *src, size_t src_len) { } size_t SBProcess::GetSTDOUT(char *dst, size_t dst_len) const { - LLDB_RECORD_CHAR_PTR_METHOD_CONST(size_t, SBProcess, GetSTDOUT, - (char *, size_t), dst, "", dst_len); + LLDB_INSTRUMENT_VA(this, dst, dst_len); size_t bytes_read = 0; ProcessSP process_sp(GetSP()); @@ -284,8 +271,7 @@ size_t SBProcess::GetSTDOUT(char *dst, size_t dst_len) const { } size_t SBProcess::GetSTDERR(char *dst, size_t dst_len) const { - LLDB_RECORD_CHAR_PTR_METHOD_CONST(size_t, SBProcess, GetSTDERR, - (char *, size_t), dst, "", dst_len); + LLDB_INSTRUMENT_VA(this, dst, dst_len); size_t bytes_read = 0; ProcessSP process_sp(GetSP()); @@ -298,8 +284,7 @@ size_t SBProcess::GetSTDERR(char *dst, size_t dst_len) const { } size_t SBProcess::GetAsyncProfileData(char *dst, size_t dst_len) const { - LLDB_RECORD_CHAR_PTR_METHOD_CONST(size_t, SBProcess, GetAsyncProfileData, - (char *, size_t), dst, "", dst_len); + LLDB_INSTRUMENT_VA(this, dst, dst_len); size_t bytes_read = 0; ProcessSP process_sp(GetSP()); @@ -312,23 +297,20 @@ size_t SBProcess::GetAsyncProfileData(char *dst, size_t dst_len) const { } void SBProcess::ReportEventState(const SBEvent &event, SBFile out) const { - LLDB_RECORD_METHOD_CONST(void, SBProcess, ReportEventState, - (const SBEvent &, SBFile), event, out); + LLDB_INSTRUMENT_VA(this, event, out); return ReportEventState(event, out.m_opaque_sp); } void SBProcess::ReportEventState(const SBEvent &event, FILE *out) const { - LLDB_RECORD_METHOD_CONST(void, SBProcess, ReportEventState, - (const lldb::SBEvent &, FILE *), event, out); + LLDB_INSTRUMENT_VA(this, event, out); FileSP outfile = std::make_shared<NativeFile>(out, false); return ReportEventState(event, outfile); } void SBProcess::ReportEventState(const SBEvent &event, FileSP out) const { - LLDB_RECORD_METHOD_CONST(void, SBProcess, ReportEventState, - (const SBEvent &, FileSP), event, out); + LLDB_INSTRUMENT_VA(this, event, out); if (!out || !out->IsValid()) return; @@ -344,9 +326,7 @@ void SBProcess::ReportEventState(const SBEvent &event, FileSP out) const { void SBProcess::AppendEventStateReport(const SBEvent &event, SBCommandReturnObject &result) { - LLDB_RECORD_METHOD(void, SBProcess, AppendEventStateReport, - (const lldb::SBEvent &, lldb::SBCommandReturnObject &), - event, result); + LLDB_INSTRUMENT_VA(this, event, result); ProcessSP process_sp(GetSP()); if (process_sp) { @@ -360,8 +340,7 @@ void SBProcess::AppendEventStateReport(const SBEvent &event, } bool SBProcess::SetSelectedThread(const SBThread &thread) { - LLDB_RECORD_METHOD(bool, SBProcess, SetSelectedThread, - (const lldb::SBThread &), thread); + LLDB_INSTRUMENT_VA(this, thread); ProcessSP process_sp(GetSP()); if (process_sp) { @@ -374,9 +353,7 @@ bool SBProcess::SetSelectedThread(const SBThread &thread) { } bool SBProcess::SetSelectedThreadByID(lldb::tid_t tid) { - LLDB_RECORD_METHOD(bool, SBProcess, SetSelectedThreadByID, (lldb::tid_t), - tid); - + LLDB_INSTRUMENT_VA(this, tid); bool ret_val = false; ProcessSP process_sp(GetSP()); @@ -390,8 +367,7 @@ bool SBProcess::SetSelectedThreadByID(lldb::tid_t tid) { } bool SBProcess::SetSelectedThreadByIndexID(uint32_t index_id) { - LLDB_RECORD_METHOD(bool, SBProcess, SetSelectedThreadByIndexID, (uint32_t), - index_id); + LLDB_INSTRUMENT_VA(this, index_id); bool ret_val = false; ProcessSP process_sp(GetSP()); @@ -406,8 +382,7 @@ bool SBProcess::SetSelectedThreadByIndexID(uint32_t index_id) { } SBThread SBProcess::GetThreadAtIndex(size_t index) { - LLDB_RECORD_METHOD(lldb::SBThread, SBProcess, GetThreadAtIndex, (size_t), - index); + LLDB_INSTRUMENT_VA(this, index); SBThread sb_thread; ThreadSP thread_sp; @@ -421,11 +396,11 @@ SBThread SBProcess::GetThreadAtIndex(size_t index) { sb_thread.SetThread(thread_sp); } - return LLDB_RECORD_RESULT(sb_thread); + return sb_thread; } uint32_t SBProcess::GetNumQueues() { - LLDB_RECORD_METHOD_NO_ARGS(uint32_t, SBProcess, GetNumQueues); + LLDB_INSTRUMENT_VA(this); uint32_t num_queues = 0; ProcessSP process_sp(GetSP()); @@ -442,8 +417,7 @@ uint32_t SBProcess::GetNumQueues() { } SBQueue SBProcess::GetQueueAtIndex(size_t index) { - LLDB_RECORD_METHOD(lldb::SBQueue, SBProcess, GetQueueAtIndex, (size_t), - index); + LLDB_INSTRUMENT_VA(this, index); SBQueue sb_queue; QueueSP queue_sp; @@ -458,12 +432,11 @@ SBQueue SBProcess::GetQueueAtIndex(size_t index) { } } - return LLDB_RECORD_RESULT(sb_queue); + return sb_queue; } uint32_t SBProcess::GetStopID(bool include_expression_stops) { - LLDB_RECORD_METHOD(uint32_t, SBProcess, GetStopID, (bool), - include_expression_stops); + LLDB_INSTRUMENT_VA(this, include_expression_stops); ProcessSP process_sp(GetSP()); if (process_sp) { @@ -478,8 +451,7 @@ uint32_t SBProcess::GetStopID(bool include_expression_stops) { } SBEvent SBProcess::GetStopEventForStopID(uint32_t stop_id) { - LLDB_RECORD_METHOD(lldb::SBEvent, SBProcess, GetStopEventForStopID, - (uint32_t), stop_id); + LLDB_INSTRUMENT_VA(this, stop_id); SBEvent sb_event; EventSP event_sp; @@ -491,11 +463,11 @@ SBEvent SBProcess::GetStopEventForStopID(uint32_t stop_id) { sb_event.reset(event_sp); } - return LLDB_RECORD_RESULT(sb_event); + return sb_event; } StateType SBProcess::GetState() { - LLDB_RECORD_METHOD_NO_ARGS(lldb::StateType, SBProcess, GetState); + LLDB_INSTRUMENT_VA(this); StateType ret_val = eStateInvalid; ProcessSP process_sp(GetSP()); @@ -509,7 +481,7 @@ StateType SBProcess::GetState() { } int SBProcess::GetExitStatus() { - LLDB_RECORD_METHOD_NO_ARGS(int, SBProcess, GetExitStatus); + LLDB_INSTRUMENT_VA(this); int exit_status = 0; ProcessSP process_sp(GetSP()); @@ -523,7 +495,7 @@ int SBProcess::GetExitStatus() { } const char *SBProcess::GetExitDescription() { - LLDB_RECORD_METHOD_NO_ARGS(const char *, SBProcess, GetExitDescription); + LLDB_INSTRUMENT_VA(this); const char *exit_desc = nullptr; ProcessSP process_sp(GetSP()); @@ -536,7 +508,7 @@ const char *SBProcess::GetExitDescription() { } lldb::pid_t SBProcess::GetProcessID() { - LLDB_RECORD_METHOD_NO_ARGS(lldb::pid_t, SBProcess, GetProcessID); + LLDB_INSTRUMENT_VA(this); lldb::pid_t ret_val = LLDB_INVALID_PROCESS_ID; ProcessSP process_sp(GetSP()); @@ -547,7 +519,7 @@ lldb::pid_t SBProcess::GetProcessID() { } uint32_t SBProcess::GetUniqueID() { - LLDB_RECORD_METHOD_NO_ARGS(uint32_t, SBProcess, GetUniqueID); + LLDB_INSTRUMENT_VA(this); uint32_t ret_val = 0; ProcessSP process_sp(GetSP()); @@ -557,7 +529,7 @@ uint32_t SBProcess::GetUniqueID() { } ByteOrder SBProcess::GetByteOrder() const { - LLDB_RECORD_METHOD_CONST_NO_ARGS(lldb::ByteOrder, SBProcess, GetByteOrder); + LLDB_INSTRUMENT_VA(this); ByteOrder byteOrder = eByteOrderInvalid; ProcessSP process_sp(GetSP()); @@ -569,7 +541,7 @@ ByteOrder SBProcess::GetByteOrder() const { } uint32_t SBProcess::GetAddressByteSize() const { - LLDB_RECORD_METHOD_CONST_NO_ARGS(uint32_t, SBProcess, GetAddressByteSize); + LLDB_INSTRUMENT_VA(this); uint32_t size = 0; ProcessSP process_sp(GetSP()); @@ -581,7 +553,7 @@ uint32_t SBProcess::GetAddressByteSize() const { } SBError SBProcess::Continue() { - LLDB_RECORD_METHOD_NO_ARGS(lldb::SBError, SBProcess, Continue); + LLDB_INSTRUMENT_VA(this); SBError sb_error; ProcessSP process_sp(GetSP()); @@ -597,11 +569,11 @@ SBError SBProcess::Continue() { } else sb_error.SetErrorString("SBProcess is invalid"); - return LLDB_RECORD_RESULT(sb_error); + return sb_error; } SBError SBProcess::Destroy() { - LLDB_RECORD_METHOD_NO_ARGS(lldb::SBError, SBProcess, Destroy); + LLDB_INSTRUMENT_VA(this); SBError sb_error; ProcessSP process_sp(GetSP()); @@ -612,11 +584,11 @@ SBError SBProcess::Destroy() { } else sb_error.SetErrorString("SBProcess is invalid"); - return LLDB_RECORD_RESULT(sb_error); + return sb_error; } SBError SBProcess::Stop() { - LLDB_RECORD_METHOD_NO_ARGS(lldb::SBError, SBProcess, Stop); + LLDB_INSTRUMENT_VA(this); SBError sb_error; ProcessSP process_sp(GetSP()); @@ -627,11 +599,11 @@ SBError SBProcess::Stop() { } else sb_error.SetErrorString("SBProcess is invalid"); - return LLDB_RECORD_RESULT(sb_error); + return sb_error; } SBError SBProcess::Kill() { - LLDB_RECORD_METHOD_NO_ARGS(lldb::SBError, SBProcess, Kill); + LLDB_INSTRUMENT_VA(this); SBError sb_error; ProcessSP process_sp(GetSP()); @@ -642,19 +614,19 @@ SBError SBProcess::Kill() { } else sb_error.SetErrorString("SBProcess is invalid"); - return LLDB_RECORD_RESULT(sb_error); + return sb_error; } SBError SBProcess::Detach() { - LLDB_RECORD_METHOD_NO_ARGS(lldb::SBError, SBProcess, Detach); + LLDB_INSTRUMENT_VA(this); // FIXME: This should come from a process default. bool keep_stopped = false; - return LLDB_RECORD_RESULT(Detach(keep_stopped)); + return Detach(keep_stopped); } SBError SBProcess::Detach(bool keep_stopped) { - LLDB_RECORD_METHOD(lldb::SBError, SBProcess, Detach, (bool), keep_stopped); + LLDB_INSTRUMENT_VA(this, keep_stopped); SBError sb_error; ProcessSP process_sp(GetSP()); @@ -665,11 +637,11 @@ SBError SBProcess::Detach(bool keep_stopped) { } else sb_error.SetErrorString("SBProcess is invalid"); - return LLDB_RECORD_RESULT(sb_error); + return sb_error; } SBError SBProcess::Signal(int signo) { - LLDB_RECORD_METHOD(lldb::SBError, SBProcess, Signal, (int), signo); + LLDB_INSTRUMENT_VA(this, signo); SBError sb_error; ProcessSP process_sp(GetSP()); @@ -680,20 +652,20 @@ SBError SBProcess::Signal(int signo) { } else sb_error.SetErrorString("SBProcess is invalid"); - return LLDB_RECORD_RESULT(sb_error); + return sb_error; } SBUnixSignals SBProcess::GetUnixSignals() { - LLDB_RECORD_METHOD_NO_ARGS(lldb::SBUnixSignals, SBProcess, GetUnixSignals); + LLDB_INSTRUMENT_VA(this); if (auto process_sp = GetSP()) - return LLDB_RECORD_RESULT(SBUnixSignals{process_sp}); + return SBUnixSignals{process_sp}; - return LLDB_RECORD_RESULT(SBUnixSignals{}); + return SBUnixSignals{}; } void SBProcess::SendAsyncInterrupt() { - LLDB_RECORD_METHOD_NO_ARGS(void, SBProcess, SendAsyncInterrupt); + LLDB_INSTRUMENT_VA(this); ProcessSP process_sp(GetSP()); if (process_sp) { @@ -702,8 +674,7 @@ void SBProcess::SendAsyncInterrupt() { } SBThread SBProcess::GetThreadByID(tid_t tid) { - LLDB_RECORD_METHOD(lldb::SBThread, SBProcess, GetThreadByID, (lldb::tid_t), - tid); + LLDB_INSTRUMENT_VA(this, tid); SBThread sb_thread; ThreadSP thread_sp; @@ -717,12 +688,11 @@ SBThread SBProcess::GetThreadByID(tid_t tid) { sb_thread.SetThread(thread_sp); } - return LLDB_RECORD_RESULT(sb_thread); + return sb_thread; } SBThread SBProcess::GetThreadByIndexID(uint32_t index_id) { - LLDB_RECORD_METHOD(lldb::SBThread, SBProcess, GetThreadByIndexID, (uint32_t), - index_id); + LLDB_INSTRUMENT_VA(this, index_id); SBThread sb_thread; ThreadSP thread_sp; @@ -737,12 +707,11 @@ SBThread SBProcess::GetThreadByIndexID(uint32_t index_id) { sb_thread.SetThread(thread_sp); } - return LLDB_RECORD_RESULT(sb_thread); + return sb_thread; } StateType SBProcess::GetStateFromEvent(const SBEvent &event) { - LLDB_RECORD_STATIC_METHOD(lldb::StateType, SBProcess, GetStateFromEvent, - (const lldb::SBEvent &), event); + LLDB_INSTRUMENT_VA(event); StateType ret_val = Process::ProcessEventData::GetStateFromEvent(event.get()); @@ -750,8 +719,7 @@ StateType SBProcess::GetStateFromEvent(const SBEvent &event) { } bool SBProcess::GetRestartedFromEvent(const SBEvent &event) { - LLDB_RECORD_STATIC_METHOD(bool, SBProcess, GetRestartedFromEvent, - (const lldb::SBEvent &), event); + LLDB_INSTRUMENT_VA(event); bool ret_val = Process::ProcessEventData::GetRestartedFromEvent(event.get()); @@ -759,8 +727,7 @@ bool SBProcess::GetRestartedFromEvent(const SBEvent &event) { } size_t SBProcess::GetNumRestartedReasonsFromEvent(const lldb::SBEvent &event) { - LLDB_RECORD_STATIC_METHOD(size_t, SBProcess, GetNumRestartedReasonsFromEvent, - (const lldb::SBEvent &), event); + LLDB_INSTRUMENT_VA(event); return Process::ProcessEventData::GetNumRestartedReasons(event.get()); } @@ -768,16 +735,13 @@ size_t SBProcess::GetNumRestartedReasonsFromEvent(const lldb::SBEvent &event) { const char * SBProcess::GetRestartedReasonAtIndexFromEvent(const lldb::SBEvent &event, size_t idx) { - LLDB_RECORD_STATIC_METHOD(const char *, SBProcess, - GetRestartedReasonAtIndexFromEvent, - (const lldb::SBEvent &, size_t), event, idx); + LLDB_INSTRUMENT_VA(event, idx); return Process::ProcessEventData::GetRestartedReasonAtIndex(event.get(), idx); } SBProcess SBProcess::GetProcessFromEvent(const SBEvent &event) { - LLDB_RECORD_STATIC_METHOD(lldb::SBProcess, SBProcess, GetProcessFromEvent, - (const lldb::SBEvent &), event); + LLDB_INSTRUMENT_VA(event); ProcessSP process_sp = Process::ProcessEventData::GetProcessFromEvent(event.get()); @@ -786,36 +750,31 @@ SBProcess SBProcess::GetProcessFromEvent(const SBEvent &event) { process_sp = EventDataStructuredData::GetProcessFromEvent(event.get()); } - return LLDB_RECORD_RESULT(SBProcess(process_sp)); + return SBProcess(process_sp); } bool SBProcess::GetInterruptedFromEvent(const SBEvent &event) { - LLDB_RECORD_STATIC_METHOD(bool, SBProcess, GetInterruptedFromEvent, - (const lldb::SBEvent &), event); + LLDB_INSTRUMENT_VA(event); return Process::ProcessEventData::GetInterruptedFromEvent(event.get()); } lldb::SBStructuredData SBProcess::GetStructuredDataFromEvent(const lldb::SBEvent &event) { - LLDB_RECORD_STATIC_METHOD(lldb::SBStructuredData, SBProcess, - GetStructuredDataFromEvent, (const lldb::SBEvent &), - event); + LLDB_INSTRUMENT_VA(event); - return LLDB_RECORD_RESULT(SBStructuredData(event.GetSP())); + return SBStructuredData(event.GetSP()); } bool SBProcess::EventIsProcessEvent(const SBEvent &event) { - LLDB_RECORD_STATIC_METHOD(bool, SBProcess, EventIsProcessEvent, - (const lldb::SBEvent &), event); + LLDB_INSTRUMENT_VA(event); return (event.GetBroadcasterClass() == SBProcess::GetBroadcasterClass()) && !EventIsStructuredDataEvent(event); } bool SBProcess::EventIsStructuredDataEvent(const lldb::SBEvent &event) { - LLDB_RECORD_STATIC_METHOD(bool, SBProcess, EventIsStructuredDataEvent, - (const lldb::SBEvent &), event); + LLDB_INSTRUMENT_VA(event); EventSP event_sp = event.GetSP(); EventData *event_data = event_sp ? event_sp->GetData() : nullptr; @@ -824,30 +783,24 @@ bool SBProcess::EventIsStructuredDataEvent(const lldb::SBEvent &event) { } SBBroadcaster SBProcess::GetBroadcaster() const { - LLDB_RECORD_METHOD_CONST_NO_ARGS(lldb::SBBroadcaster, SBProcess, - GetBroadcaster); - + LLDB_INSTRUMENT_VA(this); ProcessSP process_sp(GetSP()); SBBroadcaster broadcaster(process_sp.get(), false); - - return LLDB_RECORD_RESULT(broadcaster); + return broadcaster; } const char *SBProcess::GetBroadcasterClass() { - LLDB_RECORD_STATIC_METHOD_NO_ARGS(const char *, SBProcess, - GetBroadcasterClass); + LLDB_INSTRUMENT(); return Process::GetStaticBroadcasterClass().AsCString(); } size_t SBProcess::ReadMemory(addr_t addr, void *dst, size_t dst_len, SBError &sb_error) { - LLDB_RECORD_DUMMY(size_t, SBProcess, ReadMemory, - (lldb::addr_t, void *, size_t, lldb::SBError &), addr, dst, - dst_len, sb_error); + LLDB_INSTRUMENT_VA(this, addr, dst, dst_len, sb_error); size_t bytes_read = 0; @@ -872,9 +825,7 @@ size_t SBProcess::ReadMemory(addr_t addr, void *dst, size_t dst_len, size_t SBProcess::ReadCStringFromMemory(addr_t addr, void *buf, size_t size, lldb::SBError &sb_error) { - LLDB_RECORD_DUMMY(size_t, SBProcess, ReadCStringFromMemory, - (lldb::addr_t, void *, size_t, lldb::SBError &), addr, buf, - size, sb_error); + LLDB_INSTRUMENT_VA(this, addr, buf, size, sb_error); size_t bytes_read = 0; ProcessSP process_sp(GetSP()); @@ -896,9 +847,7 @@ size_t SBProcess::ReadCStringFromMemory(addr_t addr, void *buf, size_t size, uint64_t SBProcess::ReadUnsignedFromMemory(addr_t addr, uint32_t byte_size, lldb::SBError &sb_error) { - LLDB_RECORD_METHOD(uint64_t, SBProcess, ReadUnsignedFromMemory, - (lldb::addr_t, uint32_t, lldb::SBError &), addr, byte_size, - sb_error); + LLDB_INSTRUMENT_VA(this, addr, byte_size, sb_error); uint64_t value = 0; ProcessSP process_sp(GetSP()); @@ -920,8 +869,7 @@ uint64_t SBProcess::ReadUnsignedFromMemory(addr_t addr, uint32_t byte_size, lldb::addr_t SBProcess::ReadPointerFromMemory(addr_t addr, lldb::SBError &sb_error) { - LLDB_RECORD_METHOD(lldb::addr_t, SBProcess, ReadPointerFromMemory, - (lldb::addr_t, lldb::SBError &), addr, sb_error); + LLDB_INSTRUMENT_VA(this, addr, sb_error); lldb::addr_t ptr = LLDB_INVALID_ADDRESS; ProcessSP process_sp(GetSP()); @@ -942,9 +890,7 @@ lldb::addr_t SBProcess::ReadPointerFromMemory(addr_t addr, size_t SBProcess::WriteMemory(addr_t addr, const void *src, size_t src_len, SBError &sb_error) { - LLDB_RECORD_DUMMY(size_t, SBProcess, WriteMemory, - (lldb::addr_t, const void *, size_t, lldb::SBError &), addr, - src, src_len, sb_error); + LLDB_INSTRUMENT_VA(this, addr, src, src_len, sb_error); size_t bytes_written = 0; @@ -966,8 +912,7 @@ size_t SBProcess::WriteMemory(addr_t addr, const void *src, size_t src_len, } bool SBProcess::GetDescription(SBStream &description) { - LLDB_RECORD_METHOD(bool, SBProcess, GetDescription, (lldb::SBStream &), - description); + LLDB_INSTRUMENT_VA(this, description); Stream &strm = description.ref(); @@ -991,34 +936,31 @@ bool SBProcess::GetDescription(SBStream &description) { } SBStructuredData SBProcess::GetExtendedCrashInformation() { - LLDB_RECORD_METHOD_NO_ARGS(lldb::SBStructuredData, SBProcess, - GetExtendedCrashInformation); + LLDB_INSTRUMENT_VA(this); SBStructuredData data; ProcessSP process_sp(GetSP()); if (!process_sp) - return LLDB_RECORD_RESULT(data); + return data; PlatformSP platform_sp = process_sp->GetTarget().GetPlatform(); if (!platform_sp) - return LLDB_RECORD_RESULT(data); + return data; auto expected_data = platform_sp->FetchExtendedCrashInformation(*process_sp.get()); if (!expected_data) - return LLDB_RECORD_RESULT(data); + return data; StructuredData::ObjectSP fetched_data = *expected_data; data.m_impl_up->SetObjectSP(fetched_data); - return LLDB_RECORD_RESULT(data); + return data; } uint32_t SBProcess::GetNumSupportedHardwareWatchpoints(lldb::SBError &sb_error) const { - LLDB_RECORD_METHOD_CONST(uint32_t, SBProcess, - GetNumSupportedHardwareWatchpoints, - (lldb::SBError &), sb_error); + LLDB_INSTRUMENT_VA(this, sb_error); uint32_t num = 0; ProcessSP process_sp(GetSP()); @@ -1034,9 +976,7 @@ SBProcess::GetNumSupportedHardwareWatchpoints(lldb::SBError &sb_error) const { uint32_t SBProcess::LoadImage(lldb::SBFileSpec &sb_remote_image_spec, lldb::SBError &sb_error) { - LLDB_RECORD_METHOD(uint32_t, SBProcess, LoadImage, - (lldb::SBFileSpec &, lldb::SBError &), - sb_remote_image_spec, sb_error); + LLDB_INSTRUMENT_VA(this, sb_remote_image_spec, sb_error); return LoadImage(SBFileSpec(), sb_remote_image_spec, sb_error); } @@ -1044,10 +984,7 @@ uint32_t SBProcess::LoadImage(lldb::SBFileSpec &sb_remote_image_spec, uint32_t SBProcess::LoadImage(const lldb::SBFileSpec &sb_local_image_spec, const lldb::SBFileSpec &sb_remote_image_spec, lldb::SBError &sb_error) { - LLDB_RECORD_METHOD( - uint32_t, SBProcess, LoadImage, - (const lldb::SBFileSpec &, const lldb::SBFileSpec &, lldb::SBError &), - sb_local_image_spec, sb_remote_image_spec, sb_error); + LLDB_INSTRUMENT_VA(this, sb_local_image_spec, sb_remote_image_spec, sb_error); ProcessSP process_sp(GetSP()); if (process_sp) { @@ -1071,10 +1008,7 @@ uint32_t SBProcess::LoadImageUsingPaths(const lldb::SBFileSpec &image_spec, SBStringList &paths, lldb::SBFileSpec &loaded_path, lldb::SBError &error) { - LLDB_RECORD_METHOD(uint32_t, SBProcess, LoadImageUsingPaths, - (const lldb::SBFileSpec &, lldb::SBStringList &, - lldb::SBFileSpec &, lldb::SBError &), - image_spec, paths, loaded_path, error); + LLDB_INSTRUMENT_VA(this, image_spec, paths, loaded_path, error); ProcessSP process_sp(GetSP()); if (process_sp) { @@ -1106,8 +1040,7 @@ uint32_t SBProcess::LoadImageUsingPaths(const lldb::SBFileSpec &image_spec, } lldb::SBError SBProcess::UnloadImage(uint32_t image_token) { - LLDB_RECORD_METHOD(lldb::SBError, SBProcess, UnloadImage, (uint32_t), - image_token); + LLDB_INSTRUMENT_VA(this, image_token); lldb::SBError sb_error; ProcessSP process_sp(GetSP()); @@ -1124,12 +1057,11 @@ lldb::SBError SBProcess::UnloadImage(uint32_t image_token) { } } else sb_error.SetErrorString("invalid process"); - return LLDB_RECORD_RESULT(sb_error); + return sb_error; } lldb::SBError SBProcess::SendEventData(const char *event_data) { - LLDB_RECORD_METHOD(lldb::SBError, SBProcess, SendEventData, (const char *), - event_data); + LLDB_INSTRUMENT_VA(this, event_data); lldb::SBError sb_error; ProcessSP process_sp(GetSP()); @@ -1144,11 +1076,11 @@ lldb::SBError SBProcess::SendEventData(const char *event_data) { } } else sb_error.SetErrorString("invalid process"); - return LLDB_RECORD_RESULT(sb_error); + return sb_error; } uint32_t SBProcess::GetNumExtendedBacktraceTypes() { - LLDB_RECORD_METHOD_NO_ARGS(uint32_t, SBProcess, GetNumExtendedBacktraceTypes); + LLDB_INSTRUMENT_VA(this); ProcessSP process_sp(GetSP()); if (process_sp && process_sp->GetSystemRuntime()) { @@ -1159,8 +1091,7 @@ uint32_t SBProcess::GetNumExtendedBacktraceTypes() { } const char *SBProcess::GetExtendedBacktraceTypeAtIndex(uint32_t idx) { - LLDB_RECORD_METHOD(const char *, SBProcess, GetExtendedBacktraceTypeAtIndex, - (uint32_t), idx); + LLDB_INSTRUMENT_VA(this, idx); ProcessSP process_sp(GetSP()); if (process_sp && process_sp->GetSystemRuntime()) { @@ -1175,21 +1106,19 @@ const char *SBProcess::GetExtendedBacktraceTypeAtIndex(uint32_t idx) { } SBThreadCollection SBProcess::GetHistoryThreads(addr_t addr) { - LLDB_RECORD_METHOD(lldb::SBThreadCollection, SBProcess, GetHistoryThreads, - (lldb::addr_t), addr); + LLDB_INSTRUMENT_VA(this, addr); ProcessSP process_sp(GetSP()); SBThreadCollection threads; if (process_sp) { threads = SBThreadCollection(process_sp->GetHistoryThreads(addr)); } - return LLDB_RECORD_RESULT(threads); + return threads; } bool SBProcess::IsInstrumentationRuntimePresent( InstrumentationRuntimeType type) { - LLDB_RECORD_METHOD(bool, SBProcess, IsInstrumentationRuntimePresent, - (lldb::InstrumentationRuntimeType), type); + LLDB_INSTRUMENT_VA(this, type); ProcessSP process_sp(GetSP()); if (!process_sp) @@ -1208,14 +1137,13 @@ bool SBProcess::IsInstrumentationRuntimePresent( } lldb::SBError SBProcess::SaveCore(const char *file_name) { - LLDB_RECORD_METHOD(lldb::SBError, SBProcess, SaveCore, (const char *), - file_name); + LLDB_INSTRUMENT_VA(this, file_name); lldb::SBError error; ProcessSP process_sp(GetSP()); if (!process_sp) { error.SetErrorString("SBProcess is invalid"); - return LLDB_RECORD_RESULT(error); + return error; } std::lock_guard<std::recursive_mutex> guard( @@ -1223,21 +1151,19 @@ lldb::SBError SBProcess::SaveCore(const char *file_name) { if (process_sp->GetState() != eStateStopped) { error.SetErrorString("the process is not stopped"); - return LLDB_RECORD_RESULT(error); + return error; } FileSpec core_file(file_name); SaveCoreStyle core_style = SaveCoreStyle::eSaveCoreFull; error.ref() = PluginManager::SaveCore(process_sp, core_file, core_style, ""); - return LLDB_RECORD_RESULT(error); + return error; } lldb::SBError SBProcess::GetMemoryRegionInfo(lldb::addr_t load_addr, SBMemoryRegionInfo &sb_region_info) { - LLDB_RECORD_METHOD(lldb::SBError, SBProcess, GetMemoryRegionInfo, - (lldb::addr_t, lldb::SBMemoryRegionInfo &), load_addr, - sb_region_info); + LLDB_INSTRUMENT_VA(this, load_addr, sb_region_info); lldb::SBError sb_error; ProcessSP process_sp(GetSP()); @@ -1255,12 +1181,11 @@ SBProcess::GetMemoryRegionInfo(lldb::addr_t load_addr, } else { sb_error.SetErrorString("SBProcess is invalid"); } - return LLDB_RECORD_RESULT(sb_error); + return sb_error; } lldb::SBMemoryRegionInfoList SBProcess::GetMemoryRegions() { - LLDB_RECORD_METHOD_NO_ARGS(lldb::SBMemoryRegionInfoList, SBProcess, - GetMemoryRegions); + LLDB_INSTRUMENT_VA(this); lldb::SBMemoryRegionInfoList sb_region_list; @@ -1273,11 +1198,11 @@ lldb::SBMemoryRegionInfoList SBProcess::GetMemoryRegions() { process_sp->GetMemoryRegions(sb_region_list.ref()); } - return LLDB_RECORD_RESULT(sb_region_list); + return sb_region_list; } lldb::SBProcessInfo SBProcess::GetProcessInfo() { - LLDB_RECORD_METHOD_NO_ARGS(lldb::SBProcessInfo, SBProcess, GetProcessInfo); + LLDB_INSTRUMENT_VA(this); lldb::SBProcessInfo sb_proc_info; ProcessSP process_sp(GetSP()); @@ -1285,14 +1210,12 @@ lldb::SBProcessInfo SBProcess::GetProcessInfo() { if (process_sp && process_sp->GetProcessInfo(proc_info)) { sb_proc_info.SetProcessInfo(proc_info); } - return LLDB_RECORD_RESULT(sb_proc_info); + return sb_proc_info; } lldb::addr_t SBProcess::AllocateMemory(size_t size, uint32_t permissions, lldb::SBError &sb_error) { - LLDB_RECORD_METHOD(lldb::addr_t, SBProcess, AllocateMemory, - (size_t, uint32_t, lldb::SBError &), size, permissions, - sb_error); + LLDB_INSTRUMENT_VA(this, size, permissions, sb_error); lldb::addr_t addr = LLDB_INVALID_ADDRESS; ProcessSP process_sp(GetSP()); @@ -1312,8 +1235,7 @@ lldb::addr_t SBProcess::AllocateMemory(size_t size, uint32_t permissions, } lldb::SBError SBProcess::DeallocateMemory(lldb::addr_t ptr) { - LLDB_RECORD_METHOD(lldb::SBError, SBProcess, DeallocateMemory, (lldb::addr_t), - ptr); + LLDB_INSTRUMENT_VA(this, ptr); lldb::SBError sb_error; ProcessSP process_sp(GetSP()); @@ -1332,145 +1254,3 @@ lldb::SBError SBProcess::DeallocateMemory(lldb::addr_t ptr) { } return sb_error; } - -namespace lldb_private { -namespace repro { - -template <> -void RegisterMethods<SBProcess>(Registry &R) { - LLDB_REGISTER_CONSTRUCTOR(SBProcess, ()); - LLDB_REGISTER_CONSTRUCTOR(SBProcess, (const lldb::SBProcess &)); - LLDB_REGISTER_CONSTRUCTOR(SBProcess, (const lldb::ProcessSP &)); - LLDB_REGISTER_METHOD(const lldb::SBProcess &, - SBProcess, operator=,(const lldb::SBProcess &)); - LLDB_REGISTER_STATIC_METHOD(const char *, SBProcess, - GetBroadcasterClassName, ()); - LLDB_REGISTER_METHOD(const char *, SBProcess, GetPluginName, ()); - LLDB_REGISTER_METHOD(const char *, SBProcess, GetShortPluginName, ()); - LLDB_REGISTER_METHOD(void, SBProcess, Clear, ()); - LLDB_REGISTER_METHOD_CONST(bool, SBProcess, IsValid, ()); - LLDB_REGISTER_METHOD_CONST(bool, SBProcess, operator bool, ()); - LLDB_REGISTER_METHOD(bool, SBProcess, RemoteLaunch, - (const char **, const char **, const char *, - const char *, const char *, const char *, uint32_t, - bool, lldb::SBError &)); - LLDB_REGISTER_METHOD(bool, SBProcess, RemoteAttachToProcessWithID, - (lldb::pid_t, lldb::SBError &)); - LLDB_REGISTER_METHOD(uint32_t, SBProcess, GetNumThreads, ()); - LLDB_REGISTER_METHOD_CONST(lldb::SBThread, SBProcess, GetSelectedThread, - ()); - LLDB_REGISTER_METHOD(lldb::SBThread, SBProcess, CreateOSPluginThread, - (lldb::tid_t, lldb::addr_t)); - LLDB_REGISTER_METHOD_CONST(lldb::SBTarget, SBProcess, GetTarget, ()); - LLDB_REGISTER_METHOD(size_t, SBProcess, PutSTDIN, (const char *, size_t)); - LLDB_REGISTER_METHOD_CONST(void, SBProcess, ReportEventState, - (const lldb::SBEvent &, FILE *)); - LLDB_REGISTER_METHOD_CONST(void, SBProcess, ReportEventState, - (const lldb::SBEvent &, FileSP)); - LLDB_REGISTER_METHOD_CONST(void, SBProcess, ReportEventState, - (const lldb::SBEvent &, SBFile)); - LLDB_REGISTER_METHOD( - void, SBProcess, AppendEventStateReport, - (const lldb::SBEvent &, lldb::SBCommandReturnObject &)); - LLDB_REGISTER_METHOD(bool, SBProcess, SetSelectedThread, - (const lldb::SBThread &)); - LLDB_REGISTER_METHOD(bool, SBProcess, SetSelectedThreadByID, (lldb::tid_t)); - LLDB_REGISTER_METHOD(bool, SBProcess, SetSelectedThreadByIndexID, - (uint32_t)); - LLDB_REGISTER_METHOD(lldb::SBThread, SBProcess, GetThreadAtIndex, (size_t)); - LLDB_REGISTER_METHOD(uint32_t, SBProcess, GetNumQueues, ()); - LLDB_REGISTER_METHOD(lldb::SBQueue, SBProcess, GetQueueAtIndex, (size_t)); - LLDB_REGISTER_METHOD(uint32_t, SBProcess, GetStopID, (bool)); - LLDB_REGISTER_METHOD(lldb::SBEvent, SBProcess, GetStopEventForStopID, - (uint32_t)); - LLDB_REGISTER_METHOD(lldb::StateType, SBProcess, GetState, ()); - LLDB_REGISTER_METHOD(int, SBProcess, GetExitStatus, ()); - LLDB_REGISTER_METHOD(const char *, SBProcess, GetExitDescription, ()); - LLDB_REGISTER_METHOD(lldb::pid_t, SBProcess, GetProcessID, ()); - LLDB_REGISTER_METHOD(uint32_t, SBProcess, GetUniqueID, ()); - LLDB_REGISTER_METHOD_CONST(lldb::ByteOrder, SBProcess, GetByteOrder, ()); - LLDB_REGISTER_METHOD_CONST(uint32_t, SBProcess, GetAddressByteSize, ()); - LLDB_REGISTER_METHOD(lldb::SBError, SBProcess, Continue, ()); - LLDB_REGISTER_METHOD(lldb::SBError, SBProcess, Destroy, ()); - LLDB_REGISTER_METHOD(lldb::SBError, SBProcess, Stop, ()); - LLDB_REGISTER_METHOD(lldb::SBError, SBProcess, Kill, ()); - LLDB_REGISTER_METHOD(lldb::SBError, SBProcess, Detach, ()); - LLDB_REGISTER_METHOD(lldb::SBError, SBProcess, Detach, (bool)); - LLDB_REGISTER_METHOD(lldb::SBError, SBProcess, Signal, (int)); - LLDB_REGISTER_METHOD(lldb::SBUnixSignals, SBProcess, GetUnixSignals, ()); - LLDB_REGISTER_METHOD(void, SBProcess, SendAsyncInterrupt, ()); - LLDB_REGISTER_METHOD(lldb::SBThread, SBProcess, GetThreadByID, - (lldb::tid_t)); - LLDB_REGISTER_METHOD(lldb::SBThread, SBProcess, GetThreadByIndexID, - (uint32_t)); - LLDB_REGISTER_STATIC_METHOD(lldb::StateType, SBProcess, GetStateFromEvent, - (const lldb::SBEvent &)); - LLDB_REGISTER_STATIC_METHOD(bool, SBProcess, GetRestartedFromEvent, - (const lldb::SBEvent &)); - LLDB_REGISTER_STATIC_METHOD(size_t, SBProcess, - GetNumRestartedReasonsFromEvent, - (const lldb::SBEvent &)); - LLDB_REGISTER_STATIC_METHOD(const char *, SBProcess, - GetRestartedReasonAtIndexFromEvent, - (const lldb::SBEvent &, size_t)); - LLDB_REGISTER_STATIC_METHOD(lldb::SBProcess, SBProcess, GetProcessFromEvent, - (const lldb::SBEvent &)); - LLDB_REGISTER_STATIC_METHOD(bool, SBProcess, GetInterruptedFromEvent, - (const lldb::SBEvent &)); - LLDB_REGISTER_STATIC_METHOD(lldb::SBStructuredData, SBProcess, - GetStructuredDataFromEvent, - (const lldb::SBEvent &)); - LLDB_REGISTER_STATIC_METHOD(bool, SBProcess, EventIsProcessEvent, - (const lldb::SBEvent &)); - LLDB_REGISTER_STATIC_METHOD(bool, SBProcess, EventIsStructuredDataEvent, - (const lldb::SBEvent &)); - LLDB_REGISTER_METHOD_CONST(lldb::SBBroadcaster, SBProcess, GetBroadcaster, - ()); - LLDB_REGISTER_STATIC_METHOD(const char *, SBProcess, GetBroadcasterClass, - ()); - LLDB_REGISTER_METHOD(uint64_t, SBProcess, ReadUnsignedFromMemory, - (lldb::addr_t, uint32_t, lldb::SBError &)); - LLDB_REGISTER_METHOD(lldb::addr_t, SBProcess, ReadPointerFromMemory, - (lldb::addr_t, lldb::SBError &)); - LLDB_REGISTER_METHOD(bool, SBProcess, GetDescription, (lldb::SBStream &)); - LLDB_REGISTER_METHOD(lldb::SBStructuredData, SBProcess, - GetExtendedCrashInformation, ()); - LLDB_REGISTER_METHOD_CONST(uint32_t, SBProcess, - GetNumSupportedHardwareWatchpoints, - (lldb::SBError &)); - LLDB_REGISTER_METHOD(uint32_t, SBProcess, LoadImage, - (lldb::SBFileSpec &, lldb::SBError &)); - LLDB_REGISTER_METHOD( - uint32_t, SBProcess, LoadImage, - (const lldb::SBFileSpec &, const lldb::SBFileSpec &, lldb::SBError &)); - LLDB_REGISTER_METHOD(uint32_t, SBProcess, LoadImageUsingPaths, - (const lldb::SBFileSpec &, lldb::SBStringList &, - lldb::SBFileSpec &, lldb::SBError &)); - LLDB_REGISTER_METHOD(lldb::SBError, SBProcess, UnloadImage, (uint32_t)); - LLDB_REGISTER_METHOD(lldb::SBError, SBProcess, SendEventData, - (const char *)); - LLDB_REGISTER_METHOD(uint32_t, SBProcess, GetNumExtendedBacktraceTypes, ()); - LLDB_REGISTER_METHOD(const char *, SBProcess, - GetExtendedBacktraceTypeAtIndex, (uint32_t)); - LLDB_REGISTER_METHOD(lldb::SBThreadCollection, SBProcess, GetHistoryThreads, - (lldb::addr_t)); - LLDB_REGISTER_METHOD(bool, SBProcess, IsInstrumentationRuntimePresent, - (lldb::InstrumentationRuntimeType)); - LLDB_REGISTER_METHOD(lldb::SBError, SBProcess, SaveCore, (const char *)); - LLDB_REGISTER_METHOD(lldb::SBError, SBProcess, GetMemoryRegionInfo, - (lldb::addr_t, lldb::SBMemoryRegionInfo &)); - LLDB_REGISTER_METHOD(lldb::SBMemoryRegionInfoList, SBProcess, - GetMemoryRegions, ()); - LLDB_REGISTER_METHOD(lldb::SBProcessInfo, SBProcess, GetProcessInfo, ()); - LLDB_REGISTER_METHOD(lldb::addr_t, SBProcess, AllocateMemory, - (size_t, uint32_t, lldb::SBError &)); - LLDB_REGISTER_METHOD(lldb::SBError, SBProcess, DeallocateMemory, - (lldb::addr_t)); - - LLDB_REGISTER_CHAR_PTR_METHOD_CONST(size_t, SBProcess, GetSTDOUT); - LLDB_REGISTER_CHAR_PTR_METHOD_CONST(size_t, SBProcess, GetSTDERR); - LLDB_REGISTER_CHAR_PTR_METHOD_CONST(size_t, SBProcess, GetAsyncProfileData); -} - -} -} diff --git a/lldb/source/API/SBProcessInfo.cpp b/lldb/source/API/SBProcessInfo.cpp index cba3bdc179f3..da3db75ff47e 100644 --- a/lldb/source/API/SBProcessInfo.cpp +++ b/lldb/source/API/SBProcessInfo.cpp @@ -7,20 +7,18 @@ //===----------------------------------------------------------------------===// #include "lldb/API/SBProcessInfo.h" -#include "SBReproducerPrivate.h" #include "Utils.h" #include "lldb/API/SBFileSpec.h" +#include "lldb/Utility/Instrumentation.h" #include "lldb/Utility/ProcessInfo.h" using namespace lldb; using namespace lldb_private; -SBProcessInfo::SBProcessInfo() : m_opaque_up() { - LLDB_RECORD_CONSTRUCTOR_NO_ARGS(SBProcessInfo); -} +SBProcessInfo::SBProcessInfo() { LLDB_INSTRUMENT_VA(this); } -SBProcessInfo::SBProcessInfo(const SBProcessInfo &rhs) : m_opaque_up() { - LLDB_RECORD_CONSTRUCTOR(SBProcessInfo, (const lldb::SBProcessInfo &), rhs); +SBProcessInfo::SBProcessInfo(const SBProcessInfo &rhs) { + LLDB_INSTRUMENT_VA(this, rhs); m_opaque_up = clone(rhs.m_opaque_up); } @@ -28,13 +26,11 @@ SBProcessInfo::SBProcessInfo(const SBProcessInfo &rhs) : m_opaque_up() { SBProcessInfo::~SBProcessInfo() = default; SBProcessInfo &SBProcessInfo::operator=(const SBProcessInfo &rhs) { - LLDB_RECORD_METHOD(lldb::SBProcessInfo &, - SBProcessInfo, operator=,(const lldb::SBProcessInfo &), - rhs); + LLDB_INSTRUMENT_VA(this, rhs); if (this != &rhs) m_opaque_up = clone(rhs.m_opaque_up); - return LLDB_RECORD_RESULT(*this); + return *this; } ProcessInstanceInfo &SBProcessInfo::ref() { @@ -49,17 +45,17 @@ void SBProcessInfo::SetProcessInfo(const ProcessInstanceInfo &proc_info_ref) { } bool SBProcessInfo::IsValid() const { - LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBProcessInfo, IsValid); + LLDB_INSTRUMENT_VA(this); return this->operator bool(); } SBProcessInfo::operator bool() const { - LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBProcessInfo, operator bool); + LLDB_INSTRUMENT_VA(this); return m_opaque_up != nullptr; } const char *SBProcessInfo::GetName() { - LLDB_RECORD_METHOD_NO_ARGS(const char *, SBProcessInfo, GetName); + LLDB_INSTRUMENT_VA(this); const char *name = nullptr; if (m_opaque_up) { @@ -69,18 +65,17 @@ const char *SBProcessInfo::GetName() { } SBFileSpec SBProcessInfo::GetExecutableFile() { - LLDB_RECORD_METHOD_NO_ARGS(lldb::SBFileSpec, SBProcessInfo, - GetExecutableFile); + LLDB_INSTRUMENT_VA(this); SBFileSpec file_spec; if (m_opaque_up) { file_spec.SetFileSpec(m_opaque_up->GetExecutableFile()); } - return LLDB_RECORD_RESULT(file_spec); + return file_spec; } lldb::pid_t SBProcessInfo::GetProcessID() { - LLDB_RECORD_METHOD_NO_ARGS(lldb::pid_t, SBProcessInfo, GetProcessID); + LLDB_INSTRUMENT_VA(this); lldb::pid_t proc_id = LLDB_INVALID_PROCESS_ID; if (m_opaque_up) { @@ -90,7 +85,7 @@ lldb::pid_t SBProcessInfo::GetProcessID() { } uint32_t SBProcessInfo::GetUserID() { - LLDB_RECORD_METHOD_NO_ARGS(uint32_t, SBProcessInfo, GetUserID); + LLDB_INSTRUMENT_VA(this); uint32_t user_id = UINT32_MAX; if (m_opaque_up) { @@ -100,7 +95,7 @@ uint32_t SBProcessInfo::GetUserID() { } uint32_t SBProcessInfo::GetGroupID() { - LLDB_RECORD_METHOD_NO_ARGS(uint32_t, SBProcessInfo, GetGroupID); + LLDB_INSTRUMENT_VA(this); uint32_t group_id = UINT32_MAX; if (m_opaque_up) { @@ -110,7 +105,7 @@ uint32_t SBProcessInfo::GetGroupID() { } bool SBProcessInfo::UserIDIsValid() { - LLDB_RECORD_METHOD_NO_ARGS(bool, SBProcessInfo, UserIDIsValid); + LLDB_INSTRUMENT_VA(this); bool is_valid = false; if (m_opaque_up) { @@ -120,7 +115,7 @@ bool SBProcessInfo::UserIDIsValid() { } bool SBProcessInfo::GroupIDIsValid() { - LLDB_RECORD_METHOD_NO_ARGS(bool, SBProcessInfo, GroupIDIsValid); + LLDB_INSTRUMENT_VA(this); bool is_valid = false; if (m_opaque_up) { @@ -130,7 +125,7 @@ bool SBProcessInfo::GroupIDIsValid() { } uint32_t SBProcessInfo::GetEffectiveUserID() { - LLDB_RECORD_METHOD_NO_ARGS(uint32_t, SBProcessInfo, GetEffectiveUserID); + LLDB_INSTRUMENT_VA(this); uint32_t user_id = UINT32_MAX; if (m_opaque_up) { @@ -140,7 +135,7 @@ uint32_t SBProcessInfo::GetEffectiveUserID() { } uint32_t SBProcessInfo::GetEffectiveGroupID() { - LLDB_RECORD_METHOD_NO_ARGS(uint32_t, SBProcessInfo, GetEffectiveGroupID); + LLDB_INSTRUMENT_VA(this); uint32_t group_id = UINT32_MAX; if (m_opaque_up) { @@ -150,7 +145,7 @@ uint32_t SBProcessInfo::GetEffectiveGroupID() { } bool SBProcessInfo::EffectiveUserIDIsValid() { - LLDB_RECORD_METHOD_NO_ARGS(bool, SBProcessInfo, EffectiveUserIDIsValid); + LLDB_INSTRUMENT_VA(this); bool is_valid = false; if (m_opaque_up) { @@ -160,7 +155,7 @@ bool SBProcessInfo::EffectiveUserIDIsValid() { } bool SBProcessInfo::EffectiveGroupIDIsValid() { - LLDB_RECORD_METHOD_NO_ARGS(bool, SBProcessInfo, EffectiveGroupIDIsValid); + LLDB_INSTRUMENT_VA(this); bool is_valid = false; if (m_opaque_up) { @@ -170,7 +165,7 @@ bool SBProcessInfo::EffectiveGroupIDIsValid() { } lldb::pid_t SBProcessInfo::GetParentProcessID() { - LLDB_RECORD_METHOD_NO_ARGS(lldb::pid_t, SBProcessInfo, GetParentProcessID); + LLDB_INSTRUMENT_VA(this); lldb::pid_t proc_id = LLDB_INVALID_PROCESS_ID; if (m_opaque_up) { @@ -180,7 +175,7 @@ lldb::pid_t SBProcessInfo::GetParentProcessID() { } const char *SBProcessInfo::GetTriple() { - LLDB_RECORD_METHOD_NO_ARGS(const char *, SBProcessInfo, GetTriple); + LLDB_INSTRUMENT_VA(this); const char *triple = nullptr; if (m_opaque_up) { @@ -193,34 +188,3 @@ const char *SBProcessInfo::GetTriple() { } return triple; } - -namespace lldb_private { -namespace repro { - -template <> -void RegisterMethods<SBProcessInfo>(Registry &R) { - LLDB_REGISTER_CONSTRUCTOR(SBProcessInfo, ()); - LLDB_REGISTER_CONSTRUCTOR(SBProcessInfo, (const lldb::SBProcessInfo &)); - LLDB_REGISTER_METHOD( - lldb::SBProcessInfo &, - SBProcessInfo, operator=,(const lldb::SBProcessInfo &)); - LLDB_REGISTER_METHOD_CONST(bool, SBProcessInfo, IsValid, ()); - LLDB_REGISTER_METHOD_CONST(bool, SBProcessInfo, operator bool, ()); - LLDB_REGISTER_METHOD(const char *, SBProcessInfo, GetName, ()); - LLDB_REGISTER_METHOD(lldb::SBFileSpec, SBProcessInfo, GetExecutableFile, - ()); - LLDB_REGISTER_METHOD(lldb::pid_t, SBProcessInfo, GetProcessID, ()); - LLDB_REGISTER_METHOD(uint32_t, SBProcessInfo, GetUserID, ()); - LLDB_REGISTER_METHOD(uint32_t, SBProcessInfo, GetGroupID, ()); - LLDB_REGISTER_METHOD(bool, SBProcessInfo, UserIDIsValid, ()); - LLDB_REGISTER_METHOD(bool, SBProcessInfo, GroupIDIsValid, ()); - LLDB_REGISTER_METHOD(uint32_t, SBProcessInfo, GetEffectiveUserID, ()); - LLDB_REGISTER_METHOD(uint32_t, SBProcessInfo, GetEffectiveGroupID, ()); - LLDB_REGISTER_METHOD(bool, SBProcessInfo, EffectiveUserIDIsValid, ()); - LLDB_REGISTER_METHOD(bool, SBProcessInfo, EffectiveGroupIDIsValid, ()); - LLDB_REGISTER_METHOD(lldb::pid_t, SBProcessInfo, GetParentProcessID, ()); - LLDB_REGISTER_METHOD(const char *, SBProcessInfo, GetTriple, ()); -} - -} -} diff --git a/lldb/source/API/SBQueue.cpp b/lldb/source/API/SBQueue.cpp index 746df9e79d61..b2c143f6357e 100644 --- a/lldb/source/API/SBQueue.cpp +++ b/lldb/source/API/SBQueue.cpp @@ -8,8 +8,8 @@ #include <cinttypes> -#include "SBReproducerPrivate.h" #include "lldb/API/SBQueue.h" +#include "lldb/Utility/Instrumentation.h" #include "lldb/API/SBProcess.h" #include "lldb/API/SBQueueItem.h" @@ -27,11 +27,10 @@ namespace lldb_private { class QueueImpl { public: - QueueImpl() : m_queue_wp(), m_threads(), m_pending_items() {} + QueueImpl() {} QueueImpl(const lldb::QueueSP &queue_sp) - : m_queue_wp(), m_threads(), m_thread_list_fetched(false), - m_pending_items(), m_pending_items_fetched(false) { + : m_thread_list_fetched(false), m_pending_items_fetched(false) { m_queue_wp = queue_sp; } @@ -216,17 +215,15 @@ private: }; } -SBQueue::SBQueue() : m_opaque_sp(new QueueImpl()) { - LLDB_RECORD_CONSTRUCTOR_NO_ARGS(SBQueue); -} +SBQueue::SBQueue() : m_opaque_sp(new QueueImpl()) { LLDB_INSTRUMENT_VA(this); } SBQueue::SBQueue(const QueueSP &queue_sp) : m_opaque_sp(new QueueImpl(queue_sp)) { - LLDB_RECORD_CONSTRUCTOR(SBQueue, (const lldb::QueueSP &), queue_sp); + LLDB_INSTRUMENT_VA(this, queue_sp); } SBQueue::SBQueue(const SBQueue &rhs) { - LLDB_RECORD_CONSTRUCTOR(SBQueue, (const lldb::SBQueue &), rhs); + LLDB_INSTRUMENT_VA(this, rhs); if (&rhs == this) return; @@ -235,27 +232,26 @@ SBQueue::SBQueue(const SBQueue &rhs) { } const lldb::SBQueue &SBQueue::operator=(const lldb::SBQueue &rhs) { - LLDB_RECORD_METHOD(const lldb::SBQueue &, - SBQueue, operator=,(const lldb::SBQueue &), rhs); + LLDB_INSTRUMENT_VA(this, rhs); m_opaque_sp = rhs.m_opaque_sp; - return LLDB_RECORD_RESULT(*this); + return *this; } SBQueue::~SBQueue() = default; bool SBQueue::IsValid() const { - LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBQueue, IsValid); + LLDB_INSTRUMENT_VA(this); return this->operator bool(); } SBQueue::operator bool() const { - LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBQueue, operator bool); + LLDB_INSTRUMENT_VA(this); return m_opaque_sp->IsValid(); } void SBQueue::Clear() { - LLDB_RECORD_METHOD_NO_ARGS(void, SBQueue, Clear); + LLDB_INSTRUMENT_VA(this); m_opaque_sp->Clear(); } @@ -265,94 +261,63 @@ void SBQueue::SetQueue(const QueueSP &queue_sp) { } lldb::queue_id_t SBQueue::GetQueueID() const { - LLDB_RECORD_METHOD_CONST_NO_ARGS(lldb::queue_id_t, SBQueue, GetQueueID); + LLDB_INSTRUMENT_VA(this); return m_opaque_sp->GetQueueID(); } uint32_t SBQueue::GetIndexID() const { - LLDB_RECORD_METHOD_CONST_NO_ARGS(uint32_t, SBQueue, GetIndexID); + LLDB_INSTRUMENT_VA(this); uint32_t index_id = m_opaque_sp->GetIndexID(); return index_id; } const char *SBQueue::GetName() const { - LLDB_RECORD_METHOD_CONST_NO_ARGS(const char *, SBQueue, GetName); + LLDB_INSTRUMENT_VA(this); return m_opaque_sp->GetName(); } uint32_t SBQueue::GetNumThreads() { - LLDB_RECORD_METHOD_NO_ARGS(uint32_t, SBQueue, GetNumThreads); + LLDB_INSTRUMENT_VA(this); return m_opaque_sp->GetNumThreads(); } SBThread SBQueue::GetThreadAtIndex(uint32_t idx) { - LLDB_RECORD_METHOD(lldb::SBThread, SBQueue, GetThreadAtIndex, (uint32_t), - idx); + LLDB_INSTRUMENT_VA(this, idx); SBThread th = m_opaque_sp->GetThreadAtIndex(idx); - return LLDB_RECORD_RESULT(th); + return th; } uint32_t SBQueue::GetNumPendingItems() { - LLDB_RECORD_METHOD_NO_ARGS(uint32_t, SBQueue, GetNumPendingItems); + LLDB_INSTRUMENT_VA(this); return m_opaque_sp->GetNumPendingItems(); } SBQueueItem SBQueue::GetPendingItemAtIndex(uint32_t idx) { - LLDB_RECORD_METHOD(lldb::SBQueueItem, SBQueue, GetPendingItemAtIndex, - (uint32_t), idx); + LLDB_INSTRUMENT_VA(this, idx); - return LLDB_RECORD_RESULT(m_opaque_sp->GetPendingItemAtIndex(idx)); + return m_opaque_sp->GetPendingItemAtIndex(idx); } uint32_t SBQueue::GetNumRunningItems() { - LLDB_RECORD_METHOD_NO_ARGS(uint32_t, SBQueue, GetNumRunningItems); + LLDB_INSTRUMENT_VA(this); return m_opaque_sp->GetNumRunningItems(); } SBProcess SBQueue::GetProcess() { - LLDB_RECORD_METHOD_NO_ARGS(lldb::SBProcess, SBQueue, GetProcess); + LLDB_INSTRUMENT_VA(this); - return LLDB_RECORD_RESULT(m_opaque_sp->GetProcess()); + return m_opaque_sp->GetProcess(); } lldb::QueueKind SBQueue::GetKind() { - LLDB_RECORD_METHOD_NO_ARGS(lldb::QueueKind, SBQueue, GetKind); + LLDB_INSTRUMENT_VA(this); return m_opaque_sp->GetKind(); } - -namespace lldb_private { -namespace repro { - -template <> -void RegisterMethods<SBQueue>(Registry &R) { - LLDB_REGISTER_CONSTRUCTOR(SBQueue, ()); - LLDB_REGISTER_CONSTRUCTOR(SBQueue, (const lldb::QueueSP &)); - LLDB_REGISTER_CONSTRUCTOR(SBQueue, (const lldb::SBQueue &)); - LLDB_REGISTER_METHOD(const lldb::SBQueue &, - SBQueue, operator=,(const lldb::SBQueue &)); - LLDB_REGISTER_METHOD_CONST(bool, SBQueue, IsValid, ()); - LLDB_REGISTER_METHOD_CONST(bool, SBQueue, operator bool, ()); - LLDB_REGISTER_METHOD(void, SBQueue, Clear, ()); - LLDB_REGISTER_METHOD_CONST(lldb::queue_id_t, SBQueue, GetQueueID, ()); - LLDB_REGISTER_METHOD_CONST(uint32_t, SBQueue, GetIndexID, ()); - LLDB_REGISTER_METHOD_CONST(const char *, SBQueue, GetName, ()); - LLDB_REGISTER_METHOD(uint32_t, SBQueue, GetNumThreads, ()); - LLDB_REGISTER_METHOD(lldb::SBThread, SBQueue, GetThreadAtIndex, (uint32_t)); - LLDB_REGISTER_METHOD(uint32_t, SBQueue, GetNumPendingItems, ()); - LLDB_REGISTER_METHOD(lldb::SBQueueItem, SBQueue, GetPendingItemAtIndex, - (uint32_t)); - LLDB_REGISTER_METHOD(uint32_t, SBQueue, GetNumRunningItems, ()); - LLDB_REGISTER_METHOD(lldb::SBProcess, SBQueue, GetProcess, ()); - LLDB_REGISTER_METHOD(lldb::QueueKind, SBQueue, GetKind, ()); -} - -} -} diff --git a/lldb/source/API/SBQueueItem.cpp b/lldb/source/API/SBQueueItem.cpp index 6cd9e4514caf..b2204452c0fa 100644 --- a/lldb/source/API/SBQueueItem.cpp +++ b/lldb/source/API/SBQueueItem.cpp @@ -8,7 +8,6 @@ #include "lldb/lldb-forward.h" -#include "SBReproducerPrivate.h" #include "lldb/API/SBAddress.h" #include "lldb/API/SBQueueItem.h" #include "lldb/API/SBThread.h" @@ -16,49 +15,46 @@ #include "lldb/Target/Process.h" #include "lldb/Target/QueueItem.h" #include "lldb/Target/Thread.h" +#include "lldb/Utility/Instrumentation.h" using namespace lldb; using namespace lldb_private; // Constructors -SBQueueItem::SBQueueItem() : m_queue_item_sp() { - LLDB_RECORD_CONSTRUCTOR_NO_ARGS(SBQueueItem); -} +SBQueueItem::SBQueueItem() { LLDB_INSTRUMENT_VA(this); } SBQueueItem::SBQueueItem(const QueueItemSP &queue_item_sp) : m_queue_item_sp(queue_item_sp) { - LLDB_RECORD_CONSTRUCTOR(SBQueueItem, (const lldb::QueueItemSP &), - queue_item_sp); + LLDB_INSTRUMENT_VA(this, queue_item_sp); } // Destructor SBQueueItem::~SBQueueItem() { m_queue_item_sp.reset(); } bool SBQueueItem::IsValid() const { - LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBQueueItem, IsValid); + LLDB_INSTRUMENT_VA(this); return this->operator bool(); } SBQueueItem::operator bool() const { - LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBQueueItem, operator bool); + LLDB_INSTRUMENT_VA(this); return m_queue_item_sp.get() != nullptr; } void SBQueueItem::Clear() { - LLDB_RECORD_METHOD_NO_ARGS(void, SBQueueItem, Clear); + LLDB_INSTRUMENT_VA(this); m_queue_item_sp.reset(); } void SBQueueItem::SetQueueItem(const QueueItemSP &queue_item_sp) { - LLDB_RECORD_METHOD(void, SBQueueItem, SetQueueItem, - (const lldb::QueueItemSP &), queue_item_sp); + LLDB_INSTRUMENT_VA(this, queue_item_sp); m_queue_item_sp = queue_item_sp; } lldb::QueueItemKind SBQueueItem::GetKind() const { - LLDB_RECORD_METHOD_CONST_NO_ARGS(lldb::QueueItemKind, SBQueueItem, GetKind); + LLDB_INSTRUMENT_VA(this); QueueItemKind result = eQueueItemKindUnknown; if (m_queue_item_sp) { @@ -68,7 +64,7 @@ lldb::QueueItemKind SBQueueItem::GetKind() const { } void SBQueueItem::SetKind(lldb::QueueItemKind kind) { - LLDB_RECORD_METHOD(void, SBQueueItem, SetKind, (lldb::QueueItemKind), kind); + LLDB_INSTRUMENT_VA(this, kind); if (m_queue_item_sp) { m_queue_item_sp->SetKind(kind); @@ -76,17 +72,17 @@ void SBQueueItem::SetKind(lldb::QueueItemKind kind) { } SBAddress SBQueueItem::GetAddress() const { - LLDB_RECORD_METHOD_CONST_NO_ARGS(lldb::SBAddress, SBQueueItem, GetAddress); + LLDB_INSTRUMENT_VA(this); SBAddress result; if (m_queue_item_sp) { result.SetAddress(m_queue_item_sp->GetAddress()); } - return LLDB_RECORD_RESULT(result); + return result; } void SBQueueItem::SetAddress(SBAddress addr) { - LLDB_RECORD_METHOD(void, SBQueueItem, SetAddress, (lldb::SBAddress), addr); + LLDB_INSTRUMENT_VA(this, addr); if (m_queue_item_sp) { m_queue_item_sp->SetAddress(addr.ref()); @@ -94,8 +90,7 @@ void SBQueueItem::SetAddress(SBAddress addr) { } SBThread SBQueueItem::GetExtendedBacktraceThread(const char *type) { - LLDB_RECORD_METHOD(lldb::SBThread, SBQueueItem, GetExtendedBacktraceThread, - (const char *), type); + LLDB_INSTRUMENT_VA(this, type); SBThread result; if (m_queue_item_sp) { @@ -113,28 +108,5 @@ SBThread SBQueueItem::GetExtendedBacktraceThread(const char *type) { } } } - return LLDB_RECORD_RESULT(result); -} - -namespace lldb_private { -namespace repro { - -template <> -void RegisterMethods<SBQueueItem>(Registry &R) { - LLDB_REGISTER_CONSTRUCTOR(SBQueueItem, ()); - LLDB_REGISTER_CONSTRUCTOR(SBQueueItem, (const lldb::QueueItemSP &)); - LLDB_REGISTER_METHOD_CONST(bool, SBQueueItem, IsValid, ()); - LLDB_REGISTER_METHOD_CONST(bool, SBQueueItem, operator bool, ()); - LLDB_REGISTER_METHOD(void, SBQueueItem, Clear, ()); - LLDB_REGISTER_METHOD(void, SBQueueItem, SetQueueItem, - (const lldb::QueueItemSP &)); - LLDB_REGISTER_METHOD_CONST(lldb::QueueItemKind, SBQueueItem, GetKind, ()); - LLDB_REGISTER_METHOD(void, SBQueueItem, SetKind, (lldb::QueueItemKind)); - LLDB_REGISTER_METHOD_CONST(lldb::SBAddress, SBQueueItem, GetAddress, ()); - LLDB_REGISTER_METHOD(void, SBQueueItem, SetAddress, (lldb::SBAddress)); - LLDB_REGISTER_METHOD(lldb::SBThread, SBQueueItem, - GetExtendedBacktraceThread, (const char *)); -} - -} + return result; } diff --git a/lldb/source/API/SBReproducer.cpp b/lldb/source/API/SBReproducer.cpp index c9c9a03c694a..d3d27cc57748 100644 --- a/lldb/source/API/SBReproducer.cpp +++ b/lldb/source/API/SBReproducer.cpp @@ -6,8 +6,7 @@ // //===----------------------------------------------------------------------===// -#include "SBReproducerPrivate.h" - +#include "lldb/API/SBReproducer.h" #include "lldb/API/LLDB.h" #include "lldb/API/SBAddress.h" #include "lldb/API/SBAttachInfo.h" @@ -21,8 +20,10 @@ #include "lldb/API/SBError.h" #include "lldb/API/SBFileSpec.h" #include "lldb/API/SBHostOS.h" -#include "lldb/API/SBReproducer.h" #include "lldb/Host/FileSystem.h" +#include "lldb/Utility/Instrumentation.h" +#include "lldb/Utility/Reproducer.h" +#include "lldb/Utility/ReproducerProvider.h" #include "lldb/Version/Version.h" using namespace lldb; @@ -38,117 +39,44 @@ SBReplayOptions::SBReplayOptions(const SBReplayOptions &rhs) SBReplayOptions::~SBReplayOptions() = default; SBReplayOptions &SBReplayOptions::operator=(const SBReplayOptions &rhs) { + LLDB_INSTRUMENT_VA(this, rhs) if (this == &rhs) return *this; *m_opaque_up = *rhs.m_opaque_up; return *this; } -void SBReplayOptions::SetVerify(bool verify) { m_opaque_up->verify = verify; } +void SBReplayOptions::SetVerify(bool verify) { + LLDB_INSTRUMENT_VA(this, verify) m_opaque_up->verify = verify; +} -bool SBReplayOptions::GetVerify() const { return m_opaque_up->verify; } +bool SBReplayOptions::GetVerify() const { + LLDB_INSTRUMENT_VA(this) return m_opaque_up->verify; +} void SBReplayOptions::SetCheckVersion(bool check) { + LLDB_INSTRUMENT_VA(this, check) m_opaque_up->check_version = check; } bool SBReplayOptions::GetCheckVersion() const { + LLDB_INSTRUMENT_VA(this) return m_opaque_up->check_version; } -SBRegistry::SBRegistry() { - Registry &R = *this; - - RegisterMethods<SBAddress>(R); - RegisterMethods<SBAttachInfo>(R); - RegisterMethods<SBBlock>(R); - RegisterMethods<SBBreakpoint>(R); - RegisterMethods<SBBreakpointList>(R); - RegisterMethods<SBBreakpointLocation>(R); - RegisterMethods<SBBreakpointName>(R); - RegisterMethods<SBBroadcaster>(R); - RegisterMethods<SBCommandInterpreter>(R); - RegisterMethods<SBCommandInterpreterRunOptions>(R); - RegisterMethods<SBCommandReturnObject>(R); - RegisterMethods<SBCommunication>(R); - RegisterMethods<SBCompileUnit>(R); - RegisterMethods<SBData>(R); - RegisterMethods<SBDebugger>(R); - RegisterMethods<SBDeclaration>(R); - RegisterMethods<SBEnvironment>(R); - RegisterMethods<SBError>(R); - RegisterMethods<SBEvent>(R); - RegisterMethods<SBExecutionContext>(R); - RegisterMethods<SBExpressionOptions>(R); - RegisterMethods<SBFile>(R); - RegisterMethods<SBFileSpec>(R); - RegisterMethods<SBFileSpecList>(R); - RegisterMethods<SBFrame>(R); - RegisterMethods<SBFunction>(R); - RegisterMethods<SBHostOS>(R); - RegisterMethods<SBInputReader>(R); - RegisterMethods<SBInstruction>(R); - RegisterMethods<SBInstructionList>(R); - RegisterMethods<SBLanguageRuntime>(R); - RegisterMethods<SBLaunchInfo>(R); - RegisterMethods<SBLineEntry>(R); - RegisterMethods<SBListener>(R); - RegisterMethods<SBMemoryRegionInfo>(R); - RegisterMethods<SBMemoryRegionInfoList>(R); - RegisterMethods<SBModule>(R); - RegisterMethods<SBModuleSpec>(R); - RegisterMethods<SBPlatform>(R); - RegisterMethods<SBPlatformConnectOptions>(R); - RegisterMethods<SBPlatformShellCommand>(R); - RegisterMethods<SBProcess>(R); - RegisterMethods<SBProcessInfo>(R); - RegisterMethods<SBQueue>(R); - RegisterMethods<SBQueueItem>(R); - RegisterMethods<SBSection>(R); - RegisterMethods<SBSourceManager>(R); - RegisterMethods<SBStream>(R); - RegisterMethods<SBStringList>(R); - RegisterMethods<SBStructuredData>(R); - RegisterMethods<SBSymbol>(R); - RegisterMethods<SBSymbolContext>(R); - RegisterMethods<SBSymbolContextList>(R); - RegisterMethods<SBTarget>(R); - RegisterMethods<SBThread>(R); - RegisterMethods<SBThreadCollection>(R); - RegisterMethods<SBThreadPlan>(R); - RegisterMethods<SBTrace>(R); - RegisterMethods<SBType>(R); - RegisterMethods<SBTypeCategory>(R); - RegisterMethods<SBTypeEnumMember>(R); - RegisterMethods<SBTypeFilter>(R); - RegisterMethods<SBTypeFormat>(R); - RegisterMethods<SBTypeNameSpecifier>(R); - RegisterMethods<SBTypeSummary>(R); - RegisterMethods<SBTypeSummaryOptions>(R); - RegisterMethods<SBTypeSynthetic>(R); - RegisterMethods<SBUnixSignals>(R); - RegisterMethods<SBValue>(R); - RegisterMethods<SBValueList>(R); - RegisterMethods<SBVariablesOptions>(R); - RegisterMethods<SBWatchpoint>(R); -} - const char *SBReproducer::Capture() { + LLDB_INSTRUMENT() static std::string error; if (auto e = Reproducer::Initialize(ReproducerMode::Capture, llvm::None)) { error = llvm::toString(std::move(e)); return error.c_str(); } - if (auto *g = lldb_private::repro::Reproducer::Instance().GetGenerator()) { - auto &p = g->GetOrCreate<SBProvider>(); - InstrumentationData::Initialize(p.GetSerializer(), p.GetRegistry()); - } - return nullptr; } const char *SBReproducer::Capture(const char *path) { + LLDB_INSTRUMENT_VA(path) static std::string error; if (auto e = Reproducer::Initialize(ReproducerMode::Capture, FileSpec(path))) { @@ -156,32 +84,32 @@ const char *SBReproducer::Capture(const char *path) { return error.c_str(); } - if (auto *g = lldb_private::repro::Reproducer::Instance().GetGenerator()) { - auto &p = g->GetOrCreate<SBProvider>(); - InstrumentationData::Initialize(p.GetSerializer(), p.GetRegistry()); - } - return nullptr; } const char *SBReproducer::PassiveReplay(const char *path) { + LLDB_INSTRUMENT_VA(path) return "Reproducer replay has been removed"; } const char *SBReproducer::Replay(const char *path) { + LLDB_INSTRUMENT_VA(path) return "Reproducer replay has been removed"; } const char *SBReproducer::Replay(const char *path, bool skip_version_check) { + LLDB_INSTRUMENT_VA(path, skip_version_check) return Replay(path); } const char *SBReproducer::Replay(const char *path, const SBReplayOptions &options) { + LLDB_INSTRUMENT_VA(path, options) return Replay(path); } const char *SBReproducer::Finalize(const char *path) { + LLDB_INSTRUMENT_VA(path) static std::string error; repro::Loader *loader = repro::Reproducer::Instance().GetLoader(); @@ -199,6 +127,7 @@ const char *SBReproducer::Finalize(const char *path) { } bool SBReproducer::Generate() { + LLDB_INSTRUMENT() auto &r = Reproducer::Instance(); if (auto generator = r.GetGenerator()) { generator->Keep(); @@ -208,6 +137,7 @@ bool SBReproducer::Generate() { } bool SBReproducer::SetAutoGenerate(bool b) { + LLDB_INSTRUMENT_VA(b) auto &r = Reproducer::Instance(); if (auto generator = r.GetGenerator()) { generator->SetAutoGenerate(b); @@ -217,6 +147,7 @@ bool SBReproducer::SetAutoGenerate(bool b) { } const char *SBReproducer::GetPath() { + LLDB_INSTRUMENT() ConstString path; auto &r = Reproducer::Instance(); if (FileSpec reproducer_path = Reproducer::Instance().GetReproducerPath()) @@ -225,6 +156,7 @@ const char *SBReproducer::GetPath() { } void SBReproducer::SetWorkingDirectory(const char *path) { + LLDB_INSTRUMENT_VA(path) if (auto *g = lldb_private::repro::Reproducer::Instance().GetGenerator()) { auto &wp = g->GetOrCreate<repro::WorkingDirectoryProvider>(); wp.SetDirectory(path); @@ -232,7 +164,3 @@ void SBReproducer::SetWorkingDirectory(const char *path) { fp.RecordInterestingDirectory(wp.GetDirectory()); } } - -char lldb_private::repro::SBProvider::ID = 0; -const char *SBProvider::Info::name = "sbapi"; -const char *SBProvider::Info::file = "sbapi.bin"; diff --git a/lldb/source/API/SBReproducerPrivate.h b/lldb/source/API/SBReproducerPrivate.h deleted file mode 100644 index 02ac31c2ad89..000000000000 --- a/lldb/source/API/SBReproducerPrivate.h +++ /dev/null @@ -1,78 +0,0 @@ -//===-- SBReproducerPrivate.h -----------------------------------*- C++ -*-===// -// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef LLDB_SOURCE_API_SBREPRODUCERPRIVATE_H -#define LLDB_SOURCE_API_SBREPRODUCERPRIVATE_H - -#include "lldb/API/SBReproducer.h" - -#include "lldb/Utility/FileSpec.h" -#include "lldb/Utility/Log.h" -#include "lldb/Utility/Reproducer.h" -#include "lldb/Utility/ReproducerInstrumentation.h" -#include "lldb/Utility/ReproducerProvider.h" - -#include "llvm/ADT/DenseMap.h" - -#define LLDB_GET_INSTRUMENTATION_DATA() \ - lldb_private::repro::InstrumentationData::Instance() - -namespace lldb_private { -namespace repro { - -class SBRegistry : public Registry { -public: - SBRegistry(); -}; - -class SBProvider : public Provider<SBProvider> { -public: - struct Info { - static const char *name; - static const char *file; - }; - - SBProvider(const FileSpec &directory) - : Provider(directory), - m_stream(directory.CopyByAppendingPathComponent("sbapi.bin").GetPath(), - m_ec, llvm::sys::fs::OpenFlags::OF_None), - m_serializer(m_stream) {} - - Serializer &GetSerializer() { return m_serializer; } - Registry &GetRegistry() { return m_registry; } - - static char ID; - -private: - std::error_code m_ec; - llvm::raw_fd_ostream m_stream; - Serializer m_serializer; - SBRegistry m_registry; -}; - -class ReplayData { -public: - ReplayData(std::unique_ptr<llvm::MemoryBuffer> memory_buffer) - : m_memory_buffer(std::move(memory_buffer)), m_registry(), - m_deserializer(m_memory_buffer->getBuffer()) {} - Deserializer &GetDeserializer() { return m_deserializer; } - Registry &GetRegistry() { return m_registry; } - -private: - std::unique_ptr<llvm::MemoryBuffer> m_memory_buffer; - SBRegistry m_registry; - Deserializer m_deserializer; -}; - -template <typename T> void RegisterMethods(Registry &R); - -} // namespace repro -} // namespace lldb_private - -#endif diff --git a/lldb/source/API/SBSection.cpp b/lldb/source/API/SBSection.cpp index bb56fa18d9ca..733e0db0b5ba 100644 --- a/lldb/source/API/SBSection.cpp +++ b/lldb/source/API/SBSection.cpp @@ -7,7 +7,6 @@ //===----------------------------------------------------------------------===// #include "lldb/API/SBSection.h" -#include "SBReproducerPrivate.h" #include "lldb/API/SBStream.h" #include "lldb/API/SBTarget.h" #include "lldb/Core/Module.h" @@ -15,50 +14,47 @@ #include "lldb/Symbol/ObjectFile.h" #include "lldb/Utility/DataBuffer.h" #include "lldb/Utility/DataExtractor.h" +#include "lldb/Utility/Instrumentation.h" #include "lldb/Utility/StreamString.h" using namespace lldb; using namespace lldb_private; -SBSection::SBSection() : m_opaque_wp() { - LLDB_RECORD_CONSTRUCTOR_NO_ARGS(SBSection); -} +SBSection::SBSection() { LLDB_INSTRUMENT_VA(this); } SBSection::SBSection(const SBSection &rhs) : m_opaque_wp(rhs.m_opaque_wp) { - LLDB_RECORD_CONSTRUCTOR(SBSection, (const lldb::SBSection &), rhs); + LLDB_INSTRUMENT_VA(this, rhs); } -SBSection::SBSection(const lldb::SectionSP §ion_sp) - : m_opaque_wp() // Don't init with section_sp otherwise this will throw if - // section_sp doesn't contain a valid Section * -{ +SBSection::SBSection(const lldb::SectionSP §ion_sp) { + // Don't init with section_sp otherwise this will throw if + // section_sp doesn't contain a valid Section * if (section_sp) m_opaque_wp = section_sp; } const SBSection &SBSection::operator=(const SBSection &rhs) { - LLDB_RECORD_METHOD(const lldb::SBSection &, - SBSection, operator=,(const lldb::SBSection &), rhs); + LLDB_INSTRUMENT_VA(this, rhs); m_opaque_wp = rhs.m_opaque_wp; - return LLDB_RECORD_RESULT(*this); + return *this; } SBSection::~SBSection() = default; bool SBSection::IsValid() const { - LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBSection, IsValid); + LLDB_INSTRUMENT_VA(this); return this->operator bool(); } SBSection::operator bool() const { - LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBSection, operator bool); + LLDB_INSTRUMENT_VA(this); SectionSP section_sp(GetSP()); return section_sp && section_sp->GetModule().get() != nullptr; } const char *SBSection::GetName() { - LLDB_RECORD_METHOD_NO_ARGS(const char *, SBSection, GetName); + LLDB_INSTRUMENT_VA(this); SectionSP section_sp(GetSP()); if (section_sp) @@ -67,7 +63,7 @@ const char *SBSection::GetName() { } lldb::SBSection SBSection::GetParent() { - LLDB_RECORD_METHOD_NO_ARGS(lldb::SBSection, SBSection, GetParent); + LLDB_INSTRUMENT_VA(this); lldb::SBSection sb_section; SectionSP section_sp(GetSP()); @@ -76,12 +72,11 @@ lldb::SBSection SBSection::GetParent() { if (parent_section_sp) sb_section.SetSP(parent_section_sp); } - return LLDB_RECORD_RESULT(sb_section); + return sb_section; } lldb::SBSection SBSection::FindSubSection(const char *sect_name) { - LLDB_RECORD_METHOD(lldb::SBSection, SBSection, FindSubSection, (const char *), - sect_name); + LLDB_INSTRUMENT_VA(this, sect_name); lldb::SBSection sb_section; if (sect_name) { @@ -92,11 +87,11 @@ lldb::SBSection SBSection::FindSubSection(const char *sect_name) { section_sp->GetChildren().FindSectionByName(const_sect_name)); } } - return LLDB_RECORD_RESULT(sb_section); + return sb_section; } size_t SBSection::GetNumSubSections() { - LLDB_RECORD_METHOD_NO_ARGS(size_t, SBSection, GetNumSubSections); + LLDB_INSTRUMENT_VA(this); SectionSP section_sp(GetSP()); if (section_sp) @@ -105,14 +100,13 @@ size_t SBSection::GetNumSubSections() { } lldb::SBSection SBSection::GetSubSectionAtIndex(size_t idx) { - LLDB_RECORD_METHOD(lldb::SBSection, SBSection, GetSubSectionAtIndex, (size_t), - idx); + LLDB_INSTRUMENT_VA(this, idx); lldb::SBSection sb_section; SectionSP section_sp(GetSP()); if (section_sp) sb_section.SetSP(section_sp->GetChildren().GetSectionAtIndex(idx)); - return LLDB_RECORD_RESULT(sb_section); + return sb_section; } lldb::SectionSP SBSection::GetSP() const { return m_opaque_wp.lock(); } @@ -122,7 +116,7 @@ void SBSection::SetSP(const lldb::SectionSP §ion_sp) { } lldb::addr_t SBSection::GetFileAddress() { - LLDB_RECORD_METHOD_NO_ARGS(lldb::addr_t, SBSection, GetFileAddress); + LLDB_INSTRUMENT_VA(this); lldb::addr_t file_addr = LLDB_INVALID_ADDRESS; SectionSP section_sp(GetSP()); @@ -132,8 +126,7 @@ lldb::addr_t SBSection::GetFileAddress() { } lldb::addr_t SBSection::GetLoadAddress(lldb::SBTarget &sb_target) { - LLDB_RECORD_METHOD(lldb::addr_t, SBSection, GetLoadAddress, - (lldb::SBTarget &), sb_target); + LLDB_INSTRUMENT_VA(this, sb_target); TargetSP target_sp(sb_target.GetSP()); if (target_sp) { @@ -145,7 +138,7 @@ lldb::addr_t SBSection::GetLoadAddress(lldb::SBTarget &sb_target) { } lldb::addr_t SBSection::GetByteSize() { - LLDB_RECORD_METHOD_NO_ARGS(lldb::addr_t, SBSection, GetByteSize); + LLDB_INSTRUMENT_VA(this); SectionSP section_sp(GetSP()); if (section_sp) @@ -154,7 +147,7 @@ lldb::addr_t SBSection::GetByteSize() { } uint64_t SBSection::GetFileOffset() { - LLDB_RECORD_METHOD_NO_ARGS(uint64_t, SBSection, GetFileOffset); + LLDB_INSTRUMENT_VA(this); SectionSP section_sp(GetSP()); if (section_sp) { @@ -169,7 +162,7 @@ uint64_t SBSection::GetFileOffset() { } uint64_t SBSection::GetFileByteSize() { - LLDB_RECORD_METHOD_NO_ARGS(uint64_t, SBSection, GetFileByteSize); + LLDB_INSTRUMENT_VA(this); SectionSP section_sp(GetSP()); if (section_sp) @@ -178,14 +171,13 @@ uint64_t SBSection::GetFileByteSize() { } SBData SBSection::GetSectionData() { - LLDB_RECORD_METHOD_NO_ARGS(lldb::SBData, SBSection, GetSectionData); + LLDB_INSTRUMENT_VA(this); - return LLDB_RECORD_RESULT(GetSectionData(0, UINT64_MAX)); + return GetSectionData(0, UINT64_MAX); } SBData SBSection::GetSectionData(uint64_t offset, uint64_t size) { - LLDB_RECORD_METHOD(lldb::SBData, SBSection, GetSectionData, - (uint64_t, uint64_t), offset, size); + LLDB_INSTRUMENT_VA(this, offset, size); SBData sb_data; SectionSP section_sp(GetSP()); @@ -220,11 +212,11 @@ SBData SBSection::GetSectionData(uint64_t offset, uint64_t size) { } } } - return LLDB_RECORD_RESULT(sb_data); + return sb_data; } SectionType SBSection::GetSectionType() { - LLDB_RECORD_METHOD_NO_ARGS(lldb::SectionType, SBSection, GetSectionType); + LLDB_INSTRUMENT_VA(this); SectionSP section_sp(GetSP()); if (section_sp.get()) @@ -233,7 +225,7 @@ SectionType SBSection::GetSectionType() { } uint32_t SBSection::GetPermissions() const { - LLDB_RECORD_METHOD_CONST_NO_ARGS(uint32_t, SBSection, GetPermissions); + LLDB_INSTRUMENT_VA(this); SectionSP section_sp(GetSP()); if (section_sp) @@ -242,7 +234,7 @@ uint32_t SBSection::GetPermissions() const { } uint32_t SBSection::GetTargetByteSize() { - LLDB_RECORD_METHOD_NO_ARGS(uint32_t, SBSection, GetTargetByteSize); + LLDB_INSTRUMENT_VA(this); SectionSP section_sp(GetSP()); if (section_sp.get()) @@ -251,8 +243,7 @@ uint32_t SBSection::GetTargetByteSize() { } bool SBSection::operator==(const SBSection &rhs) { - LLDB_RECORD_METHOD(bool, SBSection, operator==,(const lldb::SBSection &), - rhs); + LLDB_INSTRUMENT_VA(this, rhs); SectionSP lhs_section_sp(GetSP()); SectionSP rhs_section_sp(rhs.GetSP()); @@ -262,8 +253,7 @@ bool SBSection::operator==(const SBSection &rhs) { } bool SBSection::operator!=(const SBSection &rhs) { - LLDB_RECORD_METHOD(bool, SBSection, operator!=,(const lldb::SBSection &), - rhs); + LLDB_INSTRUMENT_VA(this, rhs); SectionSP lhs_section_sp(GetSP()); SectionSP rhs_section_sp(rhs.GetSP()); @@ -271,8 +261,7 @@ bool SBSection::operator!=(const SBSection &rhs) { } bool SBSection::GetDescription(SBStream &description) { - LLDB_RECORD_METHOD(bool, SBSection, GetDescription, (lldb::SBStream &), - description); + LLDB_INSTRUMENT_VA(this, description); Stream &strm = description.ref(); @@ -288,41 +277,3 @@ bool SBSection::GetDescription(SBStream &description) { return true; } - -namespace lldb_private { -namespace repro { - -template <> -void RegisterMethods<SBSection>(Registry &R) { - LLDB_REGISTER_CONSTRUCTOR(SBSection, ()); - LLDB_REGISTER_CONSTRUCTOR(SBSection, (const lldb::SBSection &)); - LLDB_REGISTER_METHOD(const lldb::SBSection &, - SBSection, operator=,(const lldb::SBSection &)); - LLDB_REGISTER_METHOD_CONST(bool, SBSection, IsValid, ()); - LLDB_REGISTER_METHOD_CONST(bool, SBSection, operator bool, ()); - LLDB_REGISTER_METHOD(const char *, SBSection, GetName, ()); - LLDB_REGISTER_METHOD(lldb::SBSection, SBSection, GetParent, ()); - LLDB_REGISTER_METHOD(lldb::SBSection, SBSection, FindSubSection, - (const char *)); - LLDB_REGISTER_METHOD(size_t, SBSection, GetNumSubSections, ()); - LLDB_REGISTER_METHOD(lldb::SBSection, SBSection, GetSubSectionAtIndex, - (size_t)); - LLDB_REGISTER_METHOD(lldb::addr_t, SBSection, GetFileAddress, ()); - LLDB_REGISTER_METHOD(lldb::addr_t, SBSection, GetLoadAddress, - (lldb::SBTarget &)); - LLDB_REGISTER_METHOD(lldb::addr_t, SBSection, GetByteSize, ()); - LLDB_REGISTER_METHOD(uint64_t, SBSection, GetFileOffset, ()); - LLDB_REGISTER_METHOD(uint64_t, SBSection, GetFileByteSize, ()); - LLDB_REGISTER_METHOD(lldb::SBData, SBSection, GetSectionData, ()); - LLDB_REGISTER_METHOD(lldb::SBData, SBSection, GetSectionData, - (uint64_t, uint64_t)); - LLDB_REGISTER_METHOD(lldb::SectionType, SBSection, GetSectionType, ()); - LLDB_REGISTER_METHOD_CONST(uint32_t, SBSection, GetPermissions, ()); - LLDB_REGISTER_METHOD(uint32_t, SBSection, GetTargetByteSize, ()); - LLDB_REGISTER_METHOD(bool, SBSection, operator==,(const lldb::SBSection &)); - LLDB_REGISTER_METHOD(bool, SBSection, operator!=,(const lldb::SBSection &)); - LLDB_REGISTER_METHOD(bool, SBSection, GetDescription, (lldb::SBStream &)); -} - -} -} diff --git a/lldb/source/API/SBSourceManager.cpp b/lldb/source/API/SBSourceManager.cpp index 43c3443672f7..7729f5d9d69f 100644 --- a/lldb/source/API/SBSourceManager.cpp +++ b/lldb/source/API/SBSourceManager.cpp @@ -7,10 +7,10 @@ //===----------------------------------------------------------------------===// #include "lldb/API/SBSourceManager.h" -#include "SBReproducerPrivate.h" #include "lldb/API/SBDebugger.h" #include "lldb/API/SBStream.h" #include "lldb/API/SBTarget.h" +#include "lldb/Utility/Instrumentation.h" #include "lldb/API/SBFileSpec.h" #include "lldb/Core/Debugger.h" @@ -24,10 +24,9 @@ namespace lldb_private { class SourceManagerImpl { public: SourceManagerImpl(const lldb::DebuggerSP &debugger_sp) - : m_debugger_wp(debugger_sp), m_target_wp() {} + : m_debugger_wp(debugger_sp) {} - SourceManagerImpl(const lldb::TargetSP &target_sp) - : m_debugger_wp(), m_target_wp(target_sp) {} + SourceManagerImpl(const lldb::TargetSP &target_sp) : m_target_wp(target_sp) {} SourceManagerImpl(const SourceManagerImpl &rhs) { if (&rhs == this) @@ -72,21 +71,19 @@ using namespace lldb; using namespace lldb_private; SBSourceManager::SBSourceManager(const SBDebugger &debugger) { - LLDB_RECORD_CONSTRUCTOR(SBSourceManager, (const lldb::SBDebugger &), - debugger); + LLDB_INSTRUMENT_VA(this, debugger); m_opaque_up = std::make_unique<SourceManagerImpl>(debugger.get_sp()); } SBSourceManager::SBSourceManager(const SBTarget &target) { - LLDB_RECORD_CONSTRUCTOR(SBSourceManager, (const lldb::SBTarget &), target); + LLDB_INSTRUMENT_VA(this, target); m_opaque_up = std::make_unique<SourceManagerImpl>(target.GetSP()); } SBSourceManager::SBSourceManager(const SBSourceManager &rhs) { - LLDB_RECORD_CONSTRUCTOR(SBSourceManager, (const lldb::SBSourceManager &), - rhs); + LLDB_INSTRUMENT_VA(this, rhs); if (&rhs == this) return; @@ -96,12 +93,10 @@ SBSourceManager::SBSourceManager(const SBSourceManager &rhs) { const lldb::SBSourceManager &SBSourceManager:: operator=(const lldb::SBSourceManager &rhs) { - LLDB_RECORD_METHOD(const lldb::SBSourceManager &, - SBSourceManager, operator=,(const lldb::SBSourceManager &), - rhs); + LLDB_INSTRUMENT_VA(this, rhs); m_opaque_up = std::make_unique<SourceManagerImpl>(*(rhs.m_opaque_up.get())); - return LLDB_RECORD_RESULT(*this); + return *this; } SBSourceManager::~SBSourceManager() = default; @@ -109,10 +104,7 @@ SBSourceManager::~SBSourceManager() = default; size_t SBSourceManager::DisplaySourceLinesWithLineNumbers( const SBFileSpec &file, uint32_t line, uint32_t context_before, uint32_t context_after, const char *current_line_cstr, SBStream &s) { - LLDB_RECORD_METHOD(size_t, SBSourceManager, DisplaySourceLinesWithLineNumbers, - (const lldb::SBFileSpec &, uint32_t, uint32_t, uint32_t, - const char *, lldb::SBStream &), - file, line, context_before, context_after, + LLDB_INSTRUMENT_VA(this, file, line, context_before, context_after, current_line_cstr, s); const uint32_t column = 0; @@ -125,11 +117,8 @@ size_t SBSourceManager::DisplaySourceLinesWithLineNumbersAndColumn( const SBFileSpec &file, uint32_t line, uint32_t column, uint32_t context_before, uint32_t context_after, const char *current_line_cstr, SBStream &s) { - LLDB_RECORD_METHOD( - size_t, SBSourceManager, DisplaySourceLinesWithLineNumbersAndColumn, - (const lldb::SBFileSpec &, uint32_t, uint32_t, uint32_t, uint32_t, - const char *, lldb::SBStream &), - file, line, column, context_before, context_after, current_line_cstr, s); + LLDB_INSTRUMENT_VA(this, file, line, column, context_before, context_after, + current_line_cstr, s); if (m_opaque_up == nullptr) return 0; @@ -138,27 +127,3 @@ size_t SBSourceManager::DisplaySourceLinesWithLineNumbersAndColumn( file.ref(), line, column, context_before, context_after, current_line_cstr, s.get()); } - -namespace lldb_private { -namespace repro { - -template <> -void RegisterMethods<SBSourceManager>(Registry &R) { - LLDB_REGISTER_CONSTRUCTOR(SBSourceManager, (const lldb::SBDebugger &)); - LLDB_REGISTER_CONSTRUCTOR(SBSourceManager, (const lldb::SBTarget &)); - LLDB_REGISTER_CONSTRUCTOR(SBSourceManager, (const lldb::SBSourceManager &)); - LLDB_REGISTER_METHOD( - const lldb::SBSourceManager &, - SBSourceManager, operator=,(const lldb::SBSourceManager &)); - LLDB_REGISTER_METHOD(size_t, SBSourceManager, - DisplaySourceLinesWithLineNumbers, - (const lldb::SBFileSpec &, uint32_t, uint32_t, - uint32_t, const char *, lldb::SBStream &)); - LLDB_REGISTER_METHOD(size_t, SBSourceManager, - DisplaySourceLinesWithLineNumbersAndColumn, - (const lldb::SBFileSpec &, uint32_t, uint32_t, - uint32_t, uint32_t, const char *, lldb::SBStream &)); -} - -} -} diff --git a/lldb/source/API/SBStream.cpp b/lldb/source/API/SBStream.cpp index 190abd18df33..9ceef3466f93 100644 --- a/lldb/source/API/SBStream.cpp +++ b/lldb/source/API/SBStream.cpp @@ -8,10 +8,10 @@ #include "lldb/API/SBStream.h" -#include "SBReproducerPrivate.h" #include "lldb/API/SBFile.h" #include "lldb/Core/StreamFile.h" #include "lldb/Host/FileSystem.h" +#include "lldb/Utility/Instrumentation.h" #include "lldb/Utility/Status.h" #include "lldb/Utility/Stream.h" #include "lldb/Utility/StreamString.h" @@ -20,7 +20,7 @@ using namespace lldb; using namespace lldb_private; SBStream::SBStream() : m_opaque_up(new StreamString()) { - LLDB_RECORD_CONSTRUCTOR_NO_ARGS(SBStream); + LLDB_INSTRUMENT_VA(this); } SBStream::SBStream(SBStream &&rhs) @@ -29,11 +29,11 @@ SBStream::SBStream(SBStream &&rhs) SBStream::~SBStream() = default; bool SBStream::IsValid() const { - LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBStream, IsValid); + LLDB_INSTRUMENT_VA(this); return this->operator bool(); } SBStream::operator bool() const { - LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBStream, operator bool); + LLDB_INSTRUMENT_VA(this); return (m_opaque_up != nullptr); } @@ -41,7 +41,7 @@ SBStream::operator bool() const { // If this stream is not redirected to a file, it will maintain a local cache // for the stream data which can be accessed using this accessor. const char *SBStream::GetData() { - LLDB_RECORD_METHOD_NO_ARGS(const char *, SBStream, GetData); + LLDB_INSTRUMENT_VA(this); if (m_is_file || m_opaque_up == nullptr) return nullptr; @@ -52,7 +52,7 @@ const char *SBStream::GetData() { // If this stream is not redirected to a file, it will maintain a local cache // for the stream output whose length can be accessed using this accessor. size_t SBStream::GetSize() { - LLDB_RECORD_METHOD_NO_ARGS(size_t, SBStream, GetSize); + LLDB_INSTRUMENT_VA(this); if (m_is_file || m_opaque_up == nullptr) return 0; @@ -61,7 +61,7 @@ size_t SBStream::GetSize() { } void SBStream::Print(const char *str) { - LLDB_RECORD_METHOD(void, SBStream, Print, (const char *), str); + LLDB_INSTRUMENT_VA(this, str); Printf("%s", str); } @@ -76,8 +76,7 @@ void SBStream::Printf(const char *format, ...) { } void SBStream::RedirectToFile(const char *path, bool append) { - LLDB_RECORD_METHOD(void, SBStream, RedirectToFile, (const char *, bool), path, - append); + LLDB_INSTRUMENT_VA(this, path, append); if (path == nullptr) return; @@ -114,19 +113,18 @@ void SBStream::RedirectToFile(const char *path, bool append) { } void SBStream::RedirectToFileHandle(FILE *fh, bool transfer_fh_ownership) { - LLDB_RECORD_METHOD(void, SBStream, RedirectToFileHandle, (FILE *, bool), fh, - transfer_fh_ownership); + LLDB_INSTRUMENT_VA(this, fh, transfer_fh_ownership); FileSP file = std::make_unique<NativeFile>(fh, transfer_fh_ownership); return RedirectToFile(file); } void SBStream::RedirectToFile(SBFile file) { - LLDB_RECORD_METHOD(void, SBStream, RedirectToFile, (SBFile), file) + LLDB_INSTRUMENT_VA(this, file) RedirectToFile(file.GetFile()); } void SBStream::RedirectToFile(FileSP file_sp) { - LLDB_RECORD_METHOD(void, SBStream, RedirectToFile, (FileSP), file_sp); + LLDB_INSTRUMENT_VA(this, file_sp); if (!file_sp || !file_sp->IsValid()) return; @@ -150,8 +148,7 @@ void SBStream::RedirectToFile(FileSP file_sp) { } void SBStream::RedirectToFileDescriptor(int fd, bool transfer_fh_ownership) { - LLDB_RECORD_METHOD(void, SBStream, RedirectToFileDescriptor, (int, bool), fd, - transfer_fh_ownership); + LLDB_INSTRUMENT_VA(this, fd, transfer_fh_ownership); std::string local_data; if (m_opaque_up) { @@ -182,7 +179,7 @@ lldb_private::Stream &SBStream::ref() { } void SBStream::Clear() { - LLDB_RECORD_METHOD_NO_ARGS(void, SBStream, Clear); + LLDB_INSTRUMENT_VA(this); if (m_opaque_up) { // See if we have any locally backed data. If so, copy it so we can then @@ -193,25 +190,3 @@ void SBStream::Clear() { static_cast<StreamString *>(m_opaque_up.get())->Clear(); } } - -namespace lldb_private { -namespace repro { - -template <> -void RegisterMethods<SBStream>(Registry &R) { - LLDB_REGISTER_CONSTRUCTOR(SBStream, ()); - LLDB_REGISTER_METHOD_CONST(bool, SBStream, IsValid, ()); - LLDB_REGISTER_METHOD_CONST(bool, SBStream, operator bool, ()); - LLDB_REGISTER_METHOD(const char *, SBStream, GetData, ()); - LLDB_REGISTER_METHOD(size_t, SBStream, GetSize, ()); - LLDB_REGISTER_METHOD(void, SBStream, RedirectToFile, (const char *, bool)); - LLDB_REGISTER_METHOD(void, SBStream, RedirectToFile, (FileSP)); - LLDB_REGISTER_METHOD(void, SBStream, RedirectToFile, (SBFile)); - LLDB_REGISTER_METHOD(void, SBStream, RedirectToFileHandle, (FILE *, bool)); - LLDB_REGISTER_METHOD(void, SBStream, RedirectToFileDescriptor, (int, bool)); - LLDB_REGISTER_METHOD(void, SBStream, Clear, ()); - LLDB_REGISTER_METHOD(void, SBStream, Print, (const char *)); -} - -} -} diff --git a/lldb/source/API/SBStringList.cpp b/lldb/source/API/SBStringList.cpp index d9b03692ec0e..dfb77b1ab32f 100644 --- a/lldb/source/API/SBStringList.cpp +++ b/lldb/source/API/SBStringList.cpp @@ -7,36 +7,32 @@ //===----------------------------------------------------------------------===// #include "lldb/API/SBStringList.h" -#include "SBReproducerPrivate.h" #include "Utils.h" +#include "lldb/Utility/Instrumentation.h" #include "lldb/Utility/StringList.h" using namespace lldb; using namespace lldb_private; -SBStringList::SBStringList() : m_opaque_up() { - LLDB_RECORD_CONSTRUCTOR_NO_ARGS(SBStringList); -} +SBStringList::SBStringList() { LLDB_INSTRUMENT_VA(this); } -SBStringList::SBStringList(const lldb_private::StringList *lldb_strings_ptr) - : m_opaque_up() { +SBStringList::SBStringList(const lldb_private::StringList *lldb_strings_ptr) { if (lldb_strings_ptr) m_opaque_up = std::make_unique<StringList>(*lldb_strings_ptr); } -SBStringList::SBStringList(const SBStringList &rhs) : m_opaque_up() { - LLDB_RECORD_CONSTRUCTOR(SBStringList, (const lldb::SBStringList &), rhs); +SBStringList::SBStringList(const SBStringList &rhs) { + LLDB_INSTRUMENT_VA(this, rhs); m_opaque_up = clone(rhs.m_opaque_up); } const SBStringList &SBStringList::operator=(const SBStringList &rhs) { - LLDB_RECORD_METHOD(const lldb::SBStringList &, - SBStringList, operator=,(const lldb::SBStringList &), rhs); + LLDB_INSTRUMENT_VA(this, rhs); if (this != &rhs) m_opaque_up = clone(rhs.m_opaque_up); - return LLDB_RECORD_RESULT(*this); + return *this; } SBStringList::~SBStringList() = default; @@ -50,17 +46,17 @@ const lldb_private::StringList &SBStringList::operator*() const { } bool SBStringList::IsValid() const { - LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBStringList, IsValid); + LLDB_INSTRUMENT_VA(this); return this->operator bool(); } SBStringList::operator bool() const { - LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBStringList, operator bool); + LLDB_INSTRUMENT_VA(this); return (m_opaque_up != nullptr); } void SBStringList::AppendString(const char *str) { - LLDB_RECORD_METHOD(void, SBStringList, AppendString, (const char *), str); + LLDB_INSTRUMENT_VA(this, str); if (str != nullptr) { if (IsValid()) @@ -71,8 +67,7 @@ void SBStringList::AppendString(const char *str) { } void SBStringList::AppendList(const char **strv, int strc) { - LLDB_RECORD_METHOD(void, SBStringList, AppendList, (const char **, int), strv, - strc); + LLDB_INSTRUMENT_VA(this, strv, strc); if ((strv != nullptr) && (strc > 0)) { if (IsValid()) @@ -83,8 +78,7 @@ void SBStringList::AppendList(const char **strv, int strc) { } void SBStringList::AppendList(const SBStringList &strings) { - LLDB_RECORD_METHOD(void, SBStringList, AppendList, - (const lldb::SBStringList &), strings); + LLDB_INSTRUMENT_VA(this, strings); if (strings.IsValid()) { if (!IsValid()) @@ -100,7 +94,7 @@ void SBStringList::AppendList(const StringList &strings) { } uint32_t SBStringList::GetSize() const { - LLDB_RECORD_METHOD_CONST_NO_ARGS(uint32_t, SBStringList, GetSize); + LLDB_INSTRUMENT_VA(this); if (IsValid()) { return m_opaque_up->GetSize(); @@ -109,8 +103,7 @@ uint32_t SBStringList::GetSize() const { } const char *SBStringList::GetStringAtIndex(size_t idx) { - LLDB_RECORD_METHOD(const char *, SBStringList, GetStringAtIndex, (size_t), - idx); + LLDB_INSTRUMENT_VA(this, idx); if (IsValid()) { return m_opaque_up->GetStringAtIndex(idx); @@ -119,8 +112,7 @@ const char *SBStringList::GetStringAtIndex(size_t idx) { } const char *SBStringList::GetStringAtIndex(size_t idx) const { - LLDB_RECORD_METHOD_CONST(const char *, SBStringList, GetStringAtIndex, - (size_t), idx); + LLDB_INSTRUMENT_VA(this, idx); if (IsValid()) { return m_opaque_up->GetStringAtIndex(idx); @@ -129,35 +121,9 @@ const char *SBStringList::GetStringAtIndex(size_t idx) const { } void SBStringList::Clear() { - LLDB_RECORD_METHOD_NO_ARGS(void, SBStringList, Clear); + LLDB_INSTRUMENT_VA(this); if (IsValid()) { m_opaque_up->Clear(); } } - -namespace lldb_private { -namespace repro { - -template <> -void RegisterMethods<SBStringList>(Registry &R) { - LLDB_REGISTER_CONSTRUCTOR(SBStringList, ()); - LLDB_REGISTER_CONSTRUCTOR(SBStringList, (const lldb::SBStringList &)); - LLDB_REGISTER_METHOD(const lldb::SBStringList &, - SBStringList, operator=,(const lldb::SBStringList &)); - LLDB_REGISTER_METHOD_CONST(bool, SBStringList, IsValid, ()); - LLDB_REGISTER_METHOD_CONST(bool, SBStringList, operator bool, ()); - LLDB_REGISTER_METHOD(void, SBStringList, AppendString, (const char *)); - LLDB_REGISTER_METHOD(void, SBStringList, AppendList, (const char **, int)); - LLDB_REGISTER_METHOD(void, SBStringList, AppendList, - (const lldb::SBStringList &)); - LLDB_REGISTER_METHOD_CONST(uint32_t, SBStringList, GetSize, ()); - LLDB_REGISTER_METHOD(const char *, SBStringList, GetStringAtIndex, - (size_t)); - LLDB_REGISTER_METHOD_CONST(const char *, SBStringList, GetStringAtIndex, - (size_t)); - LLDB_REGISTER_METHOD(void, SBStringList, Clear, ()); -} - -} -} diff --git a/lldb/source/API/SBStructuredData.cpp b/lldb/source/API/SBStructuredData.cpp index e99c6194c516..498bcdd39e44 100644 --- a/lldb/source/API/SBStructuredData.cpp +++ b/lldb/source/API/SBStructuredData.cpp @@ -7,7 +7,7 @@ //===----------------------------------------------------------------------===// #include "lldb/API/SBStructuredData.h" -#include "SBReproducerPrivate.h" +#include "lldb/Utility/Instrumentation.h" #include "lldb/API/SBStream.h" #include "lldb/API/SBStringList.h" @@ -25,41 +25,36 @@ using namespace lldb_private; #pragma mark SBStructuredData SBStructuredData::SBStructuredData() : m_impl_up(new StructuredDataImpl()) { - LLDB_RECORD_CONSTRUCTOR_NO_ARGS(SBStructuredData); + LLDB_INSTRUMENT_VA(this); } SBStructuredData::SBStructuredData(const lldb::SBStructuredData &rhs) : m_impl_up(new StructuredDataImpl(*rhs.m_impl_up)) { - LLDB_RECORD_CONSTRUCTOR(SBStructuredData, (const lldb::SBStructuredData &), - rhs); + LLDB_INSTRUMENT_VA(this, rhs); } SBStructuredData::SBStructuredData(const lldb::EventSP &event_sp) : m_impl_up(new StructuredDataImpl(event_sp)) { - LLDB_RECORD_CONSTRUCTOR(SBStructuredData, (const lldb::EventSP &), event_sp); + LLDB_INSTRUMENT_VA(this, event_sp); } SBStructuredData::SBStructuredData(const lldb_private::StructuredDataImpl &impl) : m_impl_up(new StructuredDataImpl(impl)) { - LLDB_RECORD_CONSTRUCTOR(SBStructuredData, - (const lldb_private::StructuredDataImpl &), impl); + LLDB_INSTRUMENT_VA(this, impl); } SBStructuredData::~SBStructuredData() = default; SBStructuredData &SBStructuredData:: operator=(const lldb::SBStructuredData &rhs) { - LLDB_RECORD_METHOD( - lldb::SBStructuredData &, - SBStructuredData, operator=,(const lldb::SBStructuredData &), rhs); + LLDB_INSTRUMENT_VA(this, rhs); *m_impl_up = *rhs.m_impl_up; - return LLDB_RECORD_RESULT(*this); + return *this; } lldb::SBError SBStructuredData::SetFromJSON(lldb::SBStream &stream) { - LLDB_RECORD_METHOD(lldb::SBError, SBStructuredData, SetFromJSON, - (lldb::SBStream &), stream); + LLDB_INSTRUMENT_VA(this, stream); lldb::SBError error; std::string json_str(stream.GetData()); @@ -69,69 +64,64 @@ lldb::SBError SBStructuredData::SetFromJSON(lldb::SBStream &stream) { if (!json_obj || json_obj->GetType() != eStructuredDataTypeDictionary) error.SetErrorString("Invalid Syntax"); - return LLDB_RECORD_RESULT(error); + return error; } lldb::SBError SBStructuredData::SetFromJSON(const char *json) { - LLDB_RECORD_METHOD(lldb::SBError, SBStructuredData, SetFromJSON, - (const char *), json); + LLDB_INSTRUMENT_VA(this, json); lldb::SBStream s; s.Print(json); - return LLDB_RECORD_RESULT(SetFromJSON(s)); + return SetFromJSON(s); } bool SBStructuredData::IsValid() const { - LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBStructuredData, IsValid); + LLDB_INSTRUMENT_VA(this); return this->operator bool(); } SBStructuredData::operator bool() const { - LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBStructuredData, operator bool); + LLDB_INSTRUMENT_VA(this); return m_impl_up->IsValid(); } void SBStructuredData::Clear() { - LLDB_RECORD_METHOD_NO_ARGS(void, SBStructuredData, Clear); + LLDB_INSTRUMENT_VA(this); m_impl_up->Clear(); } SBError SBStructuredData::GetAsJSON(lldb::SBStream &stream) const { - LLDB_RECORD_METHOD_CONST(lldb::SBError, SBStructuredData, GetAsJSON, - (lldb::SBStream &), stream); + LLDB_INSTRUMENT_VA(this, stream); SBError error; error.SetError(m_impl_up->GetAsJSON(stream.ref())); - return LLDB_RECORD_RESULT(error); + return error; } lldb::SBError SBStructuredData::GetDescription(lldb::SBStream &stream) const { - LLDB_RECORD_METHOD_CONST(lldb::SBError, SBStructuredData, GetDescription, - (lldb::SBStream &), stream); + LLDB_INSTRUMENT_VA(this, stream); Status error = m_impl_up->GetDescription(stream.ref()); SBError sb_error; sb_error.SetError(error); - return LLDB_RECORD_RESULT(sb_error); + return sb_error; } StructuredDataType SBStructuredData::GetType() const { - LLDB_RECORD_METHOD_CONST_NO_ARGS(lldb::StructuredDataType, SBStructuredData, - GetType); + LLDB_INSTRUMENT_VA(this); return m_impl_up->GetType(); } size_t SBStructuredData::GetSize() const { - LLDB_RECORD_METHOD_CONST_NO_ARGS(size_t, SBStructuredData, GetSize); + LLDB_INSTRUMENT_VA(this); return m_impl_up->GetSize(); } bool SBStructuredData::GetKeys(lldb::SBStringList &keys) const { - LLDB_RECORD_METHOD_CONST(bool, SBStructuredData, GetKeys, - (lldb::SBStringList &), keys); + LLDB_INSTRUMENT_VA(this, keys); if (GetType() != eStructuredDataTypeDictionary) return false; @@ -157,89 +147,41 @@ bool SBStructuredData::GetKeys(lldb::SBStringList &keys) const { } lldb::SBStructuredData SBStructuredData::GetValueForKey(const char *key) const { - LLDB_RECORD_METHOD_CONST(lldb::SBStructuredData, SBStructuredData, - GetValueForKey, (const char *), key); + LLDB_INSTRUMENT_VA(this, key); SBStructuredData result; result.m_impl_up->SetObjectSP(m_impl_up->GetValueForKey(key)); - return LLDB_RECORD_RESULT(result); + return result; } lldb::SBStructuredData SBStructuredData::GetItemAtIndex(size_t idx) const { - LLDB_RECORD_METHOD_CONST(lldb::SBStructuredData, SBStructuredData, - GetItemAtIndex, (size_t), idx); + LLDB_INSTRUMENT_VA(this, idx); SBStructuredData result; result.m_impl_up->SetObjectSP(m_impl_up->GetItemAtIndex(idx)); - return LLDB_RECORD_RESULT(result); + return result; } uint64_t SBStructuredData::GetIntegerValue(uint64_t fail_value) const { - LLDB_RECORD_METHOD_CONST(uint64_t, SBStructuredData, GetIntegerValue, - (uint64_t), fail_value); + LLDB_INSTRUMENT_VA(this, fail_value); return m_impl_up->GetIntegerValue(fail_value); } double SBStructuredData::GetFloatValue(double fail_value) const { - LLDB_RECORD_METHOD_CONST(double, SBStructuredData, GetFloatValue, (double), - fail_value); + LLDB_INSTRUMENT_VA(this, fail_value); return m_impl_up->GetFloatValue(fail_value); } bool SBStructuredData::GetBooleanValue(bool fail_value) const { - LLDB_RECORD_METHOD_CONST(bool, SBStructuredData, GetBooleanValue, (bool), - fail_value); + LLDB_INSTRUMENT_VA(this, fail_value); return m_impl_up->GetBooleanValue(fail_value); } size_t SBStructuredData::GetStringValue(char *dst, size_t dst_len) const { - LLDB_RECORD_CHAR_PTR_METHOD_CONST(size_t, SBStructuredData, GetStringValue, - (char *, size_t), dst, "", dst_len); + LLDB_INSTRUMENT_VA(this, dst, dst_len); return m_impl_up->GetStringValue(dst, dst_len); } - -namespace lldb_private { -namespace repro { - -template <> void RegisterMethods<SBStructuredData>(Registry &R) { - LLDB_REGISTER_CONSTRUCTOR(SBStructuredData, ()); - LLDB_REGISTER_CONSTRUCTOR(SBStructuredData, (const lldb::SBStructuredData &)); - LLDB_REGISTER_CONSTRUCTOR(SBStructuredData, (const lldb::EventSP &)); - LLDB_REGISTER_CONSTRUCTOR(SBStructuredData, - (const lldb_private::StructuredDataImpl &)); - LLDB_REGISTER_METHOD( - lldb::SBStructuredData &, - SBStructuredData, operator=,(const lldb::SBStructuredData &)); - LLDB_REGISTER_METHOD(lldb::SBError, SBStructuredData, SetFromJSON, - (lldb::SBStream &)); - LLDB_REGISTER_METHOD(lldb::SBError, SBStructuredData, SetFromJSON, - (const char *)); - LLDB_REGISTER_METHOD_CONST(bool, SBStructuredData, IsValid, ()); - LLDB_REGISTER_METHOD_CONST(bool, SBStructuredData, operator bool, ()); - LLDB_REGISTER_METHOD(void, SBStructuredData, Clear, ()); - LLDB_REGISTER_METHOD_CONST(lldb::SBError, SBStructuredData, GetAsJSON, - (lldb::SBStream &)); - LLDB_REGISTER_METHOD_CONST(lldb::SBError, SBStructuredData, GetDescription, - (lldb::SBStream &)); - LLDB_REGISTER_METHOD_CONST(lldb::StructuredDataType, SBStructuredData, - GetType, ()); - LLDB_REGISTER_METHOD_CONST(size_t, SBStructuredData, GetSize, ()); - LLDB_REGISTER_METHOD_CONST(bool, SBStructuredData, GetKeys, - (lldb::SBStringList &)); - LLDB_REGISTER_METHOD_CONST(lldb::SBStructuredData, SBStructuredData, - GetValueForKey, (const char *)); - LLDB_REGISTER_METHOD_CONST(lldb::SBStructuredData, SBStructuredData, - GetItemAtIndex, (size_t)); - LLDB_REGISTER_METHOD_CONST(uint64_t, SBStructuredData, GetIntegerValue, - (uint64_t)); - LLDB_REGISTER_METHOD_CONST(double, SBStructuredData, GetFloatValue, (double)); - LLDB_REGISTER_METHOD_CONST(bool, SBStructuredData, GetBooleanValue, (bool)); - LLDB_REGISTER_CHAR_PTR_METHOD_CONST(size_t, SBStructuredData, GetStringValue); -} - -} // namespace repro -} // namespace lldb_private diff --git a/lldb/source/API/SBSymbol.cpp b/lldb/source/API/SBSymbol.cpp index d3abc13675f5..b671f987dc99 100644 --- a/lldb/source/API/SBSymbol.cpp +++ b/lldb/source/API/SBSymbol.cpp @@ -7,32 +7,31 @@ //===----------------------------------------------------------------------===// #include "lldb/API/SBSymbol.h" -#include "SBReproducerPrivate.h" #include "lldb/API/SBStream.h" #include "lldb/Core/Disassembler.h" #include "lldb/Core/Module.h" #include "lldb/Symbol/Symbol.h" #include "lldb/Target/ExecutionContext.h" #include "lldb/Target/Target.h" +#include "lldb/Utility/Instrumentation.h" using namespace lldb; using namespace lldb_private; -SBSymbol::SBSymbol() { LLDB_RECORD_CONSTRUCTOR_NO_ARGS(SBSymbol); } +SBSymbol::SBSymbol() { LLDB_INSTRUMENT_VA(this); } SBSymbol::SBSymbol(lldb_private::Symbol *lldb_object_ptr) : m_opaque_ptr(lldb_object_ptr) {} SBSymbol::SBSymbol(const lldb::SBSymbol &rhs) : m_opaque_ptr(rhs.m_opaque_ptr) { - LLDB_RECORD_CONSTRUCTOR(SBSymbol, (const lldb::SBSymbol &), rhs); + LLDB_INSTRUMENT_VA(this, rhs); } const SBSymbol &SBSymbol::operator=(const SBSymbol &rhs) { - LLDB_RECORD_METHOD(const lldb::SBSymbol &, - SBSymbol, operator=,(const lldb::SBSymbol &), rhs); + LLDB_INSTRUMENT_VA(this, rhs); m_opaque_ptr = rhs.m_opaque_ptr; - return LLDB_RECORD_RESULT(*this); + return *this; } SBSymbol::~SBSymbol() { m_opaque_ptr = nullptr; } @@ -42,17 +41,17 @@ void SBSymbol::SetSymbol(lldb_private::Symbol *lldb_object_ptr) { } bool SBSymbol::IsValid() const { - LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBSymbol, IsValid); + LLDB_INSTRUMENT_VA(this); return this->operator bool(); } SBSymbol::operator bool() const { - LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBSymbol, operator bool); + LLDB_INSTRUMENT_VA(this); return m_opaque_ptr != nullptr; } const char *SBSymbol::GetName() const { - LLDB_RECORD_METHOD_CONST_NO_ARGS(const char *, SBSymbol, GetName); + LLDB_INSTRUMENT_VA(this); const char *name = nullptr; if (m_opaque_ptr) @@ -62,7 +61,7 @@ const char *SBSymbol::GetName() const { } const char *SBSymbol::GetDisplayName() const { - LLDB_RECORD_METHOD_CONST_NO_ARGS(const char *, SBSymbol, GetDisplayName); + LLDB_INSTRUMENT_VA(this); const char *name = nullptr; if (m_opaque_ptr) @@ -72,7 +71,7 @@ const char *SBSymbol::GetDisplayName() const { } const char *SBSymbol::GetMangledName() const { - LLDB_RECORD_METHOD_CONST_NO_ARGS(const char *, SBSymbol, GetMangledName); + LLDB_INSTRUMENT_VA(this); const char *name = nullptr; if (m_opaque_ptr) @@ -81,22 +80,19 @@ const char *SBSymbol::GetMangledName() const { } bool SBSymbol::operator==(const SBSymbol &rhs) const { - LLDB_RECORD_METHOD_CONST(bool, SBSymbol, operator==,(const lldb::SBSymbol &), - rhs); + LLDB_INSTRUMENT_VA(this, rhs); return m_opaque_ptr == rhs.m_opaque_ptr; } bool SBSymbol::operator!=(const SBSymbol &rhs) const { - LLDB_RECORD_METHOD_CONST(bool, SBSymbol, operator!=,(const lldb::SBSymbol &), - rhs); + LLDB_INSTRUMENT_VA(this, rhs); return m_opaque_ptr != rhs.m_opaque_ptr; } bool SBSymbol::GetDescription(SBStream &description) { - LLDB_RECORD_METHOD(bool, SBSymbol, GetDescription, (lldb::SBStream &), - description); + LLDB_INSTRUMENT_VA(this, description); Stream &strm = description.ref(); @@ -109,16 +105,14 @@ bool SBSymbol::GetDescription(SBStream &description) { } SBInstructionList SBSymbol::GetInstructions(SBTarget target) { - LLDB_RECORD_METHOD(lldb::SBInstructionList, SBSymbol, GetInstructions, - (lldb::SBTarget), target); + LLDB_INSTRUMENT_VA(this, target); - return LLDB_RECORD_RESULT(GetInstructions(target, nullptr)); + return GetInstructions(target, nullptr); } SBInstructionList SBSymbol::GetInstructions(SBTarget target, const char *flavor_string) { - LLDB_RECORD_METHOD(lldb::SBInstructionList, SBSymbol, GetInstructions, - (lldb::SBTarget, const char *), target, flavor_string); + LLDB_INSTRUMENT_VA(this, target, flavor_string); SBInstructionList sb_instructions; if (m_opaque_ptr) { @@ -137,7 +131,7 @@ SBInstructionList SBSymbol::GetInstructions(SBTarget target, } } } - return LLDB_RECORD_RESULT(sb_instructions); + return sb_instructions; } lldb_private::Symbol *SBSymbol::get() { return m_opaque_ptr; } @@ -145,17 +139,17 @@ lldb_private::Symbol *SBSymbol::get() { return m_opaque_ptr; } void SBSymbol::reset(lldb_private::Symbol *symbol) { m_opaque_ptr = symbol; } SBAddress SBSymbol::GetStartAddress() { - LLDB_RECORD_METHOD_NO_ARGS(lldb::SBAddress, SBSymbol, GetStartAddress); + LLDB_INSTRUMENT_VA(this); SBAddress addr; if (m_opaque_ptr && m_opaque_ptr->ValueIsAddress()) { addr.SetAddress(m_opaque_ptr->GetAddressRef()); } - return LLDB_RECORD_RESULT(addr); + return addr; } SBAddress SBSymbol::GetEndAddress() { - LLDB_RECORD_METHOD_NO_ARGS(lldb::SBAddress, SBSymbol, GetEndAddress); + LLDB_INSTRUMENT_VA(this); SBAddress addr; if (m_opaque_ptr && m_opaque_ptr->ValueIsAddress()) { @@ -165,11 +159,11 @@ SBAddress SBSymbol::GetEndAddress() { addr->Slide(m_opaque_ptr->GetByteSize()); } } - return LLDB_RECORD_RESULT(addr); + return addr; } uint32_t SBSymbol::GetPrologueByteSize() { - LLDB_RECORD_METHOD_NO_ARGS(uint32_t, SBSymbol, GetPrologueByteSize); + LLDB_INSTRUMENT_VA(this); if (m_opaque_ptr) return m_opaque_ptr->GetPrologueByteSize(); @@ -177,7 +171,7 @@ uint32_t SBSymbol::GetPrologueByteSize() { } SymbolType SBSymbol::GetType() { - LLDB_RECORD_METHOD_NO_ARGS(lldb::SymbolType, SBSymbol, GetType); + LLDB_INSTRUMENT_VA(this); if (m_opaque_ptr) return m_opaque_ptr->GetType(); @@ -185,7 +179,7 @@ SymbolType SBSymbol::GetType() { } bool SBSymbol::IsExternal() { - LLDB_RECORD_METHOD_NO_ARGS(bool, SBSymbol, IsExternal); + LLDB_INSTRUMENT_VA(this); if (m_opaque_ptr) return m_opaque_ptr->IsExternal(); @@ -193,43 +187,9 @@ bool SBSymbol::IsExternal() { } bool SBSymbol::IsSynthetic() { - LLDB_RECORD_METHOD_NO_ARGS(bool, SBSymbol, IsSynthetic); + LLDB_INSTRUMENT_VA(this); if (m_opaque_ptr) return m_opaque_ptr->IsSynthetic(); return false; } - -namespace lldb_private { -namespace repro { - -template <> -void RegisterMethods<SBSymbol>(Registry &R) { - LLDB_REGISTER_CONSTRUCTOR(SBSymbol, ()); - LLDB_REGISTER_CONSTRUCTOR(SBSymbol, (const lldb::SBSymbol &)); - LLDB_REGISTER_METHOD(const lldb::SBSymbol &, - SBSymbol, operator=,(const lldb::SBSymbol &)); - LLDB_REGISTER_METHOD_CONST(bool, SBSymbol, IsValid, ()); - LLDB_REGISTER_METHOD_CONST(bool, SBSymbol, operator bool, ()); - LLDB_REGISTER_METHOD_CONST(const char *, SBSymbol, GetName, ()); - LLDB_REGISTER_METHOD_CONST(const char *, SBSymbol, GetDisplayName, ()); - LLDB_REGISTER_METHOD_CONST(const char *, SBSymbol, GetMangledName, ()); - LLDB_REGISTER_METHOD_CONST(bool, - SBSymbol, operator==,(const lldb::SBSymbol &)); - LLDB_REGISTER_METHOD_CONST(bool, - SBSymbol, operator!=,(const lldb::SBSymbol &)); - LLDB_REGISTER_METHOD(bool, SBSymbol, GetDescription, (lldb::SBStream &)); - LLDB_REGISTER_METHOD(lldb::SBInstructionList, SBSymbol, GetInstructions, - (lldb::SBTarget)); - LLDB_REGISTER_METHOD(lldb::SBInstructionList, SBSymbol, GetInstructions, - (lldb::SBTarget, const char *)); - LLDB_REGISTER_METHOD(lldb::SBAddress, SBSymbol, GetStartAddress, ()); - LLDB_REGISTER_METHOD(lldb::SBAddress, SBSymbol, GetEndAddress, ()); - LLDB_REGISTER_METHOD(uint32_t, SBSymbol, GetPrologueByteSize, ()); - LLDB_REGISTER_METHOD(lldb::SymbolType, SBSymbol, GetType, ()); - LLDB_REGISTER_METHOD(bool, SBSymbol, IsExternal, ()); - LLDB_REGISTER_METHOD(bool, SBSymbol, IsSynthetic, ()); -} - -} -} diff --git a/lldb/source/API/SBSymbolContext.cpp b/lldb/source/API/SBSymbolContext.cpp index 89fe051658ff..484399c89590 100644 --- a/lldb/source/API/SBSymbolContext.cpp +++ b/lldb/source/API/SBSymbolContext.cpp @@ -7,30 +7,26 @@ //===----------------------------------------------------------------------===// #include "lldb/API/SBSymbolContext.h" -#include "SBReproducerPrivate.h" #include "Utils.h" #include "lldb/API/SBStream.h" #include "lldb/Core/Module.h" #include "lldb/Symbol/Function.h" #include "lldb/Symbol/Symbol.h" #include "lldb/Symbol/SymbolContext.h" +#include "lldb/Utility/Instrumentation.h" using namespace lldb; using namespace lldb_private; -SBSymbolContext::SBSymbolContext() : m_opaque_up() { - LLDB_RECORD_CONSTRUCTOR_NO_ARGS(SBSymbolContext); -} +SBSymbolContext::SBSymbolContext() { LLDB_INSTRUMENT_VA(this); } SBSymbolContext::SBSymbolContext(const SymbolContext &sc) : m_opaque_up(std::make_unique<SymbolContext>(sc)) { - LLDB_RECORD_CONSTRUCTOR(SBSymbolContext, - (const lldb_private::SymbolContext &), sc); + LLDB_INSTRUMENT_VA(this, sc); } -SBSymbolContext::SBSymbolContext(const SBSymbolContext &rhs) : m_opaque_up() { - LLDB_RECORD_CONSTRUCTOR(SBSymbolContext, (const lldb::SBSymbolContext &), - rhs); +SBSymbolContext::SBSymbolContext(const SBSymbolContext &rhs) { + LLDB_INSTRUMENT_VA(this, rhs); m_opaque_up = clone(rhs.m_opaque_up); } @@ -38,27 +34,25 @@ SBSymbolContext::SBSymbolContext(const SBSymbolContext &rhs) : m_opaque_up() { SBSymbolContext::~SBSymbolContext() = default; const SBSymbolContext &SBSymbolContext::operator=(const SBSymbolContext &rhs) { - LLDB_RECORD_METHOD(const lldb::SBSymbolContext &, - SBSymbolContext, operator=,(const lldb::SBSymbolContext &), - rhs); + LLDB_INSTRUMENT_VA(this, rhs); if (this != &rhs) m_opaque_up = clone(rhs.m_opaque_up); - return LLDB_RECORD_RESULT(*this); + return *this; } bool SBSymbolContext::IsValid() const { - LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBSymbolContext, IsValid); + LLDB_INSTRUMENT_VA(this); return this->operator bool(); } SBSymbolContext::operator bool() const { - LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBSymbolContext, operator bool); + LLDB_INSTRUMENT_VA(this); return m_opaque_up != nullptr; } SBModule SBSymbolContext::GetModule() { - LLDB_RECORD_METHOD_NO_ARGS(lldb::SBModule, SBSymbolContext, GetModule); + LLDB_INSTRUMENT_VA(this); SBModule sb_module; ModuleSP module_sp; @@ -67,19 +61,17 @@ SBModule SBSymbolContext::GetModule() { sb_module.SetSP(module_sp); } - return LLDB_RECORD_RESULT(sb_module); + return sb_module; } SBCompileUnit SBSymbolContext::GetCompileUnit() { - LLDB_RECORD_METHOD_NO_ARGS(lldb::SBCompileUnit, SBSymbolContext, - GetCompileUnit); + LLDB_INSTRUMENT_VA(this); - return LLDB_RECORD_RESULT( - SBCompileUnit(m_opaque_up ? m_opaque_up->comp_unit : nullptr)); + return SBCompileUnit(m_opaque_up ? m_opaque_up->comp_unit : nullptr); } SBFunction SBSymbolContext::GetFunction() { - LLDB_RECORD_METHOD_NO_ARGS(lldb::SBFunction, SBSymbolContext, GetFunction); + LLDB_INSTRUMENT_VA(this); Function *function = nullptr; @@ -88,28 +80,27 @@ SBFunction SBSymbolContext::GetFunction() { SBFunction sb_function(function); - return LLDB_RECORD_RESULT(sb_function); + return sb_function; } SBBlock SBSymbolContext::GetBlock() { - LLDB_RECORD_METHOD_NO_ARGS(lldb::SBBlock, SBSymbolContext, GetBlock); + LLDB_INSTRUMENT_VA(this); - return LLDB_RECORD_RESULT( - SBBlock(m_opaque_up ? m_opaque_up->block : nullptr)); + return SBBlock(m_opaque_up ? m_opaque_up->block : nullptr); } SBLineEntry SBSymbolContext::GetLineEntry() { - LLDB_RECORD_METHOD_NO_ARGS(lldb::SBLineEntry, SBSymbolContext, GetLineEntry); + LLDB_INSTRUMENT_VA(this); SBLineEntry sb_line_entry; if (m_opaque_up) sb_line_entry.SetLineEntry(m_opaque_up->line_entry); - return LLDB_RECORD_RESULT(sb_line_entry); + return sb_line_entry; } SBSymbol SBSymbolContext::GetSymbol() { - LLDB_RECORD_METHOD_NO_ARGS(lldb::SBSymbol, SBSymbolContext, GetSymbol); + LLDB_INSTRUMENT_VA(this); Symbol *symbol = nullptr; @@ -118,39 +109,35 @@ SBSymbol SBSymbolContext::GetSymbol() { SBSymbol sb_symbol(symbol); - return LLDB_RECORD_RESULT(sb_symbol); + return sb_symbol; } void SBSymbolContext::SetModule(lldb::SBModule module) { - LLDB_RECORD_METHOD(void, SBSymbolContext, SetModule, (lldb::SBModule), - module); + LLDB_INSTRUMENT_VA(this, module); ref().module_sp = module.GetSP(); } void SBSymbolContext::SetCompileUnit(lldb::SBCompileUnit compile_unit) { - LLDB_RECORD_METHOD(void, SBSymbolContext, SetCompileUnit, - (lldb::SBCompileUnit), compile_unit); + LLDB_INSTRUMENT_VA(this, compile_unit); ref().comp_unit = compile_unit.get(); } void SBSymbolContext::SetFunction(lldb::SBFunction function) { - LLDB_RECORD_METHOD(void, SBSymbolContext, SetFunction, (lldb::SBFunction), - function); + LLDB_INSTRUMENT_VA(this, function); ref().function = function.get(); } void SBSymbolContext::SetBlock(lldb::SBBlock block) { - LLDB_RECORD_METHOD(void, SBSymbolContext, SetBlock, (lldb::SBBlock), block); + LLDB_INSTRUMENT_VA(this, block); ref().block = block.GetPtr(); } void SBSymbolContext::SetLineEntry(lldb::SBLineEntry line_entry) { - LLDB_RECORD_METHOD(void, SBSymbolContext, SetLineEntry, (lldb::SBLineEntry), - line_entry); + LLDB_INSTRUMENT_VA(this, line_entry); if (line_entry.IsValid()) ref().line_entry = line_entry.ref(); @@ -159,8 +146,7 @@ void SBSymbolContext::SetLineEntry(lldb::SBLineEntry line_entry) { } void SBSymbolContext::SetSymbol(lldb::SBSymbol symbol) { - LLDB_RECORD_METHOD(void, SBSymbolContext, SetSymbol, (lldb::SBSymbol), - symbol); + LLDB_INSTRUMENT_VA(this, symbol); ref().symbol = symbol.get(); } @@ -191,8 +177,7 @@ lldb_private::SymbolContext *SBSymbolContext::get() const { } bool SBSymbolContext::GetDescription(SBStream &description) { - LLDB_RECORD_METHOD(bool, SBSymbolContext, GetDescription, (lldb::SBStream &), - description); + LLDB_INSTRUMENT_VA(this, description); Stream &strm = description.ref(); @@ -207,56 +192,13 @@ bool SBSymbolContext::GetDescription(SBStream &description) { SBSymbolContext SBSymbolContext::GetParentOfInlinedScope(const SBAddress &curr_frame_pc, SBAddress &parent_frame_addr) const { - LLDB_RECORD_METHOD_CONST(lldb::SBSymbolContext, SBSymbolContext, - GetParentOfInlinedScope, - (const lldb::SBAddress &, lldb::SBAddress &), - curr_frame_pc, parent_frame_addr); + LLDB_INSTRUMENT_VA(this, curr_frame_pc, parent_frame_addr); SBSymbolContext sb_sc; if (m_opaque_up.get() && curr_frame_pc.IsValid()) { if (m_opaque_up->GetParentOfInlinedScope(curr_frame_pc.ref(), sb_sc.ref(), parent_frame_addr.ref())) - return LLDB_RECORD_RESULT(sb_sc); + return sb_sc; } - return LLDB_RECORD_RESULT(SBSymbolContext()); -} - -namespace lldb_private { -namespace repro { - -template <> -void RegisterMethods<SBSymbolContext>(Registry &R) { - LLDB_REGISTER_CONSTRUCTOR(SBSymbolContext, ()); - LLDB_REGISTER_CONSTRUCTOR(SBSymbolContext, - (const lldb_private::SymbolContext &)); - LLDB_REGISTER_CONSTRUCTOR(SBSymbolContext, (const lldb::SBSymbolContext &)); - LLDB_REGISTER_METHOD( - const lldb::SBSymbolContext &, - SBSymbolContext, operator=,(const lldb::SBSymbolContext &)); - LLDB_REGISTER_METHOD_CONST(bool, SBSymbolContext, IsValid, ()); - LLDB_REGISTER_METHOD_CONST(bool, SBSymbolContext, operator bool, ()); - LLDB_REGISTER_METHOD(lldb::SBModule, SBSymbolContext, GetModule, ()); - LLDB_REGISTER_METHOD(lldb::SBCompileUnit, SBSymbolContext, GetCompileUnit, - ()); - LLDB_REGISTER_METHOD(lldb::SBFunction, SBSymbolContext, GetFunction, ()); - LLDB_REGISTER_METHOD(lldb::SBBlock, SBSymbolContext, GetBlock, ()); - LLDB_REGISTER_METHOD(lldb::SBLineEntry, SBSymbolContext, GetLineEntry, ()); - LLDB_REGISTER_METHOD(lldb::SBSymbol, SBSymbolContext, GetSymbol, ()); - LLDB_REGISTER_METHOD(void, SBSymbolContext, SetModule, (lldb::SBModule)); - LLDB_REGISTER_METHOD(void, SBSymbolContext, SetCompileUnit, - (lldb::SBCompileUnit)); - LLDB_REGISTER_METHOD(void, SBSymbolContext, SetFunction, - (lldb::SBFunction)); - LLDB_REGISTER_METHOD(void, SBSymbolContext, SetBlock, (lldb::SBBlock)); - LLDB_REGISTER_METHOD(void, SBSymbolContext, SetLineEntry, - (lldb::SBLineEntry)); - LLDB_REGISTER_METHOD(void, SBSymbolContext, SetSymbol, (lldb::SBSymbol)); - LLDB_REGISTER_METHOD(bool, SBSymbolContext, GetDescription, - (lldb::SBStream &)); - LLDB_REGISTER_METHOD_CONST(lldb::SBSymbolContext, SBSymbolContext, - GetParentOfInlinedScope, - (const lldb::SBAddress &, lldb::SBAddress &)); -} - -} + return SBSymbolContext(); } diff --git a/lldb/source/API/SBSymbolContextList.cpp b/lldb/source/API/SBSymbolContextList.cpp index 70a8bbe6694c..baa558caebbc 100644 --- a/lldb/source/API/SBSymbolContextList.cpp +++ b/lldb/source/API/SBSymbolContextList.cpp @@ -7,23 +7,21 @@ //===----------------------------------------------------------------------===// #include "lldb/API/SBSymbolContextList.h" -#include "SBReproducerPrivate.h" #include "Utils.h" #include "lldb/API/SBStream.h" #include "lldb/Symbol/SymbolContext.h" +#include "lldb/Utility/Instrumentation.h" using namespace lldb; using namespace lldb_private; SBSymbolContextList::SBSymbolContextList() : m_opaque_up(new SymbolContextList()) { - LLDB_RECORD_CONSTRUCTOR_NO_ARGS(SBSymbolContextList); + LLDB_INSTRUMENT_VA(this); } -SBSymbolContextList::SBSymbolContextList(const SBSymbolContextList &rhs) - : m_opaque_up() { - LLDB_RECORD_CONSTRUCTOR(SBSymbolContextList, - (const lldb::SBSymbolContextList &), rhs); +SBSymbolContextList::SBSymbolContextList(const SBSymbolContextList &rhs) { + LLDB_INSTRUMENT_VA(this, rhs); m_opaque_up = clone(rhs.m_opaque_up); } @@ -32,17 +30,15 @@ SBSymbolContextList::~SBSymbolContextList() = default; const SBSymbolContextList &SBSymbolContextList:: operator=(const SBSymbolContextList &rhs) { - LLDB_RECORD_METHOD( - const lldb::SBSymbolContextList &, - SBSymbolContextList, operator=,(const lldb::SBSymbolContextList &), rhs); + LLDB_INSTRUMENT_VA(this, rhs); if (this != &rhs) m_opaque_up = clone(rhs.m_opaque_up); - return LLDB_RECORD_RESULT(*this); + return *this; } uint32_t SBSymbolContextList::GetSize() const { - LLDB_RECORD_METHOD_CONST_NO_ARGS(uint32_t, SBSymbolContextList, GetSize); + LLDB_INSTRUMENT_VA(this); if (m_opaque_up) return m_opaque_up->GetSize(); @@ -50,8 +46,7 @@ uint32_t SBSymbolContextList::GetSize() const { } SBSymbolContext SBSymbolContextList::GetContextAtIndex(uint32_t idx) { - LLDB_RECORD_METHOD(lldb::SBSymbolContext, SBSymbolContextList, - GetContextAtIndex, (uint32_t), idx); + LLDB_INSTRUMENT_VA(this, idx); SBSymbolContext sb_sc; if (m_opaque_up) { @@ -59,38 +54,36 @@ SBSymbolContext SBSymbolContextList::GetContextAtIndex(uint32_t idx) { if (m_opaque_up->GetContextAtIndex(idx, sc)) sb_sc = sc; } - return LLDB_RECORD_RESULT(sb_sc); + return sb_sc; } void SBSymbolContextList::Clear() { - LLDB_RECORD_METHOD_NO_ARGS(void, SBSymbolContextList, Clear); + LLDB_INSTRUMENT_VA(this); if (m_opaque_up) m_opaque_up->Clear(); } void SBSymbolContextList::Append(SBSymbolContext &sc) { - LLDB_RECORD_METHOD(void, SBSymbolContextList, Append, - (lldb::SBSymbolContext &), sc); + LLDB_INSTRUMENT_VA(this, sc); if (sc.IsValid() && m_opaque_up.get()) m_opaque_up->Append(*sc); } void SBSymbolContextList::Append(SBSymbolContextList &sc_list) { - LLDB_RECORD_METHOD(void, SBSymbolContextList, Append, - (lldb::SBSymbolContextList &), sc_list); + LLDB_INSTRUMENT_VA(this, sc_list); if (sc_list.IsValid() && m_opaque_up.get()) m_opaque_up->Append(*sc_list); } bool SBSymbolContextList::IsValid() const { - LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBSymbolContextList, IsValid); + LLDB_INSTRUMENT_VA(this); return this->operator bool(); } SBSymbolContextList::operator bool() const { - LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBSymbolContextList, operator bool); + LLDB_INSTRUMENT_VA(this); return m_opaque_up != nullptr; } @@ -105,39 +98,10 @@ lldb_private::SymbolContextList &SBSymbolContextList::operator*() const { } bool SBSymbolContextList::GetDescription(lldb::SBStream &description) { - LLDB_RECORD_METHOD(bool, SBSymbolContextList, GetDescription, - (lldb::SBStream &), description); + LLDB_INSTRUMENT_VA(this, description); Stream &strm = description.ref(); if (m_opaque_up) m_opaque_up->GetDescription(&strm, lldb::eDescriptionLevelFull, nullptr); return true; } - -namespace lldb_private { -namespace repro { - -template <> -void RegisterMethods<SBSymbolContextList>(Registry &R) { - LLDB_REGISTER_CONSTRUCTOR(SBSymbolContextList, ()); - LLDB_REGISTER_CONSTRUCTOR(SBSymbolContextList, - (const lldb::SBSymbolContextList &)); - LLDB_REGISTER_METHOD( - const lldb::SBSymbolContextList &, - SBSymbolContextList, operator=,(const lldb::SBSymbolContextList &)); - LLDB_REGISTER_METHOD_CONST(uint32_t, SBSymbolContextList, GetSize, ()); - LLDB_REGISTER_METHOD(lldb::SBSymbolContext, SBSymbolContextList, - GetContextAtIndex, (uint32_t)); - LLDB_REGISTER_METHOD(void, SBSymbolContextList, Clear, ()); - LLDB_REGISTER_METHOD(void, SBSymbolContextList, Append, - (lldb::SBSymbolContext &)); - LLDB_REGISTER_METHOD(void, SBSymbolContextList, Append, - (lldb::SBSymbolContextList &)); - LLDB_REGISTER_METHOD_CONST(bool, SBSymbolContextList, IsValid, ()); - LLDB_REGISTER_METHOD_CONST(bool, SBSymbolContextList, operator bool, ()); - LLDB_REGISTER_METHOD(bool, SBSymbolContextList, GetDescription, - (lldb::SBStream &)); -} - -} -} diff --git a/lldb/source/API/SBTarget.cpp b/lldb/source/API/SBTarget.cpp index dc79c77fee9e..75534b2343d4 100644 --- a/lldb/source/API/SBTarget.cpp +++ b/lldb/source/API/SBTarget.cpp @@ -7,7 +7,7 @@ //===----------------------------------------------------------------------===// #include "lldb/API/SBTarget.h" -#include "SBReproducerPrivate.h" +#include "lldb/Utility/Instrumentation.h" #include "lldb/lldb-public.h" @@ -93,48 +93,41 @@ static Status AttachToProcess(ProcessAttachInfo &attach_info, Target &target) { } // SBTarget constructor -SBTarget::SBTarget() : m_opaque_sp() { - LLDB_RECORD_CONSTRUCTOR_NO_ARGS(SBTarget); -} +SBTarget::SBTarget() { LLDB_INSTRUMENT_VA(this); } SBTarget::SBTarget(const SBTarget &rhs) : m_opaque_sp(rhs.m_opaque_sp) { - LLDB_RECORD_CONSTRUCTOR(SBTarget, (const lldb::SBTarget &), rhs); + LLDB_INSTRUMENT_VA(this, rhs); } SBTarget::SBTarget(const TargetSP &target_sp) : m_opaque_sp(target_sp) { - LLDB_RECORD_CONSTRUCTOR(SBTarget, (const lldb::TargetSP &), target_sp); + LLDB_INSTRUMENT_VA(this, target_sp); } const SBTarget &SBTarget::operator=(const SBTarget &rhs) { - LLDB_RECORD_METHOD(const lldb::SBTarget &, - SBTarget, operator=,(const lldb::SBTarget &), rhs); + LLDB_INSTRUMENT_VA(this, rhs); if (this != &rhs) m_opaque_sp = rhs.m_opaque_sp; - return LLDB_RECORD_RESULT(*this); + return *this; } // Destructor SBTarget::~SBTarget() = default; bool SBTarget::EventIsTargetEvent(const SBEvent &event) { - LLDB_RECORD_STATIC_METHOD(bool, SBTarget, EventIsTargetEvent, - (const lldb::SBEvent &), event); + LLDB_INSTRUMENT_VA(event); return Target::TargetEventData::GetEventDataFromEvent(event.get()) != nullptr; } SBTarget SBTarget::GetTargetFromEvent(const SBEvent &event) { - LLDB_RECORD_STATIC_METHOD(lldb::SBTarget, SBTarget, GetTargetFromEvent, - (const lldb::SBEvent &), event); + LLDB_INSTRUMENT_VA(event); - return LLDB_RECORD_RESULT( - Target::TargetEventData::GetTargetFromEvent(event.get())); + return Target::TargetEventData::GetTargetFromEvent(event.get()); } uint32_t SBTarget::GetNumModulesFromEvent(const SBEvent &event) { - LLDB_RECORD_STATIC_METHOD(uint32_t, SBTarget, GetNumModulesFromEvent, - (const lldb::SBEvent &), event); + LLDB_INSTRUMENT_VA(event); const ModuleList module_list = Target::TargetEventData::GetModuleListFromEvent(event.get()); @@ -143,34 +136,31 @@ uint32_t SBTarget::GetNumModulesFromEvent(const SBEvent &event) { SBModule SBTarget::GetModuleAtIndexFromEvent(const uint32_t idx, const SBEvent &event) { - LLDB_RECORD_STATIC_METHOD(lldb::SBModule, SBTarget, GetModuleAtIndexFromEvent, - (const uint32_t, const lldb::SBEvent &), idx, - event); + LLDB_INSTRUMENT_VA(idx, event); const ModuleList module_list = Target::TargetEventData::GetModuleListFromEvent(event.get()); - return LLDB_RECORD_RESULT(SBModule(module_list.GetModuleAtIndex(idx))); + return SBModule(module_list.GetModuleAtIndex(idx)); } const char *SBTarget::GetBroadcasterClassName() { - LLDB_RECORD_STATIC_METHOD_NO_ARGS(const char *, SBTarget, - GetBroadcasterClassName); + LLDB_INSTRUMENT(); return Target::GetStaticBroadcasterClass().AsCString(); } bool SBTarget::IsValid() const { - LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBTarget, IsValid); + LLDB_INSTRUMENT_VA(this); return this->operator bool(); } SBTarget::operator bool() const { - LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBTarget, operator bool); + LLDB_INSTRUMENT_VA(this); return m_opaque_sp.get() != nullptr && m_opaque_sp->IsValid(); } SBProcess SBTarget::GetProcess() { - LLDB_RECORD_METHOD_NO_ARGS(lldb::SBProcess, SBTarget, GetProcess); + LLDB_INSTRUMENT_VA(this); SBProcess sb_process; ProcessSP process_sp; @@ -180,49 +170,49 @@ SBProcess SBTarget::GetProcess() { sb_process.SetSP(process_sp); } - return LLDB_RECORD_RESULT(sb_process); + return sb_process; } SBPlatform SBTarget::GetPlatform() { - LLDB_RECORD_METHOD_NO_ARGS(lldb::SBPlatform, SBTarget, GetPlatform); + LLDB_INSTRUMENT_VA(this); TargetSP target_sp(GetSP()); if (!target_sp) - return LLDB_RECORD_RESULT(SBPlatform()); + return SBPlatform(); SBPlatform platform; platform.m_opaque_sp = target_sp->GetPlatform(); - return LLDB_RECORD_RESULT(platform); + return platform; } SBDebugger SBTarget::GetDebugger() const { - LLDB_RECORD_METHOD_CONST_NO_ARGS(lldb::SBDebugger, SBTarget, GetDebugger); + LLDB_INSTRUMENT_VA(this); SBDebugger debugger; TargetSP target_sp(GetSP()); if (target_sp) debugger.reset(target_sp->GetDebugger().shared_from_this()); - return LLDB_RECORD_RESULT(debugger); + return debugger; } SBStructuredData SBTarget::GetStatistics() { - LLDB_RECORD_METHOD_NO_ARGS(lldb::SBStructuredData, SBTarget, GetStatistics); + LLDB_INSTRUMENT_VA(this); SBStructuredData data; TargetSP target_sp(GetSP()); if (!target_sp) - return LLDB_RECORD_RESULT(data); + return data; std::string json_str = llvm::formatv("{0:2}", DebuggerStats::ReportStatistics(target_sp->GetDebugger(), target_sp.get())).str(); data.m_impl_up->SetObjectSP(StructuredData::ParseJSON(json_str)); - return LLDB_RECORD_RESULT(data); + return data; } void SBTarget::SetCollectingStats(bool v) { - LLDB_RECORD_METHOD(void, SBTarget, SetCollectingStats, (bool), v); + LLDB_INSTRUMENT_VA(this, v); TargetSP target_sp(GetSP()); if (!target_sp) @@ -231,7 +221,7 @@ void SBTarget::SetCollectingStats(bool v) { } bool SBTarget::GetCollectingStats() { - LLDB_RECORD_METHOD_NO_ARGS(bool, SBTarget, GetCollectingStats); + LLDB_INSTRUMENT_VA(this); TargetSP target_sp(GetSP()); if (!target_sp) @@ -240,16 +230,14 @@ bool SBTarget::GetCollectingStats() { } SBProcess SBTarget::LoadCore(const char *core_file) { - LLDB_RECORD_METHOD(lldb::SBProcess, SBTarget, LoadCore, (const char *), - core_file); + LLDB_INSTRUMENT_VA(this, core_file); lldb::SBError error; // Ignored - return LLDB_RECORD_RESULT(LoadCore(core_file, error)); + return LoadCore(core_file, error); } SBProcess SBTarget::LoadCore(const char *core_file, lldb::SBError &error) { - LLDB_RECORD_METHOD(lldb::SBProcess, SBTarget, LoadCore, - (const char *, lldb::SBError &), core_file, error); + LLDB_INSTRUMENT_VA(this, core_file, error); SBProcess sb_process; TargetSP target_sp(GetSP()); @@ -268,18 +256,16 @@ SBProcess SBTarget::LoadCore(const char *core_file, lldb::SBError &error) { } else { error.SetErrorString("SBTarget is invalid"); } - return LLDB_RECORD_RESULT(sb_process); + return sb_process; } SBProcess SBTarget::LaunchSimple(char const **argv, char const **envp, const char *working_directory) { - LLDB_RECORD_METHOD(lldb::SBProcess, SBTarget, LaunchSimple, - (const char **, const char **, const char *), argv, envp, - working_directory); + LLDB_INSTRUMENT_VA(this, argv, envp, working_directory); TargetSP target_sp = GetSP(); if (!target_sp) - return LLDB_RECORD_RESULT(SBProcess()); + return SBProcess(); SBLaunchInfo launch_info = GetLaunchInfo(); @@ -294,11 +280,11 @@ SBProcess SBTarget::LaunchSimple(char const **argv, char const **envp, launch_info.SetWorkingDirectory(working_directory); SBError error; - return LLDB_RECORD_RESULT(Launch(launch_info, error)); + return Launch(launch_info, error); } SBError SBTarget::Install() { - LLDB_RECORD_METHOD_NO_ARGS(lldb::SBError, SBTarget, Install); + LLDB_INSTRUMENT_VA(this); SBError sb_error; TargetSP target_sp(GetSP()); @@ -306,7 +292,7 @@ SBError SBTarget::Install() { std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex()); sb_error.ref() = target_sp->Install(nullptr); } - return LLDB_RECORD_RESULT(sb_error); + return sb_error; } SBProcess SBTarget::Launch(SBListener &listener, char const **argv, @@ -315,12 +301,9 @@ SBProcess SBTarget::Launch(SBListener &listener, char const **argv, const char *working_directory, uint32_t launch_flags, // See LaunchFlags bool stop_at_entry, lldb::SBError &error) { - LLDB_RECORD_METHOD(lldb::SBProcess, SBTarget, Launch, - (lldb::SBListener &, const char **, const char **, - const char *, const char *, const char *, const char *, - uint32_t, bool, lldb::SBError &), - listener, argv, envp, stdin_path, stdout_path, stderr_path, - working_directory, launch_flags, stop_at_entry, error); + LLDB_INSTRUMENT_VA(this, listener, argv, envp, stdin_path, stdout_path, + stderr_path, working_directory, launch_flags, + stop_at_entry, error); SBProcess sb_process; ProcessSP process_sp; @@ -345,7 +328,7 @@ SBProcess SBTarget::Launch(SBListener &listener, char const **argv, error.SetErrorString("process attach is in progress"); else error.SetErrorString("a process is already being debugged"); - return LLDB_RECORD_RESULT(sb_process); + return sb_process; } } @@ -356,7 +339,7 @@ SBProcess SBTarget::Launch(SBListener &listener, char const **argv, if (listener.IsValid()) { error.SetErrorString("process is connected and already has a listener, " "pass empty listener"); - return LLDB_RECORD_RESULT(sb_process); + return sb_process; } } @@ -394,14 +377,11 @@ SBProcess SBTarget::Launch(SBListener &listener, char const **argv, error.SetErrorString("SBTarget is invalid"); } - return LLDB_RECORD_RESULT(sb_process); + return sb_process; } SBProcess SBTarget::Launch(SBLaunchInfo &sb_launch_info, SBError &error) { - LLDB_RECORD_METHOD(lldb::SBProcess, SBTarget, Launch, - (lldb::SBLaunchInfo &, lldb::SBError &), sb_launch_info, - error); - + LLDB_INSTRUMENT_VA(this, sb_launch_info, error); SBProcess sb_process; TargetSP target_sp(GetSP()); @@ -419,7 +399,7 @@ SBProcess SBTarget::Launch(SBLaunchInfo &sb_launch_info, SBError &error) { error.SetErrorString("process attach is in progress"); else error.SetErrorString("a process is already being debugged"); - return LLDB_RECORD_RESULT(sb_process); + return sb_process; } } } @@ -443,13 +423,11 @@ SBProcess SBTarget::Launch(SBLaunchInfo &sb_launch_info, SBError &error) { error.SetErrorString("SBTarget is invalid"); } - return LLDB_RECORD_RESULT(sb_process); + return sb_process; } lldb::SBProcess SBTarget::Attach(SBAttachInfo &sb_attach_info, SBError &error) { - LLDB_RECORD_METHOD(lldb::SBProcess, SBTarget, Attach, - (lldb::SBAttachInfo &, lldb::SBError &), sb_attach_info, - error); + LLDB_INSTRUMENT_VA(this, sb_attach_info, error); SBProcess sb_process; TargetSP target_sp(GetSP()); @@ -467,7 +445,7 @@ lldb::SBProcess SBTarget::Attach(SBAttachInfo &sb_attach_info, SBError &error) { } else { error.ref().SetErrorStringWithFormat( "no process found with process ID %" PRIu64, attach_pid); - return LLDB_RECORD_RESULT(sb_process); + return sb_process; } } } @@ -478,7 +456,7 @@ lldb::SBProcess SBTarget::Attach(SBAttachInfo &sb_attach_info, SBError &error) { error.SetErrorString("SBTarget is invalid"); } - return LLDB_RECORD_RESULT(sb_process); + return sb_process; } lldb::SBProcess SBTarget::AttachToProcessWithID( @@ -486,9 +464,7 @@ lldb::SBProcess SBTarget::AttachToProcessWithID( lldb::pid_t pid, // The process ID to attach to SBError &error // An error explaining what went wrong if attach fails ) { - LLDB_RECORD_METHOD(lldb::SBProcess, SBTarget, AttachToProcessWithID, - (lldb::SBListener &, lldb::pid_t, lldb::SBError &), - listener, pid, error); + LLDB_INSTRUMENT_VA(this, listener, pid, error); SBProcess sb_process; TargetSP target_sp(GetSP()); @@ -509,7 +485,7 @@ lldb::SBProcess SBTarget::AttachToProcessWithID( } else error.SetErrorString("SBTarget is invalid"); - return LLDB_RECORD_RESULT(sb_process); + return sb_process; } lldb::SBProcess SBTarget::AttachToProcessWithName( @@ -518,9 +494,7 @@ lldb::SBProcess SBTarget::AttachToProcessWithName( bool wait_for, // if true wait for a new instance of "name" to be launched SBError &error // An error explaining what went wrong if attach fails ) { - LLDB_RECORD_METHOD(lldb::SBProcess, SBTarget, AttachToProcessWithName, - (lldb::SBListener &, const char *, bool, lldb::SBError &), - listener, name, wait_for, error); + LLDB_INSTRUMENT_VA(this, listener, name, wait_for, error); SBProcess sb_process; TargetSP target_sp(GetSP()); @@ -538,16 +512,13 @@ lldb::SBProcess SBTarget::AttachToProcessWithName( } else error.SetErrorString("SBTarget is invalid"); - return LLDB_RECORD_RESULT(sb_process); + return sb_process; } lldb::SBProcess SBTarget::ConnectRemote(SBListener &listener, const char *url, const char *plugin_name, SBError &error) { - LLDB_RECORD_METHOD( - lldb::SBProcess, SBTarget, ConnectRemote, - (lldb::SBListener &, const char *, const char *, lldb::SBError &), - listener, url, plugin_name, error); + LLDB_INSTRUMENT_VA(this, listener, url, plugin_name, error); SBProcess sb_process; ProcessSP process_sp; @@ -573,11 +544,11 @@ lldb::SBProcess SBTarget::ConnectRemote(SBListener &listener, const char *url, error.SetErrorString("SBTarget is invalid"); } - return LLDB_RECORD_RESULT(sb_process); + return sb_process; } SBFileSpec SBTarget::GetExecutable() { - LLDB_RECORD_METHOD_NO_ARGS(lldb::SBFileSpec, SBTarget, GetExecutable); + LLDB_INSTRUMENT_VA(this); SBFileSpec exe_file_spec; TargetSP target_sp(GetSP()); @@ -587,19 +558,17 @@ SBFileSpec SBTarget::GetExecutable() { exe_file_spec.SetFileSpec(exe_module->GetFileSpec()); } - return LLDB_RECORD_RESULT(exe_file_spec); + return exe_file_spec; } bool SBTarget::operator==(const SBTarget &rhs) const { - LLDB_RECORD_METHOD_CONST(bool, SBTarget, operator==,(const lldb::SBTarget &), - rhs); + LLDB_INSTRUMENT_VA(this, rhs); return m_opaque_sp.get() == rhs.m_opaque_sp.get(); } bool SBTarget::operator!=(const SBTarget &rhs) const { - LLDB_RECORD_METHOD_CONST(bool, SBTarget, operator!=,(const lldb::SBTarget &), - rhs); + LLDB_INSTRUMENT_VA(this, rhs); return m_opaque_sp.get() != rhs.m_opaque_sp.get(); } @@ -611,8 +580,7 @@ void SBTarget::SetSP(const lldb::TargetSP &target_sp) { } lldb::SBAddress SBTarget::ResolveLoadAddress(lldb::addr_t vm_addr) { - LLDB_RECORD_METHOD(lldb::SBAddress, SBTarget, ResolveLoadAddress, - (lldb::addr_t), vm_addr); + LLDB_INSTRUMENT_VA(this, vm_addr); lldb::SBAddress sb_addr; Address &addr = sb_addr.ref(); @@ -620,18 +588,17 @@ lldb::SBAddress SBTarget::ResolveLoadAddress(lldb::addr_t vm_addr) { if (target_sp) { std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex()); if (target_sp->ResolveLoadAddress(vm_addr, addr)) - return LLDB_RECORD_RESULT(sb_addr); + return sb_addr; } // We have a load address that isn't in a section, just return an address // with the offset filled in (the address) and the section set to NULL addr.SetRawAddress(vm_addr); - return LLDB_RECORD_RESULT(sb_addr); + return sb_addr; } lldb::SBAddress SBTarget::ResolveFileAddress(lldb::addr_t file_addr) { - LLDB_RECORD_METHOD(lldb::SBAddress, SBTarget, ResolveFileAddress, - (lldb::addr_t), file_addr); + LLDB_INSTRUMENT_VA(this, file_addr); lldb::SBAddress sb_addr; Address &addr = sb_addr.ref(); @@ -639,17 +606,16 @@ lldb::SBAddress SBTarget::ResolveFileAddress(lldb::addr_t file_addr) { if (target_sp) { std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex()); if (target_sp->ResolveFileAddress(file_addr, addr)) - return LLDB_RECORD_RESULT(sb_addr); + return sb_addr; } addr.SetRawAddress(file_addr); - return LLDB_RECORD_RESULT(sb_addr); + return sb_addr; } lldb::SBAddress SBTarget::ResolvePastLoadAddress(uint32_t stop_id, lldb::addr_t vm_addr) { - LLDB_RECORD_METHOD(lldb::SBAddress, SBTarget, ResolvePastLoadAddress, - (uint32_t, lldb::addr_t), stop_id, vm_addr); + LLDB_INSTRUMENT_VA(this, stop_id, vm_addr); lldb::SBAddress sb_addr; Address &addr = sb_addr.ref(); @@ -657,21 +623,19 @@ lldb::SBAddress SBTarget::ResolvePastLoadAddress(uint32_t stop_id, if (target_sp) { std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex()); if (target_sp->ResolveLoadAddress(vm_addr, addr)) - return LLDB_RECORD_RESULT(sb_addr); + return sb_addr; } // We have a load address that isn't in a section, just return an address // with the offset filled in (the address) and the section set to NULL addr.SetRawAddress(vm_addr); - return LLDB_RECORD_RESULT(sb_addr); + return sb_addr; } SBSymbolContext SBTarget::ResolveSymbolContextForAddress(const SBAddress &addr, uint32_t resolve_scope) { - LLDB_RECORD_METHOD(lldb::SBSymbolContext, SBTarget, - ResolveSymbolContextForAddress, - (const lldb::SBAddress &, uint32_t), addr, resolve_scope); + LLDB_INSTRUMENT_VA(this, addr, resolve_scope); SBSymbolContext sc; SymbolContextItem scope = static_cast<SymbolContextItem>(resolve_scope); @@ -681,14 +645,12 @@ SBTarget::ResolveSymbolContextForAddress(const SBAddress &addr, target_sp->GetImages().ResolveSymbolContextForAddress(addr.ref(), scope, sc.ref()); } - return LLDB_RECORD_RESULT(sc); + return sc; } size_t SBTarget::ReadMemory(const SBAddress addr, void *buf, size_t size, lldb::SBError &error) { - LLDB_RECORD_METHOD(size_t, SBTarget, ReadMemory, - (const lldb::SBAddress, void *, size_t, lldb::SBError &), - addr, buf, size, error); + LLDB_INSTRUMENT_VA(this, addr, buf, size, error); SBError sb_error; size_t bytes_read = 0; @@ -706,54 +668,43 @@ size_t SBTarget::ReadMemory(const SBAddress addr, void *buf, size_t size, SBBreakpoint SBTarget::BreakpointCreateByLocation(const char *file, uint32_t line) { - LLDB_RECORD_METHOD(lldb::SBBreakpoint, SBTarget, BreakpointCreateByLocation, - (const char *, uint32_t), file, line); + LLDB_INSTRUMENT_VA(this, file, line); - return LLDB_RECORD_RESULT( - SBBreakpoint(BreakpointCreateByLocation(SBFileSpec(file, false), line))); + return SBBreakpoint( + BreakpointCreateByLocation(SBFileSpec(file, false), line)); } SBBreakpoint SBTarget::BreakpointCreateByLocation(const SBFileSpec &sb_file_spec, uint32_t line) { - LLDB_RECORD_METHOD(lldb::SBBreakpoint, SBTarget, BreakpointCreateByLocation, - (const lldb::SBFileSpec &, uint32_t), sb_file_spec, line); + LLDB_INSTRUMENT_VA(this, sb_file_spec, line); - return LLDB_RECORD_RESULT(BreakpointCreateByLocation(sb_file_spec, line, 0)); + return BreakpointCreateByLocation(sb_file_spec, line, 0); } SBBreakpoint SBTarget::BreakpointCreateByLocation(const SBFileSpec &sb_file_spec, uint32_t line, lldb::addr_t offset) { - LLDB_RECORD_METHOD(lldb::SBBreakpoint, SBTarget, BreakpointCreateByLocation, - (const lldb::SBFileSpec &, uint32_t, lldb::addr_t), - sb_file_spec, line, offset); + LLDB_INSTRUMENT_VA(this, sb_file_spec, line, offset); SBFileSpecList empty_list; - return LLDB_RECORD_RESULT( - BreakpointCreateByLocation(sb_file_spec, line, offset, empty_list)); + return BreakpointCreateByLocation(sb_file_spec, line, offset, empty_list); } SBBreakpoint SBTarget::BreakpointCreateByLocation(const SBFileSpec &sb_file_spec, uint32_t line, lldb::addr_t offset, SBFileSpecList &sb_module_list) { - LLDB_RECORD_METHOD(lldb::SBBreakpoint, SBTarget, BreakpointCreateByLocation, - (const lldb::SBFileSpec &, uint32_t, lldb::addr_t, - lldb::SBFileSpecList &), - sb_file_spec, line, offset, sb_module_list); + LLDB_INSTRUMENT_VA(this, sb_file_spec, line, offset, sb_module_list); - return LLDB_RECORD_RESULT(BreakpointCreateByLocation(sb_file_spec, line, 0, - offset, sb_module_list)); + return BreakpointCreateByLocation(sb_file_spec, line, 0, offset, + sb_module_list); } SBBreakpoint SBTarget::BreakpointCreateByLocation( const SBFileSpec &sb_file_spec, uint32_t line, uint32_t column, lldb::addr_t offset, SBFileSpecList &sb_module_list) { - LLDB_RECORD_METHOD(lldb::SBBreakpoint, SBTarget, BreakpointCreateByLocation, - (const lldb::SBFileSpec &, uint32_t, uint32_t, - lldb::addr_t, lldb::SBFileSpecList &), - sb_file_spec, line, column, offset, sb_module_list); + LLDB_INSTRUMENT_VA(this, sb_file_spec, line, column, offset, sb_module_list); SBBreakpoint sb_bp; TargetSP target_sp(GetSP()); @@ -774,17 +725,14 @@ SBBreakpoint SBTarget::BreakpointCreateByLocation( skip_prologue, internal, hardware, move_to_nearest_code); } - return LLDB_RECORD_RESULT(sb_bp); + return sb_bp; } SBBreakpoint SBTarget::BreakpointCreateByLocation( const SBFileSpec &sb_file_spec, uint32_t line, uint32_t column, lldb::addr_t offset, SBFileSpecList &sb_module_list, bool move_to_nearest_code) { - LLDB_RECORD_METHOD(lldb::SBBreakpoint, SBTarget, BreakpointCreateByLocation, - (const lldb::SBFileSpec &, uint32_t, uint32_t, - lldb::addr_t, lldb::SBFileSpecList &, bool), - sb_file_spec, line, column, offset, sb_module_list, + LLDB_INSTRUMENT_VA(this, sb_file_spec, line, column, offset, sb_module_list, move_to_nearest_code); SBBreakpoint sb_bp; @@ -806,13 +754,12 @@ SBBreakpoint SBTarget::BreakpointCreateByLocation( move_to_nearest_code ? eLazyBoolYes : eLazyBoolNo); } - return LLDB_RECORD_RESULT(sb_bp); + return sb_bp; } SBBreakpoint SBTarget::BreakpointCreateByName(const char *symbol_name, const char *module_name) { - LLDB_RECORD_METHOD(lldb::SBBreakpoint, SBTarget, BreakpointCreateByName, - (const char *, const char *), symbol_name, module_name); + LLDB_INSTRUMENT_VA(this, symbol_name, module_name); SBBreakpoint sb_bp; TargetSP target_sp(GetSP()); @@ -836,47 +783,38 @@ SBBreakpoint SBTarget::BreakpointCreateByName(const char *symbol_name, } } - return LLDB_RECORD_RESULT(sb_bp); + return sb_bp; } lldb::SBBreakpoint SBTarget::BreakpointCreateByName(const char *symbol_name, const SBFileSpecList &module_list, const SBFileSpecList &comp_unit_list) { - LLDB_RECORD_METHOD(lldb::SBBreakpoint, SBTarget, BreakpointCreateByName, - (const char *, const lldb::SBFileSpecList &, - const lldb::SBFileSpecList &), - symbol_name, module_list, comp_unit_list); + LLDB_INSTRUMENT_VA(this, symbol_name, module_list, comp_unit_list); lldb::FunctionNameType name_type_mask = eFunctionNameTypeAuto; - return LLDB_RECORD_RESULT( - BreakpointCreateByName(symbol_name, name_type_mask, eLanguageTypeUnknown, - module_list, comp_unit_list)); + return BreakpointCreateByName(symbol_name, name_type_mask, + eLanguageTypeUnknown, module_list, + comp_unit_list); } lldb::SBBreakpoint SBTarget::BreakpointCreateByName( const char *symbol_name, uint32_t name_type_mask, const SBFileSpecList &module_list, const SBFileSpecList &comp_unit_list) { - LLDB_RECORD_METHOD(lldb::SBBreakpoint, SBTarget, BreakpointCreateByName, - (const char *, uint32_t, const lldb::SBFileSpecList &, - const lldb::SBFileSpecList &), - symbol_name, name_type_mask, module_list, comp_unit_list); + LLDB_INSTRUMENT_VA(this, symbol_name, name_type_mask, module_list, + comp_unit_list); - return LLDB_RECORD_RESULT( - BreakpointCreateByName(symbol_name, name_type_mask, eLanguageTypeUnknown, - module_list, comp_unit_list)); + return BreakpointCreateByName(symbol_name, name_type_mask, + eLanguageTypeUnknown, module_list, + comp_unit_list); } lldb::SBBreakpoint SBTarget::BreakpointCreateByName( const char *symbol_name, uint32_t name_type_mask, LanguageType symbol_language, const SBFileSpecList &module_list, const SBFileSpecList &comp_unit_list) { - LLDB_RECORD_METHOD(lldb::SBBreakpoint, SBTarget, BreakpointCreateByName, - (const char *, uint32_t, lldb::LanguageType, - const lldb::SBFileSpecList &, - const lldb::SBFileSpecList &), - symbol_name, name_type_mask, symbol_language, module_list, - comp_unit_list); + LLDB_INSTRUMENT_VA(this, symbol_name, name_type_mask, symbol_language, + module_list, comp_unit_list); SBBreakpoint sb_bp; TargetSP target_sp(GetSP()); @@ -891,49 +829,38 @@ lldb::SBBreakpoint SBTarget::BreakpointCreateByName( skip_prologue, internal, hardware); } - return LLDB_RECORD_RESULT(sb_bp); + return sb_bp; } lldb::SBBreakpoint SBTarget::BreakpointCreateByNames( const char *symbol_names[], uint32_t num_names, uint32_t name_type_mask, const SBFileSpecList &module_list, const SBFileSpecList &comp_unit_list) { - LLDB_RECORD_METHOD( - lldb::SBBreakpoint, SBTarget, BreakpointCreateByNames, - (const char **, uint32_t, uint32_t, const lldb::SBFileSpecList &, - const lldb::SBFileSpecList &), - symbol_names, num_names, name_type_mask, module_list, comp_unit_list); + LLDB_INSTRUMENT_VA(this, symbol_names, num_names, name_type_mask, module_list, + comp_unit_list); - return LLDB_RECORD_RESULT(BreakpointCreateByNames( - symbol_names, num_names, name_type_mask, eLanguageTypeUnknown, - module_list, comp_unit_list)); + return BreakpointCreateByNames(symbol_names, num_names, name_type_mask, + eLanguageTypeUnknown, module_list, + comp_unit_list); } lldb::SBBreakpoint SBTarget::BreakpointCreateByNames( const char *symbol_names[], uint32_t num_names, uint32_t name_type_mask, LanguageType symbol_language, const SBFileSpecList &module_list, const SBFileSpecList &comp_unit_list) { - LLDB_RECORD_METHOD(lldb::SBBreakpoint, SBTarget, BreakpointCreateByNames, - (const char **, uint32_t, uint32_t, lldb::LanguageType, - const lldb::SBFileSpecList &, - const lldb::SBFileSpecList &), - symbol_names, num_names, name_type_mask, symbol_language, - module_list, comp_unit_list); + LLDB_INSTRUMENT_VA(this, symbol_names, num_names, name_type_mask, + symbol_language, module_list, comp_unit_list); - return LLDB_RECORD_RESULT(BreakpointCreateByNames( - symbol_names, num_names, name_type_mask, eLanguageTypeUnknown, 0, - module_list, comp_unit_list)); + return BreakpointCreateByNames(symbol_names, num_names, name_type_mask, + eLanguageTypeUnknown, 0, module_list, + comp_unit_list); } lldb::SBBreakpoint SBTarget::BreakpointCreateByNames( const char *symbol_names[], uint32_t num_names, uint32_t name_type_mask, LanguageType symbol_language, lldb::addr_t offset, const SBFileSpecList &module_list, const SBFileSpecList &comp_unit_list) { - LLDB_RECORD_METHOD(lldb::SBBreakpoint, SBTarget, BreakpointCreateByNames, - (const char **, uint32_t, uint32_t, lldb::LanguageType, - lldb::addr_t, const lldb::SBFileSpecList &, - const lldb::SBFileSpecList &), - symbol_names, num_names, name_type_mask, symbol_language, - offset, module_list, comp_unit_list); + LLDB_INSTRUMENT_VA(this, symbol_names, num_names, name_type_mask, + symbol_language, offset, module_list, comp_unit_list); SBBreakpoint sb_bp; TargetSP target_sp(GetSP()); @@ -948,47 +875,37 @@ lldb::SBBreakpoint SBTarget::BreakpointCreateByNames( symbol_language, offset, skip_prologue, internal, hardware); } - return LLDB_RECORD_RESULT(sb_bp); + return sb_bp; } SBBreakpoint SBTarget::BreakpointCreateByRegex(const char *symbol_name_regex, const char *module_name) { - LLDB_RECORD_METHOD(lldb::SBBreakpoint, SBTarget, BreakpointCreateByRegex, - (const char *, const char *), symbol_name_regex, - module_name); + LLDB_INSTRUMENT_VA(this, symbol_name_regex, module_name); SBFileSpecList module_spec_list; SBFileSpecList comp_unit_list; if (module_name && module_name[0]) { module_spec_list.Append(FileSpec(module_name)); } - return LLDB_RECORD_RESULT( - BreakpointCreateByRegex(symbol_name_regex, eLanguageTypeUnknown, - module_spec_list, comp_unit_list)); + return BreakpointCreateByRegex(symbol_name_regex, eLanguageTypeUnknown, + module_spec_list, comp_unit_list); } lldb::SBBreakpoint SBTarget::BreakpointCreateByRegex(const char *symbol_name_regex, const SBFileSpecList &module_list, const SBFileSpecList &comp_unit_list) { - LLDB_RECORD_METHOD(lldb::SBBreakpoint, SBTarget, BreakpointCreateByRegex, - (const char *, const lldb::SBFileSpecList &, - const lldb::SBFileSpecList &), - symbol_name_regex, module_list, comp_unit_list); + LLDB_INSTRUMENT_VA(this, symbol_name_regex, module_list, comp_unit_list); - return LLDB_RECORD_RESULT(BreakpointCreateByRegex( - symbol_name_regex, eLanguageTypeUnknown, module_list, comp_unit_list)); + return BreakpointCreateByRegex(symbol_name_regex, eLanguageTypeUnknown, + module_list, comp_unit_list); } lldb::SBBreakpoint SBTarget::BreakpointCreateByRegex( const char *symbol_name_regex, LanguageType symbol_language, const SBFileSpecList &module_list, const SBFileSpecList &comp_unit_list) { - LLDB_RECORD_METHOD( - lldb::SBBreakpoint, SBTarget, BreakpointCreateByRegex, - (const char *, lldb::LanguageType, const lldb::SBFileSpecList &, - const lldb::SBFileSpecList &), - symbol_name_regex, symbol_language, module_list, comp_unit_list); - + LLDB_INSTRUMENT_VA(this, symbol_name_regex, symbol_language, module_list, + comp_unit_list); SBBreakpoint sb_bp; TargetSP target_sp(GetSP()); @@ -1004,12 +921,11 @@ lldb::SBBreakpoint SBTarget::BreakpointCreateByRegex( symbol_language, skip_prologue, internal, hardware); } - return LLDB_RECORD_RESULT(sb_bp); + return sb_bp; } SBBreakpoint SBTarget::BreakpointCreateByAddress(addr_t address) { - LLDB_RECORD_METHOD(lldb::SBBreakpoint, SBTarget, BreakpointCreateByAddress, - (lldb::addr_t), address); + LLDB_INSTRUMENT_VA(this, address); SBBreakpoint sb_bp; TargetSP target_sp(GetSP()); @@ -1019,17 +935,16 @@ SBBreakpoint SBTarget::BreakpointCreateByAddress(addr_t address) { sb_bp = target_sp->CreateBreakpoint(address, false, hardware); } - return LLDB_RECORD_RESULT(sb_bp); + return sb_bp; } SBBreakpoint SBTarget::BreakpointCreateBySBAddress(SBAddress &sb_address) { - LLDB_RECORD_METHOD(lldb::SBBreakpoint, SBTarget, BreakpointCreateBySBAddress, - (lldb::SBAddress &), sb_address); + LLDB_INSTRUMENT_VA(this, sb_address); SBBreakpoint sb_bp; TargetSP target_sp(GetSP()); if (!sb_address.IsValid()) { - return LLDB_RECORD_RESULT(sb_bp); + return sb_bp; } if (target_sp) { @@ -1038,17 +953,14 @@ SBBreakpoint SBTarget::BreakpointCreateBySBAddress(SBAddress &sb_address) { sb_bp = target_sp->CreateBreakpoint(sb_address.ref(), false, hardware); } - return LLDB_RECORD_RESULT(sb_bp); + return sb_bp; } lldb::SBBreakpoint SBTarget::BreakpointCreateBySourceRegex(const char *source_regex, const lldb::SBFileSpec &source_file, const char *module_name) { - LLDB_RECORD_METHOD(lldb::SBBreakpoint, SBTarget, - BreakpointCreateBySourceRegex, - (const char *, const lldb::SBFileSpec &, const char *), - source_regex, source_file, module_name); + LLDB_INSTRUMENT_VA(this, source_regex, source_file, module_name); SBFileSpecList module_spec_list; @@ -1061,32 +973,25 @@ SBTarget::BreakpointCreateBySourceRegex(const char *source_regex, source_file_list.Append(source_file); } - return LLDB_RECORD_RESULT(BreakpointCreateBySourceRegex( - source_regex, module_spec_list, source_file_list)); + return BreakpointCreateBySourceRegex(source_regex, module_spec_list, + source_file_list); } lldb::SBBreakpoint SBTarget::BreakpointCreateBySourceRegex( const char *source_regex, const SBFileSpecList &module_list, const lldb::SBFileSpecList &source_file_list) { - LLDB_RECORD_METHOD(lldb::SBBreakpoint, SBTarget, - BreakpointCreateBySourceRegex, - (const char *, const lldb::SBFileSpecList &, - const lldb::SBFileSpecList &), - source_regex, module_list, source_file_list); + LLDB_INSTRUMENT_VA(this, source_regex, module_list, source_file_list); - return LLDB_RECORD_RESULT(BreakpointCreateBySourceRegex( - source_regex, module_list, source_file_list, SBStringList())); + return BreakpointCreateBySourceRegex(source_regex, module_list, + source_file_list, SBStringList()); } lldb::SBBreakpoint SBTarget::BreakpointCreateBySourceRegex( const char *source_regex, const SBFileSpecList &module_list, const lldb::SBFileSpecList &source_file_list, const SBStringList &func_names) { - LLDB_RECORD_METHOD(lldb::SBBreakpoint, SBTarget, - BreakpointCreateBySourceRegex, - (const char *, const lldb::SBFileSpecList &, - const lldb::SBFileSpecList &, const lldb::SBStringList &), - source_regex, module_list, source_file_list, func_names); + LLDB_INSTRUMENT_VA(this, source_regex, module_list, source_file_list, + func_names); SBBreakpoint sb_bp; TargetSP target_sp(GetSP()); @@ -1105,15 +1010,13 @@ lldb::SBBreakpoint SBTarget::BreakpointCreateBySourceRegex( std::move(regexp), false, hardware, move_to_nearest_code); } - return LLDB_RECORD_RESULT(sb_bp); + return sb_bp; } lldb::SBBreakpoint SBTarget::BreakpointCreateForException(lldb::LanguageType language, bool catch_bp, bool throw_bp) { - LLDB_RECORD_METHOD(lldb::SBBreakpoint, SBTarget, BreakpointCreateForException, - (lldb::LanguageType, bool, bool), language, catch_bp, - throw_bp); + LLDB_INSTRUMENT_VA(this, language, catch_bp, throw_bp); SBBreakpoint sb_bp; TargetSP target_sp(GetSP()); @@ -1124,18 +1027,15 @@ SBTarget::BreakpointCreateForException(lldb::LanguageType language, hardware); } - return LLDB_RECORD_RESULT(sb_bp); + return sb_bp; } lldb::SBBreakpoint SBTarget::BreakpointCreateFromScript( const char *class_name, SBStructuredData &extra_args, const SBFileSpecList &module_list, const SBFileSpecList &file_list, bool request_hardware) { - LLDB_RECORD_METHOD( - lldb::SBBreakpoint, SBTarget, BreakpointCreateFromScript, - (const char *, lldb::SBStructuredData &, const lldb::SBFileSpecList &, - const lldb::SBFileSpecList &, bool), - class_name, extra_args, module_list, file_list, request_hardware); + LLDB_INSTRUMENT_VA(this, class_name, extra_args, module_list, file_list, + request_hardware); SBBreakpoint sb_bp; TargetSP target_sp(GetSP()); @@ -1154,11 +1054,11 @@ lldb::SBBreakpoint SBTarget::BreakpointCreateFromScript( &error); } - return LLDB_RECORD_RESULT(sb_bp); + return sb_bp; } uint32_t SBTarget::GetNumBreakpoints() const { - LLDB_RECORD_METHOD_CONST_NO_ARGS(uint32_t, SBTarget, GetNumBreakpoints); + LLDB_INSTRUMENT_VA(this); TargetSP target_sp(GetSP()); if (target_sp) { @@ -1169,8 +1069,7 @@ uint32_t SBTarget::GetNumBreakpoints() const { } SBBreakpoint SBTarget::GetBreakpointAtIndex(uint32_t idx) const { - LLDB_RECORD_METHOD_CONST(lldb::SBBreakpoint, SBTarget, GetBreakpointAtIndex, - (uint32_t), idx); + LLDB_INSTRUMENT_VA(this, idx); SBBreakpoint sb_breakpoint; TargetSP target_sp(GetSP()); @@ -1178,12 +1077,11 @@ SBBreakpoint SBTarget::GetBreakpointAtIndex(uint32_t idx) const { // The breakpoint list is thread safe, no need to lock sb_breakpoint = target_sp->GetBreakpointList().GetBreakpointAtIndex(idx); } - return LLDB_RECORD_RESULT(sb_breakpoint); + return sb_breakpoint; } bool SBTarget::BreakpointDelete(break_id_t bp_id) { - LLDB_RECORD_METHOD(bool, SBTarget, BreakpointDelete, (lldb::break_id_t), - bp_id); + LLDB_INSTRUMENT_VA(this, bp_id); bool result = false; TargetSP target_sp(GetSP()); @@ -1196,8 +1094,7 @@ bool SBTarget::BreakpointDelete(break_id_t bp_id) { } SBBreakpoint SBTarget::FindBreakpointByID(break_id_t bp_id) { - LLDB_RECORD_METHOD(lldb::SBBreakpoint, SBTarget, FindBreakpointByID, - (lldb::break_id_t), bp_id); + LLDB_INSTRUMENT_VA(this, bp_id); SBBreakpoint sb_breakpoint; TargetSP target_sp(GetSP()); @@ -1206,13 +1103,12 @@ SBBreakpoint SBTarget::FindBreakpointByID(break_id_t bp_id) { sb_breakpoint = target_sp->GetBreakpointByID(bp_id); } - return LLDB_RECORD_RESULT(sb_breakpoint); + return sb_breakpoint; } bool SBTarget::FindBreakpointsByName(const char *name, SBBreakpointList &bkpts) { - LLDB_RECORD_METHOD(bool, SBTarget, FindBreakpointsByName, - (const char *, lldb::SBBreakpointList &), name, bkpts); + LLDB_INSTRUMENT_VA(this, name, bkpts); TargetSP target_sp(GetSP()); if (target_sp) { @@ -1233,8 +1129,7 @@ bool SBTarget::FindBreakpointsByName(const char *name, } void SBTarget::GetBreakpointNames(SBStringList &names) { - LLDB_RECORD_METHOD(void, SBTarget, GetBreakpointNames, (lldb::SBStringList &), - names); + LLDB_INSTRUMENT_VA(this, names); names.Clear(); @@ -1250,8 +1145,7 @@ void SBTarget::GetBreakpointNames(SBStringList &names) { } void SBTarget::DeleteBreakpointName(const char *name) { - LLDB_RECORD_METHOD(void, SBTarget, DeleteBreakpointName, (const char *), - name); + LLDB_INSTRUMENT_VA(this, name); TargetSP target_sp(GetSP()); if (target_sp) { @@ -1261,7 +1155,7 @@ void SBTarget::DeleteBreakpointName(const char *name) { } bool SBTarget::EnableAllBreakpoints() { - LLDB_RECORD_METHOD_NO_ARGS(bool, SBTarget, EnableAllBreakpoints); + LLDB_INSTRUMENT_VA(this); TargetSP target_sp(GetSP()); if (target_sp) { @@ -1273,7 +1167,7 @@ bool SBTarget::EnableAllBreakpoints() { } bool SBTarget::DisableAllBreakpoints() { - LLDB_RECORD_METHOD_NO_ARGS(bool, SBTarget, DisableAllBreakpoints); + LLDB_INSTRUMENT_VA(this); TargetSP target_sp(GetSP()); if (target_sp) { @@ -1285,7 +1179,7 @@ bool SBTarget::DisableAllBreakpoints() { } bool SBTarget::DeleteAllBreakpoints() { - LLDB_RECORD_METHOD_NO_ARGS(bool, SBTarget, DeleteAllBreakpoints); + LLDB_INSTRUMENT_VA(this); TargetSP target_sp(GetSP()); if (target_sp) { @@ -1298,29 +1192,23 @@ bool SBTarget::DeleteAllBreakpoints() { lldb::SBError SBTarget::BreakpointsCreateFromFile(SBFileSpec &source_file, SBBreakpointList &new_bps) { - LLDB_RECORD_METHOD(lldb::SBError, SBTarget, BreakpointsCreateFromFile, - (lldb::SBFileSpec &, lldb::SBBreakpointList &), - source_file, new_bps); + LLDB_INSTRUMENT_VA(this, source_file, new_bps); SBStringList empty_name_list; - return LLDB_RECORD_RESULT( - BreakpointsCreateFromFile(source_file, empty_name_list, new_bps)); + return BreakpointsCreateFromFile(source_file, empty_name_list, new_bps); } lldb::SBError SBTarget::BreakpointsCreateFromFile(SBFileSpec &source_file, SBStringList &matching_names, SBBreakpointList &new_bps) { - LLDB_RECORD_METHOD( - lldb::SBError, SBTarget, BreakpointsCreateFromFile, - (lldb::SBFileSpec &, lldb::SBStringList &, lldb::SBBreakpointList &), - source_file, matching_names, new_bps); + LLDB_INSTRUMENT_VA(this, source_file, matching_names, new_bps); SBError sberr; TargetSP target_sp(GetSP()); if (!target_sp) { sberr.SetErrorString( "BreakpointCreateFromFile called with invalid target."); - return LLDB_RECORD_RESULT(sberr); + return sberr; } std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex()); @@ -1334,42 +1222,39 @@ lldb::SBError SBTarget::BreakpointsCreateFromFile(SBFileSpec &source_file, sberr.ref() = target_sp->CreateBreakpointsFromFile(source_file.ref(), name_vector, bp_ids); if (sberr.Fail()) - return LLDB_RECORD_RESULT(sberr); + return sberr; size_t num_bkpts = bp_ids.GetSize(); for (size_t i = 0; i < num_bkpts; i++) { BreakpointID bp_id = bp_ids.GetBreakpointIDAtIndex(i); new_bps.AppendByID(bp_id.GetBreakpointID()); } - return LLDB_RECORD_RESULT(sberr); + return sberr; } lldb::SBError SBTarget::BreakpointsWriteToFile(SBFileSpec &dest_file) { - LLDB_RECORD_METHOD(lldb::SBError, SBTarget, BreakpointsWriteToFile, - (lldb::SBFileSpec &), dest_file); + LLDB_INSTRUMENT_VA(this, dest_file); SBError sberr; TargetSP target_sp(GetSP()); if (!target_sp) { sberr.SetErrorString("BreakpointWriteToFile called with invalid target."); - return LLDB_RECORD_RESULT(sberr); + return sberr; } SBBreakpointList bkpt_list(*this); - return LLDB_RECORD_RESULT(BreakpointsWriteToFile(dest_file, bkpt_list)); + return BreakpointsWriteToFile(dest_file, bkpt_list); } lldb::SBError SBTarget::BreakpointsWriteToFile(SBFileSpec &dest_file, SBBreakpointList &bkpt_list, bool append) { - LLDB_RECORD_METHOD(lldb::SBError, SBTarget, BreakpointsWriteToFile, - (lldb::SBFileSpec &, lldb::SBBreakpointList &, bool), - dest_file, bkpt_list, append); + LLDB_INSTRUMENT_VA(this, dest_file, bkpt_list, append); SBError sberr; TargetSP target_sp(GetSP()); if (!target_sp) { sberr.SetErrorString("BreakpointWriteToFile called with invalid target."); - return LLDB_RECORD_RESULT(sberr); + return sberr; } std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex()); @@ -1377,11 +1262,11 @@ lldb::SBError SBTarget::BreakpointsWriteToFile(SBFileSpec &dest_file, bkpt_list.CopyToBreakpointIDList(bp_id_list); sberr.ref() = target_sp->SerializeBreakpointsToFile(dest_file.ref(), bp_id_list, append); - return LLDB_RECORD_RESULT(sberr); + return sberr; } uint32_t SBTarget::GetNumWatchpoints() const { - LLDB_RECORD_METHOD_CONST_NO_ARGS(uint32_t, SBTarget, GetNumWatchpoints); + LLDB_INSTRUMENT_VA(this); TargetSP target_sp(GetSP()); if (target_sp) { @@ -1392,8 +1277,7 @@ uint32_t SBTarget::GetNumWatchpoints() const { } SBWatchpoint SBTarget::GetWatchpointAtIndex(uint32_t idx) const { - LLDB_RECORD_METHOD_CONST(lldb::SBWatchpoint, SBTarget, GetWatchpointAtIndex, - (uint32_t), idx); + LLDB_INSTRUMENT_VA(this, idx); SBWatchpoint sb_watchpoint; TargetSP target_sp(GetSP()); @@ -1401,13 +1285,11 @@ SBWatchpoint SBTarget::GetWatchpointAtIndex(uint32_t idx) const { // The watchpoint list is thread safe, no need to lock sb_watchpoint.SetSP(target_sp->GetWatchpointList().GetByIndex(idx)); } - return LLDB_RECORD_RESULT(sb_watchpoint); + return sb_watchpoint; } bool SBTarget::DeleteWatchpoint(watch_id_t wp_id) { - LLDB_RECORD_METHOD(bool, SBTarget, DeleteWatchpoint, (lldb::watch_id_t), - wp_id); - + LLDB_INSTRUMENT_VA(this, wp_id); bool result = false; TargetSP target_sp(GetSP()); @@ -1422,9 +1304,7 @@ bool SBTarget::DeleteWatchpoint(watch_id_t wp_id) { } SBWatchpoint SBTarget::FindWatchpointByID(lldb::watch_id_t wp_id) { - LLDB_RECORD_METHOD(lldb::SBWatchpoint, SBTarget, FindWatchpointByID, - (lldb::watch_id_t), wp_id); - + LLDB_INSTRUMENT_VA(this, wp_id); SBWatchpoint sb_watchpoint; lldb::WatchpointSP watchpoint_sp; @@ -1437,15 +1317,13 @@ SBWatchpoint SBTarget::FindWatchpointByID(lldb::watch_id_t wp_id) { sb_watchpoint.SetSP(watchpoint_sp); } - return LLDB_RECORD_RESULT(sb_watchpoint); + return sb_watchpoint; } lldb::SBWatchpoint SBTarget::WatchAddress(lldb::addr_t addr, size_t size, bool read, bool write, SBError &error) { - LLDB_RECORD_METHOD(lldb::SBWatchpoint, SBTarget, WatchAddress, - (lldb::addr_t, size_t, bool, bool, lldb::SBError &), addr, - size, read, write, error); + LLDB_INSTRUMENT_VA(this, addr, size, read, write, error); SBWatchpoint sb_watchpoint; lldb::WatchpointSP watchpoint_sp; @@ -1461,7 +1339,7 @@ lldb::SBWatchpoint SBTarget::WatchAddress(lldb::addr_t addr, size_t size, if (watch_type == 0) { error.SetErrorString( "Can't create a watchpoint that is neither read nor write."); - return LLDB_RECORD_RESULT(sb_watchpoint); + return sb_watchpoint; } // Target::CreateWatchpoint() is thread safe. @@ -1474,11 +1352,11 @@ lldb::SBWatchpoint SBTarget::WatchAddress(lldb::addr_t addr, size_t size, sb_watchpoint.SetSP(watchpoint_sp); } - return LLDB_RECORD_RESULT(sb_watchpoint); + return sb_watchpoint; } bool SBTarget::EnableAllWatchpoints() { - LLDB_RECORD_METHOD_NO_ARGS(bool, SBTarget, EnableAllWatchpoints); + LLDB_INSTRUMENT_VA(this); TargetSP target_sp(GetSP()); if (target_sp) { @@ -1492,7 +1370,7 @@ bool SBTarget::EnableAllWatchpoints() { } bool SBTarget::DisableAllWatchpoints() { - LLDB_RECORD_METHOD_NO_ARGS(bool, SBTarget, DisableAllWatchpoints); + LLDB_INSTRUMENT_VA(this); TargetSP target_sp(GetSP()); if (target_sp) { @@ -1507,9 +1385,7 @@ bool SBTarget::DisableAllWatchpoints() { SBValue SBTarget::CreateValueFromAddress(const char *name, SBAddress addr, SBType type) { - LLDB_RECORD_METHOD(lldb::SBValue, SBTarget, CreateValueFromAddress, - (const char *, lldb::SBAddress, lldb::SBType), name, addr, - type); + LLDB_INSTRUMENT_VA(this, name, addr, type); SBValue sb_value; lldb::ValueObjectSP new_value_sp; @@ -1522,14 +1398,12 @@ SBValue SBTarget::CreateValueFromAddress(const char *name, SBAddress addr, exe_ctx, ast_type); } sb_value.SetSP(new_value_sp); - return LLDB_RECORD_RESULT(sb_value); + return sb_value; } lldb::SBValue SBTarget::CreateValueFromData(const char *name, lldb::SBData data, lldb::SBType type) { - LLDB_RECORD_METHOD(lldb::SBValue, SBTarget, CreateValueFromData, - (const char *, lldb::SBData, lldb::SBType), name, data, - type); + LLDB_INSTRUMENT_VA(this, name, data, type); SBValue sb_value; lldb::ValueObjectSP new_value_sp; @@ -1542,13 +1416,12 @@ lldb::SBValue SBTarget::CreateValueFromData(const char *name, lldb::SBData data, exe_ctx, ast_type); } sb_value.SetSP(new_value_sp); - return LLDB_RECORD_RESULT(sb_value); + return sb_value; } lldb::SBValue SBTarget::CreateValueFromExpression(const char *name, const char *expr) { - LLDB_RECORD_METHOD(lldb::SBValue, SBTarget, CreateValueFromExpression, - (const char *, const char *), name, expr); + LLDB_INSTRUMENT_VA(this, name, expr); SBValue sb_value; lldb::ValueObjectSP new_value_sp; @@ -1559,11 +1432,11 @@ lldb::SBValue SBTarget::CreateValueFromExpression(const char *name, ValueObject::CreateValueObjectFromExpression(name, expr, exe_ctx); } sb_value.SetSP(new_value_sp); - return LLDB_RECORD_RESULT(sb_value); + return sb_value; } bool SBTarget::DeleteAllWatchpoints() { - LLDB_RECORD_METHOD_NO_ARGS(bool, SBTarget, DeleteAllWatchpoints); + LLDB_INSTRUMENT_VA(this); TargetSP target_sp(GetSP()); if (target_sp) { @@ -1578,9 +1451,7 @@ bool SBTarget::DeleteAllWatchpoints() { void SBTarget::AppendImageSearchPath(const char *from, const char *to, lldb::SBError &error) { - LLDB_RECORD_METHOD(void, SBTarget, AppendImageSearchPath, - (const char *, const char *, lldb::SBError &), from, to, - error); + LLDB_INSTRUMENT_VA(this, from, to, error); TargetSP target_sp(GetSP()); if (!target_sp) @@ -1597,18 +1468,14 @@ void SBTarget::AppendImageSearchPath(const char *from, const char *to, lldb::SBModule SBTarget::AddModule(const char *path, const char *triple, const char *uuid_cstr) { - LLDB_RECORD_METHOD(lldb::SBModule, SBTarget, AddModule, - (const char *, const char *, const char *), path, triple, - uuid_cstr); + LLDB_INSTRUMENT_VA(this, path, triple, uuid_cstr); - return LLDB_RECORD_RESULT(AddModule(path, triple, uuid_cstr, nullptr)); + return AddModule(path, triple, uuid_cstr, nullptr); } lldb::SBModule SBTarget::AddModule(const char *path, const char *triple, const char *uuid_cstr, const char *symfile) { - LLDB_RECORD_METHOD(lldb::SBModule, SBTarget, AddModule, - (const char *, const char *, const char *, const char *), - path, triple, uuid_cstr, symfile); + LLDB_INSTRUMENT_VA(this, path, triple, uuid_cstr, symfile); lldb::SBModule sb_module; TargetSP target_sp(GetSP()); @@ -1631,23 +1498,22 @@ lldb::SBModule SBTarget::AddModule(const char *path, const char *triple, sb_module.SetSP(target_sp->GetOrCreateModule(module_spec, true /* notify */)); } - return LLDB_RECORD_RESULT(sb_module); + return sb_module; } lldb::SBModule SBTarget::AddModule(const SBModuleSpec &module_spec) { - LLDB_RECORD_METHOD(lldb::SBModule, SBTarget, AddModule, - (const lldb::SBModuleSpec &), module_spec); + LLDB_INSTRUMENT_VA(this, module_spec); lldb::SBModule sb_module; TargetSP target_sp(GetSP()); if (target_sp) sb_module.SetSP(target_sp->GetOrCreateModule(*module_spec.m_opaque_up, true /* notify */)); - return LLDB_RECORD_RESULT(sb_module); + return sb_module; } bool SBTarget::AddModule(lldb::SBModule &module) { - LLDB_RECORD_METHOD(bool, SBTarget, AddModule, (lldb::SBModule &), module); + LLDB_INSTRUMENT_VA(this, module); TargetSP target_sp(GetSP()); if (target_sp) { @@ -1658,7 +1524,7 @@ bool SBTarget::AddModule(lldb::SBModule &module) { } uint32_t SBTarget::GetNumModules() const { - LLDB_RECORD_METHOD_CONST_NO_ARGS(uint32_t, SBTarget, GetNumModules); + LLDB_INSTRUMENT_VA(this); uint32_t num = 0; TargetSP target_sp(GetSP()); @@ -1671,14 +1537,13 @@ uint32_t SBTarget::GetNumModules() const { } void SBTarget::Clear() { - LLDB_RECORD_METHOD_NO_ARGS(void, SBTarget, Clear); + LLDB_INSTRUMENT_VA(this); m_opaque_sp.reset(); } SBModule SBTarget::FindModule(const SBFileSpec &sb_file_spec) { - LLDB_RECORD_METHOD(lldb::SBModule, SBTarget, FindModule, - (const lldb::SBFileSpec &), sb_file_spec); + LLDB_INSTRUMENT_VA(this, sb_file_spec); SBModule sb_module; TargetSP target_sp(GetSP()); @@ -1687,22 +1552,21 @@ SBModule SBTarget::FindModule(const SBFileSpec &sb_file_spec) { // The module list is thread safe, no need to lock sb_module.SetSP(target_sp->GetImages().FindFirstModule(module_spec)); } - return LLDB_RECORD_RESULT(sb_module); + return sb_module; } SBSymbolContextList SBTarget::FindCompileUnits(const SBFileSpec &sb_file_spec) { - LLDB_RECORD_METHOD(lldb::SBSymbolContextList, SBTarget, FindCompileUnits, - (const lldb::SBFileSpec &), sb_file_spec); + LLDB_INSTRUMENT_VA(this, sb_file_spec); SBSymbolContextList sb_sc_list; const TargetSP target_sp(GetSP()); if (target_sp && sb_file_spec.IsValid()) target_sp->GetImages().FindCompileUnits(*sb_file_spec, *sb_sc_list); - return LLDB_RECORD_RESULT(sb_sc_list); + return sb_sc_list; } lldb::ByteOrder SBTarget::GetByteOrder() { - LLDB_RECORD_METHOD_NO_ARGS(lldb::ByteOrder, SBTarget, GetByteOrder); + LLDB_INSTRUMENT_VA(this); TargetSP target_sp(GetSP()); if (target_sp) @@ -1711,7 +1575,7 @@ lldb::ByteOrder SBTarget::GetByteOrder() { } const char *SBTarget::GetTriple() { - LLDB_RECORD_METHOD_NO_ARGS(const char *, SBTarget, GetTriple); + LLDB_INSTRUMENT_VA(this); TargetSP target_sp(GetSP()); if (target_sp) { @@ -1726,7 +1590,7 @@ const char *SBTarget::GetTriple() { } uint32_t SBTarget::GetDataByteSize() { - LLDB_RECORD_METHOD_NO_ARGS(uint32_t, SBTarget, GetDataByteSize); + LLDB_INSTRUMENT_VA(this); TargetSP target_sp(GetSP()); if (target_sp) { @@ -1736,7 +1600,7 @@ uint32_t SBTarget::GetDataByteSize() { } uint32_t SBTarget::GetCodeByteSize() { - LLDB_RECORD_METHOD_NO_ARGS(uint32_t, SBTarget, GetCodeByteSize); + LLDB_INSTRUMENT_VA(this); TargetSP target_sp(GetSP()); if (target_sp) { @@ -1746,7 +1610,7 @@ uint32_t SBTarget::GetCodeByteSize() { } uint32_t SBTarget::GetMaximumNumberOfChildrenToDisplay() const { - LLDB_RECORD_METHOD_CONST_NO_ARGS(uint32_t, SBTarget, GetMaximumNumberOfChildrenToDisplay); + LLDB_INSTRUMENT_VA(this); TargetSP target_sp(GetSP()); if(target_sp){ @@ -1756,7 +1620,7 @@ uint32_t SBTarget::GetMaximumNumberOfChildrenToDisplay() const { } uint32_t SBTarget::GetAddressByteSize() { - LLDB_RECORD_METHOD_NO_ARGS(uint32_t, SBTarget, GetAddressByteSize); + LLDB_INSTRUMENT_VA(this); TargetSP target_sp(GetSP()); if (target_sp) @@ -1765,8 +1629,7 @@ uint32_t SBTarget::GetAddressByteSize() { } SBModule SBTarget::GetModuleAtIndex(uint32_t idx) { - LLDB_RECORD_METHOD(lldb::SBModule, SBTarget, GetModuleAtIndex, (uint32_t), - idx); + LLDB_INSTRUMENT_VA(this, idx); SBModule sb_module; ModuleSP module_sp; @@ -1777,11 +1640,11 @@ SBModule SBTarget::GetModuleAtIndex(uint32_t idx) { sb_module.SetSP(module_sp); } - return LLDB_RECORD_RESULT(sb_module); + return sb_module; } bool SBTarget::RemoveModule(lldb::SBModule module) { - LLDB_RECORD_METHOD(bool, SBTarget, RemoveModule, (lldb::SBModule), module); + LLDB_INSTRUMENT_VA(this, module); TargetSP target_sp(GetSP()); if (target_sp) @@ -1790,22 +1653,17 @@ bool SBTarget::RemoveModule(lldb::SBModule module) { } SBBroadcaster SBTarget::GetBroadcaster() const { - LLDB_RECORD_METHOD_CONST_NO_ARGS(lldb::SBBroadcaster, SBTarget, - GetBroadcaster); - + LLDB_INSTRUMENT_VA(this); TargetSP target_sp(GetSP()); SBBroadcaster broadcaster(target_sp.get(), false); - - return LLDB_RECORD_RESULT(broadcaster); + return broadcaster; } bool SBTarget::GetDescription(SBStream &description, lldb::DescriptionLevel description_level) { - LLDB_RECORD_METHOD(bool, SBTarget, GetDescription, - (lldb::SBStream &, lldb::DescriptionLevel), description, - description_level); + LLDB_INSTRUMENT_VA(this, description, description_level); Stream &strm = description.ref(); @@ -1820,16 +1678,15 @@ bool SBTarget::GetDescription(SBStream &description, lldb::SBSymbolContextList SBTarget::FindFunctions(const char *name, uint32_t name_type_mask) { - LLDB_RECORD_METHOD(lldb::SBSymbolContextList, SBTarget, FindFunctions, - (const char *, uint32_t), name, name_type_mask); + LLDB_INSTRUMENT_VA(this, name, name_type_mask); lldb::SBSymbolContextList sb_sc_list; if (!name || !name[0]) - return LLDB_RECORD_RESULT(sb_sc_list); + return sb_sc_list; TargetSP target_sp(GetSP()); if (!target_sp) - return LLDB_RECORD_RESULT(sb_sc_list); + return sb_sc_list; ModuleFunctionSearchOptions function_options; function_options.include_symbols = true; @@ -1838,15 +1695,13 @@ lldb::SBSymbolContextList SBTarget::FindFunctions(const char *name, FunctionNameType mask = static_cast<FunctionNameType>(name_type_mask); target_sp->GetImages().FindFunctions(ConstString(name), mask, function_options, *sb_sc_list); - return LLDB_RECORD_RESULT(sb_sc_list); + return sb_sc_list; } lldb::SBSymbolContextList SBTarget::FindGlobalFunctions(const char *name, uint32_t max_matches, MatchType matchtype) { - LLDB_RECORD_METHOD(lldb::SBSymbolContextList, SBTarget, FindGlobalFunctions, - (const char *, uint32_t, lldb::MatchType), name, - max_matches, matchtype); + LLDB_INSTRUMENT_VA(this, name, max_matches, matchtype); lldb::SBSymbolContextList sb_sc_list; if (name && name[0]) { @@ -1876,12 +1731,11 @@ lldb::SBSymbolContextList SBTarget::FindGlobalFunctions(const char *name, } } } - return LLDB_RECORD_RESULT(sb_sc_list); + return sb_sc_list; } lldb::SBType SBTarget::FindFirstType(const char *typename_cstr) { - LLDB_RECORD_METHOD(lldb::SBType, SBTarget, FindFirstType, (const char *), - typename_cstr); + LLDB_INSTRUMENT_VA(this, typename_cstr); TargetSP target_sp(GetSP()); if (typename_cstr && typename_cstr[0] && target_sp) { @@ -1897,7 +1751,7 @@ lldb::SBType SBTarget::FindFirstType(const char *typename_cstr) { TypeSP type_sp( module_sp->FindFirstType(sc, const_typename, exact_match)); if (type_sp) - return LLDB_RECORD_RESULT(SBType(type_sp)); + return SBType(type_sp); } } @@ -1907,7 +1761,7 @@ lldb::SBType SBTarget::FindFirstType(const char *typename_cstr) { if (auto vendor = runtime->GetDeclVendor()) { auto types = vendor->FindTypes(const_typename, /*max_matches*/ 1); if (!types.empty()) - return LLDB_RECORD_RESULT(SBType(types.front())); + return SBType(types.front()); } } } @@ -1915,28 +1769,26 @@ lldb::SBType SBTarget::FindFirstType(const char *typename_cstr) { // No matches, search for basic typename matches for (auto *type_system : target_sp->GetScratchTypeSystems()) if (auto type = type_system->GetBuiltinTypeByName(const_typename)) - return LLDB_RECORD_RESULT(SBType(type)); + return SBType(type); } - return LLDB_RECORD_RESULT(SBType()); + return SBType(); } SBType SBTarget::GetBasicType(lldb::BasicType type) { - LLDB_RECORD_METHOD(lldb::SBType, SBTarget, GetBasicType, (lldb::BasicType), - type); + LLDB_INSTRUMENT_VA(this, type); TargetSP target_sp(GetSP()); if (target_sp) { for (auto *type_system : target_sp->GetScratchTypeSystems()) if (auto compiler_type = type_system->GetBasicTypeFromAST(type)) - return LLDB_RECORD_RESULT(SBType(compiler_type)); + return SBType(compiler_type); } - return LLDB_RECORD_RESULT(SBType()); + return SBType(); } lldb::SBTypeList SBTarget::FindTypes(const char *typename_cstr) { - LLDB_RECORD_METHOD(lldb::SBTypeList, SBTarget, FindTypes, (const char *), - typename_cstr); + LLDB_INSTRUMENT_VA(this, typename_cstr); SBTypeList sb_type_list; TargetSP target_sp(GetSP()); @@ -1975,13 +1827,12 @@ lldb::SBTypeList SBTarget::FindTypes(const char *typename_cstr) { sb_type_list.Append(SBType(compiler_type)); } } - return LLDB_RECORD_RESULT(sb_type_list); + return sb_type_list; } SBValueList SBTarget::FindGlobalVariables(const char *name, uint32_t max_matches) { - LLDB_RECORD_METHOD(lldb::SBValueList, SBTarget, FindGlobalVariables, - (const char *, uint32_t), name, max_matches); + LLDB_INSTRUMENT_VA(this, name, max_matches); SBValueList sb_value_list; @@ -2003,15 +1854,13 @@ SBValueList SBTarget::FindGlobalVariables(const char *name, } } - return LLDB_RECORD_RESULT(sb_value_list); + return sb_value_list; } SBValueList SBTarget::FindGlobalVariables(const char *name, uint32_t max_matches, MatchType matchtype) { - LLDB_RECORD_METHOD(lldb::SBValueList, SBTarget, FindGlobalVariables, - (const char *, uint32_t, lldb::MatchType), name, - max_matches, matchtype); + LLDB_INSTRUMENT_VA(this, name, max_matches, matchtype); SBValueList sb_value_list; @@ -2049,40 +1898,36 @@ SBValueList SBTarget::FindGlobalVariables(const char *name, } } - return LLDB_RECORD_RESULT(sb_value_list); + return sb_value_list; } lldb::SBValue SBTarget::FindFirstGlobalVariable(const char *name) { - LLDB_RECORD_METHOD(lldb::SBValue, SBTarget, FindFirstGlobalVariable, - (const char *), name); + LLDB_INSTRUMENT_VA(this, name); SBValueList sb_value_list(FindGlobalVariables(name, 1)); if (sb_value_list.IsValid() && sb_value_list.GetSize() > 0) - return LLDB_RECORD_RESULT(sb_value_list.GetValueAtIndex(0)); - return LLDB_RECORD_RESULT(SBValue()); + return sb_value_list.GetValueAtIndex(0); + return SBValue(); } SBSourceManager SBTarget::GetSourceManager() { - LLDB_RECORD_METHOD_NO_ARGS(lldb::SBSourceManager, SBTarget, GetSourceManager); + LLDB_INSTRUMENT_VA(this); SBSourceManager source_manager(*this); - return LLDB_RECORD_RESULT(source_manager); + return source_manager; } lldb::SBInstructionList SBTarget::ReadInstructions(lldb::SBAddress base_addr, uint32_t count) { - LLDB_RECORD_METHOD(lldb::SBInstructionList, SBTarget, ReadInstructions, - (lldb::SBAddress, uint32_t), base_addr, count); + LLDB_INSTRUMENT_VA(this, base_addr, count); - return LLDB_RECORD_RESULT(ReadInstructions(base_addr, count, nullptr)); + return ReadInstructions(base_addr, count, nullptr); } lldb::SBInstructionList SBTarget::ReadInstructions(lldb::SBAddress base_addr, uint32_t count, const char *flavor_string) { - LLDB_RECORD_METHOD(lldb::SBInstructionList, SBTarget, ReadInstructions, - (lldb::SBAddress, uint32_t, const char *), base_addr, - count, flavor_string); + LLDB_INSTRUMENT_VA(this, base_addr, count, flavor_string); SBInstructionList sb_instructions; @@ -2106,28 +1951,22 @@ lldb::SBInstructionList SBTarget::ReadInstructions(lldb::SBAddress base_addr, } } - return LLDB_RECORD_RESULT(sb_instructions); + return sb_instructions; } lldb::SBInstructionList SBTarget::GetInstructions(lldb::SBAddress base_addr, const void *buf, size_t size) { - LLDB_RECORD_METHOD(lldb::SBInstructionList, SBTarget, GetInstructions, - (lldb::SBAddress, const void *, size_t), base_addr, buf, - size); + LLDB_INSTRUMENT_VA(this, base_addr, buf, size); - return LLDB_RECORD_RESULT( - GetInstructionsWithFlavor(base_addr, nullptr, buf, size)); + return GetInstructionsWithFlavor(base_addr, nullptr, buf, size); } lldb::SBInstructionList SBTarget::GetInstructionsWithFlavor(lldb::SBAddress base_addr, const char *flavor_string, const void *buf, size_t size) { - LLDB_RECORD_METHOD(lldb::SBInstructionList, SBTarget, - GetInstructionsWithFlavor, - (lldb::SBAddress, const char *, const void *, size_t), - base_addr, flavor_string, buf, size); + LLDB_INSTRUMENT_VA(this, base_addr, flavor_string, buf, size); SBInstructionList sb_instructions; @@ -2145,38 +1984,31 @@ SBTarget::GetInstructionsWithFlavor(lldb::SBAddress base_addr, UINT32_MAX, data_from_file)); } - return LLDB_RECORD_RESULT(sb_instructions); + return sb_instructions; } lldb::SBInstructionList SBTarget::GetInstructions(lldb::addr_t base_addr, const void *buf, size_t size) { - LLDB_RECORD_METHOD(lldb::SBInstructionList, SBTarget, GetInstructions, - (lldb::addr_t, const void *, size_t), base_addr, buf, - size); + LLDB_INSTRUMENT_VA(this, base_addr, buf, size); - return LLDB_RECORD_RESULT(GetInstructionsWithFlavor( - ResolveLoadAddress(base_addr), nullptr, buf, size)); + return GetInstructionsWithFlavor(ResolveLoadAddress(base_addr), nullptr, buf, + size); } lldb::SBInstructionList SBTarget::GetInstructionsWithFlavor(lldb::addr_t base_addr, const char *flavor_string, const void *buf, size_t size) { - LLDB_RECORD_METHOD(lldb::SBInstructionList, SBTarget, - GetInstructionsWithFlavor, - (lldb::addr_t, const char *, const void *, size_t), - base_addr, flavor_string, buf, size); + LLDB_INSTRUMENT_VA(this, base_addr, flavor_string, buf, size); - return LLDB_RECORD_RESULT(GetInstructionsWithFlavor( - ResolveLoadAddress(base_addr), flavor_string, buf, size)); + return GetInstructionsWithFlavor(ResolveLoadAddress(base_addr), flavor_string, + buf, size); } SBError SBTarget::SetSectionLoadAddress(lldb::SBSection section, lldb::addr_t section_base_addr) { - LLDB_RECORD_METHOD(lldb::SBError, SBTarget, SetSectionLoadAddress, - (lldb::SBSection, lldb::addr_t), section, - section_base_addr); + LLDB_INSTRUMENT_VA(this, section, section_base_addr); SBError sb_error; TargetSP target_sp(GetSP()); @@ -2208,12 +2040,11 @@ SBError SBTarget::SetSectionLoadAddress(lldb::SBSection section, } else { sb_error.SetErrorString("invalid target"); } - return LLDB_RECORD_RESULT(sb_error); + return sb_error; } SBError SBTarget::ClearSectionLoadAddress(lldb::SBSection section) { - LLDB_RECORD_METHOD(lldb::SBError, SBTarget, ClearSectionLoadAddress, - (lldb::SBSection), section); + LLDB_INSTRUMENT_VA(this, section); SBError sb_error; @@ -2243,13 +2074,12 @@ SBError SBTarget::ClearSectionLoadAddress(lldb::SBSection section) { } else { sb_error.SetErrorStringWithFormat("invalid target"); } - return LLDB_RECORD_RESULT(sb_error); + return sb_error; } SBError SBTarget::SetModuleLoadAddress(lldb::SBModule module, int64_t slide_offset) { - LLDB_RECORD_METHOD(lldb::SBError, SBTarget, SetModuleLoadAddress, - (lldb::SBModule, int64_t), module, slide_offset); + LLDB_INSTRUMENT_VA(this, module, slide_offset); SBError sb_error; @@ -2278,12 +2108,11 @@ SBError SBTarget::SetModuleLoadAddress(lldb::SBModule module, } else { sb_error.SetErrorStringWithFormat("invalid target"); } - return LLDB_RECORD_RESULT(sb_error); + return sb_error; } SBError SBTarget::ClearModuleLoadAddress(lldb::SBModule module) { - LLDB_RECORD_METHOD(lldb::SBError, SBTarget, ClearModuleLoadAddress, - (lldb::SBModule), module); + LLDB_INSTRUMENT_VA(this, module); SBError sb_error; @@ -2330,13 +2159,12 @@ SBError SBTarget::ClearModuleLoadAddress(lldb::SBModule module) { } else { sb_error.SetErrorStringWithFormat("invalid target"); } - return LLDB_RECORD_RESULT(sb_error); + return sb_error; } lldb::SBSymbolContextList SBTarget::FindSymbols(const char *name, lldb::SymbolType symbol_type) { - LLDB_RECORD_METHOD(lldb::SBSymbolContextList, SBTarget, FindSymbols, - (const char *, lldb::SymbolType), name, symbol_type); + LLDB_INSTRUMENT_VA(this, name, symbol_type); SBSymbolContextList sb_sc_list; if (name && name[0]) { @@ -2345,30 +2173,27 @@ lldb::SBSymbolContextList SBTarget::FindSymbols(const char *name, target_sp->GetImages().FindSymbolsWithNameAndType( ConstString(name), symbol_type, *sb_sc_list); } - return LLDB_RECORD_RESULT(sb_sc_list); + return sb_sc_list; } lldb::SBValue SBTarget::EvaluateExpression(const char *expr) { - LLDB_RECORD_METHOD(lldb::SBValue, SBTarget, EvaluateExpression, - (const char *), expr); + LLDB_INSTRUMENT_VA(this, expr); TargetSP target_sp(GetSP()); if (!target_sp) - return LLDB_RECORD_RESULT(SBValue()); + return SBValue(); SBExpressionOptions options; lldb::DynamicValueType fetch_dynamic_value = target_sp->GetPreferDynamicValue(); options.SetFetchDynamicValue(fetch_dynamic_value); options.SetUnwindOnError(true); - return LLDB_RECORD_RESULT(EvaluateExpression(expr, options)); + return EvaluateExpression(expr, options); } lldb::SBValue SBTarget::EvaluateExpression(const char *expr, const SBExpressionOptions &options) { - LLDB_RECORD_METHOD(lldb::SBValue, SBTarget, EvaluateExpression, - (const char *, const lldb::SBExpressionOptions &), expr, - options); + LLDB_INSTRUMENT_VA(this, expr, options); Log *expr_log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS)); SBValue expr_result; @@ -2377,7 +2202,7 @@ lldb::SBValue SBTarget::EvaluateExpression(const char *expr, StackFrame *frame = nullptr; if (target_sp) { if (expr == nullptr || expr[0] == '\0') { - return LLDB_RECORD_RESULT(expr_result); + return expr_result; } std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex()); @@ -2397,11 +2222,11 @@ lldb::SBValue SBTarget::EvaluateExpression(const char *expr, "** [SBTarget::EvaluateExpression] Expression result is " "%s, summary %s **", expr_result.GetValue(), expr_result.GetSummary()); - return LLDB_RECORD_RESULT(expr_result); + return expr_result; } lldb::addr_t SBTarget::GetStackRedZoneSize() { - LLDB_RECORD_METHOD_NO_ARGS(lldb::addr_t, SBTarget, GetStackRedZoneSize); + LLDB_INSTRUMENT_VA(this); TargetSP target_sp(GetSP()); if (target_sp) { @@ -2418,8 +2243,7 @@ lldb::addr_t SBTarget::GetStackRedZoneSize() { } bool SBTarget::IsLoaded(const SBModule &module) const { - LLDB_RECORD_METHOD_CONST(bool, SBTarget, IsLoaded, (const lldb::SBModule &), - module); + LLDB_INSTRUMENT_VA(this, module); TargetSP target_sp(GetSP()); if (!target_sp) @@ -2433,18 +2257,17 @@ bool SBTarget::IsLoaded(const SBModule &module) const { } lldb::SBLaunchInfo SBTarget::GetLaunchInfo() const { - LLDB_RECORD_METHOD_CONST_NO_ARGS(lldb::SBLaunchInfo, SBTarget, GetLaunchInfo); + LLDB_INSTRUMENT_VA(this); lldb::SBLaunchInfo launch_info(nullptr); TargetSP target_sp(GetSP()); if (target_sp) launch_info.set_ref(m_opaque_sp->GetProcessLaunchInfo()); - return LLDB_RECORD_RESULT(launch_info); + return launch_info; } void SBTarget::SetLaunchInfo(const lldb::SBLaunchInfo &launch_info) { - LLDB_RECORD_METHOD(void, SBTarget, SetLaunchInfo, - (const lldb::SBLaunchInfo &), launch_info); + LLDB_INSTRUMENT_VA(this, launch_info); TargetSP target_sp(GetSP()); if (target_sp) @@ -2452,309 +2275,39 @@ void SBTarget::SetLaunchInfo(const lldb::SBLaunchInfo &launch_info) { } SBEnvironment SBTarget::GetEnvironment() { - LLDB_RECORD_METHOD_NO_ARGS(lldb::SBEnvironment, SBTarget, GetEnvironment); + LLDB_INSTRUMENT_VA(this); TargetSP target_sp(GetSP()); if (target_sp) { - return LLDB_RECORD_RESULT(SBEnvironment(target_sp->GetEnvironment())); + return SBEnvironment(target_sp->GetEnvironment()); } - return LLDB_RECORD_RESULT(SBEnvironment()); + return SBEnvironment(); } lldb::SBTrace SBTarget::GetTrace() { - LLDB_RECORD_METHOD_NO_ARGS(lldb::SBTrace, SBTarget, GetTrace); + LLDB_INSTRUMENT_VA(this); TargetSP target_sp(GetSP()); if (target_sp) - return LLDB_RECORD_RESULT(SBTrace(target_sp->GetTrace())); + return SBTrace(target_sp->GetTrace()); - return LLDB_RECORD_RESULT(SBTrace()); + return SBTrace(); } lldb::SBTrace SBTarget::CreateTrace(lldb::SBError &error) { - LLDB_RECORD_METHOD(lldb::SBTrace, SBTarget, CreateTrace, (lldb::SBError &), - error); + LLDB_INSTRUMENT_VA(this, error); TargetSP target_sp(GetSP()); error.Clear(); if (target_sp) { if (llvm::Expected<lldb::TraceSP> trace_sp = target_sp->CreateTrace()) { - return LLDB_RECORD_RESULT(SBTrace(*trace_sp)); + return SBTrace(*trace_sp); } else { error.SetErrorString(llvm::toString(trace_sp.takeError()).c_str()); } } else { error.SetErrorString("missing target"); } - return LLDB_RECORD_RESULT(SBTrace()); -} - -namespace lldb_private { -namespace repro { - -template <> -void RegisterMethods<SBTarget>(Registry &R) { - LLDB_REGISTER_CONSTRUCTOR(SBTarget, ()); - LLDB_REGISTER_CONSTRUCTOR(SBTarget, (const lldb::SBTarget &)); - LLDB_REGISTER_CONSTRUCTOR(SBTarget, (const lldb::TargetSP &)); - LLDB_REGISTER_METHOD(const lldb::SBTarget &, - SBTarget, operator=,(const lldb::SBTarget &)); - LLDB_REGISTER_STATIC_METHOD(bool, SBTarget, EventIsTargetEvent, - (const lldb::SBEvent &)); - LLDB_REGISTER_STATIC_METHOD(lldb::SBTarget, SBTarget, GetTargetFromEvent, - (const lldb::SBEvent &)); - LLDB_REGISTER_STATIC_METHOD(uint32_t, SBTarget, GetNumModulesFromEvent, - (const lldb::SBEvent &)); - LLDB_REGISTER_STATIC_METHOD(lldb::SBModule, SBTarget, - GetModuleAtIndexFromEvent, - (const uint32_t, const lldb::SBEvent &)); - LLDB_REGISTER_STATIC_METHOD(const char *, SBTarget, GetBroadcasterClassName, - ()); - LLDB_REGISTER_METHOD_CONST(bool, SBTarget, IsValid, ()); - LLDB_REGISTER_METHOD_CONST(bool, SBTarget, operator bool, ()); - LLDB_REGISTER_METHOD(lldb::SBProcess, SBTarget, GetProcess, ()); - LLDB_REGISTER_METHOD(lldb::SBPlatform, SBTarget, GetPlatform, ()); - LLDB_REGISTER_METHOD_CONST(lldb::SBDebugger, SBTarget, GetDebugger, ()); - LLDB_REGISTER_METHOD(lldb::SBStructuredData, SBTarget, GetStatistics, ()); - LLDB_REGISTER_METHOD(void, SBTarget, SetCollectingStats, (bool)); - LLDB_REGISTER_METHOD(bool, SBTarget, GetCollectingStats, ()); - LLDB_REGISTER_METHOD(lldb::SBProcess, SBTarget, LoadCore, (const char *)); - LLDB_REGISTER_METHOD(lldb::SBProcess, SBTarget, LoadCore, - (const char *, lldb::SBError &)); - LLDB_REGISTER_METHOD(lldb::SBProcess, SBTarget, LaunchSimple, - (const char **, const char **, const char *)); - LLDB_REGISTER_METHOD(lldb::SBError, SBTarget, Install, ()); - LLDB_REGISTER_METHOD(lldb::SBProcess, SBTarget, Launch, - (lldb::SBListener &, const char **, const char **, - const char *, const char *, const char *, - const char *, uint32_t, bool, lldb::SBError &)); - LLDB_REGISTER_METHOD(lldb::SBProcess, SBTarget, Launch, - (lldb::SBLaunchInfo &, lldb::SBError &)); - LLDB_REGISTER_METHOD(lldb::SBProcess, SBTarget, Attach, - (lldb::SBAttachInfo &, lldb::SBError &)); - LLDB_REGISTER_METHOD(lldb::SBProcess, SBTarget, AttachToProcessWithID, - (lldb::SBListener &, lldb::pid_t, lldb::SBError &)); - LLDB_REGISTER_METHOD( - lldb::SBProcess, SBTarget, AttachToProcessWithName, - (lldb::SBListener &, const char *, bool, lldb::SBError &)); - LLDB_REGISTER_METHOD( - lldb::SBProcess, SBTarget, ConnectRemote, - (lldb::SBListener &, const char *, const char *, lldb::SBError &)); - LLDB_REGISTER_METHOD(lldb::SBFileSpec, SBTarget, GetExecutable, ()); - LLDB_REGISTER_METHOD_CONST(bool, - SBTarget, operator==,(const lldb::SBTarget &)); - LLDB_REGISTER_METHOD_CONST(bool, - SBTarget, operator!=,(const lldb::SBTarget &)); - LLDB_REGISTER_METHOD(lldb::SBAddress, SBTarget, ResolveLoadAddress, - (lldb::addr_t)); - LLDB_REGISTER_METHOD(lldb::SBAddress, SBTarget, ResolveFileAddress, - (lldb::addr_t)); - LLDB_REGISTER_METHOD(lldb::SBAddress, SBTarget, ResolvePastLoadAddress, - (uint32_t, lldb::addr_t)); - LLDB_REGISTER_METHOD(lldb::SBSymbolContext, SBTarget, - ResolveSymbolContextForAddress, - (const lldb::SBAddress &, uint32_t)); - LLDB_REGISTER_METHOD(lldb::SBBreakpoint, SBTarget, - BreakpointCreateByLocation, (const char *, uint32_t)); - LLDB_REGISTER_METHOD(lldb::SBBreakpoint, SBTarget, - BreakpointCreateByLocation, - (const lldb::SBFileSpec &, uint32_t)); - LLDB_REGISTER_METHOD(lldb::SBBreakpoint, SBTarget, - BreakpointCreateByLocation, - (const lldb::SBFileSpec &, uint32_t, lldb::addr_t)); - LLDB_REGISTER_METHOD(lldb::SBBreakpoint, SBTarget, - BreakpointCreateByLocation, - (const lldb::SBFileSpec &, uint32_t, lldb::addr_t, - lldb::SBFileSpecList &)); - LLDB_REGISTER_METHOD(lldb::SBBreakpoint, SBTarget, - BreakpointCreateByLocation, - (const lldb::SBFileSpec &, uint32_t, uint32_t, - lldb::addr_t, lldb::SBFileSpecList &)); - LLDB_REGISTER_METHOD(lldb::SBBreakpoint, SBTarget, BreakpointCreateByLocation, - (const lldb::SBFileSpec &, uint32_t, uint32_t, - lldb::addr_t, lldb::SBFileSpecList &, bool)); - LLDB_REGISTER_METHOD(lldb::SBBreakpoint, SBTarget, BreakpointCreateByName, - (const char *, const char *)); - LLDB_REGISTER_METHOD(lldb::SBBreakpoint, SBTarget, BreakpointCreateByName, - (const char *, const lldb::SBFileSpecList &, - const lldb::SBFileSpecList &)); - LLDB_REGISTER_METHOD(lldb::SBBreakpoint, SBTarget, BreakpointCreateByName, - (const char *, uint32_t, const lldb::SBFileSpecList &, - const lldb::SBFileSpecList &)); - LLDB_REGISTER_METHOD(lldb::SBBreakpoint, SBTarget, BreakpointCreateByName, - (const char *, uint32_t, lldb::LanguageType, - const lldb::SBFileSpecList &, - const lldb::SBFileSpecList &)); - LLDB_REGISTER_METHOD(lldb::SBBreakpoint, SBTarget, BreakpointCreateByNames, - (const char **, uint32_t, uint32_t, - const lldb::SBFileSpecList &, - const lldb::SBFileSpecList &)); - LLDB_REGISTER_METHOD(lldb::SBBreakpoint, SBTarget, BreakpointCreateByNames, - (const char **, uint32_t, uint32_t, lldb::LanguageType, - const lldb::SBFileSpecList &, - const lldb::SBFileSpecList &)); - LLDB_REGISTER_METHOD(lldb::SBBreakpoint, SBTarget, BreakpointCreateByNames, - (const char **, uint32_t, uint32_t, lldb::LanguageType, - lldb::addr_t, const lldb::SBFileSpecList &, - const lldb::SBFileSpecList &)); - LLDB_REGISTER_METHOD(lldb::SBBreakpoint, SBTarget, BreakpointCreateByRegex, - (const char *, const char *)); - LLDB_REGISTER_METHOD(lldb::SBBreakpoint, SBTarget, BreakpointCreateByRegex, - (const char *, const lldb::SBFileSpecList &, - const lldb::SBFileSpecList &)); - LLDB_REGISTER_METHOD(lldb::SBBreakpoint, SBTarget, BreakpointCreateByRegex, - (const char *, lldb::LanguageType, - const lldb::SBFileSpecList &, - const lldb::SBFileSpecList &)); - LLDB_REGISTER_METHOD(lldb::SBBreakpoint, SBTarget, - BreakpointCreateByAddress, (lldb::addr_t)); - LLDB_REGISTER_METHOD(lldb::SBBreakpoint, SBTarget, - BreakpointCreateBySBAddress, (lldb::SBAddress &)); - LLDB_REGISTER_METHOD( - lldb::SBBreakpoint, SBTarget, BreakpointCreateBySourceRegex, - (const char *, const lldb::SBFileSpec &, const char *)); - LLDB_REGISTER_METHOD(lldb::SBBreakpoint, SBTarget, - BreakpointCreateBySourceRegex, - (const char *, const lldb::SBFileSpecList &, - const lldb::SBFileSpecList &)); - LLDB_REGISTER_METHOD( - lldb::SBBreakpoint, SBTarget, BreakpointCreateBySourceRegex, - (const char *, const lldb::SBFileSpecList &, - const lldb::SBFileSpecList &, const lldb::SBStringList &)); - LLDB_REGISTER_METHOD(lldb::SBBreakpoint, SBTarget, - BreakpointCreateForException, - (lldb::LanguageType, bool, bool)); - LLDB_REGISTER_METHOD( - lldb::SBBreakpoint, SBTarget, BreakpointCreateFromScript, - (const char *, lldb::SBStructuredData &, const lldb::SBFileSpecList &, - const lldb::SBFileSpecList &, bool)); - LLDB_REGISTER_METHOD_CONST(uint32_t, SBTarget, GetNumBreakpoints, ()); - LLDB_REGISTER_METHOD_CONST(lldb::SBBreakpoint, SBTarget, - GetBreakpointAtIndex, (uint32_t)); - LLDB_REGISTER_METHOD(bool, SBTarget, BreakpointDelete, (lldb::break_id_t)); - LLDB_REGISTER_METHOD(lldb::SBBreakpoint, SBTarget, FindBreakpointByID, - (lldb::break_id_t)); - LLDB_REGISTER_METHOD(bool, SBTarget, FindBreakpointsByName, - (const char *, lldb::SBBreakpointList &)); - LLDB_REGISTER_METHOD(void, SBTarget, GetBreakpointNames, - (lldb::SBStringList &)); - LLDB_REGISTER_METHOD(void, SBTarget, DeleteBreakpointName, (const char *)); - LLDB_REGISTER_METHOD(bool, SBTarget, EnableAllBreakpoints, ()); - LLDB_REGISTER_METHOD(bool, SBTarget, DisableAllBreakpoints, ()); - LLDB_REGISTER_METHOD(bool, SBTarget, DeleteAllBreakpoints, ()); - LLDB_REGISTER_METHOD(lldb::SBError, SBTarget, BreakpointsCreateFromFile, - (lldb::SBFileSpec &, lldb::SBBreakpointList &)); - LLDB_REGISTER_METHOD( - lldb::SBError, SBTarget, BreakpointsCreateFromFile, - (lldb::SBFileSpec &, lldb::SBStringList &, lldb::SBBreakpointList &)); - LLDB_REGISTER_METHOD(lldb::SBError, SBTarget, BreakpointsWriteToFile, - (lldb::SBFileSpec &)); - LLDB_REGISTER_METHOD(lldb::SBError, SBTarget, BreakpointsWriteToFile, - (lldb::SBFileSpec &, lldb::SBBreakpointList &, bool)); - LLDB_REGISTER_METHOD_CONST(uint32_t, SBTarget, GetNumWatchpoints, ()); - LLDB_REGISTER_METHOD_CONST(lldb::SBWatchpoint, SBTarget, - GetWatchpointAtIndex, (uint32_t)); - LLDB_REGISTER_METHOD(bool, SBTarget, DeleteWatchpoint, (lldb::watch_id_t)); - LLDB_REGISTER_METHOD(lldb::SBWatchpoint, SBTarget, FindWatchpointByID, - (lldb::watch_id_t)); - LLDB_REGISTER_METHOD(lldb::SBWatchpoint, SBTarget, WatchAddress, - (lldb::addr_t, size_t, bool, bool, lldb::SBError &)); - LLDB_REGISTER_METHOD(bool, SBTarget, EnableAllWatchpoints, ()); - LLDB_REGISTER_METHOD(bool, SBTarget, DisableAllWatchpoints, ()); - LLDB_REGISTER_METHOD(lldb::SBValue, SBTarget, CreateValueFromAddress, - (const char *, lldb::SBAddress, lldb::SBType)); - LLDB_REGISTER_METHOD(lldb::SBValue, SBTarget, CreateValueFromData, - (const char *, lldb::SBData, lldb::SBType)); - LLDB_REGISTER_METHOD(lldb::SBValue, SBTarget, CreateValueFromExpression, - (const char *, const char *)); - LLDB_REGISTER_METHOD(bool, SBTarget, DeleteAllWatchpoints, ()); - LLDB_REGISTER_METHOD(void, SBTarget, AppendImageSearchPath, - (const char *, const char *, lldb::SBError &)); - LLDB_REGISTER_METHOD(lldb::SBModule, SBTarget, AddModule, - (const char *, const char *, const char *)); - LLDB_REGISTER_METHOD( - lldb::SBModule, SBTarget, AddModule, - (const char *, const char *, const char *, const char *)); - LLDB_REGISTER_METHOD(lldb::SBModule, SBTarget, AddModule, - (const lldb::SBModuleSpec &)); - LLDB_REGISTER_METHOD(bool, SBTarget, AddModule, (lldb::SBModule &)); - LLDB_REGISTER_METHOD_CONST(uint32_t, SBTarget, GetNumModules, ()); - LLDB_REGISTER_METHOD(void, SBTarget, Clear, ()); - LLDB_REGISTER_METHOD(lldb::SBModule, SBTarget, FindModule, - (const lldb::SBFileSpec &)); - LLDB_REGISTER_METHOD(lldb::SBSymbolContextList, SBTarget, FindCompileUnits, - (const lldb::SBFileSpec &)); - LLDB_REGISTER_METHOD(lldb::ByteOrder, SBTarget, GetByteOrder, ()); - LLDB_REGISTER_METHOD(const char *, SBTarget, GetTriple, ()); - LLDB_REGISTER_METHOD(uint32_t, SBTarget, GetDataByteSize, ()); - LLDB_REGISTER_METHOD(uint32_t, SBTarget, GetCodeByteSize, ()); - LLDB_REGISTER_METHOD_CONST(uint32_t, SBTarget, GetMaximumNumberOfChildrenToDisplay,()); - LLDB_REGISTER_METHOD(uint32_t, SBTarget, GetAddressByteSize, ()); - LLDB_REGISTER_METHOD(lldb::SBModule, SBTarget, GetModuleAtIndex, - (uint32_t)); - LLDB_REGISTER_METHOD(bool, SBTarget, RemoveModule, (lldb::SBModule)); - LLDB_REGISTER_METHOD_CONST(lldb::SBBroadcaster, SBTarget, GetBroadcaster, - ()); - LLDB_REGISTER_METHOD(bool, SBTarget, GetDescription, - (lldb::SBStream &, lldb::DescriptionLevel)); - LLDB_REGISTER_METHOD(lldb::SBSymbolContextList, SBTarget, FindFunctions, - (const char *, uint32_t)); - LLDB_REGISTER_METHOD(lldb::SBSymbolContextList, SBTarget, - FindGlobalFunctions, - (const char *, uint32_t, lldb::MatchType)); - LLDB_REGISTER_METHOD(lldb::SBType, SBTarget, FindFirstType, (const char *)); - LLDB_REGISTER_METHOD(lldb::SBType, SBTarget, GetBasicType, - (lldb::BasicType)); - LLDB_REGISTER_METHOD(lldb::SBTypeList, SBTarget, FindTypes, (const char *)); - LLDB_REGISTER_METHOD(lldb::SBValueList, SBTarget, FindGlobalVariables, - (const char *, uint32_t)); - LLDB_REGISTER_METHOD(lldb::SBValueList, SBTarget, FindGlobalVariables, - (const char *, uint32_t, lldb::MatchType)); - LLDB_REGISTER_METHOD(lldb::SBValue, SBTarget, FindFirstGlobalVariable, - (const char *)); - LLDB_REGISTER_METHOD(lldb::SBSourceManager, SBTarget, GetSourceManager, ()); - LLDB_REGISTER_METHOD(lldb::SBInstructionList, SBTarget, ReadInstructions, - (lldb::SBAddress, uint32_t)); - LLDB_REGISTER_METHOD(lldb::SBInstructionList, SBTarget, ReadInstructions, - (lldb::SBAddress, uint32_t, const char *)); - LLDB_REGISTER_METHOD(lldb::SBError, SBTarget, SetSectionLoadAddress, - (lldb::SBSection, lldb::addr_t)); - LLDB_REGISTER_METHOD(lldb::SBError, SBTarget, ClearSectionLoadAddress, - (lldb::SBSection)); - LLDB_REGISTER_METHOD(lldb::SBError, SBTarget, SetModuleLoadAddress, - (lldb::SBModule, int64_t)); - LLDB_REGISTER_METHOD(lldb::SBError, SBTarget, ClearModuleLoadAddress, - (lldb::SBModule)); - LLDB_REGISTER_METHOD(lldb::SBSymbolContextList, SBTarget, FindSymbols, - (const char *, lldb::SymbolType)); - LLDB_REGISTER_METHOD(lldb::SBValue, SBTarget, EvaluateExpression, - (const char *)); - LLDB_REGISTER_METHOD(lldb::SBValue, SBTarget, EvaluateExpression, - (const char *, const lldb::SBExpressionOptions &)); - LLDB_REGISTER_METHOD(lldb::addr_t, SBTarget, GetStackRedZoneSize, ()); - LLDB_REGISTER_METHOD_CONST(bool, SBTarget, IsLoaded, - (const lldb::SBModule &)); - LLDB_REGISTER_METHOD_CONST(lldb::SBLaunchInfo, SBTarget, GetLaunchInfo, ()); - LLDB_REGISTER_METHOD(void, SBTarget, SetLaunchInfo, - (const lldb::SBLaunchInfo &)); - LLDB_REGISTER_METHOD( - size_t, SBTarget, ReadMemory, - (const lldb::SBAddress, void *, size_t, lldb::SBError &)); - LLDB_REGISTER_METHOD(lldb::SBInstructionList, SBTarget, GetInstructions, - (lldb::SBAddress, const void *, size_t)); - LLDB_REGISTER_METHOD(lldb::SBInstructionList, SBTarget, - GetInstructionsWithFlavor, - (lldb::SBAddress, const char *, const void *, size_t)); - LLDB_REGISTER_METHOD(lldb::SBInstructionList, SBTarget, GetInstructions, - (lldb::addr_t, const void *, size_t)); - LLDB_REGISTER_METHOD(lldb::SBInstructionList, SBTarget, - GetInstructionsWithFlavor, - (lldb::addr_t, const char *, const void *, size_t)); - LLDB_REGISTER_METHOD(lldb::SBEnvironment, SBTarget, GetEnvironment, ()); - LLDB_REGISTER_METHOD(lldb::SBTrace, SBTarget, GetTrace, ()); - LLDB_REGISTER_METHOD(lldb::SBTrace, SBTarget, CreateTrace, (lldb::SBError &)); -} - -} + return SBTrace(); } diff --git a/lldb/source/API/SBThread.cpp b/lldb/source/API/SBThread.cpp index 8d5b6f2a5423..dcc2a6ed3d18 100644 --- a/lldb/source/API/SBThread.cpp +++ b/lldb/source/API/SBThread.cpp @@ -7,7 +7,6 @@ //===----------------------------------------------------------------------===// #include "lldb/API/SBThread.h" -#include "SBReproducerPrivate.h" #include "Utils.h" #include "lldb/API/SBAddress.h" #include "lldb/API/SBDebugger.h" @@ -40,6 +39,7 @@ #include "lldb/Target/ThreadPlanStepInstruction.h" #include "lldb/Target/ThreadPlanStepOut.h" #include "lldb/Target/ThreadPlanStepRange.h" +#include "lldb/Utility/Instrumentation.h" #include "lldb/Utility/State.h" #include "lldb/Utility/Stream.h" #include "lldb/Utility/StructuredData.h" @@ -51,24 +51,23 @@ using namespace lldb; using namespace lldb_private; const char *SBThread::GetBroadcasterClassName() { - LLDB_RECORD_STATIC_METHOD_NO_ARGS(const char *, SBThread, - GetBroadcasterClassName); + LLDB_INSTRUMENT(); return Thread::GetStaticBroadcasterClass().AsCString(); } // Constructors SBThread::SBThread() : m_opaque_sp(new ExecutionContextRef()) { - LLDB_RECORD_CONSTRUCTOR_NO_ARGS(SBThread); + LLDB_INSTRUMENT_VA(this); } SBThread::SBThread(const ThreadSP &lldb_object_sp) : m_opaque_sp(new ExecutionContextRef(lldb_object_sp)) { - LLDB_RECORD_CONSTRUCTOR(SBThread, (const lldb::ThreadSP &), lldb_object_sp); + LLDB_INSTRUMENT_VA(this, lldb_object_sp); } -SBThread::SBThread(const SBThread &rhs) : m_opaque_sp() { - LLDB_RECORD_CONSTRUCTOR(SBThread, (const lldb::SBThread &), rhs); +SBThread::SBThread(const SBThread &rhs) { + LLDB_INSTRUMENT_VA(this, rhs); m_opaque_sp = clone(rhs.m_opaque_sp); } @@ -76,19 +75,18 @@ SBThread::SBThread(const SBThread &rhs) : m_opaque_sp() { // Assignment operator const lldb::SBThread &SBThread::operator=(const SBThread &rhs) { - LLDB_RECORD_METHOD(const lldb::SBThread &, - SBThread, operator=,(const lldb::SBThread &), rhs); + LLDB_INSTRUMENT_VA(this, rhs); if (this != &rhs) m_opaque_sp = clone(rhs.m_opaque_sp); - return LLDB_RECORD_RESULT(*this); + return *this; } // Destructor SBThread::~SBThread() = default; lldb::SBQueue SBThread::GetQueue() const { - LLDB_RECORD_METHOD_CONST_NO_ARGS(lldb::SBQueue, SBThread, GetQueue); + LLDB_INSTRUMENT_VA(this); SBQueue sb_queue; QueueSP queue_sp; @@ -105,15 +103,15 @@ lldb::SBQueue SBThread::GetQueue() const { } } - return LLDB_RECORD_RESULT(sb_queue); + return sb_queue; } bool SBThread::IsValid() const { - LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBThread, IsValid); + LLDB_INSTRUMENT_VA(this); return this->operator bool(); } SBThread::operator bool() const { - LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBThread, operator bool); + LLDB_INSTRUMENT_VA(this); std::unique_lock<std::recursive_mutex> lock; ExecutionContext exe_ctx(m_opaque_sp.get(), lock); @@ -130,13 +128,13 @@ SBThread::operator bool() const { } void SBThread::Clear() { - LLDB_RECORD_METHOD_NO_ARGS(void, SBThread, Clear); + LLDB_INSTRUMENT_VA(this); m_opaque_sp->Clear(); } StopReason SBThread::GetStopReason() { - LLDB_RECORD_METHOD_NO_ARGS(lldb::StopReason, SBThread, GetStopReason); + LLDB_INSTRUMENT_VA(this); StopReason reason = eStopReasonInvalid; std::unique_lock<std::recursive_mutex> lock; @@ -153,7 +151,7 @@ StopReason SBThread::GetStopReason() { } size_t SBThread::GetStopReasonDataCount() { - LLDB_RECORD_METHOD_NO_ARGS(size_t, SBThread, GetStopReasonDataCount); + LLDB_INSTRUMENT_VA(this); std::unique_lock<std::recursive_mutex> lock; ExecutionContext exe_ctx(m_opaque_sp.get(), lock); @@ -210,8 +208,7 @@ size_t SBThread::GetStopReasonDataCount() { } uint64_t SBThread::GetStopReasonDataAtIndex(uint32_t idx) { - LLDB_RECORD_METHOD(uint64_t, SBThread, GetStopReasonDataAtIndex, (uint32_t), - idx); + LLDB_INSTRUMENT_VA(this, idx); std::unique_lock<std::recursive_mutex> lock; ExecutionContext exe_ctx(m_opaque_sp.get(), lock); @@ -280,8 +277,7 @@ uint64_t SBThread::GetStopReasonDataAtIndex(uint32_t idx) { } bool SBThread::GetStopReasonExtendedInfoAsJSON(lldb::SBStream &stream) { - LLDB_RECORD_METHOD(bool, SBThread, GetStopReasonExtendedInfoAsJSON, - (lldb::SBStream &), stream); + LLDB_INSTRUMENT_VA(this, stream); Stream &strm = stream.ref(); @@ -303,9 +299,7 @@ bool SBThread::GetStopReasonExtendedInfoAsJSON(lldb::SBStream &stream) { SBThreadCollection SBThread::GetStopReasonExtendedBacktraces(InstrumentationRuntimeType type) { - LLDB_RECORD_METHOD(lldb::SBThreadCollection, SBThread, - GetStopReasonExtendedBacktraces, - (lldb::InstrumentationRuntimeType), type); + LLDB_INSTRUMENT_VA(this, type); SBThreadCollection threads; @@ -313,23 +307,22 @@ SBThread::GetStopReasonExtendedBacktraces(InstrumentationRuntimeType type) { ExecutionContext exe_ctx(m_opaque_sp.get(), lock); if (!exe_ctx.HasThreadScope()) - return LLDB_RECORD_RESULT(SBThreadCollection()); + return SBThreadCollection(); ProcessSP process_sp = exe_ctx.GetProcessSP(); StopInfoSP stop_info = exe_ctx.GetThreadPtr()->GetStopInfo(); StructuredData::ObjectSP info = stop_info->GetExtendedInfo(); if (!info) - return LLDB_RECORD_RESULT(threads); + return threads; threads = process_sp->GetInstrumentationRuntime(type) ->GetBacktracesFromExtendedStopInfo(info); - return LLDB_RECORD_RESULT(threads); + return threads; } size_t SBThread::GetStopDescription(char *dst, size_t dst_len) { - LLDB_RECORD_CHAR_PTR_METHOD(size_t, SBThread, GetStopDescription, - (char *, size_t), dst, "", dst_len); + LLDB_INSTRUMENT_VA(this, dst, dst_len); std::unique_lock<std::recursive_mutex> lock; ExecutionContext exe_ctx(m_opaque_sp.get(), lock); @@ -357,7 +350,7 @@ size_t SBThread::GetStopDescription(char *dst, size_t dst_len) { } SBValue SBThread::GetStopReturnValue() { - LLDB_RECORD_METHOD_NO_ARGS(lldb::SBValue, SBThread, GetStopReturnValue); + LLDB_INSTRUMENT_VA(this); ValueObjectSP return_valobj_sp; std::unique_lock<std::recursive_mutex> lock; @@ -373,7 +366,7 @@ SBValue SBThread::GetStopReturnValue() { } } - return LLDB_RECORD_RESULT(SBValue(return_valobj_sp)); + return SBValue(return_valobj_sp); } void SBThread::SetThread(const ThreadSP &lldb_object_sp) { @@ -381,7 +374,7 @@ void SBThread::SetThread(const ThreadSP &lldb_object_sp) { } lldb::tid_t SBThread::GetThreadID() const { - LLDB_RECORD_METHOD_CONST_NO_ARGS(lldb::tid_t, SBThread, GetThreadID); + LLDB_INSTRUMENT_VA(this); ThreadSP thread_sp(m_opaque_sp->GetThreadSP()); if (thread_sp) @@ -390,7 +383,7 @@ lldb::tid_t SBThread::GetThreadID() const { } uint32_t SBThread::GetIndexID() const { - LLDB_RECORD_METHOD_CONST_NO_ARGS(uint32_t, SBThread, GetIndexID); + LLDB_INSTRUMENT_VA(this); ThreadSP thread_sp(m_opaque_sp->GetThreadSP()); if (thread_sp) @@ -399,7 +392,7 @@ uint32_t SBThread::GetIndexID() const { } const char *SBThread::GetName() const { - LLDB_RECORD_METHOD_CONST_NO_ARGS(const char *, SBThread, GetName); + LLDB_INSTRUMENT_VA(this); const char *name = nullptr; std::unique_lock<std::recursive_mutex> lock; @@ -416,7 +409,7 @@ const char *SBThread::GetName() const { } const char *SBThread::GetQueueName() const { - LLDB_RECORD_METHOD_CONST_NO_ARGS(const char *, SBThread, GetQueueName); + LLDB_INSTRUMENT_VA(this); const char *name = nullptr; std::unique_lock<std::recursive_mutex> lock; @@ -433,7 +426,7 @@ const char *SBThread::GetQueueName() const { } lldb::queue_id_t SBThread::GetQueueID() const { - LLDB_RECORD_METHOD_CONST_NO_ARGS(lldb::queue_id_t, SBThread, GetQueueID); + LLDB_INSTRUMENT_VA(this); queue_id_t id = LLDB_INVALID_QUEUE_ID; std::unique_lock<std::recursive_mutex> lock; @@ -450,8 +443,7 @@ lldb::queue_id_t SBThread::GetQueueID() const { } bool SBThread::GetInfoItemByPathAsString(const char *path, SBStream &strm) { - LLDB_RECORD_METHOD(bool, SBThread, GetInfoItemByPathAsString, - (const char *, lldb::SBStream &), path, strm); + LLDB_INSTRUMENT_VA(this, path, strm); bool success = false; std::unique_lock<std::recursive_mutex> lock; @@ -532,16 +524,14 @@ SBError SBThread::ResumeNewPlan(ExecutionContext &exe_ctx, } void SBThread::StepOver(lldb::RunMode stop_other_threads) { - LLDB_RECORD_METHOD(void, SBThread, StepOver, (lldb::RunMode), - stop_other_threads); + LLDB_INSTRUMENT_VA(this, stop_other_threads); SBError error; // Ignored StepOver(stop_other_threads, error); } void SBThread::StepOver(lldb::RunMode stop_other_threads, SBError &error) { - LLDB_RECORD_METHOD(void, SBThread, StepOver, (lldb::RunMode, lldb::SBError &), - stop_other_threads, error); + LLDB_INSTRUMENT_VA(this, stop_other_threads, error); std::unique_lock<std::recursive_mutex> lock; ExecutionContext exe_ctx(m_opaque_sp.get(), lock); @@ -573,16 +563,14 @@ void SBThread::StepOver(lldb::RunMode stop_other_threads, SBError &error) { } void SBThread::StepInto(lldb::RunMode stop_other_threads) { - LLDB_RECORD_METHOD(void, SBThread, StepInto, (lldb::RunMode), - stop_other_threads); + LLDB_INSTRUMENT_VA(this, stop_other_threads); StepInto(nullptr, stop_other_threads); } void SBThread::StepInto(const char *target_name, lldb::RunMode stop_other_threads) { - LLDB_RECORD_METHOD(void, SBThread, StepInto, (const char *, lldb::RunMode), - target_name, stop_other_threads); + LLDB_INSTRUMENT_VA(this, target_name, stop_other_threads); SBError error; // Ignored StepInto(target_name, LLDB_INVALID_LINE_NUMBER, error, stop_other_threads); @@ -590,10 +578,7 @@ void SBThread::StepInto(const char *target_name, void SBThread::StepInto(const char *target_name, uint32_t end_line, SBError &error, lldb::RunMode stop_other_threads) { - LLDB_RECORD_METHOD(void, SBThread, StepInto, - (const char *, uint32_t, lldb::SBError &, lldb::RunMode), - target_name, end_line, error, stop_other_threads); - + LLDB_INSTRUMENT_VA(this, target_name, end_line, error, stop_other_threads); std::unique_lock<std::recursive_mutex> lock; ExecutionContext exe_ctx(m_opaque_sp.get(), lock); @@ -640,14 +625,14 @@ void SBThread::StepInto(const char *target_name, uint32_t end_line, } void SBThread::StepOut() { - LLDB_RECORD_METHOD_NO_ARGS(void, SBThread, StepOut); + LLDB_INSTRUMENT_VA(this); SBError error; // Ignored StepOut(error); } void SBThread::StepOut(SBError &error) { - LLDB_RECORD_METHOD(void, SBThread, StepOut, (lldb::SBError &), error); + LLDB_INSTRUMENT_VA(this, error); std::unique_lock<std::recursive_mutex> lock; ExecutionContext exe_ctx(m_opaque_sp.get(), lock); @@ -675,17 +660,14 @@ void SBThread::StepOut(SBError &error) { } void SBThread::StepOutOfFrame(SBFrame &sb_frame) { - LLDB_RECORD_METHOD(void, SBThread, StepOutOfFrame, (lldb::SBFrame &), - sb_frame); + LLDB_INSTRUMENT_VA(this, sb_frame); SBError error; // Ignored StepOutOfFrame(sb_frame, error); } void SBThread::StepOutOfFrame(SBFrame &sb_frame, SBError &error) { - LLDB_RECORD_METHOD(void, SBThread, StepOutOfFrame, - (lldb::SBFrame &, lldb::SBError &), sb_frame, error); - + LLDB_INSTRUMENT_VA(this, sb_frame, error); std::unique_lock<std::recursive_mutex> lock; ExecutionContext exe_ctx(m_opaque_sp.get(), lock); @@ -722,15 +704,14 @@ void SBThread::StepOutOfFrame(SBFrame &sb_frame, SBError &error) { } void SBThread::StepInstruction(bool step_over) { - LLDB_RECORD_METHOD(void, SBThread, StepInstruction, (bool), step_over); + LLDB_INSTRUMENT_VA(this, step_over); SBError error; // Ignored StepInstruction(step_over, error); } void SBThread::StepInstruction(bool step_over, SBError &error) { - LLDB_RECORD_METHOD(void, SBThread, StepInstruction, (bool, lldb::SBError &), - step_over, error); + LLDB_INSTRUMENT_VA(this, step_over, error); std::unique_lock<std::recursive_mutex> lock; ExecutionContext exe_ctx(m_opaque_sp.get(), lock); @@ -752,15 +733,14 @@ void SBThread::StepInstruction(bool step_over, SBError &error) { } void SBThread::RunToAddress(lldb::addr_t addr) { - LLDB_RECORD_METHOD(void, SBThread, RunToAddress, (lldb::addr_t), addr); + LLDB_INSTRUMENT_VA(this, addr); SBError error; // Ignored RunToAddress(addr, error); } void SBThread::RunToAddress(lldb::addr_t addr, SBError &error) { - LLDB_RECORD_METHOD(void, SBThread, RunToAddress, - (lldb::addr_t, lldb::SBError &), addr, error); + LLDB_INSTRUMENT_VA(this, addr, error); std::unique_lock<std::recursive_mutex> lock; ExecutionContext exe_ctx(m_opaque_sp.get(), lock); @@ -789,9 +769,7 @@ void SBThread::RunToAddress(lldb::addr_t addr, SBError &error) { SBError SBThread::StepOverUntil(lldb::SBFrame &sb_frame, lldb::SBFileSpec &sb_file_spec, uint32_t line) { - LLDB_RECORD_METHOD(lldb::SBError, SBThread, StepOverUntil, - (lldb::SBFrame &, lldb::SBFileSpec &, uint32_t), sb_frame, - sb_file_spec, line); + LLDB_INSTRUMENT_VA(this, sb_frame, sb_file_spec, line); SBError sb_error; char path[PATH_MAX]; @@ -807,7 +785,7 @@ SBError SBThread::StepOverUntil(lldb::SBFrame &sb_frame, if (line == 0) { sb_error.SetErrorString("invalid line argument"); - return LLDB_RECORD_RESULT(sb_error); + return sb_error; } if (!frame_sp) { @@ -819,7 +797,7 @@ SBError SBThread::StepOverUntil(lldb::SBFrame &sb_frame, SymbolContext frame_sc; if (!frame_sp) { sb_error.SetErrorString("no valid frames in thread to step"); - return LLDB_RECORD_RESULT(sb_error); + return sb_error; } // If we have a frame, get its line @@ -830,7 +808,7 @@ SBError SBThread::StepOverUntil(lldb::SBFrame &sb_frame, if (frame_sc.comp_unit == nullptr) { sb_error.SetErrorStringWithFormat( "frame %u doesn't have debug information", frame_sp->GetFrameIndex()); - return LLDB_RECORD_RESULT(sb_error); + return sb_error; } FileSpec step_file_spec; @@ -842,7 +820,7 @@ SBError SBThread::StepOverUntil(lldb::SBFrame &sb_frame, step_file_spec = frame_sc.line_entry.file; else { sb_error.SetErrorString("invalid file argument or no file for frame"); - return LLDB_RECORD_RESULT(sb_error); + return sb_error; } } @@ -904,34 +882,28 @@ SBError SBThread::StepOverUntil(lldb::SBFrame &sb_frame, } else { sb_error.SetErrorString("this SBThread object is invalid"); } - return LLDB_RECORD_RESULT(sb_error); + return sb_error; } SBError SBThread::StepUsingScriptedThreadPlan(const char *script_class_name) { - LLDB_RECORD_METHOD(lldb::SBError, SBThread, StepUsingScriptedThreadPlan, - (const char *), script_class_name); + LLDB_INSTRUMENT_VA(this, script_class_name); - return LLDB_RECORD_RESULT( - StepUsingScriptedThreadPlan(script_class_name, true)); + return StepUsingScriptedThreadPlan(script_class_name, true); } SBError SBThread::StepUsingScriptedThreadPlan(const char *script_class_name, bool resume_immediately) { - LLDB_RECORD_METHOD(lldb::SBError, SBThread, StepUsingScriptedThreadPlan, - (const char *, bool), script_class_name, - resume_immediately); + LLDB_INSTRUMENT_VA(this, script_class_name, resume_immediately); lldb::SBStructuredData no_data; - return LLDB_RECORD_RESULT(StepUsingScriptedThreadPlan( - script_class_name, no_data, resume_immediately)); + return StepUsingScriptedThreadPlan(script_class_name, no_data, + resume_immediately); } SBError SBThread::StepUsingScriptedThreadPlan(const char *script_class_name, SBStructuredData &args_data, bool resume_immediately) { - LLDB_RECORD_METHOD(lldb::SBError, SBThread, StepUsingScriptedThreadPlan, - (const char *, lldb::SBStructuredData &, bool), - script_class_name, args_data, resume_immediately); + LLDB_INSTRUMENT_VA(this, script_class_name, args_data, resume_immediately); SBError error; @@ -940,7 +912,7 @@ SBError SBThread::StepUsingScriptedThreadPlan(const char *script_class_name, if (!exe_ctx.HasThreadScope()) { error.SetErrorString("this SBThread object is invalid"); - return LLDB_RECORD_RESULT(error); + return error; } Thread *thread = exe_ctx.GetThreadPtr(); @@ -952,23 +924,22 @@ SBError SBThread::StepUsingScriptedThreadPlan(const char *script_class_name, if (new_plan_status.Fail()) { error.SetErrorString(new_plan_status.AsCString()); - return LLDB_RECORD_RESULT(error); + return error; } if (!resume_immediately) - return LLDB_RECORD_RESULT(error); + return error; if (new_plan_status.Success()) error = ResumeNewPlan(exe_ctx, new_plan_sp.get()); else error.SetErrorString(new_plan_status.AsCString()); - return LLDB_RECORD_RESULT(error); + return error; } SBError SBThread::JumpToLine(lldb::SBFileSpec &file_spec, uint32_t line) { - LLDB_RECORD_METHOD(lldb::SBError, SBThread, JumpToLine, - (lldb::SBFileSpec &, uint32_t), file_spec, line); + LLDB_INSTRUMENT_VA(this, file_spec, line); SBError sb_error; @@ -977,19 +948,18 @@ SBError SBThread::JumpToLine(lldb::SBFileSpec &file_spec, uint32_t line) { if (!exe_ctx.HasThreadScope()) { sb_error.SetErrorString("this SBThread object is invalid"); - return LLDB_RECORD_RESULT(sb_error); + return sb_error; } Thread *thread = exe_ctx.GetThreadPtr(); Status err = thread->JumpToLine(file_spec.ref(), line, true); sb_error.SetError(err); - return LLDB_RECORD_RESULT(sb_error); + return sb_error; } SBError SBThread::ReturnFromFrame(SBFrame &frame, SBValue &return_value) { - LLDB_RECORD_METHOD(lldb::SBError, SBThread, ReturnFromFrame, - (lldb::SBFrame &, lldb::SBValue &), frame, return_value); + LLDB_INSTRUMENT_VA(this, frame, return_value); SBError sb_error; @@ -1002,12 +972,11 @@ SBError SBThread::ReturnFromFrame(SBFrame &frame, SBValue &return_value) { thread->ReturnFromFrame(frame.GetFrameSP(), return_value.GetSP())); } - return LLDB_RECORD_RESULT(sb_error); + return sb_error; } SBError SBThread::UnwindInnermostExpression() { - LLDB_RECORD_METHOD_NO_ARGS(lldb::SBError, SBThread, - UnwindInnermostExpression); + LLDB_INSTRUMENT_VA(this); SBError sb_error; @@ -1021,18 +990,18 @@ SBError SBThread::UnwindInnermostExpression() { thread->SetSelectedFrameByIndex(0, false); } - return LLDB_RECORD_RESULT(sb_error); + return sb_error; } bool SBThread::Suspend() { - LLDB_RECORD_METHOD_NO_ARGS(bool, SBThread, Suspend); + LLDB_INSTRUMENT_VA(this); SBError error; // Ignored return Suspend(error); } bool SBThread::Suspend(SBError &error) { - LLDB_RECORD_METHOD(bool, SBThread, Suspend, (lldb::SBError &), error); + LLDB_INSTRUMENT_VA(this, error); std::unique_lock<std::recursive_mutex> lock; ExecutionContext exe_ctx(m_opaque_sp.get(), lock); @@ -1052,14 +1021,14 @@ bool SBThread::Suspend(SBError &error) { } bool SBThread::Resume() { - LLDB_RECORD_METHOD_NO_ARGS(bool, SBThread, Resume); + LLDB_INSTRUMENT_VA(this); SBError error; // Ignored return Resume(error); } bool SBThread::Resume(SBError &error) { - LLDB_RECORD_METHOD(bool, SBThread, Resume, (lldb::SBError &), error); + LLDB_INSTRUMENT_VA(this, error); std::unique_lock<std::recursive_mutex> lock; ExecutionContext exe_ctx(m_opaque_sp.get(), lock); @@ -1080,7 +1049,7 @@ bool SBThread::Resume(SBError &error) { } bool SBThread::IsSuspended() { - LLDB_RECORD_METHOD_NO_ARGS(bool, SBThread, IsSuspended); + LLDB_INSTRUMENT_VA(this); std::unique_lock<std::recursive_mutex> lock; ExecutionContext exe_ctx(m_opaque_sp.get(), lock); @@ -1091,7 +1060,7 @@ bool SBThread::IsSuspended() { } bool SBThread::IsStopped() { - LLDB_RECORD_METHOD_NO_ARGS(bool, SBThread, IsStopped); + LLDB_INSTRUMENT_VA(this); std::unique_lock<std::recursive_mutex> lock; ExecutionContext exe_ctx(m_opaque_sp.get(), lock); @@ -1102,7 +1071,7 @@ bool SBThread::IsStopped() { } SBProcess SBThread::GetProcess() { - LLDB_RECORD_METHOD_NO_ARGS(lldb::SBProcess, SBThread, GetProcess); + LLDB_INSTRUMENT_VA(this); SBProcess sb_process; std::unique_lock<std::recursive_mutex> lock; @@ -1114,11 +1083,11 @@ SBProcess SBThread::GetProcess() { sb_process.SetSP(exe_ctx.GetProcessSP()); } - return LLDB_RECORD_RESULT(sb_process); + return sb_process; } uint32_t SBThread::GetNumFrames() { - LLDB_RECORD_METHOD_NO_ARGS(uint32_t, SBThread, GetNumFrames); + LLDB_INSTRUMENT_VA(this); uint32_t num_frames = 0; std::unique_lock<std::recursive_mutex> lock; @@ -1135,7 +1104,7 @@ uint32_t SBThread::GetNumFrames() { } SBFrame SBThread::GetFrameAtIndex(uint32_t idx) { - LLDB_RECORD_METHOD(lldb::SBFrame, SBThread, GetFrameAtIndex, (uint32_t), idx); + LLDB_INSTRUMENT_VA(this, idx); SBFrame sb_frame; StackFrameSP frame_sp; @@ -1150,11 +1119,11 @@ SBFrame SBThread::GetFrameAtIndex(uint32_t idx) { } } - return LLDB_RECORD_RESULT(sb_frame); + return sb_frame; } lldb::SBFrame SBThread::GetSelectedFrame() { - LLDB_RECORD_METHOD_NO_ARGS(lldb::SBFrame, SBThread, GetSelectedFrame); + LLDB_INSTRUMENT_VA(this); SBFrame sb_frame; StackFrameSP frame_sp; @@ -1169,12 +1138,11 @@ lldb::SBFrame SBThread::GetSelectedFrame() { } } - return LLDB_RECORD_RESULT(sb_frame); + return sb_frame; } lldb::SBFrame SBThread::SetSelectedFrame(uint32_t idx) { - LLDB_RECORD_METHOD(lldb::SBFrame, SBThread, SetSelectedFrame, (uint32_t), - idx); + LLDB_INSTRUMENT_VA(this, idx); SBFrame sb_frame; StackFrameSP frame_sp; @@ -1193,51 +1161,43 @@ lldb::SBFrame SBThread::SetSelectedFrame(uint32_t idx) { } } - return LLDB_RECORD_RESULT(sb_frame); + return sb_frame; } bool SBThread::EventIsThreadEvent(const SBEvent &event) { - LLDB_RECORD_STATIC_METHOD(bool, SBThread, EventIsThreadEvent, - (const lldb::SBEvent &), event); + LLDB_INSTRUMENT_VA(event); return Thread::ThreadEventData::GetEventDataFromEvent(event.get()) != nullptr; } SBFrame SBThread::GetStackFrameFromEvent(const SBEvent &event) { - LLDB_RECORD_STATIC_METHOD(lldb::SBFrame, SBThread, GetStackFrameFromEvent, - (const lldb::SBEvent &), event); + LLDB_INSTRUMENT_VA(event); - return LLDB_RECORD_RESULT( - Thread::ThreadEventData::GetStackFrameFromEvent(event.get())); + return Thread::ThreadEventData::GetStackFrameFromEvent(event.get()); } SBThread SBThread::GetThreadFromEvent(const SBEvent &event) { - LLDB_RECORD_STATIC_METHOD(lldb::SBThread, SBThread, GetThreadFromEvent, - (const lldb::SBEvent &), event); + LLDB_INSTRUMENT_VA(event); - return LLDB_RECORD_RESULT( - Thread::ThreadEventData::GetThreadFromEvent(event.get())); + return Thread::ThreadEventData::GetThreadFromEvent(event.get()); } bool SBThread::operator==(const SBThread &rhs) const { - LLDB_RECORD_METHOD_CONST(bool, SBThread, operator==,(const lldb::SBThread &), - rhs); + LLDB_INSTRUMENT_VA(this, rhs); return m_opaque_sp->GetThreadSP().get() == rhs.m_opaque_sp->GetThreadSP().get(); } bool SBThread::operator!=(const SBThread &rhs) const { - LLDB_RECORD_METHOD_CONST(bool, SBThread, operator!=,(const lldb::SBThread &), - rhs); + LLDB_INSTRUMENT_VA(this, rhs); return m_opaque_sp->GetThreadSP().get() != rhs.m_opaque_sp->GetThreadSP().get(); } bool SBThread::GetStatus(SBStream &status) const { - LLDB_RECORD_METHOD_CONST(bool, SBThread, GetStatus, (lldb::SBStream &), - status); + LLDB_INSTRUMENT_VA(this, status); Stream &strm = status.ref(); @@ -1253,15 +1213,13 @@ bool SBThread::GetStatus(SBStream &status) const { } bool SBThread::GetDescription(SBStream &description) const { - LLDB_RECORD_METHOD_CONST(bool, SBThread, GetDescription, (lldb::SBStream &), - description); + LLDB_INSTRUMENT_VA(this, description); return GetDescription(description, false); } bool SBThread::GetDescription(SBStream &description, bool stop_format) const { - LLDB_RECORD_METHOD_CONST(bool, SBThread, GetDescription, - (lldb::SBStream &, bool), description, stop_format); + LLDB_INSTRUMENT_VA(this, description, stop_format); Stream &strm = description.ref(); @@ -1281,8 +1239,7 @@ bool SBThread::GetDescription(SBStream &description, bool stop_format) const { } SBThread SBThread::GetExtendedBacktraceThread(const char *type) { - LLDB_RECORD_METHOD(lldb::SBThread, SBThread, GetExtendedBacktraceThread, - (const char *), type); + LLDB_INSTRUMENT_VA(this, type); std::unique_lock<std::recursive_mutex> lock; ExecutionContext exe_ctx(m_opaque_sp.get(), lock); @@ -1312,12 +1269,11 @@ SBThread SBThread::GetExtendedBacktraceThread(const char *type) { } } - return LLDB_RECORD_RESULT(sb_origin_thread); + return sb_origin_thread; } uint32_t SBThread::GetExtendedBacktraceOriginatingIndexID() { - LLDB_RECORD_METHOD_NO_ARGS(uint32_t, SBThread, - GetExtendedBacktraceOriginatingIndexID); + LLDB_INSTRUMENT_VA(this); ThreadSP thread_sp(m_opaque_sp->GetThreadSP()); if (thread_sp) @@ -1326,29 +1282,27 @@ uint32_t SBThread::GetExtendedBacktraceOriginatingIndexID() { } SBValue SBThread::GetCurrentException() { - LLDB_RECORD_METHOD_NO_ARGS(lldb::SBValue, SBThread, GetCurrentException); + LLDB_INSTRUMENT_VA(this); ThreadSP thread_sp(m_opaque_sp->GetThreadSP()); if (!thread_sp) - return LLDB_RECORD_RESULT(SBValue()); + return SBValue(); - return LLDB_RECORD_RESULT(SBValue(thread_sp->GetCurrentException())); + return SBValue(thread_sp->GetCurrentException()); } SBThread SBThread::GetCurrentExceptionBacktrace() { - LLDB_RECORD_METHOD_NO_ARGS(lldb::SBThread, SBThread, - GetCurrentExceptionBacktrace); + LLDB_INSTRUMENT_VA(this); ThreadSP thread_sp(m_opaque_sp->GetThreadSP()); if (!thread_sp) - return LLDB_RECORD_RESULT(SBThread()); + return SBThread(); - return LLDB_RECORD_RESULT( - SBThread(thread_sp->GetCurrentExceptionBacktrace())); + return SBThread(thread_sp->GetCurrentExceptionBacktrace()); } bool SBThread::SafeToCallFunctions() { - LLDB_RECORD_METHOD_NO_ARGS(bool, SBThread, SafeToCallFunctions); + LLDB_INSTRUMENT_VA(this); ThreadSP thread_sp(m_opaque_sp->GetThreadSP()); if (thread_sp) @@ -1364,109 +1318,49 @@ lldb_private::Thread *SBThread::get() { return m_opaque_sp->GetThreadSP().get(); } -namespace lldb_private { -namespace repro { - -template <> -void RegisterMethods<SBThread>(Registry &R) { - LLDB_REGISTER_STATIC_METHOD(const char *, SBThread, GetBroadcasterClassName, - ()); - LLDB_REGISTER_CONSTRUCTOR(SBThread, ()); - LLDB_REGISTER_CONSTRUCTOR(SBThread, (const lldb::ThreadSP &)); - LLDB_REGISTER_CONSTRUCTOR(SBThread, (const lldb::SBThread &)); - LLDB_REGISTER_METHOD(const lldb::SBThread &, - SBThread, operator=,(const lldb::SBThread &)); - LLDB_REGISTER_METHOD_CONST(lldb::SBQueue, SBThread, GetQueue, ()); - LLDB_REGISTER_METHOD_CONST(bool, SBThread, IsValid, ()); - LLDB_REGISTER_METHOD_CONST(bool, SBThread, operator bool, ()); - LLDB_REGISTER_METHOD(void, SBThread, Clear, ()); - LLDB_REGISTER_METHOD(lldb::StopReason, SBThread, GetStopReason, ()); - LLDB_REGISTER_METHOD(size_t, SBThread, GetStopReasonDataCount, ()); - LLDB_REGISTER_METHOD(uint64_t, SBThread, GetStopReasonDataAtIndex, - (uint32_t)); - LLDB_REGISTER_METHOD(bool, SBThread, GetStopReasonExtendedInfoAsJSON, - (lldb::SBStream &)); - LLDB_REGISTER_METHOD(lldb::SBThreadCollection, SBThread, - GetStopReasonExtendedBacktraces, - (lldb::InstrumentationRuntimeType)); - LLDB_REGISTER_METHOD(lldb::SBValue, SBThread, GetStopReturnValue, ()); - LLDB_REGISTER_METHOD_CONST(lldb::tid_t, SBThread, GetThreadID, ()); - LLDB_REGISTER_METHOD_CONST(uint32_t, SBThread, GetIndexID, ()); - LLDB_REGISTER_METHOD_CONST(const char *, SBThread, GetName, ()); - LLDB_REGISTER_METHOD_CONST(const char *, SBThread, GetQueueName, ()); - LLDB_REGISTER_METHOD_CONST(lldb::queue_id_t, SBThread, GetQueueID, ()); - LLDB_REGISTER_METHOD(bool, SBThread, GetInfoItemByPathAsString, - (const char *, lldb::SBStream &)); - LLDB_REGISTER_METHOD(void, SBThread, StepOver, (lldb::RunMode)); - LLDB_REGISTER_METHOD(void, SBThread, StepOver, - (lldb::RunMode, lldb::SBError &)); - LLDB_REGISTER_METHOD(void, SBThread, StepInto, (lldb::RunMode)); - LLDB_REGISTER_METHOD(void, SBThread, StepInto, - (const char *, lldb::RunMode)); - LLDB_REGISTER_METHOD( - void, SBThread, StepInto, - (const char *, uint32_t, lldb::SBError &, lldb::RunMode)); - LLDB_REGISTER_METHOD(void, SBThread, StepOut, ()); - LLDB_REGISTER_METHOD(void, SBThread, StepOut, (lldb::SBError &)); - LLDB_REGISTER_METHOD(void, SBThread, StepOutOfFrame, (lldb::SBFrame &)); - LLDB_REGISTER_METHOD(void, SBThread, StepOutOfFrame, - (lldb::SBFrame &, lldb::SBError &)); - LLDB_REGISTER_METHOD(void, SBThread, StepInstruction, (bool)); - LLDB_REGISTER_METHOD(void, SBThread, StepInstruction, - (bool, lldb::SBError &)); - LLDB_REGISTER_METHOD(void, SBThread, RunToAddress, (lldb::addr_t)); - LLDB_REGISTER_METHOD(void, SBThread, RunToAddress, - (lldb::addr_t, lldb::SBError &)); - LLDB_REGISTER_METHOD(lldb::SBError, SBThread, StepOverUntil, - (lldb::SBFrame &, lldb::SBFileSpec &, uint32_t)); - LLDB_REGISTER_METHOD(lldb::SBError, SBThread, StepUsingScriptedThreadPlan, - (const char *)); - LLDB_REGISTER_METHOD(lldb::SBError, SBThread, StepUsingScriptedThreadPlan, - (const char *, bool)); - LLDB_REGISTER_METHOD(lldb::SBError, SBThread, StepUsingScriptedThreadPlan, - (const char *, SBStructuredData &, bool)); - LLDB_REGISTER_METHOD(lldb::SBError, SBThread, JumpToLine, - (lldb::SBFileSpec &, uint32_t)); - LLDB_REGISTER_METHOD(lldb::SBError, SBThread, ReturnFromFrame, - (lldb::SBFrame &, lldb::SBValue &)); - LLDB_REGISTER_METHOD(lldb::SBError, SBThread, UnwindInnermostExpression, - ()); - LLDB_REGISTER_METHOD(bool, SBThread, Suspend, ()); - LLDB_REGISTER_METHOD(bool, SBThread, Suspend, (lldb::SBError &)); - LLDB_REGISTER_METHOD(bool, SBThread, Resume, ()); - LLDB_REGISTER_METHOD(bool, SBThread, Resume, (lldb::SBError &)); - LLDB_REGISTER_METHOD(bool, SBThread, IsSuspended, ()); - LLDB_REGISTER_METHOD(bool, SBThread, IsStopped, ()); - LLDB_REGISTER_METHOD(lldb::SBProcess, SBThread, GetProcess, ()); - LLDB_REGISTER_METHOD(uint32_t, SBThread, GetNumFrames, ()); - LLDB_REGISTER_METHOD(lldb::SBFrame, SBThread, GetFrameAtIndex, (uint32_t)); - LLDB_REGISTER_METHOD(lldb::SBFrame, SBThread, GetSelectedFrame, ()); - LLDB_REGISTER_METHOD(lldb::SBFrame, SBThread, SetSelectedFrame, (uint32_t)); - LLDB_REGISTER_STATIC_METHOD(bool, SBThread, EventIsThreadEvent, - (const lldb::SBEvent &)); - LLDB_REGISTER_STATIC_METHOD(lldb::SBFrame, SBThread, GetStackFrameFromEvent, - (const lldb::SBEvent &)); - LLDB_REGISTER_STATIC_METHOD(lldb::SBThread, SBThread, GetThreadFromEvent, - (const lldb::SBEvent &)); - LLDB_REGISTER_METHOD_CONST(bool, - SBThread, operator==,(const lldb::SBThread &)); - LLDB_REGISTER_METHOD_CONST(bool, - SBThread, operator!=,(const lldb::SBThread &)); - LLDB_REGISTER_METHOD_CONST(bool, SBThread, GetStatus, (lldb::SBStream &)); - LLDB_REGISTER_METHOD_CONST(bool, SBThread, GetDescription, - (lldb::SBStream &)); - LLDB_REGISTER_METHOD_CONST(bool, SBThread, GetDescription, - (lldb::SBStream &, bool)); - LLDB_REGISTER_METHOD(lldb::SBThread, SBThread, GetExtendedBacktraceThread, - (const char *)); - LLDB_REGISTER_METHOD(uint32_t, SBThread, - GetExtendedBacktraceOriginatingIndexID, ()); - LLDB_REGISTER_METHOD(lldb::SBValue, SBThread, GetCurrentException, ()); - LLDB_REGISTER_METHOD(lldb::SBThread, SBThread, GetCurrentExceptionBacktrace, - ()); - LLDB_REGISTER_METHOD(bool, SBThread, SafeToCallFunctions, ()); - LLDB_REGISTER_CHAR_PTR_METHOD(size_t, SBThread, GetStopDescription); -} +SBValue SBThread::GetSiginfo(SBError &error) { + LLDB_INSTRUMENT_VA(this, error); -} + SBValue value; + SBProcess process = GetProcess(); + if (!process.IsValid()) { + error.SetErrorString("no process"); + return value; + } + SBTarget target = process.GetTarget(); + if (!target.IsValid()) { + error.SetErrorString("unable to get target"); + return value; + } + SBPlatform platform = target.GetPlatform(); + if (!platform.IsValid()) { + error.SetErrorString("unable to get platform"); + return value; + } + CompilerType type = platform.GetSP()->GetSiginfoType( + target.GetSP()->GetArchitecture().GetTriple()); + if (!type.IsValid()) { + error.SetErrorString("no siginfo_t for the platform"); + return value; + } + llvm::Optional<uint64_t> type_size = type.GetByteSize(nullptr); + assert(type_size); + ThreadSP thread_sp = m_opaque_sp->GetThreadSP(); + if (!thread_sp) { + error.SetErrorString("unable to get thread"); + return value; + } + llvm::Expected<std::unique_ptr<llvm::MemoryBuffer>> data = + thread_sp->GetSiginfo(type_size.getValue()); + if (!data) { + error.SetErrorString(llvm::toString(data.takeError()).c_str()); + return value; + } + SBData sb_data; + sb_data.SetData(error, data.get()->getBufferStart(), + data.get()->getBufferSize(), process.GetByteOrder(), 0); + if (!sb_data.IsValid()) + return value; + + return target.CreateValueFromData("siginfo", sb_data, type); } diff --git a/lldb/source/API/SBThreadCollection.cpp b/lldb/source/API/SBThreadCollection.cpp index bfca864d6bcd..9d688e012239 100644 --- a/lldb/source/API/SBThreadCollection.cpp +++ b/lldb/source/API/SBThreadCollection.cpp @@ -7,32 +7,27 @@ //===----------------------------------------------------------------------===// #include "lldb/API/SBThreadCollection.h" -#include "SBReproducerPrivate.h" #include "lldb/API/SBThread.h" #include "lldb/Target/ThreadList.h" +#include "lldb/Utility/Instrumentation.h" using namespace lldb; using namespace lldb_private; -SBThreadCollection::SBThreadCollection() : m_opaque_sp() { - LLDB_RECORD_CONSTRUCTOR_NO_ARGS(SBThreadCollection); -} +SBThreadCollection::SBThreadCollection() { LLDB_INSTRUMENT_VA(this); } SBThreadCollection::SBThreadCollection(const SBThreadCollection &rhs) : m_opaque_sp(rhs.m_opaque_sp) { - LLDB_RECORD_CONSTRUCTOR(SBThreadCollection, - (const lldb::SBThreadCollection &), rhs); + LLDB_INSTRUMENT_VA(this, rhs); } const SBThreadCollection &SBThreadCollection:: operator=(const SBThreadCollection &rhs) { - LLDB_RECORD_METHOD( - const lldb::SBThreadCollection &, - SBThreadCollection, operator=,(const lldb::SBThreadCollection &), rhs); + LLDB_INSTRUMENT_VA(this, rhs); if (this != &rhs) m_opaque_sp = rhs.m_opaque_sp; - return LLDB_RECORD_RESULT(*this); + return *this; } SBThreadCollection::SBThreadCollection(const ThreadCollectionSP &threads) @@ -61,17 +56,17 @@ const lldb::ThreadCollectionSP &SBThreadCollection::operator*() const { } bool SBThreadCollection::IsValid() const { - LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBThreadCollection, IsValid); + LLDB_INSTRUMENT_VA(this); return this->operator bool(); } SBThreadCollection::operator bool() const { - LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBThreadCollection, operator bool); + LLDB_INSTRUMENT_VA(this); return m_opaque_sp.get() != nullptr; } size_t SBThreadCollection::GetSize() { - LLDB_RECORD_METHOD_NO_ARGS(size_t, SBThreadCollection, GetSize); + LLDB_INSTRUMENT_VA(this); if (m_opaque_sp) return m_opaque_sp->GetSize(); @@ -79,32 +74,10 @@ size_t SBThreadCollection::GetSize() { } SBThread SBThreadCollection::GetThreadAtIndex(size_t idx) { - LLDB_RECORD_METHOD(lldb::SBThread, SBThreadCollection, GetThreadAtIndex, - (size_t), idx); + LLDB_INSTRUMENT_VA(this, idx); SBThread thread; if (m_opaque_sp && idx < m_opaque_sp->GetSize()) thread = m_opaque_sp->GetThreadAtIndex(idx); - return LLDB_RECORD_RESULT(thread); -} - -namespace lldb_private { -namespace repro { - -template <> -void RegisterMethods<SBThreadCollection>(Registry &R) { - LLDB_REGISTER_CONSTRUCTOR(SBThreadCollection, ()); - LLDB_REGISTER_CONSTRUCTOR(SBThreadCollection, - (const lldb::SBThreadCollection &)); - LLDB_REGISTER_METHOD( - const lldb::SBThreadCollection &, - SBThreadCollection, operator=,(const lldb::SBThreadCollection &)); - LLDB_REGISTER_METHOD_CONST(bool, SBThreadCollection, IsValid, ()); - LLDB_REGISTER_METHOD_CONST(bool, SBThreadCollection, operator bool, ()); - LLDB_REGISTER_METHOD(size_t, SBThreadCollection, GetSize, ()); - LLDB_REGISTER_METHOD(lldb::SBThread, SBThreadCollection, GetThreadAtIndex, - (size_t)); -} - -} + return thread; } diff --git a/lldb/source/API/SBThreadPlan.cpp b/lldb/source/API/SBThreadPlan.cpp index 99ecb321595f..2e66ac120839 100644 --- a/lldb/source/API/SBThreadPlan.cpp +++ b/lldb/source/API/SBThreadPlan.cpp @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#include "SBReproducerPrivate.h" #include "lldb/API/SBThread.h" +#include "lldb/Utility/Instrumentation.h" #include "lldb/API/SBFileSpec.h" #include "lldb/API/SBStream.h" @@ -50,22 +50,20 @@ using namespace lldb; using namespace lldb_private; // Constructors -SBThreadPlan::SBThreadPlan() { LLDB_RECORD_CONSTRUCTOR_NO_ARGS(SBThreadPlan); } +SBThreadPlan::SBThreadPlan() { LLDB_INSTRUMENT_VA(this); } SBThreadPlan::SBThreadPlan(const ThreadPlanSP &lldb_object_sp) : m_opaque_wp(lldb_object_sp) { - LLDB_RECORD_CONSTRUCTOR(SBThreadPlan, (const lldb::ThreadPlanSP &), - lldb_object_sp); + LLDB_INSTRUMENT_VA(this, lldb_object_sp); } SBThreadPlan::SBThreadPlan(const SBThreadPlan &rhs) : m_opaque_wp(rhs.m_opaque_wp) { - LLDB_RECORD_CONSTRUCTOR(SBThreadPlan, (const lldb::SBThreadPlan &), rhs); + LLDB_INSTRUMENT_VA(this, rhs); } SBThreadPlan::SBThreadPlan(lldb::SBThread &sb_thread, const char *class_name) { - LLDB_RECORD_CONSTRUCTOR(SBThreadPlan, (lldb::SBThread &, const char *), - sb_thread, class_name); + LLDB_INSTRUMENT_VA(this, sb_thread, class_name); Thread *thread = sb_thread.get(); if (thread) @@ -75,9 +73,7 @@ SBThreadPlan::SBThreadPlan(lldb::SBThread &sb_thread, const char *class_name) { SBThreadPlan::SBThreadPlan(lldb::SBThread &sb_thread, const char *class_name, lldb::SBStructuredData &args_data) { - LLDB_RECORD_CONSTRUCTOR(SBThreadPlan, (lldb::SBThread &, const char *, - SBStructuredData &), - sb_thread, class_name, args_data); + LLDB_INSTRUMENT_VA(this, sb_thread, class_name, args_data); Thread *thread = sb_thread.get(); if (thread) @@ -88,65 +84,61 @@ SBThreadPlan::SBThreadPlan(lldb::SBThread &sb_thread, const char *class_name, // Assignment operator const lldb::SBThreadPlan &SBThreadPlan::operator=(const SBThreadPlan &rhs) { - LLDB_RECORD_METHOD(const lldb::SBThreadPlan &, - SBThreadPlan, operator=,(const lldb::SBThreadPlan &), rhs); + LLDB_INSTRUMENT_VA(this, rhs); if (this != &rhs) m_opaque_wp = rhs.m_opaque_wp; - return LLDB_RECORD_RESULT(*this); + return *this; } // Destructor SBThreadPlan::~SBThreadPlan() = default; bool SBThreadPlan::IsValid() const { - LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBThreadPlan, IsValid); + LLDB_INSTRUMENT_VA(this); return this->operator bool(); } SBThreadPlan::operator bool() const { - LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBThreadPlan, operator bool); + LLDB_INSTRUMENT_VA(this); return static_cast<bool>(GetSP()); } void SBThreadPlan::Clear() { - LLDB_RECORD_METHOD_NO_ARGS(void, SBThreadPlan, Clear); + LLDB_INSTRUMENT_VA(this); m_opaque_wp.reset(); } lldb::StopReason SBThreadPlan::GetStopReason() { - LLDB_RECORD_METHOD_NO_ARGS(lldb::StopReason, SBThreadPlan, GetStopReason); + LLDB_INSTRUMENT_VA(this); return eStopReasonNone; } size_t SBThreadPlan::GetStopReasonDataCount() { - LLDB_RECORD_METHOD_NO_ARGS(size_t, SBThreadPlan, GetStopReasonDataCount); + LLDB_INSTRUMENT_VA(this); return 0; } uint64_t SBThreadPlan::GetStopReasonDataAtIndex(uint32_t idx) { - LLDB_RECORD_METHOD(uint64_t, SBThreadPlan, GetStopReasonDataAtIndex, - (uint32_t), idx); + LLDB_INSTRUMENT_VA(this, idx); return 0; } SBThread SBThreadPlan::GetThread() const { - LLDB_RECORD_METHOD_CONST_NO_ARGS(lldb::SBThread, SBThreadPlan, GetThread); + LLDB_INSTRUMENT_VA(this); ThreadPlanSP thread_plan_sp(GetSP()); if (thread_plan_sp) { - return LLDB_RECORD_RESULT( - SBThread(thread_plan_sp->GetThread().shared_from_this())); + return SBThread(thread_plan_sp->GetThread().shared_from_this()); } else - return LLDB_RECORD_RESULT(SBThread()); + return SBThread(); } bool SBThreadPlan::GetDescription(lldb::SBStream &description) const { - LLDB_RECORD_METHOD_CONST(bool, SBThreadPlan, GetDescription, - (lldb::SBStream &), description); + LLDB_INSTRUMENT_VA(this, description); ThreadPlanSP thread_plan_sp(GetSP()); if (thread_plan_sp) { @@ -162,7 +154,7 @@ void SBThreadPlan::SetThreadPlan(const ThreadPlanSP &lldb_object_wp) { } void SBThreadPlan::SetPlanComplete(bool success) { - LLDB_RECORD_METHOD(void, SBThreadPlan, SetPlanComplete, (bool), success); + LLDB_INSTRUMENT_VA(this, success); ThreadPlanSP thread_plan_sp(GetSP()); if (thread_plan_sp) @@ -170,7 +162,7 @@ void SBThreadPlan::SetPlanComplete(bool success) { } bool SBThreadPlan::IsPlanComplete() { - LLDB_RECORD_METHOD_NO_ARGS(bool, SBThreadPlan, IsPlanComplete); + LLDB_INSTRUMENT_VA(this); ThreadPlanSP thread_plan_sp(GetSP()); if (thread_plan_sp) @@ -179,7 +171,7 @@ bool SBThreadPlan::IsPlanComplete() { } bool SBThreadPlan::IsPlanStale() { - LLDB_RECORD_METHOD_NO_ARGS(bool, SBThreadPlan, IsPlanStale); + LLDB_INSTRUMENT_VA(this); ThreadPlanSP thread_plan_sp(GetSP()); if (thread_plan_sp) @@ -188,7 +180,7 @@ bool SBThreadPlan::IsPlanStale() { } bool SBThreadPlan::IsValid() { - LLDB_RECORD_METHOD_NO_ARGS(bool, SBThreadPlan, IsValid); + LLDB_INSTRUMENT_VA(this); ThreadPlanSP thread_plan_sp(GetSP()); if (thread_plan_sp) @@ -197,7 +189,7 @@ bool SBThreadPlan::IsValid() { } bool SBThreadPlan::GetStopOthers() { - LLDB_RECORD_METHOD_NO_ARGS(bool, SBThreadPlan, GetStopOthers); + LLDB_INSTRUMENT_VA(this); ThreadPlanSP thread_plan_sp(GetSP()); if (thread_plan_sp) @@ -206,7 +198,7 @@ bool SBThreadPlan::GetStopOthers() { } void SBThreadPlan::SetStopOthers(bool stop_others) { - LLDB_RECORD_METHOD(void, SBThreadPlan, SetStopOthers, (bool), stop_others); + LLDB_INSTRUMENT_VA(this, stop_others); ThreadPlanSP thread_plan_sp(GetSP()); if (thread_plan_sp) @@ -222,27 +214,21 @@ void SBThreadPlan::SetStopOthers(bool stop_others) { SBThreadPlan SBThreadPlan::QueueThreadPlanForStepOverRange(SBAddress &sb_start_address, lldb::addr_t size) { - LLDB_RECORD_METHOD(lldb::SBThreadPlan, SBThreadPlan, - QueueThreadPlanForStepOverRange, - (lldb::SBAddress &, lldb::addr_t), sb_start_address, size); + LLDB_INSTRUMENT_VA(this, sb_start_address, size); SBError error; - return LLDB_RECORD_RESULT( - QueueThreadPlanForStepOverRange(sb_start_address, size, error)); + return QueueThreadPlanForStepOverRange(sb_start_address, size, error); } SBThreadPlan SBThreadPlan::QueueThreadPlanForStepOverRange( SBAddress &sb_start_address, lldb::addr_t size, SBError &error) { - LLDB_RECORD_METHOD(lldb::SBThreadPlan, SBThreadPlan, - QueueThreadPlanForStepOverRange, - (lldb::SBAddress &, lldb::addr_t, lldb::SBError &), - sb_start_address, size, error); + LLDB_INSTRUMENT_VA(this, sb_start_address, size, error); ThreadPlanSP thread_plan_sp(GetSP()); if (thread_plan_sp) { Address *start_address = sb_start_address.get(); if (!start_address) { - return LLDB_RECORD_RESULT(SBThreadPlan()); + return SBThreadPlan(); } AddressRange range(*start_address, size); @@ -259,36 +245,30 @@ SBThreadPlan SBThreadPlan::QueueThreadPlanForStepOverRange( else plan.GetSP()->SetPrivate(true); - return LLDB_RECORD_RESULT(plan); + return plan; } - return LLDB_RECORD_RESULT(SBThreadPlan()); + return SBThreadPlan(); } SBThreadPlan SBThreadPlan::QueueThreadPlanForStepInRange(SBAddress &sb_start_address, lldb::addr_t size) { - LLDB_RECORD_METHOD(lldb::SBThreadPlan, SBThreadPlan, - QueueThreadPlanForStepInRange, - (lldb::SBAddress &, lldb::addr_t), sb_start_address, size); + LLDB_INSTRUMENT_VA(this, sb_start_address, size); SBError error; - return LLDB_RECORD_RESULT( - QueueThreadPlanForStepInRange(sb_start_address, size, error)); + return QueueThreadPlanForStepInRange(sb_start_address, size, error); } SBThreadPlan SBThreadPlan::QueueThreadPlanForStepInRange(SBAddress &sb_start_address, lldb::addr_t size, SBError &error) { - LLDB_RECORD_METHOD(lldb::SBThreadPlan, SBThreadPlan, - QueueThreadPlanForStepInRange, - (lldb::SBAddress &, lldb::addr_t, lldb::SBError &), - sb_start_address, size, error); + LLDB_INSTRUMENT_VA(this, sb_start_address, size, error); ThreadPlanSP thread_plan_sp(GetSP()); if (thread_plan_sp) { Address *start_address = sb_start_address.get(); if (!start_address) { - return LLDB_RECORD_RESULT(SBThreadPlan()); + return SBThreadPlan(); } AddressRange range(*start_address, size); @@ -305,30 +285,24 @@ SBThreadPlan::QueueThreadPlanForStepInRange(SBAddress &sb_start_address, else plan.GetSP()->SetPrivate(true); - return LLDB_RECORD_RESULT(plan); + return plan; } - return LLDB_RECORD_RESULT(SBThreadPlan()); + return SBThreadPlan(); } SBThreadPlan SBThreadPlan::QueueThreadPlanForStepOut(uint32_t frame_idx_to_step_to, bool first_insn) { - LLDB_RECORD_METHOD(lldb::SBThreadPlan, SBThreadPlan, - QueueThreadPlanForStepOut, (uint32_t, bool), - frame_idx_to_step_to, first_insn); + LLDB_INSTRUMENT_VA(this, frame_idx_to_step_to, first_insn); SBError error; - return LLDB_RECORD_RESULT( - QueueThreadPlanForStepOut(frame_idx_to_step_to, first_insn, error)); + return QueueThreadPlanForStepOut(frame_idx_to_step_to, first_insn, error); } SBThreadPlan SBThreadPlan::QueueThreadPlanForStepOut(uint32_t frame_idx_to_step_to, bool first_insn, SBError &error) { - LLDB_RECORD_METHOD(lldb::SBThreadPlan, SBThreadPlan, - QueueThreadPlanForStepOut, - (uint32_t, bool, lldb::SBError &), frame_idx_to_step_to, - first_insn, error); + LLDB_INSTRUMENT_VA(this, frame_idx_to_step_to, first_insn, error); ThreadPlanSP thread_plan_sp(GetSP()); if (thread_plan_sp) { @@ -347,32 +321,28 @@ SBThreadPlan::QueueThreadPlanForStepOut(uint32_t frame_idx_to_step_to, else plan.GetSP()->SetPrivate(true); - return LLDB_RECORD_RESULT(plan); + return plan; } - return LLDB_RECORD_RESULT(SBThreadPlan()); + return SBThreadPlan(); } SBThreadPlan SBThreadPlan::QueueThreadPlanForRunToAddress(SBAddress sb_address) { - LLDB_RECORD_METHOD(lldb::SBThreadPlan, SBThreadPlan, - QueueThreadPlanForRunToAddress, (lldb::SBAddress), - sb_address); + LLDB_INSTRUMENT_VA(this, sb_address); SBError error; - return LLDB_RECORD_RESULT(QueueThreadPlanForRunToAddress(sb_address, error)); + return QueueThreadPlanForRunToAddress(sb_address, error); } SBThreadPlan SBThreadPlan::QueueThreadPlanForRunToAddress(SBAddress sb_address, SBError &error) { - LLDB_RECORD_METHOD(lldb::SBThreadPlan, SBThreadPlan, - QueueThreadPlanForRunToAddress, - (lldb::SBAddress, lldb::SBError &), sb_address, error); + LLDB_INSTRUMENT_VA(this, sb_address, error); ThreadPlanSP thread_plan_sp(GetSP()); if (thread_plan_sp) { Address *address = sb_address.get(); if (!address) - return LLDB_RECORD_RESULT(SBThreadPlan()); + return SBThreadPlan(); Status plan_status; SBThreadPlan plan = @@ -384,28 +354,23 @@ SBThreadPlan SBThreadPlan::QueueThreadPlanForRunToAddress(SBAddress sb_address, else plan.GetSP()->SetPrivate(true); - return LLDB_RECORD_RESULT(plan); + return plan; } - return LLDB_RECORD_RESULT(SBThreadPlan()); + return SBThreadPlan(); } SBThreadPlan SBThreadPlan::QueueThreadPlanForStepScripted(const char *script_class_name) { - LLDB_RECORD_METHOD(lldb::SBThreadPlan, SBThreadPlan, - QueueThreadPlanForStepScripted, (const char *), - script_class_name); + LLDB_INSTRUMENT_VA(this, script_class_name); SBError error; - return LLDB_RECORD_RESULT( - QueueThreadPlanForStepScripted(script_class_name, error)); + return QueueThreadPlanForStepScripted(script_class_name, error); } SBThreadPlan SBThreadPlan::QueueThreadPlanForStepScripted(const char *script_class_name, SBError &error) { - LLDB_RECORD_METHOD(lldb::SBThreadPlan, SBThreadPlan, - QueueThreadPlanForStepScripted, - (const char *, lldb::SBError &), script_class_name, error); + LLDB_INSTRUMENT_VA(this, script_class_name, error); ThreadPlanSP thread_plan_sp(GetSP()); if (thread_plan_sp) { @@ -420,19 +385,16 @@ SBThreadPlan::QueueThreadPlanForStepScripted(const char *script_class_name, else plan.GetSP()->SetPrivate(true); - return LLDB_RECORD_RESULT(plan); + return plan; } - return LLDB_RECORD_RESULT(SBThreadPlan()); + return SBThreadPlan(); } SBThreadPlan SBThreadPlan::QueueThreadPlanForStepScripted(const char *script_class_name, lldb::SBStructuredData &args_data, SBError &error) { - LLDB_RECORD_METHOD(lldb::SBThreadPlan, SBThreadPlan, - QueueThreadPlanForStepScripted, - (const char *, lldb::SBStructuredData &, lldb::SBError &), - script_class_name, args_data, error); + LLDB_INSTRUMENT_VA(this, script_class_name, args_data, error); ThreadPlanSP thread_plan_sp(GetSP()); if (thread_plan_sp) { @@ -447,73 +409,8 @@ SBThreadPlan::QueueThreadPlanForStepScripted(const char *script_class_name, else plan.GetSP()->SetPrivate(true); - return LLDB_RECORD_RESULT(plan); + return plan; } else { - return LLDB_RECORD_RESULT(SBThreadPlan()); + return SBThreadPlan(); } } - -namespace lldb_private { -namespace repro { - -template <> -void RegisterMethods<SBThreadPlan>(Registry &R) { - LLDB_REGISTER_CONSTRUCTOR(SBThreadPlan, ()); - LLDB_REGISTER_CONSTRUCTOR(SBThreadPlan, (const lldb::ThreadPlanSP &)); - LLDB_REGISTER_CONSTRUCTOR(SBThreadPlan, (const lldb::SBThreadPlan &)); - LLDB_REGISTER_CONSTRUCTOR(SBThreadPlan, (lldb::SBThread &, const char *)); - LLDB_REGISTER_CONSTRUCTOR(SBThreadPlan, (lldb::SBThread &, const char *, - lldb::SBStructuredData &)); - LLDB_REGISTER_METHOD(const lldb::SBThreadPlan &, - SBThreadPlan, operator=,(const lldb::SBThreadPlan &)); - LLDB_REGISTER_METHOD_CONST(bool, SBThreadPlan, IsValid, ()); - LLDB_REGISTER_METHOD_CONST(bool, SBThreadPlan, operator bool, ()); - LLDB_REGISTER_METHOD(void, SBThreadPlan, Clear, ()); - LLDB_REGISTER_METHOD(lldb::StopReason, SBThreadPlan, GetStopReason, ()); - LLDB_REGISTER_METHOD(size_t, SBThreadPlan, GetStopReasonDataCount, ()); - LLDB_REGISTER_METHOD(uint64_t, SBThreadPlan, GetStopReasonDataAtIndex, - (uint32_t)); - LLDB_REGISTER_METHOD_CONST(lldb::SBThread, SBThreadPlan, GetThread, ()); - LLDB_REGISTER_METHOD_CONST(bool, SBThreadPlan, GetDescription, - (lldb::SBStream &)); - LLDB_REGISTER_METHOD(void, SBThreadPlan, SetPlanComplete, (bool)); - LLDB_REGISTER_METHOD(bool, SBThreadPlan, IsPlanComplete, ()); - LLDB_REGISTER_METHOD(bool, SBThreadPlan, IsPlanStale, ()); - LLDB_REGISTER_METHOD(bool, SBThreadPlan, IsValid, ()); - LLDB_REGISTER_METHOD(void, SBThreadPlan, SetStopOthers, (bool)); - LLDB_REGISTER_METHOD(bool, SBThreadPlan, GetStopOthers, ()); - LLDB_REGISTER_METHOD(lldb::SBThreadPlan, SBThreadPlan, - QueueThreadPlanForStepOverRange, - (lldb::SBAddress &, lldb::addr_t)); - LLDB_REGISTER_METHOD(lldb::SBThreadPlan, SBThreadPlan, - QueueThreadPlanForStepOverRange, - (lldb::SBAddress &, lldb::addr_t, lldb::SBError &)); - LLDB_REGISTER_METHOD(lldb::SBThreadPlan, SBThreadPlan, - QueueThreadPlanForStepInRange, - (lldb::SBAddress &, lldb::addr_t)); - LLDB_REGISTER_METHOD(lldb::SBThreadPlan, SBThreadPlan, - QueueThreadPlanForStepInRange, - (lldb::SBAddress &, lldb::addr_t, lldb::SBError &)); - LLDB_REGISTER_METHOD(lldb::SBThreadPlan, SBThreadPlan, - QueueThreadPlanForStepOut, (uint32_t, bool)); - LLDB_REGISTER_METHOD(lldb::SBThreadPlan, SBThreadPlan, - QueueThreadPlanForStepOut, - (uint32_t, bool, lldb::SBError &)); - LLDB_REGISTER_METHOD(lldb::SBThreadPlan, SBThreadPlan, - QueueThreadPlanForRunToAddress, (lldb::SBAddress)); - LLDB_REGISTER_METHOD(lldb::SBThreadPlan, SBThreadPlan, - QueueThreadPlanForRunToAddress, - (lldb::SBAddress, lldb::SBError &)); - LLDB_REGISTER_METHOD(lldb::SBThreadPlan, SBThreadPlan, - QueueThreadPlanForStepScripted, (const char *)); - LLDB_REGISTER_METHOD(lldb::SBThreadPlan, SBThreadPlan, - QueueThreadPlanForStepScripted, - (const char *, lldb::SBError &)); - LLDB_REGISTER_METHOD(lldb::SBThreadPlan, SBThreadPlan, - QueueThreadPlanForStepScripted, - (const char *, lldb::SBStructuredData &, - lldb::SBError &)); -} - -} -} diff --git a/lldb/source/API/SBTrace.cpp b/lldb/source/API/SBTrace.cpp index 079c33a562c0..64a675e2e16c 100644 --- a/lldb/source/API/SBTrace.cpp +++ b/lldb/source/API/SBTrace.cpp @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#include "SBReproducerPrivate.h" #include "lldb/Target/Process.h" +#include "lldb/Utility/Instrumentation.h" #include "lldb/API/SBStructuredData.h" #include "lldb/API/SBThread.h" @@ -20,35 +20,31 @@ using namespace lldb; using namespace lldb_private; -SBTrace::SBTrace() { LLDB_RECORD_CONSTRUCTOR_NO_ARGS(SBTrace); } +SBTrace::SBTrace() { LLDB_INSTRUMENT_VA(this); } SBTrace::SBTrace(const lldb::TraceSP &trace_sp) : m_opaque_sp(trace_sp) { - LLDB_RECORD_CONSTRUCTOR(SBTrace, (const lldb::TraceSP &), trace_sp); + LLDB_INSTRUMENT_VA(this, trace_sp); } const char *SBTrace::GetStartConfigurationHelp() { - LLDB_RECORD_METHOD_NO_ARGS(const char *, SBTrace, GetStartConfigurationHelp); - return LLDB_RECORD_RESULT( - m_opaque_sp ? m_opaque_sp->GetStartConfigurationHelp() : nullptr); + LLDB_INSTRUMENT_VA(this); + return m_opaque_sp ? m_opaque_sp->GetStartConfigurationHelp() : nullptr; } SBError SBTrace::Start(const SBStructuredData &configuration) { - LLDB_RECORD_METHOD(SBError, SBTrace, Start, (const SBStructuredData &), - configuration); + LLDB_INSTRUMENT_VA(this, configuration); SBError error; if (!m_opaque_sp) error.SetErrorString("error: invalid trace"); else if (llvm::Error err = m_opaque_sp->Start(configuration.m_impl_up->GetObjectSP())) error.SetErrorString(llvm::toString(std::move(err)).c_str()); - return LLDB_RECORD_RESULT(error); + return error; } SBError SBTrace::Start(const SBThread &thread, const SBStructuredData &configuration) { - LLDB_RECORD_METHOD(SBError, SBTrace, Start, - (const SBThread &, const SBStructuredData &), thread, - configuration); + LLDB_INSTRUMENT_VA(this, thread, configuration); SBError error; if (!m_opaque_sp) @@ -60,55 +56,35 @@ SBError SBTrace::Start(const SBThread &thread, error.SetErrorString(llvm::toString(std::move(err)).c_str()); } - return LLDB_RECORD_RESULT(error); + return error; } SBError SBTrace::Stop() { - LLDB_RECORD_METHOD_NO_ARGS(SBError, SBTrace, Stop); + LLDB_INSTRUMENT_VA(this); SBError error; if (!m_opaque_sp) error.SetErrorString("error: invalid trace"); else if (llvm::Error err = m_opaque_sp->Stop()) error.SetErrorString(llvm::toString(std::move(err)).c_str()); - return LLDB_RECORD_RESULT(error); + return error; } SBError SBTrace::Stop(const SBThread &thread) { - LLDB_RECORD_METHOD(SBError, SBTrace, Stop, (const SBThread &), thread); + LLDB_INSTRUMENT_VA(this, thread); SBError error; if (!m_opaque_sp) error.SetErrorString("error: invalid trace"); else if (llvm::Error err = m_opaque_sp->Stop({thread.GetThreadID()})) error.SetErrorString(llvm::toString(std::move(err)).c_str()); - return LLDB_RECORD_RESULT(error); + return error; } bool SBTrace::IsValid() { - LLDB_RECORD_METHOD_NO_ARGS(bool, SBTrace, IsValid); + LLDB_INSTRUMENT_VA(this); return this->operator bool(); } SBTrace::operator bool() const { - LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBTrace, operator bool); + LLDB_INSTRUMENT_VA(this); return (bool)m_opaque_sp; } - -namespace lldb_private { -namespace repro { - -template <> -void RegisterMethods<SBTrace>(Registry &R) { - LLDB_REGISTER_CONSTRUCTOR(SBTrace, ()); - LLDB_REGISTER_CONSTRUCTOR(SBTrace, (const lldb::TraceSP &)); - LLDB_REGISTER_METHOD(SBError, SBTrace, Start, (const SBStructuredData &)); - LLDB_REGISTER_METHOD(SBError, SBTrace, Start, - (const SBThread &, const SBStructuredData &)); - LLDB_REGISTER_METHOD(SBError, SBTrace, Stop, (const SBThread &)); - LLDB_REGISTER_METHOD(SBError, SBTrace, Stop, ()); - LLDB_REGISTER_METHOD(bool, SBTrace, IsValid, ()); - LLDB_REGISTER_METHOD(const char *, SBTrace, GetStartConfigurationHelp, ()); - LLDB_REGISTER_METHOD_CONST(bool, SBTrace, operator bool, ()); -} - -} -} diff --git a/lldb/source/API/SBType.cpp b/lldb/source/API/SBType.cpp index 550c4b065914..da9202bf9386 100644 --- a/lldb/source/API/SBType.cpp +++ b/lldb/source/API/SBType.cpp @@ -7,7 +7,6 @@ //===----------------------------------------------------------------------===// #include "lldb/API/SBType.h" -#include "SBReproducerPrivate.h" #include "lldb/API/SBDefines.h" #include "lldb/API/SBModule.h" #include "lldb/API/SBStream.h" @@ -17,6 +16,7 @@ #include "lldb/Symbol/Type.h" #include "lldb/Symbol/TypeSystem.h" #include "lldb/Utility/ConstString.h" +#include "lldb/Utility/Instrumentation.h" #include "lldb/Utility/Stream.h" #include "llvm/ADT/APSInt.h" @@ -26,7 +26,7 @@ using namespace lldb; using namespace lldb_private; -SBType::SBType() : m_opaque_sp() { LLDB_RECORD_CONSTRUCTOR_NO_ARGS(SBType); } +SBType::SBType() { LLDB_INSTRUMENT_VA(this); } SBType::SBType(const CompilerType &type) : m_opaque_sp(new TypeImpl( @@ -38,8 +38,8 @@ SBType::SBType(const lldb::TypeSP &type_sp) SBType::SBType(const lldb::TypeImplSP &type_impl_sp) : m_opaque_sp(type_impl_sp) {} -SBType::SBType(const SBType &rhs) : m_opaque_sp() { - LLDB_RECORD_CONSTRUCTOR(SBType, (const lldb::SBType &), rhs); +SBType::SBType(const SBType &rhs) { + LLDB_INSTRUMENT_VA(this, rhs); if (this != &rhs) { m_opaque_sp = rhs.m_opaque_sp; @@ -51,7 +51,7 @@ SBType::SBType(const SBType &rhs) : m_opaque_sp() { //{} // bool SBType::operator==(SBType &rhs) { - LLDB_RECORD_METHOD(bool, SBType, operator==,(lldb::SBType &), rhs); + LLDB_INSTRUMENT_VA(this, rhs); if (!IsValid()) return !rhs.IsValid(); @@ -63,7 +63,7 @@ bool SBType::operator==(SBType &rhs) { } bool SBType::operator!=(SBType &rhs) { - LLDB_RECORD_METHOD(bool, SBType, operator!=,(lldb::SBType &), rhs); + LLDB_INSTRUMENT_VA(this, rhs); if (!IsValid()) return rhs.IsValid(); @@ -81,13 +81,12 @@ void SBType::SetSP(const lldb::TypeImplSP &type_impl_sp) { } SBType &SBType::operator=(const SBType &rhs) { - LLDB_RECORD_METHOD(lldb::SBType &, SBType, operator=,(const lldb::SBType &), - rhs); + LLDB_INSTRUMENT_VA(this, rhs); if (this != &rhs) { m_opaque_sp = rhs.m_opaque_sp; } - return LLDB_RECORD_RESULT(*this); + return *this; } SBType::~SBType() = default; @@ -107,11 +106,11 @@ const TypeImpl &SBType::ref() const { } bool SBType::IsValid() const { - LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBType, IsValid); + LLDB_INSTRUMENT_VA(this); return this->operator bool(); } SBType::operator bool() const { - LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBType, operator bool); + LLDB_INSTRUMENT_VA(this); if (m_opaque_sp.get() == nullptr) return false; @@ -120,7 +119,7 @@ SBType::operator bool() const { } uint64_t SBType::GetByteSize() { - LLDB_RECORD_METHOD_NO_ARGS(uint64_t, SBType, GetByteSize); + LLDB_INSTRUMENT_VA(this); if (IsValid()) if (llvm::Optional<uint64_t> size = @@ -130,7 +129,7 @@ uint64_t SBType::GetByteSize() { } bool SBType::IsPointerType() { - LLDB_RECORD_METHOD_NO_ARGS(bool, SBType, IsPointerType); + LLDB_INSTRUMENT_VA(this); if (!IsValid()) return false; @@ -138,7 +137,7 @@ bool SBType::IsPointerType() { } bool SBType::IsArrayType() { - LLDB_RECORD_METHOD_NO_ARGS(bool, SBType, IsArrayType); + LLDB_INSTRUMENT_VA(this); if (!IsValid()) return false; @@ -147,7 +146,7 @@ bool SBType::IsArrayType() { } bool SBType::IsVectorType() { - LLDB_RECORD_METHOD_NO_ARGS(bool, SBType, IsVectorType); + LLDB_INSTRUMENT_VA(this); if (!IsValid()) return false; @@ -155,7 +154,7 @@ bool SBType::IsVectorType() { } bool SBType::IsReferenceType() { - LLDB_RECORD_METHOD_NO_ARGS(bool, SBType, IsReferenceType); + LLDB_INSTRUMENT_VA(this); if (!IsValid()) return false; @@ -163,71 +162,66 @@ bool SBType::IsReferenceType() { } SBType SBType::GetPointerType() { - LLDB_RECORD_METHOD_NO_ARGS(lldb::SBType, SBType, GetPointerType); + LLDB_INSTRUMENT_VA(this); if (!IsValid()) - return LLDB_RECORD_RESULT(SBType()); + return SBType(); - return LLDB_RECORD_RESULT( - SBType(TypeImplSP(new TypeImpl(m_opaque_sp->GetPointerType())))); + return SBType(TypeImplSP(new TypeImpl(m_opaque_sp->GetPointerType()))); } SBType SBType::GetPointeeType() { - LLDB_RECORD_METHOD_NO_ARGS(lldb::SBType, SBType, GetPointeeType); + LLDB_INSTRUMENT_VA(this); if (!IsValid()) - return LLDB_RECORD_RESULT(SBType()); - return LLDB_RECORD_RESULT( - SBType(TypeImplSP(new TypeImpl(m_opaque_sp->GetPointeeType())))); + return SBType(); + return SBType(TypeImplSP(new TypeImpl(m_opaque_sp->GetPointeeType()))); } SBType SBType::GetReferenceType() { - LLDB_RECORD_METHOD_NO_ARGS(lldb::SBType, SBType, GetReferenceType); + LLDB_INSTRUMENT_VA(this); if (!IsValid()) - return LLDB_RECORD_RESULT(SBType()); - return LLDB_RECORD_RESULT( - SBType(TypeImplSP(new TypeImpl(m_opaque_sp->GetReferenceType())))); + return SBType(); + return SBType(TypeImplSP(new TypeImpl(m_opaque_sp->GetReferenceType()))); } SBType SBType::GetTypedefedType() { - LLDB_RECORD_METHOD_NO_ARGS(lldb::SBType, SBType, GetTypedefedType); + LLDB_INSTRUMENT_VA(this); if (!IsValid()) - return LLDB_RECORD_RESULT(SBType()); - return LLDB_RECORD_RESULT( - SBType(TypeImplSP(new TypeImpl(m_opaque_sp->GetTypedefedType())))); + return SBType(); + return SBType(TypeImplSP(new TypeImpl(m_opaque_sp->GetTypedefedType()))); } SBType SBType::GetDereferencedType() { - LLDB_RECORD_METHOD_NO_ARGS(lldb::SBType, SBType, GetDereferencedType); + LLDB_INSTRUMENT_VA(this); if (!IsValid()) - return LLDB_RECORD_RESULT(SBType()); - return LLDB_RECORD_RESULT( - SBType(TypeImplSP(new TypeImpl(m_opaque_sp->GetDereferencedType())))); + return SBType(); + return SBType(TypeImplSP(new TypeImpl(m_opaque_sp->GetDereferencedType()))); } SBType SBType::GetArrayElementType() { - LLDB_RECORD_METHOD_NO_ARGS(lldb::SBType, SBType, GetArrayElementType); + LLDB_INSTRUMENT_VA(this); if (!IsValid()) - return LLDB_RECORD_RESULT(SBType()); - return LLDB_RECORD_RESULT(SBType(TypeImplSP(new TypeImpl( - m_opaque_sp->GetCompilerType(true).GetArrayElementType(nullptr))))); + return SBType(); + return SBType(TypeImplSP(new TypeImpl( + m_opaque_sp->GetCompilerType(true).GetArrayElementType(nullptr)))); } SBType SBType::GetArrayType(uint64_t size) { - LLDB_RECORD_METHOD(lldb::SBType, SBType, GetArrayType, (uint64_t), size); + LLDB_INSTRUMENT_VA(this, size); if (!IsValid()) - return LLDB_RECORD_RESULT(SBType()); - return LLDB_RECORD_RESULT(SBType(TypeImplSP( - new TypeImpl(m_opaque_sp->GetCompilerType(true).GetArrayType(size))))); + return SBType(); + return SBType(TypeImplSP( + new TypeImpl(m_opaque_sp->GetCompilerType(true).GetArrayType(size)))); } SBType SBType::GetVectorElementType() { - LLDB_RECORD_METHOD_NO_ARGS(lldb::SBType, SBType, GetVectorElementType); + LLDB_INSTRUMENT_VA(this); SBType type_sb; if (IsValid()) { @@ -236,11 +230,11 @@ SBType SBType::GetVectorElementType() { nullptr)) type_sb.SetSP(TypeImplSP(new TypeImpl(vector_element_type))); } - return LLDB_RECORD_RESULT(type_sb); + return type_sb; } bool SBType::IsFunctionType() { - LLDB_RECORD_METHOD_NO_ARGS(bool, SBType, IsFunctionType); + LLDB_INSTRUMENT_VA(this); if (!IsValid()) return false; @@ -248,7 +242,7 @@ bool SBType::IsFunctionType() { } bool SBType::IsPolymorphicClass() { - LLDB_RECORD_METHOD_NO_ARGS(bool, SBType, IsPolymorphicClass); + LLDB_INSTRUMENT_VA(this); if (!IsValid()) return false; @@ -256,7 +250,7 @@ bool SBType::IsPolymorphicClass() { } bool SBType::IsTypedefType() { - LLDB_RECORD_METHOD_NO_ARGS(bool, SBType, IsTypedefType); + LLDB_INSTRUMENT_VA(this); if (!IsValid()) return false; @@ -264,7 +258,7 @@ bool SBType::IsTypedefType() { } bool SBType::IsAnonymousType() { - LLDB_RECORD_METHOD_NO_ARGS(bool, SBType, IsAnonymousType); + LLDB_INSTRUMENT_VA(this); if (!IsValid()) return false; @@ -272,7 +266,7 @@ bool SBType::IsAnonymousType() { } bool SBType::IsScopedEnumerationType() { - LLDB_RECORD_METHOD_NO_ARGS(bool, SBType, IsScopedEnumerationType); + LLDB_INSTRUMENT_VA(this); if (!IsValid()) return false; @@ -280,20 +274,19 @@ bool SBType::IsScopedEnumerationType() { } lldb::SBType SBType::GetFunctionReturnType() { - LLDB_RECORD_METHOD_NO_ARGS(lldb::SBType, SBType, GetFunctionReturnType); + LLDB_INSTRUMENT_VA(this); if (IsValid()) { CompilerType return_type( m_opaque_sp->GetCompilerType(true).GetFunctionReturnType()); if (return_type.IsValid()) - return LLDB_RECORD_RESULT(SBType(return_type)); + return SBType(return_type); } - return LLDB_RECORD_RESULT(lldb::SBType()); + return lldb::SBType(); } lldb::SBTypeList SBType::GetFunctionArgumentTypes() { - LLDB_RECORD_METHOD_NO_ARGS(lldb::SBTypeList, SBType, - GetFunctionArgumentTypes); + LLDB_INSTRUMENT_VA(this); SBTypeList sb_type_list; if (IsValid()) { @@ -303,11 +296,11 @@ lldb::SBTypeList SBType::GetFunctionArgumentTypes() { sb_type_list.Append(SBType(func_type.GetFunctionArgumentAtIndex(i))); } } - return LLDB_RECORD_RESULT(sb_type_list); + return sb_type_list; } uint32_t SBType::GetNumberOfMemberFunctions() { - LLDB_RECORD_METHOD_NO_ARGS(uint32_t, SBType, GetNumberOfMemberFunctions); + LLDB_INSTRUMENT_VA(this); if (IsValid()) { return m_opaque_sp->GetCompilerType(true).GetNumMemberFunctions(); @@ -316,46 +309,43 @@ uint32_t SBType::GetNumberOfMemberFunctions() { } lldb::SBTypeMemberFunction SBType::GetMemberFunctionAtIndex(uint32_t idx) { - LLDB_RECORD_METHOD(lldb::SBTypeMemberFunction, SBType, - GetMemberFunctionAtIndex, (uint32_t), idx); + LLDB_INSTRUMENT_VA(this, idx); SBTypeMemberFunction sb_func_type; if (IsValid()) sb_func_type.reset(new TypeMemberFunctionImpl( m_opaque_sp->GetCompilerType(true).GetMemberFunctionAtIndex(idx))); - return LLDB_RECORD_RESULT(sb_func_type); + return sb_func_type; } lldb::SBType SBType::GetUnqualifiedType() { - LLDB_RECORD_METHOD_NO_ARGS(lldb::SBType, SBType, GetUnqualifiedType); + LLDB_INSTRUMENT_VA(this); if (!IsValid()) - return LLDB_RECORD_RESULT(SBType()); - return LLDB_RECORD_RESULT( - SBType(TypeImplSP(new TypeImpl(m_opaque_sp->GetUnqualifiedType())))); + return SBType(); + return SBType(TypeImplSP(new TypeImpl(m_opaque_sp->GetUnqualifiedType()))); } lldb::SBType SBType::GetCanonicalType() { - LLDB_RECORD_METHOD_NO_ARGS(lldb::SBType, SBType, GetCanonicalType); + LLDB_INSTRUMENT_VA(this); if (IsValid()) - return LLDB_RECORD_RESULT( - SBType(TypeImplSP(new TypeImpl(m_opaque_sp->GetCanonicalType())))); - return LLDB_RECORD_RESULT(SBType()); + return SBType(TypeImplSP(new TypeImpl(m_opaque_sp->GetCanonicalType()))); + return SBType(); } SBType SBType::GetEnumerationIntegerType() { - LLDB_RECORD_METHOD_NO_ARGS(lldb::SBType, SBType, GetEnumerationIntegerType); + LLDB_INSTRUMENT_VA(this); if (IsValid()) { - return LLDB_RECORD_RESULT( - SBType(m_opaque_sp->GetCompilerType(true).GetEnumerationIntegerType())); + return SBType( + m_opaque_sp->GetCompilerType(true).GetEnumerationIntegerType()); } - return LLDB_RECORD_RESULT(SBType()); + return SBType(); } lldb::BasicType SBType::GetBasicType() { - LLDB_RECORD_METHOD_NO_ARGS(lldb::BasicType, SBType, GetBasicType); + LLDB_INSTRUMENT_VA(this); if (IsValid()) return m_opaque_sp->GetCompilerType(false).GetBasicTypeEnumeration(); @@ -363,17 +353,16 @@ lldb::BasicType SBType::GetBasicType() { } SBType SBType::GetBasicType(lldb::BasicType basic_type) { - LLDB_RECORD_METHOD(lldb::SBType, SBType, GetBasicType, (lldb::BasicType), - basic_type); + LLDB_INSTRUMENT_VA(this, basic_type); if (IsValid() && m_opaque_sp->IsValid()) - return LLDB_RECORD_RESULT(SBType( - m_opaque_sp->GetTypeSystem(false)->GetBasicTypeFromAST(basic_type))); - return LLDB_RECORD_RESULT(SBType()); + return SBType( + m_opaque_sp->GetTypeSystem(false)->GetBasicTypeFromAST(basic_type)); + return SBType(); } uint32_t SBType::GetNumberOfDirectBaseClasses() { - LLDB_RECORD_METHOD_NO_ARGS(uint32_t, SBType, GetNumberOfDirectBaseClasses); + LLDB_INSTRUMENT_VA(this); if (IsValid()) return m_opaque_sp->GetCompilerType(true).GetNumDirectBaseClasses(); @@ -381,7 +370,7 @@ uint32_t SBType::GetNumberOfDirectBaseClasses() { } uint32_t SBType::GetNumberOfVirtualBaseClasses() { - LLDB_RECORD_METHOD_NO_ARGS(uint32_t, SBType, GetNumberOfVirtualBaseClasses); + LLDB_INSTRUMENT_VA(this); if (IsValid()) return m_opaque_sp->GetCompilerType(true).GetNumVirtualBaseClasses(); @@ -389,7 +378,7 @@ uint32_t SBType::GetNumberOfVirtualBaseClasses() { } uint32_t SBType::GetNumberOfFields() { - LLDB_RECORD_METHOD_NO_ARGS(uint32_t, SBType, GetNumberOfFields); + LLDB_INSTRUMENT_VA(this); if (IsValid()) return m_opaque_sp->GetCompilerType(true).GetNumFields(); @@ -398,9 +387,7 @@ uint32_t SBType::GetNumberOfFields() { bool SBType::GetDescription(SBStream &description, lldb::DescriptionLevel description_level) { - LLDB_RECORD_METHOD(bool, SBType, GetDescription, - (lldb::SBStream &, lldb::DescriptionLevel), description, - description_level); + LLDB_INSTRUMENT_VA(this, description, description_level); Stream &strm = description.ref(); @@ -413,8 +400,7 @@ bool SBType::GetDescription(SBStream &description, } SBTypeMember SBType::GetDirectBaseClassAtIndex(uint32_t idx) { - LLDB_RECORD_METHOD(lldb::SBTypeMember, SBType, GetDirectBaseClassAtIndex, - (uint32_t), idx); + LLDB_INSTRUMENT_VA(this, idx); SBTypeMember sb_type_member; if (IsValid()) { @@ -426,12 +412,11 @@ SBTypeMember SBType::GetDirectBaseClassAtIndex(uint32_t idx) { sb_type_member.reset(new TypeMemberImpl( TypeImplSP(new TypeImpl(base_class_type)), bit_offset)); } - return LLDB_RECORD_RESULT(sb_type_member); + return sb_type_member; } SBTypeMember SBType::GetVirtualBaseClassAtIndex(uint32_t idx) { - LLDB_RECORD_METHOD(lldb::SBTypeMember, SBType, GetVirtualBaseClassAtIndex, - (uint32_t), idx); + LLDB_INSTRUMENT_VA(this, idx); SBTypeMember sb_type_member; if (IsValid()) { @@ -443,12 +428,11 @@ SBTypeMember SBType::GetVirtualBaseClassAtIndex(uint32_t idx) { sb_type_member.reset(new TypeMemberImpl( TypeImplSP(new TypeImpl(base_class_type)), bit_offset)); } - return LLDB_RECORD_RESULT(sb_type_member); + return sb_type_member; } SBTypeEnumMemberList SBType::GetEnumMembers() { - LLDB_RECORD_METHOD_NO_ARGS(lldb::SBTypeEnumMemberList, SBType, - GetEnumMembers); + LLDB_INSTRUMENT_VA(this); SBTypeEnumMemberList sb_enum_member_list; if (IsValid()) { @@ -466,12 +450,11 @@ SBTypeEnumMemberList SBType::GetEnumMembers() { }); } } - return LLDB_RECORD_RESULT(sb_enum_member_list); + return sb_enum_member_list; } SBTypeMember SBType::GetFieldAtIndex(uint32_t idx) { - LLDB_RECORD_METHOD(lldb::SBTypeMember, SBType, GetFieldAtIndex, (uint32_t), - idx); + LLDB_INSTRUMENT_VA(this, idx); SBTypeMember sb_type_member; if (IsValid()) { @@ -493,11 +476,11 @@ SBTypeMember SBType::GetFieldAtIndex(uint32_t idx) { } } } - return LLDB_RECORD_RESULT(sb_type_member); + return sb_type_member; } bool SBType::IsTypeComplete() { - LLDB_RECORD_METHOD_NO_ARGS(bool, SBType, IsTypeComplete); + LLDB_INSTRUMENT_VA(this); if (!IsValid()) return false; @@ -505,7 +488,7 @@ bool SBType::IsTypeComplete() { } uint32_t SBType::GetTypeFlags() { - LLDB_RECORD_METHOD_NO_ARGS(uint32_t, SBType, GetTypeFlags); + LLDB_INSTRUMENT_VA(this); if (!IsValid()) return 0; @@ -513,18 +496,18 @@ uint32_t SBType::GetTypeFlags() { } lldb::SBModule SBType::GetModule() { - LLDB_RECORD_METHOD_NO_ARGS(lldb::SBModule, SBType, GetModule); + LLDB_INSTRUMENT_VA(this); lldb::SBModule sb_module; if (!IsValid()) - return LLDB_RECORD_RESULT(sb_module); + return sb_module; sb_module.SetSP(m_opaque_sp->GetModule()); - return LLDB_RECORD_RESULT(sb_module); + return sb_module; } const char *SBType::GetName() { - LLDB_RECORD_METHOD_NO_ARGS(const char *, SBType, GetName); + LLDB_INSTRUMENT_VA(this); if (!IsValid()) return ""; @@ -532,7 +515,7 @@ const char *SBType::GetName() { } const char *SBType::GetDisplayTypeName() { - LLDB_RECORD_METHOD_NO_ARGS(const char *, SBType, GetDisplayTypeName); + LLDB_INSTRUMENT_VA(this); if (!IsValid()) return ""; @@ -540,7 +523,7 @@ const char *SBType::GetDisplayTypeName() { } lldb::TypeClass SBType::GetTypeClass() { - LLDB_RECORD_METHOD_NO_ARGS(lldb::TypeClass, SBType, GetTypeClass); + LLDB_INSTRUMENT_VA(this); if (IsValid()) return m_opaque_sp->GetCompilerType(true).GetTypeClass(); @@ -548,7 +531,7 @@ lldb::TypeClass SBType::GetTypeClass() { } uint32_t SBType::GetNumberOfTemplateArguments() { - LLDB_RECORD_METHOD_NO_ARGS(uint32_t, SBType, GetNumberOfTemplateArguments); + LLDB_INSTRUMENT_VA(this); if (IsValid()) return m_opaque_sp->GetCompilerType(false).GetNumTemplateArguments(); @@ -556,11 +539,10 @@ uint32_t SBType::GetNumberOfTemplateArguments() { } lldb::SBType SBType::GetTemplateArgumentType(uint32_t idx) { - LLDB_RECORD_METHOD(lldb::SBType, SBType, GetTemplateArgumentType, (uint32_t), - idx); + LLDB_INSTRUMENT_VA(this, idx); if (!IsValid()) - return LLDB_RECORD_RESULT(SBType()); + return SBType(); CompilerType type; switch(GetTemplateArgumentKind(idx)) { @@ -576,13 +558,12 @@ lldb::SBType SBType::GetTemplateArgumentType(uint32_t idx) { break; } if (type.IsValid()) - return LLDB_RECORD_RESULT(SBType(type)); - return LLDB_RECORD_RESULT(SBType()); + return SBType(type); + return SBType(); } lldb::TemplateArgumentKind SBType::GetTemplateArgumentKind(uint32_t idx) { - LLDB_RECORD_METHOD(lldb::TemplateArgumentKind, SBType, - GetTemplateArgumentKind, (uint32_t), idx); + LLDB_INSTRUMENT_VA(this, idx); if (IsValid()) return m_opaque_sp->GetCompilerType(false).GetTemplateArgumentKind(idx); @@ -590,12 +571,12 @@ lldb::TemplateArgumentKind SBType::GetTemplateArgumentKind(uint32_t idx) { } SBTypeList::SBTypeList() : m_opaque_up(new TypeListImpl()) { - LLDB_RECORD_CONSTRUCTOR_NO_ARGS(SBTypeList); + LLDB_INSTRUMENT_VA(this); } SBTypeList::SBTypeList(const SBTypeList &rhs) : m_opaque_up(new TypeListImpl()) { - LLDB_RECORD_CONSTRUCTOR(SBTypeList, (const lldb::SBTypeList &), rhs); + LLDB_INSTRUMENT_VA(this, rhs); for (uint32_t i = 0, rhs_size = const_cast<SBTypeList &>(rhs).GetSize(); i < rhs_size; i++) @@ -603,18 +584,17 @@ SBTypeList::SBTypeList(const SBTypeList &rhs) } bool SBTypeList::IsValid() { - LLDB_RECORD_METHOD_NO_ARGS(bool, SBTypeList, IsValid); + LLDB_INSTRUMENT_VA(this); return this->operator bool(); } SBTypeList::operator bool() const { - LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBTypeList, operator bool); + LLDB_INSTRUMENT_VA(this); return (m_opaque_up != nullptr); } SBTypeList &SBTypeList::operator=(const SBTypeList &rhs) { - LLDB_RECORD_METHOD(lldb::SBTypeList &, - SBTypeList, operator=,(const lldb::SBTypeList &), rhs); + LLDB_INSTRUMENT_VA(this, rhs); if (this != &rhs) { m_opaque_up = std::make_unique<TypeListImpl>(); @@ -622,41 +602,38 @@ SBTypeList &SBTypeList::operator=(const SBTypeList &rhs) { i < rhs_size; i++) Append(const_cast<SBTypeList &>(rhs).GetTypeAtIndex(i)); } - return LLDB_RECORD_RESULT(*this); + return *this; } void SBTypeList::Append(SBType type) { - LLDB_RECORD_METHOD(void, SBTypeList, Append, (lldb::SBType), type); + LLDB_INSTRUMENT_VA(this, type); if (type.IsValid()) m_opaque_up->Append(type.m_opaque_sp); } SBType SBTypeList::GetTypeAtIndex(uint32_t index) { - LLDB_RECORD_METHOD(lldb::SBType, SBTypeList, GetTypeAtIndex, (uint32_t), - index); + LLDB_INSTRUMENT_VA(this, index); if (m_opaque_up) - return LLDB_RECORD_RESULT(SBType(m_opaque_up->GetTypeAtIndex(index))); - return LLDB_RECORD_RESULT(SBType()); + return SBType(m_opaque_up->GetTypeAtIndex(index)); + return SBType(); } uint32_t SBTypeList::GetSize() { - LLDB_RECORD_METHOD_NO_ARGS(uint32_t, SBTypeList, GetSize); + LLDB_INSTRUMENT_VA(this); return m_opaque_up->GetSize(); } SBTypeList::~SBTypeList() = default; -SBTypeMember::SBTypeMember() : m_opaque_up() { - LLDB_RECORD_CONSTRUCTOR_NO_ARGS(SBTypeMember); -} +SBTypeMember::SBTypeMember() { LLDB_INSTRUMENT_VA(this); } SBTypeMember::~SBTypeMember() = default; -SBTypeMember::SBTypeMember(const SBTypeMember &rhs) : m_opaque_up() { - LLDB_RECORD_CONSTRUCTOR(SBTypeMember, (const lldb::SBTypeMember &), rhs); +SBTypeMember::SBTypeMember(const SBTypeMember &rhs) { + LLDB_INSTRUMENT_VA(this, rhs); if (this != &rhs) { if (rhs.IsValid()) @@ -665,28 +642,27 @@ SBTypeMember::SBTypeMember(const SBTypeMember &rhs) : m_opaque_up() { } lldb::SBTypeMember &SBTypeMember::operator=(const lldb::SBTypeMember &rhs) { - LLDB_RECORD_METHOD(lldb::SBTypeMember &, - SBTypeMember, operator=,(const lldb::SBTypeMember &), rhs); + LLDB_INSTRUMENT_VA(this, rhs); if (this != &rhs) { if (rhs.IsValid()) m_opaque_up = std::make_unique<TypeMemberImpl>(rhs.ref()); } - return LLDB_RECORD_RESULT(*this); + return *this; } bool SBTypeMember::IsValid() const { - LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBTypeMember, IsValid); + LLDB_INSTRUMENT_VA(this); return this->operator bool(); } SBTypeMember::operator bool() const { - LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBTypeMember, operator bool); + LLDB_INSTRUMENT_VA(this); return m_opaque_up.get(); } const char *SBTypeMember::GetName() { - LLDB_RECORD_METHOD_NO_ARGS(const char *, SBTypeMember, GetName); + LLDB_INSTRUMENT_VA(this); if (m_opaque_up) return m_opaque_up->GetName().GetCString(); @@ -694,17 +670,17 @@ const char *SBTypeMember::GetName() { } SBType SBTypeMember::GetType() { - LLDB_RECORD_METHOD_NO_ARGS(lldb::SBType, SBTypeMember, GetType); + LLDB_INSTRUMENT_VA(this); SBType sb_type; if (m_opaque_up) { sb_type.SetSP(m_opaque_up->GetTypeImpl()); } - return LLDB_RECORD_RESULT(sb_type); + return sb_type; } uint64_t SBTypeMember::GetOffsetInBytes() { - LLDB_RECORD_METHOD_NO_ARGS(uint64_t, SBTypeMember, GetOffsetInBytes); + LLDB_INSTRUMENT_VA(this); if (m_opaque_up) return m_opaque_up->GetBitOffset() / 8u; @@ -712,7 +688,7 @@ uint64_t SBTypeMember::GetOffsetInBytes() { } uint64_t SBTypeMember::GetOffsetInBits() { - LLDB_RECORD_METHOD_NO_ARGS(uint64_t, SBTypeMember, GetOffsetInBits); + LLDB_INSTRUMENT_VA(this); if (m_opaque_up) return m_opaque_up->GetBitOffset(); @@ -720,7 +696,7 @@ uint64_t SBTypeMember::GetOffsetInBits() { } bool SBTypeMember::IsBitfield() { - LLDB_RECORD_METHOD_NO_ARGS(bool, SBTypeMember, IsBitfield); + LLDB_INSTRUMENT_VA(this); if (m_opaque_up) return m_opaque_up->GetIsBitfield(); @@ -728,7 +704,7 @@ bool SBTypeMember::IsBitfield() { } uint32_t SBTypeMember::GetBitfieldSizeInBits() { - LLDB_RECORD_METHOD_NO_ARGS(uint32_t, SBTypeMember, GetBitfieldSizeInBits); + LLDB_INSTRUMENT_VA(this); if (m_opaque_up) return m_opaque_up->GetBitfieldBitSize(); @@ -737,9 +713,7 @@ uint32_t SBTypeMember::GetBitfieldSizeInBits() { bool SBTypeMember::GetDescription(lldb::SBStream &description, lldb::DescriptionLevel description_level) { - LLDB_RECORD_METHOD(bool, SBTypeMember, GetDescription, - (lldb::SBStream &, lldb::DescriptionLevel), description, - description_level); + LLDB_INSTRUMENT_VA(this, description, description_level); Stream &strm = description.ref(); @@ -780,42 +754,36 @@ TypeMemberImpl &SBTypeMember::ref() { const TypeMemberImpl &SBTypeMember::ref() const { return *m_opaque_up; } -SBTypeMemberFunction::SBTypeMemberFunction() : m_opaque_sp() { - LLDB_RECORD_CONSTRUCTOR_NO_ARGS(SBTypeMemberFunction); -} +SBTypeMemberFunction::SBTypeMemberFunction() { LLDB_INSTRUMENT_VA(this); } SBTypeMemberFunction::~SBTypeMemberFunction() = default; SBTypeMemberFunction::SBTypeMemberFunction(const SBTypeMemberFunction &rhs) : m_opaque_sp(rhs.m_opaque_sp) { - LLDB_RECORD_CONSTRUCTOR(SBTypeMemberFunction, - (const lldb::SBTypeMemberFunction &), rhs); + LLDB_INSTRUMENT_VA(this, rhs); } lldb::SBTypeMemberFunction &SBTypeMemberFunction:: operator=(const lldb::SBTypeMemberFunction &rhs) { - LLDB_RECORD_METHOD( - lldb::SBTypeMemberFunction &, - SBTypeMemberFunction, operator=,(const lldb::SBTypeMemberFunction &), - rhs); + LLDB_INSTRUMENT_VA(this, rhs); if (this != &rhs) m_opaque_sp = rhs.m_opaque_sp; - return LLDB_RECORD_RESULT(*this); + return *this; } bool SBTypeMemberFunction::IsValid() const { - LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBTypeMemberFunction, IsValid); + LLDB_INSTRUMENT_VA(this); return this->operator bool(); } SBTypeMemberFunction::operator bool() const { - LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBTypeMemberFunction, operator bool); + LLDB_INSTRUMENT_VA(this); return m_opaque_sp.get(); } const char *SBTypeMemberFunction::GetName() { - LLDB_RECORD_METHOD_NO_ARGS(const char *, SBTypeMemberFunction, GetName); + LLDB_INSTRUMENT_VA(this); if (m_opaque_sp) return m_opaque_sp->GetName().GetCString(); @@ -823,8 +791,7 @@ const char *SBTypeMemberFunction::GetName() { } const char *SBTypeMemberFunction::GetDemangledName() { - LLDB_RECORD_METHOD_NO_ARGS(const char *, SBTypeMemberFunction, - GetDemangledName); + LLDB_INSTRUMENT_VA(this); if (m_opaque_sp) { ConstString mangled_str = m_opaque_sp->GetMangledName(); @@ -837,8 +804,7 @@ const char *SBTypeMemberFunction::GetDemangledName() { } const char *SBTypeMemberFunction::GetMangledName() { - LLDB_RECORD_METHOD_NO_ARGS(const char *, SBTypeMemberFunction, - GetMangledName); + LLDB_INSTRUMENT_VA(this); if (m_opaque_sp) return m_opaque_sp->GetMangledName().GetCString(); @@ -846,28 +812,27 @@ const char *SBTypeMemberFunction::GetMangledName() { } SBType SBTypeMemberFunction::GetType() { - LLDB_RECORD_METHOD_NO_ARGS(lldb::SBType, SBTypeMemberFunction, GetType); + LLDB_INSTRUMENT_VA(this); SBType sb_type; if (m_opaque_sp) { sb_type.SetSP(lldb::TypeImplSP(new TypeImpl(m_opaque_sp->GetType()))); } - return LLDB_RECORD_RESULT(sb_type); + return sb_type; } lldb::SBType SBTypeMemberFunction::GetReturnType() { - LLDB_RECORD_METHOD_NO_ARGS(lldb::SBType, SBTypeMemberFunction, GetReturnType); + LLDB_INSTRUMENT_VA(this); SBType sb_type; if (m_opaque_sp) { sb_type.SetSP(lldb::TypeImplSP(new TypeImpl(m_opaque_sp->GetReturnType()))); } - return LLDB_RECORD_RESULT(sb_type); + return sb_type; } uint32_t SBTypeMemberFunction::GetNumberOfArguments() { - LLDB_RECORD_METHOD_NO_ARGS(uint32_t, SBTypeMemberFunction, - GetNumberOfArguments); + LLDB_INSTRUMENT_VA(this); if (m_opaque_sp) return m_opaque_sp->GetNumArguments(); @@ -875,20 +840,18 @@ uint32_t SBTypeMemberFunction::GetNumberOfArguments() { } lldb::SBType SBTypeMemberFunction::GetArgumentTypeAtIndex(uint32_t i) { - LLDB_RECORD_METHOD(lldb::SBType, SBTypeMemberFunction, GetArgumentTypeAtIndex, - (uint32_t), i); + LLDB_INSTRUMENT_VA(this, i); SBType sb_type; if (m_opaque_sp) { sb_type.SetSP( lldb::TypeImplSP(new TypeImpl(m_opaque_sp->GetArgumentAtIndex(i)))); } - return LLDB_RECORD_RESULT(sb_type); + return sb_type; } lldb::MemberFunctionKind SBTypeMemberFunction::GetKind() { - LLDB_RECORD_METHOD_NO_ARGS(lldb::MemberFunctionKind, SBTypeMemberFunction, - GetKind); + LLDB_INSTRUMENT_VA(this); if (m_opaque_sp) return m_opaque_sp->GetKind(); @@ -897,9 +860,7 @@ lldb::MemberFunctionKind SBTypeMemberFunction::GetKind() { bool SBTypeMemberFunction::GetDescription( lldb::SBStream &description, lldb::DescriptionLevel description_level) { - LLDB_RECORD_METHOD(bool, SBTypeMemberFunction, GetDescription, - (lldb::SBStream &, lldb::DescriptionLevel), description, - description_level); + LLDB_INSTRUMENT_VA(this, description, description_level); Stream &strm = description.ref(); @@ -922,120 +883,3 @@ TypeMemberFunctionImpl &SBTypeMemberFunction::ref() { const TypeMemberFunctionImpl &SBTypeMemberFunction::ref() const { return *m_opaque_sp.get(); } - -namespace lldb_private { -namespace repro { - -template <> -void RegisterMethods<SBType>(Registry &R) { - LLDB_REGISTER_CONSTRUCTOR(SBType, ()); - LLDB_REGISTER_CONSTRUCTOR(SBType, (const lldb::SBType &)); - LLDB_REGISTER_METHOD(bool, SBType, operator==,(lldb::SBType &)); - LLDB_REGISTER_METHOD(bool, SBType, operator!=,(lldb::SBType &)); - LLDB_REGISTER_METHOD(lldb::SBType &, - SBType, operator=,(const lldb::SBType &)); - LLDB_REGISTER_METHOD_CONST(bool, SBType, IsValid, ()); - LLDB_REGISTER_METHOD_CONST(bool, SBType, operator bool, ()); - LLDB_REGISTER_METHOD(uint64_t, SBType, GetByteSize, ()); - LLDB_REGISTER_METHOD(bool, SBType, IsPointerType, ()); - LLDB_REGISTER_METHOD(bool, SBType, IsArrayType, ()); - LLDB_REGISTER_METHOD(bool, SBType, IsVectorType, ()); - LLDB_REGISTER_METHOD(bool, SBType, IsReferenceType, ()); - LLDB_REGISTER_METHOD(lldb::SBType, SBType, GetPointerType, ()); - LLDB_REGISTER_METHOD(lldb::SBType, SBType, GetPointeeType, ()); - LLDB_REGISTER_METHOD(lldb::SBType, SBType, GetReferenceType, ()); - LLDB_REGISTER_METHOD(lldb::SBType, SBType, GetTypedefedType, ()); - LLDB_REGISTER_METHOD(lldb::SBType, SBType, GetDereferencedType, ()); - LLDB_REGISTER_METHOD(lldb::SBType, SBType, GetArrayElementType, ()); - LLDB_REGISTER_METHOD(lldb::SBType, SBType, GetArrayType, (uint64_t)); - LLDB_REGISTER_METHOD(lldb::SBType, SBType, GetVectorElementType, ()); - LLDB_REGISTER_METHOD(bool, SBType, IsFunctionType, ()); - LLDB_REGISTER_METHOD(bool, SBType, IsPolymorphicClass, ()); - LLDB_REGISTER_METHOD(bool, SBType, IsTypedefType, ()); - LLDB_REGISTER_METHOD(bool, SBType, IsAnonymousType, ()); - LLDB_REGISTER_METHOD(bool, SBType, IsScopedEnumerationType, ()); - LLDB_REGISTER_METHOD(lldb::SBType, SBType, GetFunctionReturnType, ()); - LLDB_REGISTER_METHOD(lldb::SBTypeList, SBType, GetFunctionArgumentTypes, - ()); - LLDB_REGISTER_METHOD(uint32_t, SBType, GetNumberOfMemberFunctions, ()); - LLDB_REGISTER_METHOD(lldb::SBTypeMemberFunction, SBType, - GetMemberFunctionAtIndex, (uint32_t)); - LLDB_REGISTER_METHOD(lldb::SBType, SBType, GetUnqualifiedType, ()); - LLDB_REGISTER_METHOD(lldb::SBType, SBType, GetCanonicalType, ()); - LLDB_REGISTER_METHOD(lldb::SBType, SBType, GetEnumerationIntegerType, ()); - LLDB_REGISTER_METHOD(lldb::BasicType, SBType, GetBasicType, ()); - LLDB_REGISTER_METHOD(lldb::SBType, SBType, GetBasicType, (lldb::BasicType)); - LLDB_REGISTER_METHOD(uint32_t, SBType, GetNumberOfDirectBaseClasses, ()); - LLDB_REGISTER_METHOD(uint32_t, SBType, GetNumberOfVirtualBaseClasses, ()); - LLDB_REGISTER_METHOD(uint32_t, SBType, GetNumberOfFields, ()); - LLDB_REGISTER_METHOD(bool, SBType, GetDescription, - (lldb::SBStream &, lldb::DescriptionLevel)); - LLDB_REGISTER_METHOD(lldb::SBTypeMember, SBType, GetDirectBaseClassAtIndex, - (uint32_t)); - LLDB_REGISTER_METHOD(lldb::SBTypeMember, SBType, GetVirtualBaseClassAtIndex, - (uint32_t)); - LLDB_REGISTER_METHOD(lldb::SBTypeEnumMemberList, SBType, GetEnumMembers, - ()); - LLDB_REGISTER_METHOD(lldb::SBTypeMember, SBType, GetFieldAtIndex, - (uint32_t)); - LLDB_REGISTER_METHOD(bool, SBType, IsTypeComplete, ()); - LLDB_REGISTER_METHOD(uint32_t, SBType, GetTypeFlags, ()); - LLDB_REGISTER_METHOD(lldb::SBModule, SBType, GetModule, ()); - LLDB_REGISTER_METHOD(const char *, SBType, GetName, ()); - LLDB_REGISTER_METHOD(const char *, SBType, GetDisplayTypeName, ()); - LLDB_REGISTER_METHOD(lldb::TypeClass, SBType, GetTypeClass, ()); - LLDB_REGISTER_METHOD(uint32_t, SBType, GetNumberOfTemplateArguments, ()); - LLDB_REGISTER_METHOD(lldb::SBType, SBType, GetTemplateArgumentType, - (uint32_t)); - LLDB_REGISTER_METHOD(lldb::TemplateArgumentKind, SBType, - GetTemplateArgumentKind, (uint32_t)); - LLDB_REGISTER_CONSTRUCTOR(SBTypeList, ()); - LLDB_REGISTER_CONSTRUCTOR(SBTypeList, (const lldb::SBTypeList &)); - LLDB_REGISTER_METHOD(bool, SBTypeList, IsValid, ()); - LLDB_REGISTER_METHOD_CONST(bool, SBTypeList, operator bool, ()); - LLDB_REGISTER_METHOD(lldb::SBTypeList &, - SBTypeList, operator=,(const lldb::SBTypeList &)); - LLDB_REGISTER_METHOD(void, SBTypeList, Append, (lldb::SBType)); - LLDB_REGISTER_METHOD(lldb::SBType, SBTypeList, GetTypeAtIndex, (uint32_t)); - LLDB_REGISTER_METHOD(uint32_t, SBTypeList, GetSize, ()); - LLDB_REGISTER_CONSTRUCTOR(SBTypeMember, ()); - LLDB_REGISTER_CONSTRUCTOR(SBTypeMember, (const lldb::SBTypeMember &)); - LLDB_REGISTER_METHOD(lldb::SBTypeMember &, - SBTypeMember, operator=,(const lldb::SBTypeMember &)); - LLDB_REGISTER_METHOD_CONST(bool, SBTypeMember, IsValid, ()); - LLDB_REGISTER_METHOD_CONST(bool, SBTypeMember, operator bool, ()); - LLDB_REGISTER_METHOD(const char *, SBTypeMember, GetName, ()); - LLDB_REGISTER_METHOD(lldb::SBType, SBTypeMember, GetType, ()); - LLDB_REGISTER_METHOD(uint64_t, SBTypeMember, GetOffsetInBytes, ()); - LLDB_REGISTER_METHOD(uint64_t, SBTypeMember, GetOffsetInBits, ()); - LLDB_REGISTER_METHOD(bool, SBTypeMember, IsBitfield, ()); - LLDB_REGISTER_METHOD(uint32_t, SBTypeMember, GetBitfieldSizeInBits, ()); - LLDB_REGISTER_METHOD(bool, SBTypeMember, GetDescription, - (lldb::SBStream &, lldb::DescriptionLevel)); - LLDB_REGISTER_CONSTRUCTOR(SBTypeMemberFunction, ()); - LLDB_REGISTER_CONSTRUCTOR(SBTypeMemberFunction, - (const lldb::SBTypeMemberFunction &)); - LLDB_REGISTER_METHOD( - lldb::SBTypeMemberFunction &, - SBTypeMemberFunction, operator=,(const lldb::SBTypeMemberFunction &)); - LLDB_REGISTER_METHOD_CONST(bool, SBTypeMemberFunction, IsValid, ()); - LLDB_REGISTER_METHOD_CONST(bool, SBTypeMemberFunction, operator bool, ()); - LLDB_REGISTER_METHOD(const char *, SBTypeMemberFunction, GetName, ()); - LLDB_REGISTER_METHOD(const char *, SBTypeMemberFunction, GetDemangledName, - ()); - LLDB_REGISTER_METHOD(const char *, SBTypeMemberFunction, GetMangledName, - ()); - LLDB_REGISTER_METHOD(lldb::SBType, SBTypeMemberFunction, GetType, ()); - LLDB_REGISTER_METHOD(lldb::SBType, SBTypeMemberFunction, GetReturnType, ()); - LLDB_REGISTER_METHOD(uint32_t, SBTypeMemberFunction, GetNumberOfArguments, - ()); - LLDB_REGISTER_METHOD(lldb::SBType, SBTypeMemberFunction, - GetArgumentTypeAtIndex, (uint32_t)); - LLDB_REGISTER_METHOD(lldb::MemberFunctionKind, SBTypeMemberFunction, - GetKind, ()); - LLDB_REGISTER_METHOD(bool, SBTypeMemberFunction, GetDescription, - (lldb::SBStream &, lldb::DescriptionLevel)); -} - -} -} diff --git a/lldb/source/API/SBTypeCategory.cpp b/lldb/source/API/SBTypeCategory.cpp index e7432959b260..7d929fe49795 100644 --- a/lldb/source/API/SBTypeCategory.cpp +++ b/lldb/source/API/SBTypeCategory.cpp @@ -7,7 +7,7 @@ //===----------------------------------------------------------------------===// #include "lldb/API/SBTypeCategory.h" -#include "SBReproducerPrivate.h" +#include "lldb/Utility/Instrumentation.h" #include "lldb/API/SBStream.h" #include "lldb/API/SBTypeFilter.h" @@ -26,33 +26,31 @@ using namespace lldb_private; typedef std::pair<lldb::TypeCategoryImplSP, user_id_t> ImplType; -SBTypeCategory::SBTypeCategory() : m_opaque_sp() { - LLDB_RECORD_CONSTRUCTOR_NO_ARGS(SBTypeCategory); -} +SBTypeCategory::SBTypeCategory() { LLDB_INSTRUMENT_VA(this); } -SBTypeCategory::SBTypeCategory(const char *name) : m_opaque_sp() { +SBTypeCategory::SBTypeCategory(const char *name) { DataVisualization::Categories::GetCategory(ConstString(name), m_opaque_sp); } SBTypeCategory::SBTypeCategory(const lldb::SBTypeCategory &rhs) : m_opaque_sp(rhs.m_opaque_sp) { - LLDB_RECORD_CONSTRUCTOR(SBTypeCategory, (const lldb::SBTypeCategory &), rhs); + LLDB_INSTRUMENT_VA(this, rhs); } SBTypeCategory::~SBTypeCategory() = default; bool SBTypeCategory::IsValid() const { - LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBTypeCategory, IsValid); + LLDB_INSTRUMENT_VA(this); return this->operator bool(); } SBTypeCategory::operator bool() const { - LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBTypeCategory, operator bool); + LLDB_INSTRUMENT_VA(this); return (m_opaque_sp.get() != nullptr); } bool SBTypeCategory::GetEnabled() { - LLDB_RECORD_METHOD_NO_ARGS(bool, SBTypeCategory, GetEnabled); + LLDB_INSTRUMENT_VA(this); if (!IsValid()) return false; @@ -60,7 +58,7 @@ bool SBTypeCategory::GetEnabled() { } void SBTypeCategory::SetEnabled(bool enabled) { - LLDB_RECORD_METHOD(void, SBTypeCategory, SetEnabled, (bool), enabled); + LLDB_INSTRUMENT_VA(this, enabled); if (!IsValid()) return; @@ -71,7 +69,7 @@ void SBTypeCategory::SetEnabled(bool enabled) { } const char *SBTypeCategory::GetName() { - LLDB_RECORD_METHOD_NO_ARGS(const char *, SBTypeCategory, GetName); + LLDB_INSTRUMENT_VA(this); if (!IsValid()) return nullptr; @@ -79,8 +77,7 @@ const char *SBTypeCategory::GetName() { } lldb::LanguageType SBTypeCategory::GetLanguageAtIndex(uint32_t idx) { - LLDB_RECORD_METHOD(lldb::LanguageType, SBTypeCategory, GetLanguageAtIndex, - (uint32_t), idx); + LLDB_INSTRUMENT_VA(this, idx); if (IsValid()) return m_opaque_sp->GetLanguageAtIndex(idx); @@ -88,7 +85,7 @@ lldb::LanguageType SBTypeCategory::GetLanguageAtIndex(uint32_t idx) { } uint32_t SBTypeCategory::GetNumLanguages() { - LLDB_RECORD_METHOD_NO_ARGS(uint32_t, SBTypeCategory, GetNumLanguages); + LLDB_INSTRUMENT_VA(this); if (IsValid()) return m_opaque_sp->GetNumLanguages(); @@ -96,15 +93,14 @@ uint32_t SBTypeCategory::GetNumLanguages() { } void SBTypeCategory::AddLanguage(lldb::LanguageType language) { - LLDB_RECORD_METHOD(void, SBTypeCategory, AddLanguage, (lldb::LanguageType), - language); + LLDB_INSTRUMENT_VA(this, language); if (IsValid()) m_opaque_sp->AddLanguage(language); } uint32_t SBTypeCategory::GetNumFormats() { - LLDB_RECORD_METHOD_NO_ARGS(uint32_t, SBTypeCategory, GetNumFormats); + LLDB_INSTRUMENT_VA(this); if (!IsValid()) return 0; @@ -114,7 +110,7 @@ uint32_t SBTypeCategory::GetNumFormats() { } uint32_t SBTypeCategory::GetNumSummaries() { - LLDB_RECORD_METHOD_NO_ARGS(uint32_t, SBTypeCategory, GetNumSummaries); + LLDB_INSTRUMENT_VA(this); if (!IsValid()) return 0; @@ -123,7 +119,7 @@ uint32_t SBTypeCategory::GetNumSummaries() { } uint32_t SBTypeCategory::GetNumFilters() { - LLDB_RECORD_METHOD_NO_ARGS(uint32_t, SBTypeCategory, GetNumFilters); + LLDB_INSTRUMENT_VA(this); if (!IsValid()) return 0; @@ -132,7 +128,7 @@ uint32_t SBTypeCategory::GetNumFilters() { } uint32_t SBTypeCategory::GetNumSynthetics() { - LLDB_RECORD_METHOD_NO_ARGS(uint32_t, SBTypeCategory, GetNumSynthetics); + LLDB_INSTRUMENT_VA(this); if (!IsValid()) return 0; @@ -142,58 +138,52 @@ uint32_t SBTypeCategory::GetNumSynthetics() { lldb::SBTypeNameSpecifier SBTypeCategory::GetTypeNameSpecifierForFilterAtIndex(uint32_t index) { - LLDB_RECORD_METHOD(lldb::SBTypeNameSpecifier, SBTypeCategory, - GetTypeNameSpecifierForFilterAtIndex, (uint32_t), index); + LLDB_INSTRUMENT_VA(this, index); if (!IsValid()) - return LLDB_RECORD_RESULT(SBTypeNameSpecifier()); - return LLDB_RECORD_RESULT(SBTypeNameSpecifier( - m_opaque_sp->GetTypeNameSpecifierForFilterAtIndex(index))); + return SBTypeNameSpecifier(); + return SBTypeNameSpecifier( + m_opaque_sp->GetTypeNameSpecifierForFilterAtIndex(index)); } lldb::SBTypeNameSpecifier SBTypeCategory::GetTypeNameSpecifierForFormatAtIndex(uint32_t index) { - LLDB_RECORD_METHOD(lldb::SBTypeNameSpecifier, SBTypeCategory, - GetTypeNameSpecifierForFormatAtIndex, (uint32_t), index); + LLDB_INSTRUMENT_VA(this, index); if (!IsValid()) - return LLDB_RECORD_RESULT(SBTypeNameSpecifier()); - return LLDB_RECORD_RESULT(SBTypeNameSpecifier( - m_opaque_sp->GetTypeNameSpecifierForFormatAtIndex(index))); + return SBTypeNameSpecifier(); + return SBTypeNameSpecifier( + m_opaque_sp->GetTypeNameSpecifierForFormatAtIndex(index)); } lldb::SBTypeNameSpecifier SBTypeCategory::GetTypeNameSpecifierForSummaryAtIndex(uint32_t index) { - LLDB_RECORD_METHOD(lldb::SBTypeNameSpecifier, SBTypeCategory, - GetTypeNameSpecifierForSummaryAtIndex, (uint32_t), index); + LLDB_INSTRUMENT_VA(this, index); if (!IsValid()) - return LLDB_RECORD_RESULT(SBTypeNameSpecifier()); - return LLDB_RECORD_RESULT(SBTypeNameSpecifier( - m_opaque_sp->GetTypeNameSpecifierForSummaryAtIndex(index))); + return SBTypeNameSpecifier(); + return SBTypeNameSpecifier( + m_opaque_sp->GetTypeNameSpecifierForSummaryAtIndex(index)); } lldb::SBTypeNameSpecifier SBTypeCategory::GetTypeNameSpecifierForSyntheticAtIndex(uint32_t index) { - LLDB_RECORD_METHOD(lldb::SBTypeNameSpecifier, SBTypeCategory, - GetTypeNameSpecifierForSyntheticAtIndex, (uint32_t), - index); + LLDB_INSTRUMENT_VA(this, index); if (!IsValid()) - return LLDB_RECORD_RESULT(SBTypeNameSpecifier()); - return LLDB_RECORD_RESULT(SBTypeNameSpecifier( - m_opaque_sp->GetTypeNameSpecifierForSyntheticAtIndex(index))); + return SBTypeNameSpecifier(); + return SBTypeNameSpecifier( + m_opaque_sp->GetTypeNameSpecifierForSyntheticAtIndex(index)); } SBTypeFilter SBTypeCategory::GetFilterForType(SBTypeNameSpecifier spec) { - LLDB_RECORD_METHOD(lldb::SBTypeFilter, SBTypeCategory, GetFilterForType, - (lldb::SBTypeNameSpecifier), spec); + LLDB_INSTRUMENT_VA(this, spec); if (!IsValid()) - return LLDB_RECORD_RESULT(SBTypeFilter()); + return SBTypeFilter(); if (!spec.IsValid()) - return LLDB_RECORD_RESULT(SBTypeFilter()); + return SBTypeFilter(); lldb::TypeFilterImplSP children_sp; @@ -205,22 +195,21 @@ SBTypeFilter SBTypeCategory::GetFilterForType(SBTypeNameSpecifier spec) { ConstString(spec.GetName()), children_sp); if (!children_sp) - return LLDB_RECORD_RESULT(lldb::SBTypeFilter()); + return lldb::SBTypeFilter(); TypeFilterImplSP filter_sp = std::static_pointer_cast<TypeFilterImpl>(children_sp); - return LLDB_RECORD_RESULT(lldb::SBTypeFilter(filter_sp)); + return lldb::SBTypeFilter(filter_sp); } SBTypeFormat SBTypeCategory::GetFormatForType(SBTypeNameSpecifier spec) { - LLDB_RECORD_METHOD(lldb::SBTypeFormat, SBTypeCategory, GetFormatForType, - (lldb::SBTypeNameSpecifier), spec); + LLDB_INSTRUMENT_VA(this, spec); if (!IsValid()) - return LLDB_RECORD_RESULT(SBTypeFormat()); + return SBTypeFormat(); if (!spec.IsValid()) - return LLDB_RECORD_RESULT(SBTypeFormat()); + return SBTypeFormat(); lldb::TypeFormatImplSP format_sp; @@ -232,20 +221,19 @@ SBTypeFormat SBTypeCategory::GetFormatForType(SBTypeNameSpecifier spec) { ConstString(spec.GetName()), format_sp); if (!format_sp) - return LLDB_RECORD_RESULT(lldb::SBTypeFormat()); + return lldb::SBTypeFormat(); - return LLDB_RECORD_RESULT(lldb::SBTypeFormat(format_sp)); + return lldb::SBTypeFormat(format_sp); } SBTypeSummary SBTypeCategory::GetSummaryForType(SBTypeNameSpecifier spec) { - LLDB_RECORD_METHOD(lldb::SBTypeSummary, SBTypeCategory, GetSummaryForType, - (lldb::SBTypeNameSpecifier), spec); + LLDB_INSTRUMENT_VA(this, spec); if (!IsValid()) - return LLDB_RECORD_RESULT(SBTypeSummary()); + return SBTypeSummary(); if (!spec.IsValid()) - return LLDB_RECORD_RESULT(SBTypeSummary()); + return SBTypeSummary(); lldb::TypeSummaryImplSP summary_sp; @@ -257,20 +245,19 @@ SBTypeSummary SBTypeCategory::GetSummaryForType(SBTypeNameSpecifier spec) { ConstString(spec.GetName()), summary_sp); if (!summary_sp) - return LLDB_RECORD_RESULT(lldb::SBTypeSummary()); + return lldb::SBTypeSummary(); - return LLDB_RECORD_RESULT(lldb::SBTypeSummary(summary_sp)); + return lldb::SBTypeSummary(summary_sp); } SBTypeSynthetic SBTypeCategory::GetSyntheticForType(SBTypeNameSpecifier spec) { - LLDB_RECORD_METHOD(lldb::SBTypeSynthetic, SBTypeCategory, GetSyntheticForType, - (lldb::SBTypeNameSpecifier), spec); + LLDB_INSTRUMENT_VA(this, spec); if (!IsValid()) - return LLDB_RECORD_RESULT(SBTypeSynthetic()); + return SBTypeSynthetic(); if (!spec.IsValid()) - return LLDB_RECORD_RESULT(SBTypeSynthetic()); + return SBTypeSynthetic(); lldb::SyntheticChildrenSP children_sp; @@ -282,75 +269,67 @@ SBTypeSynthetic SBTypeCategory::GetSyntheticForType(SBTypeNameSpecifier spec) { ConstString(spec.GetName()), children_sp); if (!children_sp) - return LLDB_RECORD_RESULT(lldb::SBTypeSynthetic()); + return lldb::SBTypeSynthetic(); ScriptedSyntheticChildrenSP synth_sp = std::static_pointer_cast<ScriptedSyntheticChildren>(children_sp); - return LLDB_RECORD_RESULT(lldb::SBTypeSynthetic(synth_sp)); + return lldb::SBTypeSynthetic(synth_sp); } SBTypeFilter SBTypeCategory::GetFilterAtIndex(uint32_t index) { - LLDB_RECORD_METHOD(lldb::SBTypeFilter, SBTypeCategory, GetFilterAtIndex, - (uint32_t), index); + LLDB_INSTRUMENT_VA(this, index); if (!IsValid()) - return LLDB_RECORD_RESULT(SBTypeFilter()); + return SBTypeFilter(); lldb::SyntheticChildrenSP children_sp = m_opaque_sp->GetSyntheticAtIndex((index)); if (!children_sp.get()) - return LLDB_RECORD_RESULT(lldb::SBTypeFilter()); + return lldb::SBTypeFilter(); TypeFilterImplSP filter_sp = std::static_pointer_cast<TypeFilterImpl>(children_sp); - return LLDB_RECORD_RESULT(lldb::SBTypeFilter(filter_sp)); + return lldb::SBTypeFilter(filter_sp); } SBTypeFormat SBTypeCategory::GetFormatAtIndex(uint32_t index) { - LLDB_RECORD_METHOD(lldb::SBTypeFormat, SBTypeCategory, GetFormatAtIndex, - (uint32_t), index); + LLDB_INSTRUMENT_VA(this, index); if (!IsValid()) - return LLDB_RECORD_RESULT(SBTypeFormat()); - return LLDB_RECORD_RESULT( - SBTypeFormat(m_opaque_sp->GetFormatAtIndex((index)))); + return SBTypeFormat(); + return SBTypeFormat(m_opaque_sp->GetFormatAtIndex((index))); } SBTypeSummary SBTypeCategory::GetSummaryAtIndex(uint32_t index) { - LLDB_RECORD_METHOD(lldb::SBTypeSummary, SBTypeCategory, GetSummaryAtIndex, - (uint32_t), index); + LLDB_INSTRUMENT_VA(this, index); if (!IsValid()) - return LLDB_RECORD_RESULT(SBTypeSummary()); - return LLDB_RECORD_RESULT( - SBTypeSummary(m_opaque_sp->GetSummaryAtIndex((index)))); + return SBTypeSummary(); + return SBTypeSummary(m_opaque_sp->GetSummaryAtIndex((index))); } SBTypeSynthetic SBTypeCategory::GetSyntheticAtIndex(uint32_t index) { - LLDB_RECORD_METHOD(lldb::SBTypeSynthetic, SBTypeCategory, GetSyntheticAtIndex, - (uint32_t), index); + LLDB_INSTRUMENT_VA(this, index); if (!IsValid()) - return LLDB_RECORD_RESULT(SBTypeSynthetic()); + return SBTypeSynthetic(); lldb::SyntheticChildrenSP children_sp = m_opaque_sp->GetSyntheticAtIndex((index)); if (!children_sp.get()) - return LLDB_RECORD_RESULT(lldb::SBTypeSynthetic()); + return lldb::SBTypeSynthetic(); ScriptedSyntheticChildrenSP synth_sp = std::static_pointer_cast<ScriptedSyntheticChildren>(children_sp); - return LLDB_RECORD_RESULT(lldb::SBTypeSynthetic(synth_sp)); + return lldb::SBTypeSynthetic(synth_sp); } bool SBTypeCategory::AddTypeFormat(SBTypeNameSpecifier type_name, SBTypeFormat format) { - LLDB_RECORD_METHOD(bool, SBTypeCategory, AddTypeFormat, - (lldb::SBTypeNameSpecifier, lldb::SBTypeFormat), type_name, - format); + LLDB_INSTRUMENT_VA(this, type_name, format); if (!IsValid()) return false; @@ -372,8 +351,7 @@ bool SBTypeCategory::AddTypeFormat(SBTypeNameSpecifier type_name, } bool SBTypeCategory::DeleteTypeFormat(SBTypeNameSpecifier type_name) { - LLDB_RECORD_METHOD(bool, SBTypeCategory, DeleteTypeFormat, - (lldb::SBTypeNameSpecifier), type_name); + LLDB_INSTRUMENT_VA(this, type_name); if (!IsValid()) return false; @@ -391,9 +369,7 @@ bool SBTypeCategory::DeleteTypeFormat(SBTypeNameSpecifier type_name) { bool SBTypeCategory::AddTypeSummary(SBTypeNameSpecifier type_name, SBTypeSummary summary) { - LLDB_RECORD_METHOD(bool, SBTypeCategory, AddTypeSummary, - (lldb::SBTypeNameSpecifier, lldb::SBTypeSummary), - type_name, summary); + LLDB_INSTRUMENT_VA(this, type_name, summary); if (!IsValid()) return false; @@ -449,8 +425,7 @@ bool SBTypeCategory::AddTypeSummary(SBTypeNameSpecifier type_name, } bool SBTypeCategory::DeleteTypeSummary(SBTypeNameSpecifier type_name) { - LLDB_RECORD_METHOD(bool, SBTypeCategory, DeleteTypeSummary, - (lldb::SBTypeNameSpecifier), type_name); + LLDB_INSTRUMENT_VA(this, type_name); if (!IsValid()) return false; @@ -468,9 +443,7 @@ bool SBTypeCategory::DeleteTypeSummary(SBTypeNameSpecifier type_name) { bool SBTypeCategory::AddTypeFilter(SBTypeNameSpecifier type_name, SBTypeFilter filter) { - LLDB_RECORD_METHOD(bool, SBTypeCategory, AddTypeFilter, - (lldb::SBTypeNameSpecifier, lldb::SBTypeFilter), type_name, - filter); + LLDB_INSTRUMENT_VA(this, type_name, filter); if (!IsValid()) return false; @@ -492,8 +465,7 @@ bool SBTypeCategory::AddTypeFilter(SBTypeNameSpecifier type_name, } bool SBTypeCategory::DeleteTypeFilter(SBTypeNameSpecifier type_name) { - LLDB_RECORD_METHOD(bool, SBTypeCategory, DeleteTypeFilter, - (lldb::SBTypeNameSpecifier), type_name); + LLDB_INSTRUMENT_VA(this, type_name); if (!IsValid()) return false; @@ -511,9 +483,7 @@ bool SBTypeCategory::DeleteTypeFilter(SBTypeNameSpecifier type_name) { bool SBTypeCategory::AddTypeSynthetic(SBTypeNameSpecifier type_name, SBTypeSynthetic synth) { - LLDB_RECORD_METHOD(bool, SBTypeCategory, AddTypeSynthetic, - (lldb::SBTypeNameSpecifier, lldb::SBTypeSynthetic), - type_name, synth); + LLDB_INSTRUMENT_VA(this, type_name, synth); if (!IsValid()) return false; @@ -569,8 +539,7 @@ bool SBTypeCategory::AddTypeSynthetic(SBTypeNameSpecifier type_name, } bool SBTypeCategory::DeleteTypeSynthetic(SBTypeNameSpecifier type_name) { - LLDB_RECORD_METHOD(bool, SBTypeCategory, DeleteTypeSynthetic, - (lldb::SBTypeNameSpecifier), type_name); + LLDB_INSTRUMENT_VA(this, type_name); if (!IsValid()) return false; @@ -588,9 +557,7 @@ bool SBTypeCategory::DeleteTypeSynthetic(SBTypeNameSpecifier type_name) { bool SBTypeCategory::GetDescription(lldb::SBStream &description, lldb::DescriptionLevel description_level) { - LLDB_RECORD_METHOD(bool, SBTypeCategory, GetDescription, - (lldb::SBStream &, lldb::DescriptionLevel), description, - description_level); + LLDB_INSTRUMENT_VA(this, description, description_level); if (!IsValid()) return false; @@ -600,19 +567,16 @@ bool SBTypeCategory::GetDescription(lldb::SBStream &description, lldb::SBTypeCategory &SBTypeCategory:: operator=(const lldb::SBTypeCategory &rhs) { - LLDB_RECORD_METHOD(lldb::SBTypeCategory &, - SBTypeCategory, operator=,(const lldb::SBTypeCategory &), - rhs); + LLDB_INSTRUMENT_VA(this, rhs); if (this != &rhs) { m_opaque_sp = rhs.m_opaque_sp; } - return LLDB_RECORD_RESULT(*this); + return *this; } bool SBTypeCategory::operator==(lldb::SBTypeCategory &rhs) { - LLDB_RECORD_METHOD(bool, SBTypeCategory, operator==,(lldb::SBTypeCategory &), - rhs); + LLDB_INSTRUMENT_VA(this, rhs); if (!IsValid()) return !rhs.IsValid(); @@ -621,8 +585,7 @@ bool SBTypeCategory::operator==(lldb::SBTypeCategory &rhs) { } bool SBTypeCategory::operator!=(lldb::SBTypeCategory &rhs) { - LLDB_RECORD_METHOD(bool, SBTypeCategory, operator!=,(lldb::SBTypeCategory &), - rhs); + LLDB_INSTRUMENT_VA(this, rhs); if (!IsValid()) return rhs.IsValid(); @@ -651,78 +614,3 @@ bool SBTypeCategory::IsDefaultCategory() { return (strcmp(m_opaque_sp->GetName(), "default") == 0); } - -namespace lldb_private { -namespace repro { - -template <> -void RegisterMethods<SBTypeCategory>(Registry &R) { - LLDB_REGISTER_CONSTRUCTOR(SBTypeCategory, ()); - LLDB_REGISTER_CONSTRUCTOR(SBTypeCategory, (const lldb::SBTypeCategory &)); - LLDB_REGISTER_METHOD_CONST(bool, SBTypeCategory, IsValid, ()); - LLDB_REGISTER_METHOD_CONST(bool, SBTypeCategory, operator bool, ()); - LLDB_REGISTER_METHOD(bool, SBTypeCategory, GetEnabled, ()); - LLDB_REGISTER_METHOD(void, SBTypeCategory, SetEnabled, (bool)); - LLDB_REGISTER_METHOD(const char *, SBTypeCategory, GetName, ()); - LLDB_REGISTER_METHOD(lldb::LanguageType, SBTypeCategory, GetLanguageAtIndex, - (uint32_t)); - LLDB_REGISTER_METHOD(uint32_t, SBTypeCategory, GetNumLanguages, ()); - LLDB_REGISTER_METHOD(void, SBTypeCategory, AddLanguage, - (lldb::LanguageType)); - LLDB_REGISTER_METHOD(uint32_t, SBTypeCategory, GetNumFormats, ()); - LLDB_REGISTER_METHOD(uint32_t, SBTypeCategory, GetNumSummaries, ()); - LLDB_REGISTER_METHOD(uint32_t, SBTypeCategory, GetNumFilters, ()); - LLDB_REGISTER_METHOD(uint32_t, SBTypeCategory, GetNumSynthetics, ()); - LLDB_REGISTER_METHOD(lldb::SBTypeNameSpecifier, SBTypeCategory, - GetTypeNameSpecifierForSyntheticAtIndex, (uint32_t)); - LLDB_REGISTER_METHOD(lldb::SBTypeSummary, SBTypeCategory, GetSummaryForType, - (lldb::SBTypeNameSpecifier)); - LLDB_REGISTER_METHOD(lldb::SBTypeSynthetic, SBTypeCategory, - GetSyntheticForType, (lldb::SBTypeNameSpecifier)); - LLDB_REGISTER_METHOD(lldb::SBTypeFilter, SBTypeCategory, GetFilterAtIndex, - (uint32_t)); - LLDB_REGISTER_METHOD(lldb::SBTypeSummary, SBTypeCategory, GetSummaryAtIndex, - (uint32_t)); - LLDB_REGISTER_METHOD(lldb::SBTypeSynthetic, SBTypeCategory, - GetSyntheticAtIndex, (uint32_t)); - LLDB_REGISTER_METHOD(bool, SBTypeCategory, AddTypeSummary, - (lldb::SBTypeNameSpecifier, lldb::SBTypeSummary)); - LLDB_REGISTER_METHOD(bool, SBTypeCategory, AddTypeSynthetic, - (lldb::SBTypeNameSpecifier, lldb::SBTypeSynthetic)); - LLDB_REGISTER_METHOD(bool, SBTypeCategory, DeleteTypeSynthetic, - (lldb::SBTypeNameSpecifier)); - LLDB_REGISTER_METHOD(lldb::SBTypeNameSpecifier, SBTypeCategory, - GetTypeNameSpecifierForFilterAtIndex, (uint32_t)); - LLDB_REGISTER_METHOD(lldb::SBTypeNameSpecifier, SBTypeCategory, - GetTypeNameSpecifierForFormatAtIndex, (uint32_t)); - LLDB_REGISTER_METHOD(lldb::SBTypeNameSpecifier, SBTypeCategory, - GetTypeNameSpecifierForSummaryAtIndex, (uint32_t)); - LLDB_REGISTER_METHOD(lldb::SBTypeFilter, SBTypeCategory, GetFilterForType, - (lldb::SBTypeNameSpecifier)); - LLDB_REGISTER_METHOD(lldb::SBTypeFormat, SBTypeCategory, GetFormatForType, - (lldb::SBTypeNameSpecifier)); - LLDB_REGISTER_METHOD(lldb::SBTypeFormat, SBTypeCategory, GetFormatAtIndex, - (uint32_t)); - LLDB_REGISTER_METHOD(bool, SBTypeCategory, AddTypeFormat, - (lldb::SBTypeNameSpecifier, lldb::SBTypeFormat)); - LLDB_REGISTER_METHOD(bool, SBTypeCategory, DeleteTypeFormat, - (lldb::SBTypeNameSpecifier)); - LLDB_REGISTER_METHOD(bool, SBTypeCategory, DeleteTypeSummary, - (lldb::SBTypeNameSpecifier)); - LLDB_REGISTER_METHOD(bool, SBTypeCategory, AddTypeFilter, - (lldb::SBTypeNameSpecifier, lldb::SBTypeFilter)); - LLDB_REGISTER_METHOD(bool, SBTypeCategory, DeleteTypeFilter, - (lldb::SBTypeNameSpecifier)); - LLDB_REGISTER_METHOD(bool, SBTypeCategory, GetDescription, - (lldb::SBStream &, lldb::DescriptionLevel)); - LLDB_REGISTER_METHOD( - lldb::SBTypeCategory &, - SBTypeCategory, operator=,(const lldb::SBTypeCategory &)); - LLDB_REGISTER_METHOD(bool, - SBTypeCategory, operator==,(lldb::SBTypeCategory &)); - LLDB_REGISTER_METHOD(bool, - SBTypeCategory, operator!=,(lldb::SBTypeCategory &)); -} - -} -} diff --git a/lldb/source/API/SBTypeEnumMember.cpp b/lldb/source/API/SBTypeEnumMember.cpp index 43a4891b54b1..a3d99bd57e31 100644 --- a/lldb/source/API/SBTypeEnumMember.cpp +++ b/lldb/source/API/SBTypeEnumMember.cpp @@ -7,13 +7,13 @@ //===----------------------------------------------------------------------===// #include "lldb/API/SBTypeEnumMember.h" -#include "SBReproducerPrivate.h" #include "Utils.h" #include "lldb/API/SBDefines.h" #include "lldb/API/SBStream.h" #include "lldb/API/SBType.h" #include "lldb/Symbol/CompilerType.h" #include "lldb/Symbol/Type.h" +#include "lldb/Utility/Instrumentation.h" #include "lldb/Utility/Stream.h" #include <memory> @@ -21,9 +21,7 @@ using namespace lldb; using namespace lldb_private; -SBTypeEnumMember::SBTypeEnumMember() : m_opaque_sp() { - LLDB_RECORD_CONSTRUCTOR_NO_ARGS(SBTypeEnumMember); -} +SBTypeEnumMember::SBTypeEnumMember() { LLDB_INSTRUMENT_VA(this); } SBTypeEnumMember::~SBTypeEnumMember() = default; @@ -31,36 +29,32 @@ SBTypeEnumMember::SBTypeEnumMember( const lldb::TypeEnumMemberImplSP &enum_member_sp) : m_opaque_sp(enum_member_sp) {} -SBTypeEnumMember::SBTypeEnumMember(const SBTypeEnumMember &rhs) - : m_opaque_sp() { - LLDB_RECORD_CONSTRUCTOR(SBTypeEnumMember, (const lldb::SBTypeEnumMember &), - rhs); +SBTypeEnumMember::SBTypeEnumMember(const SBTypeEnumMember &rhs) { + LLDB_INSTRUMENT_VA(this, rhs); m_opaque_sp = clone(rhs.m_opaque_sp); } SBTypeEnumMember &SBTypeEnumMember::operator=(const SBTypeEnumMember &rhs) { - LLDB_RECORD_METHOD( - SBTypeEnumMember &, - SBTypeEnumMember, operator=,(const lldb::SBTypeEnumMember &), rhs); + LLDB_INSTRUMENT_VA(this, rhs); if (this != &rhs) m_opaque_sp = clone(rhs.m_opaque_sp); - return LLDB_RECORD_RESULT(*this); + return *this; } bool SBTypeEnumMember::IsValid() const { - LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBTypeEnumMember, IsValid); + LLDB_INSTRUMENT_VA(this); return this->operator bool(); } SBTypeEnumMember::operator bool() const { - LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBTypeEnumMember, operator bool); + LLDB_INSTRUMENT_VA(this); return m_opaque_sp.get(); } const char *SBTypeEnumMember::GetName() { - LLDB_RECORD_METHOD_NO_ARGS(const char *, SBTypeEnumMember, GetName); + LLDB_INSTRUMENT_VA(this); if (m_opaque_sp.get()) return m_opaque_sp->GetName().GetCString(); @@ -68,7 +62,7 @@ const char *SBTypeEnumMember::GetName() { } int64_t SBTypeEnumMember::GetValueAsSigned() { - LLDB_RECORD_METHOD_NO_ARGS(int64_t, SBTypeEnumMember, GetValueAsSigned); + LLDB_INSTRUMENT_VA(this); if (m_opaque_sp.get()) return m_opaque_sp->GetValueAsSigned(); @@ -76,7 +70,7 @@ int64_t SBTypeEnumMember::GetValueAsSigned() { } uint64_t SBTypeEnumMember::GetValueAsUnsigned() { - LLDB_RECORD_METHOD_NO_ARGS(uint64_t, SBTypeEnumMember, GetValueAsUnsigned); + LLDB_INSTRUMENT_VA(this); if (m_opaque_sp.get()) return m_opaque_sp->GetValueAsUnsigned(); @@ -84,13 +78,13 @@ uint64_t SBTypeEnumMember::GetValueAsUnsigned() { } SBType SBTypeEnumMember::GetType() { - LLDB_RECORD_METHOD_NO_ARGS(lldb::SBType, SBTypeEnumMember, GetType); + LLDB_INSTRUMENT_VA(this); SBType sb_type; if (m_opaque_sp.get()) { sb_type.SetSP(m_opaque_sp->GetIntegerType()); } - return LLDB_RECORD_RESULT(sb_type); + return sb_type; } void SBTypeEnumMember::reset(TypeEnumMemberImpl *type_member_impl) { @@ -109,13 +103,12 @@ const TypeEnumMemberImpl &SBTypeEnumMember::ref() const { SBTypeEnumMemberList::SBTypeEnumMemberList() : m_opaque_up(new TypeEnumMemberListImpl()) { - LLDB_RECORD_CONSTRUCTOR_NO_ARGS(SBTypeEnumMemberList); + LLDB_INSTRUMENT_VA(this); } SBTypeEnumMemberList::SBTypeEnumMemberList(const SBTypeEnumMemberList &rhs) : m_opaque_up(new TypeEnumMemberListImpl()) { - LLDB_RECORD_CONSTRUCTOR(SBTypeEnumMemberList, - (const lldb::SBTypeEnumMemberList &), rhs); + LLDB_INSTRUMENT_VA(this, rhs); for (uint32_t i = 0, rhs_size = const_cast<SBTypeEnumMemberList &>(rhs).GetSize(); @@ -124,21 +117,18 @@ SBTypeEnumMemberList::SBTypeEnumMemberList(const SBTypeEnumMemberList &rhs) } bool SBTypeEnumMemberList::IsValid() { - LLDB_RECORD_METHOD_NO_ARGS(bool, SBTypeEnumMemberList, IsValid); + LLDB_INSTRUMENT_VA(this); return this->operator bool(); } SBTypeEnumMemberList::operator bool() const { - LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBTypeEnumMemberList, operator bool); + LLDB_INSTRUMENT_VA(this); return (m_opaque_up != nullptr); } SBTypeEnumMemberList &SBTypeEnumMemberList:: operator=(const SBTypeEnumMemberList &rhs) { - LLDB_RECORD_METHOD( - lldb::SBTypeEnumMemberList &, - SBTypeEnumMemberList, operator=,(const lldb::SBTypeEnumMemberList &), - rhs); + LLDB_INSTRUMENT_VA(this, rhs); if (this != &rhs) { m_opaque_up = std::make_unique<TypeEnumMemberListImpl>(); @@ -148,12 +138,11 @@ operator=(const SBTypeEnumMemberList &rhs) { Append( const_cast<SBTypeEnumMemberList &>(rhs).GetTypeEnumMemberAtIndex(i)); } - return LLDB_RECORD_RESULT(*this); + return *this; } void SBTypeEnumMemberList::Append(SBTypeEnumMember enum_member) { - LLDB_RECORD_METHOD(void, SBTypeEnumMemberList, Append, - (lldb::SBTypeEnumMember), enum_member); + LLDB_INSTRUMENT_VA(this, enum_member); if (enum_member.IsValid()) m_opaque_up->Append(enum_member.m_opaque_sp); @@ -161,17 +150,15 @@ void SBTypeEnumMemberList::Append(SBTypeEnumMember enum_member) { SBTypeEnumMember SBTypeEnumMemberList::GetTypeEnumMemberAtIndex(uint32_t index) { - LLDB_RECORD_METHOD(lldb::SBTypeEnumMember, SBTypeEnumMemberList, - GetTypeEnumMemberAtIndex, (uint32_t), index); + LLDB_INSTRUMENT_VA(this, index); if (m_opaque_up) - return LLDB_RECORD_RESULT( - SBTypeEnumMember(m_opaque_up->GetTypeEnumMemberAtIndex(index))); - return LLDB_RECORD_RESULT(SBTypeEnumMember()); + return SBTypeEnumMember(m_opaque_up->GetTypeEnumMemberAtIndex(index)); + return SBTypeEnumMember(); } uint32_t SBTypeEnumMemberList::GetSize() { - LLDB_RECORD_METHOD_NO_ARGS(uint32_t, SBTypeEnumMemberList, GetSize); + LLDB_INSTRUMENT_VA(this); return m_opaque_up->GetSize(); } @@ -180,9 +167,7 @@ SBTypeEnumMemberList::~SBTypeEnumMemberList() = default; bool SBTypeEnumMember::GetDescription( lldb::SBStream &description, lldb::DescriptionLevel description_level) { - LLDB_RECORD_METHOD(bool, SBTypeEnumMember, GetDescription, - (lldb::SBStream &, lldb::DescriptionLevel), description, - description_level); + LLDB_INSTRUMENT_VA(this, description, description_level); Stream &strm = description.ref(); @@ -196,40 +181,3 @@ bool SBTypeEnumMember::GetDescription( } return true; } - -namespace lldb_private { -namespace repro { - -template <> -void RegisterMethods<SBTypeEnumMember>(Registry &R) { - LLDB_REGISTER_CONSTRUCTOR(SBTypeEnumMember, ()); - LLDB_REGISTER_CONSTRUCTOR(SBTypeEnumMember, - (const lldb::SBTypeEnumMember &)); - LLDB_REGISTER_METHOD( - lldb::SBTypeEnumMember &, - SBTypeEnumMember, operator=,(const lldb::SBTypeEnumMember &)); - LLDB_REGISTER_METHOD_CONST(bool, SBTypeEnumMember, IsValid, ()); - LLDB_REGISTER_METHOD_CONST(bool, SBTypeEnumMember, operator bool, ()); - LLDB_REGISTER_METHOD(const char *, SBTypeEnumMember, GetName, ()); - LLDB_REGISTER_METHOD(int64_t, SBTypeEnumMember, GetValueAsSigned, ()); - LLDB_REGISTER_METHOD(uint64_t, SBTypeEnumMember, GetValueAsUnsigned, ()); - LLDB_REGISTER_METHOD(lldb::SBType, SBTypeEnumMember, GetType, ()); - LLDB_REGISTER_CONSTRUCTOR(SBTypeEnumMemberList, ()); - LLDB_REGISTER_CONSTRUCTOR(SBTypeEnumMemberList, - (const lldb::SBTypeEnumMemberList &)); - LLDB_REGISTER_METHOD(bool, SBTypeEnumMemberList, IsValid, ()); - LLDB_REGISTER_METHOD_CONST(bool, SBTypeEnumMemberList, operator bool, ()); - LLDB_REGISTER_METHOD( - lldb::SBTypeEnumMemberList &, - SBTypeEnumMemberList, operator=,(const lldb::SBTypeEnumMemberList &)); - LLDB_REGISTER_METHOD(void, SBTypeEnumMemberList, Append, - (lldb::SBTypeEnumMember)); - LLDB_REGISTER_METHOD(lldb::SBTypeEnumMember, SBTypeEnumMemberList, - GetTypeEnumMemberAtIndex, (uint32_t)); - LLDB_REGISTER_METHOD(uint32_t, SBTypeEnumMemberList, GetSize, ()); - LLDB_REGISTER_METHOD(bool, SBTypeEnumMember, GetDescription, - (lldb::SBStream &, lldb::DescriptionLevel)); -} - -} -} diff --git a/lldb/source/API/SBTypeFilter.cpp b/lldb/source/API/SBTypeFilter.cpp index 5f91a194f16b..94f222b254b2 100644 --- a/lldb/source/API/SBTypeFilter.cpp +++ b/lldb/source/API/SBTypeFilter.cpp @@ -7,7 +7,7 @@ //===----------------------------------------------------------------------===// #include "lldb/API/SBTypeFilter.h" -#include "SBReproducerPrivate.h" +#include "lldb/Utility/Instrumentation.h" #include "lldb/API/SBStream.h" @@ -16,34 +16,32 @@ using namespace lldb; using namespace lldb_private; -SBTypeFilter::SBTypeFilter() : m_opaque_sp() { - LLDB_RECORD_CONSTRUCTOR_NO_ARGS(SBTypeFilter); -} +SBTypeFilter::SBTypeFilter() { LLDB_INSTRUMENT_VA(this); } SBTypeFilter::SBTypeFilter(uint32_t options) : m_opaque_sp(TypeFilterImplSP(new TypeFilterImpl(options))) { - LLDB_RECORD_CONSTRUCTOR(SBTypeFilter, (uint32_t), options); + LLDB_INSTRUMENT_VA(this, options); } SBTypeFilter::SBTypeFilter(const lldb::SBTypeFilter &rhs) : m_opaque_sp(rhs.m_opaque_sp) { - LLDB_RECORD_CONSTRUCTOR(SBTypeFilter, (const lldb::SBTypeFilter &), rhs); + LLDB_INSTRUMENT_VA(this, rhs); } SBTypeFilter::~SBTypeFilter() = default; bool SBTypeFilter::IsValid() const { - LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBTypeFilter, IsValid); + LLDB_INSTRUMENT_VA(this); return this->operator bool(); } SBTypeFilter::operator bool() const { - LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBTypeFilter, operator bool); + LLDB_INSTRUMENT_VA(this); return m_opaque_sp.get() != nullptr; } uint32_t SBTypeFilter::GetOptions() { - LLDB_RECORD_METHOD_NO_ARGS(uint32_t, SBTypeFilter, GetOptions); + LLDB_INSTRUMENT_VA(this); if (IsValid()) return m_opaque_sp->GetOptions(); @@ -51,7 +49,7 @@ uint32_t SBTypeFilter::GetOptions() { } void SBTypeFilter::SetOptions(uint32_t value) { - LLDB_RECORD_METHOD(void, SBTypeFilter, SetOptions, (uint32_t), value); + LLDB_INSTRUMENT_VA(this, value); if (CopyOnWrite_Impl()) m_opaque_sp->SetOptions(value); @@ -59,9 +57,7 @@ void SBTypeFilter::SetOptions(uint32_t value) { bool SBTypeFilter::GetDescription(lldb::SBStream &description, lldb::DescriptionLevel description_level) { - LLDB_RECORD_METHOD(bool, SBTypeFilter, GetDescription, - (lldb::SBStream &, lldb::DescriptionLevel), description, - description_level); + LLDB_INSTRUMENT_VA(this, description, description_level); if (!IsValid()) return false; @@ -72,15 +68,14 @@ bool SBTypeFilter::GetDescription(lldb::SBStream &description, } void SBTypeFilter::Clear() { - LLDB_RECORD_METHOD_NO_ARGS(void, SBTypeFilter, Clear); + LLDB_INSTRUMENT_VA(this); if (CopyOnWrite_Impl()) m_opaque_sp->Clear(); } uint32_t SBTypeFilter::GetNumberOfExpressionPaths() { - LLDB_RECORD_METHOD_NO_ARGS(uint32_t, SBTypeFilter, - GetNumberOfExpressionPaths); + LLDB_INSTRUMENT_VA(this); if (IsValid()) return m_opaque_sp->GetCount(); @@ -88,8 +83,7 @@ uint32_t SBTypeFilter::GetNumberOfExpressionPaths() { } const char *SBTypeFilter::GetExpressionPathAtIndex(uint32_t i) { - LLDB_RECORD_METHOD(const char *, SBTypeFilter, GetExpressionPathAtIndex, - (uint32_t), i); + LLDB_INSTRUMENT_VA(this, i); if (IsValid()) { const char *item = m_opaque_sp->GetExpressionPathAtIndex(i); @@ -101,8 +95,7 @@ const char *SBTypeFilter::GetExpressionPathAtIndex(uint32_t i) { } bool SBTypeFilter::ReplaceExpressionPathAtIndex(uint32_t i, const char *item) { - LLDB_RECORD_METHOD(bool, SBTypeFilter, ReplaceExpressionPathAtIndex, - (uint32_t, const char *), i, item); + LLDB_INSTRUMENT_VA(this, i, item); if (CopyOnWrite_Impl()) return m_opaque_sp->SetExpressionPathAtIndex(i, item); @@ -111,26 +104,23 @@ bool SBTypeFilter::ReplaceExpressionPathAtIndex(uint32_t i, const char *item) { } void SBTypeFilter::AppendExpressionPath(const char *item) { - LLDB_RECORD_METHOD(void, SBTypeFilter, AppendExpressionPath, (const char *), - item); + LLDB_INSTRUMENT_VA(this, item); if (CopyOnWrite_Impl()) m_opaque_sp->AddExpressionPath(item); } lldb::SBTypeFilter &SBTypeFilter::operator=(const lldb::SBTypeFilter &rhs) { - LLDB_RECORD_METHOD(lldb::SBTypeFilter &, - SBTypeFilter, operator=,(const lldb::SBTypeFilter &), rhs); + LLDB_INSTRUMENT_VA(this, rhs); if (this != &rhs) { m_opaque_sp = rhs.m_opaque_sp; } - return LLDB_RECORD_RESULT(*this); + return *this; } bool SBTypeFilter::operator==(lldb::SBTypeFilter &rhs) { - LLDB_RECORD_METHOD(bool, SBTypeFilter, operator==,(lldb::SBTypeFilter &), - rhs); + LLDB_INSTRUMENT_VA(this, rhs); if (!IsValid()) return !rhs.IsValid(); @@ -139,8 +129,7 @@ bool SBTypeFilter::operator==(lldb::SBTypeFilter &rhs) { } bool SBTypeFilter::IsEqualTo(lldb::SBTypeFilter &rhs) { - LLDB_RECORD_METHOD(bool, SBTypeFilter, IsEqualTo, (lldb::SBTypeFilter &), - rhs); + LLDB_INSTRUMENT_VA(this, rhs); if (!IsValid()) return !rhs.IsValid(); @@ -157,8 +146,7 @@ bool SBTypeFilter::IsEqualTo(lldb::SBTypeFilter &rhs) { } bool SBTypeFilter::operator!=(lldb::SBTypeFilter &rhs) { - LLDB_RECORD_METHOD(bool, SBTypeFilter, operator!=,(lldb::SBTypeFilter &), - rhs); + LLDB_INSTRUMENT_VA(this, rhs); if (!IsValid()) return !rhs.IsValid(); @@ -190,36 +178,3 @@ bool SBTypeFilter::CopyOnWrite_Impl() { return true; } - -namespace lldb_private { -namespace repro { - -template <> -void RegisterMethods<SBTypeFilter>(Registry &R) { - LLDB_REGISTER_CONSTRUCTOR(SBTypeFilter, ()); - LLDB_REGISTER_CONSTRUCTOR(SBTypeFilter, (uint32_t)); - LLDB_REGISTER_CONSTRUCTOR(SBTypeFilter, (const lldb::SBTypeFilter &)); - LLDB_REGISTER_METHOD_CONST(bool, SBTypeFilter, IsValid, ()); - LLDB_REGISTER_METHOD_CONST(bool, SBTypeFilter, operator bool, ()); - LLDB_REGISTER_METHOD(uint32_t, SBTypeFilter, GetOptions, ()); - LLDB_REGISTER_METHOD(void, SBTypeFilter, SetOptions, (uint32_t)); - LLDB_REGISTER_METHOD(bool, SBTypeFilter, GetDescription, - (lldb::SBStream &, lldb::DescriptionLevel)); - LLDB_REGISTER_METHOD(void, SBTypeFilter, Clear, ()); - LLDB_REGISTER_METHOD(uint32_t, SBTypeFilter, GetNumberOfExpressionPaths, - ()); - LLDB_REGISTER_METHOD(const char *, SBTypeFilter, GetExpressionPathAtIndex, - (uint32_t)); - LLDB_REGISTER_METHOD(bool, SBTypeFilter, ReplaceExpressionPathAtIndex, - (uint32_t, const char *)); - LLDB_REGISTER_METHOD(void, SBTypeFilter, AppendExpressionPath, - (const char *)); - LLDB_REGISTER_METHOD(lldb::SBTypeFilter &, - SBTypeFilter, operator=,(const lldb::SBTypeFilter &)); - LLDB_REGISTER_METHOD(bool, SBTypeFilter, operator==,(lldb::SBTypeFilter &)); - LLDB_REGISTER_METHOD(bool, SBTypeFilter, IsEqualTo, (lldb::SBTypeFilter &)); - LLDB_REGISTER_METHOD(bool, SBTypeFilter, operator!=,(lldb::SBTypeFilter &)); -} - -} -} diff --git a/lldb/source/API/SBTypeFormat.cpp b/lldb/source/API/SBTypeFormat.cpp index 70289bef8db5..86e11e8b8fde 100644 --- a/lldb/source/API/SBTypeFormat.cpp +++ b/lldb/source/API/SBTypeFormat.cpp @@ -7,7 +7,7 @@ //===----------------------------------------------------------------------===// #include "lldb/API/SBTypeFormat.h" -#include "SBReproducerPrivate.h" +#include "lldb/Utility/Instrumentation.h" #include "lldb/API/SBStream.h" @@ -16,43 +16,39 @@ using namespace lldb; using namespace lldb_private; -SBTypeFormat::SBTypeFormat() : m_opaque_sp() { - LLDB_RECORD_CONSTRUCTOR_NO_ARGS(SBTypeFormat); -} +SBTypeFormat::SBTypeFormat() { LLDB_INSTRUMENT_VA(this); } SBTypeFormat::SBTypeFormat(lldb::Format format, uint32_t options) : m_opaque_sp( TypeFormatImplSP(new TypeFormatImpl_Format(format, options))) { - LLDB_RECORD_CONSTRUCTOR(SBTypeFormat, (lldb::Format, uint32_t), format, - options); + LLDB_INSTRUMENT_VA(this, format, options); } SBTypeFormat::SBTypeFormat(const char *type, uint32_t options) : m_opaque_sp(TypeFormatImplSP(new TypeFormatImpl_EnumType( ConstString(type ? type : ""), options))) { - LLDB_RECORD_CONSTRUCTOR(SBTypeFormat, (const char *, uint32_t), type, - options); + LLDB_INSTRUMENT_VA(this, type, options); } SBTypeFormat::SBTypeFormat(const lldb::SBTypeFormat &rhs) : m_opaque_sp(rhs.m_opaque_sp) { - LLDB_RECORD_CONSTRUCTOR(SBTypeFormat, (const lldb::SBTypeFormat &), rhs); + LLDB_INSTRUMENT_VA(this, rhs); } SBTypeFormat::~SBTypeFormat() = default; bool SBTypeFormat::IsValid() const { - LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBTypeFormat, IsValid); + LLDB_INSTRUMENT_VA(this); return this->operator bool(); } SBTypeFormat::operator bool() const { - LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBTypeFormat, operator bool); + LLDB_INSTRUMENT_VA(this); return m_opaque_sp.get() != nullptr; } lldb::Format SBTypeFormat::GetFormat() { - LLDB_RECORD_METHOD_NO_ARGS(lldb::Format, SBTypeFormat, GetFormat); + LLDB_INSTRUMENT_VA(this); if (IsValid() && m_opaque_sp->GetType() == TypeFormatImpl::Type::eTypeFormat) return ((TypeFormatImpl_Format *)m_opaque_sp.get())->GetFormat(); @@ -60,7 +56,7 @@ lldb::Format SBTypeFormat::GetFormat() { } const char *SBTypeFormat::GetTypeName() { - LLDB_RECORD_METHOD_NO_ARGS(const char *, SBTypeFormat, GetTypeName); + LLDB_INSTRUMENT_VA(this); if (IsValid() && m_opaque_sp->GetType() == TypeFormatImpl::Type::eTypeEnum) return ((TypeFormatImpl_EnumType *)m_opaque_sp.get()) @@ -70,7 +66,7 @@ const char *SBTypeFormat::GetTypeName() { } uint32_t SBTypeFormat::GetOptions() { - LLDB_RECORD_METHOD_NO_ARGS(uint32_t, SBTypeFormat, GetOptions); + LLDB_INSTRUMENT_VA(this); if (IsValid()) return m_opaque_sp->GetOptions(); @@ -78,14 +74,14 @@ uint32_t SBTypeFormat::GetOptions() { } void SBTypeFormat::SetFormat(lldb::Format fmt) { - LLDB_RECORD_METHOD(void, SBTypeFormat, SetFormat, (lldb::Format), fmt); + LLDB_INSTRUMENT_VA(this, fmt); if (CopyOnWrite_Impl(Type::eTypeFormat)) ((TypeFormatImpl_Format *)m_opaque_sp.get())->SetFormat(fmt); } void SBTypeFormat::SetTypeName(const char *type) { - LLDB_RECORD_METHOD(void, SBTypeFormat, SetTypeName, (const char *), type); + LLDB_INSTRUMENT_VA(this, type); if (CopyOnWrite_Impl(Type::eTypeEnum)) ((TypeFormatImpl_EnumType *)m_opaque_sp.get()) @@ -93,7 +89,7 @@ void SBTypeFormat::SetTypeName(const char *type) { } void SBTypeFormat::SetOptions(uint32_t value) { - LLDB_RECORD_METHOD(void, SBTypeFormat, SetOptions, (uint32_t), value); + LLDB_INSTRUMENT_VA(this, value); if (CopyOnWrite_Impl(Type::eTypeKeepSame)) m_opaque_sp->SetOptions(value); @@ -101,9 +97,7 @@ void SBTypeFormat::SetOptions(uint32_t value) { bool SBTypeFormat::GetDescription(lldb::SBStream &description, lldb::DescriptionLevel description_level) { - LLDB_RECORD_METHOD(bool, SBTypeFormat, GetDescription, - (lldb::SBStream &, lldb::DescriptionLevel), description, - description_level); + LLDB_INSTRUMENT_VA(this, description, description_level); if (!IsValid()) return false; @@ -114,18 +108,16 @@ bool SBTypeFormat::GetDescription(lldb::SBStream &description, } lldb::SBTypeFormat &SBTypeFormat::operator=(const lldb::SBTypeFormat &rhs) { - LLDB_RECORD_METHOD(lldb::SBTypeFormat &, - SBTypeFormat, operator=,(const lldb::SBTypeFormat &), rhs); + LLDB_INSTRUMENT_VA(this, rhs); if (this != &rhs) { m_opaque_sp = rhs.m_opaque_sp; } - return LLDB_RECORD_RESULT(*this); + return *this; } bool SBTypeFormat::operator==(lldb::SBTypeFormat &rhs) { - LLDB_RECORD_METHOD(bool, SBTypeFormat, operator==,(lldb::SBTypeFormat &), - rhs); + LLDB_INSTRUMENT_VA(this, rhs); if (!IsValid()) return !rhs.IsValid(); @@ -133,8 +125,7 @@ bool SBTypeFormat::operator==(lldb::SBTypeFormat &rhs) { } bool SBTypeFormat::IsEqualTo(lldb::SBTypeFormat &rhs) { - LLDB_RECORD_METHOD(bool, SBTypeFormat, IsEqualTo, (lldb::SBTypeFormat &), - rhs); + LLDB_INSTRUMENT_VA(this, rhs); if (!IsValid()) return !rhs.IsValid(); @@ -146,8 +137,7 @@ bool SBTypeFormat::IsEqualTo(lldb::SBTypeFormat &rhs) { } bool SBTypeFormat::operator!=(lldb::SBTypeFormat &rhs) { - LLDB_RECORD_METHOD(bool, SBTypeFormat, operator!=,(lldb::SBTypeFormat &), - rhs); + LLDB_INSTRUMENT_VA(this, rhs); if (!IsValid()) return !rhs.IsValid(); @@ -191,32 +181,3 @@ bool SBTypeFormat::CopyOnWrite_Impl(Type type) { return true; } - -namespace lldb_private { -namespace repro { - -template <> -void RegisterMethods<SBTypeFormat>(Registry &R) { - LLDB_REGISTER_CONSTRUCTOR(SBTypeFormat, ()); - LLDB_REGISTER_CONSTRUCTOR(SBTypeFormat, (lldb::Format, uint32_t)); - LLDB_REGISTER_CONSTRUCTOR(SBTypeFormat, (const char *, uint32_t)); - LLDB_REGISTER_CONSTRUCTOR(SBTypeFormat, (const lldb::SBTypeFormat &)); - LLDB_REGISTER_METHOD_CONST(bool, SBTypeFormat, IsValid, ()); - LLDB_REGISTER_METHOD_CONST(bool, SBTypeFormat, operator bool, ()); - LLDB_REGISTER_METHOD(lldb::Format, SBTypeFormat, GetFormat, ()); - LLDB_REGISTER_METHOD(const char *, SBTypeFormat, GetTypeName, ()); - LLDB_REGISTER_METHOD(uint32_t, SBTypeFormat, GetOptions, ()); - LLDB_REGISTER_METHOD(void, SBTypeFormat, SetFormat, (lldb::Format)); - LLDB_REGISTER_METHOD(void, SBTypeFormat, SetTypeName, (const char *)); - LLDB_REGISTER_METHOD(void, SBTypeFormat, SetOptions, (uint32_t)); - LLDB_REGISTER_METHOD(bool, SBTypeFormat, GetDescription, - (lldb::SBStream &, lldb::DescriptionLevel)); - LLDB_REGISTER_METHOD(lldb::SBTypeFormat &, - SBTypeFormat, operator=,(const lldb::SBTypeFormat &)); - LLDB_REGISTER_METHOD(bool, SBTypeFormat, operator==,(lldb::SBTypeFormat &)); - LLDB_REGISTER_METHOD(bool, SBTypeFormat, IsEqualTo, (lldb::SBTypeFormat &)); - LLDB_REGISTER_METHOD(bool, SBTypeFormat, operator!=,(lldb::SBTypeFormat &)); -} - -} -} diff --git a/lldb/source/API/SBTypeNameSpecifier.cpp b/lldb/source/API/SBTypeNameSpecifier.cpp index 3673a5024530..bc83a1d664d0 100644 --- a/lldb/source/API/SBTypeNameSpecifier.cpp +++ b/lldb/source/API/SBTypeNameSpecifier.cpp @@ -7,7 +7,7 @@ //===----------------------------------------------------------------------===// #include "lldb/API/SBTypeNameSpecifier.h" -#include "SBReproducerPrivate.h" +#include "lldb/Utility/Instrumentation.h" #include "lldb/API/SBStream.h" #include "lldb/API/SBType.h" @@ -17,21 +17,18 @@ using namespace lldb; using namespace lldb_private; -SBTypeNameSpecifier::SBTypeNameSpecifier() : m_opaque_sp() { - LLDB_RECORD_CONSTRUCTOR_NO_ARGS(SBTypeNameSpecifier); -} +SBTypeNameSpecifier::SBTypeNameSpecifier() { LLDB_INSTRUMENT_VA(this); } SBTypeNameSpecifier::SBTypeNameSpecifier(const char *name, bool is_regex) : m_opaque_sp(new TypeNameSpecifierImpl(name, is_regex)) { - LLDB_RECORD_CONSTRUCTOR(SBTypeNameSpecifier, (const char *, bool), name, - is_regex); + LLDB_INSTRUMENT_VA(this, name, is_regex); if (name == nullptr || (*name) == 0) m_opaque_sp.reset(); } -SBTypeNameSpecifier::SBTypeNameSpecifier(SBType type) : m_opaque_sp() { - LLDB_RECORD_CONSTRUCTOR(SBTypeNameSpecifier, (lldb::SBType), type); +SBTypeNameSpecifier::SBTypeNameSpecifier(SBType type) { + LLDB_INSTRUMENT_VA(this, type); if (type.IsValid()) m_opaque_sp = TypeNameSpecifierImplSP( @@ -40,24 +37,23 @@ SBTypeNameSpecifier::SBTypeNameSpecifier(SBType type) : m_opaque_sp() { SBTypeNameSpecifier::SBTypeNameSpecifier(const lldb::SBTypeNameSpecifier &rhs) : m_opaque_sp(rhs.m_opaque_sp) { - LLDB_RECORD_CONSTRUCTOR(SBTypeNameSpecifier, - (const lldb::SBTypeNameSpecifier &), rhs); + LLDB_INSTRUMENT_VA(this, rhs); } SBTypeNameSpecifier::~SBTypeNameSpecifier() = default; bool SBTypeNameSpecifier::IsValid() const { - LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBTypeNameSpecifier, IsValid); + LLDB_INSTRUMENT_VA(this); return this->operator bool(); } SBTypeNameSpecifier::operator bool() const { - LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBTypeNameSpecifier, operator bool); + LLDB_INSTRUMENT_VA(this); return m_opaque_sp.get() != nullptr; } const char *SBTypeNameSpecifier::GetName() { - LLDB_RECORD_METHOD_NO_ARGS(const char *, SBTypeNameSpecifier, GetName); + LLDB_INSTRUMENT_VA(this); if (!IsValid()) return nullptr; @@ -66,18 +62,18 @@ const char *SBTypeNameSpecifier::GetName() { } SBType SBTypeNameSpecifier::GetType() { - LLDB_RECORD_METHOD_NO_ARGS(lldb::SBType, SBTypeNameSpecifier, GetType); + LLDB_INSTRUMENT_VA(this); if (!IsValid()) - return LLDB_RECORD_RESULT(SBType()); + return SBType(); lldb_private::CompilerType c_type = m_opaque_sp->GetCompilerType(); if (c_type.IsValid()) - return LLDB_RECORD_RESULT(SBType(c_type)); - return LLDB_RECORD_RESULT(SBType()); + return SBType(c_type); + return SBType(); } bool SBTypeNameSpecifier::IsRegex() { - LLDB_RECORD_METHOD_NO_ARGS(bool, SBTypeNameSpecifier, IsRegex); + LLDB_INSTRUMENT_VA(this); if (!IsValid()) return false; @@ -87,9 +83,7 @@ bool SBTypeNameSpecifier::IsRegex() { bool SBTypeNameSpecifier::GetDescription( lldb::SBStream &description, lldb::DescriptionLevel description_level) { - LLDB_RECORD_METHOD(bool, SBTypeNameSpecifier, GetDescription, - (lldb::SBStream &, lldb::DescriptionLevel), description, - description_level); + LLDB_INSTRUMENT_VA(this, description, description_level); if (!IsValid()) return false; @@ -100,19 +94,16 @@ bool SBTypeNameSpecifier::GetDescription( lldb::SBTypeNameSpecifier &SBTypeNameSpecifier:: operator=(const lldb::SBTypeNameSpecifier &rhs) { - LLDB_RECORD_METHOD( - lldb::SBTypeNameSpecifier &, - SBTypeNameSpecifier, operator=,(const lldb::SBTypeNameSpecifier &), rhs); + LLDB_INSTRUMENT_VA(this, rhs); if (this != &rhs) { m_opaque_sp = rhs.m_opaque_sp; } - return LLDB_RECORD_RESULT(*this); + return *this; } bool SBTypeNameSpecifier::operator==(lldb::SBTypeNameSpecifier &rhs) { - LLDB_RECORD_METHOD( - bool, SBTypeNameSpecifier, operator==,(lldb::SBTypeNameSpecifier &), rhs); + LLDB_INSTRUMENT_VA(this, rhs); if (!IsValid()) return !rhs.IsValid(); @@ -120,8 +111,7 @@ bool SBTypeNameSpecifier::operator==(lldb::SBTypeNameSpecifier &rhs) { } bool SBTypeNameSpecifier::IsEqualTo(lldb::SBTypeNameSpecifier &rhs) { - LLDB_RECORD_METHOD(bool, SBTypeNameSpecifier, IsEqualTo, - (lldb::SBTypeNameSpecifier &), rhs); + LLDB_INSTRUMENT_VA(this, rhs); if (!IsValid()) return !rhs.IsValid(); @@ -135,8 +125,7 @@ bool SBTypeNameSpecifier::IsEqualTo(lldb::SBTypeNameSpecifier &rhs) { } bool SBTypeNameSpecifier::operator!=(lldb::SBTypeNameSpecifier &rhs) { - LLDB_RECORD_METHOD( - bool, SBTypeNameSpecifier, operator!=,(lldb::SBTypeNameSpecifier &), rhs); + LLDB_INSTRUMENT_VA(this, rhs); if (!IsValid()) return !rhs.IsValid(); @@ -155,34 +144,3 @@ void SBTypeNameSpecifier::SetSP( SBTypeNameSpecifier::SBTypeNameSpecifier( const lldb::TypeNameSpecifierImplSP &type_namespec_sp) : m_opaque_sp(type_namespec_sp) {} - -namespace lldb_private { -namespace repro { - -template <> -void RegisterMethods<SBTypeNameSpecifier>(Registry &R) { - LLDB_REGISTER_CONSTRUCTOR(SBTypeNameSpecifier, ()); - LLDB_REGISTER_CONSTRUCTOR(SBTypeNameSpecifier, (const char *, bool)); - LLDB_REGISTER_CONSTRUCTOR(SBTypeNameSpecifier, (lldb::SBType)); - LLDB_REGISTER_CONSTRUCTOR(SBTypeNameSpecifier, - (const lldb::SBTypeNameSpecifier &)); - LLDB_REGISTER_METHOD_CONST(bool, SBTypeNameSpecifier, IsValid, ()); - LLDB_REGISTER_METHOD_CONST(bool, SBTypeNameSpecifier, operator bool, ()); - LLDB_REGISTER_METHOD(const char *, SBTypeNameSpecifier, GetName, ()); - LLDB_REGISTER_METHOD(lldb::SBType, SBTypeNameSpecifier, GetType, ()); - LLDB_REGISTER_METHOD(bool, SBTypeNameSpecifier, IsRegex, ()); - LLDB_REGISTER_METHOD(bool, SBTypeNameSpecifier, GetDescription, - (lldb::SBStream &, lldb::DescriptionLevel)); - LLDB_REGISTER_METHOD( - lldb::SBTypeNameSpecifier &, - SBTypeNameSpecifier, operator=,(const lldb::SBTypeNameSpecifier &)); - LLDB_REGISTER_METHOD( - bool, SBTypeNameSpecifier, operator==,(lldb::SBTypeNameSpecifier &)); - LLDB_REGISTER_METHOD(bool, SBTypeNameSpecifier, IsEqualTo, - (lldb::SBTypeNameSpecifier &)); - LLDB_REGISTER_METHOD( - bool, SBTypeNameSpecifier, operator!=,(lldb::SBTypeNameSpecifier &)); -} - -} -} diff --git a/lldb/source/API/SBTypeSummary.cpp b/lldb/source/API/SBTypeSummary.cpp index 2d7f8ef340c9..a65dfc987ad2 100644 --- a/lldb/source/API/SBTypeSummary.cpp +++ b/lldb/source/API/SBTypeSummary.cpp @@ -7,11 +7,11 @@ //===----------------------------------------------------------------------===// #include "lldb/API/SBTypeSummary.h" -#include "SBReproducerPrivate.h" #include "Utils.h" #include "lldb/API/SBStream.h" #include "lldb/API/SBValue.h" #include "lldb/DataFormatters/DataVisualization.h" +#include "lldb/Utility/Instrumentation.h" #include "llvm/Support/Casting.h" @@ -19,15 +19,14 @@ using namespace lldb; using namespace lldb_private; SBTypeSummaryOptions::SBTypeSummaryOptions() { - LLDB_RECORD_CONSTRUCTOR_NO_ARGS(SBTypeSummaryOptions); + LLDB_INSTRUMENT_VA(this); m_opaque_up = std::make_unique<TypeSummaryOptions>(); } SBTypeSummaryOptions::SBTypeSummaryOptions( const lldb::SBTypeSummaryOptions &rhs) { - LLDB_RECORD_CONSTRUCTOR(SBTypeSummaryOptions, - (const lldb::SBTypeSummaryOptions &), rhs); + LLDB_INSTRUMENT_VA(this, rhs); m_opaque_up = clone(rhs.m_opaque_up); } @@ -35,18 +34,17 @@ SBTypeSummaryOptions::SBTypeSummaryOptions( SBTypeSummaryOptions::~SBTypeSummaryOptions() = default; bool SBTypeSummaryOptions::IsValid() { - LLDB_RECORD_METHOD_NO_ARGS(bool, SBTypeSummaryOptions, IsValid); + LLDB_INSTRUMENT_VA(this); return this->operator bool(); } SBTypeSummaryOptions::operator bool() const { - LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBTypeSummaryOptions, operator bool); + LLDB_INSTRUMENT_VA(this); return m_opaque_up.get(); } lldb::LanguageType SBTypeSummaryOptions::GetLanguage() { - LLDB_RECORD_METHOD_NO_ARGS(lldb::LanguageType, SBTypeSummaryOptions, - GetLanguage); + LLDB_INSTRUMENT_VA(this); if (IsValid()) return m_opaque_up->GetLanguage(); @@ -54,8 +52,7 @@ lldb::LanguageType SBTypeSummaryOptions::GetLanguage() { } lldb::TypeSummaryCapping SBTypeSummaryOptions::GetCapping() { - LLDB_RECORD_METHOD_NO_ARGS(lldb::TypeSummaryCapping, SBTypeSummaryOptions, - GetCapping); + LLDB_INSTRUMENT_VA(this); if (IsValid()) return m_opaque_up->GetCapping(); @@ -63,16 +60,14 @@ lldb::TypeSummaryCapping SBTypeSummaryOptions::GetCapping() { } void SBTypeSummaryOptions::SetLanguage(lldb::LanguageType l) { - LLDB_RECORD_METHOD(void, SBTypeSummaryOptions, SetLanguage, - (lldb::LanguageType), l); + LLDB_INSTRUMENT_VA(this, l); if (IsValid()) m_opaque_up->SetLanguage(l); } void SBTypeSummaryOptions::SetCapping(lldb::TypeSummaryCapping c) { - LLDB_RECORD_METHOD(void, SBTypeSummaryOptions, SetCapping, - (lldb::TypeSummaryCapping), c); + LLDB_INSTRUMENT_VA(this, c); if (IsValid()) m_opaque_up->SetCapping(c); @@ -102,61 +97,48 @@ const lldb_private::TypeSummaryOptions &SBTypeSummaryOptions::ref() const { SBTypeSummaryOptions::SBTypeSummaryOptions( const lldb_private::TypeSummaryOptions &lldb_object) : m_opaque_up(std::make_unique<TypeSummaryOptions>(lldb_object)) { - LLDB_RECORD_CONSTRUCTOR(SBTypeSummaryOptions, - (const lldb_private::TypeSummaryOptions &), - lldb_object); + LLDB_INSTRUMENT_VA(this, lldb_object); } -SBTypeSummary::SBTypeSummary() : m_opaque_sp() { - LLDB_RECORD_CONSTRUCTOR_NO_ARGS(SBTypeSummary); -} +SBTypeSummary::SBTypeSummary() { LLDB_INSTRUMENT_VA(this); } SBTypeSummary SBTypeSummary::CreateWithSummaryString(const char *data, uint32_t options) { - LLDB_RECORD_STATIC_METHOD(lldb::SBTypeSummary, SBTypeSummary, - CreateWithSummaryString, (const char *, uint32_t), - data, options); + LLDB_INSTRUMENT_VA(data, options); if (!data || data[0] == 0) - return LLDB_RECORD_RESULT(SBTypeSummary()); + return SBTypeSummary(); - return LLDB_RECORD_RESULT( - SBTypeSummary(TypeSummaryImplSP(new StringSummaryFormat(options, data)))); + return SBTypeSummary( + TypeSummaryImplSP(new StringSummaryFormat(options, data))); } SBTypeSummary SBTypeSummary::CreateWithFunctionName(const char *data, uint32_t options) { - LLDB_RECORD_STATIC_METHOD(lldb::SBTypeSummary, SBTypeSummary, - CreateWithFunctionName, (const char *, uint32_t), - data, options); + LLDB_INSTRUMENT_VA(data, options); if (!data || data[0] == 0) - return LLDB_RECORD_RESULT(SBTypeSummary()); + return SBTypeSummary(); - return LLDB_RECORD_RESULT( - SBTypeSummary(TypeSummaryImplSP(new ScriptSummaryFormat(options, data)))); + return SBTypeSummary( + TypeSummaryImplSP(new ScriptSummaryFormat(options, data))); } SBTypeSummary SBTypeSummary::CreateWithScriptCode(const char *data, uint32_t options) { - LLDB_RECORD_STATIC_METHOD(lldb::SBTypeSummary, SBTypeSummary, - CreateWithScriptCode, (const char *, uint32_t), - data, options); + LLDB_INSTRUMENT_VA(data, options); if (!data || data[0] == 0) - return LLDB_RECORD_RESULT(SBTypeSummary()); + return SBTypeSummary(); - return LLDB_RECORD_RESULT(SBTypeSummary( - TypeSummaryImplSP(new ScriptSummaryFormat(options, "", data)))); + return SBTypeSummary( + TypeSummaryImplSP(new ScriptSummaryFormat(options, "", data))); } SBTypeSummary SBTypeSummary::CreateWithCallback(FormatCallback cb, uint32_t options, const char *description) { - LLDB_RECORD_DUMMY( - lldb::SBTypeSummary, SBTypeSummary, CreateWithCallback, - (lldb::SBTypeSummary::FormatCallback, uint32_t, const char *), cb, - options, description); + LLDB_INSTRUMENT_VA(cb, options, description); SBTypeSummary retval; if (cb) { @@ -180,23 +162,23 @@ SBTypeSummary SBTypeSummary::CreateWithCallback(FormatCallback cb, SBTypeSummary::SBTypeSummary(const lldb::SBTypeSummary &rhs) : m_opaque_sp(rhs.m_opaque_sp) { - LLDB_RECORD_CONSTRUCTOR(SBTypeSummary, (const lldb::SBTypeSummary &), rhs); + LLDB_INSTRUMENT_VA(this, rhs); } SBTypeSummary::~SBTypeSummary() = default; bool SBTypeSummary::IsValid() const { - LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBTypeSummary, IsValid); + LLDB_INSTRUMENT_VA(this); return this->operator bool(); } SBTypeSummary::operator bool() const { - LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBTypeSummary, operator bool); + LLDB_INSTRUMENT_VA(this); return m_opaque_sp.get() != nullptr; } bool SBTypeSummary::IsFunctionCode() { - LLDB_RECORD_METHOD_NO_ARGS(bool, SBTypeSummary, IsFunctionCode); + LLDB_INSTRUMENT_VA(this); if (!IsValid()) return false; @@ -209,7 +191,7 @@ bool SBTypeSummary::IsFunctionCode() { } bool SBTypeSummary::IsFunctionName() { - LLDB_RECORD_METHOD_NO_ARGS(bool, SBTypeSummary, IsFunctionName); + LLDB_INSTRUMENT_VA(this); if (!IsValid()) return false; @@ -222,7 +204,7 @@ bool SBTypeSummary::IsFunctionName() { } bool SBTypeSummary::IsSummaryString() { - LLDB_RECORD_METHOD_NO_ARGS(bool, SBTypeSummary, IsSummaryString); + LLDB_INSTRUMENT_VA(this); if (!IsValid()) return false; @@ -231,7 +213,7 @@ bool SBTypeSummary::IsSummaryString() { } const char *SBTypeSummary::GetData() { - LLDB_RECORD_METHOD_NO_ARGS(const char *, SBTypeSummary, GetData); + LLDB_INSTRUMENT_VA(this); if (!IsValid()) return nullptr; @@ -249,7 +231,7 @@ const char *SBTypeSummary::GetData() { } uint32_t SBTypeSummary::GetOptions() { - LLDB_RECORD_METHOD_NO_ARGS(uint32_t, SBTypeSummary, GetOptions); + LLDB_INSTRUMENT_VA(this); if (!IsValid()) return lldb::eTypeOptionNone; @@ -257,7 +239,7 @@ uint32_t SBTypeSummary::GetOptions() { } void SBTypeSummary::SetOptions(uint32_t value) { - LLDB_RECORD_METHOD(void, SBTypeSummary, SetOptions, (uint32_t), value); + LLDB_INSTRUMENT_VA(this, value); if (!CopyOnWrite_Impl()) return; @@ -265,8 +247,7 @@ void SBTypeSummary::SetOptions(uint32_t value) { } void SBTypeSummary::SetSummaryString(const char *data) { - LLDB_RECORD_METHOD(void, SBTypeSummary, SetSummaryString, (const char *), - data); + LLDB_INSTRUMENT_VA(this, data); if (!IsValid()) return; @@ -278,8 +259,7 @@ void SBTypeSummary::SetSummaryString(const char *data) { } void SBTypeSummary::SetFunctionName(const char *data) { - LLDB_RECORD_METHOD(void, SBTypeSummary, SetFunctionName, (const char *), - data); + LLDB_INSTRUMENT_VA(this, data); if (!IsValid()) return; @@ -291,8 +271,7 @@ void SBTypeSummary::SetFunctionName(const char *data) { } void SBTypeSummary::SetFunctionCode(const char *data) { - LLDB_RECORD_METHOD(void, SBTypeSummary, SetFunctionCode, (const char *), - data); + LLDB_INSTRUMENT_VA(this, data); if (!IsValid()) return; @@ -305,9 +284,7 @@ void SBTypeSummary::SetFunctionCode(const char *data) { bool SBTypeSummary::GetDescription(lldb::SBStream &description, lldb::DescriptionLevel description_level) { - LLDB_RECORD_METHOD(bool, SBTypeSummary, GetDescription, - (lldb::SBStream &, lldb::DescriptionLevel), description, - description_level); + LLDB_INSTRUMENT_VA(this, description, description_level); if (!CopyOnWrite_Impl()) return false; @@ -318,8 +295,7 @@ bool SBTypeSummary::GetDescription(lldb::SBStream &description, } bool SBTypeSummary::DoesPrintValue(lldb::SBValue value) { - LLDB_RECORD_METHOD(bool, SBTypeSummary, DoesPrintValue, (lldb::SBValue), - value); + LLDB_INSTRUMENT_VA(this, value); if (!IsValid()) return false; @@ -328,19 +304,16 @@ bool SBTypeSummary::DoesPrintValue(lldb::SBValue value) { } lldb::SBTypeSummary &SBTypeSummary::operator=(const lldb::SBTypeSummary &rhs) { - LLDB_RECORD_METHOD(lldb::SBTypeSummary &, - SBTypeSummary, operator=,(const lldb::SBTypeSummary &), - rhs); + LLDB_INSTRUMENT_VA(this, rhs); if (this != &rhs) { m_opaque_sp = rhs.m_opaque_sp; } - return LLDB_RECORD_RESULT(*this); + return *this; } bool SBTypeSummary::operator==(lldb::SBTypeSummary &rhs) { - LLDB_RECORD_METHOD(bool, SBTypeSummary, operator==,(lldb::SBTypeSummary &), - rhs); + LLDB_INSTRUMENT_VA(this, rhs); if (!IsValid()) return !rhs.IsValid(); @@ -348,8 +321,7 @@ bool SBTypeSummary::operator==(lldb::SBTypeSummary &rhs) { } bool SBTypeSummary::IsEqualTo(lldb::SBTypeSummary &rhs) { - LLDB_RECORD_METHOD(bool, SBTypeSummary, IsEqualTo, (lldb::SBTypeSummary &), - rhs); + LLDB_INSTRUMENT_VA(this, rhs); if (IsValid()) { // valid and invalid are different @@ -389,8 +361,7 @@ bool SBTypeSummary::IsEqualTo(lldb::SBTypeSummary &rhs) { } bool SBTypeSummary::operator!=(lldb::SBTypeSummary &rhs) { - LLDB_RECORD_METHOD(bool, SBTypeSummary, operator!=,(lldb::SBTypeSummary &), - rhs); + LLDB_INSTRUMENT_VA(this, rhs); if (!IsValid()) return !rhs.IsValid(); @@ -463,65 +434,3 @@ bool SBTypeSummary::ChangeSummaryType(bool want_script) { return true; } - -namespace lldb_private { -namespace repro { - -template <> -void RegisterMethods<SBTypeSummaryOptions>(Registry &R) { - LLDB_REGISTER_CONSTRUCTOR(SBTypeSummaryOptions, ()); - LLDB_REGISTER_CONSTRUCTOR(SBTypeSummaryOptions, - (const lldb::SBTypeSummaryOptions &)); - LLDB_REGISTER_METHOD(bool, SBTypeSummaryOptions, IsValid, ()); - LLDB_REGISTER_METHOD_CONST(bool, SBTypeSummaryOptions, operator bool, ()); - LLDB_REGISTER_METHOD(lldb::LanguageType, SBTypeSummaryOptions, GetLanguage, - ()); - LLDB_REGISTER_METHOD(lldb::TypeSummaryCapping, SBTypeSummaryOptions, - GetCapping, ()); - LLDB_REGISTER_METHOD(void, SBTypeSummaryOptions, SetLanguage, - (lldb::LanguageType)); - LLDB_REGISTER_METHOD(void, SBTypeSummaryOptions, SetCapping, - (lldb::TypeSummaryCapping)); - LLDB_REGISTER_CONSTRUCTOR(SBTypeSummaryOptions, - (const lldb_private::TypeSummaryOptions &)); -} - -template <> -void RegisterMethods<SBTypeSummary>(Registry &R) { - LLDB_REGISTER_CONSTRUCTOR(SBTypeSummary, ()); - LLDB_REGISTER_STATIC_METHOD(lldb::SBTypeSummary, SBTypeSummary, - CreateWithSummaryString, - (const char *, uint32_t)); - LLDB_REGISTER_STATIC_METHOD(lldb::SBTypeSummary, SBTypeSummary, - CreateWithFunctionName, - (const char *, uint32_t)); - LLDB_REGISTER_STATIC_METHOD(lldb::SBTypeSummary, SBTypeSummary, - CreateWithScriptCode, (const char *, uint32_t)); - LLDB_REGISTER_CONSTRUCTOR(SBTypeSummary, (const lldb::SBTypeSummary &)); - LLDB_REGISTER_METHOD_CONST(bool, SBTypeSummary, IsValid, ()); - LLDB_REGISTER_METHOD_CONST(bool, SBTypeSummary, operator bool, ()); - LLDB_REGISTER_METHOD(bool, SBTypeSummary, IsFunctionCode, ()); - LLDB_REGISTER_METHOD(bool, SBTypeSummary, IsFunctionName, ()); - LLDB_REGISTER_METHOD(bool, SBTypeSummary, IsSummaryString, ()); - LLDB_REGISTER_METHOD(const char *, SBTypeSummary, GetData, ()); - LLDB_REGISTER_METHOD(uint32_t, SBTypeSummary, GetOptions, ()); - LLDB_REGISTER_METHOD(void, SBTypeSummary, SetOptions, (uint32_t)); - LLDB_REGISTER_METHOD(void, SBTypeSummary, SetSummaryString, (const char *)); - LLDB_REGISTER_METHOD(void, SBTypeSummary, SetFunctionName, (const char *)); - LLDB_REGISTER_METHOD(void, SBTypeSummary, SetFunctionCode, (const char *)); - LLDB_REGISTER_METHOD(bool, SBTypeSummary, GetDescription, - (lldb::SBStream &, lldb::DescriptionLevel)); - LLDB_REGISTER_METHOD(bool, SBTypeSummary, DoesPrintValue, (lldb::SBValue)); - LLDB_REGISTER_METHOD( - lldb::SBTypeSummary &, - SBTypeSummary, operator=,(const lldb::SBTypeSummary &)); - LLDB_REGISTER_METHOD(bool, - SBTypeSummary, operator==,(lldb::SBTypeSummary &)); - LLDB_REGISTER_METHOD(bool, SBTypeSummary, IsEqualTo, - (lldb::SBTypeSummary &)); - LLDB_REGISTER_METHOD(bool, - SBTypeSummary, operator!=,(lldb::SBTypeSummary &)); -} - -} -} diff --git a/lldb/source/API/SBTypeSynthetic.cpp b/lldb/source/API/SBTypeSynthetic.cpp index af5e167b9c24..7258ff04745d 100644 --- a/lldb/source/API/SBTypeSynthetic.cpp +++ b/lldb/source/API/SBTypeSynthetic.cpp @@ -7,7 +7,7 @@ //===----------------------------------------------------------------------===// #include "lldb/API/SBTypeSynthetic.h" -#include "SBReproducerPrivate.h" +#include "lldb/Utility/Instrumentation.h" #include "lldb/API/SBStream.h" @@ -16,54 +16,47 @@ using namespace lldb; using namespace lldb_private; -SBTypeSynthetic::SBTypeSynthetic() : m_opaque_sp() { - LLDB_RECORD_CONSTRUCTOR_NO_ARGS(SBTypeSynthetic); -} +SBTypeSynthetic::SBTypeSynthetic() { LLDB_INSTRUMENT_VA(this); } SBTypeSynthetic SBTypeSynthetic::CreateWithClassName(const char *data, uint32_t options) { - LLDB_RECORD_STATIC_METHOD(lldb::SBTypeSynthetic, SBTypeSynthetic, - CreateWithClassName, (const char *, uint32_t), data, - options); + LLDB_INSTRUMENT_VA(data, options); if (!data || data[0] == 0) - return LLDB_RECORD_RESULT(SBTypeSynthetic()); - return LLDB_RECORD_RESULT(SBTypeSynthetic(ScriptedSyntheticChildrenSP( - new ScriptedSyntheticChildren(options, data, "")))); + return SBTypeSynthetic(); + return SBTypeSynthetic(ScriptedSyntheticChildrenSP( + new ScriptedSyntheticChildren(options, data, ""))); } SBTypeSynthetic SBTypeSynthetic::CreateWithScriptCode(const char *data, uint32_t options) { - LLDB_RECORD_STATIC_METHOD(lldb::SBTypeSynthetic, SBTypeSynthetic, - CreateWithScriptCode, (const char *, uint32_t), - data, options); + LLDB_INSTRUMENT_VA(data, options); if (!data || data[0] == 0) - return LLDB_RECORD_RESULT(SBTypeSynthetic()); - return LLDB_RECORD_RESULT(SBTypeSynthetic(ScriptedSyntheticChildrenSP( - new ScriptedSyntheticChildren(options, "", data)))); + return SBTypeSynthetic(); + return SBTypeSynthetic(ScriptedSyntheticChildrenSP( + new ScriptedSyntheticChildren(options, "", data))); } SBTypeSynthetic::SBTypeSynthetic(const lldb::SBTypeSynthetic &rhs) : m_opaque_sp(rhs.m_opaque_sp) { - LLDB_RECORD_CONSTRUCTOR(SBTypeSynthetic, (const lldb::SBTypeSynthetic &), - rhs); + LLDB_INSTRUMENT_VA(this, rhs); } SBTypeSynthetic::~SBTypeSynthetic() = default; bool SBTypeSynthetic::IsValid() const { - LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBTypeSynthetic, IsValid); + LLDB_INSTRUMENT_VA(this); return this->operator bool(); } SBTypeSynthetic::operator bool() const { - LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBTypeSynthetic, operator bool); + LLDB_INSTRUMENT_VA(this); return m_opaque_sp.get() != nullptr; } bool SBTypeSynthetic::IsClassCode() { - LLDB_RECORD_METHOD_NO_ARGS(bool, SBTypeSynthetic, IsClassCode); + LLDB_INSTRUMENT_VA(this); if (!IsValid()) return false; @@ -72,7 +65,7 @@ bool SBTypeSynthetic::IsClassCode() { } bool SBTypeSynthetic::IsClassName() { - LLDB_RECORD_METHOD_NO_ARGS(bool, SBTypeSynthetic, IsClassName); + LLDB_INSTRUMENT_VA(this); if (!IsValid()) return false; @@ -80,7 +73,7 @@ bool SBTypeSynthetic::IsClassName() { } const char *SBTypeSynthetic::GetData() { - LLDB_RECORD_METHOD_NO_ARGS(const char *, SBTypeSynthetic, GetData); + LLDB_INSTRUMENT_VA(this); if (!IsValid()) return nullptr; @@ -91,21 +84,21 @@ const char *SBTypeSynthetic::GetData() { } void SBTypeSynthetic::SetClassName(const char *data) { - LLDB_RECORD_METHOD(void, SBTypeSynthetic, SetClassName, (const char *), data); + LLDB_INSTRUMENT_VA(this, data); if (IsValid() && data && *data) m_opaque_sp->SetPythonClassName(data); } void SBTypeSynthetic::SetClassCode(const char *data) { - LLDB_RECORD_METHOD(void, SBTypeSynthetic, SetClassCode, (const char *), data); + LLDB_INSTRUMENT_VA(this, data); if (IsValid() && data && *data) m_opaque_sp->SetPythonCode(data); } uint32_t SBTypeSynthetic::GetOptions() { - LLDB_RECORD_METHOD_NO_ARGS(uint32_t, SBTypeSynthetic, GetOptions); + LLDB_INSTRUMENT_VA(this); if (!IsValid()) return lldb::eTypeOptionNone; @@ -113,7 +106,7 @@ uint32_t SBTypeSynthetic::GetOptions() { } void SBTypeSynthetic::SetOptions(uint32_t value) { - LLDB_RECORD_METHOD(void, SBTypeSynthetic, SetOptions, (uint32_t), value); + LLDB_INSTRUMENT_VA(this, value); if (!CopyOnWrite_Impl()) return; @@ -122,9 +115,7 @@ void SBTypeSynthetic::SetOptions(uint32_t value) { bool SBTypeSynthetic::GetDescription(lldb::SBStream &description, lldb::DescriptionLevel description_level) { - LLDB_RECORD_METHOD(bool, SBTypeSynthetic, GetDescription, - (lldb::SBStream &, lldb::DescriptionLevel), description, - description_level); + LLDB_INSTRUMENT_VA(this, description, description_level); if (m_opaque_sp) { description.Printf("%s\n", m_opaque_sp->GetDescription().c_str()); @@ -135,19 +126,16 @@ bool SBTypeSynthetic::GetDescription(lldb::SBStream &description, lldb::SBTypeSynthetic &SBTypeSynthetic:: operator=(const lldb::SBTypeSynthetic &rhs) { - LLDB_RECORD_METHOD(lldb::SBTypeSynthetic &, - SBTypeSynthetic, operator=,(const lldb::SBTypeSynthetic &), - rhs); + LLDB_INSTRUMENT_VA(this, rhs); if (this != &rhs) { m_opaque_sp = rhs.m_opaque_sp; } - return LLDB_RECORD_RESULT(*this); + return *this; } bool SBTypeSynthetic::operator==(lldb::SBTypeSynthetic &rhs) { - LLDB_RECORD_METHOD( - bool, SBTypeSynthetic, operator==,(lldb::SBTypeSynthetic &), rhs); + LLDB_INSTRUMENT_VA(this, rhs); if (!IsValid()) return !rhs.IsValid(); @@ -155,8 +143,7 @@ bool SBTypeSynthetic::operator==(lldb::SBTypeSynthetic &rhs) { } bool SBTypeSynthetic::IsEqualTo(lldb::SBTypeSynthetic &rhs) { - LLDB_RECORD_METHOD(bool, SBTypeSynthetic, IsEqualTo, - (lldb::SBTypeSynthetic &), rhs); + LLDB_INSTRUMENT_VA(this, rhs); if (!IsValid()) return !rhs.IsValid(); @@ -174,8 +161,7 @@ bool SBTypeSynthetic::IsEqualTo(lldb::SBTypeSynthetic &rhs) { } bool SBTypeSynthetic::operator!=(lldb::SBTypeSynthetic &rhs) { - LLDB_RECORD_METHOD( - bool, SBTypeSynthetic, operator!=,(lldb::SBTypeSynthetic &), rhs); + LLDB_INSTRUMENT_VA(this, rhs); if (!IsValid()) return !rhs.IsValid(); @@ -209,39 +195,3 @@ bool SBTypeSynthetic::CopyOnWrite_Impl() { return true; } - -namespace lldb_private { -namespace repro { - -template <> -void RegisterMethods<SBTypeSynthetic>(Registry &R) { - LLDB_REGISTER_CONSTRUCTOR(SBTypeSynthetic, ()); - LLDB_REGISTER_STATIC_METHOD(lldb::SBTypeSynthetic, SBTypeSynthetic, - CreateWithClassName, (const char *, uint32_t)); - LLDB_REGISTER_STATIC_METHOD(lldb::SBTypeSynthetic, SBTypeSynthetic, - CreateWithScriptCode, (const char *, uint32_t)); - LLDB_REGISTER_CONSTRUCTOR(SBTypeSynthetic, (const lldb::SBTypeSynthetic &)); - LLDB_REGISTER_METHOD_CONST(bool, SBTypeSynthetic, IsValid, ()); - LLDB_REGISTER_METHOD_CONST(bool, SBTypeSynthetic, operator bool, ()); - LLDB_REGISTER_METHOD(bool, SBTypeSynthetic, IsClassCode, ()); - LLDB_REGISTER_METHOD(bool, SBTypeSynthetic, IsClassName, ()); - LLDB_REGISTER_METHOD(const char *, SBTypeSynthetic, GetData, ()); - LLDB_REGISTER_METHOD(void, SBTypeSynthetic, SetClassName, (const char *)); - LLDB_REGISTER_METHOD(void, SBTypeSynthetic, SetClassCode, (const char *)); - LLDB_REGISTER_METHOD(uint32_t, SBTypeSynthetic, GetOptions, ()); - LLDB_REGISTER_METHOD(void, SBTypeSynthetic, SetOptions, (uint32_t)); - LLDB_REGISTER_METHOD(bool, SBTypeSynthetic, GetDescription, - (lldb::SBStream &, lldb::DescriptionLevel)); - LLDB_REGISTER_METHOD( - lldb::SBTypeSynthetic &, - SBTypeSynthetic, operator=,(const lldb::SBTypeSynthetic &)); - LLDB_REGISTER_METHOD(bool, - SBTypeSynthetic, operator==,(lldb::SBTypeSynthetic &)); - LLDB_REGISTER_METHOD(bool, SBTypeSynthetic, IsEqualTo, - (lldb::SBTypeSynthetic &)); - LLDB_REGISTER_METHOD(bool, - SBTypeSynthetic, operator!=,(lldb::SBTypeSynthetic &)); -} - -} -} diff --git a/lldb/source/API/SBUnixSignals.cpp b/lldb/source/API/SBUnixSignals.cpp index a933f6d22333..dc7a68255d13 100644 --- a/lldb/source/API/SBUnixSignals.cpp +++ b/lldb/source/API/SBUnixSignals.cpp @@ -6,10 +6,10 @@ // //===----------------------------------------------------------------------===// -#include "SBReproducerPrivate.h" #include "lldb/Target/Platform.h" #include "lldb/Target/Process.h" #include "lldb/Target/UnixSignals.h" +#include "lldb/Utility/Instrumentation.h" #include "lldb/lldb-defines.h" #include "lldb/API/SBUnixSignals.h" @@ -17,13 +17,11 @@ using namespace lldb; using namespace lldb_private; -SBUnixSignals::SBUnixSignals() { - LLDB_RECORD_CONSTRUCTOR_NO_ARGS(SBUnixSignals); -} +SBUnixSignals::SBUnixSignals() { LLDB_INSTRUMENT_VA(this); } SBUnixSignals::SBUnixSignals(const SBUnixSignals &rhs) : m_opaque_wp(rhs.m_opaque_wp) { - LLDB_RECORD_CONSTRUCTOR(SBUnixSignals, (const lldb::SBUnixSignals &), rhs); + LLDB_INSTRUMENT_VA(this, rhs); } SBUnixSignals::SBUnixSignals(ProcessSP &process_sp) @@ -33,13 +31,11 @@ SBUnixSignals::SBUnixSignals(PlatformSP &platform_sp) : m_opaque_wp(platform_sp ? platform_sp->GetUnixSignals() : nullptr) {} const SBUnixSignals &SBUnixSignals::operator=(const SBUnixSignals &rhs) { - LLDB_RECORD_METHOD(const lldb::SBUnixSignals &, - SBUnixSignals, operator=,(const lldb::SBUnixSignals &), - rhs); + LLDB_INSTRUMENT_VA(this, rhs); if (this != &rhs) m_opaque_wp = rhs.m_opaque_wp; - return LLDB_RECORD_RESULT(*this); + return *this; } SBUnixSignals::~SBUnixSignals() = default; @@ -51,24 +47,23 @@ void SBUnixSignals::SetSP(const UnixSignalsSP &signals_sp) { } void SBUnixSignals::Clear() { - LLDB_RECORD_METHOD_NO_ARGS(void, SBUnixSignals, Clear); + LLDB_INSTRUMENT_VA(this); m_opaque_wp.reset(); } bool SBUnixSignals::IsValid() const { - LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBUnixSignals, IsValid); + LLDB_INSTRUMENT_VA(this); return this->operator bool(); } SBUnixSignals::operator bool() const { - LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBUnixSignals, operator bool); + LLDB_INSTRUMENT_VA(this); return static_cast<bool>(GetSP()); } const char *SBUnixSignals::GetSignalAsCString(int32_t signo) const { - LLDB_RECORD_METHOD_CONST(const char *, SBUnixSignals, GetSignalAsCString, - (int32_t), signo); + LLDB_INSTRUMENT_VA(this, signo); if (auto signals_sp = GetSP()) return signals_sp->GetSignalAsCString(signo); @@ -77,8 +72,7 @@ const char *SBUnixSignals::GetSignalAsCString(int32_t signo) const { } int32_t SBUnixSignals::GetSignalNumberFromName(const char *name) const { - LLDB_RECORD_METHOD_CONST(int32_t, SBUnixSignals, GetSignalNumberFromName, - (const char *), name); + LLDB_INSTRUMENT_VA(this, name); if (auto signals_sp = GetSP()) return signals_sp->GetSignalNumberFromName(name); @@ -87,8 +81,7 @@ int32_t SBUnixSignals::GetSignalNumberFromName(const char *name) const { } bool SBUnixSignals::GetShouldSuppress(int32_t signo) const { - LLDB_RECORD_METHOD_CONST(bool, SBUnixSignals, GetShouldSuppress, (int32_t), - signo); + LLDB_INSTRUMENT_VA(this, signo); if (auto signals_sp = GetSP()) return signals_sp->GetShouldSuppress(signo); @@ -97,8 +90,7 @@ bool SBUnixSignals::GetShouldSuppress(int32_t signo) const { } bool SBUnixSignals::SetShouldSuppress(int32_t signo, bool value) { - LLDB_RECORD_METHOD(bool, SBUnixSignals, SetShouldSuppress, (int32_t, bool), - signo, value); + LLDB_INSTRUMENT_VA(this, signo, value); auto signals_sp = GetSP(); @@ -109,8 +101,7 @@ bool SBUnixSignals::SetShouldSuppress(int32_t signo, bool value) { } bool SBUnixSignals::GetShouldStop(int32_t signo) const { - LLDB_RECORD_METHOD_CONST(bool, SBUnixSignals, GetShouldStop, (int32_t), - signo); + LLDB_INSTRUMENT_VA(this, signo); if (auto signals_sp = GetSP()) return signals_sp->GetShouldStop(signo); @@ -119,8 +110,7 @@ bool SBUnixSignals::GetShouldStop(int32_t signo) const { } bool SBUnixSignals::SetShouldStop(int32_t signo, bool value) { - LLDB_RECORD_METHOD(bool, SBUnixSignals, SetShouldStop, (int32_t, bool), signo, - value); + LLDB_INSTRUMENT_VA(this, signo, value); auto signals_sp = GetSP(); @@ -131,8 +121,7 @@ bool SBUnixSignals::SetShouldStop(int32_t signo, bool value) { } bool SBUnixSignals::GetShouldNotify(int32_t signo) const { - LLDB_RECORD_METHOD_CONST(bool, SBUnixSignals, GetShouldNotify, (int32_t), - signo); + LLDB_INSTRUMENT_VA(this, signo); if (auto signals_sp = GetSP()) return signals_sp->GetShouldNotify(signo); @@ -141,8 +130,7 @@ bool SBUnixSignals::GetShouldNotify(int32_t signo) const { } bool SBUnixSignals::SetShouldNotify(int32_t signo, bool value) { - LLDB_RECORD_METHOD(bool, SBUnixSignals, SetShouldNotify, (int32_t, bool), - signo, value); + LLDB_INSTRUMENT_VA(this, signo, value); auto signals_sp = GetSP(); @@ -153,7 +141,7 @@ bool SBUnixSignals::SetShouldNotify(int32_t signo, bool value) { } int32_t SBUnixSignals::GetNumSignals() const { - LLDB_RECORD_METHOD_CONST_NO_ARGS(int32_t, SBUnixSignals, GetNumSignals); + LLDB_INSTRUMENT_VA(this); if (auto signals_sp = GetSP()) return signals_sp->GetNumSignals(); @@ -162,44 +150,10 @@ int32_t SBUnixSignals::GetNumSignals() const { } int32_t SBUnixSignals::GetSignalAtIndex(int32_t index) const { - LLDB_RECORD_METHOD_CONST(int32_t, SBUnixSignals, GetSignalAtIndex, (int32_t), - index); + LLDB_INSTRUMENT_VA(this, index); if (auto signals_sp = GetSP()) return signals_sp->GetSignalAtIndex(index); return LLDB_INVALID_SIGNAL_NUMBER; } - -namespace lldb_private { -namespace repro { - -template <> -void RegisterMethods<SBUnixSignals>(Registry &R) { - LLDB_REGISTER_CONSTRUCTOR(SBUnixSignals, ()); - LLDB_REGISTER_CONSTRUCTOR(SBUnixSignals, (const lldb::SBUnixSignals &)); - LLDB_REGISTER_METHOD( - const lldb::SBUnixSignals &, - SBUnixSignals, operator=,(const lldb::SBUnixSignals &)); - LLDB_REGISTER_METHOD(void, SBUnixSignals, Clear, ()); - LLDB_REGISTER_METHOD_CONST(bool, SBUnixSignals, IsValid, ()); - LLDB_REGISTER_METHOD_CONST(bool, SBUnixSignals, operator bool, ()); - LLDB_REGISTER_METHOD_CONST(const char *, SBUnixSignals, GetSignalAsCString, - (int32_t)); - LLDB_REGISTER_METHOD_CONST(int32_t, SBUnixSignals, GetSignalNumberFromName, - (const char *)); - LLDB_REGISTER_METHOD_CONST(bool, SBUnixSignals, GetShouldSuppress, - (int32_t)); - LLDB_REGISTER_METHOD(bool, SBUnixSignals, SetShouldSuppress, - (int32_t, bool)); - LLDB_REGISTER_METHOD_CONST(bool, SBUnixSignals, GetShouldStop, (int32_t)); - LLDB_REGISTER_METHOD(bool, SBUnixSignals, SetShouldStop, (int32_t, bool)); - LLDB_REGISTER_METHOD_CONST(bool, SBUnixSignals, GetShouldNotify, (int32_t)); - LLDB_REGISTER_METHOD(bool, SBUnixSignals, SetShouldNotify, (int32_t, bool)); - LLDB_REGISTER_METHOD_CONST(int32_t, SBUnixSignals, GetNumSignals, ()); - LLDB_REGISTER_METHOD_CONST(int32_t, SBUnixSignals, GetSignalAtIndex, - (int32_t)); -} - -} -} diff --git a/lldb/source/API/SBValue.cpp b/lldb/source/API/SBValue.cpp index e3325b8d36fa..20581cfabdd6 100644 --- a/lldb/source/API/SBValue.cpp +++ b/lldb/source/API/SBValue.cpp @@ -7,7 +7,7 @@ //===----------------------------------------------------------------------===// #include "lldb/API/SBValue.h" -#include "SBReproducerPrivate.h" +#include "lldb/Utility/Instrumentation.h" #include "lldb/API/SBDeclaration.h" #include "lldb/API/SBStream.h" @@ -58,8 +58,8 @@ public: ValueImpl(lldb::ValueObjectSP in_valobj_sp, lldb::DynamicValueType use_dynamic, bool use_synthetic, const char *name = nullptr) - : m_valobj_sp(), m_use_dynamic(use_dynamic), - m_use_synthetic(use_synthetic), m_name(name) { + : m_use_dynamic(use_dynamic), m_use_synthetic(use_synthetic), + m_name(name) { if (in_valobj_sp) { if ((m_valobj_sp = in_valobj_sp->GetQualifiedRepresentationIfAvailable( lldb::eNoDynamicValues, false))) { @@ -215,38 +215,37 @@ private: Status m_lock_error; }; -SBValue::SBValue() : m_opaque_sp() { LLDB_RECORD_CONSTRUCTOR_NO_ARGS(SBValue); } +SBValue::SBValue() { LLDB_INSTRUMENT_VA(this); } SBValue::SBValue(const lldb::ValueObjectSP &value_sp) { - LLDB_RECORD_CONSTRUCTOR(SBValue, (const lldb::ValueObjectSP &), value_sp); + LLDB_INSTRUMENT_VA(this, value_sp); SetSP(value_sp); } SBValue::SBValue(const SBValue &rhs) { - LLDB_RECORD_CONSTRUCTOR(SBValue, (const lldb::SBValue &), rhs); + LLDB_INSTRUMENT_VA(this, rhs); SetSP(rhs.m_opaque_sp); } SBValue &SBValue::operator=(const SBValue &rhs) { - LLDB_RECORD_METHOD(lldb::SBValue &, - SBValue, operator=,(const lldb::SBValue &), rhs); + LLDB_INSTRUMENT_VA(this, rhs); if (this != &rhs) { SetSP(rhs.m_opaque_sp); } - return LLDB_RECORD_RESULT(*this); + return *this; } SBValue::~SBValue() = default; bool SBValue::IsValid() { - LLDB_RECORD_METHOD_NO_ARGS(bool, SBValue, IsValid); + LLDB_INSTRUMENT_VA(this); return this->operator bool(); } SBValue::operator bool() const { - LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBValue, operator bool); + LLDB_INSTRUMENT_VA(this); // If this function ever changes to anything that does more than just check // if the opaque shared pointer is non NULL, then we need to update all "if @@ -256,13 +255,13 @@ SBValue::operator bool() const { } void SBValue::Clear() { - LLDB_RECORD_METHOD_NO_ARGS(void, SBValue, Clear); + LLDB_INSTRUMENT_VA(this); m_opaque_sp.reset(); } SBError SBValue::GetError() { - LLDB_RECORD_METHOD_NO_ARGS(lldb::SBError, SBValue, GetError); + LLDB_INSTRUMENT_VA(this); SBError sb_error; @@ -274,11 +273,11 @@ SBError SBValue::GetError() { sb_error.SetErrorStringWithFormat("error: %s", locker.GetError().AsCString()); - return LLDB_RECORD_RESULT(sb_error); + return sb_error; } user_id_t SBValue::GetID() { - LLDB_RECORD_METHOD_NO_ARGS(lldb::user_id_t, SBValue, GetID); + LLDB_INSTRUMENT_VA(this); ValueLocker locker; lldb::ValueObjectSP value_sp(GetSP(locker)); @@ -288,7 +287,7 @@ user_id_t SBValue::GetID() { } const char *SBValue::GetName() { - LLDB_RECORD_METHOD_NO_ARGS(const char *, SBValue, GetName); + LLDB_INSTRUMENT_VA(this); const char *name = nullptr; ValueLocker locker; @@ -300,7 +299,7 @@ const char *SBValue::GetName() { } const char *SBValue::GetTypeName() { - LLDB_RECORD_METHOD_NO_ARGS(const char *, SBValue, GetTypeName); + LLDB_INSTRUMENT_VA(this); const char *name = nullptr; ValueLocker locker; @@ -313,7 +312,7 @@ const char *SBValue::GetTypeName() { } const char *SBValue::GetDisplayTypeName() { - LLDB_RECORD_METHOD_NO_ARGS(const char *, SBValue, GetDisplayTypeName); + LLDB_INSTRUMENT_VA(this); const char *name = nullptr; ValueLocker locker; @@ -326,7 +325,7 @@ const char *SBValue::GetDisplayTypeName() { } size_t SBValue::GetByteSize() { - LLDB_RECORD_METHOD_NO_ARGS(size_t, SBValue, GetByteSize); + LLDB_INSTRUMENT_VA(this); size_t result = 0; @@ -340,7 +339,7 @@ size_t SBValue::GetByteSize() { } bool SBValue::IsInScope() { - LLDB_RECORD_METHOD_NO_ARGS(bool, SBValue, IsInScope); + LLDB_INSTRUMENT_VA(this); bool result = false; @@ -354,7 +353,7 @@ bool SBValue::IsInScope() { } const char *SBValue::GetValue() { - LLDB_RECORD_METHOD_NO_ARGS(const char *, SBValue, GetValue); + LLDB_INSTRUMENT_VA(this); const char *cstr = nullptr; ValueLocker locker; @@ -367,7 +366,7 @@ const char *SBValue::GetValue() { } ValueType SBValue::GetValueType() { - LLDB_RECORD_METHOD_NO_ARGS(lldb::ValueType, SBValue, GetValueType); + LLDB_INSTRUMENT_VA(this); ValueType result = eValueTypeInvalid; ValueLocker locker; @@ -379,7 +378,7 @@ ValueType SBValue::GetValueType() { } const char *SBValue::GetObjectDescription() { - LLDB_RECORD_METHOD_NO_ARGS(const char *, SBValue, GetObjectDescription); + LLDB_INSTRUMENT_VA(this); const char *cstr = nullptr; ValueLocker locker; @@ -392,7 +391,7 @@ const char *SBValue::GetObjectDescription() { } SBType SBValue::GetType() { - LLDB_RECORD_METHOD_NO_ARGS(lldb::SBType, SBValue, GetType); + LLDB_INSTRUMENT_VA(this); SBType sb_type; ValueLocker locker; @@ -403,11 +402,11 @@ SBType SBValue::GetType() { sb_type.SetSP(type_sp); } - return LLDB_RECORD_RESULT(sb_type); + return sb_type; } bool SBValue::GetValueDidChange() { - LLDB_RECORD_METHOD_NO_ARGS(bool, SBValue, GetValueDidChange); + LLDB_INSTRUMENT_VA(this); bool result = false; ValueLocker locker; @@ -421,7 +420,7 @@ bool SBValue::GetValueDidChange() { } const char *SBValue::GetSummary() { - LLDB_RECORD_METHOD_NO_ARGS(const char *, SBValue, GetSummary); + LLDB_INSTRUMENT_VA(this); const char *cstr = nullptr; ValueLocker locker; @@ -435,9 +434,7 @@ const char *SBValue::GetSummary() { const char *SBValue::GetSummary(lldb::SBStream &stream, lldb::SBTypeSummaryOptions &options) { - LLDB_RECORD_METHOD(const char *, SBValue, GetSummary, - (lldb::SBStream &, lldb::SBTypeSummaryOptions &), stream, - options); + LLDB_INSTRUMENT_VA(this, stream, options); ValueLocker locker; lldb::ValueObjectSP value_sp(GetSP(locker)); @@ -451,7 +448,7 @@ const char *SBValue::GetSummary(lldb::SBStream &stream, } const char *SBValue::GetLocation() { - LLDB_RECORD_METHOD_NO_ARGS(const char *, SBValue, GetLocation); + LLDB_INSTRUMENT_VA(this); const char *cstr = nullptr; ValueLocker locker; @@ -464,16 +461,14 @@ const char *SBValue::GetLocation() { // Deprecated - use the one that takes an lldb::SBError bool SBValue::SetValueFromCString(const char *value_str) { - LLDB_RECORD_METHOD(bool, SBValue, SetValueFromCString, (const char *), - value_str); + LLDB_INSTRUMENT_VA(this, value_str); lldb::SBError dummy; return SetValueFromCString(value_str, dummy); } bool SBValue::SetValueFromCString(const char *value_str, lldb::SBError &error) { - LLDB_RECORD_METHOD(bool, SBValue, SetValueFromCString, - (const char *, lldb::SBError &), value_str, error); + LLDB_INSTRUMENT_VA(this, value_str, error); bool success = false; ValueLocker locker; @@ -488,7 +483,7 @@ bool SBValue::SetValueFromCString(const char *value_str, lldb::SBError &error) { } lldb::SBTypeFormat SBValue::GetTypeFormat() { - LLDB_RECORD_METHOD_NO_ARGS(lldb::SBTypeFormat, SBValue, GetTypeFormat); + LLDB_INSTRUMENT_VA(this); lldb::SBTypeFormat format; ValueLocker locker; @@ -500,11 +495,11 @@ lldb::SBTypeFormat SBValue::GetTypeFormat() { format.SetSP(format_sp); } } - return LLDB_RECORD_RESULT(format); + return format; } lldb::SBTypeSummary SBValue::GetTypeSummary() { - LLDB_RECORD_METHOD_NO_ARGS(lldb::SBTypeSummary, SBValue, GetTypeSummary); + LLDB_INSTRUMENT_VA(this); lldb::SBTypeSummary summary; ValueLocker locker; @@ -516,11 +511,11 @@ lldb::SBTypeSummary SBValue::GetTypeSummary() { summary.SetSP(summary_sp); } } - return LLDB_RECORD_RESULT(summary); + return summary; } lldb::SBTypeFilter SBValue::GetTypeFilter() { - LLDB_RECORD_METHOD_NO_ARGS(lldb::SBTypeFilter, SBValue, GetTypeFilter); + LLDB_INSTRUMENT_VA(this); lldb::SBTypeFilter filter; ValueLocker locker; @@ -536,11 +531,11 @@ lldb::SBTypeFilter SBValue::GetTypeFilter() { } } } - return LLDB_RECORD_RESULT(filter); + return filter; } lldb::SBTypeSynthetic SBValue::GetTypeSynthetic() { - LLDB_RECORD_METHOD_NO_ARGS(lldb::SBTypeSynthetic, SBValue, GetTypeSynthetic); + LLDB_INSTRUMENT_VA(this); lldb::SBTypeSynthetic synthetic; ValueLocker locker; @@ -556,14 +551,12 @@ lldb::SBTypeSynthetic SBValue::GetTypeSynthetic() { } } } - return LLDB_RECORD_RESULT(synthetic); + return synthetic; } lldb::SBValue SBValue::CreateChildAtOffset(const char *name, uint32_t offset, SBType type) { - LLDB_RECORD_METHOD(lldb::SBValue, SBValue, CreateChildAtOffset, - (const char *, uint32_t, lldb::SBType), name, offset, - type); + LLDB_INSTRUMENT_VA(this, name, offset, type); lldb::SBValue sb_value; ValueLocker locker; @@ -577,11 +570,11 @@ lldb::SBValue SBValue::CreateChildAtOffset(const char *name, uint32_t offset, GetPreferDynamicValue(), GetPreferSyntheticValue(), name); } } - return LLDB_RECORD_RESULT(sb_value); + return sb_value; } lldb::SBValue SBValue::Cast(SBType type) { - LLDB_RECORD_METHOD(lldb::SBValue, SBValue, Cast, (lldb::SBType), type); + LLDB_INSTRUMENT_VA(this, type); lldb::SBValue sb_value; ValueLocker locker; @@ -590,26 +583,22 @@ lldb::SBValue SBValue::Cast(SBType type) { if (value_sp && type_sp) sb_value.SetSP(value_sp->Cast(type_sp->GetCompilerType(false)), GetPreferDynamicValue(), GetPreferSyntheticValue()); - return LLDB_RECORD_RESULT(sb_value); + return sb_value; } lldb::SBValue SBValue::CreateValueFromExpression(const char *name, const char *expression) { - LLDB_RECORD_METHOD(lldb::SBValue, SBValue, CreateValueFromExpression, - (const char *, const char *), name, expression); + LLDB_INSTRUMENT_VA(this, name, expression); SBExpressionOptions options; options.ref().SetKeepInMemory(true); - return LLDB_RECORD_RESULT( - CreateValueFromExpression(name, expression, options)); + return CreateValueFromExpression(name, expression, options); } lldb::SBValue SBValue::CreateValueFromExpression(const char *name, const char *expression, SBExpressionOptions &options) { - LLDB_RECORD_METHOD(lldb::SBValue, SBValue, CreateValueFromExpression, - (const char *, const char *, lldb::SBExpressionOptions &), - name, expression, options); + LLDB_INSTRUMENT_VA(this, name, expression, options); lldb::SBValue sb_value; ValueLocker locker; @@ -623,15 +612,13 @@ lldb::SBValue SBValue::CreateValueFromExpression(const char *name, new_value_sp->SetName(ConstString(name)); } sb_value.SetSP(new_value_sp); - return LLDB_RECORD_RESULT(sb_value); + return sb_value; } lldb::SBValue SBValue::CreateValueFromAddress(const char *name, lldb::addr_t address, SBType sb_type) { - LLDB_RECORD_METHOD(lldb::SBValue, SBValue, CreateValueFromAddress, - (const char *, lldb::addr_t, lldb::SBType), name, address, - sb_type); + LLDB_INSTRUMENT_VA(this, name, address, sb_type); lldb::SBValue sb_value; ValueLocker locker; @@ -645,14 +632,12 @@ lldb::SBValue SBValue::CreateValueFromAddress(const char *name, exe_ctx, ast_type); } sb_value.SetSP(new_value_sp); - return LLDB_RECORD_RESULT(sb_value); + return sb_value; } lldb::SBValue SBValue::CreateValueFromData(const char *name, SBData data, SBType sb_type) { - LLDB_RECORD_METHOD(lldb::SBValue, SBValue, CreateValueFromData, - (const char *, lldb::SBData, lldb::SBType), name, data, - sb_type); + LLDB_INSTRUMENT_VA(this, name, data, sb_type); lldb::SBValue sb_value; lldb::ValueObjectSP new_value_sp; @@ -666,11 +651,11 @@ lldb::SBValue SBValue::CreateValueFromData(const char *name, SBData data, new_value_sp->SetAddressTypeOfChildren(eAddressTypeLoad); } sb_value.SetSP(new_value_sp); - return LLDB_RECORD_RESULT(sb_value); + return sb_value; } SBValue SBValue::GetChildAtIndex(uint32_t idx) { - LLDB_RECORD_METHOD(lldb::SBValue, SBValue, GetChildAtIndex, (uint32_t), idx); + LLDB_INSTRUMENT_VA(this, idx); const bool can_create_synthetic = false; lldb::DynamicValueType use_dynamic = eNoDynamicValues; @@ -681,16 +666,13 @@ SBValue SBValue::GetChildAtIndex(uint32_t idx) { if (target_sp) use_dynamic = target_sp->GetPreferDynamicValue(); - return LLDB_RECORD_RESULT( - GetChildAtIndex(idx, use_dynamic, can_create_synthetic)); + return GetChildAtIndex(idx, use_dynamic, can_create_synthetic); } SBValue SBValue::GetChildAtIndex(uint32_t idx, lldb::DynamicValueType use_dynamic, bool can_create_synthetic) { - LLDB_RECORD_METHOD(lldb::SBValue, SBValue, GetChildAtIndex, - (uint32_t, lldb::DynamicValueType, bool), idx, use_dynamic, - can_create_synthetic); + LLDB_INSTRUMENT_VA(this, idx, use_dynamic, can_create_synthetic); lldb::ValueObjectSP child_sp; @@ -707,12 +689,11 @@ SBValue SBValue::GetChildAtIndex(uint32_t idx, SBValue sb_value; sb_value.SetSP(child_sp, use_dynamic, GetPreferSyntheticValue()); - return LLDB_RECORD_RESULT(sb_value); + return sb_value; } uint32_t SBValue::GetIndexOfChildWithName(const char *name) { - LLDB_RECORD_METHOD(uint32_t, SBValue, GetIndexOfChildWithName, (const char *), - name); + LLDB_INSTRUMENT_VA(this, name); uint32_t idx = UINT32_MAX; ValueLocker locker; @@ -724,8 +705,7 @@ uint32_t SBValue::GetIndexOfChildWithName(const char *name) { } SBValue SBValue::GetChildMemberWithName(const char *name) { - LLDB_RECORD_METHOD(lldb::SBValue, SBValue, GetChildMemberWithName, - (const char *), name); + LLDB_INSTRUMENT_VA(this, name); lldb::DynamicValueType use_dynamic_value = eNoDynamicValues; TargetSP target_sp; @@ -734,15 +714,13 @@ SBValue SBValue::GetChildMemberWithName(const char *name) { if (target_sp) use_dynamic_value = target_sp->GetPreferDynamicValue(); - return LLDB_RECORD_RESULT(GetChildMemberWithName(name, use_dynamic_value)); + return GetChildMemberWithName(name, use_dynamic_value); } SBValue SBValue::GetChildMemberWithName(const char *name, lldb::DynamicValueType use_dynamic_value) { - LLDB_RECORD_METHOD(lldb::SBValue, SBValue, GetChildMemberWithName, - (const char *, lldb::DynamicValueType), name, - use_dynamic_value); + LLDB_INSTRUMENT_VA(this, name, use_dynamic_value); lldb::ValueObjectSP child_sp; const ConstString str_name(name); @@ -756,12 +734,11 @@ SBValue::GetChildMemberWithName(const char *name, SBValue sb_value; sb_value.SetSP(child_sp, use_dynamic_value, GetPreferSyntheticValue()); - return LLDB_RECORD_RESULT(sb_value); + return sb_value; } lldb::SBValue SBValue::GetDynamicValue(lldb::DynamicValueType use_dynamic) { - LLDB_RECORD_METHOD(lldb::SBValue, SBValue, GetDynamicValue, - (lldb::DynamicValueType), use_dynamic); + LLDB_INSTRUMENT_VA(this, use_dynamic); SBValue value_sb; if (IsValid()) { @@ -769,11 +746,11 @@ lldb::SBValue SBValue::GetDynamicValue(lldb::DynamicValueType use_dynamic) { m_opaque_sp->GetUseSynthetic())); value_sb.SetSP(proxy_sp); } - return LLDB_RECORD_RESULT(value_sb); + return value_sb; } lldb::SBValue SBValue::GetStaticValue() { - LLDB_RECORD_METHOD_NO_ARGS(lldb::SBValue, SBValue, GetStaticValue); + LLDB_INSTRUMENT_VA(this); SBValue value_sb; if (IsValid()) { @@ -782,11 +759,11 @@ lldb::SBValue SBValue::GetStaticValue() { m_opaque_sp->GetUseSynthetic())); value_sb.SetSP(proxy_sp); } - return LLDB_RECORD_RESULT(value_sb); + return value_sb; } lldb::SBValue SBValue::GetNonSyntheticValue() { - LLDB_RECORD_METHOD_NO_ARGS(lldb::SBValue, SBValue, GetNonSyntheticValue); + LLDB_INSTRUMENT_VA(this); SBValue value_sb; if (IsValid()) { @@ -794,12 +771,11 @@ lldb::SBValue SBValue::GetNonSyntheticValue() { m_opaque_sp->GetUseDynamic(), false)); value_sb.SetSP(proxy_sp); } - return LLDB_RECORD_RESULT(value_sb); + return value_sb; } lldb::DynamicValueType SBValue::GetPreferDynamicValue() { - LLDB_RECORD_METHOD_NO_ARGS(lldb::DynamicValueType, SBValue, - GetPreferDynamicValue); + LLDB_INSTRUMENT_VA(this); if (!IsValid()) return eNoDynamicValues; @@ -807,15 +783,14 @@ lldb::DynamicValueType SBValue::GetPreferDynamicValue() { } void SBValue::SetPreferDynamicValue(lldb::DynamicValueType use_dynamic) { - LLDB_RECORD_METHOD(void, SBValue, SetPreferDynamicValue, - (lldb::DynamicValueType), use_dynamic); + LLDB_INSTRUMENT_VA(this, use_dynamic); if (IsValid()) return m_opaque_sp->SetUseDynamic(use_dynamic); } bool SBValue::GetPreferSyntheticValue() { - LLDB_RECORD_METHOD_NO_ARGS(bool, SBValue, GetPreferSyntheticValue); + LLDB_INSTRUMENT_VA(this); if (!IsValid()) return false; @@ -823,15 +798,14 @@ bool SBValue::GetPreferSyntheticValue() { } void SBValue::SetPreferSyntheticValue(bool use_synthetic) { - LLDB_RECORD_METHOD(void, SBValue, SetPreferSyntheticValue, (bool), - use_synthetic); + LLDB_INSTRUMENT_VA(this, use_synthetic); if (IsValid()) return m_opaque_sp->SetUseSynthetic(use_synthetic); } bool SBValue::IsDynamic() { - LLDB_RECORD_METHOD_NO_ARGS(bool, SBValue, IsDynamic); + LLDB_INSTRUMENT_VA(this); ValueLocker locker; lldb::ValueObjectSP value_sp(GetSP(locker)); @@ -841,7 +815,7 @@ bool SBValue::IsDynamic() { } bool SBValue::IsSynthetic() { - LLDB_RECORD_METHOD_NO_ARGS(bool, SBValue, IsSynthetic); + LLDB_INSTRUMENT_VA(this); ValueLocker locker; lldb::ValueObjectSP value_sp(GetSP(locker)); @@ -851,7 +825,7 @@ bool SBValue::IsSynthetic() { } bool SBValue::IsSyntheticChildrenGenerated() { - LLDB_RECORD_METHOD_NO_ARGS(bool, SBValue, IsSyntheticChildrenGenerated); + LLDB_INSTRUMENT_VA(this); ValueLocker locker; lldb::ValueObjectSP value_sp(GetSP(locker)); @@ -861,7 +835,7 @@ bool SBValue::IsSyntheticChildrenGenerated() { } void SBValue::SetSyntheticChildrenGenerated(bool is) { - LLDB_RECORD_METHOD(void, SBValue, SetSyntheticChildrenGenerated, (bool), is); + LLDB_INSTRUMENT_VA(this, is); ValueLocker locker; lldb::ValueObjectSP value_sp(GetSP(locker)); @@ -870,8 +844,7 @@ void SBValue::SetSyntheticChildrenGenerated(bool is) { } lldb::SBValue SBValue::GetValueForExpressionPath(const char *expr_path) { - LLDB_RECORD_METHOD(lldb::SBValue, SBValue, GetValueForExpressionPath, - (const char *), expr_path); + LLDB_INSTRUMENT_VA(this, expr_path); lldb::ValueObjectSP child_sp; ValueLocker locker; @@ -884,12 +857,11 @@ lldb::SBValue SBValue::GetValueForExpressionPath(const char *expr_path) { SBValue sb_value; sb_value.SetSP(child_sp, GetPreferDynamicValue(), GetPreferSyntheticValue()); - return LLDB_RECORD_RESULT(sb_value); + return sb_value; } int64_t SBValue::GetValueAsSigned(SBError &error, int64_t fail_value) { - LLDB_RECORD_METHOD(int64_t, SBValue, GetValueAsSigned, - (lldb::SBError &, int64_t), error, fail_value); + LLDB_INSTRUMENT_VA(this, error, fail_value); error.Clear(); ValueLocker locker; @@ -909,8 +881,7 @@ int64_t SBValue::GetValueAsSigned(SBError &error, int64_t fail_value) { } uint64_t SBValue::GetValueAsUnsigned(SBError &error, uint64_t fail_value) { - LLDB_RECORD_METHOD(uint64_t, SBValue, GetValueAsUnsigned, - (lldb::SBError &, uint64_t), error, fail_value); + LLDB_INSTRUMENT_VA(this, error, fail_value); error.Clear(); ValueLocker locker; @@ -930,7 +901,7 @@ uint64_t SBValue::GetValueAsUnsigned(SBError &error, uint64_t fail_value) { } int64_t SBValue::GetValueAsSigned(int64_t fail_value) { - LLDB_RECORD_METHOD(int64_t, SBValue, GetValueAsSigned, (int64_t), fail_value); + LLDB_INSTRUMENT_VA(this, fail_value); ValueLocker locker; lldb::ValueObjectSP value_sp(GetSP(locker)); @@ -941,8 +912,7 @@ int64_t SBValue::GetValueAsSigned(int64_t fail_value) { } uint64_t SBValue::GetValueAsUnsigned(uint64_t fail_value) { - LLDB_RECORD_METHOD(uint64_t, SBValue, GetValueAsUnsigned, (uint64_t), - fail_value); + LLDB_INSTRUMENT_VA(this, fail_value); ValueLocker locker; lldb::ValueObjectSP value_sp(GetSP(locker)); @@ -953,7 +923,7 @@ uint64_t SBValue::GetValueAsUnsigned(uint64_t fail_value) { } bool SBValue::MightHaveChildren() { - LLDB_RECORD_METHOD_NO_ARGS(bool, SBValue, MightHaveChildren); + LLDB_INSTRUMENT_VA(this); bool has_children = false; ValueLocker locker; @@ -965,7 +935,7 @@ bool SBValue::MightHaveChildren() { } bool SBValue::IsRuntimeSupportValue() { - LLDB_RECORD_METHOD_NO_ARGS(bool, SBValue, IsRuntimeSupportValue); + LLDB_INSTRUMENT_VA(this); bool is_support = false; ValueLocker locker; @@ -977,13 +947,13 @@ bool SBValue::IsRuntimeSupportValue() { } uint32_t SBValue::GetNumChildren() { - LLDB_RECORD_METHOD_NO_ARGS(uint32_t, SBValue, GetNumChildren); + LLDB_INSTRUMENT_VA(this); return GetNumChildren(UINT32_MAX); } uint32_t SBValue::GetNumChildren(uint32_t max) { - LLDB_RECORD_METHOD(uint32_t, SBValue, GetNumChildren, (uint32_t), max); + LLDB_INSTRUMENT_VA(this, max); uint32_t num_children = 0; @@ -996,7 +966,7 @@ uint32_t SBValue::GetNumChildren(uint32_t max) { } SBValue SBValue::Dereference() { - LLDB_RECORD_METHOD_NO_ARGS(lldb::SBValue, SBValue, Dereference); + LLDB_INSTRUMENT_VA(this); SBValue sb_value; ValueLocker locker; @@ -1006,18 +976,18 @@ SBValue SBValue::Dereference() { sb_value = value_sp->Dereference(error); } - return LLDB_RECORD_RESULT(sb_value); + return sb_value; } // Deprecated - please use GetType().IsPointerType() instead. bool SBValue::TypeIsPointerType() { - LLDB_RECORD_METHOD_NO_ARGS(bool, SBValue, TypeIsPointerType); + LLDB_INSTRUMENT_VA(this); return GetType().IsPointerType(); } void *SBValue::GetOpaqueType() { - LLDB_RECORD_METHOD_NO_ARGS(void *, SBValue, GetOpaqueType); + LLDB_INSTRUMENT_VA(this); ValueLocker locker; lldb::ValueObjectSP value_sp(GetSP(locker)); @@ -1027,7 +997,7 @@ void *SBValue::GetOpaqueType() { } lldb::SBTarget SBValue::GetTarget() { - LLDB_RECORD_METHOD_NO_ARGS(lldb::SBTarget, SBValue, GetTarget); + LLDB_INSTRUMENT_VA(this); SBTarget sb_target; TargetSP target_sp; @@ -1036,11 +1006,11 @@ lldb::SBTarget SBValue::GetTarget() { sb_target.SetSP(target_sp); } - return LLDB_RECORD_RESULT(sb_target); + return sb_target; } lldb::SBProcess SBValue::GetProcess() { - LLDB_RECORD_METHOD_NO_ARGS(lldb::SBProcess, SBValue, GetProcess); + LLDB_INSTRUMENT_VA(this); SBProcess sb_process; ProcessSP process_sp; @@ -1049,11 +1019,11 @@ lldb::SBProcess SBValue::GetProcess() { sb_process.SetSP(process_sp); } - return LLDB_RECORD_RESULT(sb_process); + return sb_process; } lldb::SBThread SBValue::GetThread() { - LLDB_RECORD_METHOD_NO_ARGS(lldb::SBThread, SBValue, GetThread); + LLDB_INSTRUMENT_VA(this); SBThread sb_thread; ThreadSP thread_sp; @@ -1062,11 +1032,11 @@ lldb::SBThread SBValue::GetThread() { sb_thread.SetThread(thread_sp); } - return LLDB_RECORD_RESULT(sb_thread); + return sb_thread; } lldb::SBFrame SBValue::GetFrame() { - LLDB_RECORD_METHOD_NO_ARGS(lldb::SBFrame, SBValue, GetFrame); + LLDB_INSTRUMENT_VA(this); SBFrame sb_frame; StackFrameSP frame_sp; @@ -1075,7 +1045,7 @@ lldb::SBFrame SBValue::GetFrame() { sb_frame.SetFrameSP(frame_sp); } - return LLDB_RECORD_RESULT(sb_frame); + return sb_frame; } lldb::ValueObjectSP SBValue::GetSP(ValueLocker &locker) const { @@ -1087,10 +1057,10 @@ lldb::ValueObjectSP SBValue::GetSP(ValueLocker &locker) const { } lldb::ValueObjectSP SBValue::GetSP() const { - LLDB_RECORD_METHOD_CONST_NO_ARGS(lldb::ValueObjectSP, SBValue, GetSP); + LLDB_INSTRUMENT_VA(this); ValueLocker locker; - return LLDB_RECORD_RESULT(GetSP(locker)); + return GetSP(locker); } void SBValue::SetSP(ValueImplSP impl_sp) { m_opaque_sp = impl_sp; } @@ -1148,8 +1118,7 @@ void SBValue::SetSP(const lldb::ValueObjectSP &sp, } bool SBValue::GetExpressionPath(SBStream &description) { - LLDB_RECORD_METHOD(bool, SBValue, GetExpressionPath, (lldb::SBStream &), - description); + LLDB_INSTRUMENT_VA(this, description); ValueLocker locker; lldb::ValueObjectSP value_sp(GetSP(locker)); @@ -1162,8 +1131,7 @@ bool SBValue::GetExpressionPath(SBStream &description) { bool SBValue::GetExpressionPath(SBStream &description, bool qualify_cxx_base_classes) { - LLDB_RECORD_METHOD(bool, SBValue, GetExpressionPath, (lldb::SBStream &, bool), - description, qualify_cxx_base_classes); + LLDB_INSTRUMENT_VA(this, description, qualify_cxx_base_classes); ValueLocker locker; lldb::ValueObjectSP value_sp(GetSP(locker)); @@ -1175,59 +1143,52 @@ bool SBValue::GetExpressionPath(SBStream &description, } lldb::SBValue SBValue::EvaluateExpression(const char *expr) const { - LLDB_RECORD_METHOD_CONST(lldb::SBValue, SBValue, EvaluateExpression, - (const char *), expr); + LLDB_INSTRUMENT_VA(this, expr); ValueLocker locker; lldb::ValueObjectSP value_sp(GetSP(locker)); if (!value_sp) - return LLDB_RECORD_RESULT(SBValue()); + return SBValue(); lldb::TargetSP target_sp = value_sp->GetTargetSP(); if (!target_sp) - return LLDB_RECORD_RESULT(SBValue()); + return SBValue(); lldb::SBExpressionOptions options; options.SetFetchDynamicValue(target_sp->GetPreferDynamicValue()); options.SetUnwindOnError(true); options.SetIgnoreBreakpoints(true); - return LLDB_RECORD_RESULT(EvaluateExpression(expr, options, nullptr)); + return EvaluateExpression(expr, options, nullptr); } lldb::SBValue SBValue::EvaluateExpression(const char *expr, const SBExpressionOptions &options) const { - LLDB_RECORD_METHOD_CONST(lldb::SBValue, SBValue, EvaluateExpression, - (const char *, const lldb::SBExpressionOptions &), - expr, options); + LLDB_INSTRUMENT_VA(this, expr, options); - return LLDB_RECORD_RESULT(EvaluateExpression(expr, options, nullptr)); + return EvaluateExpression(expr, options, nullptr); } lldb::SBValue SBValue::EvaluateExpression(const char *expr, const SBExpressionOptions &options, const char *name) const { - LLDB_RECORD_METHOD_CONST( - lldb::SBValue, SBValue, EvaluateExpression, - (const char *, const lldb::SBExpressionOptions &, const char *), expr, - options, name); - + LLDB_INSTRUMENT_VA(this, expr, options, name); if (!expr || expr[0] == '\0') { - return LLDB_RECORD_RESULT(SBValue()); + return SBValue(); } ValueLocker locker; lldb::ValueObjectSP value_sp(GetSP(locker)); if (!value_sp) { - return LLDB_RECORD_RESULT(SBValue()); + return SBValue(); } lldb::TargetSP target_sp = value_sp->GetTargetSP(); if (!target_sp) { - return LLDB_RECORD_RESULT(SBValue()); + return SBValue(); } std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex()); @@ -1235,7 +1196,7 @@ lldb::SBValue SBValue::EvaluateExpression(const char *expr, StackFrame *frame = exe_ctx.GetFramePtr(); if (!frame) { - return LLDB_RECORD_RESULT(SBValue()); + return SBValue(); } ValueObjectSP res_val_sp; @@ -1247,12 +1208,11 @@ lldb::SBValue SBValue::EvaluateExpression(const char *expr, SBValue result; result.SetSP(res_val_sp, options.GetFetchDynamicValue()); - return LLDB_RECORD_RESULT(result); + return result; } bool SBValue::GetDescription(SBStream &description) { - LLDB_RECORD_METHOD(bool, SBValue, GetDescription, (lldb::SBStream &), - description); + LLDB_INSTRUMENT_VA(this, description); Stream &strm = description.ref(); @@ -1267,7 +1227,7 @@ bool SBValue::GetDescription(SBStream &description) { } lldb::Format SBValue::GetFormat() { - LLDB_RECORD_METHOD_NO_ARGS(lldb::Format, SBValue, GetFormat); + LLDB_INSTRUMENT_VA(this); ValueLocker locker; lldb::ValueObjectSP value_sp(GetSP(locker)); @@ -1277,7 +1237,7 @@ lldb::Format SBValue::GetFormat() { } void SBValue::SetFormat(lldb::Format format) { - LLDB_RECORD_METHOD(void, SBValue, SetFormat, (lldb::Format), format); + LLDB_INSTRUMENT_VA(this, format); ValueLocker locker; lldb::ValueObjectSP value_sp(GetSP(locker)); @@ -1286,7 +1246,7 @@ void SBValue::SetFormat(lldb::Format format) { } lldb::SBValue SBValue::AddressOf() { - LLDB_RECORD_METHOD_NO_ARGS(lldb::SBValue, SBValue, AddressOf); + LLDB_INSTRUMENT_VA(this); SBValue sb_value; ValueLocker locker; @@ -1297,11 +1257,11 @@ lldb::SBValue SBValue::AddressOf() { GetPreferSyntheticValue()); } - return LLDB_RECORD_RESULT(sb_value); + return sb_value; } lldb::addr_t SBValue::GetLoadAddress() { - LLDB_RECORD_METHOD_NO_ARGS(lldb::addr_t, SBValue, GetLoadAddress); + LLDB_INSTRUMENT_VA(this); lldb::addr_t value = LLDB_INVALID_ADDRESS; ValueLocker locker; @@ -1331,7 +1291,7 @@ lldb::addr_t SBValue::GetLoadAddress() { } lldb::SBAddress SBValue::GetAddress() { - LLDB_RECORD_METHOD_NO_ARGS(lldb::SBAddress, SBValue, GetAddress); + LLDB_INSTRUMENT_VA(this); Address addr; ValueLocker locker; @@ -1356,12 +1316,11 @@ lldb::SBAddress SBValue::GetAddress() { } } - return LLDB_RECORD_RESULT(SBAddress(addr)); + return SBAddress(addr); } lldb::SBData SBValue::GetPointeeData(uint32_t item_idx, uint32_t item_count) { - LLDB_RECORD_METHOD(lldb::SBData, SBValue, GetPointeeData, - (uint32_t, uint32_t), item_idx, item_count); + LLDB_INSTRUMENT_VA(this, item_idx, item_count); lldb::SBData sb_data; ValueLocker locker; @@ -1376,11 +1335,11 @@ lldb::SBData SBValue::GetPointeeData(uint32_t item_idx, uint32_t item_count) { } } - return LLDB_RECORD_RESULT(sb_data); + return sb_data; } lldb::SBData SBValue::GetData() { - LLDB_RECORD_METHOD_NO_ARGS(lldb::SBData, SBValue, GetData); + LLDB_INSTRUMENT_VA(this); lldb::SBData sb_data; ValueLocker locker; @@ -1393,12 +1352,11 @@ lldb::SBData SBValue::GetData() { *sb_data = data_sp; } - return LLDB_RECORD_RESULT(sb_data); + return sb_data; } bool SBValue::SetData(lldb::SBData &data, SBError &error) { - LLDB_RECORD_METHOD(bool, SBValue, SetData, (lldb::SBData &, lldb::SBError &), - data, error); + LLDB_INSTRUMENT_VA(this, data, error); ValueLocker locker; lldb::ValueObjectSP value_sp(GetSP(locker)); @@ -1432,7 +1390,7 @@ bool SBValue::SetData(lldb::SBData &data, SBError &error) { } lldb::SBValue SBValue::Clone(const char *new_name) { - LLDB_RECORD_METHOD(lldb::SBValue, SBValue, Clone, (const char *), new_name); + LLDB_INSTRUMENT_VA(this, new_name); ValueLocker locker; lldb::ValueObjectSP value_sp(GetSP(locker)); @@ -1444,7 +1402,7 @@ lldb::SBValue SBValue::Clone(const char *new_name) { } lldb::SBDeclaration SBValue::GetDeclaration() { - LLDB_RECORD_METHOD_NO_ARGS(lldb::SBDeclaration, SBValue, GetDeclaration); + LLDB_INSTRUMENT_VA(this); ValueLocker locker; lldb::ValueObjectSP value_sp(GetSP(locker)); @@ -1454,14 +1412,12 @@ lldb::SBDeclaration SBValue::GetDeclaration() { if (value_sp->GetDeclaration(decl)) decl_sb.SetDeclaration(decl); } - return LLDB_RECORD_RESULT(decl_sb); + return decl_sb; } lldb::SBWatchpoint SBValue::Watch(bool resolve_location, bool read, bool write, SBError &error) { - LLDB_RECORD_METHOD(lldb::SBWatchpoint, SBValue, Watch, - (bool, bool, bool, lldb::SBError &), resolve_location, - read, write, error); + LLDB_INSTRUMENT_VA(this, resolve_location, read, write, error); SBWatchpoint sb_watchpoint; @@ -1472,18 +1428,18 @@ lldb::SBWatchpoint SBValue::Watch(bool resolve_location, bool read, bool write, if (value_sp && target_sp) { // Read and Write cannot both be false. if (!read && !write) - return LLDB_RECORD_RESULT(sb_watchpoint); + return sb_watchpoint; // If the value is not in scope, don't try and watch and invalid value if (!IsInScope()) - return LLDB_RECORD_RESULT(sb_watchpoint); + return sb_watchpoint; addr_t addr = GetLoadAddress(); if (addr == LLDB_INVALID_ADDRESS) - return LLDB_RECORD_RESULT(sb_watchpoint); + return sb_watchpoint; size_t byte_size = GetByteSize(); if (byte_size == 0) - return LLDB_RECORD_RESULT(sb_watchpoint); + return sb_watchpoint; uint32_t watch_type = 0; if (read) @@ -1516,7 +1472,7 @@ lldb::SBWatchpoint SBValue::Watch(bool resolve_location, bool read, bool write, error.SetErrorString("could not set watchpoint, a target is required"); } - return LLDB_RECORD_RESULT(sb_watchpoint); + return sb_watchpoint; } // FIXME: Remove this method impl (as well as the decl in .h) once it is no @@ -1524,27 +1480,24 @@ lldb::SBWatchpoint SBValue::Watch(bool resolve_location, bool read, bool write, // Backward compatibility fix in the interim. lldb::SBWatchpoint SBValue::Watch(bool resolve_location, bool read, bool write) { - LLDB_RECORD_METHOD(lldb::SBWatchpoint, SBValue, Watch, (bool, bool, bool), - resolve_location, read, write); + LLDB_INSTRUMENT_VA(this, resolve_location, read, write); SBError error; - return LLDB_RECORD_RESULT(Watch(resolve_location, read, write, error)); + return Watch(resolve_location, read, write, error); } lldb::SBWatchpoint SBValue::WatchPointee(bool resolve_location, bool read, bool write, SBError &error) { - LLDB_RECORD_METHOD(lldb::SBWatchpoint, SBValue, WatchPointee, - (bool, bool, bool, lldb::SBError &), resolve_location, - read, write, error); + LLDB_INSTRUMENT_VA(this, resolve_location, read, write, error); SBWatchpoint sb_watchpoint; if (IsInScope() && GetType().IsPointerType()) sb_watchpoint = Dereference().Watch(resolve_location, read, write, error); - return LLDB_RECORD_RESULT(sb_watchpoint); + return sb_watchpoint; } lldb::SBValue SBValue::Persist() { - LLDB_RECORD_METHOD_NO_ARGS(lldb::SBValue, SBValue, Persist); + LLDB_INSTRUMENT_VA(this); ValueLocker locker; lldb::ValueObjectSP value_sp(GetSP(locker)); @@ -1552,132 +1505,5 @@ lldb::SBValue SBValue::Persist() { if (value_sp) { persisted_sb.SetSP(value_sp->Persist()); } - return LLDB_RECORD_RESULT(persisted_sb); -} - -namespace lldb_private { -namespace repro { - -template <> -void RegisterMethods<SBValue>(Registry &R) { - LLDB_REGISTER_CONSTRUCTOR(SBValue, ()); - LLDB_REGISTER_CONSTRUCTOR(SBValue, (const lldb::ValueObjectSP &)); - LLDB_REGISTER_CONSTRUCTOR(SBValue, (const lldb::SBValue &)); - LLDB_REGISTER_METHOD(lldb::SBValue &, - SBValue, operator=,(const lldb::SBValue &)); - LLDB_REGISTER_METHOD(bool, SBValue, IsValid, ()); - LLDB_REGISTER_METHOD_CONST(bool, SBValue, operator bool, ()); - LLDB_REGISTER_METHOD(void, SBValue, Clear, ()); - LLDB_REGISTER_METHOD(lldb::SBError, SBValue, GetError, ()); - LLDB_REGISTER_METHOD(lldb::user_id_t, SBValue, GetID, ()); - LLDB_REGISTER_METHOD(const char *, SBValue, GetName, ()); - LLDB_REGISTER_METHOD(const char *, SBValue, GetTypeName, ()); - LLDB_REGISTER_METHOD(const char *, SBValue, GetDisplayTypeName, ()); - LLDB_REGISTER_METHOD(size_t, SBValue, GetByteSize, ()); - LLDB_REGISTER_METHOD(bool, SBValue, IsInScope, ()); - LLDB_REGISTER_METHOD(const char *, SBValue, GetValue, ()); - LLDB_REGISTER_METHOD(lldb::ValueType, SBValue, GetValueType, ()); - LLDB_REGISTER_METHOD(const char *, SBValue, GetObjectDescription, ()); - LLDB_REGISTER_METHOD(lldb::SBType, SBValue, GetType, ()); - LLDB_REGISTER_METHOD(bool, SBValue, GetValueDidChange, ()); - LLDB_REGISTER_METHOD(const char *, SBValue, GetSummary, ()); - LLDB_REGISTER_METHOD(const char *, SBValue, GetSummary, - (lldb::SBStream &, lldb::SBTypeSummaryOptions &)); - LLDB_REGISTER_METHOD(const char *, SBValue, GetLocation, ()); - LLDB_REGISTER_METHOD(bool, SBValue, SetValueFromCString, (const char *)); - LLDB_REGISTER_METHOD(bool, SBValue, SetValueFromCString, - (const char *, lldb::SBError &)); - LLDB_REGISTER_METHOD(lldb::SBTypeFormat, SBValue, GetTypeFormat, ()); - LLDB_REGISTER_METHOD(lldb::SBTypeSummary, SBValue, GetTypeSummary, ()); - LLDB_REGISTER_METHOD(lldb::SBTypeFilter, SBValue, GetTypeFilter, ()); - LLDB_REGISTER_METHOD(lldb::SBTypeSynthetic, SBValue, GetTypeSynthetic, ()); - LLDB_REGISTER_METHOD(lldb::SBValue, SBValue, CreateChildAtOffset, - (const char *, uint32_t, lldb::SBType)); - LLDB_REGISTER_METHOD(lldb::SBValue, SBValue, Cast, (lldb::SBType)); - LLDB_REGISTER_METHOD(lldb::SBValue, SBValue, CreateValueFromExpression, - (const char *, const char *)); - LLDB_REGISTER_METHOD( - lldb::SBValue, SBValue, CreateValueFromExpression, - (const char *, const char *, lldb::SBExpressionOptions &)); - LLDB_REGISTER_METHOD(lldb::SBValue, SBValue, CreateValueFromAddress, - (const char *, lldb::addr_t, lldb::SBType)); - LLDB_REGISTER_METHOD(lldb::SBValue, SBValue, CreateValueFromData, - (const char *, lldb::SBData, lldb::SBType)); - LLDB_REGISTER_METHOD(lldb::SBValue, SBValue, GetChildAtIndex, (uint32_t)); - LLDB_REGISTER_METHOD(lldb::SBValue, SBValue, GetChildAtIndex, - (uint32_t, lldb::DynamicValueType, bool)); - LLDB_REGISTER_METHOD(uint32_t, SBValue, GetIndexOfChildWithName, - (const char *)); - LLDB_REGISTER_METHOD(lldb::SBValue, SBValue, GetChildMemberWithName, - (const char *)); - LLDB_REGISTER_METHOD(lldb::SBValue, SBValue, GetChildMemberWithName, - (const char *, lldb::DynamicValueType)); - LLDB_REGISTER_METHOD(lldb::SBValue, SBValue, GetDynamicValue, - (lldb::DynamicValueType)); - LLDB_REGISTER_METHOD(lldb::SBValue, SBValue, GetStaticValue, ()); - LLDB_REGISTER_METHOD(lldb::SBValue, SBValue, GetNonSyntheticValue, ()); - LLDB_REGISTER_METHOD(lldb::DynamicValueType, SBValue, GetPreferDynamicValue, - ()); - LLDB_REGISTER_METHOD(void, SBValue, SetPreferDynamicValue, - (lldb::DynamicValueType)); - LLDB_REGISTER_METHOD(bool, SBValue, GetPreferSyntheticValue, ()); - LLDB_REGISTER_METHOD(void, SBValue, SetPreferSyntheticValue, (bool)); - LLDB_REGISTER_METHOD(bool, SBValue, IsDynamic, ()); - LLDB_REGISTER_METHOD(bool, SBValue, IsSynthetic, ()); - LLDB_REGISTER_METHOD(bool, SBValue, IsSyntheticChildrenGenerated, ()); - LLDB_REGISTER_METHOD(void, SBValue, SetSyntheticChildrenGenerated, (bool)); - LLDB_REGISTER_METHOD(lldb::SBValue, SBValue, GetValueForExpressionPath, - (const char *)); - LLDB_REGISTER_METHOD(int64_t, SBValue, GetValueAsSigned, - (lldb::SBError &, int64_t)); - LLDB_REGISTER_METHOD(uint64_t, SBValue, GetValueAsUnsigned, - (lldb::SBError &, uint64_t)); - LLDB_REGISTER_METHOD(int64_t, SBValue, GetValueAsSigned, (int64_t)); - LLDB_REGISTER_METHOD(uint64_t, SBValue, GetValueAsUnsigned, (uint64_t)); - LLDB_REGISTER_METHOD(bool, SBValue, MightHaveChildren, ()); - LLDB_REGISTER_METHOD(bool, SBValue, IsRuntimeSupportValue, ()); - LLDB_REGISTER_METHOD(uint32_t, SBValue, GetNumChildren, ()); - LLDB_REGISTER_METHOD(uint32_t, SBValue, GetNumChildren, (uint32_t)); - LLDB_REGISTER_METHOD(lldb::SBValue, SBValue, Dereference, ()); - LLDB_REGISTER_METHOD(bool, SBValue, TypeIsPointerType, ()); - LLDB_REGISTER_METHOD(void *, SBValue, GetOpaqueType, ()); - LLDB_REGISTER_METHOD(lldb::SBTarget, SBValue, GetTarget, ()); - LLDB_REGISTER_METHOD(lldb::SBProcess, SBValue, GetProcess, ()); - LLDB_REGISTER_METHOD(lldb::SBThread, SBValue, GetThread, ()); - LLDB_REGISTER_METHOD(lldb::SBFrame, SBValue, GetFrame, ()); - LLDB_REGISTER_METHOD_CONST(lldb::ValueObjectSP, SBValue, GetSP, ()); - LLDB_REGISTER_METHOD(bool, SBValue, GetExpressionPath, (lldb::SBStream &)); - LLDB_REGISTER_METHOD(bool, SBValue, GetExpressionPath, - (lldb::SBStream &, bool)); - LLDB_REGISTER_METHOD_CONST(lldb::SBValue, SBValue, EvaluateExpression, - (const char *)); - LLDB_REGISTER_METHOD_CONST( - lldb::SBValue, SBValue, EvaluateExpression, - (const char *, const lldb::SBExpressionOptions &)); - LLDB_REGISTER_METHOD_CONST( - lldb::SBValue, SBValue, EvaluateExpression, - (const char *, const lldb::SBExpressionOptions &, const char *)); - LLDB_REGISTER_METHOD(bool, SBValue, GetDescription, (lldb::SBStream &)); - LLDB_REGISTER_METHOD(lldb::Format, SBValue, GetFormat, ()); - LLDB_REGISTER_METHOD(void, SBValue, SetFormat, (lldb::Format)); - LLDB_REGISTER_METHOD(lldb::SBValue, SBValue, AddressOf, ()); - LLDB_REGISTER_METHOD(lldb::addr_t, SBValue, GetLoadAddress, ()); - LLDB_REGISTER_METHOD(lldb::SBAddress, SBValue, GetAddress, ()); - LLDB_REGISTER_METHOD(lldb::SBData, SBValue, GetPointeeData, - (uint32_t, uint32_t)); - LLDB_REGISTER_METHOD(lldb::SBData, SBValue, GetData, ()); - LLDB_REGISTER_METHOD(bool, SBValue, SetData, - (lldb::SBData &, lldb::SBError &)); - LLDB_REGISTER_METHOD(lldb::SBValue, SBValue, Clone, (const char *)); - LLDB_REGISTER_METHOD(lldb::SBDeclaration, SBValue, GetDeclaration, ()); - LLDB_REGISTER_METHOD(lldb::SBWatchpoint, SBValue, Watch, - (bool, bool, bool, lldb::SBError &)); - LLDB_REGISTER_METHOD(lldb::SBWatchpoint, SBValue, Watch, - (bool, bool, bool)); - LLDB_REGISTER_METHOD(lldb::SBWatchpoint, SBValue, WatchPointee, - (bool, bool, bool, lldb::SBError &)); - LLDB_REGISTER_METHOD(lldb::SBValue, SBValue, Persist, ()); -} - -} + return persisted_sb; } diff --git a/lldb/source/API/SBValueList.cpp b/lldb/source/API/SBValueList.cpp index 0fd2a591c321..a67030c506f4 100644 --- a/lldb/source/API/SBValueList.cpp +++ b/lldb/source/API/SBValueList.cpp @@ -7,10 +7,10 @@ //===----------------------------------------------------------------------===// #include "lldb/API/SBValueList.h" -#include "SBReproducerPrivate.h" #include "lldb/API/SBStream.h" #include "lldb/API/SBValue.h" #include "lldb/Core/ValueObjectList.h" +#include "lldb/Utility/Instrumentation.h" #include <vector> @@ -19,7 +19,7 @@ using namespace lldb_private; class ValueListImpl { public: - ValueListImpl() : m_values() {} + ValueListImpl() {} ValueListImpl(const ValueListImpl &rhs) : m_values(rhs.m_values) {} @@ -67,18 +67,16 @@ private: std::vector<lldb::SBValue> m_values; }; -SBValueList::SBValueList() : m_opaque_up() { - LLDB_RECORD_CONSTRUCTOR_NO_ARGS(SBValueList); -} +SBValueList::SBValueList() { LLDB_INSTRUMENT_VA(this); } -SBValueList::SBValueList(const SBValueList &rhs) : m_opaque_up() { - LLDB_RECORD_CONSTRUCTOR(SBValueList, (const lldb::SBValueList &), rhs); +SBValueList::SBValueList(const SBValueList &rhs) { + LLDB_INSTRUMENT_VA(this, rhs); if (rhs.IsValid()) m_opaque_up = std::make_unique<ValueListImpl>(*rhs); } -SBValueList::SBValueList(const ValueListImpl *lldb_object_ptr) : m_opaque_up() { +SBValueList::SBValueList(const ValueListImpl *lldb_object_ptr) { if (lldb_object_ptr) m_opaque_up = std::make_unique<ValueListImpl>(*lldb_object_ptr); } @@ -86,24 +84,23 @@ SBValueList::SBValueList(const ValueListImpl *lldb_object_ptr) : m_opaque_up() { SBValueList::~SBValueList() = default; bool SBValueList::IsValid() const { - LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBValueList, IsValid); + LLDB_INSTRUMENT_VA(this); return this->operator bool(); } SBValueList::operator bool() const { - LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBValueList, operator bool); + LLDB_INSTRUMENT_VA(this); return (m_opaque_up != nullptr); } void SBValueList::Clear() { - LLDB_RECORD_METHOD_NO_ARGS(void, SBValueList, Clear); + LLDB_INSTRUMENT_VA(this); m_opaque_up.reset(); } const SBValueList &SBValueList::operator=(const SBValueList &rhs) { - LLDB_RECORD_METHOD(const lldb::SBValueList &, - SBValueList, operator=,(const lldb::SBValueList &), rhs); + LLDB_INSTRUMENT_VA(this, rhs); if (this != &rhs) { if (rhs.IsValid()) @@ -111,7 +108,7 @@ const SBValueList &SBValueList::operator=(const SBValueList &rhs) { else m_opaque_up.reset(); } - return LLDB_RECORD_RESULT(*this); + return *this; } ValueListImpl *SBValueList::operator->() { return m_opaque_up.get(); } @@ -125,8 +122,7 @@ const ValueListImpl *SBValueList::operator->() const { const ValueListImpl &SBValueList::operator*() const { return *m_opaque_up; } void SBValueList::Append(const SBValue &val_obj) { - LLDB_RECORD_METHOD(void, SBValueList, Append, (const lldb::SBValue &), - val_obj); + LLDB_INSTRUMENT_VA(this, val_obj); CreateIfNeeded(); m_opaque_up->Append(val_obj); @@ -140,8 +136,7 @@ void SBValueList::Append(lldb::ValueObjectSP &val_obj_sp) { } void SBValueList::Append(const lldb::SBValueList &value_list) { - LLDB_RECORD_METHOD(void, SBValueList, Append, (const lldb::SBValueList &), - value_list); + LLDB_INSTRUMENT_VA(this, value_list); if (value_list.IsValid()) { CreateIfNeeded(); @@ -150,19 +145,17 @@ void SBValueList::Append(const lldb::SBValueList &value_list) { } SBValue SBValueList::GetValueAtIndex(uint32_t idx) const { - LLDB_RECORD_METHOD_CONST(lldb::SBValue, SBValueList, GetValueAtIndex, - (uint32_t), idx); - + LLDB_INSTRUMENT_VA(this, idx); SBValue sb_value; if (m_opaque_up) sb_value = m_opaque_up->GetValueAtIndex(idx); - return LLDB_RECORD_RESULT(sb_value); + return sb_value; } uint32_t SBValueList::GetSize() const { - LLDB_RECORD_METHOD_CONST_NO_ARGS(uint32_t, SBValueList, GetSize); + LLDB_INSTRUMENT_VA(this); uint32_t size = 0; if (m_opaque_up) @@ -177,23 +170,21 @@ void SBValueList::CreateIfNeeded() { } SBValue SBValueList::FindValueObjectByUID(lldb::user_id_t uid) { - LLDB_RECORD_METHOD(lldb::SBValue, SBValueList, FindValueObjectByUID, - (lldb::user_id_t), uid); + LLDB_INSTRUMENT_VA(this, uid); SBValue sb_value; if (m_opaque_up) sb_value = m_opaque_up->FindValueByUID(uid); - return LLDB_RECORD_RESULT(sb_value); + return sb_value; } SBValue SBValueList::GetFirstValueByName(const char *name) const { - LLDB_RECORD_METHOD_CONST(lldb::SBValue, SBValueList, GetFirstValueByName, - (const char *), name); + LLDB_INSTRUMENT_VA(this, name); SBValue sb_value; if (m_opaque_up) sb_value = m_opaque_up->GetFirstValueByName(name); - return LLDB_RECORD_RESULT(sb_value); + return sb_value; } void *SBValueList::opaque_ptr() { return m_opaque_up.get(); } @@ -202,30 +193,3 @@ ValueListImpl &SBValueList::ref() { CreateIfNeeded(); return *m_opaque_up; } - -namespace lldb_private { -namespace repro { - -template <> -void RegisterMethods<SBValueList>(Registry &R) { - LLDB_REGISTER_CONSTRUCTOR(SBValueList, ()); - LLDB_REGISTER_CONSTRUCTOR(SBValueList, (const lldb::SBValueList &)); - LLDB_REGISTER_METHOD_CONST(bool, SBValueList, IsValid, ()); - LLDB_REGISTER_METHOD_CONST(bool, SBValueList, operator bool, ()); - LLDB_REGISTER_METHOD(void, SBValueList, Clear, ()); - LLDB_REGISTER_METHOD(const lldb::SBValueList &, - SBValueList, operator=,(const lldb::SBValueList &)); - LLDB_REGISTER_METHOD(void, SBValueList, Append, (const lldb::SBValue &)); - LLDB_REGISTER_METHOD(void, SBValueList, Append, - (const lldb::SBValueList &)); - LLDB_REGISTER_METHOD_CONST(lldb::SBValue, SBValueList, GetValueAtIndex, - (uint32_t)); - LLDB_REGISTER_METHOD_CONST(uint32_t, SBValueList, GetSize, ()); - LLDB_REGISTER_METHOD(lldb::SBValue, SBValueList, FindValueObjectByUID, - (lldb::user_id_t)); - LLDB_REGISTER_METHOD_CONST(lldb::SBValue, SBValueList, GetFirstValueByName, - (const char *)); -} - -} -} diff --git a/lldb/source/API/SBVariablesOptions.cpp b/lldb/source/API/SBVariablesOptions.cpp index 1af582a0c3d7..989d159139cc 100644 --- a/lldb/source/API/SBVariablesOptions.cpp +++ b/lldb/source/API/SBVariablesOptions.cpp @@ -7,9 +7,9 @@ //===----------------------------------------------------------------------===// #include "lldb/API/SBVariablesOptions.h" -#include "SBReproducerPrivate.h" #include "lldb/API/SBTarget.h" #include "lldb/Target/Target.h" +#include "lldb/Utility/Instrumentation.h" #include "lldb/lldb-private.h" @@ -80,132 +80,116 @@ private: SBVariablesOptions::SBVariablesOptions() : m_opaque_up(new VariablesOptionsImpl()) { - LLDB_RECORD_CONSTRUCTOR_NO_ARGS(SBVariablesOptions); + LLDB_INSTRUMENT_VA(this); } SBVariablesOptions::SBVariablesOptions(const SBVariablesOptions &options) : m_opaque_up(new VariablesOptionsImpl(options.ref())) { - LLDB_RECORD_CONSTRUCTOR(SBVariablesOptions, - (const lldb::SBVariablesOptions &), options); + LLDB_INSTRUMENT_VA(this, options); } SBVariablesOptions &SBVariablesOptions:: operator=(const SBVariablesOptions &options) { - LLDB_RECORD_METHOD( - lldb::SBVariablesOptions &, - SBVariablesOptions, operator=,(const lldb::SBVariablesOptions &), - options); + LLDB_INSTRUMENT_VA(this, options); m_opaque_up = std::make_unique<VariablesOptionsImpl>(options.ref()); - return LLDB_RECORD_RESULT(*this); + return *this; } SBVariablesOptions::~SBVariablesOptions() = default; bool SBVariablesOptions::IsValid() const { - LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBVariablesOptions, IsValid); + LLDB_INSTRUMENT_VA(this); return this->operator bool(); } SBVariablesOptions::operator bool() const { - LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBVariablesOptions, operator bool); + LLDB_INSTRUMENT_VA(this); return m_opaque_up != nullptr; } bool SBVariablesOptions::GetIncludeArguments() const { - LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBVariablesOptions, - GetIncludeArguments); + LLDB_INSTRUMENT_VA(this); return m_opaque_up->GetIncludeArguments(); } void SBVariablesOptions::SetIncludeArguments(bool arguments) { - LLDB_RECORD_METHOD(void, SBVariablesOptions, SetIncludeArguments, (bool), - arguments); + LLDB_INSTRUMENT_VA(this, arguments); m_opaque_up->SetIncludeArguments(arguments); } bool SBVariablesOptions::GetIncludeRecognizedArguments( const lldb::SBTarget &target) const { - LLDB_RECORD_METHOD_CONST(bool, SBVariablesOptions, - GetIncludeRecognizedArguments, - (const lldb::SBTarget &), target); + LLDB_INSTRUMENT_VA(this, target); return m_opaque_up->GetIncludeRecognizedArguments(target.GetSP()); } void SBVariablesOptions::SetIncludeRecognizedArguments(bool arguments) { - LLDB_RECORD_METHOD(void, SBVariablesOptions, SetIncludeRecognizedArguments, - (bool), arguments); + LLDB_INSTRUMENT_VA(this, arguments); m_opaque_up->SetIncludeRecognizedArguments(arguments); } bool SBVariablesOptions::GetIncludeLocals() const { - LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBVariablesOptions, GetIncludeLocals); + LLDB_INSTRUMENT_VA(this); return m_opaque_up->GetIncludeLocals(); } void SBVariablesOptions::SetIncludeLocals(bool locals) { - LLDB_RECORD_METHOD(void, SBVariablesOptions, SetIncludeLocals, (bool), - locals); + LLDB_INSTRUMENT_VA(this, locals); m_opaque_up->SetIncludeLocals(locals); } bool SBVariablesOptions::GetIncludeStatics() const { - LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBVariablesOptions, GetIncludeStatics); + LLDB_INSTRUMENT_VA(this); return m_opaque_up->GetIncludeStatics(); } void SBVariablesOptions::SetIncludeStatics(bool statics) { - LLDB_RECORD_METHOD(void, SBVariablesOptions, SetIncludeStatics, (bool), - statics); + LLDB_INSTRUMENT_VA(this, statics); m_opaque_up->SetIncludeStatics(statics); } bool SBVariablesOptions::GetInScopeOnly() const { - LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBVariablesOptions, GetInScopeOnly); + LLDB_INSTRUMENT_VA(this); return m_opaque_up->GetInScopeOnly(); } void SBVariablesOptions::SetInScopeOnly(bool in_scope_only) { - LLDB_RECORD_METHOD(void, SBVariablesOptions, SetInScopeOnly, (bool), - in_scope_only); + LLDB_INSTRUMENT_VA(this, in_scope_only); m_opaque_up->SetInScopeOnly(in_scope_only); } bool SBVariablesOptions::GetIncludeRuntimeSupportValues() const { - LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBVariablesOptions, - GetIncludeRuntimeSupportValues); + LLDB_INSTRUMENT_VA(this); return m_opaque_up->GetIncludeRuntimeSupportValues(); } void SBVariablesOptions::SetIncludeRuntimeSupportValues( bool runtime_support_values) { - LLDB_RECORD_METHOD(void, SBVariablesOptions, SetIncludeRuntimeSupportValues, - (bool), runtime_support_values); + LLDB_INSTRUMENT_VA(this, runtime_support_values); m_opaque_up->SetIncludeRuntimeSupportValues(runtime_support_values); } lldb::DynamicValueType SBVariablesOptions::GetUseDynamic() const { - LLDB_RECORD_METHOD_CONST_NO_ARGS(lldb::DynamicValueType, SBVariablesOptions, - GetUseDynamic); + LLDB_INSTRUMENT_VA(this); return m_opaque_up->GetUseDynamic(); } void SBVariablesOptions::SetUseDynamic(lldb::DynamicValueType dynamic) { - LLDB_RECORD_METHOD(void, SBVariablesOptions, SetUseDynamic, - (lldb::DynamicValueType), dynamic); + LLDB_INSTRUMENT_VA(this, dynamic); m_opaque_up->SetUseDynamic(dynamic); } @@ -232,43 +216,3 @@ SBVariablesOptions::SBVariablesOptions(VariablesOptionsImpl *lldb_object_ptr) void SBVariablesOptions::SetOptions(VariablesOptionsImpl *lldb_object_ptr) { m_opaque_up.reset(std::move(lldb_object_ptr)); } - -namespace lldb_private { -namespace repro { - -template <> -void RegisterMethods<SBVariablesOptions>(Registry &R) { - LLDB_REGISTER_CONSTRUCTOR(SBVariablesOptions, ()); - LLDB_REGISTER_CONSTRUCTOR(SBVariablesOptions, - (const lldb::SBVariablesOptions &)); - LLDB_REGISTER_METHOD( - lldb::SBVariablesOptions &, - SBVariablesOptions, operator=,(const lldb::SBVariablesOptions &)); - LLDB_REGISTER_METHOD_CONST(bool, SBVariablesOptions, IsValid, ()); - LLDB_REGISTER_METHOD_CONST(bool, SBVariablesOptions, operator bool, ()); - LLDB_REGISTER_METHOD_CONST(bool, SBVariablesOptions, GetIncludeArguments, - ()); - LLDB_REGISTER_METHOD(void, SBVariablesOptions, SetIncludeArguments, (bool)); - LLDB_REGISTER_METHOD_CONST(bool, SBVariablesOptions, - GetIncludeRecognizedArguments, - (const lldb::SBTarget &)); - LLDB_REGISTER_METHOD(void, SBVariablesOptions, - SetIncludeRecognizedArguments, (bool)); - LLDB_REGISTER_METHOD_CONST(bool, SBVariablesOptions, GetIncludeLocals, ()); - LLDB_REGISTER_METHOD(void, SBVariablesOptions, SetIncludeLocals, (bool)); - LLDB_REGISTER_METHOD_CONST(bool, SBVariablesOptions, GetIncludeStatics, ()); - LLDB_REGISTER_METHOD(void, SBVariablesOptions, SetIncludeStatics, (bool)); - LLDB_REGISTER_METHOD_CONST(bool, SBVariablesOptions, GetInScopeOnly, ()); - LLDB_REGISTER_METHOD(void, SBVariablesOptions, SetInScopeOnly, (bool)); - LLDB_REGISTER_METHOD_CONST(bool, SBVariablesOptions, - GetIncludeRuntimeSupportValues, ()); - LLDB_REGISTER_METHOD(void, SBVariablesOptions, - SetIncludeRuntimeSupportValues, (bool)); - LLDB_REGISTER_METHOD_CONST(lldb::DynamicValueType, SBVariablesOptions, - GetUseDynamic, ()); - LLDB_REGISTER_METHOD(void, SBVariablesOptions, SetUseDynamic, - (lldb::DynamicValueType)); -} - -} -} diff --git a/lldb/source/API/SBWatchpoint.cpp b/lldb/source/API/SBWatchpoint.cpp index eba75dea8f8d..f5bd9cd1a946 100644 --- a/lldb/source/API/SBWatchpoint.cpp +++ b/lldb/source/API/SBWatchpoint.cpp @@ -7,12 +7,12 @@ //===----------------------------------------------------------------------===// #include "lldb/API/SBWatchpoint.h" -#include "SBReproducerPrivate.h" #include "lldb/API/SBAddress.h" #include "lldb/API/SBDebugger.h" #include "lldb/API/SBDefines.h" #include "lldb/API/SBEvent.h" #include "lldb/API/SBStream.h" +#include "lldb/Utility/Instrumentation.h" #include "lldb/Breakpoint/Watchpoint.h" #include "lldb/Breakpoint/WatchpointList.h" @@ -26,31 +26,29 @@ using namespace lldb; using namespace lldb_private; -SBWatchpoint::SBWatchpoint() { LLDB_RECORD_CONSTRUCTOR_NO_ARGS(SBWatchpoint); } +SBWatchpoint::SBWatchpoint() { LLDB_INSTRUMENT_VA(this); } SBWatchpoint::SBWatchpoint(const lldb::WatchpointSP &wp_sp) : m_opaque_wp(wp_sp) { - LLDB_RECORD_CONSTRUCTOR(SBWatchpoint, (const lldb::WatchpointSP &), wp_sp); + LLDB_INSTRUMENT_VA(this, wp_sp); } SBWatchpoint::SBWatchpoint(const SBWatchpoint &rhs) : m_opaque_wp(rhs.m_opaque_wp) { - LLDB_RECORD_CONSTRUCTOR(SBWatchpoint, (const lldb::SBWatchpoint &), rhs); + LLDB_INSTRUMENT_VA(this, rhs); } const SBWatchpoint &SBWatchpoint::operator=(const SBWatchpoint &rhs) { - LLDB_RECORD_METHOD(const lldb::SBWatchpoint &, - SBWatchpoint, operator=,(const lldb::SBWatchpoint &), rhs); + LLDB_INSTRUMENT_VA(this, rhs); m_opaque_wp = rhs.m_opaque_wp; - return LLDB_RECORD_RESULT(*this); + return *this; } SBWatchpoint::~SBWatchpoint() = default; watch_id_t SBWatchpoint::GetID() { - LLDB_RECORD_METHOD_NO_ARGS(lldb::watch_id_t, SBWatchpoint, GetID); - + LLDB_INSTRUMENT_VA(this); watch_id_t watch_id = LLDB_INVALID_WATCH_ID; lldb::WatchpointSP watchpoint_sp(GetSP()); @@ -61,42 +59,40 @@ watch_id_t SBWatchpoint::GetID() { } bool SBWatchpoint::IsValid() const { - LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBWatchpoint, IsValid); + LLDB_INSTRUMENT_VA(this); return this->operator bool(); } SBWatchpoint::operator bool() const { - LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBWatchpoint, operator bool); + LLDB_INSTRUMENT_VA(this); return bool(m_opaque_wp.lock()); } bool SBWatchpoint::operator==(const SBWatchpoint &rhs) const { - LLDB_RECORD_METHOD_CONST( - bool, SBWatchpoint, operator==,(const SBWatchpoint &), rhs); + LLDB_INSTRUMENT_VA(this, rhs); return GetSP() == rhs.GetSP(); } bool SBWatchpoint::operator!=(const SBWatchpoint &rhs) const { - LLDB_RECORD_METHOD_CONST( - bool, SBWatchpoint, operator!=,(const SBWatchpoint &), rhs); + LLDB_INSTRUMENT_VA(this, rhs); return !(*this == rhs); } SBError SBWatchpoint::GetError() { - LLDB_RECORD_METHOD_NO_ARGS(lldb::SBError, SBWatchpoint, GetError); + LLDB_INSTRUMENT_VA(this); SBError sb_error; lldb::WatchpointSP watchpoint_sp(GetSP()); if (watchpoint_sp) { sb_error.SetError(watchpoint_sp->GetError()); } - return LLDB_RECORD_RESULT(sb_error); + return sb_error; } int32_t SBWatchpoint::GetHardwareIndex() { - LLDB_RECORD_METHOD_NO_ARGS(int32_t, SBWatchpoint, GetHardwareIndex); + LLDB_INSTRUMENT_VA(this); int32_t hw_index = -1; @@ -111,7 +107,7 @@ int32_t SBWatchpoint::GetHardwareIndex() { } addr_t SBWatchpoint::GetWatchAddress() { - LLDB_RECORD_METHOD_NO_ARGS(lldb::addr_t, SBWatchpoint, GetWatchAddress); + LLDB_INSTRUMENT_VA(this); addr_t ret_addr = LLDB_INVALID_ADDRESS; @@ -126,7 +122,7 @@ addr_t SBWatchpoint::GetWatchAddress() { } size_t SBWatchpoint::GetWatchSize() { - LLDB_RECORD_METHOD_NO_ARGS(size_t, SBWatchpoint, GetWatchSize); + LLDB_INSTRUMENT_VA(this); size_t watch_size = 0; @@ -141,7 +137,7 @@ size_t SBWatchpoint::GetWatchSize() { } void SBWatchpoint::SetEnabled(bool enabled) { - LLDB_RECORD_METHOD(void, SBWatchpoint, SetEnabled, (bool), enabled); + LLDB_INSTRUMENT_VA(this, enabled); lldb::WatchpointSP watchpoint_sp(GetSP()); if (watchpoint_sp) { @@ -161,7 +157,7 @@ void SBWatchpoint::SetEnabled(bool enabled) { } bool SBWatchpoint::IsEnabled() { - LLDB_RECORD_METHOD_NO_ARGS(bool, SBWatchpoint, IsEnabled); + LLDB_INSTRUMENT_VA(this); lldb::WatchpointSP watchpoint_sp(GetSP()); if (watchpoint_sp) { @@ -173,7 +169,7 @@ bool SBWatchpoint::IsEnabled() { } uint32_t SBWatchpoint::GetHitCount() { - LLDB_RECORD_METHOD_NO_ARGS(uint32_t, SBWatchpoint, GetHitCount); + LLDB_INSTRUMENT_VA(this); uint32_t count = 0; lldb::WatchpointSP watchpoint_sp(GetSP()); @@ -187,7 +183,7 @@ uint32_t SBWatchpoint::GetHitCount() { } uint32_t SBWatchpoint::GetIgnoreCount() { - LLDB_RECORD_METHOD_NO_ARGS(uint32_t, SBWatchpoint, GetIgnoreCount); + LLDB_INSTRUMENT_VA(this); lldb::WatchpointSP watchpoint_sp(GetSP()); if (watchpoint_sp) { @@ -199,7 +195,7 @@ uint32_t SBWatchpoint::GetIgnoreCount() { } void SBWatchpoint::SetIgnoreCount(uint32_t n) { - LLDB_RECORD_METHOD(void, SBWatchpoint, SetIgnoreCount, (uint32_t), n); + LLDB_INSTRUMENT_VA(this, n); lldb::WatchpointSP watchpoint_sp(GetSP()); if (watchpoint_sp) { @@ -210,7 +206,7 @@ void SBWatchpoint::SetIgnoreCount(uint32_t n) { } const char *SBWatchpoint::GetCondition() { - LLDB_RECORD_METHOD_NO_ARGS(const char *, SBWatchpoint, GetCondition); + LLDB_INSTRUMENT_VA(this); lldb::WatchpointSP watchpoint_sp(GetSP()); if (watchpoint_sp) { @@ -222,8 +218,7 @@ const char *SBWatchpoint::GetCondition() { } void SBWatchpoint::SetCondition(const char *condition) { - LLDB_RECORD_METHOD(void, SBWatchpoint, SetCondition, (const char *), - condition); + LLDB_INSTRUMENT_VA(this, condition); lldb::WatchpointSP watchpoint_sp(GetSP()); if (watchpoint_sp) { @@ -235,9 +230,7 @@ void SBWatchpoint::SetCondition(const char *condition) { bool SBWatchpoint::GetDescription(SBStream &description, DescriptionLevel level) { - LLDB_RECORD_METHOD(bool, SBWatchpoint, GetDescription, - (lldb::SBStream &, lldb::DescriptionLevel), description, - level); + LLDB_INSTRUMENT_VA(this, description, level); Stream &strm = description.ref(); @@ -254,27 +247,25 @@ bool SBWatchpoint::GetDescription(SBStream &description, } void SBWatchpoint::Clear() { - LLDB_RECORD_METHOD_NO_ARGS(void, SBWatchpoint, Clear); + LLDB_INSTRUMENT_VA(this); m_opaque_wp.reset(); } lldb::WatchpointSP SBWatchpoint::GetSP() const { - LLDB_RECORD_METHOD_CONST_NO_ARGS(lldb::WatchpointSP, SBWatchpoint, GetSP); + LLDB_INSTRUMENT_VA(this); - return LLDB_RECORD_RESULT(m_opaque_wp.lock()); + return m_opaque_wp.lock(); } void SBWatchpoint::SetSP(const lldb::WatchpointSP &sp) { - LLDB_RECORD_METHOD(void, SBWatchpoint, SetSP, (const lldb::WatchpointSP &), - sp); + LLDB_INSTRUMENT_VA(this, sp); m_opaque_wp = sp; } bool SBWatchpoint::EventIsWatchpointEvent(const lldb::SBEvent &event) { - LLDB_RECORD_STATIC_METHOD(bool, SBWatchpoint, EventIsWatchpointEvent, - (const lldb::SBEvent &), event); + LLDB_INSTRUMENT_VA(event); return Watchpoint::WatchpointEventData::GetEventDataFromEvent(event.get()) != nullptr; @@ -282,9 +273,7 @@ bool SBWatchpoint::EventIsWatchpointEvent(const lldb::SBEvent &event) { WatchpointEventType SBWatchpoint::GetWatchpointEventTypeFromEvent(const SBEvent &event) { - LLDB_RECORD_STATIC_METHOD(lldb::WatchpointEventType, SBWatchpoint, - GetWatchpointEventTypeFromEvent, - (const lldb::SBEvent &), event); + LLDB_INSTRUMENT_VA(event); if (event.IsValid()) return Watchpoint::WatchpointEventData::GetWatchpointEventTypeFromEvent( @@ -293,60 +282,11 @@ SBWatchpoint::GetWatchpointEventTypeFromEvent(const SBEvent &event) { } SBWatchpoint SBWatchpoint::GetWatchpointFromEvent(const lldb::SBEvent &event) { - LLDB_RECORD_STATIC_METHOD(lldb::SBWatchpoint, SBWatchpoint, - GetWatchpointFromEvent, (const lldb::SBEvent &), - event); + LLDB_INSTRUMENT_VA(event); SBWatchpoint sb_watchpoint; if (event.IsValid()) sb_watchpoint = Watchpoint::WatchpointEventData::GetWatchpointFromEvent(event.GetSP()); - return LLDB_RECORD_RESULT(sb_watchpoint); -} - -namespace lldb_private { -namespace repro { - -template <> -void RegisterMethods<SBWatchpoint>(Registry &R) { - LLDB_REGISTER_CONSTRUCTOR(SBWatchpoint, ()); - LLDB_REGISTER_CONSTRUCTOR(SBWatchpoint, (const lldb::WatchpointSP &)); - LLDB_REGISTER_CONSTRUCTOR(SBWatchpoint, (const lldb::SBWatchpoint &)); - LLDB_REGISTER_METHOD(const lldb::SBWatchpoint &, - SBWatchpoint, operator=,(const lldb::SBWatchpoint &)); - LLDB_REGISTER_METHOD(lldb::watch_id_t, SBWatchpoint, GetID, ()); - LLDB_REGISTER_METHOD_CONST(bool, SBWatchpoint, IsValid, ()); - LLDB_REGISTER_METHOD_CONST(bool, SBWatchpoint, operator bool, ()); - LLDB_REGISTER_METHOD_CONST( - bool, SBWatchpoint, operator==,(const lldb::SBWatchpoint &)); - LLDB_REGISTER_METHOD_CONST( - bool, SBWatchpoint, operator!=,(const lldb::SBWatchpoint &)); - LLDB_REGISTER_METHOD(lldb::SBError, SBWatchpoint, GetError, ()); - LLDB_REGISTER_METHOD(int32_t, SBWatchpoint, GetHardwareIndex, ()); - LLDB_REGISTER_METHOD(lldb::addr_t, SBWatchpoint, GetWatchAddress, ()); - LLDB_REGISTER_METHOD(size_t, SBWatchpoint, GetWatchSize, ()); - LLDB_REGISTER_METHOD(void, SBWatchpoint, SetEnabled, (bool)); - LLDB_REGISTER_METHOD(bool, SBWatchpoint, IsEnabled, ()); - LLDB_REGISTER_METHOD(uint32_t, SBWatchpoint, GetHitCount, ()); - LLDB_REGISTER_METHOD(uint32_t, SBWatchpoint, GetIgnoreCount, ()); - LLDB_REGISTER_METHOD(void, SBWatchpoint, SetIgnoreCount, (uint32_t)); - LLDB_REGISTER_METHOD(const char *, SBWatchpoint, GetCondition, ()); - LLDB_REGISTER_METHOD(void, SBWatchpoint, SetCondition, (const char *)); - LLDB_REGISTER_METHOD(bool, SBWatchpoint, GetDescription, - (lldb::SBStream &, lldb::DescriptionLevel)); - LLDB_REGISTER_METHOD(void, SBWatchpoint, Clear, ()); - LLDB_REGISTER_METHOD_CONST(lldb::WatchpointSP, SBWatchpoint, GetSP, ()); - LLDB_REGISTER_METHOD(void, SBWatchpoint, SetSP, - (const lldb::WatchpointSP &)); - LLDB_REGISTER_STATIC_METHOD(bool, SBWatchpoint, EventIsWatchpointEvent, - (const lldb::SBEvent &)); - LLDB_REGISTER_STATIC_METHOD(lldb::WatchpointEventType, SBWatchpoint, - GetWatchpointEventTypeFromEvent, - (const lldb::SBEvent &)); - LLDB_REGISTER_STATIC_METHOD(lldb::SBWatchpoint, SBWatchpoint, - GetWatchpointFromEvent, - (const lldb::SBEvent &)); -} - -} + return sb_watchpoint; } diff --git a/lldb/source/API/SystemInitializerFull.cpp b/lldb/source/API/SystemInitializerFull.cpp index b01cb2ff545b..d662d370f813 100644 --- a/lldb/source/API/SystemInitializerFull.cpp +++ b/lldb/source/API/SystemInitializerFull.cpp @@ -39,7 +39,7 @@ constexpr lldb_private::HostInfo::SharedLibraryDirectoryHelper #else constexpr lldb_private::HostInfo::SharedLibraryDirectoryHelper - *g_shlib_dir_helper = 0; + *g_shlib_dir_helper = nullptr; #endif using namespace lldb_private; diff --git a/lldb/source/Breakpoint/Breakpoint.cpp b/lldb/source/Breakpoint/Breakpoint.cpp index d6acf659e852..eeb8eac33567 100644 --- a/lldb/source/Breakpoint/Breakpoint.cpp +++ b/lldb/source/Breakpoint/Breakpoint.cpp @@ -1094,7 +1094,7 @@ Breakpoint::BreakpointEventData::GetBreakpointLocationAtIndexFromEvent( json::Value Breakpoint::GetStatistics() { json::Object bp; bp.try_emplace("id", GetID()); - bp.try_emplace("resolveTime", m_resolve_time.count()); + bp.try_emplace("resolveTime", m_resolve_time.get().count()); bp.try_emplace("numLocations", (int64_t)GetNumLocations()); bp.try_emplace("numResolvedLocations", (int64_t)GetNumResolvedLocations()); bp.try_emplace("internal", IsInternal()); diff --git a/lldb/source/Breakpoint/BreakpointResolverFileRegex.cpp b/lldb/source/Breakpoint/BreakpointResolverFileRegex.cpp index 435983769c05..4a11d82ecc6e 100644 --- a/lldb/source/Breakpoint/BreakpointResolverFileRegex.cpp +++ b/lldb/source/Breakpoint/BreakpointResolverFileRegex.cpp @@ -110,7 +110,7 @@ Searcher::CallbackReturn BreakpointResolverFileRegex::SearchCallback( // TODO: Handle SourceLocationSpec column information SourceLocationSpec location_spec(cu_file_spec, line_matches[i], /*column=*/llvm::None, - /*search_inlines=*/false, m_exact_match); + /*check_inlines=*/false, m_exact_match); cu->ResolveSymbolContext(location_spec, eSymbolContextEverything, sc_list); // Find all the function names: if (!m_function_names.empty()) { diff --git a/lldb/source/Commands/CommandCompletions.cpp b/lldb/source/Commands/CommandCompletions.cpp index 42b0bac717bd..ae1ee1fdd30b 100644 --- a/lldb/source/Commands/CommandCompletions.cpp +++ b/lldb/source/Commands/CommandCompletions.cpp @@ -129,7 +129,7 @@ class SourceFileCompleter : public Completer { public: SourceFileCompleter(CommandInterpreter &interpreter, CompletionRequest &request) - : Completer(interpreter, request), m_matching_files() { + : Completer(interpreter, request) { FileSpec partial_spec(m_request.GetCursorArgumentPrefix()); m_file_name = partial_spec.GetFilename().GetCString(); m_dir_name = partial_spec.GetDirectory().GetCString(); @@ -600,7 +600,7 @@ void CommandCompletions::VariablePath(CommandInterpreter &interpreter, void CommandCompletions::Registers(CommandInterpreter &interpreter, CompletionRequest &request, SearchFilter *searcher) { - std::string reg_prefix = ""; + std::string reg_prefix; if (request.GetCursorArgumentPrefix().startswith("$")) reg_prefix = "$"; diff --git a/lldb/source/Commands/CommandObjectBreakpoint.cpp b/lldb/source/Commands/CommandObjectBreakpoint.cpp index 3f88a2fa6378..c4e55fdb3b9c 100644 --- a/lldb/source/Commands/CommandObjectBreakpoint.cpp +++ b/lldb/source/Commands/CommandObjectBreakpoint.cpp @@ -49,7 +49,7 @@ static void AddBreakpointDescription(Stream *s, Breakpoint *bp, class lldb_private::BreakpointOptionGroup : public OptionGroup { public: - BreakpointOptionGroup() : OptionGroup(), m_bp_opts(false) {} + BreakpointOptionGroup() : m_bp_opts(false) {} ~BreakpointOptionGroup() override = default; @@ -179,7 +179,7 @@ public: class BreakpointDummyOptionGroup : public OptionGroup { public: - BreakpointDummyOptionGroup() : OptionGroup() {} + BreakpointDummyOptionGroup() {} ~BreakpointDummyOptionGroup() override = default; @@ -234,8 +234,7 @@ public: interpreter, "breakpoint set", "Sets a breakpoint or set of breakpoints in the executable.", "breakpoint set <cmd-options>"), - m_bp_opts(), m_python_class_options("scripted breakpoint", true, 'P'), - m_options() { + m_python_class_options("scripted breakpoint", true, 'P') { // We're picking up all the normal options, commands and disable. m_all_options.Append(&m_python_class_options, LLDB_OPT_SET_1 | LLDB_OPT_SET_2, LLDB_OPT_SET_11); @@ -253,9 +252,7 @@ public: class CommandOptions : public OptionGroup { public: - CommandOptions() - : OptionGroup(), m_condition(), m_filenames(), m_func_names(), - m_func_regexp(), m_source_text_regexp(), m_modules() {} + CommandOptions() {} ~CommandOptions() override = default; @@ -809,8 +806,7 @@ public: "created breakpoint. " "With the exception of -e, -d and -i, passing an " "empty argument clears the modification.", - nullptr), - m_options() { + nullptr) { CommandArgumentEntry arg; CommandObject::AddIDsArgumentData(arg, eArgTypeBreakpointID, eArgTypeBreakpointIDRange); @@ -1100,8 +1096,7 @@ public: : CommandObjectParsed( interpreter, "breakpoint list", "List some or all breakpoints at configurable levels of detail.", - nullptr), - m_options() { + nullptr) { CommandArgumentEntry arg; CommandArgumentData bp_id_arg; @@ -1123,7 +1118,7 @@ public: class CommandOptions : public Options { public: - CommandOptions() : Options() {} + CommandOptions() {} ~CommandOptions() override = default; @@ -1246,8 +1241,7 @@ public: : CommandObjectParsed(interpreter, "breakpoint clear", "Delete or disable breakpoints matching the " "specified source file and line.", - "breakpoint clear <cmd-options>"), - m_options() {} + "breakpoint clear <cmd-options>") {} ~CommandObjectBreakpointClear() override = default; @@ -1255,7 +1249,7 @@ public: class CommandOptions : public Options { public: - CommandOptions() : Options(), m_filename() {} + CommandOptions() {} ~CommandOptions() override = default; @@ -1384,8 +1378,7 @@ public: : CommandObjectParsed(interpreter, "breakpoint delete", "Delete the specified breakpoint(s). If no " "breakpoints are specified, delete them all.", - nullptr), - m_options() { + nullptr) { CommandArgumentEntry arg; CommandObject::AddIDsArgumentData(arg, eArgTypeBreakpointID, eArgTypeBreakpointIDRange); @@ -1408,7 +1401,7 @@ public: class CommandOptions : public Options { public: - CommandOptions() : Options() {} + CommandOptions() {} ~CommandOptions() override = default; @@ -1565,8 +1558,7 @@ private: class BreakpointNameOptionGroup : public OptionGroup { public: BreakpointNameOptionGroup() - : OptionGroup(), m_breakpoint(LLDB_INVALID_BREAK_ID), m_use_dummy(false) { - } + : m_breakpoint(LLDB_INVALID_BREAK_ID), m_use_dummy(false) {} ~BreakpointNameOptionGroup() override = default; @@ -1626,7 +1618,7 @@ public: class BreakpointAccessOptionGroup : public OptionGroup { public: - BreakpointAccessOptionGroup() : OptionGroup() {} + BreakpointAccessOptionGroup() {} ~BreakpointAccessOptionGroup() override = default; @@ -1696,8 +1688,7 @@ public: "the breakpoint, otherwise only the options specified will be set " "on the name.", "breakpoint name configure <command-options> " - "<breakpoint-name-list>"), - m_bp_opts(), m_option_group() { + "<breakpoint-name-list>") { // Create the first variant for the first (and only) argument for this // command. CommandArgumentEntry arg1; @@ -1787,8 +1778,7 @@ public: CommandObjectBreakpointNameAdd(CommandInterpreter &interpreter) : CommandObjectParsed( interpreter, "add", "Add a name to the breakpoints provided.", - "breakpoint name add <command-options> <breakpoint-id-list>"), - m_name_options(), m_option_group() { + "breakpoint name add <command-options> <breakpoint-id-list>") { // Create the first variant for the first (and only) argument for this // command. CommandArgumentEntry arg1; @@ -1872,8 +1862,7 @@ public: : CommandObjectParsed( interpreter, "delete", "Delete a name from the breakpoints provided.", - "breakpoint name delete <command-options> <breakpoint-id-list>"), - m_name_options(), m_option_group() { + "breakpoint name delete <command-options> <breakpoint-id-list>") { // Create the first variant for the first (and only) argument for this // command. CommandArgumentEntry arg1; @@ -1956,8 +1945,7 @@ public: "List either the names for a breakpoint or info " "about a given name. With no arguments, lists all " "names", - "breakpoint name list <command-options>"), - m_name_options(), m_option_group() { + "breakpoint name list <command-options>") { m_option_group.Append(&m_name_options, LLDB_OPT_SET_3, LLDB_OPT_SET_ALL); m_option_group.Finalize(); } @@ -2063,8 +2051,7 @@ public: : CommandObjectParsed(interpreter, "breakpoint read", "Read and set the breakpoints previously saved to " "a file with \"breakpoint write\". ", - nullptr), - m_options() {} + nullptr) {} ~CommandObjectBreakpointRead() override = default; @@ -2072,7 +2059,7 @@ public: class CommandOptions : public Options { public: - CommandOptions() : Options() {} + CommandOptions() {} ~CommandOptions() override = default; @@ -2245,8 +2232,7 @@ public: "Write the breakpoints listed to a file that can " "be read in with \"breakpoint read\". " "If given no arguments, writes all breakpoints.", - nullptr), - m_options() { + nullptr) { CommandArgumentEntry arg; CommandObject::AddIDsArgumentData(arg, eArgTypeBreakpointID, eArgTypeBreakpointIDRange); @@ -2269,7 +2255,7 @@ public: class CommandOptions : public Options { public: - CommandOptions() : Options() {} + CommandOptions() {} ~CommandOptions() override = default; diff --git a/lldb/source/Commands/CommandObjectBreakpointCommand.cpp b/lldb/source/Commands/CommandObjectBreakpointCommand.cpp index 26d35c82f57d..637e8b8bd578 100644 --- a/lldb/source/Commands/CommandObjectBreakpointCommand.cpp +++ b/lldb/source/Commands/CommandObjectBreakpointCommand.cpp @@ -69,7 +69,7 @@ public: nullptr), IOHandlerDelegateMultiline("DONE", IOHandlerDelegate::Completion::LLDBCommand), - m_options(), m_func_options("breakpoint command", false, 'F') { + m_func_options("breakpoint command", false, 'F') { SetHelpLong( R"( General information about entering breakpoint commands @@ -281,7 +281,7 @@ are no syntax errors may indicate that a function was declared but never called. class CommandOptions : public OptionGroup { public: - CommandOptions() : OptionGroup(), m_one_liner() {} + CommandOptions() {} ~CommandOptions() override = default; @@ -479,8 +479,7 @@ public: CommandObjectBreakpointCommandDelete(CommandInterpreter &interpreter) : CommandObjectParsed(interpreter, "delete", "Delete the set of commands from a breakpoint.", - nullptr), - m_options() { + nullptr) { CommandArgumentEntry arg; CommandArgumentData bp_id_arg; @@ -502,7 +501,7 @@ public: class CommandOptions : public Options { public: - CommandOptions() : Options() {} + CommandOptions() {} ~CommandOptions() override = default; diff --git a/lldb/source/Commands/CommandObjectCommands.cpp b/lldb/source/Commands/CommandObjectCommands.cpp index 1ec54cf7eded..4b4932dd367b 100644 --- a/lldb/source/Commands/CommandObjectCommands.cpp +++ b/lldb/source/Commands/CommandObjectCommands.cpp @@ -38,8 +38,7 @@ public: : CommandObjectParsed( interpreter, "command source", "Read and execute LLDB commands from the file <filename>.", - nullptr), - m_options() { + nullptr) { CommandArgumentEntry arg; CommandArgumentData file_arg; @@ -76,8 +75,8 @@ protected: class CommandOptions : public Options { public: CommandOptions() - : Options(), m_stop_on_error(true), m_silent_run(false), - m_stop_on_continue(true), m_cmd_relative_to_command_file(false) {} + : m_stop_on_error(true), m_silent_run(false), m_stop_on_continue(true), + m_cmd_relative_to_command_file(false) {} ~CommandOptions() override = default; @@ -207,7 +206,7 @@ class CommandObjectCommandsAlias : public CommandObjectRaw { protected: class CommandOptions : public OptionGroup { public: - CommandOptions() : OptionGroup(), m_help(), m_long_help() {} + CommandOptions() {} ~CommandOptions() override = default; @@ -258,8 +257,7 @@ public: CommandObjectCommandsAlias(CommandInterpreter &interpreter) : CommandObjectRaw( interpreter, "command alias", - "Define a custom command in terms of an existing command."), - m_option_group(), m_command_options() { + "Define a custom command in terms of an existing command.") { m_option_group.Append(&m_command_options); m_option_group.Finalize(); @@ -485,8 +483,9 @@ protected: OptionArgVectorSP option_arg_vector_sp = OptionArgVectorSP(new OptionArgVector); - if (CommandObjectSP cmd_obj_sp = - m_interpreter.GetCommandSPExact(cmd_obj.GetCommandName())) { + const bool include_aliases = true; + if (CommandObjectSP cmd_obj_sp = m_interpreter.GetCommandSPExact( + cmd_obj.GetCommandName(), include_aliases)) { if (m_interpreter.AliasExists(alias_command) || m_interpreter.UserCommandExists(alias_command)) { result.AppendWarningWithFormat( @@ -792,8 +791,7 @@ public: "regular expressions.", "command regex <cmd-name> [s/<regex>/<subst>/ ...]"), IOHandlerDelegateMultiline("", - IOHandlerDelegate::Completion::LLDBCommand), - m_options() { + IOHandlerDelegate::Completion::LLDBCommand) { SetHelpLong( R"( )" @@ -1024,7 +1022,7 @@ private: class CommandOptions : public Options { public: - CommandOptions() : Options() {} + CommandOptions() {} ~CommandOptions() override = default; @@ -1238,8 +1236,7 @@ class CommandObjectCommandsScriptImport : public CommandObjectParsed { public: CommandObjectCommandsScriptImport(CommandInterpreter &interpreter) : CommandObjectParsed(interpreter, "command script import", - "Import a scripting module in LLDB.", nullptr), - m_options() { + "Import a scripting module in LLDB.", nullptr) { CommandArgumentEntry arg1; CommandArgumentData cmd_arg; @@ -1270,7 +1267,7 @@ public: protected: class CommandOptions : public Options { public: - CommandOptions() : Options() {} + CommandOptions() {} ~CommandOptions() override = default; @@ -1394,7 +1391,7 @@ public: "must be a path to a user-added container " "command, and the last element will be the new " "command name."), - IOHandlerDelegateMultiline("DONE"), m_options() { + IOHandlerDelegateMultiline("DONE") { CommandArgumentEntry arg1; CommandArgumentData cmd_arg; @@ -1425,8 +1422,7 @@ public: protected: class CommandOptions : public Options { public: - CommandOptions() - : Options(), m_class_name(), m_funct_name(), m_short_help() {} + CommandOptions() {} ~CommandOptions() override = default; @@ -1883,7 +1879,7 @@ public: protected: class CommandOptions : public Options { public: - CommandOptions() : Options(), m_short_help(), m_long_help() {} + CommandOptions() {} ~CommandOptions() override = default; diff --git a/lldb/source/Commands/CommandObjectDisassemble.cpp b/lldb/source/Commands/CommandObjectDisassemble.cpp index 02a16622c76b..e3c40ed73cf6 100644 --- a/lldb/source/Commands/CommandObjectDisassemble.cpp +++ b/lldb/source/Commands/CommandObjectDisassemble.cpp @@ -30,8 +30,7 @@ using namespace lldb_private; #define LLDB_OPTIONS_disassemble #include "CommandOptions.inc" -CommandObjectDisassemble::CommandOptions::CommandOptions() - : Options(), func_name(), plugin_name(), flavor_string(), arch() { +CommandObjectDisassemble::CommandOptions::CommandOptions() { OptionParsingStarting(nullptr); } diff --git a/lldb/source/Commands/CommandObjectExpression.cpp b/lldb/source/Commands/CommandObjectExpression.cpp index 9d13ccab6d3e..e1a289b219c3 100644 --- a/lldb/source/Commands/CommandObjectExpression.cpp +++ b/lldb/source/Commands/CommandObjectExpression.cpp @@ -24,7 +24,7 @@ using namespace lldb; using namespace lldb_private; -CommandObjectExpression::CommandOptions::CommandOptions() : OptionGroup() {} +CommandObjectExpression::CommandOptions::CommandOptions() {} CommandObjectExpression::CommandOptions::~CommandOptions() = default; @@ -200,10 +200,10 @@ CommandObjectExpression::CommandObjectExpression( "", eCommandProcessMustBePaused | eCommandTryTargetAPILock), IOHandlerDelegate(IOHandlerDelegate::Completion::Expression), - m_option_group(), m_format_options(eFormatDefault), + m_format_options(eFormatDefault), m_repl_option(LLDB_OPT_SET_1, false, "repl", 'r', "Drop into REPL", false, true), - m_command_options(), m_expr_line_count(0), m_expr_lines() { + m_command_options(), m_expr_line_count(0) { SetHelpLong( R"( Single and multi-line expressions: diff --git a/lldb/source/Commands/CommandObjectFrame.cpp b/lldb/source/Commands/CommandObjectFrame.cpp index 2b9f5316409f..70881f2d0061 100644 --- a/lldb/source/Commands/CommandObjectFrame.cpp +++ b/lldb/source/Commands/CommandObjectFrame.cpp @@ -49,7 +49,7 @@ class CommandObjectFrameDiagnose : public CommandObjectParsed { public: class CommandOptions : public Options { public: - CommandOptions() : Options() { OptionParsingStarting(nullptr); } + CommandOptions() { OptionParsingStarting(nullptr); } ~CommandOptions() override = default; @@ -110,8 +110,7 @@ public: nullptr, eCommandRequiresThread | eCommandTryTargetAPILock | eCommandProcessMustBeLaunched | - eCommandProcessMustBePaused), - m_options() { + eCommandProcessMustBePaused) { CommandArgumentEntry arg; CommandArgumentData index_arg; @@ -222,7 +221,7 @@ class CommandObjectFrameSelect : public CommandObjectParsed { public: class CommandOptions : public Options { public: - CommandOptions() : Options() { OptionParsingStarting(nullptr); } + CommandOptions() { OptionParsingStarting(nullptr); } ~CommandOptions() override = default; @@ -267,8 +266,7 @@ public: nullptr, eCommandRequiresThread | eCommandTryTargetAPILock | eCommandProcessMustBeLaunched | - eCommandProcessMustBePaused), - m_options() { + eCommandProcessMustBePaused) { CommandArgumentEntry arg; CommandArgumentData index_arg; @@ -394,27 +392,26 @@ public: interpreter, "frame variable", "Show variables for the current stack frame. Defaults to all " "arguments and local variables in scope. Names of argument, " - "local, file static and file global variables can be specified. " - "Children of aggregate variables can be specified such as " - "'var->child.x'. The -> and [] operators in 'frame variable' do " - "not invoke operator overloads if they exist, but directly access " - "the specified element. If you want to trigger operator overloads " - "use the expression command to print the variable instead." - "\nIt is worth noting that except for overloaded " - "operators, when printing local variables 'expr local_var' and " - "'frame var local_var' produce the same " - "results. However, 'frame variable' is more efficient, since it " - "uses debug information and memory reads directly, rather than " - "parsing and evaluating an expression, which may even involve " - "JITing and running code in the target program.", + "local, file static and file global variables can be specified.", nullptr, eCommandRequiresFrame | eCommandTryTargetAPILock | eCommandProcessMustBeLaunched | eCommandProcessMustBePaused | eCommandRequiresProcess), - m_option_group(), m_option_variable( true), // Include the frame specific options by passing "true" - m_option_format(eFormatDefault), m_varobj_options() { + m_option_format(eFormatDefault) { + SetHelpLong(R"( +Children of aggregate variables can be specified such as 'var->child.x'. In +'frame variable', the operators -> and [] do not invoke operator overloads if +they exist, but directly access the specified element. If you want to trigger +operator overloads use the expression command to print the variable instead. + +It is worth noting that except for overloaded operators, when printing local +variables 'expr local_var' and 'frame var local_var' produce the same results. +However, 'frame variable' is more efficient, since it uses debug information and +memory reads directly, rather than parsing and evaluating an expression, which +may even involve JITing and running code in the target program.)"); + CommandArgumentEntry arg; CommandArgumentData var_name_arg; @@ -558,18 +555,16 @@ protected: } } } else if (num_matches == 0) { - result.GetErrorStream().Printf("error: no variables matched " - "the regular expression '%s'.\n", - entry.c_str()); + result.AppendErrorWithFormat( + "no variables matched the regular expression '%s'.", + entry.c_str()); } } else { if (llvm::Error err = regex.GetError()) - result.GetErrorStream().Printf( - "error: %s\n", llvm::toString(std::move(err)).c_str()); + result.AppendError(llvm::toString(std::move(err))); else - result.GetErrorStream().Printf( - "error: unknown regex error when compiling '%s'\n", - entry.c_str()); + result.AppendErrorWithFormat( + "unknown regex error when compiling '%s'", entry.c_str()); } } else // No regex, either exact variable names or variable // expressions. @@ -605,14 +600,13 @@ protected: valobj_sp->GetParent() ? entry.c_str() : nullptr); valobj_sp->Dump(output_stream, options); } else { - const char *error_cstr = error.AsCString(nullptr); - if (error_cstr) - result.GetErrorStream().Printf("error: %s\n", error_cstr); + if (auto error_cstr = error.AsCString(nullptr)) + result.AppendError(error_cstr); else - result.GetErrorStream().Printf("error: unable to find any " - "variable expression path that " - "matches '%s'.\n", - entry.c_str()); + result.AppendErrorWithFormat( + "unable to find any variable expression path that matches " + "'%s'.", + entry.c_str()); } } } @@ -680,7 +674,8 @@ protected: } } } - result.SetStatus(eReturnStatusSuccessFinishResult); + if (result.GetStatus() != eReturnStatusFailed) + result.SetStatus(eReturnStatusSuccessFinishResult); } if (m_option_variable.show_recognized_args) { @@ -731,7 +726,7 @@ class CommandObjectFrameRecognizerAdd : public CommandObjectParsed { private: class CommandOptions : public Options { public: - CommandOptions() : Options() {} + CommandOptions() {} ~CommandOptions() override = default; Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg, @@ -800,8 +795,7 @@ protected: public: CommandObjectFrameRecognizerAdd(CommandInterpreter &interpreter) : CommandObjectParsed(interpreter, "frame recognizer add", - "Add a new frame recognizer.", nullptr), - m_options() { + "Add a new frame recognizer.", nullptr) { SetHelpLong(R"( Frame recognizers allow for retrieving information about special frames based on ABI, arguments or other special properties of that frame, even without source diff --git a/lldb/source/Commands/CommandObjectHelp.cpp b/lldb/source/Commands/CommandObjectHelp.cpp index 8c24efaa08ee..a2f682049ae0 100644 --- a/lldb/source/Commands/CommandObjectHelp.cpp +++ b/lldb/source/Commands/CommandObjectHelp.cpp @@ -46,8 +46,7 @@ CommandObjectHelp::CommandObjectHelp(CommandInterpreter &interpreter) "Show a list of all debugger " "commands, or give details " "about a specific command.", - "help [<cmd-name>]"), - m_options() { + "help [<cmd-name>]") { CommandArgumentEntry arg; CommandArgumentData command_arg; diff --git a/lldb/source/Commands/CommandObjectHelp.h b/lldb/source/Commands/CommandObjectHelp.h index c924dda7c6d4..71799ebb3121 100644 --- a/lldb/source/Commands/CommandObjectHelp.h +++ b/lldb/source/Commands/CommandObjectHelp.h @@ -32,7 +32,7 @@ public: class CommandOptions : public Options { public: - CommandOptions() : Options() {} + CommandOptions() {} ~CommandOptions() override = default; diff --git a/lldb/source/Commands/CommandObjectLog.cpp b/lldb/source/Commands/CommandObjectLog.cpp index 05ffba27e65f..d432ab244805 100644 --- a/lldb/source/Commands/CommandObjectLog.cpp +++ b/lldb/source/Commands/CommandObjectLog.cpp @@ -45,8 +45,7 @@ public: CommandObjectLogEnable(CommandInterpreter &interpreter) : CommandObjectParsed(interpreter, "log enable", "Enable logging for a single log channel.", - nullptr), - m_options() { + nullptr) { CommandArgumentEntry arg1; CommandArgumentEntry arg2; CommandArgumentData channel_arg; @@ -76,7 +75,7 @@ public: class CommandOptions : public Options { public: - CommandOptions() : Options(), log_file() {} + CommandOptions() {} ~CommandOptions() override = default; diff --git a/lldb/source/Commands/CommandObjectMemory.cpp b/lldb/source/Commands/CommandObjectMemory.cpp index 9df42f36fafd..1b44a1bd709a 100644 --- a/lldb/source/Commands/CommandObjectMemory.cpp +++ b/lldb/source/Commands/CommandObjectMemory.cpp @@ -23,6 +23,7 @@ #include "lldb/Interpreter/Options.h" #include "lldb/Symbol/SymbolFile.h" #include "lldb/Symbol/TypeList.h" +#include "lldb/Target/ABI.h" #include "lldb/Target/Language.h" #include "lldb/Target/MemoryHistory.h" #include "lldb/Target/MemoryRegionInfo.h" @@ -47,7 +48,7 @@ using namespace lldb_private; class OptionGroupReadMemory : public OptionGroup { public: OptionGroupReadMemory() - : m_num_per_line(1, 1), m_view_as_type(), m_offset(0, 0), + : m_num_per_line(1, 1), m_offset(0, 0), m_language_for_type(eLanguageTypeUnknown) {} ~OptionGroupReadMemory() override = default; @@ -90,6 +91,10 @@ public: error = m_offset.SetValueFromString(option_value); break; + case '\x01': + m_show_tags = true; + break; + default: llvm_unreachable("Unimplemented option"); } @@ -103,6 +108,7 @@ public: m_force = false; m_offset.Clear(); m_language_for_type.Clear(); + m_show_tags = false; } Status FinalizeSettings(Target *target, OptionGroupFormat &format_options) { @@ -276,6 +282,7 @@ public: bool m_force; OptionValueUInt64 m_offset; OptionValueLanguage m_language_for_type; + bool m_show_tags = false; }; // Read memory from the inferior process @@ -286,12 +293,10 @@ public: interpreter, "memory read", "Read from the memory of the current target process.", nullptr, eCommandRequiresTarget | eCommandProcessMustBePaused), - m_option_group(), m_format_options(eFormatBytesWithASCII, 1, 8), - m_memory_options(), m_outfile_options(), m_varobj_options(), + m_format_options(eFormatBytesWithASCII, 1, 8), + m_next_addr(LLDB_INVALID_ADDRESS), m_prev_byte_size(0), - m_prev_format_options(eFormatBytesWithASCII, 1, 8), - m_prev_memory_options(), m_prev_outfile_options(), - m_prev_varobj_options() { + m_prev_format_options(eFormatBytesWithASCII, 1, 8) { CommandArgumentEntry arg1; CommandArgumentEntry arg2; CommandArgumentData start_addr_arg; @@ -590,9 +595,16 @@ protected: return false; } + ABISP abi = m_exe_ctx.GetProcessPtr()->GetABI(); + if (abi) + addr = abi->FixDataAddress(addr); + if (argc == 2) { lldb::addr_t end_addr = OptionArgParser::ToAddress( &m_exe_ctx, command[1].ref(), LLDB_INVALID_ADDRESS, nullptr); + if (end_addr != LLDB_INVALID_ADDRESS && abi) + end_addr = abi->FixDataAddress(end_addr); + if (end_addr == LLDB_INVALID_ADDRESS) { result.AppendError("invalid end address expression."); result.AppendError(error.AsCString()); @@ -854,7 +866,7 @@ protected: size_t bytes_dumped = DumpDataExtractor( data, output_stream_p, 0, format, item_byte_size, item_count, num_per_line / target->GetArchitecture().GetDataByteSize(), addr, 0, 0, - exe_scope); + exe_scope, m_memory_options.m_show_tags); m_next_addr = addr + bytes_dumped; output_stream_p->EOL(); return true; @@ -882,7 +894,7 @@ class CommandObjectMemoryFind : public CommandObjectParsed { public: class OptionGroupFindMemory : public OptionGroup { public: - OptionGroupFindMemory() : OptionGroup(), m_count(1), m_offset(0) {} + OptionGroupFindMemory() : m_count(1), m_offset(0) {} ~OptionGroupFindMemory() override = default; @@ -936,8 +948,7 @@ public: : CommandObjectParsed( interpreter, "memory find", "Find a value in the memory of the current target process.", - nullptr, eCommandRequiresProcess | eCommandProcessMustBeLaunched), - m_option_group(), m_memory_options() { + nullptr, eCommandRequiresProcess | eCommandProcessMustBeLaunched) { CommandArgumentEntry arg1; CommandArgumentEntry arg2; CommandArgumentData addr_arg; @@ -1027,6 +1038,12 @@ protected: return false; } + ABISP abi = m_exe_ctx.GetProcessPtr()->GetABI(); + if (abi) { + low_addr = abi->FixDataAddress(low_addr); + high_addr = abi->FixDataAddress(high_addr); + } + if (high_addr <= low_addr) { result.AppendError( "starting address must be smaller than ending address"); @@ -1170,7 +1187,7 @@ class CommandObjectMemoryWrite : public CommandObjectParsed { public: class OptionGroupWriteMemory : public OptionGroup { public: - OptionGroupWriteMemory() : OptionGroup() {} + OptionGroupWriteMemory() {} ~OptionGroupWriteMemory() override = default; @@ -1222,16 +1239,14 @@ public: interpreter, "memory write", "Write to the memory of the current target process.", nullptr, eCommandRequiresProcess | eCommandProcessMustBeLaunched), - m_option_group(), m_format_options( eFormatBytes, 1, UINT64_MAX, {std::make_tuple( eArgTypeFormat, "The format to use for each of the value to be written."), - std::make_tuple( - eArgTypeByteSize, - "The size in bytes to write from input file or each value.")}), - m_memory_options() { + std::make_tuple(eArgTypeByteSize, + "The size in bytes to write from input file or " + "each value.")}) { CommandArgumentEntry arg1; CommandArgumentEntry arg2; CommandArgumentData addr_arg; diff --git a/lldb/source/Commands/CommandObjectMemoryTag.cpp b/lldb/source/Commands/CommandObjectMemoryTag.cpp index 840f81719d7d..d108cf58b18c 100644 --- a/lldb/source/Commands/CommandObjectMemoryTag.cpp +++ b/lldb/source/Commands/CommandObjectMemoryTag.cpp @@ -12,6 +12,7 @@ #include "lldb/Interpreter/OptionArgParser.h" #include "lldb/Interpreter/OptionGroupFormat.h" #include "lldb/Interpreter/OptionValueString.h" +#include "lldb/Target/ABI.h" #include "lldb/Target/Process.h" using namespace lldb; @@ -85,6 +86,17 @@ protected: // If this fails the list of regions is cleared, so we don't need to read // the return status here. process->GetMemoryRegions(memory_regions); + + lldb::addr_t logical_tag = tag_manager->GetLogicalTag(start_addr); + + // The tag manager only removes tag bits. These addresses may include other + // non-address bits that must also be ignored. + ABISP abi = process->GetABI(); + if (abi) { + start_addr = abi->FixDataAddress(start_addr); + end_addr = abi->FixDataAddress(end_addr); + } + llvm::Expected<MemoryTagManager::TagRange> tagged_range = tag_manager->MakeTaggedRange(start_addr, end_addr, memory_regions); @@ -101,7 +113,6 @@ protected: return false; } - lldb::addr_t logical_tag = tag_manager->GetLogicalTag(start_addr); result.AppendMessageWithFormatv("Logical tag: {0:x}", logical_tag); result.AppendMessage("Allocation tags:"); @@ -127,7 +138,7 @@ class CommandObjectMemoryTagWrite : public CommandObjectParsed { public: class OptionGroupTagWrite : public OptionGroup { public: - OptionGroupTagWrite() : OptionGroup(), m_end_addr(LLDB_INVALID_ADDRESS) {} + OptionGroupTagWrite() : m_end_addr(LLDB_INVALID_ADDRESS) {} ~OptionGroupTagWrite() override = default; @@ -166,8 +177,7 @@ public: "contains the given address.", nullptr, eCommandRequiresTarget | eCommandRequiresProcess | - eCommandProcessMustBePaused), - m_option_group(), m_tag_write_options() { + eCommandProcessMustBePaused) { // Address m_arguments.push_back( CommandArgumentEntry{CommandArgumentData(eArgTypeAddressOrExpression)}); @@ -231,6 +241,12 @@ protected: // the return status here. process->GetMemoryRegions(memory_regions); + // The tag manager only removes tag bits. These addresses may include other + // non-address bits that must also be ignored. + ABISP abi = process->GetABI(); + if (abi) + start_addr = abi->FixDataAddress(start_addr); + // We have to assume start_addr is not granule aligned. // So if we simply made a range: // (start_addr, start_addr + (N * granule_size)) @@ -254,6 +270,10 @@ protected: end_addr = aligned_start_addr + (tags.size() * tag_manager->GetGranuleSize()); + // Remove non-address bits that aren't memory tags + if (abi) + end_addr = abi->FixDataAddress(end_addr); + // Now we've aligned the start address so if we ask for another range // using the number of tags N, we'll get back a range that is also N // granules in size. diff --git a/lldb/source/Commands/CommandObjectMultiword.cpp b/lldb/source/Commands/CommandObjectMultiword.cpp index e800bcc12bd3..0629342748aa 100644 --- a/lldb/source/Commands/CommandObjectMultiword.cpp +++ b/lldb/source/Commands/CommandObjectMultiword.cpp @@ -302,31 +302,6 @@ const char *CommandObjectMultiword::GetRepeatCommand(Args ¤t_command_args, return sub_command_object->GetRepeatCommand(current_command_args, index); } -void CommandObjectMultiword::AproposAllSubCommands(llvm::StringRef prefix, - llvm::StringRef search_word, - StringList &commands_found, - StringList &commands_help) { - CommandObject::CommandMap::const_iterator pos; - - for (pos = m_subcommand_dict.begin(); pos != m_subcommand_dict.end(); ++pos) { - const char *command_name = pos->first.c_str(); - CommandObject *sub_cmd_obj = pos->second.get(); - StreamString complete_command_name; - - complete_command_name << prefix << " " << command_name; - - if (sub_cmd_obj->HelpTextContainsWord(search_word)) { - commands_found.AppendString(complete_command_name.GetString()); - commands_help.AppendString(sub_cmd_obj->GetHelp()); - } - - if (sub_cmd_obj->IsMultiwordObject()) - sub_cmd_obj->AproposAllSubCommands(complete_command_name.GetString(), - search_word, commands_found, - commands_help); - } -} - CommandObjectProxy::CommandObjectProxy(CommandInterpreter &interpreter, const char *name, const char *help, const char *syntax, uint32_t flags) @@ -409,16 +384,6 @@ CommandObject *CommandObjectProxy::GetSubcommandObject(llvm::StringRef sub_cmd, return nullptr; } -void CommandObjectProxy::AproposAllSubCommands(llvm::StringRef prefix, - llvm::StringRef search_word, - StringList &commands_found, - StringList &commands_help) { - CommandObject *proxy_command = GetProxyCommandObject(); - if (proxy_command) - return proxy_command->AproposAllSubCommands(prefix, search_word, - commands_found, commands_help); -} - bool CommandObjectProxy::LoadSubCommand( llvm::StringRef cmd_name, const lldb::CommandObjectSP &command_sp) { CommandObject *proxy_command = GetProxyCommandObject(); diff --git a/lldb/source/Commands/CommandObjectPlatform.cpp b/lldb/source/Commands/CommandObjectPlatform.cpp index 10dd87824911..4c18465c868a 100644 --- a/lldb/source/Commands/CommandObjectPlatform.cpp +++ b/lldb/source/Commands/CommandObjectPlatform.cpp @@ -145,7 +145,6 @@ public: "Create a platform if needed and select it as the " "current platform.", "platform select <platform-name>", 0), - m_option_group(), m_platform_options( false) // Don't include the "--platform" option by passing false { @@ -377,7 +376,6 @@ public: "Set settings for the current target's platform, " "or for a platform by name.", "platform settings", 0), - m_options(), m_option_working_dir(LLDB_OPT_SET_1, false, "working-dir", 'w', CommandCompletions::eRemoteDiskDirectoryCompletion, eArgTypePath, @@ -417,8 +415,7 @@ public: CommandObjectPlatformMkDir(CommandInterpreter &interpreter) : CommandObjectParsed(interpreter, "platform mkdir", "Make a new directory on the remote end.", nullptr, - 0), - m_options() {} + 0) {} ~CommandObjectPlatformMkDir() override = default; @@ -464,8 +461,7 @@ class CommandObjectPlatformFOpen : public CommandObjectParsed { public: CommandObjectPlatformFOpen(CommandInterpreter &interpreter) : CommandObjectParsed(interpreter, "platform file open", - "Open a file on the remote end.", nullptr, 0), - m_options() {} + "Open a file on the remote end.", nullptr, 0) {} ~CommandObjectPlatformFOpen() override = default; @@ -566,8 +562,7 @@ public: CommandObjectPlatformFRead(CommandInterpreter &interpreter) : CommandObjectParsed(interpreter, "platform file read", "Read data from a file on the remote end.", nullptr, - 0), - m_options() {} + 0) {} ~CommandObjectPlatformFRead() override = default; @@ -605,7 +600,7 @@ public: protected: class CommandOptions : public Options { public: - CommandOptions() : Options() {} + CommandOptions() {} ~CommandOptions() override = default; @@ -660,8 +655,7 @@ public: CommandObjectPlatformFWrite(CommandInterpreter &interpreter) : CommandObjectParsed(interpreter, "platform file write", "Write data to a file on the remote end.", nullptr, - 0), - m_options() {} + 0) {} ~CommandObjectPlatformFWrite() override = default; @@ -698,7 +692,7 @@ public: protected: class CommandOptions : public Options { public: - CommandOptions() : Options() {} + CommandOptions() {} ~CommandOptions() override = default; @@ -1124,8 +1118,7 @@ public: : CommandObjectParsed(interpreter, "platform process launch", "Launch a new process on a remote platform.", "platform process launch program", - eCommandRequiresTarget | eCommandTryTargetAPILock), - m_options(), m_all_options() { + eCommandRequiresTarget | eCommandTryTargetAPILock) { m_all_options.Append(&m_options); m_all_options.Finalize(); } @@ -1217,8 +1210,7 @@ public: : CommandObjectParsed(interpreter, "platform process list", "List processes on a remote platform by name, pid, " "or many other matching attributes.", - "platform process list", 0), - m_options() {} + "platform process list", 0) {} ~CommandObjectPlatformProcessList() override = default; @@ -1324,7 +1316,7 @@ protected: class CommandOptions : public Options { public: - CommandOptions() : Options(), match_info() {} + CommandOptions() {} ~CommandOptions() override = default; @@ -1560,7 +1552,7 @@ class CommandObjectPlatformProcessAttach : public CommandObjectParsed { public: class CommandOptions : public Options { public: - CommandOptions() : Options() { + CommandOptions() { // Keep default values of all options in one place: OptionParsingStarting // () OptionParsingStarting(nullptr); @@ -1622,8 +1614,7 @@ public: CommandObjectPlatformProcessAttach(CommandInterpreter &interpreter) : CommandObjectParsed(interpreter, "platform process attach", "Attach to a process.", - "platform process attach <cmd-options>"), - m_options() {} + "platform process attach <cmd-options>") {} ~CommandObjectPlatformProcessAttach() override = default; @@ -1689,7 +1680,7 @@ class CommandObjectPlatformShell : public CommandObjectRaw { public: class CommandOptions : public Options { public: - CommandOptions() : Options() {} + CommandOptions() {} ~CommandOptions() override = default; @@ -1747,8 +1738,7 @@ public: CommandObjectPlatformShell(CommandInterpreter &interpreter) : CommandObjectRaw(interpreter, "platform shell", "Run a shell command on the current platform.", - "platform shell <shell-command>", 0), - m_options() {} + "platform shell <shell-command>", 0) {} ~CommandObjectPlatformShell() override = default; diff --git a/lldb/source/Commands/CommandObjectProcess.cpp b/lldb/source/Commands/CommandObjectProcess.cpp index 5fd1718e8484..c73f0df0aaf2 100644 --- a/lldb/source/Commands/CommandObjectProcess.cpp +++ b/lldb/source/Commands/CommandObjectProcess.cpp @@ -110,9 +110,8 @@ public: interpreter, "process launch", "Launch the executable in the debugger.", nullptr, eCommandRequiresTarget, "restart"), - m_options(), - m_class_options("scripted process", true, 'C', 'k', 'v', 0), - m_all_options() { + + m_class_options("scripted process", true, 'C', 'k', 'v', 0) { m_all_options.Append(&m_options); m_all_options.Append(&m_class_options, LLDB_OPT_SET_1 | LLDB_OPT_SET_2, LLDB_OPT_SET_ALL); @@ -300,7 +299,7 @@ class CommandObjectProcessAttach : public CommandObjectProcessLaunchOrAttach { public: class CommandOptions : public Options { public: - CommandOptions() : Options() { + CommandOptions() { // Keep default values of all options in one place: OptionParsingStarting // () OptionParsingStarting(nullptr); @@ -364,8 +363,7 @@ public: CommandObjectProcessAttach(CommandInterpreter &interpreter) : CommandObjectProcessLaunchOrAttach( interpreter, "process attach", "Attach to a process.", - "process attach <cmd-options>", 0, "attach"), - m_options() {} + "process attach <cmd-options>", 0, "attach") {} ~CommandObjectProcessAttach() override = default; @@ -502,15 +500,14 @@ public: "Continue execution of all threads in the current process.", "process continue", eCommandRequiresProcess | eCommandTryTargetAPILock | - eCommandProcessMustBeLaunched | eCommandProcessMustBePaused), - m_options() {} + eCommandProcessMustBeLaunched | eCommandProcessMustBePaused) {} ~CommandObjectProcessContinue() override = default; protected: class CommandOptions : public Options { public: - CommandOptions() : Options() { + CommandOptions() { // Keep default values of all options in one place: OptionParsingStarting // () OptionParsingStarting(nullptr); @@ -651,7 +648,7 @@ class CommandObjectProcessDetach : public CommandObjectParsed { public: class CommandOptions : public Options { public: - CommandOptions() : Options() { OptionParsingStarting(nullptr); } + CommandOptions() { OptionParsingStarting(nullptr); } ~CommandOptions() override = default; @@ -698,8 +695,7 @@ public: "Detach from the current target process.", "process detach", eCommandRequiresProcess | eCommandTryTargetAPILock | - eCommandProcessMustBeLaunched), - m_options() {} + eCommandProcessMustBeLaunched) {} ~CommandObjectProcessDetach() override = default; @@ -741,7 +737,7 @@ class CommandObjectProcessConnect : public CommandObjectParsed { public: class CommandOptions : public Options { public: - CommandOptions() : Options() { + CommandOptions() { // Keep default values of all options in one place: OptionParsingStarting // () OptionParsingStarting(nullptr); @@ -781,8 +777,7 @@ public: CommandObjectProcessConnect(CommandInterpreter &interpreter) : CommandObjectParsed(interpreter, "process connect", "Connect to a remote debug service.", - "process connect <remote-url>", 0), - m_options() {} + "process connect <remote-url>", 0) {} ~CommandObjectProcessConnect() override = default; @@ -863,7 +858,7 @@ class CommandObjectProcessLoad : public CommandObjectParsed { public: class CommandOptions : public Options { public: - CommandOptions() : Options() { + CommandOptions() { // Keep default values of all options in one place: OptionParsingStarting // () OptionParsingStarting(nullptr); @@ -907,8 +902,7 @@ public: "process load <filename> [<filename> ...]", eCommandRequiresProcess | eCommandTryTargetAPILock | eCommandProcessMustBeLaunched | - eCommandProcessMustBePaused), - m_options() {} + eCommandProcessMustBePaused) {} ~CommandObjectProcessLoad() override = default; @@ -1220,8 +1214,7 @@ public: class CommandOptions : public Options { public: - CommandOptions() - : Options(), m_requested_save_core_style(eSaveCoreUnspecified) {} + CommandOptions() : m_requested_save_core_style(eSaveCoreUnspecified) {} ~CommandOptions() override = default; @@ -1316,8 +1309,7 @@ public: interpreter, "process status", "Show status and stop location for the current target process.", "process status", - eCommandRequiresProcess | eCommandTryTargetAPILock), - m_options() {} + eCommandRequiresProcess | eCommandTryTargetAPILock) {} ~CommandObjectProcessStatus() override = default; @@ -1325,7 +1317,7 @@ public: class CommandOptions : public Options { public: - CommandOptions() : Options() {} + CommandOptions() {} ~CommandOptions() override = default; @@ -1430,7 +1422,7 @@ class CommandObjectProcessHandle : public CommandObjectParsed { public: class CommandOptions : public Options { public: - CommandOptions() : Options() { OptionParsingStarting(nullptr); } + CommandOptions() { OptionParsingStarting(nullptr); } ~CommandOptions() override = default; @@ -1477,8 +1469,7 @@ public: "Manage LLDB handling of OS signals for the " "current target process. Defaults to showing " "current policy.", - nullptr, eCommandRequiresTarget), - m_options() { + nullptr, eCommandRequiresTarget) { SetHelpLong("\nIf no signals are specified, update them all. If no update " "option is specified, list the current values."); CommandArgumentEntry arg; @@ -1687,7 +1678,7 @@ class CommandObjectProcessTraceSave : public CommandObjectParsed { public: class CommandOptions : public Options { public: - CommandOptions() : Options() { OptionParsingStarting(nullptr); } + CommandOptions() { OptionParsingStarting(nullptr); } Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg, ExecutionContext *execution_context) override { diff --git a/lldb/source/Commands/CommandObjectRegexCommand.cpp b/lldb/source/Commands/CommandObjectRegexCommand.cpp index 46295421834a..7ddc5c0c7e08 100644 --- a/lldb/source/Commands/CommandObjectRegexCommand.cpp +++ b/lldb/source/Commands/CommandObjectRegexCommand.cpp @@ -20,7 +20,7 @@ CommandObjectRegexCommand::CommandObjectRegexCommand( bool is_removable) : CommandObjectRaw(interpreter, name, help, syntax), m_max_matches(max_matches), m_completion_type_mask(completion_type_mask), - m_entries(), m_is_removable(is_removable) {} + m_is_removable(is_removable) {} // Destructor CommandObjectRegexCommand::~CommandObjectRegexCommand() = default; diff --git a/lldb/source/Commands/CommandObjectRegister.cpp b/lldb/source/Commands/CommandObjectRegister.cpp index 6fd71c90c327..933c243dedd5 100644 --- a/lldb/source/Commands/CommandObjectRegister.cpp +++ b/lldb/source/Commands/CommandObjectRegister.cpp @@ -43,8 +43,7 @@ public: nullptr, eCommandRequiresFrame | eCommandRequiresRegContext | eCommandProcessMustBeLaunched | eCommandProcessMustBePaused), - m_option_group(), m_format_options(eFormatDefault), - m_command_options() { + m_format_options(eFormatDefault) { CommandArgumentEntry arg; CommandArgumentData register_arg; @@ -232,8 +231,7 @@ protected: class CommandOptions : public OptionGroup { public: CommandOptions() - : OptionGroup(), - set_indexes(OptionValue::ConvertTypeToMask(OptionValue::eTypeUInt64)), + : set_indexes(OptionValue::ConvertTypeToMask(OptionValue::eTypeUInt64)), dump_all_sets(false, false), // Initial and default values are false alternate_name(false, false) {} diff --git a/lldb/source/Commands/CommandObjectReproducer.cpp b/lldb/source/Commands/CommandObjectReproducer.cpp index 4db3e070df3c..7e0ea65e148e 100644 --- a/lldb/source/Commands/CommandObjectReproducer.cpp +++ b/lldb/source/Commands/CommandObjectReproducer.cpp @@ -227,7 +227,7 @@ public: class CommandOptions : public Options { public: - CommandOptions() : Options() {} + CommandOptions() {} ~CommandOptions() override = default; @@ -355,7 +355,7 @@ public: class CommandOptions : public Options { public: - CommandOptions() : Options(), file() {} + CommandOptions() {} ~CommandOptions() override = default; @@ -602,7 +602,7 @@ public: class CommandOptions : public Options { public: - CommandOptions() : Options(), file() {} + CommandOptions() {} ~CommandOptions() override = default; diff --git a/lldb/source/Commands/CommandObjectScript.h b/lldb/source/Commands/CommandObjectScript.h index b9fee7124818..97fc05421bd0 100644 --- a/lldb/source/Commands/CommandObjectScript.h +++ b/lldb/source/Commands/CommandObjectScript.h @@ -21,7 +21,7 @@ public: class CommandOptions : public Options { public: - CommandOptions() : Options() {} + CommandOptions() {} ~CommandOptions() override = default; Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg, ExecutionContext *execution_context) override; diff --git a/lldb/source/Commands/CommandObjectSession.cpp b/lldb/source/Commands/CommandObjectSession.cpp index c2cdfa29a3f6..c11839a48de0 100644 --- a/lldb/source/Commands/CommandObjectSession.cpp +++ b/lldb/source/Commands/CommandObjectSession.cpp @@ -62,8 +62,7 @@ public: "using \"!<INDEX>\". \"!-<OFFSET>\" will re-run " "the command that is <OFFSET> commands from the end" " of the list (counting the current command).", - nullptr), - m_options() {} + nullptr) {} ~CommandObjectSessionHistory() override = default; @@ -73,8 +72,7 @@ protected: class CommandOptions : public Options { public: CommandOptions() - : Options(), m_start_idx(0), m_stop_idx(0), m_count(0), m_clear(false) { - } + : m_start_idx(0), m_stop_idx(0), m_count(0), m_clear(false) {} ~CommandOptions() override = default; diff --git a/lldb/source/Commands/CommandObjectSettings.cpp b/lldb/source/Commands/CommandObjectSettings.cpp index 13ff27c78dea..391e728d9d8a 100644 --- a/lldb/source/Commands/CommandObjectSettings.cpp +++ b/lldb/source/Commands/CommandObjectSettings.cpp @@ -27,8 +27,7 @@ class CommandObjectSettingsSet : public CommandObjectRaw { public: CommandObjectSettingsSet(CommandInterpreter &interpreter) : CommandObjectRaw(interpreter, "settings set", - "Set the value of the specified debugger setting."), - m_options() { + "Set the value of the specified debugger setting.") { CommandArgumentEntry arg1; CommandArgumentEntry arg2; CommandArgumentData var_name_arg; @@ -87,7 +86,7 @@ insert-before or insert-after."); class CommandOptions : public Options { public: - CommandOptions() : Options() {} + CommandOptions() {} ~CommandOptions() override = default; @@ -304,8 +303,7 @@ public: "Write matching debugger settings and their " "current values to a file that can be read in with " "\"settings read\". Defaults to writing all settings.", - nullptr), - m_options() { + nullptr) { CommandArgumentEntry arg1; CommandArgumentData var_name_arg; @@ -327,7 +325,7 @@ public: class CommandOptions : public Options { public: - CommandOptions() : Options() {} + CommandOptions() {} ~CommandOptions() override = default; @@ -417,8 +415,7 @@ public: : CommandObjectParsed( interpreter, "settings read", "Read settings previously saved to a file with \"settings write\".", - nullptr), - m_options() {} + nullptr) {} ~CommandObjectSettingsRead() override = default; @@ -426,7 +423,7 @@ public: class CommandOptions : public Options { public: - CommandOptions() : Options() {} + CommandOptions() {} ~CommandOptions() override = default; diff --git a/lldb/source/Commands/CommandObjectSource.cpp b/lldb/source/Commands/CommandObjectSource.cpp index fb33f41b8ef9..6c6706f4a98b 100644 --- a/lldb/source/Commands/CommandObjectSource.cpp +++ b/lldb/source/Commands/CommandObjectSource.cpp @@ -36,7 +36,7 @@ using namespace lldb_private; class CommandObjectSourceInfo : public CommandObjectParsed { class CommandOptions : public Options { public: - CommandOptions() : Options() {} + CommandOptions() {} ~CommandOptions() override = default; @@ -118,8 +118,7 @@ public: "Display source line information for the current target " "process. Defaults to instruction pointer in current stack " "frame.", - nullptr, eCommandRequiresTarget), - m_options() {} + nullptr, eCommandRequiresTarget) {} ~CommandObjectSourceInfo() override = default; @@ -624,7 +623,7 @@ protected: class CommandObjectSourceList : public CommandObjectParsed { class CommandOptions : public Options { public: - CommandOptions() : Options() {} + CommandOptions() {} ~CommandOptions() override = default; @@ -723,8 +722,7 @@ public: : CommandObjectParsed(interpreter, "source list", "Display source code for the current target " "process as specified by options.", - nullptr, eCommandRequiresTarget), - m_options() {} + nullptr, eCommandRequiresTarget) {} ~CommandObjectSourceList() override = default; @@ -757,7 +755,7 @@ protected: SourceInfo(ConstString name, const LineEntry &line_entry) : function(name), line_entry(line_entry) {} - SourceInfo() : function(), line_entry() {} + SourceInfo() {} bool IsValid() const { return (bool)function && line_entry.IsValid(); } diff --git a/lldb/source/Commands/CommandObjectStats.cpp b/lldb/source/Commands/CommandObjectStats.cpp index f32d559ca039..63aa36b39f4d 100644 --- a/lldb/source/Commands/CommandObjectStats.cpp +++ b/lldb/source/Commands/CommandObjectStats.cpp @@ -65,7 +65,7 @@ protected: class CommandObjectStatsDump : public CommandObjectParsed { class CommandOptions : public Options { public: - CommandOptions() : Options() { OptionParsingStarting(nullptr); } + CommandOptions() { OptionParsingStarting(nullptr); } Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg, ExecutionContext *execution_context) override { diff --git a/lldb/source/Commands/CommandObjectTarget.cpp b/lldb/source/Commands/CommandObjectTarget.cpp index 2a42eb22938d..157065bde10e 100644 --- a/lldb/source/Commands/CommandObjectTarget.cpp +++ b/lldb/source/Commands/CommandObjectTarget.cpp @@ -216,7 +216,6 @@ public: interpreter, "target create", "Create a target using the argument as the main executable.", nullptr), - m_option_group(), m_arch_option(), m_platform_options(true), // Include the --platform option. m_core_file(LLDB_OPT_SET_1, false, "core", 'c', 0, eArgTypeFilename, "Fullpath to a core file to use for this target."), @@ -227,8 +226,7 @@ public: "are not in the executable."), m_remote_file( LLDB_OPT_SET_1, false, "remote-file", 'r', 0, eArgTypeFilename, - "Fullpath to the file on the remote host if debugging remotely."), - m_add_dependents() { + "Fullpath to the file on the remote host if debugging remotely.") { CommandArgumentEntry arg; CommandArgumentData file_arg; @@ -534,8 +532,8 @@ public: : CommandObjectParsed(interpreter, "target delete", "Delete one or more targets by target index.", nullptr), - m_option_group(), m_all_option(LLDB_OPT_SET_1, false, "all", 'a', - "Delete all targets.", false, true), + m_all_option(LLDB_OPT_SET_1, false, "all", 'a', "Delete all targets.", + false, true), m_cleanup_option( LLDB_OPT_SET_1, false, "clean", 'c', "Perform extra cleanup to minimize memory consumption after " @@ -678,7 +676,6 @@ public: "Read global variables for the current target, " "before or while running a process.", nullptr, eCommandRequiresTarget), - m_option_group(), m_option_variable(false), // Don't include frame options m_option_format(eFormatDefault), m_option_compile_units(LLDB_OPT_SET_1, false, "file", SHORT_OPTION_FILE, @@ -691,8 +688,7 @@ public: eArgTypeFilename, "A basename or fullpath to a shared library to use in the search " "for global " - "variables. This option can be specified multiple times."), - m_varobj_options() { + "variables. This option can be specified multiple times.") { CommandArgumentEntry arg; CommandArgumentData var_name_arg; @@ -1605,7 +1601,6 @@ static size_t LookupTypeInModule(Target *target, TypeList type_list; if (module && name_cstr && name_cstr[0]) { const uint32_t max_num_matches = UINT32_MAX; - size_t num_matches = 0; bool name_is_fully_qualified = false; ConstString name(name_cstr); @@ -1616,8 +1611,10 @@ static size_t LookupTypeInModule(Target *target, if (type_list.Empty()) return 0; + const uint64_t num_matches = type_list.GetSize(); + strm.Indent(); - strm.Printf("%" PRIu64 " match%s found in ", (uint64_t)num_matches, + strm.Printf("%" PRIu64 " match%s found in ", num_matches, num_matches > 1 ? "es" : ""); DumpFullpath(strm, &module->GetFileSpec(), 0); strm.PutCString(":\n"); @@ -1927,8 +1924,7 @@ public: : CommandObjectTargetModulesModuleAutoComplete( interpreter, "target modules dump symtab", "Dump the symbol table from one or more target modules.", nullptr, - eCommandRequiresTarget), - m_options() {} + eCommandRequiresTarget) {} ~CommandObjectTargetModulesDumpSymtab() override = default; @@ -1936,7 +1932,7 @@ public: class CommandOptions : public Options { public: - CommandOptions() : Options() {} + CommandOptions() {} ~CommandOptions() override = default; @@ -2353,7 +2349,7 @@ protected: class CommandOptions : public Options { public: - CommandOptions() : Options() { OptionParsingStarting(nullptr); } + CommandOptions() { OptionParsingStarting(nullptr); } Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg, ExecutionContext *execution_context) override { @@ -2422,11 +2418,11 @@ public: "Add a new module to the current target's modules.", "target modules add [<module>]", eCommandRequiresTarget), - m_option_group(), m_symbol_file(LLDB_OPT_SET_1, false, "symfile", 's', - 0, eArgTypeFilename, - "Fullpath to a stand alone debug " - "symbols file for when debug symbols " - "are not in the executable.") { + m_symbol_file(LLDB_OPT_SET_1, false, "symfile", 's', 0, + eArgTypeFilename, + "Fullpath to a stand alone debug " + "symbols file for when debug symbols " + "are not in the executable.") { m_option_group.Append(&m_uuid_option_group, LLDB_OPT_SET_ALL, LLDB_OPT_SET_1); m_option_group.Append(&m_symbol_file, LLDB_OPT_SET_ALL, LLDB_OPT_SET_1); @@ -2574,7 +2570,6 @@ public: "target modules load [--file <module> --uuid <uuid>] <sect-name> " "<address> [<sect-name> <address> ....]", eCommandRequiresTarget), - m_option_group(), m_file_option(LLDB_OPT_SET_1, false, "file", 'f', 0, eArgTypeName, "Fullpath or basename for module to load.", ""), m_load_option(LLDB_OPT_SET_1, false, "load", 'l', @@ -2842,7 +2837,7 @@ class CommandObjectTargetModulesList : public CommandObjectParsed { public: class CommandOptions : public Options { public: - CommandOptions() : Options(), m_format_array() {} + CommandOptions() {} ~CommandOptions() override = default; @@ -2885,8 +2880,7 @@ public: : CommandObjectParsed( interpreter, "target modules list", "List current executable and dependent shared library images.", - "target modules list [<cmd-options>]"), - m_options() {} + "target modules list [<cmd-options>]") {} ~CommandObjectTargetModulesList() override = default; @@ -3185,7 +3179,7 @@ public: class CommandOptions : public Options { public: - CommandOptions() : Options(), m_str() {} + CommandOptions() {} ~CommandOptions() override = default; @@ -3242,8 +3236,7 @@ public: interpreter, "target modules show-unwind", "Show synthesized unwind instructions for a function.", nullptr, eCommandRequiresTarget | eCommandRequiresProcess | - eCommandProcessMustBeLaunched | eCommandProcessMustBePaused), - m_options() {} + eCommandProcessMustBeLaunched | eCommandProcessMustBePaused) {} ~CommandObjectTargetModulesShowUnwind() override = default; @@ -3532,7 +3525,7 @@ public: class CommandOptions : public Options { public: - CommandOptions() : Options() { OptionParsingStarting(nullptr); } + CommandOptions() { OptionParsingStarting(nullptr); } ~CommandOptions() override = default; @@ -3647,8 +3640,7 @@ public: : CommandObjectParsed(interpreter, "target modules lookup", "Look up information within executable and " "dependent shared library images.", - nullptr, eCommandRequiresTarget), - m_options() { + nullptr, eCommandRequiresTarget) { CommandArgumentEntry arg; CommandArgumentData file_arg; @@ -3954,7 +3946,6 @@ public: "to specify a module.", "target symbols add <cmd-options> [<symfile>]", eCommandRequiresTarget), - m_option_group(), m_file_option( LLDB_OPT_SET_1, false, "shlib", 's', CommandCompletions::eModuleCompletion, eArgTypeShlibName, @@ -4441,7 +4432,7 @@ class CommandObjectTargetStopHookAdd : public CommandObjectParsed, public: class CommandOptions : public OptionGroup { public: - CommandOptions() : OptionGroup(), m_line_end(UINT_MAX), m_one_liner() {} + CommandOptions() : m_line_end(UINT_MAX) {} ~CommandOptions() override = default; @@ -4598,7 +4589,7 @@ public: "target stop-hook add"), IOHandlerDelegateMultiline("DONE", IOHandlerDelegate::Completion::LLDBCommand), - m_options(), m_python_class_options("scripted stop-hook", true, 'P') { + m_python_class_options("scripted stop-hook", true, 'P') { SetHelpLong( R"( Command Based stop-hooks: diff --git a/lldb/source/Commands/CommandObjectThread.cpp b/lldb/source/Commands/CommandObjectThread.cpp index 71e67f6ba208..137aaa81c61a 100644 --- a/lldb/source/Commands/CommandObjectThread.cpp +++ b/lldb/source/Commands/CommandObjectThread.cpp @@ -47,7 +47,7 @@ class CommandObjectThreadBacktrace : public CommandObjectIterateOverThreads { public: class CommandOptions : public Options { public: - CommandOptions() : Options() { + CommandOptions() { // Keep default values of all options in one place: OptionParsingStarting // () OptionParsingStarting(nullptr); @@ -119,8 +119,7 @@ public: nullptr, eCommandRequiresProcess | eCommandRequiresThread | eCommandTryTargetAPILock | eCommandProcessMustBeLaunched | - eCommandProcessMustBePaused), - m_options() {} + eCommandProcessMustBePaused) {} ~CommandObjectThreadBacktrace() override = default; @@ -203,7 +202,7 @@ static constexpr OptionEnumValues TriRunningModes() { class ThreadStepScopeOptionGroup : public OptionGroup { public: - ThreadStepScopeOptionGroup() : OptionGroup() { + ThreadStepScopeOptionGroup() { // Keep default values of all options in one place: OptionParsingStarting // () OptionParsingStarting(nullptr); @@ -327,7 +326,7 @@ public: eCommandTryTargetAPILock | eCommandProcessMustBeLaunched | eCommandProcessMustBePaused), - m_step_type(step_type), m_step_scope(step_scope), m_options(), + m_step_type(step_type), m_step_scope(step_scope), m_class_options("scripted step") { CommandArgumentEntry arg; CommandArgumentData thread_id_arg; @@ -780,7 +779,7 @@ public: uint32_t m_thread_idx = LLDB_INVALID_THREAD_ID; uint32_t m_frame_idx = LLDB_INVALID_FRAME_ID; - CommandOptions() : Options() { + CommandOptions() { // Keep default values of all options in one place: OptionParsingStarting // () OptionParsingStarting(nullptr); @@ -861,8 +860,7 @@ public: " is provided, stepping will stop when the first one is hit.", nullptr, eCommandRequiresThread | eCommandTryTargetAPILock | - eCommandProcessMustBeLaunched | eCommandProcessMustBePaused), - m_options() { + eCommandProcessMustBeLaunched | eCommandProcessMustBePaused) { CommandArgumentEntry arg; CommandArgumentData line_num_arg; @@ -1186,7 +1184,7 @@ class CommandObjectThreadInfo : public CommandObjectIterateOverThreads { public: class CommandOptions : public Options { public: - CommandOptions() : Options() { OptionParsingStarting(nullptr); } + CommandOptions() { OptionParsingStarting(nullptr); } ~CommandOptions() override = default; @@ -1231,8 +1229,7 @@ public: "current thread.", "thread info", eCommandRequiresProcess | eCommandTryTargetAPILock | - eCommandProcessMustBeLaunched | eCommandProcessMustBePaused), - m_options() { + eCommandProcessMustBeLaunched | eCommandProcessMustBePaused) { m_add_return = false; } @@ -1331,7 +1328,7 @@ class CommandObjectThreadReturn : public CommandObjectRaw { public: class CommandOptions : public Options { public: - CommandOptions() : Options() { + CommandOptions() { // Keep default values of all options in one place: OptionParsingStarting // () OptionParsingStarting(nullptr); @@ -1386,8 +1383,7 @@ public: "thread return", eCommandRequiresFrame | eCommandTryTargetAPILock | eCommandProcessMustBeLaunched | - eCommandProcessMustBePaused), - m_options() { + eCommandProcessMustBePaused) { CommandArgumentEntry arg; CommandArgumentData expression_arg; @@ -1496,7 +1492,7 @@ class CommandObjectThreadJump : public CommandObjectParsed { public: class CommandOptions : public Options { public: - CommandOptions() : Options() { OptionParsingStarting(nullptr); } + CommandOptions() { OptionParsingStarting(nullptr); } ~CommandOptions() override = default; @@ -1556,8 +1552,7 @@ public: interpreter, "thread jump", "Sets the program counter to a new address.", "thread jump", eCommandRequiresFrame | eCommandTryTargetAPILock | - eCommandProcessMustBeLaunched | eCommandProcessMustBePaused), - m_options() {} + eCommandProcessMustBeLaunched | eCommandProcessMustBePaused) {} ~CommandObjectThreadJump() override = default; @@ -1633,7 +1628,7 @@ class CommandObjectThreadPlanList : public CommandObjectIterateOverThreads { public: class CommandOptions : public Options { public: - CommandOptions() : Options() { + CommandOptions() { // Keep default values of all options in one place: OptionParsingStarting // () OptionParsingStarting(nullptr); @@ -1695,8 +1690,7 @@ public: nullptr, eCommandRequiresProcess | eCommandRequiresThread | eCommandTryTargetAPILock | eCommandProcessMustBeLaunched | - eCommandProcessMustBePaused), - m_options() {} + eCommandProcessMustBePaused) {} ~CommandObjectThreadPlanList() override = default; @@ -2004,7 +1998,7 @@ class CommandObjectTraceDumpInstructions public: class CommandOptions : public Options { public: - CommandOptions() : Options() { OptionParsingStarting(nullptr); } + CommandOptions() { OptionParsingStarting(nullptr); } ~CommandOptions() override = default; @@ -2085,7 +2079,7 @@ public: eCommandRequiresProcess | eCommandTryTargetAPILock | eCommandProcessMustBeLaunched | eCommandProcessMustBePaused | eCommandProcessMustBeTraced), - m_options(), m_create_repeat_command_just_invoked(false) {} + m_create_repeat_command_just_invoked(false) {} ~CommandObjectTraceDumpInstructions() override = default; @@ -2165,7 +2159,7 @@ class CommandObjectTraceDumpInfo : public CommandObjectIterateOverThreads { public: class CommandOptions : public Options { public: - CommandOptions() : Options() { OptionParsingStarting(nullptr); } + CommandOptions() { OptionParsingStarting(nullptr); } ~CommandOptions() override = default; @@ -2213,8 +2207,7 @@ public: nullptr, eCommandRequiresProcess | eCommandTryTargetAPILock | eCommandProcessMustBeLaunched | eCommandProcessMustBePaused | - eCommandProcessMustBeTraced), - m_options() {} + eCommandProcessMustBeTraced) {} ~CommandObjectTraceDumpInfo() override = default; diff --git a/lldb/source/Commands/CommandObjectTrace.cpp b/lldb/source/Commands/CommandObjectTrace.cpp index 62ee48ca0546..53f1b0a32e60 100644 --- a/lldb/source/Commands/CommandObjectTrace.cpp +++ b/lldb/source/Commands/CommandObjectTrace.cpp @@ -40,7 +40,7 @@ class CommandObjectTraceLoad : public CommandObjectParsed { public: class CommandOptions : public Options { public: - CommandOptions() : Options() { OptionParsingStarting(nullptr); } + CommandOptions() { OptionParsingStarting(nullptr); } ~CommandOptions() override = default; @@ -74,8 +74,7 @@ public: CommandObjectTraceLoad(CommandInterpreter &interpreter) : CommandObjectParsed(interpreter, "trace load", "Load a processor trace session from a JSON file.", - "trace load"), - m_options() {} + "trace load") {} ~CommandObjectTraceLoad() override = default; @@ -139,7 +138,7 @@ class CommandObjectTraceDump : public CommandObjectParsed { public: class CommandOptions : public Options { public: - CommandOptions() : Options() { OptionParsingStarting(nullptr); } + CommandOptions() { OptionParsingStarting(nullptr); } ~CommandOptions() override = default; @@ -173,8 +172,7 @@ public: CommandObjectTraceDump(CommandInterpreter &interpreter) : CommandObjectParsed(interpreter, "trace dump", "Dump the loaded processor trace data.", - "trace dump"), - m_options() {} + "trace dump") {} ~CommandObjectTraceDump() override = default; @@ -205,7 +203,7 @@ class CommandObjectTraceSchema : public CommandObjectParsed { public: class CommandOptions : public Options { public: - CommandOptions() : Options() { OptionParsingStarting(nullptr); } + CommandOptions() { OptionParsingStarting(nullptr); } ~CommandOptions() override = default; @@ -240,8 +238,7 @@ public: : CommandObjectParsed(interpreter, "trace schema", "Show the schema of the given trace plugin.", "trace schema <plug-in>. Use the plug-in name " - "\"all\" to see all schemas.\n"), - m_options() {} + "\"all\" to see all schemas.\n") {} ~CommandObjectTraceSchema() override = default; diff --git a/lldb/source/Commands/CommandObjectType.cpp b/lldb/source/Commands/CommandObjectType.cpp index 0562b6be3cb5..f9e1d0f91fb7 100644 --- a/lldb/source/Commands/CommandObjectType.cpp +++ b/lldb/source/Commands/CommandObjectType.cpp @@ -69,7 +69,7 @@ public: SynthAddOptions(bool sptr, bool sref, bool casc, bool regx, std::string catg) : m_skip_pointers(sptr), m_skip_references(sref), m_cascade(casc), - m_regex(regx), m_target_types(), m_category(catg) {} + m_regex(regx), m_category(catg) {} typedef std::shared_ptr<SynthAddOptions> SharedPointer; }; @@ -103,7 +103,7 @@ class CommandObjectTypeSummaryAdd : public CommandObjectParsed, private: class CommandOptions : public Options { public: - CommandOptions(CommandInterpreter &interpreter) : Options() {} + CommandOptions(CommandInterpreter &interpreter) {} ~CommandOptions() override = default; @@ -286,7 +286,7 @@ class CommandObjectTypeSynthAdd : public CommandObjectParsed, private: class CommandOptions : public Options { public: - CommandOptions() : Options() {} + CommandOptions() {} ~CommandOptions() override = default; @@ -498,7 +498,7 @@ class CommandObjectTypeFormatAdd : public CommandObjectParsed { private: class CommandOptions : public OptionGroup { public: - CommandOptions() : OptionGroup() {} + CommandOptions() {} ~CommandOptions() override = default; @@ -571,8 +571,7 @@ public: CommandObjectTypeFormatAdd(CommandInterpreter &interpreter) : CommandObjectParsed(interpreter, "type format add", "Add a new formatting style for a type.", nullptr), - m_option_group(), m_format_options(eFormatInvalid), - m_command_options() { + m_format_options(eFormatInvalid) { CommandArgumentEntry type_arg; CommandArgumentData type_style_arg; @@ -708,7 +707,7 @@ class CommandObjectTypeFormatterDelete : public CommandObjectParsed { protected: class CommandOptions : public Options { public: - CommandOptions() : Options() {} + CommandOptions() {} ~CommandOptions() override = default; @@ -760,7 +759,7 @@ public: CommandObjectTypeFormatterDelete(CommandInterpreter &interpreter, uint32_t formatter_kind_mask, const char *name, const char *help) - : CommandObjectParsed(interpreter, name, help, nullptr), m_options(), + : CommandObjectParsed(interpreter, name, help, nullptr), m_formatter_kind_mask(formatter_kind_mask) { CommandArgumentEntry type_arg; CommandArgumentData type_style_arg; @@ -873,7 +872,7 @@ class CommandObjectTypeFormatterClear : public CommandObjectParsed { private: class CommandOptions : public Options { public: - CommandOptions() : Options() {} + CommandOptions() {} ~CommandOptions() override = default; @@ -914,7 +913,7 @@ public: CommandObjectTypeFormatterClear(CommandInterpreter &interpreter, uint32_t formatter_kind_mask, const char *name, const char *help) - : CommandObjectParsed(interpreter, name, help, nullptr), m_options(), + : CommandObjectParsed(interpreter, name, help, nullptr), m_formatter_kind_mask(formatter_kind_mask) {} ~CommandObjectTypeFormatterClear() override = default; @@ -1713,7 +1712,7 @@ class CommandObjectTypeCategoryDefine : public CommandObjectParsed { class CommandOptions : public Options { public: CommandOptions() - : Options(), m_define_enabled(false, false), + : m_define_enabled(false, false), m_cate_language(eLanguageTypeUnknown, eLanguageTypeUnknown) {} ~CommandOptions() override = default; @@ -1760,8 +1759,7 @@ public: CommandObjectTypeCategoryDefine(CommandInterpreter &interpreter) : CommandObjectParsed(interpreter, "type category define", "Define a new category as a source of formatters.", - nullptr), - m_options() { + nullptr) { CommandArgumentEntry type_arg; CommandArgumentData type_style_arg; @@ -1817,7 +1815,7 @@ protected: class CommandObjectTypeCategoryEnable : public CommandObjectParsed { class CommandOptions : public Options { public: - CommandOptions() : Options() {} + CommandOptions() {} ~CommandOptions() override = default; @@ -1863,8 +1861,7 @@ public: CommandObjectTypeCategoryEnable(CommandInterpreter &interpreter) : CommandObjectParsed(interpreter, "type category enable", "Enable a category as a source of formatters.", - nullptr), - m_options() { + nullptr) { CommandArgumentEntry type_arg; CommandArgumentData type_style_arg; @@ -1995,7 +1992,7 @@ protected: class CommandObjectTypeCategoryDisable : public CommandObjectParsed { class CommandOptions : public Options { public: - CommandOptions() : Options() {} + CommandOptions() {} ~CommandOptions() override = default; @@ -2041,8 +2038,7 @@ public: CommandObjectTypeCategoryDisable(CommandInterpreter &interpreter) : CommandObjectParsed(interpreter, "type category disable", "Disable a category as a source of formatters.", - nullptr), - m_options() { + nullptr) { CommandArgumentEntry type_arg; CommandArgumentData type_style_arg; @@ -2409,7 +2405,7 @@ private: typedef std::vector<std::string> option_vector; public: - CommandOptions() : Options() {} + CommandOptions() {} ~CommandOptions() override = default; @@ -2528,8 +2524,7 @@ private: public: CommandObjectTypeFilterAdd(CommandInterpreter &interpreter) : CommandObjectParsed(interpreter, "type filter add", - "Add a new filter for a type.", nullptr), - m_options() { + "Add a new filter for a type.", nullptr) { CommandArgumentEntry type_arg; CommandArgumentData type_style_arg; @@ -2666,7 +2661,7 @@ protected: class CommandOptions : public OptionGroup { public: - CommandOptions() : OptionGroup() {} + CommandOptions() {} ~CommandOptions() override = default; @@ -2716,8 +2711,7 @@ public: "Lookup types and declarations in the current target, " "following language-specific naming conventions.", "type lookup <type-specifier>", - eCommandRequiresTarget), - m_option_group(), m_command_options() { + eCommandRequiresTarget) { m_option_group.Append(&m_command_options); m_option_group.Finalize(); } diff --git a/lldb/source/Commands/CommandObjectWatchpoint.cpp b/lldb/source/Commands/CommandObjectWatchpoint.cpp index 9fbf036a19d1..9701553bdda9 100644 --- a/lldb/source/Commands/CommandObjectWatchpoint.cpp +++ b/lldb/source/Commands/CommandObjectWatchpoint.cpp @@ -149,8 +149,7 @@ public: : CommandObjectParsed( interpreter, "watchpoint list", "List all watchpoints at configurable levels of detail.", nullptr, - eCommandRequiresTarget), - m_options() { + eCommandRequiresTarget) { CommandArgumentEntry arg; CommandObject::AddIDsArgumentData(arg, eArgTypeWatchpointID, eArgTypeWatchpointIDRange); @@ -165,7 +164,7 @@ public: class CommandOptions : public Options { public: - CommandOptions() : Options() {} + CommandOptions() {} ~CommandOptions() override = default; @@ -432,8 +431,7 @@ public: : CommandObjectParsed(interpreter, "watchpoint delete", "Delete the specified watchpoint(s). If no " "watchpoints are specified, delete them all.", - nullptr, eCommandRequiresTarget), - m_options() { + nullptr, eCommandRequiresTarget) { CommandArgumentEntry arg; CommandObject::AddIDsArgumentData(arg, eArgTypeWatchpointID, eArgTypeWatchpointIDRange); @@ -456,7 +454,7 @@ public: class CommandOptions : public Options { public: - CommandOptions() : Options() {} + CommandOptions() {} ~CommandOptions() override = default; @@ -556,8 +554,7 @@ public: : CommandObjectParsed(interpreter, "watchpoint ignore", "Set ignore count on the specified watchpoint(s). " "If no watchpoints are specified, set them all.", - nullptr, eCommandRequiresTarget), - m_options() { + nullptr, eCommandRequiresTarget) { CommandArgumentEntry arg; CommandObject::AddIDsArgumentData(arg, eArgTypeWatchpointID, eArgTypeWatchpointIDRange); @@ -580,7 +577,7 @@ public: class CommandOptions : public Options { public: - CommandOptions() : Options() {} + CommandOptions() {} ~CommandOptions() override = default; @@ -682,8 +679,7 @@ public: "If no watchpoint is specified, act on the last created " "watchpoint. " "Passing an empty argument clears the modification.", - nullptr, eCommandRequiresTarget), - m_options() { + nullptr, eCommandRequiresTarget) { CommandArgumentEntry arg; CommandObject::AddIDsArgumentData(arg, eArgTypeWatchpointID, eArgTypeWatchpointIDRange); @@ -706,7 +702,7 @@ public: class CommandOptions : public Options { public: - CommandOptions() : Options(), m_condition() {} + CommandOptions() {} ~CommandOptions() override = default; @@ -813,8 +809,7 @@ public: "to free up resources.", nullptr, eCommandRequiresFrame | eCommandTryTargetAPILock | - eCommandProcessMustBeLaunched | eCommandProcessMustBePaused), - m_option_group(), m_option_watchpoint() { + eCommandProcessMustBeLaunched | eCommandProcessMustBePaused) { SetHelpLong( R"( Examples: @@ -1006,8 +1001,7 @@ public: "to free up resources.", "", eCommandRequiresFrame | eCommandTryTargetAPILock | - eCommandProcessMustBeLaunched | eCommandProcessMustBePaused), - m_option_group(), m_option_watchpoint() { + eCommandProcessMustBeLaunched | eCommandProcessMustBePaused) { SetHelpLong( R"( Examples: diff --git a/lldb/source/Commands/CommandObjectWatchpointCommand.cpp b/lldb/source/Commands/CommandObjectWatchpointCommand.cpp index 1f4e95366385..a429e568c61a 100644 --- a/lldb/source/Commands/CommandObjectWatchpointCommand.cpp +++ b/lldb/source/Commands/CommandObjectWatchpointCommand.cpp @@ -66,8 +66,7 @@ public: "commands previously added to it.", nullptr, eCommandRequiresTarget), IOHandlerDelegateMultiline("DONE", - IOHandlerDelegate::Completion::LLDBCommand), - m_options() { + IOHandlerDelegate::Completion::LLDBCommand) { SetHelpLong( R"( General information about entering watchpoint commands @@ -314,7 +313,7 @@ are no syntax errors may indicate that a function was declared but never called. class CommandOptions : public Options { public: - CommandOptions() : Options(), m_one_liner(), m_function_name() {} + CommandOptions() {} ~CommandOptions() override = default; diff --git a/lldb/source/Commands/CommandOptionsProcessLaunch.h b/lldb/source/Commands/CommandOptionsProcessLaunch.h index d18a23245080..7ab7fabe1050 100644 --- a/lldb/source/Commands/CommandOptionsProcessLaunch.h +++ b/lldb/source/Commands/CommandOptionsProcessLaunch.h @@ -18,7 +18,7 @@ namespace lldb_private { class CommandOptionsProcessLaunch : public lldb_private::OptionGroup { public: - CommandOptionsProcessLaunch() : lldb_private::OptionGroup() { + CommandOptionsProcessLaunch() { // Keep default values of all options in one place: OptionParsingStarting // () OptionParsingStarting(nullptr); diff --git a/lldb/source/Commands/Options.td b/lldb/source/Commands/Options.td index 3e89eb0f6bda..269c937296d5 100644 --- a/lldb/source/Commands/Options.td +++ b/lldb/source/Commands/Options.td @@ -18,8 +18,7 @@ let Command = "help" in { } let Command = "settings set" in { - def setset_global : Option<"global", "g">, Arg<"Filename">, - Completion<"DiskFile">, + def setset_global : Option<"global", "g">, Desc<"Apply the new value to the global default value.">; def setset_force : Option<"force", "f">, Desc<"Force an empty value to be accepted as the default.">; @@ -489,6 +488,8 @@ let Command = "memory read" in { "display data.">; def memory_read_force : Option<"force", "r">, Groups<[1,2,3]>, Desc<"Necessary if reading over target.max-memory-read-size bytes.">; + def memory_read_show_tags : Option<"show-tags", "\\x01">, Group<1>, + Desc<"Include memory tags in output (does not apply to binary output).">; } let Command = "memory find" in { diff --git a/lldb/source/Core/CoreProperties.td b/lldb/source/Core/CoreProperties.td index 038ed00905f1..399407075a7e 100644 --- a/lldb/source/Core/CoreProperties.td +++ b/lldb/source/Core/CoreProperties.td @@ -62,6 +62,10 @@ let Definition = "debugger" in { DefaultEnumValue<"eScriptLanguagePython">, EnumValues<"OptionEnumValues(g_language_enumerators)">, Desc<"The script language to be used for evaluating user-written scripts.">; + def REPLLanguage: Property<"repl-lang", "Language">, + Global, + DefaultEnumValue<"eLanguageTypeUnknown">, + Desc<"The language to use for the REPL.">; def StopDisassemblyCount: Property<"stop-disassembly-count", "SInt64">, Global, DefaultUnsignedValue<4>, diff --git a/lldb/source/Core/Debugger.cpp b/lldb/source/Core/Debugger.cpp index ae454fae3322..49cc21b65951 100644 --- a/lldb/source/Core/Debugger.cpp +++ b/lldb/source/Core/Debugger.cpp @@ -25,6 +25,7 @@ #include "lldb/Interpreter/CommandInterpreter.h" #include "lldb/Interpreter/CommandReturnObject.h" #include "lldb/Interpreter/OptionValue.h" +#include "lldb/Interpreter/OptionValueLanguage.h" #include "lldb/Interpreter/OptionValueProperties.h" #include "lldb/Interpreter/OptionValueSInt64.h" #include "lldb/Interpreter/OptionValueString.h" @@ -324,6 +325,20 @@ bool Debugger::SetScriptLanguage(lldb::ScriptLanguage script_lang) { script_lang); } +lldb::LanguageType Debugger::GetREPLLanguage() const { + const uint32_t idx = ePropertyREPLLanguage; + OptionValueLanguage *value = + m_collection_sp->GetPropertyAtIndexAsOptionValueLanguage(nullptr, idx); + if (value) + return value->GetCurrentValue(); + return LanguageType(); +} + +bool Debugger::SetREPLLanguage(lldb::LanguageType repl_lang) { + const uint32_t idx = ePropertyREPLLanguage; + return m_collection_sp->SetPropertyAtIndexAsLanguage(nullptr, idx, repl_lang); +} + uint32_t Debugger::GetTerminalWidth() const { const uint32_t idx = ePropertyTerminalWidth; return m_collection_sp->GetPropertyAtIndexAsSInt64( @@ -1753,17 +1768,20 @@ Status Debugger::RunREPL(LanguageType language, const char *repl_options) { Status err; FileSpec repl_executable; + if (language == eLanguageTypeUnknown) + language = GetREPLLanguage(); + if (language == eLanguageTypeUnknown) { LanguageSet repl_languages = Language::GetLanguagesSupportingREPLs(); if (auto single_lang = repl_languages.GetSingularLanguage()) { language = *single_lang; } else if (repl_languages.Empty()) { - err.SetErrorStringWithFormat( + err.SetErrorString( "LLDB isn't configured with REPL support for any languages."); return err; } else { - err.SetErrorStringWithFormat( + err.SetErrorString( "Multiple possible REPL languages. Please specify a language."); return err; } diff --git a/lldb/source/Core/DumpDataExtractor.cpp b/lldb/source/Core/DumpDataExtractor.cpp index 175ffef04a81..211e16a2e033 100644 --- a/lldb/source/Core/DumpDataExtractor.cpp +++ b/lldb/source/Core/DumpDataExtractor.cpp @@ -17,6 +17,9 @@ #include "lldb/Target/ABI.h" #include "lldb/Target/ExecutionContext.h" #include "lldb/Target/ExecutionContextScope.h" +#include "lldb/Target/MemoryRegionInfo.h" +#include "lldb/Target/MemoryTagManager.h" +#include "lldb/Target/MemoryTagMap.h" #include "lldb/Target/Process.h" #include "lldb/Target/SectionLoadList.h" #include "lldb/Target/Target.h" @@ -253,6 +256,85 @@ void DumpFloatingPoint(std::ostringstream &ss, FloatT f) { ss << f; } +static llvm::Optional<MemoryTagMap> +GetMemoryTags(lldb::addr_t addr, size_t length, + ExecutionContextScope *exe_scope) { + assert(addr != LLDB_INVALID_ADDRESS); + + if (!exe_scope) + return llvm::None; + + TargetSP target_sp = exe_scope->CalculateTarget(); + if (!target_sp) + return llvm::None; + + ProcessSP process_sp = target_sp->CalculateProcess(); + if (!process_sp) + return llvm::None; + + llvm::Expected<const MemoryTagManager *> tag_manager_or_err = + process_sp->GetMemoryTagManager(); + if (!tag_manager_or_err) { + llvm::consumeError(tag_manager_or_err.takeError()); + return llvm::None; + } + + MemoryRegionInfos memory_regions; + // Don't check return status, list will be just empty if an error happened. + process_sp->GetMemoryRegions(memory_regions); + + llvm::Expected<std::vector<MemoryTagManager::TagRange>> tagged_ranges_or_err = + (*tag_manager_or_err) + ->MakeTaggedRanges(addr, addr + length, memory_regions); + // Here we know that our range will not be inverted but we must still check + // for an error. + if (!tagged_ranges_or_err) { + llvm::consumeError(tagged_ranges_or_err.takeError()); + return llvm::None; + } + if (tagged_ranges_or_err->empty()) + return llvm::None; + + MemoryTagMap memory_tag_map(*tag_manager_or_err); + for (const MemoryTagManager::TagRange &range : *tagged_ranges_or_err) { + llvm::Expected<std::vector<lldb::addr_t>> tags_or_err = + process_sp->ReadMemoryTags(range.GetRangeBase(), range.GetByteSize()); + + if (tags_or_err) + memory_tag_map.InsertTags(range.GetRangeBase(), *tags_or_err); + else + llvm::consumeError(tags_or_err.takeError()); + } + + if (memory_tag_map.Empty()) + return llvm::None; + + return memory_tag_map; +} + +static void +printMemoryTags(const DataExtractor &DE, Stream *s, lldb::addr_t addr, + size_t len, + const llvm::Optional<MemoryTagMap> &memory_tag_map) { + std::vector<llvm::Optional<lldb::addr_t>> tags = + memory_tag_map->GetTags(addr, len); + + // Only print if there is at least one tag for this line + if (tags.empty()) + return; + + s->Printf(" (tag%s:", tags.size() > 1 ? "s" : ""); + // Some granules may not be tagged but print something for them + // so that the ordering remains intact. + for (auto tag : tags) { + if (tag) + s->Printf(" 0x%" PRIx64, *tag); + else + s->PutCString(" <no tag>"); + } + s->PutCString(")"); +} + lldb::offset_t lldb_private::DumpDataExtractor( const DataExtractor &DE, Stream *s, offset_t start_offset, lldb::Format item_format, size_t item_byte_size, size_t item_count, @@ -261,7 +343,7 @@ lldb::offset_t lldb_private::DumpDataExtractor( // non-zero, the value is a bitfield uint32_t item_bit_offset, // If "item_bit_size" is non-zero, this is the // shift amount to apply to a bitfield - ExecutionContextScope *exe_scope) { + ExecutionContextScope *exe_scope, bool show_memory_tags) { if (s == nullptr) return start_offset; @@ -272,6 +354,11 @@ lldb::offset_t lldb_private::DumpDataExtractor( offset_t offset = start_offset; + llvm::Optional<MemoryTagMap> memory_tag_map = llvm::None; + if (show_memory_tags && base_addr != LLDB_INVALID_ADDRESS) + memory_tag_map = + GetMemoryTags(base_addr, DE.GetByteSize() - offset, exe_scope); + if (item_format == eFormatInstruction) return DumpInstructions(DE, s, exe_scope, start_offset, base_addr, item_count); @@ -283,7 +370,10 @@ lldb::offset_t lldb_private::DumpDataExtractor( lldb::offset_t line_start_offset = start_offset; for (uint32_t count = 0; DE.ValidOffset(offset) && count < item_count; ++count) { + // If we are at the beginning or end of a line + // Note that the last line is handled outside this for loop. if ((count % num_per_line) == 0) { + // If we are at the end of a line if (count > 0) { if (item_format == eFormatBytesWithASCII && offset > line_start_offset) { @@ -295,6 +385,15 @@ lldb::offset_t lldb_private::DumpDataExtractor( offset - line_start_offset, SIZE_MAX, LLDB_INVALID_ADDRESS, 0, 0); } + + if (base_addr != LLDB_INVALID_ADDRESS && memory_tag_map) { + size_t line_len = offset - line_start_offset; + lldb::addr_t line_base = + base_addr + + (offset - start_offset - line_len) / DE.getTargetByteSize(); + printMemoryTags(DE, s, line_base, line_len, memory_tag_map); + } + s->EOL(); } if (base_addr != LLDB_INVALID_ADDRESS) @@ -796,14 +895,28 @@ lldb::offset_t lldb_private::DumpDataExtractor( } } - if (item_format == eFormatBytesWithASCII && offset > line_start_offset) { - s->Printf("%*s", static_cast<int>( - (num_per_line - (offset - line_start_offset)) * 3 + 2), - ""); - DumpDataExtractor(DE, s, line_start_offset, eFormatCharPrintable, 1, - offset - line_start_offset, SIZE_MAX, - LLDB_INVALID_ADDRESS, 0, 0); + // If anything was printed we want to catch the end of the last line. + // Since we will exit the for loop above before we get a chance to append to + // it normally. + if (offset > line_start_offset) { + if (item_format == eFormatBytesWithASCII) { + s->Printf("%*s", + static_cast<int>( + (num_per_line - (offset - line_start_offset)) * 3 + 2), + ""); + DumpDataExtractor(DE, s, line_start_offset, eFormatCharPrintable, 1, + offset - line_start_offset, SIZE_MAX, + LLDB_INVALID_ADDRESS, 0, 0); + } + + if (base_addr != LLDB_INVALID_ADDRESS && memory_tag_map) { + size_t line_len = offset - line_start_offset; + lldb::addr_t line_base = base_addr + (offset - start_offset - line_len) / + DE.getTargetByteSize(); + printMemoryTags(DE, s, line_base, line_len, memory_tag_map); + } } + return offset; // Return the offset at which we ended up } diff --git a/lldb/source/Core/IOHandlerCursesGUI.cpp b/lldb/source/Core/IOHandlerCursesGUI.cpp index 60207f75b7df..b37e84a13c5e 100644 --- a/lldb/source/Core/IOHandlerCursesGUI.cpp +++ b/lldb/source/Core/IOHandlerCursesGUI.cpp @@ -78,8 +78,6 @@ using namespace lldb; using namespace lldb_private; -using llvm::None; -using llvm::Optional; using llvm::StringRef; // we may want curses to be disabled for some builds for instance, windows diff --git a/lldb/source/Core/Mangled.cpp b/lldb/source/Core/Mangled.cpp index c8aacdefefa2..4e10324401dc 100644 --- a/lldb/source/Core/Mangled.cpp +++ b/lldb/source/Core/Mangled.cpp @@ -70,23 +70,13 @@ Mangled::Mangled(llvm::StringRef name) { SetValue(ConstString(name)); } -// Convert to pointer operator. This allows code to check any Mangled objects +// Convert to bool operator. This allows code to check any Mangled objects // to see if they contain anything valid using code such as: // // Mangled mangled(...); // if (mangled) // { ... -Mangled::operator void *() const { - return (m_mangled) ? const_cast<Mangled *>(this) : nullptr; -} - -// Logical NOT operator. This allows code to check any Mangled objects to see -// if they are invalid using code such as: -// -// Mangled mangled(...); -// if (!file_spec) -// { ... -bool Mangled::operator!() const { return !m_mangled; } +Mangled::operator bool() const { return m_mangled || m_demangled; } // Clear the mangled and demangled values. void Mangled::Clear() { diff --git a/lldb/source/DataFormatters/FormatManager.cpp b/lldb/source/DataFormatters/FormatManager.cpp index 0ef5f0adc832..f07bb9a7136a 100644 --- a/lldb/source/DataFormatters/FormatManager.cpp +++ b/lldb/source/DataFormatters/FormatManager.cpp @@ -730,7 +730,7 @@ void FormatManager::LoadSystemFormatters() { GetCategory(m_system_category_name); sys_category_sp->GetRegexTypeSummariesContainer()->Add( - RegularExpression(R"(^((un)?signed )?char ?(\*|\[\])$)"), string_format); + RegularExpression(R"(^(unsigned )?char ?(\*|\[\])$)"), string_format); sys_category_sp->GetRegexTypeSummariesContainer()->Add( std::move(any_size_char_arr), string_array_format); diff --git a/lldb/source/Expression/DWARFExpression.cpp b/lldb/source/Expression/DWARFExpression.cpp index 890d8b5d3107..ccd41fb4a94e 100644 --- a/lldb/source/Expression/DWARFExpression.cpp +++ b/lldb/source/Expression/DWARFExpression.cpp @@ -825,7 +825,7 @@ static bool Evaluate_DW_OP_entry_value(std::vector<Value> &stack, const DWARFExpression ¶m_expr = matched_param->LocationInCaller; if (!param_expr.Evaluate(&parent_exe_ctx, parent_frame->GetRegisterContext().get(), - /*loclist_base_addr=*/LLDB_INVALID_ADDRESS, + /*loclist_base_load_addr=*/LLDB_INVALID_ADDRESS, /*initial_value_ptr=*/nullptr, /*object_address_ptr=*/nullptr, result, error_ptr)) { LLDB_LOG(log, diff --git a/lldb/source/Expression/Materializer.cpp b/lldb/source/Expression/Materializer.cpp index 3945f3a70f75..d40365d60fb3 100644 --- a/lldb/source/Expression/Materializer.cpp +++ b/lldb/source/Expression/Materializer.cpp @@ -700,7 +700,7 @@ public: DumpHexBytes(&dump_stream, data.GetBytes(), data.GetByteSize(), 16, load_addr); - lldb::offset_t offset; + lldb::offset_t offset = 0; ptr = extractor.GetAddress(&offset); @@ -978,7 +978,7 @@ public: DumpHexBytes(&dump_stream, data.GetBytes(), data.GetByteSize(), 16, load_addr); - lldb::offset_t offset; + lldb::offset_t offset = 0; ptr = extractor.GetAddress(&offset); diff --git a/lldb/source/Host/common/Host.cpp b/lldb/source/Host/common/Host.cpp index d14ebe99fd15..53a096c617df 100644 --- a/lldb/source/Host/common/Host.cpp +++ b/lldb/source/Host/common/Host.cpp @@ -191,7 +191,7 @@ static thread_result_t MonitorChildProcessThreadFunction(void *arg) { ::sigaction(SIGUSR1, &sigUsr1Action, nullptr); #endif // __linux__ - while (1) { + while (true) { log = lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_PROCESS); LLDB_LOGF(log, "%s ::waitpid (pid = %" PRIi32 ", &status, options = %i)...", function, pid, options); diff --git a/lldb/source/Host/common/HostNativeThreadBase.cpp b/lldb/source/Host/common/HostNativeThreadBase.cpp index b15160b143ca..b8223e3ec42a 100644 --- a/lldb/source/Host/common/HostNativeThreadBase.cpp +++ b/lldb/source/Host/common/HostNativeThreadBase.cpp @@ -18,7 +18,7 @@ using namespace lldb; using namespace lldb_private; HostNativeThreadBase::HostNativeThreadBase(thread_t thread) - : m_thread(thread), m_result(0) {} + : m_thread(thread), m_result(0) {} // NOLINT(modernize-use-nullptr) lldb::thread_t HostNativeThreadBase::GetSystemHandle() const { return m_thread; @@ -34,7 +34,7 @@ bool HostNativeThreadBase::IsJoinable() const { void HostNativeThreadBase::Reset() { m_thread = LLDB_INVALID_HOST_THREAD; - m_result = 0; + m_result = 0; // NOLINT(modernize-use-nullptr) } bool HostNativeThreadBase::EqualsThread(lldb::thread_t thread) const { @@ -44,7 +44,7 @@ bool HostNativeThreadBase::EqualsThread(lldb::thread_t thread) const { lldb::thread_t HostNativeThreadBase::Release() { lldb::thread_t result = m_thread; m_thread = LLDB_INVALID_HOST_THREAD; - m_result = 0; + m_result = 0; // NOLINT(modernize-use-nullptr) return result; } diff --git a/lldb/source/Host/common/Socket.cpp b/lldb/source/Host/common/Socket.cpp index cc0659797530..d8b8f54a6468 100644 --- a/lldb/source/Host/common/Socket.cpp +++ b/lldb/source/Host/common/Socket.cpp @@ -18,6 +18,7 @@ #include "llvm/ADT/STLExtras.h" #include "llvm/Support/Errno.h" #include "llvm/Support/Error.h" +#include "llvm/Support/Regex.h" #include "llvm/Support/WindowsError.h" #if LLDB_ENABLE_POSIX @@ -281,9 +282,9 @@ Status Socket::Close() { static_cast<void *>(this), static_cast<uint64_t>(m_socket)); #if defined(_WIN32) - bool success = !!closesocket(m_socket); + bool success = closesocket(m_socket) == 0; #else - bool success = !!::close(m_socket); + bool success = ::close(m_socket) == 0; #endif // A reference to a FD was passed in, set it to an invalid value m_socket = kInvalidSocketValue; diff --git a/lldb/source/Host/common/Terminal.cpp b/lldb/source/Host/common/Terminal.cpp index 2a1c12e667bc..831e9dff4eb1 100644 --- a/lldb/source/Host/common/Terminal.cpp +++ b/lldb/source/Host/common/Terminal.cpp @@ -417,8 +417,8 @@ bool TerminalState::Save(Terminal term, bool save_process_group) { Clear(); m_tty = term; if (m_tty.IsATerminal()) { - int fd = m_tty.GetFileDescriptor(); #if LLDB_ENABLE_POSIX + int fd = m_tty.GetFileDescriptor(); m_tflags = ::fcntl(fd, F_GETFL, 0); #if LLDB_ENABLE_TERMIOS std::unique_ptr<Terminal::Data> new_data{new Terminal::Data()}; diff --git a/lldb/source/Host/common/XML.cpp b/lldb/source/Host/common/XML.cpp index 79128b98dc38..2d48175a8234 100644 --- a/lldb/source/Host/common/XML.cpp +++ b/lldb/source/Host/common/XML.cpp @@ -130,22 +130,25 @@ XMLNode XMLNode::GetChild() const { #endif } -llvm::StringRef XMLNode::GetAttributeValue(const char *name, - const char *fail_value) const { - const char *attr_value = nullptr; +std::string XMLNode::GetAttributeValue(const char *name, + const char *fail_value) const { + std::string attr_value; #if LLDB_ENABLE_LIBXML2 - - if (IsValid()) - attr_value = (const char *)xmlGetProp(m_node, (const xmlChar *)name); - else - attr_value = fail_value; + if (IsValid()) { + xmlChar *value = xmlGetProp(m_node, (const xmlChar *)name); + if (value) { + attr_value = (const char *)value; + xmlFree(value); + } + } else { + if (fail_value) + attr_value = fail_value; + } #else - attr_value = fail_value; + if (fail_value) + attr_value = fail_value; #endif - if (attr_value) - return llvm::StringRef(attr_value); - else - return llvm::StringRef(); + return attr_value; } bool XMLNode::GetAttributeValueAsUnsigned(const char *name, uint64_t &value, diff --git a/lldb/source/Host/posix/ProcessLauncherPosixFork.cpp b/lldb/source/Host/posix/ProcessLauncherPosixFork.cpp index 2f08b9fa8857..635dbb14a027 100644 --- a/lldb/source/Host/posix/ProcessLauncherPosixFork.cpp +++ b/lldb/source/Host/posix/ProcessLauncherPosixFork.cpp @@ -38,43 +38,40 @@ using namespace lldb; using namespace lldb_private; -static void FixupEnvironment(Environment &env) { -#ifdef __ANDROID__ - // If there is no PATH variable specified inside the environment then set the - // path to /system/bin. It is required because the default path used by - // execve() is wrong on android. - env.try_emplace("PATH", "/system/bin"); -#endif +// Begin code running in the child process +// NB: This code needs to be async-signal safe, since we're invoking fork from +// multithreaded contexts. + +static void write_string(int error_fd, const char *str) { + int r = write(error_fd, str, strlen(str)); + (void)r; } [[noreturn]] static void ExitWithError(int error_fd, const char *operation) { int err = errno; - llvm::raw_fd_ostream os(error_fd, true); - os << operation << " failed: " << llvm::sys::StrError(err); - os.flush(); + write_string(error_fd, operation); + write_string(error_fd, " failed: "); + // strerror is not guaranteed to be async-signal safe, but it usually is. + write_string(error_fd, strerror(err)); _exit(1); } -static void DisableASLRIfRequested(int error_fd, const ProcessLaunchInfo &info) { +static void DisableASLR(int error_fd) { #if defined(__linux__) - if (info.GetFlags().Test(lldb::eLaunchFlagDisableASLR)) { - const unsigned long personality_get_current = 0xffffffff; - int value = personality(personality_get_current); - if (value == -1) - ExitWithError(error_fd, "personality get"); - - value = personality(ADDR_NO_RANDOMIZE | value); - if (value == -1) - ExitWithError(error_fd, "personality set"); - } + const unsigned long personality_get_current = 0xffffffff; + int value = personality(personality_get_current); + if (value == -1) + ExitWithError(error_fd, "personality get"); + + value = personality(ADDR_NO_RANDOMIZE | value); + if (value == -1) + ExitWithError(error_fd, "personality set"); #endif } -static void DupDescriptor(int error_fd, const FileSpec &file_spec, int fd, - int flags) { - int target_fd = llvm::sys::RetryAfterSignal(-1, ::open, - file_spec.GetCString(), flags, 0666); +static void DupDescriptor(int error_fd, const char *file, int fd, int flags) { + int target_fd = llvm::sys::RetryAfterSignal(-1, ::open, file, flags, 0666); if (target_fd == -1) ExitWithError(error_fd, "DupDescriptor-open"); @@ -88,44 +85,67 @@ static void DupDescriptor(int error_fd, const FileSpec &file_spec, int fd, ::close(target_fd); } -[[noreturn]] static void ChildFunc(int error_fd, - const ProcessLaunchInfo &info) { - if (info.GetFlags().Test(eLaunchFlagLaunchInSeparateProcessGroup)) { +namespace { +struct ForkFileAction { + ForkFileAction(const FileAction &act); + + FileAction::Action action; + int fd; + std::string path; + int arg; +}; + +struct ForkLaunchInfo { + ForkLaunchInfo(const ProcessLaunchInfo &info); + + bool separate_process_group; + bool debug; + bool disable_aslr; + std::string wd; + const char **argv; + Environment::Envp envp; + std::vector<ForkFileAction> actions; + + bool has_action(int fd) const { + for (const ForkFileAction &action : actions) { + if (action.fd == fd) + return true; + } + return false; + } +}; +} // namespace + +[[noreturn]] static void ChildFunc(int error_fd, const ForkLaunchInfo &info) { + if (info.separate_process_group) { if (setpgid(0, 0) != 0) ExitWithError(error_fd, "setpgid"); } - for (size_t i = 0; i < info.GetNumFileActions(); ++i) { - const FileAction &action = *info.GetFileActionAtIndex(i); - switch (action.GetAction()) { + for (const ForkFileAction &action : info.actions) { + switch (action.action) { case FileAction::eFileActionClose: - if (close(action.GetFD()) != 0) + if (close(action.fd) != 0) ExitWithError(error_fd, "close"); break; case FileAction::eFileActionDuplicate: - if (dup2(action.GetFD(), action.GetActionArgument()) == -1) + if (dup2(action.fd, action.arg) == -1) ExitWithError(error_fd, "dup2"); break; case FileAction::eFileActionOpen: - DupDescriptor(error_fd, action.GetFileSpec(), action.GetFD(), - action.GetActionArgument()); + DupDescriptor(error_fd, action.path.c_str(), action.fd, action.arg); break; case FileAction::eFileActionNone: break; } } - const char **argv = info.GetArguments().GetConstArgumentVector(); - // Change working directory - if (info.GetWorkingDirectory() && - 0 != ::chdir(info.GetWorkingDirectory().GetCString())) + if (!info.wd.empty() && 0 != ::chdir(info.wd.c_str())) ExitWithError(error_fd, "chdir"); - DisableASLRIfRequested(error_fd, info); - Environment env = info.GetEnvironment(); - FixupEnvironment(env); - Environment::Envp envp = env.getEnvp(); + if (info.disable_aslr) + DisableASLR(error_fd); // Clear the signal mask to prevent the child from being affected by any // masking done by the parent. @@ -134,7 +154,7 @@ static void DupDescriptor(int error_fd, const FileSpec &file_spec, int fd, pthread_sigmask(SIG_SETMASK, &set, nullptr) != 0) ExitWithError(error_fd, "pthread_sigmask"); - if (info.GetFlags().Test(eLaunchFlagDebug)) { + if (info.debug) { // Do not inherit setgid powers. if (setgid(getgid()) != 0) ExitWithError(error_fd, "setgid"); @@ -143,6 +163,8 @@ static void DupDescriptor(int error_fd, const FileSpec &file_spec, int fd, // Close everything besides stdin, stdout, and stderr that has no file // action to avoid leaking. Only do this when debugging, as elsewhere we // actually rely on passing open descriptors to child processes. + // NB: This code is not async-signal safe, but we currently do not launch + // processes for debugging from within multithreaded contexts. const llvm::StringRef proc_fd_path = "/proc/self/fd"; std::error_code ec; @@ -157,7 +179,7 @@ static void DupDescriptor(int error_fd, const FileSpec &file_spec, int fd, // Don't close first three entries since they are stdin, stdout and // stderr. - if (fd > 2 && !info.GetFileActionForFD(fd) && fd != error_fd) + if (fd > 2 && !info.has_action(fd) && fd != error_fd) files_to_close.push_back(fd); } for (int file_to_close : files_to_close) @@ -166,7 +188,7 @@ static void DupDescriptor(int error_fd, const FileSpec &file_spec, int fd, // Since /proc/self/fd didn't work, trying the slow way instead. int max_fd = sysconf(_SC_OPEN_MAX); for (int fd = 3; fd < max_fd; ++fd) - if (!info.GetFileActionForFD(fd) && fd != error_fd) + if (!info.has_action(fd) && fd != error_fd) close(fd); } @@ -176,7 +198,7 @@ static void DupDescriptor(int error_fd, const FileSpec &file_spec, int fd, } // Execute. We should never return... - execve(argv[0], const_cast<char *const *>(argv), envp); + execve(info.argv[0], const_cast<char *const *>(info.argv), info.envp); #if defined(__linux__) if (errno == ETXTBSY) { @@ -189,7 +211,7 @@ static void DupDescriptor(int error_fd, const FileSpec &file_spec, int fd, // Since this state should clear up quickly, wait a while and then give it // one more go. usleep(50000); - execve(argv[0], const_cast<char *const *>(argv), envp); + execve(info.argv[0], const_cast<char *const *>(info.argv), info.envp); } #endif @@ -198,12 +220,43 @@ static void DupDescriptor(int error_fd, const FileSpec &file_spec, int fd, ExitWithError(error_fd, "execve"); } +// End of code running in the child process. + +ForkFileAction::ForkFileAction(const FileAction &act) + : action(act.GetAction()), fd(act.GetFD()), path(act.GetPath().str()), + arg(act.GetActionArgument()) {} + +static std::vector<ForkFileAction> +MakeForkActions(const ProcessLaunchInfo &info) { + std::vector<ForkFileAction> result; + for (size_t i = 0; i < info.GetNumFileActions(); ++i) + result.emplace_back(*info.GetFileActionAtIndex(i)); + return result; +} + +static Environment::Envp FixupEnvironment(Environment env) { +#ifdef __ANDROID__ + // If there is no PATH variable specified inside the environment then set the + // path to /system/bin. It is required because the default path used by + // execve() is wrong on android. + env.try_emplace("PATH", "/system/bin"); +#endif + return env.getEnvp(); +} + +ForkLaunchInfo::ForkLaunchInfo(const ProcessLaunchInfo &info) + : separate_process_group( + info.GetFlags().Test(eLaunchFlagLaunchInSeparateProcessGroup)), + debug(info.GetFlags().Test(eLaunchFlagDebug)), + disable_aslr(info.GetFlags().Test(eLaunchFlagDisableASLR)), + wd(info.GetWorkingDirectory().GetPath()), + argv(info.GetArguments().GetConstArgumentVector()), + envp(FixupEnvironment(info.GetEnvironment())), + actions(MakeForkActions(info)) {} + HostProcess ProcessLauncherPosixFork::LaunchProcess(const ProcessLaunchInfo &launch_info, Status &error) { - char exe_path[PATH_MAX]; - launch_info.GetExecutableFile().GetPath(exe_path, sizeof(exe_path)); - // A pipe used by the child process to report errors. PipePosix pipe; const bool child_processes_inherit = false; @@ -211,6 +264,8 @@ ProcessLauncherPosixFork::LaunchProcess(const ProcessLaunchInfo &launch_info, if (error.Fail()) return HostProcess(); + const ForkLaunchInfo fork_launch_info(launch_info); + ::pid_t pid = ::fork(); if (pid == -1) { // Fork failed @@ -221,7 +276,7 @@ ProcessLauncherPosixFork::LaunchProcess(const ProcessLaunchInfo &launch_info, if (pid == 0) { // child process pipe.CloseReadFileDescriptor(); - ChildFunc(pipe.ReleaseWriteFileDescriptor(), launch_info); + ChildFunc(pipe.ReleaseWriteFileDescriptor(), fork_launch_info); } // parent process diff --git a/lldb/source/Interpreter/CommandInterpreter.cpp b/lldb/source/Interpreter/CommandInterpreter.cpp index bd03f18b47c0..59c23716bf89 100644 --- a/lldb/source/Interpreter/CommandInterpreter.cpp +++ b/lldb/source/Interpreter/CommandInterpreter.cpp @@ -2259,13 +2259,15 @@ static void GetHomeInitFile(llvm::SmallVectorImpl<char> &init_file, FileSystem::Instance().Resolve(init_file); } -static void GetHomeREPLInitFile(llvm::SmallVectorImpl<char> &init_file) { - LanguageSet repl_languages = Language::GetLanguagesSupportingREPLs(); - LanguageType language = eLanguageTypeUnknown; - if (auto main_repl_language = repl_languages.GetSingularLanguage()) - language = *main_repl_language; - else - return; +static void GetHomeREPLInitFile(llvm::SmallVectorImpl<char> &init_file, + LanguageType language) { + if (language == eLanguageTypeUnknown) { + LanguageSet repl_languages = Language::GetLanguagesSupportingREPLs(); + if (auto main_repl_language = repl_languages.GetSingularLanguage()) + language = *main_repl_language; + else + return; + } std::string init_file_name = (llvm::Twine(".lldbinit-") + @@ -2355,7 +2357,7 @@ void CommandInterpreter::SourceInitFileHome(CommandReturnObject &result, llvm::SmallString<128> init_file; if (is_repl) - GetHomeREPLInitFile(init_file); + GetHomeREPLInitFile(init_file, GetDebugger().GetREPLLanguage()); if (init_file.empty()) GetHomeInitFile(init_file); @@ -2839,12 +2841,10 @@ void CommandInterpreter::OutputHelpText(Stream &strm, llvm::StringRef word_text, void CommandInterpreter::FindCommandsForApropos( llvm::StringRef search_word, StringList &commands_found, - StringList &commands_help, CommandObject::CommandMap &command_map) { - CommandObject::CommandMap::const_iterator pos; - - for (pos = command_map.begin(); pos != command_map.end(); ++pos) { - llvm::StringRef command_name = pos->first; - CommandObject *cmd_obj = pos->second.get(); + StringList &commands_help, const CommandObject::CommandMap &command_map) { + for (const auto &pair : command_map) { + llvm::StringRef command_name = pair.first; + CommandObject *cmd_obj = pair.second.get(); const bool search_short_help = true; const bool search_long_help = false; @@ -2854,14 +2854,19 @@ void CommandInterpreter::FindCommandsForApropos( cmd_obj->HelpTextContainsWord(search_word, search_short_help, search_long_help, search_syntax, search_options)) { - commands_found.AppendString(cmd_obj->GetCommandName()); + commands_found.AppendString(command_name); commands_help.AppendString(cmd_obj->GetHelp()); } - if (cmd_obj->IsMultiwordObject()) { - CommandObjectMultiword *cmd_multiword = cmd_obj->GetAsMultiwordCommand(); - FindCommandsForApropos(search_word, commands_found, commands_help, - cmd_multiword->GetSubcommandDictionary()); + if (auto *multiword_cmd = cmd_obj->GetAsMultiwordCommand()) { + StringList subcommands_found; + FindCommandsForApropos(search_word, subcommands_found, commands_help, + multiword_cmd->GetSubcommandDictionary()); + for (const auto &subcommand_name : subcommands_found) { + std::string qualified_name = + (command_name + " " + subcommand_name).str(); + commands_found.AppendString(qualified_name); + } } } } diff --git a/lldb/source/Interpreter/OptionValueProperties.cpp b/lldb/source/Interpreter/OptionValueProperties.cpp index 1a8f2f0ab180..6e6580574edf 100644 --- a/lldb/source/Interpreter/OptionValueProperties.cpp +++ b/lldb/source/Interpreter/OptionValueProperties.cpp @@ -226,6 +226,17 @@ OptionValueProperties::GetPropertyAtIndexAsOptionValueLanguage( return nullptr; } +bool OptionValueProperties::SetPropertyAtIndexAsLanguage( + const ExecutionContext *exe_ctx, uint32_t idx, const LanguageType lang) { + const Property *property = GetPropertyAtIndex(exe_ctx, true, idx); + if (property) { + OptionValue *value = property->GetValue().get(); + if (value) + return value->SetLanguageValue(lang); + } + return false; +} + bool OptionValueProperties::GetPropertyAtIndexAsArgs( const ExecutionContext *exe_ctx, uint32_t idx, Args &args) const { const Property *property = GetPropertyAtIndex(exe_ctx, false, idx); diff --git a/lldb/source/Interpreter/Options.cpp b/lldb/source/Interpreter/Options.cpp index 4aa298f0382b..feebe338bc9a 100644 --- a/lldb/source/Interpreter/Options.cpp +++ b/lldb/source/Interpreter/Options.cpp @@ -403,7 +403,12 @@ void Options::GenerateOptionUsage(Stream &strm, CommandObject *cmd, } else name = ""; - strm.PutCString("\nCommand Options Usage:\n"); + const uint32_t num_options = NumCommandOptions(); + if (num_options == 0) + return; + + if (!only_print_args) + strm.PutCString("\nCommand Options Usage:\n"); strm.IndentMore(2); @@ -413,10 +418,6 @@ void Options::GenerateOptionUsage(Stream &strm, CommandObject *cmd, // [options-for-level-1] // etc. - const uint32_t num_options = NumCommandOptions(); - if (num_options == 0) - return; - uint32_t num_option_sets = GetRequiredOptions().size(); uint32_t i; @@ -531,9 +532,9 @@ void Options::GenerateOptionUsage(Stream &strm, CommandObject *cmd, strm << " " << arguments_str.GetString(); } - strm.Printf("\n\n"); - if (!only_print_args) { + strm.Printf("\n\n"); + // Now print out all the detailed information about the various options: // long form, short form and help text: // -short <argument> ( --long_name <argument> ) diff --git a/lldb/source/Plugins/Disassembler/LLVMC/DisassemblerLLVMC.cpp b/lldb/source/Plugins/Disassembler/LLVMC/DisassemblerLLVMC.cpp index 2cf32bdd3800..8c54219f0a14 100644 --- a/lldb/source/Plugins/Disassembler/LLVMC/DisassemblerLLVMC.cpp +++ b/lldb/source/Plugins/Disassembler/LLVMC/DisassemblerLLVMC.cpp @@ -1111,7 +1111,7 @@ DisassemblerLLVMC::DisassemblerLLVMC(const ArchSpec &arch, triple.getSubArch() == llvm::Triple::NoSubArch) triple.setArchName("armv8.7a"); - std::string features_str = ""; + std::string features_str; const char *triple_str = triple.getTriple().c_str(); // ARM Cortex M0-M7 devices only execute thumb instructions diff --git a/lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp b/lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp index d9cbcce22c52..188b6da7a712 100644 --- a/lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp +++ b/lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp @@ -338,7 +338,7 @@ bool DynamicLoaderPOSIXDYLD::SetRendezvousBreakpoint() { dyld_break = target.CreateBreakpoint( &containingModules, /*containingSourceFiles=*/nullptr, DebugStateCandidates, eFunctionNameTypeFull, eLanguageTypeC, - /*offset=*/0, + /*m_offset=*/0, /*skip_prologue=*/eLazyBoolNo, /*internal=*/true, /*request_hardware=*/false); @@ -348,7 +348,7 @@ bool DynamicLoaderPOSIXDYLD::SetRendezvousBreakpoint() { dyld_break = target.CreateBreakpoint( &containingModules, /*containingSourceFiles=*/nullptr, DebugStateCandidates, eFunctionNameTypeFull, eLanguageTypeC, - /*offset=*/0, + /*m_offset=*/0, /*skip_prologue=*/eLazyBoolNo, /*internal=*/true, /*request_hardware=*/false); diff --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp b/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp index a0cff3cc9bf8..51f34369c383 100644 --- a/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp +++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp @@ -995,7 +995,8 @@ public: void ProcessOverloadCandidates(Sema &S, unsigned CurrentArg, OverloadCandidate *Candidates, unsigned NumCandidates, - SourceLocation OpenParLoc) override { + SourceLocation OpenParLoc, + bool Braced) override { // At the moment we don't filter out any overloaded candidates. } diff --git a/lldb/source/Plugins/ExpressionParser/Clang/CxxModuleHandler.cpp b/lldb/source/Plugins/ExpressionParser/Clang/CxxModuleHandler.cpp index 74dd04600b4b..fecffd1183f8 100644 --- a/lldb/source/Plugins/ExpressionParser/Clang/CxxModuleHandler.cpp +++ b/lldb/source/Plugins/ExpressionParser/Clang/CxxModuleHandler.cpp @@ -138,7 +138,7 @@ getEqualLocalDeclContext(Sema &sema, DeclContext *foreign_ctxt) { // We currently only support building namespaces. if (foreign_ctxt->isNamespace()) { - NamedDecl *ns = llvm::dyn_cast<NamedDecl>(foreign_ctxt); + NamedDecl *ns = llvm::cast<NamedDecl>(foreign_ctxt); llvm::StringRef ns_name = ns->getName(); auto lookup_result = emulateLookupInCtxt(sema, ns_name, *parent); diff --git a/lldb/source/Plugins/Instruction/MIPS/EmulateInstructionMIPS.cpp b/lldb/source/Plugins/Instruction/MIPS/EmulateInstructionMIPS.cpp index ea9c95c55cbb..4ef0a034b6dd 100644 --- a/lldb/source/Plugins/Instruction/MIPS/EmulateInstructionMIPS.cpp +++ b/lldb/source/Plugins/Instruction/MIPS/EmulateInstructionMIPS.cpp @@ -137,7 +137,7 @@ EmulateInstructionMIPS::EmulateInstructionMIPS( break; } - std::string features = ""; + std::string features; uint32_t arch_flags = arch.GetFlags(); if (arch_flags & ArchSpec::eMIPSAse_msa) features += "+msa,"; diff --git a/lldb/source/Plugins/Instruction/MIPS64/EmulateInstructionMIPS64.cpp b/lldb/source/Plugins/Instruction/MIPS64/EmulateInstructionMIPS64.cpp index e5732a50f3f2..26736f4c58ba 100644 --- a/lldb/source/Plugins/Instruction/MIPS64/EmulateInstructionMIPS64.cpp +++ b/lldb/source/Plugins/Instruction/MIPS64/EmulateInstructionMIPS64.cpp @@ -137,7 +137,7 @@ EmulateInstructionMIPS64::EmulateInstructionMIPS64( break; } - std::string features = ""; + std::string features; uint32_t arch_flags = arch.GetFlags(); if (arch_flags & ArchSpec::eMIPSAse_msa) features += "+msa,"; diff --git a/lldb/source/Plugins/InstrumentationRuntime/MainThreadChecker/InstrumentationRuntimeMainThreadChecker.cpp b/lldb/source/Plugins/InstrumentationRuntime/MainThreadChecker/InstrumentationRuntimeMainThreadChecker.cpp index dc8c7c96aa11..a5c23615309d 100644 --- a/lldb/source/Plugins/InstrumentationRuntime/MainThreadChecker/InstrumentationRuntimeMainThreadChecker.cpp +++ b/lldb/source/Plugins/InstrumentationRuntime/MainThreadChecker/InstrumentationRuntimeMainThreadChecker.cpp @@ -100,14 +100,14 @@ InstrumentationRuntimeMainThreadChecker::RetrieveReportData( if (!apiname_ptr) return StructuredData::ObjectSP(); - std::string apiName = ""; + std::string apiName; Status read_error; target.ReadCStringFromMemory(apiname_ptr, apiName, read_error); if (read_error.Fail()) return StructuredData::ObjectSP(); - std::string className = ""; - std::string selector = ""; + std::string className; + std::string selector; if (apiName.substr(0, 2) == "-[") { size_t spacePos = apiName.find(' '); if (spacePos != std::string::npos) { diff --git a/lldb/source/Plugins/InstrumentationRuntime/TSan/InstrumentationRuntimeTSan.cpp b/lldb/source/Plugins/InstrumentationRuntime/TSan/InstrumentationRuntimeTSan.cpp index aef10bb2a778..977d8e4dbe07 100644 --- a/lldb/source/Plugins/InstrumentationRuntime/TSan/InstrumentationRuntimeTSan.cpp +++ b/lldb/source/Plugins/InstrumentationRuntime/TSan/InstrumentationRuntimeTSan.cpp @@ -711,7 +711,7 @@ addr_t InstrumentationRuntimeTSan::GetMainRacyAddress( std::string InstrumentationRuntimeTSan::GetLocationDescription( StructuredData::ObjectSP report, addr_t &global_addr, std::string &global_name, std::string &filename, uint32_t &line) { - std::string result = ""; + std::string result; ProcessSP process_sp = GetProcessSP(); @@ -820,8 +820,8 @@ bool InstrumentationRuntimeTSan::NotifyBreakpointHit( report->GetAsDictionary()->AddIntegerItem("memory_address", main_address); addr_t global_addr = 0; - std::string global_name = ""; - std::string location_filename = ""; + std::string global_name; + std::string location_filename; uint32_t location_line = 0; std::string location_description = instance->GetLocationDescription( report, global_addr, global_name, location_filename, location_line); diff --git a/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp b/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp index df61cc3853eb..0fb65f5a317d 100644 --- a/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp +++ b/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp @@ -579,6 +579,51 @@ static void LoadLibCxxFormatters(lldb::TypeCategoryImplSP cpp_category_sp) { "std::__[[:alnum:]]+::allocator<wchar_t> >$"), stl_summary_flags, true); + AddCXXSummary(cpp_category_sp, + lldb_private::formatters::LibcxxStringViewSummaryProviderASCII, + "std::string_view summary provider", + ConstString("^std::__[[:alnum:]]+::string_view$"), + stl_summary_flags, true); + AddCXXSummary(cpp_category_sp, + lldb_private::formatters::LibcxxStringViewSummaryProviderASCII, + "std::string_view summary provider", + ConstString("^std::__[[:alnum:]]+::basic_string_view<char, " + "std::__[[:alnum:]]+::char_traits<char> >$"), + stl_summary_flags, true); + AddCXXSummary( + cpp_category_sp, + lldb_private::formatters::LibcxxStringViewSummaryProviderASCII, + "std::string_view summary provider", + ConstString("^std::__[[:alnum:]]+::basic_string_view<unsigned char, " + "std::__[[:alnum:]]+::char_traits<unsigned char> >$"), + stl_summary_flags, true); + + AddCXXSummary(cpp_category_sp, + lldb_private::formatters::LibcxxStringViewSummaryProviderUTF16, + "std::u16string_view summary provider", + ConstString("^std::__[[:alnum:]]+::basic_string_view<char16_t, " + "std::__[[:alnum:]]+::char_traits<char16_t> >$"), + stl_summary_flags, true); + + AddCXXSummary(cpp_category_sp, + lldb_private::formatters::LibcxxStringViewSummaryProviderUTF32, + "std::u32string_view summary provider", + ConstString("^std::__[[:alnum:]]+::basic_string_view<char32_t, " + "std::__[[:alnum:]]+::char_traits<char32_t> >$"), + stl_summary_flags, true); + + AddCXXSummary(cpp_category_sp, + lldb_private::formatters::LibcxxWStringViewSummaryProvider, + "std::wstring_view summary provider", + ConstString("^std::__[[:alnum:]]+::wstring_view$"), + stl_summary_flags, true); + AddCXXSummary(cpp_category_sp, + lldb_private::formatters::LibcxxWStringViewSummaryProvider, + "std::wstring_view summary provider", + ConstString("^std::__[[:alnum:]]+::basic_string_view<wchar_t, " + "std::__[[:alnum:]]+::char_traits<wchar_t> >$"), + stl_summary_flags, true); + SyntheticChildren::Flags stl_synth_flags; stl_synth_flags.SetCascades(true).SetSkipPointers(false).SetSkipReferences( false); diff --git a/lldb/source/Plugins/Language/CPlusPlus/GenericBitset.cpp b/lldb/source/Plugins/Language/CPlusPlus/GenericBitset.cpp index c8063915b178..d1d844bb4ca4 100644 --- a/lldb/source/Plugins/Language/CPlusPlus/GenericBitset.cpp +++ b/lldb/source/Plugins/Language/CPlusPlus/GenericBitset.cpp @@ -72,6 +72,7 @@ ConstString GenericBitsetFrontEnd::GetDataContainerMemberName() { case StdLib::LibStdcpp: return ConstString("_M_w"); } + llvm_unreachable("Unknown StdLib enum"); } bool GenericBitsetFrontEnd::Update() { diff --git a/lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp b/lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp index b9aef0ae7d9e..21196393371e 100644 --- a/lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp +++ b/lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp @@ -19,6 +19,7 @@ #include "lldb/Target/ProcessStructReader.h" #include "lldb/Target/SectionLoadList.h" #include "lldb/Target/Target.h" +#include "lldb/Utility/ConstString.h" #include "lldb/Utility/DataBufferHeap.h" #include "lldb/Utility/Endian.h" #include "lldb/Utility/Status.h" @@ -26,6 +27,7 @@ #include "Plugins/LanguageRuntime/CPlusPlus/CPPLanguageRuntime.h" #include "Plugins/TypeSystem/Clang/TypeSystemClang.h" +#include <tuple> using namespace lldb; using namespace lldb_private; @@ -560,7 +562,7 @@ ExtractLibcxxStringInfo(ValueObject &valobj) { return {}; ValueObjectSP layout_decider( - D->GetChildAtIndexPath(llvm::ArrayRef<size_t>({0, 0}))); + D->GetChildAtIndexPath(llvm::ArrayRef<size_t>({0, 0}))); // this child should exist if (!layout_decider) @@ -643,16 +645,10 @@ ExtractLibcxxStringInfo(ValueObject &valobj) { return std::make_pair(size, location_sp); } -bool lldb_private::formatters::LibcxxWStringSummaryProvider( - ValueObject &valobj, Stream &stream, - const TypeSummaryOptions &summary_options) { - auto string_info = ExtractLibcxxStringInfo(valobj); - if (!string_info) - return false; - uint64_t size; - ValueObjectSP location_sp; - std::tie(size, location_sp) = *string_info; - +static bool +LibcxxWStringSummaryProvider(ValueObject &valobj, Stream &stream, + const TypeSummaryOptions &summary_options, + ValueObjectSP location_sp, size_t size) { if (size == 0) { stream.Printf("L\"\""); return true; @@ -660,7 +656,6 @@ bool lldb_private::formatters::LibcxxWStringSummaryProvider( if (!location_sp) return false; - StringPrinter::ReadBufferAndDumpToStreamOptions options(valobj); if (summary_options.GetCapping() == TypeSummaryCapping::eTypeSummaryCapped) { const auto max_size = valobj.GetTargetSP()->GetMaximumSizeOfStringSummary(); @@ -714,10 +709,9 @@ bool lldb_private::formatters::LibcxxWStringSummaryProvider( return false; } -template <StringPrinter::StringElementType element_type> -bool LibcxxStringSummaryProvider(ValueObject &valobj, Stream &stream, - const TypeSummaryOptions &summary_options, - std::string prefix_token) { +bool lldb_private::formatters::LibcxxWStringSummaryProvider( + ValueObject &valobj, Stream &stream, + const TypeSummaryOptions &summary_options) { auto string_info = ExtractLibcxxStringInfo(valobj); if (!string_info) return false; @@ -725,6 +719,17 @@ bool LibcxxStringSummaryProvider(ValueObject &valobj, Stream &stream, ValueObjectSP location_sp; std::tie(size, location_sp) = *string_info; + return ::LibcxxWStringSummaryProvider(valobj, stream, summary_options, + location_sp, size); +} + +template <StringPrinter::StringElementType element_type> +static bool +LibcxxStringSummaryProvider(ValueObject &valobj, Stream &stream, + const TypeSummaryOptions &summary_options, + std::string prefix_token, ValueObjectSP location_sp, + uint64_t size) { + if (size == 0) { stream.Printf("\"\""); return true; @@ -763,6 +768,21 @@ bool LibcxxStringSummaryProvider(ValueObject &valobj, Stream &stream, } template <StringPrinter::StringElementType element_type> +static bool +LibcxxStringSummaryProvider(ValueObject &valobj, Stream &stream, + const TypeSummaryOptions &summary_options, + std::string prefix_token) { + auto string_info = ExtractLibcxxStringInfo(valobj); + if (!string_info) + return false; + uint64_t size; + ValueObjectSP location_sp; + std::tie(size, location_sp) = *string_info; + + return LibcxxStringSummaryProvider<element_type>( + valobj, stream, summary_options, prefix_token, location_sp, size); +} +template <StringPrinter::StringElementType element_type> static bool formatStringImpl(ValueObject &valobj, Stream &stream, const TypeSummaryOptions &summary_options, std::string prefix_token) { @@ -796,3 +816,83 @@ bool lldb_private::formatters::LibcxxStringSummaryProviderUTF32( return formatStringImpl<StringPrinter::StringElementType::UTF32>( valobj, stream, summary_options, "U"); } + +static std::tuple<bool, ValueObjectSP, size_t> +LibcxxExtractStringViewData(ValueObject& valobj) { + ConstString g_data_name("__data"); + ConstString g_size_name("__size"); + auto dataobj = valobj.GetChildMemberWithName(g_data_name, true); + auto sizeobj = valobj.GetChildMemberWithName(g_size_name, true); + + if (!dataobj || !sizeobj) + return std::make_tuple<bool,ValueObjectSP,size_t>(false, {}, {}); + + if (!dataobj->GetError().Success() || !sizeobj->GetError().Success()) + return std::make_tuple<bool,ValueObjectSP,size_t>(false, {}, {}); + + bool success{false}; + uint64_t size = sizeobj->GetValueAsUnsigned(0, &success); + if (!success) + return std::make_tuple<bool,ValueObjectSP,size_t>(false, {}, {}); + + return std::make_tuple(true,dataobj,size); +} + +template <StringPrinter::StringElementType element_type> +static bool formatStringViewImpl(ValueObject &valobj, Stream &stream, + const TypeSummaryOptions &summary_options, + std::string prefix_token) { + + bool success; + ValueObjectSP dataobj; + size_t size; + std::tie(success, dataobj, size) = LibcxxExtractStringViewData(valobj); + + if (!success) { + stream << "Summary Unavailable"; + return true; + } + + return LibcxxStringSummaryProvider<element_type>( + valobj, stream, summary_options, prefix_token, dataobj, size); +} + +bool lldb_private::formatters::LibcxxStringViewSummaryProviderASCII( + ValueObject &valobj, Stream &stream, + const TypeSummaryOptions &summary_options) { + return formatStringViewImpl<StringPrinter::StringElementType::ASCII>( + valobj, stream, summary_options, ""); +} + +bool lldb_private::formatters::LibcxxStringViewSummaryProviderUTF16( + ValueObject &valobj, Stream &stream, + const TypeSummaryOptions &summary_options) { + return formatStringViewImpl<StringPrinter::StringElementType::UTF16>( + valobj, stream, summary_options, "u"); +} + +bool lldb_private::formatters::LibcxxStringViewSummaryProviderUTF32( + ValueObject &valobj, Stream &stream, + const TypeSummaryOptions &summary_options) { + return formatStringViewImpl<StringPrinter::StringElementType::UTF32>( + valobj, stream, summary_options, "U"); +} + +bool lldb_private::formatters::LibcxxWStringViewSummaryProvider( + ValueObject &valobj, Stream &stream, + const TypeSummaryOptions &summary_options) { + + bool success; + ValueObjectSP dataobj; + size_t size; + std::tie( success, dataobj, size ) = LibcxxExtractStringViewData(valobj); + + if (!success) { + stream << "Summary Unavailable"; + return true; + } + + + return ::LibcxxWStringSummaryProvider(valobj, stream, summary_options, + dataobj, size); +} diff --git a/lldb/source/Plugins/Language/CPlusPlus/LibCxx.h b/lldb/source/Plugins/Language/CPlusPlus/LibCxx.h index 80dc71787ceb..0f166ae24912 100644 --- a/lldb/source/Plugins/Language/CPlusPlus/LibCxx.h +++ b/lldb/source/Plugins/Language/CPlusPlus/LibCxx.h @@ -34,6 +34,22 @@ bool LibcxxWStringSummaryProvider( ValueObject &valobj, Stream &stream, const TypeSummaryOptions &options); // libc++ std::wstring +bool LibcxxStringViewSummaryProviderASCII( + ValueObject &valueObj, Stream &stream, + const TypeSummaryOptions &summary_options); // libc++ std::string_view + +bool LibcxxStringViewSummaryProviderUTF16( + ValueObject &valobj, Stream &stream, + const TypeSummaryOptions &summary_options); // libc++ std::u16string_view + +bool LibcxxStringViewSummaryProviderUTF32( + ValueObject &valobj, Stream &stream, + const TypeSummaryOptions &summary_options); // libc++ std::u32string_view + +bool LibcxxWStringViewSummaryProvider( + ValueObject &valobj, Stream &stream, + const TypeSummaryOptions &options); // libc++ std::wstring_view + bool LibcxxOptionalSummaryProvider( ValueObject &valobj, Stream &stream, const TypeSummaryOptions &options); // libc++ std::optional<> diff --git a/lldb/source/Plugins/Language/ObjC/NSString.cpp b/lldb/source/Plugins/Language/ObjC/NSString.cpp index 2b5161e781f2..61705c866778 100644 --- a/lldb/source/Plugins/Language/ObjC/NSString.cpp +++ b/lldb/source/Plugins/Language/ObjC/NSString.cpp @@ -8,14 +8,13 @@ #include "NSString.h" -#include "Plugins/TypeSystem/Clang/TypeSystemClang.h" #include "lldb/Core/ValueObject.h" #include "lldb/Core/ValueObjectConstResult.h" #include "lldb/DataFormatters/FormattersHelpers.h" #include "lldb/DataFormatters/StringPrinter.h" #include "lldb/Target/Language.h" -#include "lldb/Target/ProcessStructReader.h" #include "lldb/Target/Target.h" +#include "lldb/Utility/ConstString.h" #include "lldb/Utility/DataBufferHeap.h" #include "lldb/Utility/Endian.h" #include "lldb/Utility/Status.h" @@ -31,24 +30,6 @@ NSString_Additionals::GetAdditionalSummaries() { return g_map; } -static CompilerType GetNSPathStore2Type(Target &target) { - static ConstString g_type_name("__lldb_autogen_nspathstore2"); - - TypeSystemClang *ast_ctx = ScratchTypeSystemClang::GetForTarget(target); - - if (!ast_ctx) - return CompilerType(); - - CompilerType voidstar = - ast_ctx->GetBasicType(lldb::eBasicTypeVoid).GetPointerType(); - CompilerType uint32 = - ast_ctx->GetBuiltinTypeForEncodingAndBitSize(eEncodingUint, 32); - - return ast_ctx->GetOrCreateStructForIdentifier( - g_type_name, - {{"isa", voidstar}, {"lengthAndRef", uint32}, {"buffer", voidstar}}); -} - bool lldb_private::formatters::NSStringSummaryProvider( ValueObject &valobj, Stream &stream, const TypeSummaryOptions &summary_options) { @@ -229,11 +210,17 @@ bool lldb_private::formatters::NSStringSummaryProvider( return StringPrinter::ReadStringAndDumpToStream< StringPrinter::StringElementType::UTF16>(options); } else if (is_path_store) { - ProcessStructReader reader(valobj.GetProcessSP().get(), - valobj.GetValueAsUnsigned(0), - GetNSPathStore2Type(*valobj.GetTargetSP())); - explicit_length = - reader.GetField<uint32_t>(ConstString("lengthAndRef")) >> 20; + // _lengthAndRefCount is the first ivar of NSPathStore2 (after the isa). + uint64_t length_ivar_offset = 1 * ptr_size; + CompilerType length_type = valobj.GetCompilerType().GetBasicTypeFromAST( + lldb::eBasicTypeUnsignedInt); + ValueObjectSP length_valobj_sp = + valobj.GetSyntheticChildAtOffset(length_ivar_offset, length_type, true, + ConstString("_lengthAndRefCount")); + if (!length_valobj_sp) + return false; + // Get the length out of _lengthAndRefCount. + explicit_length = length_valobj_sp->GetValueAsUnsigned(0) >> 20; lldb::addr_t location = valobj.GetValueAsUnsigned(0) + ptr_size + 4; options.SetLocation(location); diff --git a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp index bd6b6335ca8c..f2cf25f93eb2 100644 --- a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp +++ b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp @@ -671,7 +671,7 @@ AppleObjCRuntimeV2::AppleObjCRuntimeV2(Process *process, static const ConstString g_objc_copyRealizedClassList( "_ZL33objc_copyRealizedClassList_nolockPj"); m_has_objc_copyRealizedClassList = HasSymbol(g_objc_copyRealizedClassList); - + WarnIfNoExpandedSharedCache(); RegisterObjCExceptionRecognizer(process); } @@ -2355,6 +2355,32 @@ void AppleObjCRuntimeV2::WarnIfNoClassesCached( } } +void AppleObjCRuntimeV2::WarnIfNoExpandedSharedCache() { + if (!m_objc_module_sp) + return; + + ObjectFile *object_file = m_objc_module_sp->GetObjectFile(); + if (!object_file) + return; + + if (!object_file->IsInMemory()) + return; + + Target &target = GetProcess()->GetTarget(); + Debugger &debugger = target.GetDebugger(); + if (auto stream = debugger.GetAsyncOutputStream()) { + const char *msg = "read from the shared cache"; + if (PlatformSP platform_sp = target.GetPlatform()) + msg = platform_sp->IsHost() + ? "read from the host's in-memory shared cache" + : "find the on-disk shared cache for this device"; + stream->Printf("warning: libobjc.A.dylib is being read from process " + "memory. This indicates that LLDB could not %s. This will " + "likely reduce debugging performance.\n", + msg); + } +} + DeclVendor *AppleObjCRuntimeV2::GetDeclVendor() { if (!m_decl_vendor_up) m_decl_vendor_up = std::make_unique<AppleObjCDeclVendor>(*this); diff --git a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.h b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.h index 6266634e64c5..e1a6b7cde48a 100644 --- a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.h +++ b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.h @@ -399,6 +399,7 @@ private: }; void WarnIfNoClassesCached(SharedCacheWarningReason reason); + void WarnIfNoExpandedSharedCache(); lldb::addr_t GetSharedCacheReadOnlyAddress(); lldb::addr_t GetSharedCacheBaseAddress(); diff --git a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTrampolineHandler.cpp b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTrampolineHandler.cpp index aa6306bef8b9..ff41f187ba9d 100644 --- a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTrampolineHandler.cpp +++ b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTrampolineHandler.cpp @@ -889,8 +889,8 @@ AppleObjCTrampolineHandler::GetStepThroughDispatchPlan(Thread &thread, ThreadPlanSP ret_plan_sp; lldb::addr_t curr_pc = thread.GetRegisterContext()->GetPC(); - DispatchFunction vtable_dispatch - = {"vtable", 0, false, false, DispatchFunction::eFixUpFixed}; + DispatchFunction vtable_dispatch = {"vtable", false, false, false, + DispatchFunction::eFixUpFixed}; // First step is to look and see if we are in one of the known ObjC // dispatch functions. We've already compiled a table of same, so diff --git a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTypeEncodingParser.cpp b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTypeEncodingParser.cpp index c6cb2be981a7..40a0ea3e97a4 100644 --- a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTypeEncodingParser.cpp +++ b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTypeEncodingParser.cpp @@ -59,7 +59,7 @@ uint32_t AppleObjCTypeEncodingParser::ReadNumber(StringLexer &type) { // "{CGRect=\"origin\"{CGPoint=\"x\"d\"y\"d}\"size\"{CGSize=\"width\"d\"height\"d}}" AppleObjCTypeEncodingParser::StructElement::StructElement() - : name(""), type(clang::QualType()) {} + : type(clang::QualType()) {} AppleObjCTypeEncodingParser::StructElement AppleObjCTypeEncodingParser::ReadStructElement(TypeSystemClang &ast_ctx, diff --git a/lldb/source/Plugins/ObjectFile/Minidump/MinidumpFileBuilder.cpp b/lldb/source/Plugins/ObjectFile/Minidump/MinidumpFileBuilder.cpp index a70e6a079f76..516bcb21b019 100644 --- a/lldb/source/Plugins/ObjectFile/Minidump/MinidumpFileBuilder.cpp +++ b/lldb/source/Plugins/ObjectFile/Minidump/MinidumpFileBuilder.cpp @@ -115,7 +115,7 @@ Status MinidumpFileBuilder::AddSystemInfo(const llvm::Triple &target_triple) { sys_info.PlatformId = platform_id; m_data.AppendData(&sys_info, sizeof(llvm::minidump::SystemInfo)); - std::string csd_string = ""; + std::string csd_string; error = WriteString(csd_string, &m_data); if (error.Fail()) { @@ -272,7 +272,8 @@ Status MinidumpFileBuilder::AddModuleList(Target &target) { mod->GetObjectFile()->GetBaseAddress().GetLoadAddress(&target)); m.SizeOfImage = static_cast<llvm::support::ulittle32_t>(mod_size); m.Checksum = static_cast<llvm::support::ulittle32_t>(0); - m.TimeDateStamp = static_cast<llvm::support::ulittle32_t>(std::time(0)); + m.TimeDateStamp = + static_cast<llvm::support::ulittle32_t>(std::time(nullptr)); m.ModuleNameRVA = static_cast<llvm::support::ulittle32_t>( size_before + module_stream_size + helper_data.GetByteSize()); m.VersionInfo = info; @@ -719,7 +720,7 @@ Status MinidumpFileBuilder::Dump(lldb::FileUP &core_file) const { header.Checksum = static_cast<llvm::support::ulittle32_t>( 0u), // not used in most of the writers header.TimeDateStamp = - static_cast<llvm::support::ulittle32_t>(std::time(0)); + static_cast<llvm::support::ulittle32_t>(std::time(nullptr)); header.Flags = static_cast<llvm::support::ulittle64_t>(0u); // minidump normal flag diff --git a/lldb/source/Plugins/ObjectFile/PDB/ObjectFilePDB.h b/lldb/source/Plugins/ObjectFile/PDB/ObjectFilePDB.h index da999d2b55a7..a1a3eeb656dd 100644 --- a/lldb/source/Plugins/ObjectFile/PDB/ObjectFilePDB.h +++ b/lldb/source/Plugins/ObjectFile/PDB/ObjectFilePDB.h @@ -102,4 +102,4 @@ private: }; } // namespace lldb_private -#endif // LLDB_PLUGINS_OBJECTFILE_PDB_OBJECTFILEPDB_H +#endif // LLDB_SOURCE_PLUGINS_OBJECTFILE_PDB_OBJECTFILEPDB_H diff --git a/lldb/source/Plugins/Platform/FreeBSD/PlatformFreeBSD.cpp b/lldb/source/Plugins/Platform/FreeBSD/PlatformFreeBSD.cpp index 754d06de7cb9..2bf0a44e4a3e 100644 --- a/lldb/source/Plugins/Platform/FreeBSD/PlatformFreeBSD.cpp +++ b/lldb/source/Plugins/Platform/FreeBSD/PlatformFreeBSD.cpp @@ -183,3 +183,97 @@ MmapArgList PlatformFreeBSD::GetMmapArgumentList(const ArchSpec &arch, args.push_back(0); return args; } + +CompilerType PlatformFreeBSD::GetSiginfoType(const llvm::Triple &triple) { + if (!m_type_system_up) + m_type_system_up.reset(new TypeSystemClang("siginfo", triple)); + TypeSystemClang *ast = m_type_system_up.get(); + + // generic types + CompilerType int_type = ast->GetBasicType(eBasicTypeInt); + CompilerType uint_type = ast->GetBasicType(eBasicTypeUnsignedInt); + CompilerType long_type = ast->GetBasicType(eBasicTypeLong); + CompilerType voidp_type = ast->GetBasicType(eBasicTypeVoid).GetPointerType(); + + // platform-specific types + CompilerType &pid_type = int_type; + CompilerType &uid_type = uint_type; + + CompilerType sigval_type = ast->CreateRecordType( + nullptr, OptionalClangModuleID(), lldb::eAccessPublic, "__lldb_sigval_t", + clang::TTK_Union, lldb::eLanguageTypeC); + ast->StartTagDeclarationDefinition(sigval_type); + ast->AddFieldToRecordType(sigval_type, "sival_int", int_type, + lldb::eAccessPublic, 0); + ast->AddFieldToRecordType(sigval_type, "sival_ptr", voidp_type, + lldb::eAccessPublic, 0); + ast->CompleteTagDeclarationDefinition(sigval_type); + + // siginfo_t + CompilerType siginfo_type = ast->CreateRecordType( + nullptr, OptionalClangModuleID(), lldb::eAccessPublic, "__lldb_siginfo_t", + clang::TTK_Struct, lldb::eLanguageTypeC); + ast->StartTagDeclarationDefinition(siginfo_type); + ast->AddFieldToRecordType(siginfo_type, "si_signo", int_type, + lldb::eAccessPublic, 0); + ast->AddFieldToRecordType(siginfo_type, "si_errno", int_type, + lldb::eAccessPublic, 0); + ast->AddFieldToRecordType(siginfo_type, "si_code", int_type, + lldb::eAccessPublic, 0); + ast->AddFieldToRecordType(siginfo_type, "si_pid", pid_type, + lldb::eAccessPublic, 0); + ast->AddFieldToRecordType(siginfo_type, "si_uid", uid_type, + lldb::eAccessPublic, 0); + ast->AddFieldToRecordType(siginfo_type, "si_status", int_type, + lldb::eAccessPublic, 0); + ast->AddFieldToRecordType(siginfo_type, "si_addr", voidp_type, + lldb::eAccessPublic, 0); + ast->AddFieldToRecordType(siginfo_type, "si_value", sigval_type, + lldb::eAccessPublic, 0); + + // union used to hold the signal data + CompilerType union_type = ast->CreateRecordType( + nullptr, OptionalClangModuleID(), lldb::eAccessPublic, "", + clang::TTK_Union, lldb::eLanguageTypeC); + ast->StartTagDeclarationDefinition(union_type); + + ast->AddFieldToRecordType( + union_type, "_fault", + ast->CreateStructForIdentifier(ConstString(), + { + {"_trapno", int_type}, + }), + lldb::eAccessPublic, 0); + + ast->AddFieldToRecordType( + union_type, "_timer", + ast->CreateStructForIdentifier(ConstString(), + { + {"_timerid", int_type}, + {"_overrun", int_type}, + }), + lldb::eAccessPublic, 0); + + ast->AddFieldToRecordType( + union_type, "_mesgq", + ast->CreateStructForIdentifier(ConstString(), + { + {"_mqd", int_type}, + }), + lldb::eAccessPublic, 0); + + ast->AddFieldToRecordType( + union_type, "_poll", + ast->CreateStructForIdentifier(ConstString(), + { + {"_band", long_type}, + }), + lldb::eAccessPublic, 0); + + ast->CompleteTagDeclarationDefinition(union_type); + ast->AddFieldToRecordType(siginfo_type, "_reason", union_type, + lldb::eAccessPublic, 0); + + ast->CompleteTagDeclarationDefinition(siginfo_type); + return siginfo_type; +} diff --git a/lldb/source/Plugins/Platform/FreeBSD/PlatformFreeBSD.h b/lldb/source/Plugins/Platform/FreeBSD/PlatformFreeBSD.h index fd37b13de017..7f9dfd87a59a 100644 --- a/lldb/source/Plugins/Platform/FreeBSD/PlatformFreeBSD.h +++ b/lldb/source/Plugins/Platform/FreeBSD/PlatformFreeBSD.h @@ -10,6 +10,7 @@ #define LLDB_SOURCE_PLUGINS_PLATFORM_FREEBSD_PLATFORMFREEBSD_H #include "Plugins/Platform/POSIX/PlatformPOSIX.h" +#include "Plugins/TypeSystem/Clang/TypeSystemClang.h" namespace lldb_private { namespace platform_freebsd { @@ -53,7 +54,12 @@ public: unsigned flags, lldb::addr_t fd, lldb::addr_t offset) override; + CompilerType GetSiginfoType(const llvm::Triple &triple) override; + std::vector<ArchSpec> m_supported_architectures; + +private: + std::unique_ptr<TypeSystemClang> m_type_system_up; }; } // namespace platform_freebsd diff --git a/lldb/source/Plugins/Platform/NetBSD/PlatformNetBSD.cpp b/lldb/source/Plugins/Platform/NetBSD/PlatformNetBSD.cpp index 552b3890615c..ddba64bc5d11 100644 --- a/lldb/source/Plugins/Platform/NetBSD/PlatformNetBSD.cpp +++ b/lldb/source/Plugins/Platform/NetBSD/PlatformNetBSD.cpp @@ -202,3 +202,144 @@ MmapArgList PlatformNetBSD::GetMmapArgumentList(const ArchSpec &arch, MmapArgList args({addr, length, prot, flags_platform, fd, offset}); return args; } + +CompilerType PlatformNetBSD::GetSiginfoType(const llvm::Triple &triple) { + if (!m_type_system_up) + m_type_system_up.reset(new TypeSystemClang("siginfo", triple)); + TypeSystemClang *ast = m_type_system_up.get(); + + // generic types + CompilerType int_type = ast->GetBasicType(eBasicTypeInt); + CompilerType uint_type = ast->GetBasicType(eBasicTypeUnsignedInt); + CompilerType long_type = ast->GetBasicType(eBasicTypeLong); + CompilerType long_long_type = ast->GetBasicType(eBasicTypeLongLong); + CompilerType voidp_type = ast->GetBasicType(eBasicTypeVoid).GetPointerType(); + + // platform-specific types + CompilerType &pid_type = int_type; + CompilerType &uid_type = uint_type; + CompilerType &clock_type = uint_type; + CompilerType &lwpid_type = int_type; + + CompilerType sigval_type = ast->CreateRecordType( + nullptr, OptionalClangModuleID(), lldb::eAccessPublic, "__lldb_sigval_t", + clang::TTK_Union, lldb::eLanguageTypeC); + ast->StartTagDeclarationDefinition(sigval_type); + ast->AddFieldToRecordType(sigval_type, "sival_int", int_type, + lldb::eAccessPublic, 0); + ast->AddFieldToRecordType(sigval_type, "sival_ptr", voidp_type, + lldb::eAccessPublic, 0); + ast->CompleteTagDeclarationDefinition(sigval_type); + + CompilerType ptrace_option_type = ast->CreateRecordType( + nullptr, OptionalClangModuleID(), lldb::eAccessPublic, "", + clang::TTK_Union, lldb::eLanguageTypeC); + ast->StartTagDeclarationDefinition(ptrace_option_type); + ast->AddFieldToRecordType(ptrace_option_type, "_pe_other_pid", pid_type, + lldb::eAccessPublic, 0); + ast->AddFieldToRecordType(ptrace_option_type, "_pe_lwp", lwpid_type, + lldb::eAccessPublic, 0); + ast->CompleteTagDeclarationDefinition(ptrace_option_type); + + // siginfo_t + CompilerType siginfo_type = ast->CreateRecordType( + nullptr, OptionalClangModuleID(), lldb::eAccessPublic, "__lldb_siginfo_t", + clang::TTK_Union, lldb::eLanguageTypeC); + ast->StartTagDeclarationDefinition(siginfo_type); + + // struct _ksiginfo + CompilerType ksiginfo_type = ast->CreateRecordType( + nullptr, OptionalClangModuleID(), lldb::eAccessPublic, "", + clang::TTK_Struct, lldb::eLanguageTypeC); + ast->StartTagDeclarationDefinition(ksiginfo_type); + ast->AddFieldToRecordType(ksiginfo_type, "_signo", int_type, + lldb::eAccessPublic, 0); + ast->AddFieldToRecordType(ksiginfo_type, "_code", int_type, + lldb::eAccessPublic, 0); + ast->AddFieldToRecordType(ksiginfo_type, "_errno", int_type, + lldb::eAccessPublic, 0); + + // the structure is padded on 64-bit arches to fix alignment + if (triple.isArch64Bit()) + ast->AddFieldToRecordType(ksiginfo_type, "__pad0", int_type, + lldb::eAccessPublic, 0); + + // union used to hold the signal data + CompilerType union_type = ast->CreateRecordType( + nullptr, OptionalClangModuleID(), lldb::eAccessPublic, "", + clang::TTK_Union, lldb::eLanguageTypeC); + ast->StartTagDeclarationDefinition(union_type); + + ast->AddFieldToRecordType( + union_type, "_rt", + ast->CreateStructForIdentifier(ConstString(), + { + {"_pid", pid_type}, + {"_uid", uid_type}, + {"_value", sigval_type}, + }), + lldb::eAccessPublic, 0); + + ast->AddFieldToRecordType( + union_type, "_child", + ast->CreateStructForIdentifier(ConstString(), + { + {"_pid", pid_type}, + {"_uid", uid_type}, + {"_status", int_type}, + {"_utime", clock_type}, + {"_stime", clock_type}, + }), + lldb::eAccessPublic, 0); + + ast->AddFieldToRecordType( + union_type, "_fault", + ast->CreateStructForIdentifier(ConstString(), + { + {"_addr", voidp_type}, + {"_trap", int_type}, + {"_trap2", int_type}, + {"_trap3", int_type}, + }), + lldb::eAccessPublic, 0); + + ast->AddFieldToRecordType( + union_type, "_poll", + ast->CreateStructForIdentifier(ConstString(), + { + {"_band", long_type}, + {"_fd", int_type}, + }), + lldb::eAccessPublic, 0); + + ast->AddFieldToRecordType(union_type, "_syscall", + ast->CreateStructForIdentifier( + ConstString(), + { + {"_sysnum", int_type}, + {"_retval", int_type.GetArrayType(2)}, + {"_error", int_type}, + {"_args", long_long_type.GetArrayType(8)}, + }), + lldb::eAccessPublic, 0); + + ast->AddFieldToRecordType( + union_type, "_ptrace_state", + ast->CreateStructForIdentifier(ConstString(), + { + {"_pe_report_event", int_type}, + {"_option", ptrace_option_type}, + }), + lldb::eAccessPublic, 0); + + ast->CompleteTagDeclarationDefinition(union_type); + ast->AddFieldToRecordType(ksiginfo_type, "_reason", union_type, + lldb::eAccessPublic, 0); + + ast->CompleteTagDeclarationDefinition(ksiginfo_type); + ast->AddFieldToRecordType(siginfo_type, "_info", ksiginfo_type, + lldb::eAccessPublic, 0); + + ast->CompleteTagDeclarationDefinition(siginfo_type); + return siginfo_type; +} diff --git a/lldb/source/Plugins/Platform/NetBSD/PlatformNetBSD.h b/lldb/source/Plugins/Platform/NetBSD/PlatformNetBSD.h index 7158fbd26efb..433cf6653126 100644 --- a/lldb/source/Plugins/Platform/NetBSD/PlatformNetBSD.h +++ b/lldb/source/Plugins/Platform/NetBSD/PlatformNetBSD.h @@ -10,6 +10,7 @@ #define LLDB_SOURCE_PLUGINS_PLATFORM_NETBSD_PLATFORMNETBSD_H #include "Plugins/Platform/POSIX/PlatformPOSIX.h" +#include "Plugins/TypeSystem/Clang/TypeSystemClang.h" namespace lldb_private { namespace platform_netbsd { @@ -55,7 +56,12 @@ public: unsigned flags, lldb::addr_t fd, lldb::addr_t offset) override; + CompilerType GetSiginfoType(const llvm::Triple &triple) override; + std::vector<ArchSpec> m_supported_architectures; + +private: + std::unique_ptr<TypeSystemClang> m_type_system_up; }; } // namespace platform_netbsd diff --git a/lldb/source/Plugins/Platform/QemuUser/PlatformQemuUser.cpp b/lldb/source/Plugins/Platform/QemuUser/PlatformQemuUser.cpp index 67c9484680a4..dd7546d8fa15 100644 --- a/lldb/source/Plugins/Platform/QemuUser/PlatformQemuUser.cpp +++ b/lldb/source/Plugins/Platform/QemuUser/PlatformQemuUser.cpp @@ -162,7 +162,10 @@ lldb::ProcessSP PlatformQemuUser::DebugProcess(ProcessLaunchInfo &launch_info, Target &target, Status &error) { Log *log = GetLogIfAnyCategoriesSet(LIBLLDB_LOG_PLATFORM); - std::string qemu = GetGlobalProperties().GetEmulatorPath().GetPath(); + FileSpec qemu = GetGlobalProperties().GetEmulatorPath(); + if (!qemu) + qemu.SetPath(("qemu-" + GetGlobalProperties().GetArchitecture()).str()); + FileSystem::Instance().ResolveExecutableLocation(qemu); llvm::SmallString<0> socket_model, socket_path; HostInfo::GetProcessTempDir().GetPath(socket_model); @@ -171,7 +174,11 @@ lldb::ProcessSP PlatformQemuUser::DebugProcess(ProcessLaunchInfo &launch_info, llvm::sys::fs::createUniquePath(socket_model, socket_path, false); } while (FileSystem::Instance().Exists(socket_path)); - Args args({qemu, "-g", socket_path}); + Args args({qemu.GetPath(), "-g", socket_path}); + if (!launch_info.GetArg0().empty()) { + args.AppendArgument("-0"); + args.AppendArgument(launch_info.GetArg0()); + } args.AppendArguments(GetGlobalProperties().GetEmulatorArgs()); args.AppendArgument("--"); args.AppendArgument(launch_info.GetExecutableFile().GetPath()); @@ -184,6 +191,8 @@ lldb::ProcessSP PlatformQemuUser::DebugProcess(ProcessLaunchInfo &launch_info, launch_info.SetArguments(args, true); Environment emulator_env = Host::GetEnvironment(); + if (ConstString sysroot = GetSDKRootDirectory()) + emulator_env["QEMU_LD_PREFIX"] = sysroot.GetStringRef().str(); for (const auto &KV : GetGlobalProperties().GetEmulatorEnvVars()) emulator_env[KV.first()] = KV.second; launch_info.GetEnvironment() = ComputeLaunchEnvironment( diff --git a/lldb/source/Plugins/Platform/QemuUser/PlatformQemuUser.h b/lldb/source/Plugins/Platform/QemuUser/PlatformQemuUser.h index 71df1b7b7811..c5439e126db1 100644 --- a/lldb/source/Plugins/Platform/QemuUser/PlatformQemuUser.h +++ b/lldb/source/Plugins/Platform/QemuUser/PlatformQemuUser.h @@ -47,6 +47,14 @@ public: Environment GetEnvironment() override; + MmapArgList GetMmapArgumentList(const ArchSpec &arch, lldb::addr_t addr, + lldb::addr_t length, unsigned prot, + unsigned flags, lldb::addr_t fd, + lldb::addr_t offset) override { + return Platform::GetHostPlatform()->GetMmapArgumentList( + arch, addr, length, prot, flags, fd, offset); + } + private: static lldb::PlatformSP CreateInstance(bool force, const ArchSpec *arch); static void DebuggerInitialize(Debugger &debugger); diff --git a/lldb/source/Plugins/Platform/QemuUser/PlatformQemuUserProperties.td b/lldb/source/Plugins/Platform/QemuUser/PlatformQemuUserProperties.td index 4e8fbcfd6760..c7ec4bbc6e78 100644 --- a/lldb/source/Plugins/Platform/QemuUser/PlatformQemuUserProperties.td +++ b/lldb/source/Plugins/Platform/QemuUser/PlatformQemuUserProperties.td @@ -8,7 +8,7 @@ let Definition = "platformqemuuser" in { def EmulatorPath: Property<"emulator-path", "FileSpec">, Global, DefaultStringValue<"">, - Desc<"Path to the emulator binary.">; + Desc<"Path to the emulator binary. If the path does not contain a directory separator, the filename is looked up in the PATH environment variable. If empty, the filename is derived from the architecture setting.">; def EmulatorArgs: Property<"emulator-args", "Args">, Global, DefaultStringValue<"">, diff --git a/lldb/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp b/lldb/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp index 3535a5ad739d..0929a060d0b8 100644 --- a/lldb/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp +++ b/lldb/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp @@ -96,7 +96,8 @@ bool PlatformRemoteGDBServer::GetModuleSpec(const FileSpec &module_file_spec, const auto module_path = module_file_spec.GetPath(false); - if (!m_gdb_client.GetModuleInfo(module_file_spec, arch, module_spec)) { + if (!m_gdb_client_up || + !m_gdb_client_up->GetModuleInfo(module_file_spec, arch, module_spec)) { LLDB_LOGF( log, "PlatformRemoteGDBServer::%s - failed to get module info for %s:%s", @@ -127,11 +128,7 @@ Status PlatformRemoteGDBServer::GetFileWithUUID(const FileSpec &platform_file, /// Default Constructor PlatformRemoteGDBServer::PlatformRemoteGDBServer() - : Platform(false), // This is a remote platform - m_gdb_client() { - m_gdb_client.SetPacketTimeout( - process_gdb_remote::ProcessGDBRemote::GetPacketTimeout()); -} + : Platform(/*is_host=*/false) {} /// Destructor. /// @@ -147,29 +144,36 @@ size_t PlatformRemoteGDBServer::GetSoftwareBreakpointTrapOpcode( } bool PlatformRemoteGDBServer::GetRemoteOSVersion() { - m_os_version = m_gdb_client.GetOSVersion(); + if (m_gdb_client_up) + m_os_version = m_gdb_client_up->GetOSVersion(); return !m_os_version.empty(); } llvm::Optional<std::string> PlatformRemoteGDBServer::GetRemoteOSBuildString() { - return m_gdb_client.GetOSBuildString(); + if (!m_gdb_client_up) + return llvm::None; + return m_gdb_client_up->GetOSBuildString(); } llvm::Optional<std::string> PlatformRemoteGDBServer::GetRemoteOSKernelDescription() { - return m_gdb_client.GetOSKernelDescription(); + if (!m_gdb_client_up) + return llvm::None; + return m_gdb_client_up->GetOSKernelDescription(); } // Remote Platform subclasses need to override this function ArchSpec PlatformRemoteGDBServer::GetRemoteSystemArchitecture() { - return m_gdb_client.GetSystemArchitecture(); + if (!m_gdb_client_up) + return ArchSpec(); + return m_gdb_client_up->GetSystemArchitecture(); } FileSpec PlatformRemoteGDBServer::GetRemoteWorkingDirectory() { if (IsConnected()) { Log *log = GetLogIfAnyCategoriesSet(LIBLLDB_LOG_PLATFORM); FileSpec working_dir; - if (m_gdb_client.GetWorkingDir(working_dir) && log) + if (m_gdb_client_up->GetWorkingDir(working_dir) && log) LLDB_LOGF(log, "PlatformRemoteGDBServer::GetRemoteWorkingDirectory() -> '%s'", working_dir.GetCString()); @@ -187,13 +191,17 @@ bool PlatformRemoteGDBServer::SetRemoteWorkingDirectory( Log *log = GetLogIfAnyCategoriesSet(LIBLLDB_LOG_PLATFORM); LLDB_LOGF(log, "PlatformRemoteGDBServer::SetRemoteWorkingDirectory('%s')", working_dir.GetCString()); - return m_gdb_client.SetWorkingDir(working_dir) == 0; + return m_gdb_client_up->SetWorkingDir(working_dir) == 0; } else return Platform::SetRemoteWorkingDirectory(working_dir); } bool PlatformRemoteGDBServer::IsConnected() const { - return m_gdb_client.IsConnected(); + if (m_gdb_client_up) { + assert(m_gdb_client_up->IsConnected()); + return true; + } + return false; } Status PlatformRemoteGDBServer::ConnectRemote(Args &args) { @@ -224,26 +232,31 @@ Status PlatformRemoteGDBServer::ConnectRemote(Args &args) { m_platform_scheme = parsed_url->scheme.str(); m_platform_hostname = parsed_url->hostname.str(); - m_gdb_client.SetConnection(std::make_unique<ConnectionFileDescriptor>()); + auto client_up = + std::make_unique<process_gdb_remote::GDBRemoteCommunicationClient>(); + client_up->SetPacketTimeout( + process_gdb_remote::ProcessGDBRemote::GetPacketTimeout()); + client_up->SetConnection(std::make_unique<ConnectionFileDescriptor>()); if (repro::Generator *g = repro::Reproducer::Instance().GetGenerator()) { repro::GDBRemoteProvider &provider = g->GetOrCreate<repro::GDBRemoteProvider>(); - m_gdb_client.SetPacketRecorder(provider.GetNewPacketRecorder()); + client_up->SetPacketRecorder(provider.GetNewPacketRecorder()); } - m_gdb_client.Connect(url, &error); + client_up->Connect(url, &error); if (error.Fail()) return error; - if (m_gdb_client.HandshakeWithServer(&error)) { - m_gdb_client.GetHostInfo(); + if (client_up->HandshakeWithServer(&error)) { + m_gdb_client_up = std::move(client_up); + m_gdb_client_up->GetHostInfo(); // If a working directory was set prior to connecting, send it down // now. if (m_working_dir) - m_gdb_client.SetWorkingDir(m_working_dir); + m_gdb_client_up->SetWorkingDir(m_working_dir); m_supported_architectures.clear(); - ArchSpec remote_arch = m_gdb_client.GetSystemArchitecture(); + ArchSpec remote_arch = m_gdb_client_up->GetSystemArchitecture(); if (remote_arch) { m_supported_architectures.push_back(remote_arch); if (remote_arch.GetTriple().isArch64Bit()) @@ -251,7 +264,7 @@ Status PlatformRemoteGDBServer::ConnectRemote(Args &args) { ArchSpec(remote_arch.GetTriple().get32BitArchVariant())); } } else { - m_gdb_client.Disconnect(); + client_up->Disconnect(); if (error.Success()) error.SetErrorString("handshake failed"); } @@ -260,13 +273,14 @@ Status PlatformRemoteGDBServer::ConnectRemote(Args &args) { Status PlatformRemoteGDBServer::DisconnectRemote() { Status error; - m_gdb_client.Disconnect(&error); + m_gdb_client_up.reset(); m_remote_signals_sp.reset(); return error; } const char *PlatformRemoteGDBServer::GetHostname() { - m_gdb_client.GetHostname(m_name); + if (m_gdb_client_up) + m_gdb_client_up->GetHostname(m_name); if (m_name.empty()) return nullptr; return m_name.c_str(); @@ -275,7 +289,7 @@ const char *PlatformRemoteGDBServer::GetHostname() { llvm::Optional<std::string> PlatformRemoteGDBServer::DoGetUserName(UserIDResolver::id_t uid) { std::string name; - if (m_gdb_client.GetUserName(uid, name)) + if (m_gdb_client_up && m_gdb_client_up->GetUserName(uid, name)) return std::move(name); return llvm::None; } @@ -283,7 +297,7 @@ PlatformRemoteGDBServer::DoGetUserName(UserIDResolver::id_t uid) { llvm::Optional<std::string> PlatformRemoteGDBServer::DoGetGroupName(UserIDResolver::id_t gid) { std::string name; - if (m_gdb_client.GetGroupName(gid, name)) + if (m_gdb_client_up && m_gdb_client_up->GetGroupName(gid, name)) return std::move(name); return llvm::None; } @@ -291,12 +305,16 @@ PlatformRemoteGDBServer::DoGetGroupName(UserIDResolver::id_t gid) { uint32_t PlatformRemoteGDBServer::FindProcesses( const ProcessInstanceInfoMatch &match_info, ProcessInstanceInfoList &process_infos) { - return m_gdb_client.FindProcesses(match_info, process_infos); + if (m_gdb_client_up) + return m_gdb_client_up->FindProcesses(match_info, process_infos); + return 0; } bool PlatformRemoteGDBServer::GetProcessInfo( lldb::pid_t pid, ProcessInstanceInfo &process_info) { - return m_gdb_client.GetProcessInfo(pid, process_info); + if (m_gdb_client_up) + return m_gdb_client_up->GetProcessInfo(pid, process_info); + return false; } Status PlatformRemoteGDBServer::LaunchProcess(ProcessLaunchInfo &launch_info) { @@ -305,6 +323,8 @@ Status PlatformRemoteGDBServer::LaunchProcess(ProcessLaunchInfo &launch_info) { LLDB_LOGF(log, "PlatformRemoteGDBServer::%s() called", __FUNCTION__); + if (!IsConnected()) + return Status("Not connected."); auto num_file_actions = launch_info.GetNumFileActions(); for (decltype(num_file_actions) i = 0; i < num_file_actions; ++i) { const auto file_action = launch_info.GetFileActionAtIndex(i); @@ -312,34 +332,34 @@ Status PlatformRemoteGDBServer::LaunchProcess(ProcessLaunchInfo &launch_info) { continue; switch (file_action->GetFD()) { case STDIN_FILENO: - m_gdb_client.SetSTDIN(file_action->GetFileSpec()); + m_gdb_client_up->SetSTDIN(file_action->GetFileSpec()); break; case STDOUT_FILENO: - m_gdb_client.SetSTDOUT(file_action->GetFileSpec()); + m_gdb_client_up->SetSTDOUT(file_action->GetFileSpec()); break; case STDERR_FILENO: - m_gdb_client.SetSTDERR(file_action->GetFileSpec()); + m_gdb_client_up->SetSTDERR(file_action->GetFileSpec()); break; } } - m_gdb_client.SetDisableASLR( + m_gdb_client_up->SetDisableASLR( launch_info.GetFlags().Test(eLaunchFlagDisableASLR)); - m_gdb_client.SetDetachOnError( + m_gdb_client_up->SetDetachOnError( launch_info.GetFlags().Test(eLaunchFlagDetachOnError)); FileSpec working_dir = launch_info.GetWorkingDirectory(); if (working_dir) { - m_gdb_client.SetWorkingDir(working_dir); + m_gdb_client_up->SetWorkingDir(working_dir); } // Send the environment and the program + arguments after we connect - m_gdb_client.SendEnvironment(launch_info.GetEnvironment()); + m_gdb_client_up->SendEnvironment(launch_info.GetEnvironment()); ArchSpec arch_spec = launch_info.GetArchitecture(); const char *arch_triple = arch_spec.GetTriple().str().c_str(); - m_gdb_client.SendLaunchArchPacket(arch_triple); + m_gdb_client_up->SendLaunchArchPacket(arch_triple); LLDB_LOGF( log, "PlatformRemoteGDBServer::%s() set launch architecture triple to '%s'", @@ -349,14 +369,14 @@ Status PlatformRemoteGDBServer::LaunchProcess(ProcessLaunchInfo &launch_info) { { // Scope for the scoped timeout object process_gdb_remote::GDBRemoteCommunication::ScopedTimeout timeout( - m_gdb_client, std::chrono::seconds(5)); - arg_packet_err = m_gdb_client.SendArgumentsPacket(launch_info); + *m_gdb_client_up, std::chrono::seconds(5)); + arg_packet_err = m_gdb_client_up->SendArgumentsPacket(launch_info); } if (arg_packet_err == 0) { std::string error_str; - if (m_gdb_client.GetLaunchSuccess(error_str)) { - const auto pid = m_gdb_client.GetCurrentProcessID(false); + if (m_gdb_client_up->GetLaunchSuccess(error_str)) { + const auto pid = m_gdb_client_up->GetCurrentProcessID(false); if (pid != LLDB_INVALID_PROCESS_ID) { launch_info.SetProcessID(pid); LLDB_LOGF(log, @@ -428,6 +448,8 @@ PlatformRemoteGDBServer::DebugProcess(ProcessLaunchInfo &launch_info, bool PlatformRemoteGDBServer::LaunchGDBServer(lldb::pid_t &pid, std::string &connect_url) { + assert(IsConnected()); + ArchSpec remote_arch = GetRemoteSystemArchitecture(); llvm::Triple &remote_triple = remote_arch.GetTriple(); @@ -440,11 +462,11 @@ bool PlatformRemoteGDBServer::LaunchGDBServer(lldb::pid_t &pid, // localhost, so we will need the remote debugserver to accept connections // only from localhost, no matter what our current hostname is launch_result = - m_gdb_client.LaunchGDBServer("127.0.0.1", pid, port, socket_name); + m_gdb_client_up->LaunchGDBServer("127.0.0.1", pid, port, socket_name); } else { // All other hosts should use their actual hostname launch_result = - m_gdb_client.LaunchGDBServer(nullptr, pid, port, socket_name); + m_gdb_client_up->LaunchGDBServer(nullptr, pid, port, socket_name); } if (!launch_result) @@ -457,7 +479,8 @@ bool PlatformRemoteGDBServer::LaunchGDBServer(lldb::pid_t &pid, } bool PlatformRemoteGDBServer::KillSpawnedProcess(lldb::pid_t pid) { - return m_gdb_client.KillSpawnedProcess(pid); + assert(IsConnected()); + return m_gdb_client_up->KillSpawnedProcess(pid); } lldb::ProcessSP PlatformRemoteGDBServer::Attach( @@ -513,7 +536,9 @@ lldb::ProcessSP PlatformRemoteGDBServer::Attach( Status PlatformRemoteGDBServer::MakeDirectory(const FileSpec &file_spec, uint32_t mode) { - Status error = m_gdb_client.MakeDirectory(file_spec, mode); + if (!IsConnected()) + return Status("Not connected."); + Status error = m_gdb_client_up->MakeDirectory(file_spec, mode); Log *log = GetLogIfAnyCategoriesSet(LIBLLDB_LOG_PLATFORM); LLDB_LOGF(log, "PlatformRemoteGDBServer::MakeDirectory(path='%s', mode=%o) " @@ -524,7 +549,10 @@ Status PlatformRemoteGDBServer::MakeDirectory(const FileSpec &file_spec, Status PlatformRemoteGDBServer::GetFilePermissions(const FileSpec &file_spec, uint32_t &file_permissions) { - Status error = m_gdb_client.GetFilePermissions(file_spec, file_permissions); + if (!IsConnected()) + return Status("Not connected."); + Status error = + m_gdb_client_up->GetFilePermissions(file_spec, file_permissions); Log *log = GetLogIfAnyCategoriesSet(LIBLLDB_LOG_PLATFORM); LLDB_LOGF(log, "PlatformRemoteGDBServer::GetFilePermissions(path='%s', " @@ -536,7 +564,10 @@ Status PlatformRemoteGDBServer::GetFilePermissions(const FileSpec &file_spec, Status PlatformRemoteGDBServer::SetFilePermissions(const FileSpec &file_spec, uint32_t file_permissions) { - Status error = m_gdb_client.SetFilePermissions(file_spec, file_permissions); + if (!IsConnected()) + return Status("Not connected."); + Status error = + m_gdb_client_up->SetFilePermissions(file_spec, file_permissions); Log *log = GetLogIfAnyCategoriesSet(LIBLLDB_LOG_PLATFORM); LLDB_LOGF(log, "PlatformRemoteGDBServer::SetFilePermissions(path='%s', " @@ -550,33 +581,47 @@ lldb::user_id_t PlatformRemoteGDBServer::OpenFile(const FileSpec &file_spec, File::OpenOptions flags, uint32_t mode, Status &error) { - return m_gdb_client.OpenFile(file_spec, flags, mode, error); + if (IsConnected()) + return m_gdb_client_up->OpenFile(file_spec, flags, mode, error); + return LLDB_INVALID_UID; } bool PlatformRemoteGDBServer::CloseFile(lldb::user_id_t fd, Status &error) { - return m_gdb_client.CloseFile(fd, error); + if (IsConnected()) + return m_gdb_client_up->CloseFile(fd, error); + error = Status("Not connected."); + return false; } lldb::user_id_t PlatformRemoteGDBServer::GetFileSize(const FileSpec &file_spec) { - return m_gdb_client.GetFileSize(file_spec); + if (IsConnected()) + return m_gdb_client_up->GetFileSize(file_spec); + return LLDB_INVALID_UID; } void PlatformRemoteGDBServer::AutoCompleteDiskFileOrDirectory( CompletionRequest &request, bool only_dir) { - m_gdb_client.AutoCompleteDiskFileOrDirectory(request, only_dir); + if (IsConnected()) + m_gdb_client_up->AutoCompleteDiskFileOrDirectory(request, only_dir); } uint64_t PlatformRemoteGDBServer::ReadFile(lldb::user_id_t fd, uint64_t offset, void *dst, uint64_t dst_len, Status &error) { - return m_gdb_client.ReadFile(fd, offset, dst, dst_len, error); + if (IsConnected()) + return m_gdb_client_up->ReadFile(fd, offset, dst, dst_len, error); + error = Status("Not connected."); + return 0; } uint64_t PlatformRemoteGDBServer::WriteFile(lldb::user_id_t fd, uint64_t offset, const void *src, uint64_t src_len, Status &error) { - return m_gdb_client.WriteFile(fd, offset, src, src_len, error); + if (IsConnected()) + return m_gdb_client_up->WriteFile(fd, offset, src, src_len, error); + error = Status("Not connected."); + return 0; } Status PlatformRemoteGDBServer::PutFile(const FileSpec &source, @@ -589,7 +634,9 @@ Status PlatformRemoteGDBServer::CreateSymlink( const FileSpec &src, // The name of the link is in src const FileSpec &dst) // The symlink points to dst { - Status error = m_gdb_client.CreateSymlink(src, dst); + if (!IsConnected()) + return Status("Not connected."); + Status error = m_gdb_client_up->CreateSymlink(src, dst); Log *log = GetLogIfAnyCategoriesSet(LIBLLDB_LOG_PLATFORM); LLDB_LOGF(log, "PlatformRemoteGDBServer::CreateSymlink(src='%s', dst='%s') " @@ -600,7 +647,9 @@ Status PlatformRemoteGDBServer::CreateSymlink( } Status PlatformRemoteGDBServer::Unlink(const FileSpec &file_spec) { - Status error = m_gdb_client.Unlink(file_spec); + if (!IsConnected()) + return Status("Not connected."); + Status error = m_gdb_client_up->Unlink(file_spec); Log *log = GetLogIfAnyCategoriesSet(LIBLLDB_LOG_PLATFORM); LLDB_LOGF(log, "PlatformRemoteGDBServer::Unlink(path='%s') error = %u (%s)", file_spec.GetCString(), error.GetError(), error.AsCString()); @@ -608,7 +657,9 @@ Status PlatformRemoteGDBServer::Unlink(const FileSpec &file_spec) { } bool PlatformRemoteGDBServer::GetFileExists(const FileSpec &file_spec) { - return m_gdb_client.GetFileExists(file_spec); + if (IsConnected()) + return m_gdb_client_up->GetFileExists(file_spec); + return false; } Status PlatformRemoteGDBServer::RunShellCommand( @@ -621,8 +672,10 @@ Status PlatformRemoteGDBServer::RunShellCommand( std::string *command_output, // Pass NULL if you don't want the command output const Timeout<std::micro> &timeout) { - return m_gdb_client.RunShellCommand(command, working_dir, status_ptr, - signo_ptr, command_output, timeout); + if (!IsConnected()) + return Status("Not connected."); + return m_gdb_client_up->RunShellCommand(command, working_dir, status_ptr, + signo_ptr, command_output, timeout); } void PlatformRemoteGDBServer::CalculateTrapHandlerSymbolNames() { @@ -642,7 +695,7 @@ const UnixSignalsSP &PlatformRemoteGDBServer::GetRemoteUnixSignals() { StringExtractorGDBRemote response; auto result = - m_gdb_client.SendPacketAndWaitForResponse("jSignalsInfo", response); + m_gdb_client_up->SendPacketAndWaitForResponse("jSignalsInfo", response); if (result != decltype(result)::Success || response.GetResponseType() != response.eResponse) @@ -693,7 +746,7 @@ const UnixSignalsSP &PlatformRemoteGDBServer::GetRemoteUnixSignals() { if (object_sp && object_sp->IsValid()) notify = object_sp->GetBooleanValue(); - std::string description{""}; + std::string description; object_sp = dict->GetValueForKey("description"); if (object_sp && object_sp->IsValid()) description = std::string(object_sp->GetStringValue()); @@ -754,7 +807,9 @@ size_t PlatformRemoteGDBServer::ConnectToWaitingProcesses(Debugger &debugger, size_t PlatformRemoteGDBServer::GetPendingGdbServerList( std::vector<std::string> &connection_urls) { std::vector<std::pair<uint16_t, std::string>> remote_servers; - m_gdb_client.QueryGDBServer(remote_servers); + if (!IsConnected()) + return 0; + m_gdb_client_up->QueryGDBServer(remote_servers); for (const auto &gdbserver : remote_servers) { const char *socket_name_cstr = gdbserver.second.empty() ? nullptr : gdbserver.second.c_str(); diff --git a/lldb/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.h b/lldb/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.h index f594f43b3f13..263516f520d5 100644 --- a/lldb/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.h +++ b/lldb/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.h @@ -14,7 +14,6 @@ #include "Plugins/Process/Utility/GDBRemoteSignals.h" #include "Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.h" -#include "Plugins/Process/gdb-remote/GDBRemoteCommunicationReplayServer.h" #include "lldb/Target/Platform.h" namespace lldb_private { @@ -154,8 +153,8 @@ public: GetPendingGdbServerList(std::vector<std::string> &connection_urls); protected: - process_gdb_remote::GDBRemoteCommunicationClient m_gdb_client; - process_gdb_remote::GDBRemoteCommunicationReplayServer m_gdb_replay_server; + std::unique_ptr<process_gdb_remote::GDBRemoteCommunicationClient> + m_gdb_client_up; std::string m_platform_description; // After we connect we can get a more // complete description of what we are // connected to diff --git a/lldb/source/Plugins/Process/FreeBSD/NativeProcessFreeBSD.cpp b/lldb/source/Plugins/Process/FreeBSD/NativeProcessFreeBSD.cpp index a62d3c1ba052..21c9ead0eca4 100644 --- a/lldb/source/Plugins/Process/FreeBSD/NativeProcessFreeBSD.cpp +++ b/lldb/source/Plugins/Process/FreeBSD/NativeProcessFreeBSD.cpp @@ -54,7 +54,7 @@ llvm::Expected<std::unique_ptr<NativeProcessProtocol>> NativeProcessFreeBSD::Factory::Launch(ProcessLaunchInfo &launch_info, NativeDelegate &native_delegate, MainLoop &mainloop) const { - Log *log(ProcessPOSIXLog::GetLogIfAllCategoriesSet(POSIX_LOG_PROCESS)); + Log *log = GetLog(POSIXLog::Process); Status status; ::pid_t pid = ProcessLauncherPosixFork() @@ -108,7 +108,7 @@ llvm::Expected<std::unique_ptr<NativeProcessProtocol>> NativeProcessFreeBSD::Factory::Attach( lldb::pid_t pid, NativeProcessProtocol::NativeDelegate &native_delegate, MainLoop &mainloop) const { - Log *log(ProcessPOSIXLog::GetLogIfAllCategoriesSet(POSIX_LOG_PROCESS)); + Log *log = GetLog(POSIXLog::Process); LLDB_LOG(log, "pid = {0:x}", pid); // Retrieve the architecture for the running process. @@ -135,7 +135,8 @@ NativeProcessFreeBSD::Factory::GetSupportedExtensions() const { Extension::savecore | #endif Extension::multiprocess | Extension::fork | Extension::vfork | - Extension::pass_signals | Extension::auxv | Extension::libraries_svr4; + Extension::pass_signals | Extension::auxv | Extension::libraries_svr4 | + Extension::siginfo_read; } // Public Instance Methods @@ -170,7 +171,7 @@ void NativeProcessFreeBSD::MonitorCallback(lldb::pid_t pid, int signal) { } void NativeProcessFreeBSD::MonitorExited(lldb::pid_t pid, WaitStatus status) { - Log *log(ProcessPOSIXLog::GetLogIfAllCategoriesSet(POSIX_LOG_PROCESS)); + Log *log = GetLog(POSIXLog::Process); LLDB_LOG(log, "got exit signal({0}) , pid = {1}", status, pid); @@ -193,7 +194,7 @@ void NativeProcessFreeBSD::MonitorSIGSTOP(lldb::pid_t pid) { } void NativeProcessFreeBSD::MonitorSIGTRAP(lldb::pid_t pid) { - Log *log(ProcessPOSIXLog::GetLogIfAllCategoriesSet(POSIX_LOG_PROCESS)); + Log *log = GetLog(POSIXLog::Process); struct ptrace_lwpinfo info; const auto siginfo_err = PtraceWrapper(PT_LWPINFO, pid, &info, sizeof(info)); @@ -254,6 +255,7 @@ void NativeProcessFreeBSD::MonitorSIGTRAP(lldb::pid_t pid) { for (const auto &thread : m_threads) static_cast<NativeThreadFreeBSD &>(*thread).SetStoppedByExec(); + SetCurrentThreadID(m_threads.front()->GetID()); SetState(StateType::eStateStopped, true); return; } @@ -312,6 +314,7 @@ void NativeProcessFreeBSD::MonitorSIGTRAP(lldb::pid_t pid) { } else thread->SetStoppedByBreakpoint(); FixupBreakpointPCAsNeeded(*thread); + SetCurrentThreadID(thread->GetID()); } SetState(StateType::eStateStopped, true); return; @@ -333,11 +336,13 @@ void NativeProcessFreeBSD::MonitorSIGTRAP(lldb::pid_t pid) { if (wp_index != LLDB_INVALID_INDEX32) { regctx.ClearWatchpointHit(wp_index); thread->SetStoppedByWatchpoint(wp_index); + SetCurrentThreadID(thread->GetID()); SetState(StateType::eStateStopped, true); break; } thread->SetStoppedByTrace(); + SetCurrentThreadID(thread->GetID()); } SetState(StateType::eStateStopped, true); @@ -352,7 +357,7 @@ void NativeProcessFreeBSD::MonitorSIGTRAP(lldb::pid_t pid) { } void NativeProcessFreeBSD::MonitorSignal(lldb::pid_t pid, int signal) { - Log *log(ProcessPOSIXLog::GetLogIfAllCategoriesSet(POSIX_LOG_PROCESS)); + Log *log = GetLog(POSIXLog::Process); struct ptrace_lwpinfo info; const auto siginfo_err = PtraceWrapper(PT_LWPINFO, pid, &info, sizeof(info)); @@ -370,9 +375,10 @@ void NativeProcessFreeBSD::MonitorSignal(lldb::pid_t pid, int signal) { static_cast<NativeThreadFreeBSD &>(*abs_thread); assert(info.pl_lwpid >= 0); if (info.pl_lwpid == 0 || - static_cast<lldb::tid_t>(info.pl_lwpid) == thread.GetID()) + static_cast<lldb::tid_t>(info.pl_lwpid) == thread.GetID()) { thread.SetStoppedBySignal(info.pl_siginfo.si_signo, &info.pl_siginfo); - else + SetCurrentThreadID(thread.GetID()); + } else thread.SetStoppedWithNoReason(); } SetState(StateType::eStateStopped, true); @@ -380,7 +386,7 @@ void NativeProcessFreeBSD::MonitorSignal(lldb::pid_t pid, int signal) { Status NativeProcessFreeBSD::PtraceWrapper(int req, lldb::pid_t pid, void *addr, int data, int *result) { - Log *log(ProcessPOSIXLog::GetLogIfAllCategoriesSet(POSIX_LOG_PTRACE)); + Log *log = GetLog(POSIXLog::Ptrace); Status error; int ret; @@ -424,7 +430,7 @@ NativeProcessFreeBSD::GetSoftwareBreakpointTrapOpcode(size_t size_hint) { } Status NativeProcessFreeBSD::Resume(const ResumeActionList &resume_actions) { - Log *log(ProcessPOSIXLog::GetLogIfAllCategoriesSet(POSIX_LOG_PROCESS)); + Log *log = GetLog(POSIXLog::Process); LLDB_LOG(log, "pid {0}", GetID()); Status ret; @@ -521,7 +527,7 @@ Status NativeProcessFreeBSD::Signal(int signo) { Status NativeProcessFreeBSD::Interrupt() { return Halt(); } Status NativeProcessFreeBSD::Kill() { - Log *log(ProcessPOSIXLog::GetLogIfAllCategoriesSet(POSIX_LOG_PROCESS)); + Log *log = GetLog(POSIXLog::Process); LLDB_LOG(log, "pid {0}", GetID()); Status error; @@ -608,7 +614,7 @@ Status NativeProcessFreeBSD::GetMemoryRegionInfo(lldb::addr_t load_addr, } Status NativeProcessFreeBSD::PopulateMemoryRegionCache() { - Log *log(ProcessPOSIXLog::GetLogIfAllCategoriesSet(POSIX_LOG_PROCESS)); + Log *log = GetLog(POSIXLog::Process); // If our cache is empty, pull the latest. There should always be at least // one memory region if memory region handling is supported. if (!m_mem_region_cache.empty()) { @@ -735,7 +741,7 @@ NativeProcessFreeBSD::GetFileLoadAddress(const llvm::StringRef &file_name, } void NativeProcessFreeBSD::SigchldHandler() { - Log *log(ProcessPOSIXLog::GetLogIfAllCategoriesSet(POSIX_LOG_PROCESS)); + Log *log = GetLog(POSIXLog::Process); int status; ::pid_t wait_pid = llvm::sys::RetryAfterSignal(-1, waitpid, GetID(), &status, WNOHANG); @@ -780,7 +786,7 @@ bool NativeProcessFreeBSD::HasThreadNoLock(lldb::tid_t thread_id) { } NativeThreadFreeBSD &NativeProcessFreeBSD::AddThread(lldb::tid_t thread_id) { - Log *log(ProcessPOSIXLog::GetLogIfAllCategoriesSet(POSIX_LOG_THREAD)); + Log *log = GetLog(POSIXLog::Thread); LLDB_LOG(log, "pid {0} adding thread with tid {1}", GetID(), thread_id); assert(thread_id > 0); @@ -796,7 +802,7 @@ NativeThreadFreeBSD &NativeProcessFreeBSD::AddThread(lldb::tid_t thread_id) { } void NativeProcessFreeBSD::RemoveThread(lldb::tid_t thread_id) { - Log *log(ProcessPOSIXLog::GetLogIfAllCategoriesSet(POSIX_LOG_THREAD)); + Log *log = GetLog(POSIXLog::Thread); LLDB_LOG(log, "pid {0} removing thread with tid {1}", GetID(), thread_id); assert(thread_id > 0); @@ -809,6 +815,9 @@ void NativeProcessFreeBSD::RemoveThread(lldb::tid_t thread_id) { break; } } + + if (GetCurrentThreadID() == thread_id) + SetCurrentThreadID(m_threads.front()->GetID()); } Status NativeProcessFreeBSD::Attach() { @@ -845,7 +854,7 @@ Status NativeProcessFreeBSD::ReadMemory(lldb::addr_t addr, void *buf, unsigned char *dst = static_cast<unsigned char *>(buf); struct ptrace_io_desc io; - Log *log(ProcessPOSIXLog::GetLogIfAllCategoriesSet(POSIX_LOG_MEMORY)); + Log *log = GetLog(POSIXLog::Memory); LLDB_LOG(log, "addr = {0}, buf = {1}, size = {2}", addr, buf, size); bytes_read = 0; @@ -873,7 +882,7 @@ Status NativeProcessFreeBSD::WriteMemory(lldb::addr_t addr, const void *buf, Status error; struct ptrace_io_desc io; - Log *log(ProcessPOSIXLog::GetLogIfAllCategoriesSet(POSIX_LOG_MEMORY)); + Log *log = GetLog(POSIXLog::Memory); LLDB_LOG(log, "addr = {0}, buf = {1}, size = {2}", addr, buf, size); bytes_written = 0; @@ -953,7 +962,7 @@ bool NativeProcessFreeBSD::SupportHardwareSingleStepping() const { void NativeProcessFreeBSD::MonitorClone(::pid_t child_pid, bool is_vfork, NativeThreadFreeBSD &parent_thread) { - Log *log(ProcessPOSIXLog::GetLogIfAllCategoriesSet(POSIX_LOG_PROCESS)); + Log *log = GetLog(POSIXLog::Process); LLDB_LOG(log, "fork, child_pid={0}", child_pid); int status; diff --git a/lldb/source/Plugins/Process/FreeBSD/NativeRegisterContextFreeBSD_arm64.cpp b/lldb/source/Plugins/Process/FreeBSD/NativeRegisterContextFreeBSD_arm64.cpp index 4578138a89b3..143d94069bc6 100644 --- a/lldb/source/Plugins/Process/FreeBSD/NativeRegisterContextFreeBSD_arm64.cpp +++ b/lldb/source/Plugins/Process/FreeBSD/NativeRegisterContextFreeBSD_arm64.cpp @@ -227,7 +227,7 @@ llvm::Error NativeRegisterContextFreeBSD_arm64::CopyHardwareWatchpointsFrom( llvm::Error NativeRegisterContextFreeBSD_arm64::ReadHardwareDebugInfo() { #ifdef LLDB_HAS_FREEBSD_WATCHPOINT - Log *log(ProcessPOSIXLog::GetLogIfAllCategoriesSet(POSIX_LOG_REGISTERS)); + Log *log = GetLog(POSIXLog::Registers); // we're fully stateful, so no need to reread control registers ever if (m_read_dbreg) diff --git a/lldb/source/Plugins/Process/FreeBSD/NativeThreadFreeBSD.cpp b/lldb/source/Plugins/Process/FreeBSD/NativeThreadFreeBSD.cpp index 80b3527aebce..a75668f3b5c7 100644 --- a/lldb/source/Plugins/Process/FreeBSD/NativeThreadFreeBSD.cpp +++ b/lldb/source/Plugins/Process/FreeBSD/NativeThreadFreeBSD.cpp @@ -75,7 +75,7 @@ Status NativeThreadFreeBSD::Suspend() { void NativeThreadFreeBSD::SetStoppedBySignal(uint32_t signo, const siginfo_t *info) { - Log *log(ProcessPOSIXLog::GetLogIfAllCategoriesSet(POSIX_LOG_THREAD)); + Log *log = GetLog(POSIXLog::Thread); LLDB_LOG(log, "tid = {0} in called with signal {1}", GetID(), signo); SetStopped(); @@ -178,7 +178,7 @@ void NativeThreadFreeBSD::SetStepping() { } std::string NativeThreadFreeBSD::GetName() { - Log *log(ProcessPOSIXLog::GetLogIfAllCategoriesSet(POSIX_LOG_THREAD)); + Log *log = GetLog(POSIXLog::Thread); std::vector<struct kinfo_proc> kp; int mib[4] = {CTL_KERN, KERN_PROC, KERN_PROC_PID | KERN_PROC_INC_THREAD, @@ -213,7 +213,7 @@ lldb::StateType NativeThreadFreeBSD::GetState() { return m_state; } bool NativeThreadFreeBSD::GetStopReason(ThreadStopInfo &stop_info, std::string &description) { - Log *log(ProcessPOSIXLog::GetLogIfAllCategoriesSet(POSIX_LOG_THREAD)); + Log *log = GetLog(POSIXLog::Thread); description.clear(); switch (m_state) { @@ -313,3 +313,27 @@ NativeThreadFreeBSD::CopyWatchpointsFrom(NativeThreadFreeBSD &source) { } return s; } + +llvm::Expected<std::unique_ptr<llvm::MemoryBuffer>> +NativeThreadFreeBSD::GetSiginfo() const { + Log *log = GetLog(POSIXLog::Process); + + struct ptrace_lwpinfo info; + const auto siginfo_err = NativeProcessFreeBSD::PtraceWrapper( + PT_LWPINFO, GetID(), &info, sizeof(info)); + if (siginfo_err.Fail()) { + LLDB_LOG(log, "PT_LWPINFO failed {0}", siginfo_err); + return siginfo_err.ToError(); + } + + if (info.pl_event != PL_EVENT_SIGNAL) + return llvm::createStringError(llvm::inconvertibleErrorCode(), + "Thread not signaled"); + if (!(info.pl_flags & PL_FLAG_SI)) + return llvm::createStringError(llvm::inconvertibleErrorCode(), + "No siginfo for thread"); + + return llvm::MemoryBuffer::getMemBufferCopy( + llvm::StringRef(reinterpret_cast<const char *>(&info.pl_siginfo), + sizeof(info.pl_siginfo))); +} diff --git a/lldb/source/Plugins/Process/FreeBSD/NativeThreadFreeBSD.h b/lldb/source/Plugins/Process/FreeBSD/NativeThreadFreeBSD.h index 3ec6daa409e4..6294a7a70963 100644 --- a/lldb/source/Plugins/Process/FreeBSD/NativeThreadFreeBSD.h +++ b/lldb/source/Plugins/Process/FreeBSD/NativeThreadFreeBSD.h @@ -47,6 +47,9 @@ public: Status RemoveHardwareBreakpoint(lldb::addr_t addr) override; + llvm::Expected<std::unique_ptr<llvm::MemoryBuffer>> + GetSiginfo() const override; + private: // Interface for friend classes diff --git a/lldb/source/Plugins/Process/FreeBSDKernel/ProcessFreeBSDKernel.cpp b/lldb/source/Plugins/Process/FreeBSDKernel/ProcessFreeBSDKernel.cpp index 339d33d25110..e3707365a9c3 100644 --- a/lldb/source/Plugins/Process/FreeBSDKernel/ProcessFreeBSDKernel.cpp +++ b/lldb/source/Plugins/Process/FreeBSDKernel/ProcessFreeBSDKernel.cpp @@ -137,12 +137,115 @@ bool ProcessFreeBSDKernel::DoUpdateThreadList(ThreadList &old_thread_list, return false; } - const Symbol *pcb_sym = - GetTarget().GetExecutableModule()->FindFirstSymbolWithNameAndType( - ConstString("dumppcb")); - ThreadSP thread_sp(new ThreadFreeBSDKernel( - *this, 1, pcb_sym ? pcb_sym->GetFileAddress() : LLDB_INVALID_ADDRESS)); - new_thread_list.AddThread(thread_sp); + Status error; + + // struct field offsets are written as symbols so that we don't have + // to figure them out ourselves + int32_t offset_p_list = ReadSignedIntegerFromMemory( + FindSymbol("proc_off_p_list"), 4, -1, error); + int32_t offset_p_pid = + ReadSignedIntegerFromMemory(FindSymbol("proc_off_p_pid"), 4, -1, error); + int32_t offset_p_threads = ReadSignedIntegerFromMemory( + FindSymbol("proc_off_p_threads"), 4, -1, error); + int32_t offset_p_comm = ReadSignedIntegerFromMemory( + FindSymbol("proc_off_p_comm"), 4, -1, error); + + int32_t offset_td_tid = ReadSignedIntegerFromMemory( + FindSymbol("thread_off_td_tid"), 4, -1, error); + int32_t offset_td_plist = ReadSignedIntegerFromMemory( + FindSymbol("thread_off_td_plist"), 4, -1, error); + int32_t offset_td_pcb = ReadSignedIntegerFromMemory( + FindSymbol("thread_off_td_pcb"), 4, -1, error); + int32_t offset_td_oncpu = ReadSignedIntegerFromMemory( + FindSymbol("thread_off_td_oncpu"), 4, -1, error); + int32_t offset_td_name = ReadSignedIntegerFromMemory( + FindSymbol("thread_off_td_name"), 4, -1, error); + + // fail if we were not able to read any of the offsets + if (offset_p_list == -1 || offset_p_pid == -1 || offset_p_threads == -1 || + offset_p_comm == -1 || offset_td_tid == -1 || offset_td_plist == -1 || + offset_td_pcb == -1 || offset_td_oncpu == -1 || offset_td_name == -1) + return false; + + // dumptid contains the thread-id of the crashing thread + // dumppcb contains its PCB + int32_t dumptid = + ReadSignedIntegerFromMemory(FindSymbol("dumptid"), 4, -1, error); + lldb::addr_t dumppcb = FindSymbol("dumppcb"); + + // stoppcbs is an array of PCBs on all CPUs + // each element is of size pcb_size + int32_t pcbsize = + ReadSignedIntegerFromMemory(FindSymbol("pcb_size"), 4, -1, error); + lldb::addr_t stoppcbs = FindSymbol("stoppcbs"); + + // from FreeBSD sys/param.h + constexpr size_t fbsd_maxcomlen = 19; + + // iterate through a linked list of all processes + // allproc is a pointer to the first list element, p_list field + // (found at offset_p_list) specifies the next element + for (lldb::addr_t proc = + ReadPointerFromMemory(FindSymbol("allproc"), error); + proc != 0 && proc != LLDB_INVALID_ADDRESS; + proc = ReadPointerFromMemory(proc + offset_p_list, error)) { + int32_t pid = + ReadSignedIntegerFromMemory(proc + offset_p_pid, 4, -1, error); + // process' command-line string + char comm[fbsd_maxcomlen + 1]; + ReadCStringFromMemory(proc + offset_p_comm, comm, sizeof(comm), error); + + // iterate through a linked list of all process' threads + // the initial thread is found in process' p_threads, subsequent + // elements are linked via td_plist field + for (lldb::addr_t td = + ReadPointerFromMemory(proc + offset_p_threads, error); + td != 0; td = ReadPointerFromMemory(td + offset_td_plist, error)) { + int32_t tid = + ReadSignedIntegerFromMemory(td + offset_td_tid, 4, -1, error); + lldb::addr_t pcb_addr = + ReadPointerFromMemory(td + offset_td_pcb, error); + // whether process was on CPU (-1 if not, otherwise CPU number) + int32_t oncpu = + ReadSignedIntegerFromMemory(td + offset_td_oncpu, 4, -2, error); + // thread name + char thread_name[fbsd_maxcomlen + 1]; + ReadCStringFromMemory(td + offset_td_name, thread_name, + sizeof(thread_name), error); + + // if we failed to read TID, ignore this thread + if (tid == -1) + continue; + + std::string thread_desc = llvm::formatv("(pid {0}) {1}", pid, comm); + if (*thread_name && strcmp(thread_name, comm)) { + thread_desc += '/'; + thread_desc += thread_name; + } + + // roughly: + // 1. if the thread crashed, its PCB is going to be at "dumppcb" + // 2. if the thread was on CPU, its PCB is going to be on the CPU + // 3. otherwise, its PCB is in the thread struct + if (tid == dumptid) { + // NB: dumppcb can be LLDB_INVALID_ADDRESS if reading it failed + pcb_addr = dumppcb; + thread_desc += " (crashed)"; + } else if (oncpu != -1) { + // if we managed to read stoppcbs and pcb_size, use them to find + // the correct PCB + if (stoppcbs != LLDB_INVALID_ADDRESS && pcbsize > 0) + pcb_addr = stoppcbs + oncpu * pcbsize; + else + pcb_addr = LLDB_INVALID_ADDRESS; + thread_desc += llvm::formatv(" (on CPU {0})", oncpu); + } + + ThreadSP thread_sp{ + new ThreadFreeBSDKernel(*this, tid, pcb_addr, thread_desc)}; + new_thread_list.AddThread(thread_sp); + } + } } else { const uint32_t num_threads = old_thread_list.GetSize(false); for (uint32_t i = 0; i < num_threads; ++i) @@ -163,6 +266,12 @@ DynamicLoader *ProcessFreeBSDKernel::GetDynamicLoader() { return m_dyld_up.get(); } +lldb::addr_t ProcessFreeBSDKernel::FindSymbol(const char *name) { + ModuleSP mod_sp = GetTarget().GetExecutableModule(); + const Symbol *sym = mod_sp->FindFirstSymbolWithNameAndType(ConstString(name)); + return sym ? sym->GetLoadAddress(&GetTarget()) : LLDB_INVALID_ADDRESS; +} + #if LLDB_ENABLE_FBSDVMCORE ProcessFreeBSDKernelFVC::ProcessFreeBSDKernelFVC(lldb::TargetSP target_sp, diff --git a/lldb/source/Plugins/Process/FreeBSDKernel/ProcessFreeBSDKernel.h b/lldb/source/Plugins/Process/FreeBSDKernel/ProcessFreeBSDKernel.h index 558eec5403db..5bd463126307 100644 --- a/lldb/source/Plugins/Process/FreeBSDKernel/ProcessFreeBSDKernel.h +++ b/lldb/source/Plugins/Process/FreeBSDKernel/ProcessFreeBSDKernel.h @@ -46,6 +46,8 @@ public: protected: bool DoUpdateThreadList(lldb_private::ThreadList &old_thread_list, lldb_private::ThreadList &new_thread_list) override; + + lldb::addr_t FindSymbol(const char* name); }; #endif // LLDB_SOURCE_PLUGINS_PROCESS_FREEBSDKERNEL_PROCESSFREEBSDKERNEL_H diff --git a/lldb/source/Plugins/Process/FreeBSDKernel/ThreadFreeBSDKernel.cpp b/lldb/source/Plugins/Process/FreeBSDKernel/ThreadFreeBSDKernel.cpp index 124c65d587ff..8d304086a163 100644 --- a/lldb/source/Plugins/Process/FreeBSDKernel/ThreadFreeBSDKernel.cpp +++ b/lldb/source/Plugins/Process/FreeBSDKernel/ThreadFreeBSDKernel.cpp @@ -24,8 +24,10 @@ using namespace lldb; using namespace lldb_private; ThreadFreeBSDKernel::ThreadFreeBSDKernel(Process &process, lldb::tid_t tid, - lldb::addr_t pcb_addr) - : Thread(process, tid), m_pcb_addr(pcb_addr) {} + lldb::addr_t pcb_addr, + std::string thread_name) + : Thread(process, tid), m_thread_name(std::move(thread_name)), + m_pcb_addr(pcb_addr) {} ThreadFreeBSDKernel::~ThreadFreeBSDKernel() {} @@ -61,9 +63,8 @@ ThreadFreeBSDKernel::CreateRegisterContextForFrame(StackFrame *frame) { m_pcb_addr); break; case llvm::Triple::x86: - m_thread_reg_ctx_sp = - std::make_shared<RegisterContextFreeBSDKernel_i386>( - *this, new RegisterContextFreeBSD_i386(arch), m_pcb_addr); + m_thread_reg_ctx_sp = std::make_shared<RegisterContextFreeBSDKernel_i386>( + *this, new RegisterContextFreeBSD_i386(arch), m_pcb_addr); break; case llvm::Triple::x86_64: m_thread_reg_ctx_sp = diff --git a/lldb/source/Plugins/Process/FreeBSDKernel/ThreadFreeBSDKernel.h b/lldb/source/Plugins/Process/FreeBSDKernel/ThreadFreeBSDKernel.h index 2842eba64e56..3bc019b63e68 100644 --- a/lldb/source/Plugins/Process/FreeBSDKernel/ThreadFreeBSDKernel.h +++ b/lldb/source/Plugins/Process/FreeBSDKernel/ThreadFreeBSDKernel.h @@ -14,7 +14,7 @@ class ThreadFreeBSDKernel : public lldb_private::Thread { public: ThreadFreeBSDKernel(lldb_private::Process &process, lldb::tid_t tid, - lldb::addr_t pcb_addr); + lldb::addr_t pcb_addr, std::string thread_name); ~ThreadFreeBSDKernel() override; @@ -25,10 +25,24 @@ public: lldb::RegisterContextSP CreateRegisterContextForFrame(lldb_private::StackFrame *frame) override; + const char *GetName() override { + if (m_thread_name.empty()) + return nullptr; + return m_thread_name.c_str(); + } + + void SetName(const char *name) override { + if (name && name[0]) + m_thread_name.assign(name); + else + m_thread_name.clear(); + } + protected: bool CalculateStopInfo() override; private: + std::string m_thread_name; lldb::RegisterContextSP m_thread_reg_ctx_sp; lldb::addr_t m_pcb_addr; }; diff --git a/lldb/source/Plugins/Process/NetBSD/NativeProcessNetBSD.cpp b/lldb/source/Plugins/Process/NetBSD/NativeProcessNetBSD.cpp index 0420d00e39d6..182eefb7bee7 100644 --- a/lldb/source/Plugins/Process/NetBSD/NativeProcessNetBSD.cpp +++ b/lldb/source/Plugins/Process/NetBSD/NativeProcessNetBSD.cpp @@ -59,7 +59,7 @@ llvm::Expected<std::unique_ptr<NativeProcessProtocol>> NativeProcessNetBSD::Factory::Launch(ProcessLaunchInfo &launch_info, NativeDelegate &native_delegate, MainLoop &mainloop) const { - Log *log(ProcessPOSIXLog::GetLogIfAllCategoriesSet(POSIX_LOG_PROCESS)); + Log *log = GetLog(POSIXLog::Process); Status status; ::pid_t pid = ProcessLauncherPosixFork() @@ -113,7 +113,7 @@ llvm::Expected<std::unique_ptr<NativeProcessProtocol>> NativeProcessNetBSD::Factory::Attach( lldb::pid_t pid, NativeProcessProtocol::NativeDelegate &native_delegate, MainLoop &mainloop) const { - Log *log(ProcessPOSIXLog::GetLogIfAllCategoriesSet(POSIX_LOG_PROCESS)); + Log *log = GetLog(POSIXLog::Process); LLDB_LOG(log, "pid = {0:x}", pid); // Retrieve the architecture for the running process. @@ -172,7 +172,7 @@ void NativeProcessNetBSD::MonitorCallback(lldb::pid_t pid, int signal) { } void NativeProcessNetBSD::MonitorExited(lldb::pid_t pid, WaitStatus status) { - Log *log(ProcessPOSIXLog::GetLogIfAllCategoriesSet(POSIX_LOG_PROCESS)); + Log *log = GetLog(POSIXLog::Process); LLDB_LOG(log, "got exit signal({0}) , pid = {1}", status, pid); @@ -207,7 +207,7 @@ void NativeProcessNetBSD::MonitorSIGSTOP(lldb::pid_t pid) { } void NativeProcessNetBSD::MonitorSIGTRAP(lldb::pid_t pid) { - Log *log(ProcessPOSIXLog::GetLogIfAllCategoriesSet(POSIX_LOG_PROCESS)); + Log *log = GetLog(POSIXLog::Process); ptrace_siginfo_t info; const auto siginfo_err = @@ -359,7 +359,7 @@ void NativeProcessNetBSD::MonitorSIGTRAP(lldb::pid_t pid) { } void NativeProcessNetBSD::MonitorSignal(lldb::pid_t pid, int signal) { - Log *log(ProcessPOSIXLog::GetLogIfAllCategoriesSet(POSIX_LOG_PROCESS)); + Log *log = GetLog(POSIXLog::Process); ptrace_siginfo_t info; const auto siginfo_err = @@ -383,7 +383,7 @@ void NativeProcessNetBSD::MonitorSignal(lldb::pid_t pid, int signal) { Status NativeProcessNetBSD::PtraceWrapper(int req, lldb::pid_t pid, void *addr, int data, int *result) { - Log *log(ProcessPOSIXLog::GetLogIfAllCategoriesSet(POSIX_LOG_PTRACE)); + Log *log = GetLog(POSIXLog::Ptrace); Status error; int ret; @@ -459,7 +459,7 @@ static llvm::Expected<ptrace_siginfo_t> ComputeSignalInfo( } Status NativeProcessNetBSD::Resume(const ResumeActionList &resume_actions) { - Log *log(ProcessPOSIXLog::GetLogIfAllCategoriesSet(POSIX_LOG_PROCESS)); + Log *log = GetLog(POSIXLog::Process); LLDB_LOG(log, "pid {0}", GetID()); Status ret; @@ -562,7 +562,7 @@ Status NativeProcessNetBSD::Interrupt() { } Status NativeProcessNetBSD::Kill() { - Log *log(ProcessPOSIXLog::GetLogIfAllCategoriesSet(POSIX_LOG_PROCESS)); + Log *log = GetLog(POSIXLog::Process); LLDB_LOG(log, "pid {0}", GetID()); Status error; @@ -654,7 +654,7 @@ Status NativeProcessNetBSD::GetMemoryRegionInfo(lldb::addr_t load_addr, } Status NativeProcessNetBSD::PopulateMemoryRegionCache() { - Log *log(ProcessPOSIXLog::GetLogIfAllCategoriesSet(POSIX_LOG_PROCESS)); + Log *log = GetLog(POSIXLog::Process); // If our cache is empty, pull the latest. There should always be at least // one memory region if memory region handling is supported. if (!m_mem_region_cache.empty()) { @@ -772,7 +772,7 @@ Status NativeProcessNetBSD::GetFileLoadAddress(const llvm::StringRef &file_name, } void NativeProcessNetBSD::SigchldHandler() { - Log *log(ProcessPOSIXLog::GetLogIfAllCategoriesSet(POSIX_LOG_PROCESS)); + Log *log = GetLog(POSIXLog::Process); int status; ::pid_t wait_pid = llvm::sys::RetryAfterSignal(-1, waitpid, GetID(), &status, WALLSIG | WNOHANG); @@ -817,7 +817,7 @@ bool NativeProcessNetBSD::HasThreadNoLock(lldb::tid_t thread_id) { } NativeThreadNetBSD &NativeProcessNetBSD::AddThread(lldb::tid_t thread_id) { - Log *log(ProcessPOSIXLog::GetLogIfAllCategoriesSet(POSIX_LOG_THREAD)); + Log *log = GetLog(POSIXLog::Thread); LLDB_LOG(log, "pid {0} adding thread with tid {1}", GetID(), thread_id); assert(thread_id > 0); @@ -833,7 +833,7 @@ NativeThreadNetBSD &NativeProcessNetBSD::AddThread(lldb::tid_t thread_id) { } void NativeProcessNetBSD::RemoveThread(lldb::tid_t thread_id) { - Log *log(ProcessPOSIXLog::GetLogIfAllCategoriesSet(POSIX_LOG_THREAD)); + Log *log = GetLog(POSIXLog::Thread); LLDB_LOG(log, "pid {0} removing thread with tid {1}", GetID(), thread_id); assert(thread_id > 0); @@ -882,7 +882,7 @@ Status NativeProcessNetBSD::ReadMemory(lldb::addr_t addr, void *buf, unsigned char *dst = static_cast<unsigned char *>(buf); struct ptrace_io_desc io; - Log *log(ProcessPOSIXLog::GetLogIfAllCategoriesSet(POSIX_LOG_MEMORY)); + Log *log = GetLog(POSIXLog::Memory); LLDB_LOG(log, "addr = {0}, buf = {1}, size = {2}", addr, buf, size); bytes_read = 0; @@ -910,7 +910,7 @@ Status NativeProcessNetBSD::WriteMemory(lldb::addr_t addr, const void *buf, Status error; struct ptrace_io_desc io; - Log *log(ProcessPOSIXLog::GetLogIfAllCategoriesSet(POSIX_LOG_MEMORY)); + Log *log = GetLog(POSIXLog::Memory); LLDB_LOG(log, "addr = {0}, buf = {1}, size = {2}", addr, buf, size); bytes_written = 0; @@ -1013,7 +1013,7 @@ Status NativeProcessNetBSD::ReinitializeThreads() { void NativeProcessNetBSD::MonitorClone(::pid_t child_pid, bool is_vfork, NativeThreadNetBSD &parent_thread) { - Log *log(ProcessPOSIXLog::GetLogIfAllCategoriesSet(POSIX_LOG_PROCESS)); + Log *log = GetLog(POSIXLog::Process); LLDB_LOG(log, "clone, child_pid={0}", child_pid); int status; diff --git a/lldb/source/Plugins/Process/NetBSD/NativeThreadNetBSD.cpp b/lldb/source/Plugins/Process/NetBSD/NativeThreadNetBSD.cpp index 400b89a5fddf..3e8cf9fd9f23 100644 --- a/lldb/source/Plugins/Process/NetBSD/NativeThreadNetBSD.cpp +++ b/lldb/source/Plugins/Process/NetBSD/NativeThreadNetBSD.cpp @@ -75,7 +75,7 @@ Status NativeThreadNetBSD::Suspend() { void NativeThreadNetBSD::SetStoppedBySignal(uint32_t signo, const siginfo_t *info) { - Log *log(ProcessPOSIXLog::GetLogIfAllCategoriesSet(POSIX_LOG_THREAD)); + Log *log = GetLog(POSIXLog::Thread); LLDB_LOG(log, "tid = {0} in called with signal {1}", GetID(), signo); SetStopped(); @@ -178,7 +178,7 @@ void NativeThreadNetBSD::SetStepping() { } std::string NativeThreadNetBSD::GetName() { - Log *log(ProcessPOSIXLog::GetLogIfAllCategoriesSet(POSIX_LOG_THREAD)); + Log *log = GetLog(POSIXLog::Thread); #ifdef PT_LWPSTATUS struct ptrace_lwpstatus info = {}; @@ -225,7 +225,7 @@ lldb::StateType NativeThreadNetBSD::GetState() { return m_state; } bool NativeThreadNetBSD::GetStopReason(ThreadStopInfo &stop_info, std::string &description) { - Log *log(ProcessPOSIXLog::GetLogIfAllCategoriesSet(POSIX_LOG_THREAD)); + Log *log = GetLog(POSIXLog::Thread); description.clear(); switch (m_state) { diff --git a/lldb/source/Plugins/Process/POSIX/ProcessPOSIXLog.cpp b/lldb/source/Plugins/Process/POSIX/ProcessPOSIXLog.cpp index f4d0803b264a..7ad88aabc2c0 100644 --- a/lldb/source/Plugins/Process/POSIX/ProcessPOSIXLog.cpp +++ b/lldb/source/Plugins/Process/POSIX/ProcessPOSIXLog.cpp @@ -13,16 +13,20 @@ using namespace lldb_private; static constexpr Log::Category g_categories[] = { - {{"break"}, {"log breakpoints"}, POSIX_LOG_BREAKPOINTS}, - {{"memory"}, {"log memory reads and writes"}, POSIX_LOG_MEMORY}, - {{"process"}, {"log process events and activities"}, POSIX_LOG_PROCESS}, - {{"ptrace"}, {"log all calls to ptrace"}, POSIX_LOG_PTRACE}, - {{"registers"}, {"log register read/writes"}, POSIX_LOG_REGISTERS}, - {{"thread"}, {"log thread events and activities"}, POSIX_LOG_THREAD}, - {{"watch"}, {"log watchpoint related activities"}, POSIX_LOG_WATCHPOINTS}, + {{"break"}, {"log breakpoints"}, POSIXLog::Breakpoints}, + {{"memory"}, {"log memory reads and writes"}, POSIXLog::Memory}, + {{"process"}, {"log process events and activities"}, POSIXLog::Process}, + {{"ptrace"}, {"log all calls to ptrace"}, POSIXLog::Ptrace}, + {{"registers"}, {"log register read/writes"}, POSIXLog::Registers}, + {{"thread"}, {"log thread events and activities"}, POSIXLog::Thread}, + {{"watch"}, {"log watchpoint related activities"}, POSIXLog::Watchpoints}, }; -Log::Channel ProcessPOSIXLog::g_channel(g_categories, POSIX_LOG_DEFAULT); +static Log::Channel g_channel(g_categories, POSIXLog::Process); + +template <> Log::Channel &lldb_private::LogChannelFor<POSIXLog>() { + return g_channel; +} void ProcessPOSIXLog::Initialize() { static llvm::once_flag g_once_flag; diff --git a/lldb/source/Plugins/Process/POSIX/ProcessPOSIXLog.h b/lldb/source/Plugins/Process/POSIX/ProcessPOSIXLog.h index c0147c43410f..7b8b6cdbf255 100644 --- a/lldb/source/Plugins/Process/POSIX/ProcessPOSIXLog.h +++ b/lldb/source/Plugins/Process/POSIX/ProcessPOSIXLog.h @@ -13,27 +13,25 @@ #include "lldb/Utility/Log.h" -#define POSIX_LOG_PROCESS (1u << 1) -#define POSIX_LOG_THREAD (1u << 2) -#define POSIX_LOG_MEMORY (1u << 4) // Log memory reads/writes calls -#define POSIX_LOG_PTRACE (1u << 5) -#define POSIX_LOG_REGISTERS (1u << 6) -#define POSIX_LOG_BREAKPOINTS (1u << 7) -#define POSIX_LOG_WATCHPOINTS (1u << 8) -#define POSIX_LOG_ALL (UINT32_MAX) -#define POSIX_LOG_DEFAULT POSIX_LOG_PROCESS - namespace lldb_private { -class ProcessPOSIXLog { - static Log::Channel g_channel; +enum class POSIXLog : Log::MaskType { + Breakpoints = Log::ChannelFlag<0>, + Memory = Log::ChannelFlag<1>, + Process = Log::ChannelFlag<2>, + Ptrace = Log::ChannelFlag<3>, + Registers = Log::ChannelFlag<4>, + Thread = Log::ChannelFlag<5>, + Watchpoints = Log::ChannelFlag<6>, + LLVM_MARK_AS_BITMASK_ENUM(Watchpoints) +}; + +class ProcessPOSIXLog { public: static void Initialize(); - - static Log *GetLogIfAllCategoriesSet(uint32_t mask) { - return g_channel.GetLogIfAll(mask); - } }; -} + +template <> Log::Channel &LogChannelFor<POSIXLog>(); +} // namespace lldb_private #endif // liblldb_ProcessPOSIXLog_h_ diff --git a/lldb/source/Plugins/Process/Utility/MemoryTagManagerAArch64MTE.cpp b/lldb/source/Plugins/Process/Utility/MemoryTagManagerAArch64MTE.cpp index d74b66b58afc..b71de4cadb18 100644 --- a/lldb/source/Plugins/Process/Utility/MemoryTagManagerAArch64MTE.cpp +++ b/lldb/source/Plugins/Process/Utility/MemoryTagManagerAArch64MTE.cpp @@ -7,6 +7,8 @@ //===----------------------------------------------------------------------===// #include "MemoryTagManagerAArch64MTE.h" +#include "llvm/Support/Error.h" +#include <assert.h> using namespace lldb_private; @@ -20,7 +22,7 @@ MemoryTagManagerAArch64MTE::GetLogicalTag(lldb::addr_t addr) const { } lldb::addr_t -MemoryTagManagerAArch64MTE::RemoveNonAddressBits(lldb::addr_t addr) const { +MemoryTagManagerAArch64MTE::RemoveTagBits(lldb::addr_t addr) const { // Here we're ignoring the whole top byte. If you've got MTE // you must also have TBI (top byte ignore). // The other 4 bits could contain other extension bits or @@ -30,7 +32,7 @@ MemoryTagManagerAArch64MTE::RemoveNonAddressBits(lldb::addr_t addr) const { ptrdiff_t MemoryTagManagerAArch64MTE::AddressDiff(lldb::addr_t addr1, lldb::addr_t addr2) const { - return RemoveNonAddressBits(addr1) - RemoveNonAddressBits(addr2); + return RemoveTagBits(addr1) - RemoveTagBits(addr2); } lldb::addr_t MemoryTagManagerAArch64MTE::GetGranuleSize() const { @@ -66,6 +68,15 @@ MemoryTagManagerAArch64MTE::ExpandToGranule(TagRange range) const { return TagRange(new_start, new_len); } +static llvm::Error MakeInvalidRangeErr(lldb::addr_t addr, + lldb::addr_t end_addr) { + return llvm::createStringError( + llvm::inconvertibleErrorCode(), + "End address (0x%" PRIx64 + ") must be greater than the start address (0x%" PRIx64 ")", + end_addr, addr); +} + llvm::Expected<MemoryTagManager::TagRange> MemoryTagManagerAArch64MTE::MakeTaggedRange( lldb::addr_t addr, lldb::addr_t end_addr, @@ -74,17 +85,12 @@ MemoryTagManagerAArch64MTE::MakeTaggedRange( // We must remove tags here otherwise an address with a higher // tag value will always be > the other. ptrdiff_t len = AddressDiff(end_addr, addr); - if (len <= 0) { - return llvm::createStringError( - llvm::inconvertibleErrorCode(), - "End address (0x%" PRIx64 - ") must be greater than the start address (0x%" PRIx64 ")", - end_addr, addr); - } + if (len <= 0) + return MakeInvalidRangeErr(addr, end_addr); // Region addresses will not have memory tags. So when searching // we must use an untagged address. - MemoryRegionInfo::RangeType tag_range(RemoveNonAddressBits(addr), len); + MemoryRegionInfo::RangeType tag_range(RemoveTagBits(addr), len); tag_range = ExpandToGranule(tag_range); // Make a copy so we can use the original for errors and the final return. @@ -123,6 +129,91 @@ MemoryTagManagerAArch64MTE::MakeTaggedRange( return tag_range; } +llvm::Expected<std::vector<MemoryTagManager::TagRange>> +MemoryTagManagerAArch64MTE::MakeTaggedRanges( + lldb::addr_t addr, lldb::addr_t end_addr, + const lldb_private::MemoryRegionInfos &memory_regions) const { + // First check that the range is not inverted. + // We must remove tags here otherwise an address with a higher + // tag value will always be > the other. + ptrdiff_t len = AddressDiff(end_addr, addr); + if (len <= 0) + return MakeInvalidRangeErr(addr, end_addr); + + std::vector<MemoryTagManager::TagRange> tagged_ranges; + // No memory regions means no tagged memory at all + if (memory_regions.empty()) + return tagged_ranges; + + // For the logic to work regions must be in ascending order + // which is what you'd have if you used GetMemoryRegions. + assert(std::is_sorted( + memory_regions.begin(), memory_regions.end(), + [](const MemoryRegionInfo &lhs, const MemoryRegionInfo &rhs) { + return lhs.GetRange().GetRangeBase() < rhs.GetRange().GetRangeBase(); + })); + + // If we're debugging userspace in an OS like Linux that uses an MMU, + // the only reason we'd get overlapping regions is incorrect data. + // It is possible that won't hold for embedded with memory protection + // units (MPUs) that allow overlaps. + // + // For now we're going to assume the former, as there is no good way + // to handle overlaps. For example: + // < requested range > + // [-- region 1 --] + // [-- region 2--] + // Where the first region will reduce the requested range to nothing + // and exit early before it sees the overlap. + MemoryRegionInfos::const_iterator overlap = std::adjacent_find( + memory_regions.begin(), memory_regions.end(), + [](const MemoryRegionInfo &lhs, const MemoryRegionInfo &rhs) { + return rhs.GetRange().DoesIntersect(lhs.GetRange()); + }); + UNUSED_IF_ASSERT_DISABLED(overlap); + assert(overlap == memory_regions.end()); + + // Region addresses will not have memory tags so when searching + // we must use an untagged address. + MemoryRegionInfo::RangeType range(RemoveTagBits(addr), len); + range = ExpandToGranule(range); + + // While there are regions to check and the range has non zero length + for (const MemoryRegionInfo ®ion : memory_regions) { + // If range we're checking has been reduced to zero length, exit early + if (!range.IsValid()) + break; + + // If the region doesn't overlap the range at all, ignore it. + if (!region.GetRange().DoesIntersect(range)) + continue; + + // If it's tagged record this sub-range. + // (assuming that it's already granule aligned) + if (region.GetMemoryTagged()) { + // The region found may extend outside the requested range. + // For example the first region might start before the range. + // We must only add what covers the requested range. + lldb::addr_t start = + std::max(range.GetRangeBase(), region.GetRange().GetRangeBase()); + lldb::addr_t end = + std::min(range.GetRangeEnd(), region.GetRange().GetRangeEnd()); + tagged_ranges.push_back(MemoryTagManager::TagRange(start, end - start)); + } + + // Move the range up to start at the end of the region. + lldb::addr_t old_end = range.GetRangeEnd(); + // This "slides" the range so it moves the end as well. + range.SetRangeBase(region.GetRange().GetRangeEnd()); + // So we set the end back to the original end address after sliding it up. + range.SetRangeEnd(old_end); + // (if the above were to try to set end < begin the range will just be set + // to 0 size) + } + + return tagged_ranges; +} + llvm::Expected<std::vector<lldb::addr_t>> MemoryTagManagerAArch64MTE::UnpackTagsData(const std::vector<uint8_t> &tags, size_t granules /*=0*/) const { diff --git a/lldb/source/Plugins/Process/Utility/MemoryTagManagerAArch64MTE.h b/lldb/source/Plugins/Process/Utility/MemoryTagManagerAArch64MTE.h index d4e8249da93f..7cda728b140f 100644 --- a/lldb/source/Plugins/Process/Utility/MemoryTagManagerAArch64MTE.h +++ b/lldb/source/Plugins/Process/Utility/MemoryTagManagerAArch64MTE.h @@ -27,7 +27,7 @@ public: size_t GetTagSizeInBytes() const override; lldb::addr_t GetLogicalTag(lldb::addr_t addr) const override; - lldb::addr_t RemoveNonAddressBits(lldb::addr_t addr) const override; + lldb::addr_t RemoveTagBits(lldb::addr_t addr) const override; ptrdiff_t AddressDiff(lldb::addr_t addr1, lldb::addr_t addr2) const override; TagRange ExpandToGranule(TagRange range) const override; @@ -36,6 +36,10 @@ public: lldb::addr_t addr, lldb::addr_t end_addr, const lldb_private::MemoryRegionInfos &memory_regions) const override; + llvm::Expected<std::vector<TagRange>> MakeTaggedRanges( + lldb::addr_t addr, lldb::addr_t end_addr, + const lldb_private::MemoryRegionInfos &memory_regions) const override; + llvm::Expected<std::vector<lldb::addr_t>> UnpackTagsData(const std::vector<uint8_t> &tags, size_t granules = 0) const override; diff --git a/lldb/source/Plugins/Process/Utility/RegisterInfoPOSIX_arm64.cpp b/lldb/source/Plugins/Process/Utility/RegisterInfoPOSIX_arm64.cpp index 6c130be7b741..d6c4a8687ec5 100644 --- a/lldb/source/Plugins/Process/Utility/RegisterInfoPOSIX_arm64.cpp +++ b/lldb/source/Plugins/Process/Utility/RegisterInfoPOSIX_arm64.cpp @@ -178,10 +178,10 @@ static const lldb_private::RegisterSet g_reg_sets_arm64[k_num_register_sets] = { g_sve_regnums_arm64}}; static const lldb_private::RegisterSet g_reg_set_pauth_arm64 = { - "Pointer Authentication Registers", "pauth", k_num_pauth_register, NULL}; + "Pointer Authentication Registers", "pauth", k_num_pauth_register, nullptr}; static const lldb_private::RegisterSet g_reg_set_mte_arm64 = { - "MTE Control Register", "mte", k_num_mte_register, NULL}; + "MTE Control Register", "mte", k_num_mte_register, nullptr}; RegisterInfoPOSIX_arm64::RegisterInfoPOSIX_arm64( const lldb_private::ArchSpec &target_arch, lldb_private::Flags opt_regsets) diff --git a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp index b5b105351de5..f6526d03863b 100644 --- a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp +++ b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp @@ -173,6 +173,13 @@ bool GDBRemoteCommunicationClient::GetQXferMemoryMapReadSupported() { return m_supports_qXfer_memory_map_read == eLazyBoolYes; } +bool GDBRemoteCommunicationClient::GetQXferSigInfoReadSupported() { + if (m_supports_qXfer_siginfo_read == eLazyBoolCalculate) { + GetRemoteQSupported(); + } + return m_supports_qXfer_siginfo_read == eLazyBoolYes; +} + uint64_t GDBRemoteCommunicationClient::GetRemoteMaxPacketSize() { if (m_max_packet_size == 0) { GetRemoteQSupported(); @@ -273,6 +280,7 @@ void GDBRemoteCommunicationClient::ResetDiscoverableSettings(bool did_exec) { m_supports_qXfer_libraries_svr4_read = eLazyBoolCalculate; m_supports_qXfer_features_read = eLazyBoolCalculate; m_supports_qXfer_memory_map_read = eLazyBoolCalculate; + m_supports_qXfer_siginfo_read = eLazyBoolCalculate; m_supports_augmented_libraries_svr4_read = eLazyBoolCalculate; m_uses_native_signals = eLazyBoolCalculate; m_supports_qProcessInfoPID = true; @@ -320,6 +328,7 @@ void GDBRemoteCommunicationClient::GetRemoteQSupported() { m_supports_augmented_libraries_svr4_read = eLazyBoolNo; m_supports_qXfer_features_read = eLazyBoolNo; m_supports_qXfer_memory_map_read = eLazyBoolNo; + m_supports_qXfer_siginfo_read = eLazyBoolNo; m_supports_multiprocess = eLazyBoolNo; m_supports_qEcho = eLazyBoolNo; m_supports_QPassSignals = eLazyBoolNo; @@ -362,6 +371,8 @@ void GDBRemoteCommunicationClient::GetRemoteQSupported() { m_supports_qXfer_features_read = eLazyBoolYes; else if (x == "qXfer:memory-map:read+") m_supports_qXfer_memory_map_read = eLazyBoolYes; + else if (x == "qXfer:siginfo:read+") + m_supports_qXfer_siginfo_read = eLazyBoolYes; else if (x == "qEcho") m_supports_qEcho = eLazyBoolYes; else if (x == "QPassSignals+") diff --git a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.h b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.h index c69c33bb1c15..58ed22187747 100644 --- a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.h +++ b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.h @@ -337,6 +337,8 @@ public: bool GetQXferMemoryMapReadSupported(); + bool GetQXferSigInfoReadSupported(); + LazyBool SupportsAllocDeallocMemory() // const { // Uncomment this to have lldb pretend the debug server doesn't respond to @@ -551,6 +553,7 @@ protected: LazyBool m_supports_qXfer_libraries_svr4_read = eLazyBoolCalculate; LazyBool m_supports_qXfer_features_read = eLazyBoolCalculate; LazyBool m_supports_qXfer_memory_map_read = eLazyBoolCalculate; + LazyBool m_supports_qXfer_siginfo_read = eLazyBoolCalculate; LazyBool m_supports_augmented_libraries_svr4_read = eLazyBoolCalculate; LazyBool m_supports_jThreadExtendedInfo = eLazyBoolCalculate; LazyBool m_supports_jLoadedDynamicLibrariesInfos = eLazyBoolCalculate; diff --git a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationReplayServer.cpp b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationReplayServer.cpp deleted file mode 100644 index c91d7cb5ac30..000000000000 --- a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationReplayServer.cpp +++ /dev/null @@ -1,314 +0,0 @@ -//===-- GDBRemoteCommunicationReplayServer.cpp ----------------------------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#include <cerrno> - -#include "lldb/Host/Config.h" -#include "llvm/ADT/ScopeExit.h" - -#include "GDBRemoteCommunicationReplayServer.h" -#include "ProcessGDBRemoteLog.h" - -// C Includes -// C++ Includes -#include <cstring> - -// Project includes -#include "lldb/Host/ThreadLauncher.h" -#include "lldb/Utility/ConstString.h" -#include "lldb/Utility/Event.h" -#include "lldb/Utility/FileSpec.h" -#include "lldb/Utility/StreamString.h" -#include "lldb/Utility/StringExtractorGDBRemote.h" - -using namespace llvm; -using namespace lldb; -using namespace lldb_private; -using namespace lldb_private::process_gdb_remote; - -/// Check if the given expected packet matches the actual packet. -static bool unexpected(llvm::StringRef expected, llvm::StringRef actual) { - // The 'expected' string contains the raw data, including the leading $ and - // trailing checksum. The 'actual' string contains only the packet's content. - if (expected.contains(actual)) - return false; - // Contains a PID which might be different. - if (expected.contains("vAttach")) - return false; - // Contains a ascii-hex-path. - if (expected.contains("QSetSTD")) - return false; - // Contains environment values. - if (expected.contains("QEnvironment")) - return false; - - return true; -} - -/// Check if we should reply to the given packet. -static bool skip(llvm::StringRef data) { - assert(!data.empty() && "Empty packet?"); - - // We've already acknowledge the '+' packet so we're done here. - if (data == "+") - return true; - - /// Don't 't reply to ^C. We need this because of stop reply packets, which - /// are only returned when the target halts. Reproducers synchronize these - /// 'asynchronous' replies, by recording them as a regular replies to the - /// previous packet (e.g. vCont). As a result, we should ignore real - /// asynchronous requests. - if (data.data()[0] == 0x03) - return true; - - return false; -} - -GDBRemoteCommunicationReplayServer::GDBRemoteCommunicationReplayServer() - : GDBRemoteCommunication("gdb-replay", "gdb-replay.rx_packet"), - m_async_broadcaster(nullptr, "lldb.gdb-replay.async-broadcaster"), - m_async_listener_sp( - Listener::MakeListener("lldb.gdb-replay.async-listener")), - m_async_thread_state_mutex() { - m_async_broadcaster.SetEventName(eBroadcastBitAsyncContinue, - "async thread continue"); - m_async_broadcaster.SetEventName(eBroadcastBitAsyncThreadShouldExit, - "async thread should exit"); - - const uint32_t async_event_mask = - eBroadcastBitAsyncContinue | eBroadcastBitAsyncThreadShouldExit; - m_async_listener_sp->StartListeningForEvents(&m_async_broadcaster, - async_event_mask); -} - -GDBRemoteCommunicationReplayServer::~GDBRemoteCommunicationReplayServer() { - StopAsyncThread(); -} - -GDBRemoteCommunication::PacketResult -GDBRemoteCommunicationReplayServer::GetPacketAndSendResponse( - Timeout<std::micro> timeout, Status &error, bool &interrupt, bool &quit) { - std::lock_guard<std::recursive_mutex> guard(m_async_thread_state_mutex); - - StringExtractorGDBRemote packet; - PacketResult packet_result = WaitForPacketNoLock(packet, timeout, false); - - if (packet_result != PacketResult::Success) { - if (!IsConnected()) { - error.SetErrorString("lost connection"); - quit = true; - } else { - error.SetErrorString("timeout"); - } - return packet_result; - } - - m_async_broadcaster.BroadcastEvent(eBroadcastBitAsyncContinue); - - // Check if we should reply to this packet. - if (skip(packet.GetStringRef())) - return PacketResult::Success; - - // This completes the handshake. Since m_send_acks was true, we can unset it - // already. - if (packet.GetStringRef() == "QStartNoAckMode") - m_send_acks = false; - - // A QEnvironment packet is sent for every environment variable. If the - // number of environment variables is different during replay, the replies - // become out of sync. - if (packet.GetStringRef().find("QEnvironment") == 0) - return SendRawPacketNoLock("$OK#9a"); - - Log *log(ProcessGDBRemoteLog::GetLogIfAllCategoriesSet(GDBR_LOG_PROCESS)); - while (!m_packet_history.empty()) { - // Pop last packet from the history. - GDBRemotePacket entry = m_packet_history.back(); - m_packet_history.pop_back(); - - // Decode run-length encoding. - const std::string expanded_data = - GDBRemoteCommunication::ExpandRLE(entry.packet.data); - - // We've handled the handshake implicitly before. Skip the packet and move - // on. - if (entry.packet.data == "+") - continue; - - if (entry.type == GDBRemotePacket::ePacketTypeSend) { - if (unexpected(expanded_data, packet.GetStringRef())) { - LLDB_LOG(log, - "GDBRemoteCommunicationReplayServer expected packet: '{0}'", - expanded_data); - LLDB_LOG(log, "GDBRemoteCommunicationReplayServer actual packet: '{0}'", - packet.GetStringRef()); -#ifndef NDEBUG - // This behaves like a regular assert, but prints the expected and - // received packet before aborting. - printf("Reproducer expected packet: '%s'\n", expanded_data.c_str()); - printf("Reproducer received packet: '%s'\n", - packet.GetStringRef().data()); - llvm::report_fatal_error("Encountered unexpected packet during replay"); -#endif - return PacketResult::ErrorSendFailed; - } - - // Ignore QEnvironment packets as they're handled earlier. - if (expanded_data.find("QEnvironment") == 1) { - assert(m_packet_history.back().type == - GDBRemotePacket::ePacketTypeRecv); - m_packet_history.pop_back(); - } - - continue; - } - - if (entry.type == GDBRemotePacket::ePacketTypeInvalid) { - LLDB_LOG( - log, - "GDBRemoteCommunicationReplayServer skipped invalid packet: '{0}'", - packet.GetStringRef()); - continue; - } - - LLDB_LOG(log, - "GDBRemoteCommunicationReplayServer replied to '{0}' with '{1}'", - packet.GetStringRef(), entry.packet.data); - return SendRawPacketNoLock(entry.packet.data); - } - - quit = true; - - return packet_result; -} - -llvm::Error -GDBRemoteCommunicationReplayServer::LoadReplayHistory(const FileSpec &path) { - auto error_or_file = MemoryBuffer::getFile(path.GetPath()); - if (auto err = error_or_file.getError()) - return errorCodeToError(err); - - yaml::Input yin((*error_or_file)->getBuffer()); - yin >> m_packet_history; - - if (auto err = yin.error()) - return errorCodeToError(err); - - // We want to manipulate the vector like a stack so we need to reverse the - // order of the packets to have the oldest on at the back. - std::reverse(m_packet_history.begin(), m_packet_history.end()); - - return Error::success(); -} - -bool GDBRemoteCommunicationReplayServer::StartAsyncThread() { - std::lock_guard<std::recursive_mutex> guard(m_async_thread_state_mutex); - if (!m_async_thread.IsJoinable()) { - // Create a thread that watches our internal state and controls which - // events make it to clients (into the DCProcess event queue). - llvm::Expected<HostThread> async_thread = ThreadLauncher::LaunchThread( - "<lldb.gdb-replay.async>", - GDBRemoteCommunicationReplayServer::AsyncThread, this); - if (!async_thread) { - LLDB_LOG_ERROR(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_HOST), - async_thread.takeError(), - "failed to launch host thread: {}"); - return false; - } - m_async_thread = *async_thread; - } - - // Wait for handshake. - m_async_broadcaster.BroadcastEvent(eBroadcastBitAsyncContinue); - - return m_async_thread.IsJoinable(); -} - -void GDBRemoteCommunicationReplayServer::StopAsyncThread() { - std::lock_guard<std::recursive_mutex> guard(m_async_thread_state_mutex); - - if (!m_async_thread.IsJoinable()) - return; - - // Request thread to stop. - m_async_broadcaster.BroadcastEvent(eBroadcastBitAsyncThreadShouldExit); - - // Disconnect client. - Disconnect(); - - // Stop the thread. - m_async_thread.Join(nullptr); - m_async_thread.Reset(); -} - -void GDBRemoteCommunicationReplayServer::ReceivePacket( - GDBRemoteCommunicationReplayServer &server, bool &done) { - Status error; - bool interrupt; - auto packet_result = server.GetPacketAndSendResponse(std::chrono::seconds(1), - error, interrupt, done); - if (packet_result != GDBRemoteCommunication::PacketResult::Success && - packet_result != - GDBRemoteCommunication::PacketResult::ErrorReplyTimeout) { - done = true; - } else { - server.m_async_broadcaster.BroadcastEvent(eBroadcastBitAsyncContinue); - } -} - -thread_result_t GDBRemoteCommunicationReplayServer::AsyncThread(void *arg) { - GDBRemoteCommunicationReplayServer *server = - (GDBRemoteCommunicationReplayServer *)arg; - auto D = make_scope_exit([&]() { server->Disconnect(); }); - EventSP event_sp; - bool done = false; - while (!done) { - if (server->m_async_listener_sp->GetEvent(event_sp, llvm::None)) { - const uint32_t event_type = event_sp->GetType(); - if (event_sp->BroadcasterIs(&server->m_async_broadcaster)) { - switch (event_type) { - case eBroadcastBitAsyncContinue: - ReceivePacket(*server, done); - if (done) - return {}; - break; - case eBroadcastBitAsyncThreadShouldExit: - default: - return {}; - } - } - } - } - - return {}; -} - -Status GDBRemoteCommunicationReplayServer::Connect( - process_gdb_remote::GDBRemoteCommunicationClient &client) { - repro::Loader *loader = repro::Reproducer::Instance().GetLoader(); - if (!loader) - return Status("No loader provided."); - - static std::unique_ptr<repro::MultiLoader<repro::GDBRemoteProvider>> - multi_loader = repro::MultiLoader<repro::GDBRemoteProvider>::Create( - repro::Reproducer::Instance().GetLoader()); - if (!multi_loader) - return Status("No gdb remote provider found."); - - llvm::Optional<std::string> history_file = multi_loader->GetNextFile(); - if (!history_file) - return Status("No gdb remote packet log found."); - - if (auto error = LoadReplayHistory(FileSpec(*history_file))) - return Status("Unable to load replay history"); - - if (auto error = GDBRemoteCommunication::ConnectLocally(client, *this)) - return Status("Unable to connect to replay server"); - - return {}; -} diff --git a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationReplayServer.h b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationReplayServer.h deleted file mode 100644 index 2f8770d0accf..000000000000 --- a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationReplayServer.h +++ /dev/null @@ -1,88 +0,0 @@ -//===-- GDBRemoteCommunicationReplayServer.h --------------------*- C++ -*-===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef LLDB_SOURCE_PLUGINS_PROCESS_GDB_REMOTE_GDBREMOTECOMMUNICATIONREPLAYSERVER_H -#define LLDB_SOURCE_PLUGINS_PROCESS_GDB_REMOTE_GDBREMOTECOMMUNICATIONREPLAYSERVER_H - -// Other libraries and framework includes -#include "GDBRemoteCommunication.h" -#include "GDBRemoteCommunicationClient.h" -#include "GDBRemoteCommunicationHistory.h" - -// Project includes -#include "lldb/Host/HostThread.h" -#include "lldb/Utility/Broadcaster.h" -#include "lldb/lldb-private-forward.h" -#include "llvm/Support/Error.h" - -// C Includes -// C++ Includes -#include <functional> -#include <map> -#include <thread> - -class StringExtractorGDBRemote; - -namespace lldb_private { -namespace process_gdb_remote { - -class ProcessGDBRemote; - -/// Dummy GDB server that replays packets from the GDB Remote Communication -/// history. This is used to replay GDB packets. -class GDBRemoteCommunicationReplayServer : public GDBRemoteCommunication { -public: - GDBRemoteCommunicationReplayServer(); - - ~GDBRemoteCommunicationReplayServer() override; - - PacketResult GetPacketAndSendResponse(Timeout<std::micro> timeout, - Status &error, bool &interrupt, - bool &quit); - - bool HandshakeWithClient() { return GetAck() == PacketResult::Success; } - - llvm::Error LoadReplayHistory(const FileSpec &path); - - bool StartAsyncThread(); - void StopAsyncThread(); - - Status Connect(process_gdb_remote::GDBRemoteCommunicationClient &client); - -protected: - enum { - eBroadcastBitAsyncContinue = (1 << 0), - eBroadcastBitAsyncThreadShouldExit = (1 << 1), - }; - - static void ReceivePacket(GDBRemoteCommunicationReplayServer &server, - bool &done); - static lldb::thread_result_t AsyncThread(void *arg); - - /// Replay history with the oldest packet at the end. - std::vector<GDBRemotePacket> m_packet_history; - - /// Server thread. - Broadcaster m_async_broadcaster; - lldb::ListenerSP m_async_listener_sp; - HostThread m_async_thread; - std::recursive_mutex m_async_thread_state_mutex; - - bool m_skip_acks = false; - -private: - GDBRemoteCommunicationReplayServer( - const GDBRemoteCommunicationReplayServer &) = delete; - const GDBRemoteCommunicationReplayServer & - operator=(const GDBRemoteCommunicationReplayServer &) = delete; -}; - -} // namespace process_gdb_remote -} // namespace lldb_private - -#endif // LLDB_SOURCE_PLUGINS_PROCESS_GDB_REMOTE_GDBREMOTECOMMUNICATIONREPLAYSERVER_H diff --git a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp index 30f14a52dfb5..123a8198a89b 100644 --- a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp +++ b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp @@ -1086,7 +1086,7 @@ void GDBRemoteCommunicationServerLLGS::NewSubprocess( } void GDBRemoteCommunicationServerLLGS::DataAvailableCallback() { - Log *log(GetLogIfAnyCategoriesSet(GDBR_LOG_COMM)); + Log *log = GetLog(GDBRLog::Comm); bool interrupt = false; bool done = false; @@ -2920,6 +2920,18 @@ GDBRemoteCommunicationServerLLGS::ReadXferObject(llvm::StringRef object, return std::move(*buffer_or_error); } + if (object == "siginfo") { + NativeThreadProtocol *thread = m_current_process->GetCurrentThread(); + if (!thread) + return llvm::createStringError(llvm::inconvertibleErrorCode(), + "no current thread"); + + auto buffer_or_error = thread->GetSiginfo(); + if (!buffer_or_error) + return buffer_or_error.takeError(); + return std::move(*buffer_or_error); + } + if (object == "libraries-svr4") { auto library_list = m_current_process->GetLoadedSVR4Libraries(); if (!library_list) @@ -3838,6 +3850,8 @@ std::vector<std::string> GDBRemoteCommunicationServerLLGS::HandleFeatures( ret.push_back("qXfer:auxv:read+"); if (bool(plugin_features & Extension::libraries_svr4)) ret.push_back("qXfer:libraries-svr4:read+"); + if (bool(plugin_features & Extension::siginfo_read)) + ret.push_back("qXfer:siginfo:read+"); if (bool(plugin_features & Extension::memory_tagging)) ret.push_back("memory-tagging+"); if (bool(plugin_features & Extension::savecore)) diff --git a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteRegisterFallback.cpp b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteRegisterFallback.cpp new file mode 100644 index 000000000000..b391edced695 --- /dev/null +++ b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteRegisterFallback.cpp @@ -0,0 +1,86 @@ +//===-- GDBRemoteRegisterFallback.cpp -------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include "GDBRemoteRegisterFallback.h" + +namespace lldb_private { +namespace process_gdb_remote { + +#define REG(name, size) \ + DynamicRegisterInfo::Register { \ + ConstString(#name), empty_alt_name, reg_set, size, LLDB_INVALID_INDEX32, \ + lldb::eEncodingUint, lldb::eFormatHex, LLDB_INVALID_REGNUM, \ + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, {}, {} \ + } +#define R64(name) REG(name, 8) +#define R32(name) REG(name, 4) + +static std::vector<DynamicRegisterInfo::Register> GetRegisters_aarch64() { + ConstString empty_alt_name; + ConstString reg_set{"general purpose registers"}; + + std::vector<DynamicRegisterInfo::Register> registers{ + R64(x0), R64(x1), R64(x2), R64(x3), R64(x4), R64(x5), R64(x6), + R64(x7), R64(x8), R64(x9), R64(x10), R64(x11), R64(x12), R64(x13), + R64(x14), R64(x15), R64(x16), R64(x17), R64(x18), R64(x19), R64(x20), + R64(x21), R64(x22), R64(x23), R64(x24), R64(x25), R64(x26), R64(x27), + R64(x28), R64(x29), R64(x30), R64(sp), R64(pc), R32(cpsr), + }; + + return registers; +} + +static std::vector<DynamicRegisterInfo::Register> GetRegisters_x86() { + ConstString empty_alt_name; + ConstString reg_set{"general purpose registers"}; + + std::vector<DynamicRegisterInfo::Register> registers{ + R32(eax), R32(ecx), R32(edx), R32(ebx), R32(esp), R32(ebp), + R32(esi), R32(edi), R32(eip), R32(eflags), R32(cs), R32(ss), + R32(ds), R32(es), R32(fs), R32(gs), + }; + + return registers; +} + +static std::vector<DynamicRegisterInfo::Register> GetRegisters_x86_64() { + ConstString empty_alt_name; + ConstString reg_set{"general purpose registers"}; + + std::vector<DynamicRegisterInfo::Register> registers{ + R64(rax), R64(rbx), R64(rcx), R64(rdx), R64(rsi), R64(rdi), + R64(rbp), R64(rsp), R64(r8), R64(r9), R64(r10), R64(r11), + R64(r12), R64(r13), R64(r14), R64(r15), R64(rip), R32(eflags), + R32(cs), R32(ss), R32(ds), R32(es), R32(fs), R32(gs), + }; + + return registers; +} + +#undef R32 +#undef R64 +#undef REG + +std::vector<DynamicRegisterInfo::Register> +GetFallbackRegisters(const ArchSpec &arch_to_use) { + switch (arch_to_use.GetMachine()) { + case llvm::Triple::aarch64: + return GetRegisters_aarch64(); + case llvm::Triple::x86: + return GetRegisters_x86(); + case llvm::Triple::x86_64: + return GetRegisters_x86_64(); + default: + break; + } + + return {}; +} + +} // namespace process_gdb_remote +} // namespace lldb_private diff --git a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteRegisterFallback.h b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteRegisterFallback.h new file mode 100644 index 000000000000..82e03c6b9b1c --- /dev/null +++ b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteRegisterFallback.h @@ -0,0 +1,26 @@ +//===-- GDBRemoteRegisterFallback.h -----------------------------*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef LLDB_SOURCE_PLUGINS_PROCESS_GDB_REMOTE_GDBREMOTEREGISTERFALLBACK_H +#define LLDB_SOURCE_PLUGINS_PROCESS_GDB_REMOTE_GDBREMOTEREGISTERFALLBACK_H + +#include <vector> + +#include "lldb/Target/DynamicRegisterInfo.h" +#include "lldb/Utility/ArchSpec.h" + +namespace lldb_private { +namespace process_gdb_remote { + +std::vector<DynamicRegisterInfo::Register> +GetFallbackRegisters(const ArchSpec &arch_to_use); + +} // namespace process_gdb_remote +} // namespace lldb_private + +#endif // LLDB_SOURCE_PLUGINS_PROCESS_GDB_REMOTE_GDBREMOTEREGISTERFALLBACK_H diff --git a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp index 93fe36c0d9d6..d8ad0b4e4e4b 100644 --- a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp +++ b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp @@ -23,13 +23,6 @@ #include <ctime> #include <sys/types.h> -#include <algorithm> -#include <csignal> -#include <map> -#include <memory> -#include <mutex> -#include <sstream> - #include "lldb/Breakpoint/Watchpoint.h" #include "lldb/Core/Debugger.h" #include "lldb/Core/Module.h" @@ -70,8 +63,16 @@ #include "lldb/Utility/State.h" #include "lldb/Utility/StreamString.h" #include "lldb/Utility/Timer.h" +#include <algorithm> +#include <csignal> +#include <map> +#include <memory> +#include <mutex> +#include <sstream> +#include <thread> #include "GDBRemoteRegisterContext.h" +#include "GDBRemoteRegisterFallback.h" #include "Plugins/Platform/MacOSX/PlatformRemoteiOS.h" #include "Plugins/Process/Utility/GDBRemoteSignals.h" #include "Plugins/Process/Utility/InferiorCallPOSIX.h" @@ -253,9 +254,8 @@ ProcessGDBRemote::ProcessGDBRemote(lldb::TargetSP target_sp, m_addr_to_mmap_size(), m_thread_create_bp_sp(), m_waiting_for_attach(false), m_destroy_tried_resuming(false), m_command_sp(), m_breakpoint_pc_offset(0), - m_initial_tid(LLDB_INVALID_THREAD_ID), m_replay_mode(false), - m_allow_flash_writes(false), m_erased_flash_ranges(), - m_vfork_in_progress(false) { + m_initial_tid(LLDB_INVALID_THREAD_ID), m_allow_flash_writes(false), + m_erased_flash_ranges(), m_vfork_in_progress(false) { m_async_broadcaster.SetEventName(eBroadcastBitAsyncThreadShouldExit, "async thread should exit"); m_async_broadcaster.SetEventName(eBroadcastBitAsyncContinue, @@ -395,6 +395,7 @@ void ProcessGDBRemote::BuildDynamicRegisterInfo(bool force) { // 2 - If the target definition doesn't have any of the info from the // target.xml (registers) then proceed to read the target.xml. // 3 - Fall back on the qRegisterInfo packets. + // 4 - Use hardcoded defaults if available. FileSpec target_definition_fspec = GetGlobalPluginProperties().GetTargetDefinitionFile(); @@ -508,6 +509,9 @@ void ProcessGDBRemote::BuildDynamicRegisterInfo(bool force) { } } + if (registers.empty()) + registers = GetFallbackRegisters(arch_to_use); + AddRemoteRegisters(registers, arch_to_use); } @@ -525,7 +529,7 @@ Status ProcessGDBRemote::WillAttachToProcessWithName(const char *process_name, } Status ProcessGDBRemote::DoConnectRemote(llvm::StringRef remote_url) { - Log *log(ProcessGDBRemoteLog::GetLogIfAllCategoriesSet(GDBR_LOG_PROCESS)); + Log *log = GetLog(GDBRLog::Process); Status error(WillLaunchOrAttach()); if (error.Fail()) @@ -602,8 +606,7 @@ Status ProcessGDBRemote::DoConnectRemote(llvm::StringRef remote_url) { ReadModuleFromMemory(FileSpec(namebuf), standalone_value); } - Log *log(ProcessGDBRemoteLog::GetLogIfAllCategoriesSet( - LIBLLDB_LOG_DYNAMIC_LOADER)); + Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_DYNAMIC_LOADER)); if (module_sp.get()) { target.GetImages().AppendIfNeeded(module_sp, false); @@ -3316,24 +3319,6 @@ Status ProcessGDBRemote::DoSignal(int signo) { return error; } -Status ProcessGDBRemote::ConnectToReplayServer() { - Status status = m_gdb_replay_server.Connect(m_gdb_comm); - if (status.Fail()) - return status; - - // Enable replay mode. - m_replay_mode = true; - - // Start server thread. - m_gdb_replay_server.StartAsyncThread(); - - // Start client thread. - StartAsyncThread(); - - // Do the usual setup. - return ConnectToDebugserver(""); -} - Status ProcessGDBRemote::EstablishConnectionIfNeeded(const ProcessInfo &process_info) { // Make sure we aren't already connected? @@ -4370,9 +4355,9 @@ bool ProcessGDBRemote::GetGDBServerRegisterInfoXMLAndProcess( } else if (name == "osabi") { node.GetElementText(target_info.osabi); } else if (name == "xi:include" || name == "include") { - llvm::StringRef href = node.GetAttributeValue("href"); + std::string href = node.GetAttributeValue("href"); if (!href.empty()) - target_info.includes.push_back(href.str()); + target_info.includes.push_back(href); } else if (name == "feature") { feature_nodes.push_back(node); } else if (name == "groups") { @@ -4411,9 +4396,9 @@ bool ProcessGDBRemote::GetGDBServerRegisterInfoXMLAndProcess( const XMLNode &node) -> bool { llvm::StringRef name = node.GetName(); if (name == "xi:include" || name == "include") { - llvm::StringRef href = node.GetAttributeValue("href"); + std::string href = node.GetAttributeValue("href"); if (!href.empty()) - target_info.includes.push_back(href.str()); + target_info.includes.push_back(href); } return true; }); @@ -4549,7 +4534,7 @@ llvm::Expected<LoadedModuleInfoList> ProcessGDBRemote::GetLoadedModuleList() { "Error finding library-list-svr4 xml element"); // main link map structure - llvm::StringRef main_lm = root_element.GetAttributeValue("main-lm"); + std::string main_lm = root_element.GetAttributeValue("main-lm"); // FIXME: we're silently ignoring invalid data here if (!main_lm.empty()) llvm::to_integer(main_lm, list.m_link_map); @@ -4637,15 +4622,15 @@ llvm::Expected<LoadedModuleInfoList> ProcessGDBRemote::GetLoadedModuleList() { "library", [log, &list](const XMLNode &library) -> bool { LoadedModuleInfoList::LoadedModuleInfo module; - llvm::StringRef name = library.GetAttributeValue("name"); - module.set_name(name.str()); + std::string name = library.GetAttributeValue("name"); + module.set_name(name); // The base address of a given library will be the address of its // first section. Most remotes send only one section for Windows // targets for example. const XMLNode §ion = library.FindFirstChildElementWithName("section"); - llvm::StringRef address = section.GetAttributeValue("address"); + std::string address = section.GetAttributeValue("address"); uint64_t address_value = LLDB_INVALID_ADDRESS; llvm::to_integer(address, address_value); module.set_base(address_value); diff --git a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h index 488336b8c1b8..bdf130e3ec11 100644 --- a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h +++ b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h @@ -34,7 +34,6 @@ #include "lldb/lldb-private-forward.h" #include "GDBRemoteCommunicationClient.h" -#include "GDBRemoteCommunicationReplayServer.h" #include "GDBRemoteRegisterContext.h" #include "llvm/ADT/DenseMap.h" @@ -251,7 +250,6 @@ protected: }; GDBRemoteCommunicationClient m_gdb_comm; - GDBRemoteCommunicationReplayServer m_gdb_replay_server; std::atomic<lldb::pid_t> m_debugserver_pid; llvm::Optional<StringExtractorGDBRemote> m_last_stop_packet; @@ -292,7 +290,6 @@ protected: lldb::tid_t m_initial_tid; // The initial thread ID, given by stub on attach bool m_use_g_packet_for_reading; - bool m_replay_mode; bool m_allow_flash_writes; using FlashRangeVector = lldb_private::RangeVector<lldb::addr_t, size_t>; using FlashRange = FlashRangeVector::Entry; @@ -320,8 +317,6 @@ protected: bool DoUpdateThreadList(ThreadList &old_thread_list, ThreadList &new_thread_list) override; - Status ConnectToReplayServer(); - Status EstablishConnectionIfNeeded(const ProcessInfo &process_info); Status LaunchAndConnectToDebugserver(const ProcessInfo &process_info); diff --git a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemoteLog.cpp b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemoteLog.cpp index 40990ef66494..3322f6b8048a 100644 --- a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemoteLog.cpp +++ b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemoteLog.cpp @@ -15,25 +15,29 @@ using namespace lldb_private; using namespace lldb_private::process_gdb_remote; static constexpr Log::Category g_categories[] = { - {{"async"}, {"log asynchronous activity"}, GDBR_LOG_ASYNC}, - {{"break"}, {"log breakpoints"}, GDBR_LOG_BREAKPOINTS}, - {{"comm"}, {"log communication activity"}, GDBR_LOG_COMM}, - {{"packets"}, {"log gdb remote packets"}, GDBR_LOG_PACKETS}, - {{"memory"}, {"log memory reads and writes"}, GDBR_LOG_MEMORY}, + {{"async"}, {"log asynchronous activity"}, GDBRLog::Async}, + {{"break"}, {"log breakpoints"}, GDBRLog::Breakpoints}, + {{"comm"}, {"log communication activity"}, GDBRLog::Comm}, + {{"packets"}, {"log gdb remote packets"}, GDBRLog::Packets}, + {{"memory"}, {"log memory reads and writes"}, GDBRLog::Memory}, {{"data-short"}, {"log memory bytes for memory reads and writes for short transactions " "only"}, - GDBR_LOG_MEMORY_DATA_SHORT}, + GDBRLog::MemoryDataShort}, {{"data-long"}, {"log memory bytes for memory reads and writes for all transactions"}, - GDBR_LOG_MEMORY_DATA_LONG}, - {{"process"}, {"log process events and activities"}, GDBR_LOG_PROCESS}, - {{"step"}, {"log step related activities"}, GDBR_LOG_STEP}, - {{"thread"}, {"log thread events and activities"}, GDBR_LOG_THREAD}, - {{"watch"}, {"log watchpoint related activities"}, GDBR_LOG_WATCHPOINTS}, + GDBRLog::MemoryDataLong}, + {{"process"}, {"log process events and activities"}, GDBRLog::Process}, + {{"step"}, {"log step related activities"}, GDBRLog::Step}, + {{"thread"}, {"log thread events and activities"}, GDBRLog::Thread}, + {{"watch"}, {"log watchpoint related activities"}, GDBRLog::Watchpoints}, }; -Log::Channel ProcessGDBRemoteLog::g_channel(g_categories, GDBR_LOG_DEFAULT); +static Log::Channel g_channel(g_categories, GDBRLog::Packets); + +template <> Log::Channel &lldb_private::LogChannelFor<GDBRLog>() { + return g_channel; +} void ProcessGDBRemoteLog::Initialize() { static llvm::once_flag g_once_flag; diff --git a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemoteLog.h b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemoteLog.h index bd3e993cf72a..44e390ec8cad 100644 --- a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemoteLog.h +++ b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemoteLog.h @@ -11,35 +11,52 @@ #include "lldb/Utility/Log.h" -#define GDBR_LOG_PROCESS (1u << 1) -#define GDBR_LOG_THREAD (1u << 2) -#define GDBR_LOG_PACKETS (1u << 3) -#define GDBR_LOG_MEMORY (1u << 4) // Log memory reads/writes calls -#define GDBR_LOG_MEMORY_DATA_SHORT \ - (1u << 5) // Log short memory reads/writes bytes -#define GDBR_LOG_MEMORY_DATA_LONG (1u << 6) // Log all memory reads/writes bytes -#define GDBR_LOG_BREAKPOINTS (1u << 7) -#define GDBR_LOG_WATCHPOINTS (1u << 8) -#define GDBR_LOG_STEP (1u << 9) -#define GDBR_LOG_COMM (1u << 10) -#define GDBR_LOG_ASYNC (1u << 11) -#define GDBR_LOG_ALL (UINT32_MAX) -#define GDBR_LOG_DEFAULT GDBR_LOG_PACKETS - namespace lldb_private { namespace process_gdb_remote { -class ProcessGDBRemoteLog { - static Log::Channel g_channel; +enum class GDBRLog : Log::MaskType { + Async = Log::ChannelFlag<0>, + Breakpoints = Log::ChannelFlag<1>, + Comm = Log::ChannelFlag<2>, + Memory = Log::ChannelFlag<3>, // Log memory reads/writes calls + MemoryDataLong = Log::ChannelFlag<4>, // Log all memory reads/writes bytes + MemoryDataShort = Log::ChannelFlag<5>, // Log short memory reads/writes bytes + Packets = Log::ChannelFlag<6>, + Process = Log::ChannelFlag<7>, + Step = Log::ChannelFlag<8>, + Thread = Log::ChannelFlag<9>, + Watchpoints = Log::ChannelFlag<10>, + LLVM_MARK_AS_BITMASK_ENUM(Watchpoints) +}; +#define GDBR_LOG_PROCESS ::lldb_private::process_gdb_remote::GDBRLog::Process +#define GDBR_LOG_THREAD ::lldb_private::process_gdb_remote::GDBRLog::Thread +#define GDBR_LOG_PACKETS ::lldb_private::process_gdb_remote::GDBRLog::Packets +#define GDBR_LOG_MEMORY ::lldb_private::process_gdb_remote::GDBRLog::Memory +#define GDBR_LOG_MEMORY_DATA_SHORT \ + ::lldb_private::process_gdb_remote::GDBRLog::MemoryDataShort +#define GDBR_LOG_MEMORY_DATA_LONG \ + ::lldb_private::process_gdb_remote::GDBRLog::MemoryDataLong +#define GDBR_LOG_BREAKPOINTS \ + ::lldb_private::process_gdb_remote::GDBRLog::Breakpoints +#define GDBR_LOG_WATCHPOINTS \ + ::lldb_private::process_gdb_remote::GDBRLog::Watchpoints +#define GDBR_LOG_STEP ::lldb_private::process_gdb_remote::GDBRLog::Step +#define GDBR_LOG_COMM ::lldb_private::process_gdb_remote::GDBRLog::Comm +#define GDBR_LOG_ASYNC ::lldb_private::process_gdb_remote::GDBRLog::Async + +class ProcessGDBRemoteLog { public: static void Initialize(); - static Log *GetLogIfAllCategoriesSet(uint32_t mask) { return g_channel.GetLogIfAll(mask); } - static Log *GetLogIfAnyCategoryIsSet(uint32_t mask) { return g_channel.GetLogIfAny(mask); } + static Log *GetLogIfAllCategoriesSet(GDBRLog mask) { return GetLog(mask); } + static Log *GetLogIfAnyCategoryIsSet(GDBRLog mask) { return GetLog(mask); } }; } // namespace process_gdb_remote + +template <> Log::Channel &LogChannelFor<process_gdb_remote::GDBRLog>(); + } // namespace lldb_private #endif // LLDB_SOURCE_PLUGINS_PROCESS_GDB_REMOTE_PROCESSGDBREMOTELOG_H diff --git a/lldb/source/Plugins/Process/gdb-remote/ThreadGDBRemote.cpp b/lldb/source/Plugins/Process/gdb-remote/ThreadGDBRemote.cpp index 2a9896e41085..3d23c074c1be 100644 --- a/lldb/source/Plugins/Process/gdb-remote/ThreadGDBRemote.cpp +++ b/lldb/source/Plugins/Process/gdb-remote/ThreadGDBRemote.cpp @@ -39,7 +39,7 @@ ThreadGDBRemote::ThreadGDBRemote(Process &process, lldb::tid_t tid) m_dispatch_queue_t(LLDB_INVALID_ADDRESS), m_queue_kind(eQueueKindUnknown), m_queue_serial_number(LLDB_INVALID_QUEUE_ID), m_associated_with_libdispatch_queue(eLazyBoolCalculate) { - Log *log(GetLogIfAnyCategoriesSet(GDBR_LOG_THREAD)); + Log *log = GetLog(GDBRLog::Thread); LLDB_LOG(log, "this = {0}, pid = {1}, tid = {2}", this, process.GetID(), GetID()); // At this point we can clone reg_info for architectures supporting @@ -54,7 +54,7 @@ ThreadGDBRemote::ThreadGDBRemote(Process &process, lldb::tid_t tid) ThreadGDBRemote::~ThreadGDBRemote() { ProcessSP process_sp(GetProcess()); - Log *log(GetLogIfAnyCategoriesSet(GDBR_LOG_THREAD)); + Log *log = GetLog(GDBRLog::Thread); LLDB_LOG(log, "this = {0}, pid = {1}, tid = {2}", this, process_sp ? process_sp->GetID() : LLDB_INVALID_PROCESS_ID, GetID()); DestroyThread(); @@ -222,7 +222,7 @@ void ThreadGDBRemote::SetAssociatedWithLibdispatchQueue( StructuredData::ObjectSP ThreadGDBRemote::FetchThreadExtendedInfo() { StructuredData::ObjectSP object_sp; const lldb::user_id_t tid = GetProtocolID(); - Log *log(GetLogIfAnyCategoriesSet(GDBR_LOG_THREAD)); + Log *log = GetLog(GDBRLog::Thread); LLDB_LOGF(log, "Fetching extended information for thread %4.4" PRIx64, tid); ProcessSP process_sp(GetProcess()); if (process_sp) { @@ -236,7 +236,7 @@ StructuredData::ObjectSP ThreadGDBRemote::FetchThreadExtendedInfo() { void ThreadGDBRemote::WillResume(StateType resume_state) { int signo = GetResumeSignal(); const lldb::user_id_t tid = GetProtocolID(); - Log *log(GetLogIfAnyCategoriesSet(GDBR_LOG_THREAD)); + Log *log = GetLog(GDBRLog::Thread); LLDB_LOGF(log, "Resuming thread: %4.4" PRIx64 " with state: %s.", tid, StateAsCString(resume_state)); @@ -346,3 +346,23 @@ bool ThreadGDBRemote::CalculateStopInfo() { ->CalculateThreadStopInfo(this); return false; } + +llvm::Expected<std::unique_ptr<llvm::MemoryBuffer>> +ThreadGDBRemote::GetSiginfo(size_t max_size) const { + ProcessSP process_sp(GetProcess()); + if (!process_sp) + return llvm::createStringError(llvm::inconvertibleErrorCode(), + "no process"); + ProcessGDBRemote *gdb_process = + static_cast<ProcessGDBRemote *>(process_sp.get()); + if (!gdb_process->m_gdb_comm.GetQXferSigInfoReadSupported()) + return llvm::createStringError(llvm::inconvertibleErrorCode(), + "qXfer:siginfo:read not supported"); + + llvm::Expected<std::string> response = + gdb_process->m_gdb_comm.ReadExtFeature("siginfo", ""); + if (!response) + return response.takeError(); + + return llvm::MemoryBuffer::getMemBufferCopy(response.get()); +} diff --git a/lldb/source/Plugins/Process/gdb-remote/ThreadGDBRemote.h b/lldb/source/Plugins/Process/gdb-remote/ThreadGDBRemote.h index b7d75021c062..fb83c74fd2c5 100644 --- a/lldb/source/Plugins/Process/gdb-remote/ThreadGDBRemote.h +++ b/lldb/source/Plugins/Process/gdb-remote/ThreadGDBRemote.h @@ -90,6 +90,9 @@ public: StructuredData::ObjectSP FetchThreadExtendedInfo() override; + llvm::Expected<std::unique_ptr<llvm::MemoryBuffer>> + GetSiginfo(size_t max_size) const override; + protected: friend class ProcessGDBRemote; diff --git a/lldb/source/Plugins/Process/scripted/ScriptedProcess.cpp b/lldb/source/Plugins/Process/scripted/ScriptedProcess.cpp index cb21a3e7e65f..5eb7cb0e6a5c 100644 --- a/lldb/source/Plugins/Process/scripted/ScriptedProcess.cpp +++ b/lldb/source/Plugins/Process/scripted/ScriptedProcess.cpp @@ -164,9 +164,6 @@ Status ScriptedProcess::DoLaunch(Module *exe_module, SetPrivateState(eStateStopped); - UpdateThreadListIfNeeded(); - GetThreadList(); - return {}; } @@ -225,8 +222,8 @@ bool ScriptedProcess::IsAlive() { size_t ScriptedProcess::DoReadMemory(lldb::addr_t addr, void *buf, size_t size, Status &error) { if (!m_interpreter) - return GetInterface().ErrorWithMessage<size_t>(LLVM_PRETTY_FUNCTION, - "No interpreter.", error); + return ScriptedInterface::ErrorWithMessage<size_t>( + LLVM_PRETTY_FUNCTION, "No interpreter.", error); lldb::DataExtractorSP data_extractor_sp = GetInterface().ReadMemoryAtAddress(addr, size, error); @@ -238,7 +235,7 @@ size_t ScriptedProcess::DoReadMemory(lldb::addr_t addr, void *buf, size_t size, 0, data_extractor_sp->GetByteSize(), buf, size, GetByteOrder()); if (!bytes_copied || bytes_copied == LLDB_INVALID_OFFSET) - return GetInterface().ErrorWithMessage<size_t>( + return ScriptedInterface::ErrorWithMessage<size_t>( LLVM_PRETTY_FUNCTION, "Failed to copy read memory to buffer.", error); return size; @@ -296,7 +293,7 @@ bool ScriptedProcess::DoUpdateThreadList(ThreadList &old_thread_list, ScriptLanguage language = m_interpreter->GetLanguage(); if (language != eScriptLanguagePython) - return GetInterface().ErrorWithMessage<bool>( + return ScriptedInterface::ErrorWithMessage<bool>( LLVM_PRETTY_FUNCTION, llvm::Twine("ScriptInterpreter language (" + llvm::Twine(m_interpreter->LanguageToString(language)) + @@ -304,19 +301,57 @@ bool ScriptedProcess::DoUpdateThreadList(ThreadList &old_thread_list, .str(), error); - lldb::ThreadSP thread_sp; - thread_sp = std::make_shared<ScriptedThread>(*this, error); + StructuredData::DictionarySP thread_info_sp = GetInterface().GetThreadsInfo(); + + if (!thread_info_sp) + return ScriptedInterface::ErrorWithMessage<bool>( + LLVM_PRETTY_FUNCTION, + "Couldn't fetch thread list from Scripted Process.", error); + + auto create_scripted_thread = + [this, &old_thread_list, &error, + &new_thread_list](ConstString key, StructuredData::Object *val) -> bool { + if (!val) + return ScriptedInterface::ErrorWithMessage<bool>( + LLVM_PRETTY_FUNCTION, "Invalid thread info object", error); + + lldb::tid_t tid = LLDB_INVALID_THREAD_ID; + if (!llvm::to_integer(key.AsCString(), tid)) + return ScriptedInterface::ErrorWithMessage<bool>( + LLVM_PRETTY_FUNCTION, "Invalid thread id", error); + + if (ThreadSP thread_sp = + old_thread_list.FindThreadByID(tid, false /*=can_update*/)) { + // If the thread was already in the old_thread_list, + // just add it back to the new_thread_list. + new_thread_list.AddThread(thread_sp); + return true; + } + + auto thread_or_error = ScriptedThread::Create(*this, val->GetAsGeneric()); + + if (!thread_or_error) + return ScriptedInterface::ErrorWithMessage<bool>( + LLVM_PRETTY_FUNCTION, toString(thread_or_error.takeError()), error); + + ThreadSP thread_sp = thread_or_error.get(); + lldbassert(thread_sp && "Couldn't initialize scripted thread."); + + RegisterContextSP reg_ctx_sp = thread_sp->GetRegisterContext(); + if (!reg_ctx_sp) + return ScriptedInterface::ErrorWithMessage<bool>( + LLVM_PRETTY_FUNCTION, + llvm::Twine("Invalid Register Context for thread " + + llvm::Twine(key.AsCString())) + .str(), + error); - if (!thread_sp || error.Fail()) - return GetInterface().ErrorWithMessage<bool>(LLVM_PRETTY_FUNCTION, - error.AsCString(), error); + new_thread_list.AddThread(thread_sp); - RegisterContextSP reg_ctx_sp = thread_sp->GetRegisterContext(); - if (!reg_ctx_sp) - return GetInterface().ErrorWithMessage<bool>( - LLVM_PRETTY_FUNCTION, "Invalid Register Context", error); + return true; + }; - new_thread_list.AddThread(thread_sp); + thread_info_sp->ForEach(create_scripted_thread); return new_thread_list.GetSize(false) > 0; } @@ -324,7 +359,6 @@ bool ScriptedProcess::DoUpdateThreadList(ThreadList &old_thread_list, void ScriptedProcess::RefreshStateAfterStop() { // Let all threads recover from stopping and do any clean up based on the // previous thread state (if any). - m_thread_list.RefreshStateAfterStop(); } bool ScriptedProcess::GetProcessInfo(ProcessInstanceInfo &info) { diff --git a/lldb/source/Plugins/Process/scripted/ScriptedThread.cpp b/lldb/source/Plugins/Process/scripted/ScriptedThread.cpp index 959b8c581885..b6cbb62fd6e6 100644 --- a/lldb/source/Plugins/Process/scripted/ScriptedThread.cpp +++ b/lldb/source/Plugins/Process/scripted/ScriptedThread.cpp @@ -28,44 +28,60 @@ void ScriptedThread::CheckInterpreterAndScriptObject() const { lldbassert(GetInterface() && "Invalid Scripted Thread Interface."); } -ScriptedThread::ScriptedThread(ScriptedProcess &process, Status &error) - : Thread(process, LLDB_INVALID_THREAD_ID), m_scripted_process(process) { - if (!process.IsValid()) { - error.SetErrorString("Invalid scripted process"); - return; - } +llvm::Expected<std::shared_ptr<ScriptedThread>> +ScriptedThread::Create(ScriptedProcess &process, + StructuredData::Generic *script_object) { + if (!process.IsValid()) + return llvm::createStringError(llvm::inconvertibleErrorCode(), + "Invalid scripted process."); process.CheckInterpreterAndScriptObject(); - auto scripted_thread_interface = GetInterface(); - if (!scripted_thread_interface) { - error.SetErrorString("Failed to get scripted thread interface."); - return; - } - - llvm::Optional<std::string> class_name = - process.GetInterface().GetScriptedThreadPluginName(); - if (!class_name || class_name->empty()) { - error.SetErrorString("Failed to get scripted thread class name."); - return; + auto scripted_thread_interface = + process.GetInterface().CreateScriptedThreadInterface(); + if (!scripted_thread_interface) + return llvm::createStringError( + llvm::inconvertibleErrorCode(), + "Failed to create scripted thread interface."); + + llvm::StringRef thread_class_name; + if (!script_object) { + llvm::Optional<std::string> class_name = + process.GetInterface().GetScriptedThreadPluginName(); + if (!class_name || class_name->empty()) + return llvm::createStringError( + llvm::inconvertibleErrorCode(), + "Failed to get scripted thread class name."); + thread_class_name = *class_name; } ExecutionContext exe_ctx(process); - - StructuredData::GenericSP object_sp = + StructuredData::GenericSP owned_script_object_sp = scripted_thread_interface->CreatePluginObject( - class_name->c_str(), exe_ctx, - process.m_scripted_process_info.GetArgsSP()); - if (!object_sp || !object_sp->IsValid()) { - error.SetErrorString("Failed to create valid script object"); - return; - } + thread_class_name, exe_ctx, + process.m_scripted_process_info.GetArgsSP(), script_object); - m_script_object_sp = object_sp; + if (!owned_script_object_sp) + return llvm::createStringError(llvm::inconvertibleErrorCode(), + "Failed to create script object."); + if (!owned_script_object_sp->IsValid()) + return llvm::createStringError(llvm::inconvertibleErrorCode(), + "Created script object is invalid."); - SetID(scripted_thread_interface->GetThreadID()); + lldb::tid_t tid = scripted_thread_interface->GetThreadID(); + + return std::make_shared<ScriptedThread>(process, scripted_thread_interface, + tid, owned_script_object_sp); } +ScriptedThread::ScriptedThread(ScriptedProcess &process, + ScriptedThreadInterfaceSP interface_sp, + lldb::tid_t tid, + StructuredData::GenericSP script_object_sp) + : Thread(process, tid), m_scripted_process(process), + m_scripted_thread_interface_sp(interface_sp), + m_script_object_sp(script_object_sp) {} + ScriptedThread::~ScriptedThread() { DestroyThread(); } const char *ScriptedThread::GetName() { @@ -137,6 +153,11 @@ bool ScriptedThread::CalculateStopInfo() { StructuredData::DictionarySP dict_sp = GetInterface()->GetStopReason(); Status error; + if (!dict_sp) + return GetInterface()->ErrorWithMessage<bool>( + LLVM_PRETTY_FUNCTION, "Failed to get scripted thread stop info.", error, + LIBLLDB_LOG_THREAD); + lldb::StopInfoSP stop_info_sp; lldb::StopReason stop_reason_type; @@ -150,12 +171,12 @@ bool ScriptedThread::CalculateStopInfo() { if (!dict_sp->GetValueForKeyAsDictionary("data", data_dict)) return GetInterface()->ErrorWithMessage<bool>( LLVM_PRETTY_FUNCTION, - "Couldn't find value for key 'type' in stop reason dictionary.", error, + "Couldn't find value for key 'data' in stop reason dictionary.", error, LIBLLDB_LOG_THREAD); switch (stop_reason_type) { case lldb::eStopReasonNone: - break; + return true; case lldb::eStopReasonBreakpoint: { lldb::break_id_t break_id; data_dict->GetValueForKeyAsInteger("break_id", break_id, @@ -172,6 +193,13 @@ bool ScriptedThread::CalculateStopInfo() { stop_info_sp = StopInfo::CreateStopReasonWithSignal(*this, signal, description.data()); } break; + case lldb::eStopReasonException: { + llvm::StringRef description; + data_dict->GetValueForKeyAsString("desc", description); + + stop_info_sp = + StopInfo::CreateStopReasonWithException(*this, description.data()); + } break; default: return GetInterface()->ErrorWithMessage<bool>( LLVM_PRETTY_FUNCTION, @@ -181,6 +209,9 @@ bool ScriptedThread::CalculateStopInfo() { error, LIBLLDB_LOG_THREAD); } + if (!stop_info_sp) + return false; + SetStopInfo(stop_info_sp); return true; } @@ -190,7 +221,7 @@ void ScriptedThread::RefreshStateAfterStop() { } lldb::ScriptedThreadInterfaceSP ScriptedThread::GetInterface() const { - return m_scripted_process.GetInterface().GetScriptedThreadInterface(); + return m_scripted_thread_interface_sp; } std::shared_ptr<DynamicRegisterInfo> ScriptedThread::GetDynamicRegisterInfo() { diff --git a/lldb/source/Plugins/Process/scripted/ScriptedThread.h b/lldb/source/Plugins/Process/scripted/ScriptedThread.h index cdcd543702a4..8d8a7c2a3df9 100644 --- a/lldb/source/Plugins/Process/scripted/ScriptedThread.h +++ b/lldb/source/Plugins/Process/scripted/ScriptedThread.h @@ -25,11 +25,18 @@ class ScriptedProcess; namespace lldb_private { class ScriptedThread : public lldb_private::Thread { + public: - ScriptedThread(ScriptedProcess &process, Status &error); + ScriptedThread(ScriptedProcess &process, + lldb::ScriptedThreadInterfaceSP interface_sp, lldb::tid_t tid, + StructuredData::GenericSP script_object_sp = nullptr); ~ScriptedThread() override; + static llvm::Expected<std::shared_ptr<ScriptedThread>> + Create(ScriptedProcess &process, + StructuredData::Generic *script_object = nullptr); + lldb::RegisterContextSP GetRegisterContext() override; lldb::RegisterContextSP @@ -59,8 +66,9 @@ private: std::shared_ptr<DynamicRegisterInfo> GetDynamicRegisterInfo(); const ScriptedProcess &m_scripted_process; + lldb::ScriptedThreadInterfaceSP m_scripted_thread_interface_sp = nullptr; + lldb_private::StructuredData::GenericSP m_script_object_sp = nullptr; std::shared_ptr<DynamicRegisterInfo> m_register_info_sp = nullptr; - lldb_private::StructuredData::ObjectSP m_script_object_sp = nullptr; }; } // namespace lldb_private diff --git a/lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.cpp b/lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.cpp index 7c71c9329e57..68f4e90d70f6 100644 --- a/lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.cpp +++ b/lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.cpp @@ -69,6 +69,30 @@ Expected<std::string> python::As<std::string>(Expected<PythonObject> &&obj) { return std::string(utf8.get()); } +static bool python_is_finalizing() { +#if PY_MAJOR_VERSION == 2 + return false; +#elif PY_MAJOR_VERSION == 3 && PY_MINOR_VERSION < 7 + return _Py_Finalizing != nullptr; +#else + return _Py_IsFinalizing(); +#endif +} + +void PythonObject::Reset() { + if (m_py_obj && Py_IsInitialized()) { + if (python_is_finalizing()) { + // Leak m_py_obj rather than crashing the process. + // https://docs.python.org/3/c-api/init.html#c.PyGILState_Ensure + } else { + PyGILState_STATE state = PyGILState_Ensure(); + Py_DECREF(m_py_obj); + PyGILState_Release(state); + } + } + m_py_obj = nullptr; +} + Expected<long long> PythonObject::AsLongLong() const { if (!m_py_obj) return nullDeref(); @@ -257,6 +281,9 @@ PythonObject PythonObject::GetAttributeValue(llvm::StringRef attr) const { } StructuredData::ObjectSP PythonObject::CreateStructuredObject() const { +#if PY_MAJOR_VERSION >= 3 + assert(PyGILState_Check()); +#endif switch (GetObjectType()) { case PyObjectType::Dictionary: return PythonDictionary(PyRefType::Borrowed, m_py_obj) @@ -279,7 +306,8 @@ StructuredData::ObjectSP PythonObject::CreateStructuredObject() const { case PyObjectType::None: return StructuredData::ObjectSP(); default: - return StructuredData::ObjectSP(new StructuredPythonObject(m_py_obj)); + return StructuredData::ObjectSP(new StructuredPythonObject( + PythonObject(PyRefType::Borrowed, m_py_obj))); } } diff --git a/lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.h b/lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.h index 56bc55d239d1..2094f0b3afd2 100644 --- a/lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.h +++ b/lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.h @@ -83,30 +83,6 @@ protected: PyGILState_STATE m_state; }; -class StructuredPythonObject : public StructuredData::Generic { -public: - StructuredPythonObject() : StructuredData::Generic() {} - - StructuredPythonObject(void *obj) : StructuredData::Generic(obj) { - Py_XINCREF(GetValue()); - } - - ~StructuredPythonObject() override { - if (Py_IsInitialized()) - Py_XDECREF(GetValue()); - SetValue(nullptr); - } - - bool IsValid() const override { return GetValue() && GetValue() != Py_None; } - - void Serialize(llvm::json::OStream &s) const override; - -private: - StructuredPythonObject(const StructuredPythonObject &) = delete; - const StructuredPythonObject & - operator=(const StructuredPythonObject &) = delete; -}; - enum class PyObjectType { Unknown, None, @@ -263,11 +239,7 @@ public: ~PythonObject() { Reset(); } - void Reset() { - if (m_py_obj && Py_IsInitialized()) - Py_DECREF(m_py_obj); - m_py_obj = nullptr; - } + void Reset(); void Dump() const { if (m_py_obj) @@ -767,6 +739,30 @@ public: } }; +class StructuredPythonObject : public StructuredData::Generic { +public: + StructuredPythonObject() : StructuredData::Generic() {} + + // Take ownership of the object we received. + StructuredPythonObject(PythonObject obj) + : StructuredData::Generic(obj.release()) {} + + ~StructuredPythonObject() override { + // Hand ownership back to a (temporary) PythonObject instance and let it + // take care of releasing it. + PythonObject(PyRefType::Owned, static_cast<PyObject *>(GetValue())); + } + + bool IsValid() const override { return GetValue() && GetValue() != Py_None; } + + void Serialize(llvm::json::OStream &s) const override; + +private: + StructuredPythonObject(const StructuredPythonObject &) = delete; + const StructuredPythonObject & + operator=(const StructuredPythonObject &) = delete; +}; + } // namespace python } // namespace lldb_private diff --git a/lldb/source/Plugins/ScriptInterpreter/Python/SWIGPythonBridge.h b/lldb/source/Plugins/ScriptInterpreter/Python/SWIGPythonBridge.h index 2bb69dc47731..4df235356737 100644 --- a/lldb/source/Plugins/ScriptInterpreter/Python/SWIGPythonBridge.h +++ b/lldb/source/Plugins/ScriptInterpreter/Python/SWIGPythonBridge.h @@ -18,6 +18,7 @@ // LLDB Python header must be included first #include "lldb-python.h" +#include "Plugins/ScriptInterpreter/Python/PythonDataObjects.h" #include "lldb/lldb-forward.h" #include "lldb/lldb-types.h" #include "llvm/Support/Error.h" @@ -54,17 +55,15 @@ void *LLDBSWIGPython_CastPyObjectToSBMemoryRegionInfo(PyObject *data); // Although these are scripting-language specific, their definition depends on // the public API. -void *LLDBSwigPythonCreateScriptedProcess(const char *python_class_name, - const char *session_dictionary_name, - const lldb::TargetSP &target_sp, - const StructuredDataImpl &args_impl, - std::string &error_string); +python::PythonObject LLDBSwigPythonCreateScriptedProcess( + const char *python_class_name, const char *session_dictionary_name, + const lldb::TargetSP &target_sp, const StructuredDataImpl &args_impl, + std::string &error_string); -void *LLDBSwigPythonCreateScriptedThread(const char *python_class_name, - const char *session_dictionary_name, - const lldb::ProcessSP &process_sp, - const StructuredDataImpl &args_impl, - std::string &error_string); +python::PythonObject LLDBSwigPythonCreateScriptedThread( + const char *python_class_name, const char *session_dictionary_name, + const lldb::ProcessSP &process_sp, const StructuredDataImpl &args_impl, + std::string &error_string); llvm::Expected<bool> LLDBSwigPythonBreakpointCallbackFunction( const char *python_function_name, const char *session_dictionary_name, @@ -83,16 +82,17 @@ bool LLDBSwigPythonCallTypeScript(const char *python_function_name, const lldb::TypeSummaryOptionsSP &options_sp, std::string &retval); -void * +python::PythonObject LLDBSwigPythonCreateSyntheticProvider(const char *python_class_name, const char *session_dictionary_name, const lldb::ValueObjectSP &valobj_sp); -void *LLDBSwigPythonCreateCommandObject(const char *python_class_name, - const char *session_dictionary_name, - lldb::DebuggerSP debugger_sp); +python::PythonObject +LLDBSwigPythonCreateCommandObject(const char *python_class_name, + const char *session_dictionary_name, + lldb::DebuggerSP debugger_sp); -void *LLDBSwigPythonCreateScriptedThreadPlan( +python::PythonObject LLDBSwigPythonCreateScriptedThreadPlan( const char *python_class_name, const char *session_dictionary_name, const StructuredDataImpl &args_data, std::string &error_string, const lldb::ThreadPlanSP &thread_plan_sp); @@ -101,7 +101,7 @@ bool LLDBSWIGPythonCallThreadPlan(void *implementor, const char *method_name, lldb_private::Event *event_sp, bool &got_error); -void *LLDBSwigPythonCreateScriptedBreakpointResolver( +python::PythonObject LLDBSwigPythonCreateScriptedBreakpointResolver( const char *python_class_name, const char *session_dictionary_name, const StructuredDataImpl &args, const lldb::BreakpointSP &bkpt_sp); @@ -109,11 +109,10 @@ unsigned int LLDBSwigPythonCallBreakpointResolver(void *implementor, const char *method_name, lldb_private::SymbolContext *sym_ctx); -void *LLDBSwigPythonCreateScriptedStopHook(lldb::TargetSP target_sp, - const char *python_class_name, - const char *session_dictionary_name, - const StructuredDataImpl &args, - lldb_private::Status &error); +python::PythonObject LLDBSwigPythonCreateScriptedStopHook( + lldb::TargetSP target_sp, const char *python_class_name, + const char *session_dictionary_name, const StructuredDataImpl &args, + lldb_private::Status &error); bool LLDBSwigPythonStopHookCallHandleStop(void *implementor, lldb::ExecutionContextRefSP exc_ctx, @@ -150,12 +149,14 @@ bool LLDBSwigPythonCallModuleInit(const char *python_module_name, const char *session_dictionary_name, lldb::DebuggerSP debugger); -void *LLDBSWIGPythonCreateOSPlugin(const char *python_class_name, - const char *session_dictionary_name, - const lldb::ProcessSP &process_sp); +python::PythonObject +LLDBSWIGPythonCreateOSPlugin(const char *python_class_name, + const char *session_dictionary_name, + const lldb::ProcessSP &process_sp); -void *LLDBSWIGPython_CreateFrameRecognizer(const char *python_class_name, - const char *session_dictionary_name); +python::PythonObject +LLDBSWIGPython_CreateFrameRecognizer(const char *python_class_name, + const char *session_dictionary_name); PyObject * LLDBSwigPython_GetRecognizedArguments(PyObject *implementor, diff --git a/lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp b/lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp index 6afa4742698b..1bf647e4acfc 100644 --- a/lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp +++ b/lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp @@ -37,7 +37,7 @@ #include "lldb/Interpreter/CommandReturnObject.h" #include "lldb/Target/Thread.h" #include "lldb/Target/ThreadPlan.h" -#include "lldb/Utility/ReproducerInstrumentation.h" +#include "lldb/Utility/Instrumentation.h" #include "lldb/Utility/Timer.h" #include "llvm/ADT/STLExtras.h" #include "llvm/ADT/StringRef.h" @@ -70,6 +70,14 @@ extern "C" void init_lldb(void); #define LLDBSwigPyInit init_lldb #endif +#if defined(_WIN32) +// Don't mess with the signal handlers on Windows. +#define LLDB_USE_PYTHON_SET_INTERRUPT 0 +#else +// PyErr_SetInterrupt was introduced in 3.2. +#define LLDB_USE_PYTHON_SET_INTERRUPT \ + (PY_MAJOR_VERSION == 3 && PY_MINOR_VERSION >= 2) || (PY_MAJOR_VERSION > 3) +#endif static ScriptInterpreterPythonImpl *GetPythonInterpreter(Debugger &debugger) { ScriptInterpreter *script_interpreter = @@ -77,8 +85,6 @@ static ScriptInterpreterPythonImpl *GetPythonInterpreter(Debugger &debugger) { return static_cast<ScriptInterpreterPythonImpl *>(script_interpreter); } -static bool g_initialized = false; - namespace { // Initializing Python is not a straightforward process. We cannot control @@ -211,6 +217,28 @@ private: PyGILState_STATE m_gil_state = PyGILState_UNLOCKED; bool m_was_already_initialized = false; }; + +#if LLDB_USE_PYTHON_SET_INTERRUPT +/// Saves the current signal handler for the specified signal and restores +/// it at the end of the current scope. +struct RestoreSignalHandlerScope { + /// The signal handler. + struct sigaction m_prev_handler; + int m_signal_code; + RestoreSignalHandlerScope(int signal_code) : m_signal_code(signal_code) { + // Initialize sigaction to their default state. + std::memset(&m_prev_handler, 0, sizeof(m_prev_handler)); + // Don't install a new handler, just read back the old one. + struct sigaction *new_handler = nullptr; + int signal_err = ::sigaction(m_signal_code, new_handler, &m_prev_handler); + lldbassert(signal_err == 0 && "sigaction failed to read handler"); + } + ~RestoreSignalHandlerScope() { + int signal_err = ::sigaction(m_signal_code, &m_prev_handler, nullptr); + lldbassert(signal_err == 0 && "sigaction failed to restore old handler"); + } +}; +#endif } // namespace void ScriptInterpreterPython::ComputePythonDirForApple( @@ -325,12 +353,12 @@ llvm::StringRef ScriptInterpreterPython::GetPluginDescriptionStatic() { void ScriptInterpreterPython::Initialize() { static llvm::once_flag g_once_flag; - llvm::call_once(g_once_flag, []() { PluginManager::RegisterPlugin(GetPluginNameStatic(), GetPluginDescriptionStatic(), lldb::eScriptLanguagePython, ScriptInterpreterPythonImpl::CreateInstance); + ScriptInterpreterPythonImpl::Initialize(); }); } @@ -342,7 +370,6 @@ ScriptInterpreterPythonImpl::Locker::Locker( : ScriptInterpreterLocker(), m_teardown_session((on_leave & TearDownSession) == TearDownSession), m_python_interpreter(py_interpreter) { - repro::Recorder::PrivateThread(); DoAcquireLock(); if ((on_entry & InitSession) == InitSession) { if (!DoInitSession(on_entry, in, out, err)) { @@ -408,8 +435,6 @@ ScriptInterpreterPythonImpl::ScriptInterpreterPythonImpl(Debugger &debugger) m_active_io_handler(eIOHandlerNone), m_session_is_active(false), m_pty_secondary_is_open(false), m_valid_session(true), m_lock_count(0), m_command_thread_state(nullptr) { - InitializePrivate(); - m_scripted_process_interface_up = std::make_unique<ScriptedProcessPythonInterface>(*this); @@ -921,6 +946,22 @@ void ScriptInterpreterPythonImpl::ExecuteInterpreterLoop() { } bool ScriptInterpreterPythonImpl::Interrupt() { +#if LLDB_USE_PYTHON_SET_INTERRUPT + // If the interpreter isn't evaluating any Python at the moment then return + // false to signal that this function didn't handle the interrupt and the + // next component should try handling it. + if (!IsExecutingPython()) + return false; + + // Tell Python that it should pretend to have received a SIGINT. + PyErr_SetInterrupt(); + // PyErr_SetInterrupt has no way to return an error so we can only pretend the + // signal got successfully handled and return true. + // Python 3.10 introduces PyErr_SetInterruptEx that could return an error, but + // the error handling is limited to checking the arguments which would be + // just our (hardcoded) input signal code SIGINT, so that's not useful at all. + return true; +#else Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_SCRIPT)); if (IsExecutingPython()) { @@ -942,6 +983,7 @@ bool ScriptInterpreterPythonImpl::Interrupt() { "ScriptInterpreterPythonImpl::Interrupt() python code not running, " "can't interrupt"); return false; +#endif } bool ScriptInterpreterPythonImpl::ExecuteOneLineWithReturn( @@ -1414,16 +1456,12 @@ ScriptInterpreterPythonImpl::CreateFrameRecognizer(const char *class_name) { if (class_name == nullptr || class_name[0] == '\0') return StructuredData::GenericSP(); - void *ret_val; - - { - Locker py_lock(this, Locker::AcquireLock | Locker::NoSTDIN, - Locker::FreeLock); - ret_val = LLDBSWIGPython_CreateFrameRecognizer(class_name, - m_dictionary_name.c_str()); - } + Locker py_lock(this, Locker::AcquireLock | Locker::NoSTDIN, Locker::FreeLock); + PythonObject ret_val = LLDBSWIGPython_CreateFrameRecognizer( + class_name, m_dictionary_name.c_str()); - return StructuredData::GenericSP(new StructuredPythonObject(ret_val)); + return StructuredData::GenericSP( + new StructuredPythonObject(std::move(ret_val))); } lldb::ValueObjectListSP ScriptInterpreterPythonImpl::GetRecognizedArguments( @@ -1478,16 +1516,12 @@ ScriptInterpreterPythonImpl::OSPlugin_CreatePluginObject( if (!process_sp) return StructuredData::GenericSP(); - void *ret_val; - - { - Locker py_lock(this, Locker::AcquireLock | Locker::NoSTDIN, - Locker::FreeLock); - ret_val = LLDBSWIGPythonCreateOSPlugin( - class_name, m_dictionary_name.c_str(), process_sp); - } + Locker py_lock(this, Locker::AcquireLock | Locker::NoSTDIN, Locker::FreeLock); + PythonObject ret_val = LLDBSWIGPythonCreateOSPlugin( + class_name, m_dictionary_name.c_str(), process_sp); - return StructuredData::GenericSP(new StructuredPythonObject(ret_val)); + return StructuredData::GenericSP( + new StructuredPythonObject(std::move(ret_val))); } StructuredData::DictionarySP ScriptInterpreterPythonImpl::OSPlugin_RegisterInfo( @@ -1733,19 +1767,16 @@ StructuredData::ObjectSP ScriptInterpreterPythonImpl::CreateScriptedThreadPlan( if (!python_interpreter) return {}; - void *ret_val; - - { - Locker py_lock(this, - Locker::AcquireLock | Locker::InitSession | Locker::NoSTDIN); - ret_val = LLDBSwigPythonCreateScriptedThreadPlan( - class_name, python_interpreter->m_dictionary_name.c_str(), - args_data, error_str, thread_plan_sp); - if (!ret_val) - return {}; - } + Locker py_lock(this, + Locker::AcquireLock | Locker::InitSession | Locker::NoSTDIN); + PythonObject ret_val = LLDBSwigPythonCreateScriptedThreadPlan( + class_name, python_interpreter->m_dictionary_name.c_str(), args_data, + error_str, thread_plan_sp); + if (!ret_val) + return {}; - return StructuredData::ObjectSP(new StructuredPythonObject(ret_val)); + return StructuredData::ObjectSP( + new StructuredPythonObject(std::move(ret_val))); } bool ScriptInterpreterPythonImpl::ScriptedThreadPlanExplainsStop( @@ -1836,18 +1867,15 @@ ScriptInterpreterPythonImpl::CreateScriptedBreakpointResolver( if (!python_interpreter) return StructuredData::GenericSP(); - void *ret_val; - - { - Locker py_lock(this, - Locker::AcquireLock | Locker::InitSession | Locker::NoSTDIN); + Locker py_lock(this, + Locker::AcquireLock | Locker::InitSession | Locker::NoSTDIN); - ret_val = LLDBSwigPythonCreateScriptedBreakpointResolver( - class_name, python_interpreter->m_dictionary_name.c_str(), args_data, - bkpt_sp); - } + PythonObject ret_val = LLDBSwigPythonCreateScriptedBreakpointResolver( + class_name, python_interpreter->m_dictionary_name.c_str(), args_data, + bkpt_sp); - return StructuredData::GenericSP(new StructuredPythonObject(ret_val)); + return StructuredData::GenericSP( + new StructuredPythonObject(std::move(ret_val))); } bool ScriptInterpreterPythonImpl::ScriptedBreakpointResolverSearchCallback( @@ -1911,18 +1939,15 @@ StructuredData::GenericSP ScriptInterpreterPythonImpl::CreateScriptedStopHook( return StructuredData::GenericSP(); } - void *ret_val; - - { - Locker py_lock(this, - Locker::AcquireLock | Locker::InitSession | Locker::NoSTDIN); + Locker py_lock(this, + Locker::AcquireLock | Locker::InitSession | Locker::NoSTDIN); - ret_val = LLDBSwigPythonCreateScriptedStopHook( - target_sp, class_name, python_interpreter->m_dictionary_name.c_str(), - args_data, error); - } + PythonObject ret_val = LLDBSwigPythonCreateScriptedStopHook( + target_sp, class_name, python_interpreter->m_dictionary_name.c_str(), + args_data, error); - return StructuredData::GenericSP(new StructuredPythonObject(ret_val)); + return StructuredData::GenericSP( + new StructuredPythonObject(std::move(ret_val))); } bool ScriptInterpreterPythonImpl::ScriptedStopHookHandleStop( @@ -2011,16 +2036,13 @@ ScriptInterpreterPythonImpl::CreateSyntheticScriptedProvider( if (!python_interpreter) return StructuredData::ObjectSP(); - void *ret_val = nullptr; - - { - Locker py_lock(this, - Locker::AcquireLock | Locker::InitSession | Locker::NoSTDIN); - ret_val = LLDBSwigPythonCreateSyntheticProvider( - class_name, python_interpreter->m_dictionary_name.c_str(), valobj); - } + Locker py_lock(this, + Locker::AcquireLock | Locker::InitSession | Locker::NoSTDIN); + PythonObject ret_val = LLDBSwigPythonCreateSyntheticProvider( + class_name, python_interpreter->m_dictionary_name.c_str(), valobj); - return StructuredData::ObjectSP(new StructuredPythonObject(ret_val)); + return StructuredData::ObjectSP( + new StructuredPythonObject(std::move(ret_val))); } StructuredData::GenericSP @@ -2033,16 +2055,13 @@ ScriptInterpreterPythonImpl::CreateScriptCommandObject(const char *class_name) { if (!debugger_sp.get()) return StructuredData::GenericSP(); - void *ret_val; - - { - Locker py_lock(this, - Locker::AcquireLock | Locker::InitSession | Locker::NoSTDIN); - ret_val = LLDBSwigPythonCreateCommandObject( - class_name, m_dictionary_name.c_str(), debugger_sp); - } + Locker py_lock(this, + Locker::AcquireLock | Locker::InitSession | Locker::NoSTDIN); + PythonObject ret_val = LLDBSwigPythonCreateCommandObject( + class_name, m_dictionary_name.c_str(), debugger_sp); - return StructuredData::GenericSP(new StructuredPythonObject(ret_val)); + return StructuredData::GenericSP( + new StructuredPythonObject(std::move(ret_val))); } bool ScriptInterpreterPythonImpl::GenerateTypeScriptFunction( @@ -2152,8 +2171,12 @@ bool ScriptInterpreterPythonImpl::GetScriptedSummary( return false; } - if (new_callee && old_callee != new_callee) - callee_wrapper_sp = std::make_shared<StructuredPythonObject>(new_callee); + if (new_callee && old_callee != new_callee) { + Locker py_lock(this, + Locker::AcquireLock | Locker::InitSession | Locker::NoSTDIN); + callee_wrapper_sp = std::make_shared<StructuredPythonObject>( + PythonObject(PyRefType::Borrowed, static_cast<PyObject *>(new_callee))); + } return ret_val; } @@ -2805,7 +2828,8 @@ bool ScriptInterpreterPythonImpl::LoadScriptingModule( ScriptInterpreter::eScriptReturnTypeOpaqueObject, &module_pyobj, exc_options) && module_pyobj) - *module_sp = std::make_shared<StructuredPythonObject>(module_pyobj); + *module_sp = std::make_shared<StructuredPythonObject>(PythonObject( + PyRefType::Owned, static_cast<PyObject *>(module_pyobj))); } return true; @@ -3145,12 +3169,7 @@ ScriptInterpreterPythonImpl::AcquireInterpreterLock() { return py_lock; } -void ScriptInterpreterPythonImpl::InitializePrivate() { - if (g_initialized) - return; - - g_initialized = true; - +void ScriptInterpreterPythonImpl::Initialize() { LLDB_SCOPED_TIMER(); // RAII-based initialization which correctly handles multiple-initialization, @@ -3180,6 +3199,25 @@ void ScriptInterpreterPythonImpl::InitializePrivate() { "lldb.embedded_interpreter; from " "lldb.embedded_interpreter import run_python_interpreter; " "from lldb.embedded_interpreter import run_one_line"); + +#if LLDB_USE_PYTHON_SET_INTERRUPT + // Python will not just overwrite its internal SIGINT handler but also the + // one from the process. Backup the current SIGINT handler to prevent that + // Python deletes it. + RestoreSignalHandlerScope save_sigint(SIGINT); + + // Setup a default SIGINT signal handler that works the same way as the + // normal Python REPL signal handler which raises a KeyboardInterrupt. + // Also make sure to not pollute the user's REPL with the signal module nor + // our utility function. + PyRun_SimpleString("def lldb_setup_sigint_handler():\n" + " import signal;\n" + " def signal_handler(sig, frame):\n" + " raise KeyboardInterrupt()\n" + " signal.signal(signal.SIGINT, signal_handler);\n" + "lldb_setup_sigint_handler();\n" + "del lldb_setup_sigint_handler\n"); +#endif } void ScriptInterpreterPythonImpl::AddToSysPath(AddLocation location, diff --git a/lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPythonImpl.h b/lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPythonImpl.h index defc2acffcfa..3b80c67d201a 100644 --- a/lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPythonImpl.h +++ b/lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPythonImpl.h @@ -341,7 +341,7 @@ public: static bool WatchpointCallbackFunction(void *baton, StoppointCallbackContext *context, lldb::user_id_t watch_id); - static void InitializePrivate(); + static void Initialize(); class SynchronicityHandler { private: diff --git a/lldb/source/Plugins/ScriptInterpreter/Python/ScriptedProcessPythonInterface.cpp b/lldb/source/Plugins/ScriptInterpreter/Python/ScriptedProcessPythonInterface.cpp index e3c1931a565a..e39f8be73e49 100644 --- a/lldb/source/Plugins/ScriptInterpreter/Python/ScriptedProcessPythonInterface.cpp +++ b/lldb/source/Plugins/ScriptInterpreter/Python/ScriptedProcessPythonInterface.cpp @@ -32,7 +32,7 @@ ScriptedProcessPythonInterface::ScriptedProcessPythonInterface( StructuredData::GenericSP ScriptedProcessPythonInterface::CreatePluginObject( llvm::StringRef class_name, ExecutionContext &exe_ctx, - StructuredData::DictionarySP args_sp) { + StructuredData::DictionarySP args_sp, StructuredData::Generic *script_obj) { if (class_name.empty()) return {}; @@ -43,15 +43,12 @@ StructuredData::GenericSP ScriptedProcessPythonInterface::CreatePluginObject( Locker py_lock(&m_interpreter, Locker::AcquireLock | Locker::NoSTDIN, Locker::FreeLock); - void *ret_val = LLDBSwigPythonCreateScriptedProcess( + PythonObject ret_val = LLDBSwigPythonCreateScriptedProcess( class_name.str().c_str(), m_interpreter.GetDictionaryName(), target_sp, args_impl, error_string); - if (!ret_val) - return {}; - m_object_instance_sp = - StructuredData::GenericSP(new StructuredPythonObject(ret_val)); + StructuredData::GenericSP(new StructuredPythonObject(std::move(ret_val))); return m_object_instance_sp; } @@ -92,6 +89,17 @@ ScriptedProcessPythonInterface::GetMemoryRegionContainingAddress( return mem_region; } +StructuredData::DictionarySP ScriptedProcessPythonInterface::GetThreadsInfo() { + Status error; + StructuredData::DictionarySP dict = + Dispatch<StructuredData::DictionarySP>("get_threads_info", error); + + if (!CheckStructuredDataObject(LLVM_PRETTY_FUNCTION, dict, error)) + return {}; + + return dict; +} + StructuredData::DictionarySP ScriptedProcessPythonInterface::GetThreadWithID(lldb::tid_t tid) { Status error; @@ -154,12 +162,8 @@ ScriptedProcessPythonInterface::GetScriptedThreadPluginName() { } lldb::ScriptedThreadInterfaceSP -ScriptedProcessPythonInterface::GetScriptedThreadInterface() { - if (!m_scripted_thread_interface_sp) - m_scripted_thread_interface_sp = - std::make_shared<ScriptedThreadPythonInterface>(m_interpreter); - - return m_scripted_thread_interface_sp; +ScriptedProcessPythonInterface::CreateScriptedThreadInterface() { + return std::make_shared<ScriptedThreadPythonInterface>(m_interpreter); } #endif diff --git a/lldb/source/Plugins/ScriptInterpreter/Python/ScriptedProcessPythonInterface.h b/lldb/source/Plugins/ScriptInterpreter/Python/ScriptedProcessPythonInterface.h index 421bdd59887c..e34a181849eb 100644 --- a/lldb/source/Plugins/ScriptInterpreter/Python/ScriptedProcessPythonInterface.h +++ b/lldb/source/Plugins/ScriptInterpreter/Python/ScriptedProcessPythonInterface.h @@ -25,7 +25,8 @@ public: StructuredData::GenericSP CreatePluginObject(const llvm::StringRef class_name, ExecutionContext &exe_ctx, - StructuredData::DictionarySP args_sp) override; + StructuredData::DictionarySP args_sp, + StructuredData::Generic *script_obj = nullptr) override; Status Launch() override; @@ -39,6 +40,8 @@ public: GetMemoryRegionContainingAddress(lldb::addr_t address, Status &error) override; + StructuredData::DictionarySP GetThreadsInfo() override; + StructuredData::DictionarySP GetThreadWithID(lldb::tid_t tid) override; StructuredData::DictionarySP GetRegistersForThread(lldb::tid_t tid) override; @@ -55,7 +58,7 @@ public: llvm::Optional<std::string> GetScriptedThreadPluginName() override; private: - lldb::ScriptedThreadInterfaceSP GetScriptedThreadInterface() override; + lldb::ScriptedThreadInterfaceSP CreateScriptedThreadInterface() override; }; } // namespace lldb_private diff --git a/lldb/source/Plugins/ScriptInterpreter/Python/ScriptedThreadPythonInterface.cpp b/lldb/source/Plugins/ScriptInterpreter/Python/ScriptedThreadPythonInterface.cpp index 6a881bfe625c..d471b2c5f7e3 100644 --- a/lldb/source/Plugins/ScriptInterpreter/Python/ScriptedThreadPythonInterface.cpp +++ b/lldb/source/Plugins/ScriptInterpreter/Python/ScriptedThreadPythonInterface.cpp @@ -31,9 +31,8 @@ ScriptedThreadPythonInterface::ScriptedThreadPythonInterface( StructuredData::GenericSP ScriptedThreadPythonInterface::CreatePluginObject( const llvm::StringRef class_name, ExecutionContext &exe_ctx, - StructuredData::DictionarySP args_sp) { - - if (class_name.empty()) + StructuredData::DictionarySP args_sp, StructuredData::Generic *script_obj) { + if (class_name.empty() && !script_obj) return {}; ProcessSP process_sp = exe_ctx.GetProcessSP(); @@ -43,15 +42,21 @@ StructuredData::GenericSP ScriptedThreadPythonInterface::CreatePluginObject( Locker py_lock(&m_interpreter, Locker::AcquireLock | Locker::NoSTDIN, Locker::FreeLock); - void *ret_val = LLDBSwigPythonCreateScriptedThread( - class_name.str().c_str(), m_interpreter.GetDictionaryName(), process_sp, - args_impl, error_string); + PythonObject ret_val; + + if (!script_obj) + ret_val = LLDBSwigPythonCreateScriptedThread( + class_name.str().c_str(), m_interpreter.GetDictionaryName(), process_sp, + args_impl, error_string); + else + ret_val = PythonObject(PyRefType::Borrowed, + static_cast<PyObject *>(script_obj->GetValue())); if (!ret_val) return {}; m_object_instance_sp = - StructuredData::GenericSP(new StructuredPythonObject(ret_val)); + StructuredData::GenericSP(new StructuredPythonObject(std::move(ret_val))); return m_object_instance_sp; } diff --git a/lldb/source/Plugins/ScriptInterpreter/Python/ScriptedThreadPythonInterface.h b/lldb/source/Plugins/ScriptInterpreter/Python/ScriptedThreadPythonInterface.h index 996b8d43136b..59bb182ae3f3 100644 --- a/lldb/source/Plugins/ScriptInterpreter/Python/ScriptedThreadPythonInterface.h +++ b/lldb/source/Plugins/ScriptInterpreter/Python/ScriptedThreadPythonInterface.h @@ -24,7 +24,8 @@ public: StructuredData::GenericSP CreatePluginObject(llvm::StringRef class_name, ExecutionContext &exe_ctx, - StructuredData::DictionarySP args_sp) override; + StructuredData::DictionarySP args_sp, + StructuredData::Generic *script_obj = nullptr) override; lldb::tid_t GetThreadID() override; @@ -45,4 +46,4 @@ public: } // namespace lldb_private #endif // LLDB_ENABLE_PYTHON -#endif // LLDB_PLUGINS_SCRIPTINTERPRETER_PYTHON_SCRIPTEDPROCESSTHREADINTERFACE_H +#endif // LLDB_PLUGINS_SCRIPTINTERPRETER_PYTHON_SCRIPTEDTHREADPYTHONINTERFACE_H diff --git a/lldb/source/Plugins/ScriptInterpreter/Python/lldb-python.h b/lldb/source/Plugins/ScriptInterpreter/Python/lldb-python.h index 48f27b09b95c..c99372fa110c 100644 --- a/lldb/source/Plugins/ScriptInterpreter/Python/lldb-python.h +++ b/lldb/source/Plugins/ScriptInterpreter/Python/lldb-python.h @@ -9,6 +9,13 @@ #ifndef LLDB_PLUGINS_SCRIPTINTERPRETER_PYTHON_LLDB_PYTHON_H #define LLDB_PLUGINS_SCRIPTINTERPRETER_PYTHON_LLDB_PYTHON_H +// BEGIN FIXME +// This declaration works around a clang module build failure. +// It should be deleted ASAP. +#include "llvm/Support/Error.h" +static llvm::Expected<bool> *g_fcxx_modules_workaround; +// END + #include "lldb/Host/Config.h" // Python.h needs to be included before any system headers in order to avoid diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DIERef.cpp b/lldb/source/Plugins/SymbolFile/DWARF/DIERef.cpp index 7a8ab9c9bcfd..25cb368763c1 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/DIERef.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/DIERef.cpp @@ -7,8 +7,13 @@ //===----------------------------------------------------------------------===// #include "DIERef.h" +#include "lldb/Utility/DataEncoder.h" +#include "lldb/Utility/DataExtractor.h" #include "llvm/Support/Format.h" +using namespace lldb; +using namespace lldb_private; + void llvm::format_provider<DIERef>::format(const DIERef &ref, raw_ostream &OS, StringRef Style) { if (ref.dwo_num()) @@ -16,3 +21,35 @@ void llvm::format_provider<DIERef>::format(const DIERef &ref, raw_ostream &OS, OS << (ref.section() == DIERef::DebugInfo ? "INFO" : "TYPE"); OS << "/" << format_hex_no_prefix(ref.die_offset(), 8); } + +constexpr uint32_t k_dwo_num_mask = 0x3FFFFFFF; +constexpr uint32_t k_dwo_num_valid_bitmask = (1u << 30); +constexpr uint32_t k_section_bitmask = (1u << 31); + +llvm::Optional<DIERef> DIERef::Decode(const DataExtractor &data, + lldb::offset_t *offset_ptr) { + const uint32_t bitfield_storage = data.GetU32(offset_ptr); + uint32_t dwo_num = bitfield_storage & k_dwo_num_mask; + bool dwo_num_valid = (bitfield_storage & (k_dwo_num_valid_bitmask)) != 0; + Section section = (Section)((bitfield_storage & (k_section_bitmask)) != 0); + // DIE offsets can't be zero and if we fail to decode something from data, + // it will return 0 + dw_offset_t die_offset = data.GetU32(offset_ptr); + if (die_offset == 0) + return llvm::None; + if (dwo_num_valid) + return DIERef(dwo_num, section, die_offset); + else + return DIERef(llvm::None, section, die_offset); +} + +void DIERef::Encode(DataEncoder &encoder) const { + uint32_t bitfield_storage = m_dwo_num; + if (m_dwo_num_valid) + bitfield_storage |= k_dwo_num_valid_bitmask; + if (m_section) + bitfield_storage |= k_section_bitmask; + encoder.AppendU32(bitfield_storage); + static_assert(sizeof(m_die_offset) == 4, "m_die_offset must be 4 bytes"); + encoder.AppendU32(m_die_offset); +} diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DIERef.h b/lldb/source/Plugins/SymbolFile/DWARF/DIERef.h index f7e09ee17283..23e1eec26ec3 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/DIERef.h +++ b/lldb/source/Plugins/SymbolFile/DWARF/DIERef.h @@ -54,6 +54,37 @@ public: return m_die_offset < other.m_die_offset; } + bool operator==(const DIERef &rhs) const { + return dwo_num() == rhs.dwo_num() && m_section == rhs.m_section && + m_die_offset == rhs.m_die_offset; + } + + bool operator!=(const DIERef &rhs) const { return !(*this == rhs); } + + /// Decode a serialized version of this object from data. + /// + /// \param data + /// The decoder object that references the serialized data. + /// + /// \param offset_ptr + /// A pointer that contains the offset from which the data will be decoded + /// from that gets updated as data gets decoded. + /// + /// \return + /// Returns a valid DIERef if decoding succeeded, llvm::None if there was + /// unsufficient or invalid values that were decoded. + static llvm::Optional<DIERef> Decode(const lldb_private::DataExtractor &data, + lldb::offset_t *offset_ptr); + + /// Encode this object into a data encoder object. + /// + /// This allows this object to be serialized to disk. + /// + /// \param encoder + /// A data encoder object that serialized bytes will be encoded into. + /// + void Encode(lldb_private::DataEncoder &encoder) const; + private: uint32_t m_dwo_num : 30; uint32_t m_dwo_num_valid : 1; diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp index b90f104c4d21..be555c130bfe 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp @@ -933,7 +933,7 @@ TypeSP DWARFASTParserClang::ParseSubroutine(const DWARFDIE &die, DW_TAG_value_to_name(tag), type_name_cstr); CompilerType return_clang_type; - Type *func_type = NULL; + Type *func_type = nullptr; if (attrs.type.IsValid()) func_type = dwarf->ResolveTypeUID(attrs.type.Reference(), true); @@ -1027,7 +1027,7 @@ TypeSP DWARFASTParserClang::ParseSubroutine(const DWARFDIE &die, class_opaque_type, attrs.name.GetCString(), clang_type, attrs.accessibility, attrs.is_artificial, is_variadic, attrs.is_objc_direct_call); - type_handled = objc_method_decl != NULL; + type_handled = objc_method_decl != nullptr; if (type_handled) { LinkDeclContextToDIE(objc_method_decl, die); m_ast.SetMetadataAsUserID(objc_method_decl, die.GetID()); @@ -1178,7 +1178,7 @@ TypeSP DWARFASTParserClang::ParseSubroutine(const DWARFDIE &die, is_static, attrs.is_inline, attrs.is_explicit, is_attr_used, attrs.is_artificial); - type_handled = cxx_method_decl != NULL; + type_handled = cxx_method_decl != nullptr; // Artificial methods are always handled even when we // don't create a new declaration for them. type_handled |= attrs.is_artificial; @@ -2036,7 +2036,7 @@ bool DWARFASTParserClang::ParseTemplateDIE( if (name && name[0]) template_param_infos.names.push_back(name); else - template_param_infos.names.push_back(NULL); + template_param_infos.names.push_back(nullptr); // Get the signed value for any integer or enumeration if available clang_type.IsIntegerOrEnumerationType(is_signed); @@ -3336,7 +3336,8 @@ DWARFASTParserClang::GetOwningClangModule(const DWARFDIE &die) { auto it = m_die_to_module.find(module_die.GetDIE()); if (it != m_die_to_module.end()) return it->second; - const char *name = module_die.GetAttributeValueAsString(DW_AT_name, 0); + const char *name = + module_die.GetAttributeValueAsString(DW_AT_name, nullptr); if (!name) return {}; diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFIndex.h b/lldb/source/Plugins/SymbolFile/DWARF/DWARFIndex.h index 1d3d70dfef01..c4995e721554 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFIndex.h +++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFIndex.h @@ -64,11 +64,11 @@ public: virtual void Dump(Stream &s) = 0; - StatsDuration GetIndexTime() { return m_index_time; } + StatsDuration::Duration GetIndexTime() { return m_index_time; } protected: Module &m_module; - StatsDuration m_index_time{0.0}; + StatsDuration m_index_time; /// Helper function implementing common logic for processing function dies. If /// the function given by "ref" matches search criteria given by diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.h b/lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.h index 71d4c1e6c52f..2457e8276e20 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.h +++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.h @@ -269,7 +269,7 @@ protected: ExtractUnitDIENoDwoIfNeeded(); // m_first_die_mutex is not required as m_first_die is never cleared. if (!m_first_die) - return NULL; + return nullptr; return &m_first_die; } @@ -277,7 +277,7 @@ protected: const DWARFDebugInfoEntry *DIEPtr() { ExtractDIEsIfNeeded(); if (m_die_array.empty()) - return NULL; + return nullptr; return &m_die_array[0]; } diff --git a/lldb/source/Plugins/SymbolFile/DWARF/LogChannelDWARF.cpp b/lldb/source/Plugins/SymbolFile/DWARF/LogChannelDWARF.cpp index 3f1d6677bacf..d2b8fe19db53 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/LogChannelDWARF.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/LogChannelDWARF.cpp @@ -13,18 +13,20 @@ using namespace lldb_private; static constexpr Log::Category g_categories[] = { {{"comp"}, {"log insertions of object files into DWARF debug maps"}, - DWARF_LOG_TYPE_COMPLETION}, - {{"info"}, {"log the parsing of .debug_info"}, DWARF_LOG_DEBUG_INFO}, - {{"line"}, {"log the parsing of .debug_line"}, DWARF_LOG_DEBUG_LINE}, + DWARFLog::TypeCompletion}, + {{"info"}, {"log the parsing of .debug_info"}, DWARFLog::DebugInfo}, + {{"line"}, {"log the parsing of .debug_line"}, DWARFLog::DebugLine}, {{"lookups"}, {"log any lookups that happen by name, regex, or address"}, - DWARF_LOG_LOOKUPS}, - {{"map"}, - {"log struct/unions/class type completions"}, - DWARF_LOG_DEBUG_MAP}, + DWARFLog::Lookups}, + {{"map"}, {"log struct/unions/class type completions"}, DWARFLog::DebugMap}, }; -Log::Channel LogChannelDWARF::g_channel(g_categories, DWARF_LOG_DEFAULT); +static Log::Channel g_channel(g_categories, DWARFLog::DebugInfo); + +template <> Log::Channel &lldb_private::LogChannelFor<DWARFLog>() { + return g_channel; +} void LogChannelDWARF::Initialize() { Log::Register("dwarf", g_channel); diff --git a/lldb/source/Plugins/SymbolFile/DWARF/LogChannelDWARF.h b/lldb/source/Plugins/SymbolFile/DWARF/LogChannelDWARF.h index 2fc23563ef93..8076c719e9c4 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/LogChannelDWARF.h +++ b/lldb/source/Plugins/SymbolFile/DWARF/LogChannelDWARF.h @@ -11,25 +11,32 @@ #include "lldb/Utility/Log.h" -#define DWARF_LOG_DEBUG_INFO (1u << 1) -#define DWARF_LOG_DEBUG_LINE (1u << 2) -#define DWARF_LOG_LOOKUPS (1u << 3) -#define DWARF_LOG_TYPE_COMPLETION (1u << 4) -#define DWARF_LOG_DEBUG_MAP (1u << 5) -#define DWARF_LOG_ALL (UINT32_MAX) -#define DWARF_LOG_DEFAULT (DWARF_LOG_DEBUG_INFO) - namespace lldb_private { -class LogChannelDWARF { - static Log::Channel g_channel; +enum class DWARFLog : Log::MaskType { + DebugInfo = Log::ChannelFlag<0>, + DebugLine = Log::ChannelFlag<1>, + DebugMap = Log::ChannelFlag<2>, + Lookups = Log::ChannelFlag<3>, + TypeCompletion = Log::ChannelFlag<4>, + LLVM_MARK_AS_BITMASK_ENUM(TypeCompletion) +}; +#define DWARF_LOG_DEBUG_INFO ::lldb_private::DWARFLog::DebugInfo +#define DWARF_LOG_DEBUG_LINE ::lldb_private::DWARFLog::DebugLine +#define DWARF_LOG_LOOKUPS ::lldb_private::DWARFLog::Lookups +#define DWARF_LOG_TYPE_COMPLETION ::lldb_private::DWARFLog::TypeCompletion +#define DWARF_LOG_DEBUG_MAP ::lldb_private::DWARFLog::DebugMap + +class LogChannelDWARF { public: static void Initialize(); static void Terminate(); - static Log *GetLogIfAll(uint32_t mask) { return g_channel.GetLogIfAll(mask); } - static Log *GetLogIfAny(uint32_t mask) { return g_channel.GetLogIfAny(mask); } + static Log *GetLogIfAll(DWARFLog mask) { return GetLog(mask); } + static Log *GetLogIfAny(DWARFLog mask) { return GetLog(mask); } }; -} + +template <> Log::Channel &LogChannelFor<DWARFLog>(); +} // namespace lldb_private #endif // LLDB_SOURCE_PLUGINS_SYMBOLFILE_DWARF_LOGCHANNELDWARF_H diff --git a/lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp b/lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp index ab10e9ca98f9..e15a22affcb2 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp @@ -12,9 +12,12 @@ #include "Plugins/SymbolFile/DWARF/DWARFDeclContext.h" #include "Plugins/SymbolFile/DWARF/LogChannelDWARF.h" #include "Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.h" +#include "lldb/Core/DataFileCache.h" #include "lldb/Core/Module.h" #include "lldb/Core/Progress.h" #include "lldb/Symbol/ObjectFile.h" +#include "lldb/Utility/DataEncoder.h" +#include "lldb/Utility/DataExtractor.h" #include "lldb/Utility/Stream.h" #include "lldb/Utility/Timer.h" #include "llvm/Support/FormatVariadic.h" @@ -24,17 +27,19 @@ using namespace lldb_private; using namespace lldb; void ManualDWARFIndex::Index() { - if (!m_dwarf) + if (m_indexed) return; - - SymbolFileDWARF &main_dwarf = *m_dwarf; - m_dwarf = nullptr; + m_indexed = true; ElapsedTime elapsed(m_index_time); - LLDB_SCOPED_TIMERF("%p", static_cast<void *>(&main_dwarf)); + LLDB_SCOPED_TIMERF("%p", static_cast<void *>(m_dwarf)); + if (LoadFromCache()) { + m_dwarf->SetDebugInfoIndexWasLoadedFromCache(); + return; + } - DWARFDebugInfo &main_info = main_dwarf.DebugInfo(); - SymbolFileDWARFDwo *dwp_dwarf = main_dwarf.GetDwpSymbolFile().get(); + DWARFDebugInfo &main_info = m_dwarf->DebugInfo(); + SymbolFileDWARFDwo *dwp_dwarf = m_dwarf->GetDwpSymbolFile().get(); DWARFDebugInfo *dwp_info = dwp_dwarf ? &dwp_dwarf->DebugInfo() : nullptr; std::vector<DWARFUnit *> units_to_index; @@ -125,6 +130,8 @@ void ManualDWARFIndex::Index() { pool.async(finalize_fn, &IndexSet::types); pool.async(finalize_fn, &IndexSet::namespaces); pool.wait(); + + SaveToCache(); } void ManualDWARFIndex::IndexUnit(DWARFUnit &unit, SymbolFileDWARFDwo *dwp, @@ -480,3 +487,214 @@ void ManualDWARFIndex::Dump(Stream &s) { s.Printf("\nNamespaces:\n"); m_set.namespaces.Dump(&s); } + +constexpr llvm::StringLiteral kIdentifierManualDWARFIndex("DIDX"); +// Define IDs for the different tables when encoding and decoding the +// ManualDWARFIndex NameToDIE objects so we can avoid saving any empty maps. +enum DataID { + kDataIDFunctionBasenames = 1u, + kDataIDFunctionFullnames, + kDataIDFunctionMethods, + kDataIDFunctionSelectors, + kDataIDFunctionObjcClassSelectors, + kDataIDGlobals, + kDataIDTypes, + kDataIDNamespaces, + kDataIDEnd = 255u, + +}; +constexpr uint32_t CURRENT_CACHE_VERSION = 1; + +bool ManualDWARFIndex::IndexSet::Decode(const DataExtractor &data, + lldb::offset_t *offset_ptr) { + StringTableReader strtab; + // We now decode the string table for all strings in the data cache file. + if (!strtab.Decode(data, offset_ptr)) + return false; + + llvm::StringRef identifier((const char *)data.GetData(offset_ptr, 4), 4); + if (identifier != kIdentifierManualDWARFIndex) + return false; + const uint32_t version = data.GetU32(offset_ptr); + if (version != CURRENT_CACHE_VERSION) + return false; + + bool done = false; + while (!done) { + switch (data.GetU8(offset_ptr)) { + default: + // If we got here, this is not expected, we expect the data IDs to match + // one of the values from the DataID enumeration. + return false; + case kDataIDFunctionBasenames: + if (!function_basenames.Decode(data, offset_ptr, strtab)) + return false; + break; + case kDataIDFunctionFullnames: + if (!function_fullnames.Decode(data, offset_ptr, strtab)) + return false; + break; + case kDataIDFunctionMethods: + if (!function_methods.Decode(data, offset_ptr, strtab)) + return false; + break; + case kDataIDFunctionSelectors: + if (!function_selectors.Decode(data, offset_ptr, strtab)) + return false; + break; + case kDataIDFunctionObjcClassSelectors: + if (!objc_class_selectors.Decode(data, offset_ptr, strtab)) + return false; + break; + case kDataIDGlobals: + if (!globals.Decode(data, offset_ptr, strtab)) + return false; + break; + case kDataIDTypes: + if (!types.Decode(data, offset_ptr, strtab)) + return false; + break; + case kDataIDNamespaces: + if (!namespaces.Decode(data, offset_ptr, strtab)) + return false; + break; + case kDataIDEnd: + // We got to the end of our NameToDIE encodings. + done = true; + break; + } + } + // Success! + return true; +} + +void ManualDWARFIndex::IndexSet::Encode(DataEncoder &encoder) const { + ConstStringTable strtab; + + // Encoder the DWARF index into a separate encoder first. This allows us + // gather all of the strings we willl need in "strtab" as we will need to + // write the string table out before the symbol table. + DataEncoder index_encoder(encoder.GetByteOrder(), + encoder.GetAddressByteSize()); + + index_encoder.AppendData(kIdentifierManualDWARFIndex); + // Encode the data version. + index_encoder.AppendU32(CURRENT_CACHE_VERSION); + + if (!function_basenames.IsEmpty()) { + index_encoder.AppendU8(kDataIDFunctionBasenames); + function_basenames.Encode(index_encoder, strtab); + } + if (!function_fullnames.IsEmpty()) { + index_encoder.AppendU8(kDataIDFunctionFullnames); + function_fullnames.Encode(index_encoder, strtab); + } + if (!function_methods.IsEmpty()) { + index_encoder.AppendU8(kDataIDFunctionMethods); + function_methods.Encode(index_encoder, strtab); + } + if (!function_selectors.IsEmpty()) { + index_encoder.AppendU8(kDataIDFunctionSelectors); + function_selectors.Encode(index_encoder, strtab); + } + if (!objc_class_selectors.IsEmpty()) { + index_encoder.AppendU8(kDataIDFunctionObjcClassSelectors); + objc_class_selectors.Encode(index_encoder, strtab); + } + if (!globals.IsEmpty()) { + index_encoder.AppendU8(kDataIDGlobals); + globals.Encode(index_encoder, strtab); + } + if (!types.IsEmpty()) { + index_encoder.AppendU8(kDataIDTypes); + types.Encode(index_encoder, strtab); + } + if (!namespaces.IsEmpty()) { + index_encoder.AppendU8(kDataIDNamespaces); + namespaces.Encode(index_encoder, strtab); + } + index_encoder.AppendU8(kDataIDEnd); + + // Now that all strings have been gathered, we will emit the string table. + strtab.Encode(encoder); + // Followed the the symbol table data. + encoder.AppendData(index_encoder.GetData()); +} + +bool ManualDWARFIndex::Decode(const DataExtractor &data, + lldb::offset_t *offset_ptr, + bool &signature_mismatch) { + signature_mismatch = false; + CacheSignature signature; + if (!signature.Decode(data, offset_ptr)) + return false; + if (CacheSignature(m_dwarf->GetObjectFile()) != signature) { + signature_mismatch = true; + return false; + } + IndexSet set; + if (!set.Decode(data, offset_ptr)) + return false; + m_set = std::move(set); + return true; +} + +bool ManualDWARFIndex::Encode(DataEncoder &encoder) const { + CacheSignature signature(m_dwarf->GetObjectFile()); + if (!signature.Encode(encoder)) + return false; + m_set.Encode(encoder); + return true; +} + +std::string ManualDWARFIndex::GetCacheKey() { + std::string key; + llvm::raw_string_ostream strm(key); + // DWARF Index can come from different object files for the same module. A + // module can have one object file as the main executable and might have + // another object file in a separate symbol file, or we might have a .dwo file + // that claims its module is the main executable. + ObjectFile *objfile = m_dwarf->GetObjectFile(); + strm << objfile->GetModule()->GetCacheKey() << "-dwarf-index-" + << llvm::format_hex(objfile->GetCacheHash(), 10); + return strm.str(); +} + +bool ManualDWARFIndex::LoadFromCache() { + DataFileCache *cache = Module::GetIndexCache(); + if (!cache) + return false; + ObjectFile *objfile = m_dwarf->GetObjectFile(); + if (!objfile) + return false; + std::unique_ptr<llvm::MemoryBuffer> mem_buffer_up = + cache->GetCachedData(GetCacheKey()); + if (!mem_buffer_up) + return false; + DataExtractor data(mem_buffer_up->getBufferStart(), + mem_buffer_up->getBufferSize(), + endian::InlHostByteOrder(), + objfile->GetAddressByteSize()); + bool signature_mismatch = false; + lldb::offset_t offset = 0; + const bool result = Decode(data, &offset, signature_mismatch); + if (signature_mismatch) + cache->RemoveCacheFile(GetCacheKey()); + return result; +} + +void ManualDWARFIndex::SaveToCache() { + DataFileCache *cache = Module::GetIndexCache(); + if (!cache) + return; // Caching is not enabled. + ObjectFile *objfile = m_dwarf->GetObjectFile(); + if (!objfile) + return; + DataEncoder file(endian::InlHostByteOrder(), objfile->GetAddressByteSize()); + // Encode will return false if the object file doesn't have anything to make + // a signature from. + if (Encode(file)) { + if (cache->SetCachedData(GetCacheKey(), file.GetData())) + m_dwarf->SetDebugInfoIndexWasSavedToCache(); + } +} diff --git a/lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.h b/lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.h index 36f371402b90..5c5e43de9ca6 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.h +++ b/lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.h @@ -55,7 +55,7 @@ public: void Dump(Stream &s) override; -private: + // Make IndexSet public so we can unit test the encoding and decoding logic. struct IndexSet { NameToDIE function_basenames; NameToDIE function_fullnames; @@ -65,21 +65,113 @@ private: NameToDIE globals; NameToDIE types; NameToDIE namespaces; + bool Decode(const DataExtractor &data, lldb::offset_t *offset_ptr); + void Encode(DataEncoder &encoder) const; + bool operator==(const IndexSet &rhs) const { + return function_basenames == rhs.function_basenames && + function_fullnames == rhs.function_fullnames && + function_methods == rhs.function_methods && + function_selectors == rhs.function_selectors && + objc_class_selectors == rhs.objc_class_selectors && + globals == rhs.globals && types == rhs.types && + namespaces == rhs.namespaces; + } }; + +private: void Index(); + + /// Decode a serialized version of this object from data. + /// + /// \param data + /// The decoder object that references the serialized data. + /// + /// \param offset_ptr + /// A pointer that contains the offset from which the data will be decoded + /// from that gets updated as data gets decoded. + /// + /// \param strtab + /// All strings in cache files are put into string tables for efficiency + /// and cache file size reduction. Strings are stored as uint32_t string + /// table offsets in the cache data. + bool Decode(const DataExtractor &data, lldb::offset_t *offset_ptr, + bool &signature_mismatch); + + /// Encode this object into a data encoder object. + /// + /// This allows this object to be serialized to disk. + /// + /// \param encoder + /// A data encoder object that serialized bytes will be encoded into. + /// + /// \param strtab + /// All strings in cache files are put into string tables for efficiency + /// and cache file size reduction. Strings are stored as uint32_t string + /// table offsets in the cache data. + /// + /// \return + /// True if the symbol table's object file can generate a valid signature + /// and all data for the symbol table was encoded, false otherwise. + bool Encode(DataEncoder &encoder) const; + + /// Get the cache key string for this symbol table. + /// + /// The cache key must start with the module's cache key and is followed + /// by information that indicates this key is for caching the symbol table + /// contents and should also include the has of the object file. A module can + /// be represented by an ObjectFile object for the main executable, but can + /// also have a symbol file that is from the same or a different object file. + /// This means we might have two symbol tables cached in the index cache, one + /// for the main executable and one for the symbol file. + /// + /// \return + /// The unique cache key used to save and retrieve data from the index + /// cache. + std::string GetCacheKey(); + + /// Save the symbol table data out into a cache. + /// + /// The symbol table will only be saved to a cache file if caching is enabled. + /// + /// We cache the contents of the symbol table since symbol tables in LLDB take + /// some time to initialize. This is due to the many sources for data that are + /// used to create a symbol table: + /// - standard symbol table + /// - dynamic symbol table (ELF) + /// - compressed debug info sections + /// - unwind information + /// - function pointers found in runtimes for global constructor/destructors + /// - other sources. + /// All of the above sources are combined and one symbol table results after + /// all sources have been considered. + void SaveToCache(); + + /// Load the symbol table from the index cache. + /// + /// Quickly load the finalized symbol table from the index cache. This saves + /// time when the debugger starts up. The index cache file for the symbol + /// table has the modification time set to the same time as the main module. + /// If the cache file exists and the modification times match, we will load + /// the symbol table from the serlized cache file. + /// + /// \return + /// True if the symbol table was successfully loaded from the index cache, + /// false if the symbol table wasn't cached or was out of date. + bool LoadFromCache(); + void IndexUnit(DWARFUnit &unit, SymbolFileDWARFDwo *dwp, IndexSet &set); static void IndexUnitImpl(DWARFUnit &unit, const lldb::LanguageType cu_language, IndexSet &set); - /// The DWARF file which we are indexing. Set to nullptr after the index is - /// built. + /// The DWARF file which we are indexing. SymbolFileDWARF *m_dwarf; /// Which dwarf units should we skip while building the index. llvm::DenseSet<dw_offset_t> m_units_to_avoid; IndexSet m_set; + bool m_indexed = false; }; } // namespace lldb_private diff --git a/lldb/source/Plugins/SymbolFile/DWARF/NameToDIE.cpp b/lldb/source/Plugins/SymbolFile/DWARF/NameToDIE.cpp index 493d1b4a2702..413920f33619 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/NameToDIE.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/NameToDIE.cpp @@ -8,8 +8,11 @@ #include "NameToDIE.h" #include "DWARFUnit.h" +#include "lldb/Core/DataFileCache.h" #include "lldb/Symbol/ObjectFile.h" #include "lldb/Utility/ConstString.h" +#include "lldb/Utility/DataEncoder.h" +#include "lldb/Utility/DataExtractor.h" #include "lldb/Utility/RegularExpression.h" #include "lldb/Utility/Stream.h" #include "lldb/Utility/StreamString.h" @@ -18,7 +21,7 @@ using namespace lldb; using namespace lldb_private; void NameToDIE::Finalize() { - m_map.Sort(); + m_map.Sort(std::less<DIERef>()); m_map.SizeToFit(); } @@ -87,3 +90,50 @@ void NameToDIE::Append(const NameToDIE &other) { other.m_map.GetValueAtIndexUnchecked(i)); } } + +constexpr llvm::StringLiteral kIdentifierNameToDIE("N2DI"); + +bool NameToDIE::Decode(const DataExtractor &data, lldb::offset_t *offset_ptr, + const StringTableReader &strtab) { + m_map.Clear(); + llvm::StringRef identifier((const char *)data.GetData(offset_ptr, 4), 4); + if (identifier != kIdentifierNameToDIE) + return false; + const uint32_t count = data.GetU32(offset_ptr); + for (uint32_t i = 0; i < count; ++i) { + llvm::StringRef str(strtab.Get(data.GetU32(offset_ptr))); + // No empty strings allowed in the name to DIE maps. + if (str.empty()) + return false; + if (llvm::Optional<DIERef> die_ref = DIERef::Decode(data, offset_ptr)) + m_map.Append(ConstString(str), die_ref.getValue()); + else + return false; + } + return true; +} + +void NameToDIE::Encode(DataEncoder &encoder, ConstStringTable &strtab) const { + encoder.AppendData(kIdentifierNameToDIE); + encoder.AppendU32(m_map.GetSize()); + for (const auto &entry : m_map) { + // Make sure there are no empty strings. + assert((bool)entry.cstring); + encoder.AppendU32(strtab.Add(entry.cstring)); + entry.value.Encode(encoder); + } +} + +bool NameToDIE::operator==(const NameToDIE &rhs) const { + const size_t size = m_map.GetSize(); + if (size != rhs.m_map.GetSize()) + return false; + for (size_t i = 0; i < size; ++i) { + if (m_map.GetCStringAtIndex(i) != rhs.m_map.GetCStringAtIndex(i)) + return false; + if (m_map.GetValueRefAtIndexUnchecked(i) != + rhs.m_map.GetValueRefAtIndexUnchecked(i)) + return false; + } + return true; +} diff --git a/lldb/source/Plugins/SymbolFile/DWARF/NameToDIE.h b/lldb/source/Plugins/SymbolFile/DWARF/NameToDIE.h index 994af07189f8..61df1a628ab5 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/NameToDIE.h +++ b/lldb/source/Plugins/SymbolFile/DWARF/NameToDIE.h @@ -48,6 +48,44 @@ public: const DIERef &die_ref)> const &callback) const; + /// Decode a serialized version of this object from data. + /// + /// \param data + /// The decoder object that references the serialized data. + /// + /// \param offset_ptr + /// A pointer that contains the offset from which the data will be decoded + /// from that gets updated as data gets decoded. + /// + /// \param strtab + /// All strings in cache files are put into string tables for efficiency + /// and cache file size reduction. Strings are stored as uint32_t string + /// table offsets in the cache data. + bool Decode(const lldb_private::DataExtractor &data, + lldb::offset_t *offset_ptr, + const lldb_private::StringTableReader &strtab); + + /// Encode this object into a data encoder object. + /// + /// This allows this object to be serialized to disk. + /// + /// \param encoder + /// A data encoder object that serialized bytes will be encoded into. + /// + /// \param strtab + /// All strings in cache files are put into string tables for efficiency + /// and cache file size reduction. Strings are stored as uint32_t string + /// table offsets in the cache data. + void Encode(lldb_private::DataEncoder &encoder, + lldb_private::ConstStringTable &strtab) const; + + /// Used for unit testing the encoding and decoding. + bool operator==(const NameToDIE &rhs) const; + + bool IsEmpty() const { return m_map.IsEmpty(); } + + void Clear() { m_map.Clear(); } + protected: lldb_private::UniqueCStringMap<DIERef> m_map; }; diff --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp index 8c995ef2eb2a..02d1a6a4a8be 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp @@ -2140,7 +2140,8 @@ void SymbolFileDWARF::FindGlobalVariables( llvm::StringRef basename; llvm::StringRef context; - bool name_is_mangled = (bool)Mangled(name); + bool name_is_mangled = Mangled::GetManglingScheme(name.GetStringRef()) != + Mangled::eManglingSchemeNone; if (!CPlusPlusLanguage::ExtractContextAndIdentifier(name.GetCString(), context, basename)) @@ -4085,8 +4086,8 @@ LanguageType SymbolFileDWARF::GetLanguageFamily(DWARFUnit &unit) { return LanguageTypeFromDWARF(lang); } -StatsDuration SymbolFileDWARF::GetDebugInfoIndexTime() { +StatsDuration::Duration SymbolFileDWARF::GetDebugInfoIndexTime() { if (m_index) return m_index->GetIndexTime(); - return StatsDuration(0.0); + return {}; } diff --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h index e81ce28cb86e..f84a78620e17 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h +++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h @@ -319,10 +319,10 @@ public: /// Same as GetLanguage() but reports all C++ versions as C++ (no version). static lldb::LanguageType GetLanguageFamily(DWARFUnit &unit); - lldb_private::StatsDuration GetDebugInfoParseTime() override { + lldb_private::StatsDuration::Duration GetDebugInfoParseTime() override { return m_parse_time; } - lldb_private::StatsDuration GetDebugInfoIndexTime() override; + lldb_private::StatsDuration::Duration GetDebugInfoIndexTime() override; lldb_private::StatsDuration &GetDebugInfoParseTimeRef() { return m_parse_time; @@ -559,7 +559,7 @@ protected: /// Try to filter out this debug info by comparing it to the lowest code /// address in the module. lldb::addr_t m_first_code_address = LLDB_INVALID_ADDRESS; - lldb_private::StatsDuration m_parse_time{0.0}; + lldb_private::StatsDuration m_parse_time; }; #endif // LLDB_SOURCE_PLUGINS_SYMBOLFILE_DWARF_SYMBOLFILEDWARF_H diff --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp index 2491f6af8c19..6ee189e04250 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp @@ -1447,8 +1447,8 @@ uint64_t SymbolFileDWARFDebugMap::GetDebugInfoSize() { return debug_info_size; } -StatsDuration SymbolFileDWARFDebugMap::GetDebugInfoParseTime() { - StatsDuration elapsed(0.0); +StatsDuration::Duration SymbolFileDWARFDebugMap::GetDebugInfoParseTime() { + StatsDuration::Duration elapsed(0.0); ForEachSymbolFile([&](SymbolFileDWARF *oso_dwarf) -> bool { ObjectFile *oso_objfile = oso_dwarf->GetObjectFile(); if (oso_objfile) { @@ -1464,8 +1464,8 @@ StatsDuration SymbolFileDWARFDebugMap::GetDebugInfoParseTime() { return elapsed; } -StatsDuration SymbolFileDWARFDebugMap::GetDebugInfoIndexTime() { - StatsDuration elapsed(0.0); +StatsDuration::Duration SymbolFileDWARFDebugMap::GetDebugInfoIndexTime() { + StatsDuration::Duration elapsed(0.0); ForEachSymbolFile([&](SymbolFileDWARF *oso_dwarf) -> bool { ObjectFile *oso_objfile = oso_dwarf->GetObjectFile(); if (oso_objfile) { diff --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h index 74f32442de2f..2a6232a501b4 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h +++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h @@ -143,8 +143,8 @@ public: llvm::StringRef GetPluginName() override { return GetPluginNameStatic(); } uint64_t GetDebugInfoSize() override; - lldb_private::StatsDuration GetDebugInfoParseTime() override; - lldb_private::StatsDuration GetDebugInfoIndexTime() override; + lldb_private::StatsDuration::Duration GetDebugInfoParseTime() override; + lldb_private::StatsDuration::Duration GetDebugInfoIndexTime() override; protected: enum { kHaveInitializedOSOs = (1 << 0), kNumFlags }; diff --git a/lldb/source/Plugins/SymbolFile/NativePDB/CompileUnitIndex.cpp b/lldb/source/Plugins/SymbolFile/NativePDB/CompileUnitIndex.cpp index 9f09c0accc87..d8f737612c25 100644 --- a/lldb/source/Plugins/SymbolFile/NativePDB/CompileUnitIndex.cpp +++ b/lldb/source/Plugins/SymbolFile/NativePDB/CompileUnitIndex.cpp @@ -106,6 +106,24 @@ static void ParseExtendedInfo(PdbIndex &index, CompilandIndexItem &item) { } } +static void ParseInlineeLineTableForCompileUnit(CompilandIndexItem &item) { + for (const auto &ss : item.m_debug_stream.getSubsectionsArray()) { + if (ss.kind() != DebugSubsectionKind::InlineeLines) + continue; + + DebugInlineeLinesSubsectionRef inlinee_lines; + llvm::BinaryStreamReader reader(ss.getRecordData()); + if (llvm::Error error = inlinee_lines.initialize(reader)) { + consumeError(std::move(error)); + continue; + } + + for (const InlineeSourceLine &Line : inlinee_lines) { + item.m_inline_map[Line.Header->Inlinee] = Line; + } + } +} + CompilandIndexItem::CompilandIndexItem( PdbCompilandId id, llvm::pdb::ModuleDebugStreamRef debug_stream, llvm::pdb::DbiModuleDescriptor descriptor) @@ -142,6 +160,7 @@ CompilandIndexItem &CompileUnitIndex::GetOrCreateCompiland(uint16_t modi) { cci = std::make_unique<CompilandIndexItem>( PdbCompilandId{modi}, std::move(debug_stream), std::move(descriptor)); ParseExtendedInfo(m_index, *cci); + ParseInlineeLineTableForCompileUnit(*cci); cci->m_strings.initialize(debug_stream.getSubsectionsArray()); PDBStringTable &strings = cantFail(m_index.pdb().getStringTable()); diff --git a/lldb/source/Plugins/SymbolFile/NativePDB/CompileUnitIndex.h b/lldb/source/Plugins/SymbolFile/NativePDB/CompileUnitIndex.h index 088de970cbf3..4ad27de98695 100644 --- a/lldb/source/Plugins/SymbolFile/NativePDB/CompileUnitIndex.h +++ b/lldb/source/Plugins/SymbolFile/NativePDB/CompileUnitIndex.h @@ -9,10 +9,12 @@ #ifndef LLDB_SOURCE_PLUGINS_SYMBOLFILE_NATIVEPDB_COMPILEUNITINDEX_H #define LLDB_SOURCE_PLUGINS_SYMBOLFILE_NATIVEPDB_COMPILEUNITINDEX_H +#include "lldb/Utility/RangeMap.h" #include "llvm/ADT/DenseMap.h" #include "llvm/ADT/DenseSet.h" #include "llvm/ADT/IntervalMap.h" #include "llvm/ADT/Optional.h" +#include "llvm/DebugInfo/CodeView/DebugInlineeLinesSubsection.h" #include "llvm/DebugInfo/CodeView/StringsAndChecksums.h" #include "llvm/DebugInfo/CodeView/SymbolRecord.h" #include "llvm/DebugInfo/CodeView/TypeIndex.h" @@ -69,6 +71,17 @@ struct CompilandIndexItem { // command line, etc. This usually contains exactly 5 items which // are references to other strings. llvm::SmallVector<llvm::codeview::TypeIndex, 5> m_build_info; + + // Inlinee lines table in this compile unit. + std::map<llvm::codeview::TypeIndex, llvm::codeview::InlineeSourceLine> + m_inline_map; + + // It's the line table parsed from DEBUG_S_LINES sections, mapping the file + // address range to file index and source line number. + using GlobalLineTable = + lldb_private::RangeDataVector<lldb::addr_t, uint32_t, + std::pair<uint32_t, uint32_t>>; + GlobalLineTable m_global_line_table; }; /// Indexes information about all compile units. This is really just a map of diff --git a/lldb/source/Plugins/SymbolFile/NativePDB/PdbAstBuilder.cpp b/lldb/source/Plugins/SymbolFile/NativePDB/PdbAstBuilder.cpp index 9473befa6cc3..dc0969a0ce7c 100644 --- a/lldb/source/Plugins/SymbolFile/NativePDB/PdbAstBuilder.cpp +++ b/lldb/source/Plugins/SymbolFile/NativePDB/PdbAstBuilder.cpp @@ -1081,7 +1081,7 @@ PdbAstBuilder::GetOrCreateFunctionDecl(PdbCompilandSymId func_id) { clang::FunctionDecl *function_decl = nullptr; if (parent->isRecord()) { - clang::QualType parent_qt = llvm::dyn_cast<clang::TypeDecl>(parent) + clang::QualType parent_qt = llvm::cast<clang::TypeDecl>(parent) ->getTypeForDecl() ->getCanonicalTypeInternal(); lldb::opaque_compiler_type_t parent_opaque_ty = @@ -1318,7 +1318,7 @@ void PdbAstBuilder::ParseAllNamespacesPlusChildrenOf( if (!context->isNamespace()) continue; - clang::NamespaceDecl *ns = llvm::dyn_cast<clang::NamespaceDecl>(context); + clang::NamespaceDecl *ns = llvm::cast<clang::NamespaceDecl>(context); std::string actual_ns = ns->getQualifiedNameAsString(); if (llvm::StringRef(actual_ns).startswith(*parent)) { clang::QualType qt = GetOrCreateType(tid); diff --git a/lldb/source/Plugins/SymbolFile/NativePDB/PdbIndex.h b/lldb/source/Plugins/SymbolFile/NativePDB/PdbIndex.h index 1b382e5263c1..edbdd9ee290b 100644 --- a/lldb/source/Plugins/SymbolFile/NativePDB/PdbIndex.h +++ b/lldb/source/Plugins/SymbolFile/NativePDB/PdbIndex.h @@ -25,7 +25,6 @@ namespace llvm { namespace pdb { class DbiStream; class TpiStream; -class TpiStream; class InfoStream; class PublicsStream; class GlobalsStream; diff --git a/lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp b/lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp index e859b1d5a86c..a035a791f868 100644 --- a/lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp +++ b/lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp @@ -330,31 +330,65 @@ uint32_t SymbolFileNativePDB::CalculateNumCompileUnits() { Block &SymbolFileNativePDB::CreateBlock(PdbCompilandSymId block_id) { CompilandIndexItem *cii = m_index->compilands().GetCompiland(block_id.modi); CVSymbol sym = cii->m_debug_stream.readSymbolAtOffset(block_id.offset); - - if (sym.kind() == S_GPROC32 || sym.kind() == S_LPROC32) { - // This is a function. It must be global. Creating the Function entry for - // it automatically creates a block for it. - CompUnitSP comp_unit = GetOrCreateCompileUnit(*cii); - return GetOrCreateFunction(block_id, *comp_unit)->GetBlock(false); - } - - lldbassert(sym.kind() == S_BLOCK32); - - // This is a block. Its parent is either a function or another block. In - // either case, its parent can be viewed as a block (e.g. a function contains - // 1 big block. So just get the parent block and add this block to it. - BlockSym block(static_cast<SymbolRecordKind>(sym.kind())); - cantFail(SymbolDeserializer::deserializeAs<BlockSym>(sym, block)); - lldbassert(block.Parent != 0); - PdbCompilandSymId parent_id(block_id.modi, block.Parent); - Block &parent_block = GetOrCreateBlock(parent_id); + CompUnitSP comp_unit = GetOrCreateCompileUnit(*cii); lldb::user_id_t opaque_block_uid = toOpaqueUid(block_id); BlockSP child_block = std::make_shared<Block>(opaque_block_uid); - parent_block.AddChild(child_block); - m_ast->GetOrCreateBlockDecl(block_id); + switch (sym.kind()) { + case S_GPROC32: + case S_LPROC32: { + // This is a function. It must be global. Creating the Function entry + // for it automatically creates a block for it. + FunctionSP func = GetOrCreateFunction(block_id, *comp_unit); + Block &block = func->GetBlock(false); + if (block.GetNumRanges() == 0) + block.AddRange(Block::Range(0, func->GetAddressRange().GetByteSize())); + return block; + } + case S_BLOCK32: { + // This is a block. Its parent is either a function or another block. In + // either case, its parent can be viewed as a block (e.g. a function + // contains 1 big block. So just get the parent block and add this block + // to it. + BlockSym block(static_cast<SymbolRecordKind>(sym.kind())); + cantFail(SymbolDeserializer::deserializeAs<BlockSym>(sym, block)); + lldbassert(block.Parent != 0); + PdbCompilandSymId parent_id(block_id.modi, block.Parent); + Block &parent_block = GetOrCreateBlock(parent_id); + parent_block.AddChild(child_block); + m_ast->GetOrCreateBlockDecl(block_id); + m_blocks.insert({opaque_block_uid, child_block}); + break; + } + case S_INLINESITE: { + // This ensures line table is parsed first so we have inline sites info. + comp_unit->GetLineTable(); + + std::shared_ptr<InlineSite> inline_site = m_inline_sites[opaque_block_uid]; + Block &parent_block = GetOrCreateBlock(inline_site->parent_id); + parent_block.AddChild(child_block); + + // Copy ranges from InlineSite to Block. + for (size_t i = 0; i < inline_site->ranges.GetSize(); ++i) { + auto *entry = inline_site->ranges.GetEntryAtIndex(i); + child_block->AddRange( + Block::Range(entry->GetRangeBase(), entry->GetByteSize())); + } + child_block->FinalizeRanges(); + + // Get the inlined function callsite info. + Declaration &decl = inline_site->inline_function_info->GetDeclaration(); + Declaration &callsite = inline_site->inline_function_info->GetCallSite(); + child_block->SetInlinedFunctionInfo( + inline_site->inline_function_info->GetName().GetCString(), nullptr, + &decl, &callsite); + m_blocks.insert({opaque_block_uid, child_block}); + break; + } + default: + lldbassert(false && "Symbol is not a block!"); + } - m_blocks.insert({opaque_block_uid, child_block}); return *child_block; } @@ -971,16 +1005,22 @@ uint32_t SymbolFileNativePDB::ResolveSymbolContext( continue; if (type == PDB_SymType::Function) { sc.function = GetOrCreateFunction(csid, *sc.comp_unit).get(); - sc.block = sc.GetFunctionBlock(); + Block &block = sc.function->GetBlock(true); + addr_t func_base = + sc.function->GetAddressRange().GetBaseAddress().GetFileAddress(); + addr_t offset = file_addr - func_base; + sc.block = block.FindInnermostBlockByOffset(offset); } if (type == PDB_SymType::Block) { sc.block = &GetOrCreateBlock(csid); sc.function = sc.block->CalculateSymbolContextFunction(); } - resolved_flags |= eSymbolContextFunction; - resolved_flags |= eSymbolContextBlock; - break; + if (sc.function) + resolved_flags |= eSymbolContextFunction; + if (sc.block) + resolved_flags |= eSymbolContextBlock; + break; } } @@ -998,43 +1038,24 @@ uint32_t SymbolFileNativePDB::ResolveSymbolContext( uint32_t SymbolFileNativePDB::ResolveSymbolContext( const SourceLocationSpec &src_location_spec, lldb::SymbolContextItem resolve_scope, SymbolContextList &sc_list) { - return 0; -} - -static void AppendLineEntryToSequence(LineTable &table, LineSequence &sequence, - const CompilandIndexItem &cci, - lldb::addr_t base_addr, - uint32_t file_number, - const LineFragmentHeader &block, - const LineNumberEntry &cur) { - LineInfo cur_info(cur.Flags); - - if (cur_info.isAlwaysStepInto() || cur_info.isNeverStepInto()) - return; - - uint64_t addr = base_addr + cur.Offset; - - bool is_statement = cur_info.isStatement(); - bool is_prologue = IsFunctionPrologue(cci, addr); - bool is_epilogue = IsFunctionEpilogue(cci, addr); - - uint32_t lno = cur_info.getStartLine(); - - table.AppendLineEntryToSequence(&sequence, addr, lno, 0, file_number, - is_statement, false, is_prologue, is_epilogue, - false); -} + std::lock_guard<std::recursive_mutex> guard(GetModuleMutex()); + const uint32_t prev_size = sc_list.GetSize(); + if (resolve_scope & eSymbolContextCompUnit) { + for (uint32_t cu_idx = 0, num_cus = GetNumCompileUnits(); cu_idx < num_cus; + ++cu_idx) { + CompileUnit *cu = ParseCompileUnitAtIndex(cu_idx).get(); + if (!cu) + continue; -static void TerminateLineSequence(LineTable &table, - const LineFragmentHeader &block, - lldb::addr_t base_addr, uint32_t file_number, - uint32_t last_line, - std::unique_ptr<LineSequence> seq) { - // The end is always a terminal entry, so insert it regardless. - table.AppendLineEntryToSequence(seq.get(), base_addr + block.CodeSize, - last_line, 0, file_number, false, false, - false, false, true); - table.InsertSequence(seq.get()); + bool file_spec_matches_cu_file_spec = FileSpec::Match( + src_location_spec.GetFileSpec(), cu->GetPrimaryFile()); + if (file_spec_matches_cu_file_spec) { + cu->ResolveSymbolContext(src_location_spec, resolve_scope, sc_list); + break; + } + } + } + return sc_list.GetSize() - prev_size; } bool SymbolFileNativePDB::ParseLineTable(CompileUnit &comp_unit) { @@ -1045,16 +1066,21 @@ bool SymbolFileNativePDB::ParseLineTable(CompileUnit &comp_unit) { std::lock_guard<std::recursive_mutex> guard(GetModuleMutex()); PdbSymUid cu_id(comp_unit.GetID()); lldbassert(cu_id.kind() == PdbSymUidKind::Compiland); - CompilandIndexItem *cci = - m_index->compilands().GetCompiland(cu_id.asCompiland().modi); - lldbassert(cci); - auto line_table = std::make_unique<LineTable>(&comp_unit); + uint16_t modi = cu_id.asCompiland().modi; + CompilandIndexItem *cii = m_index->compilands().GetCompiland(modi); + lldbassert(cii); + + // Parse DEBUG_S_LINES subsections first, then parse all S_INLINESITE records + // in this CU. Add line entries into the set first so that if there are line + // entries with same addres, the later is always more accurate than the + // former. + std::set<LineTable::Entry, LineTableEntryComparator> line_set; // This is basically a copy of the .debug$S subsections from all original COFF // object files merged together with address relocations applied. We are // looking for all DEBUG_S_LINES subsections. for (const DebugSubsectionRecord &dssr : - cci->m_debug_stream.getSubsectionsArray()) { + cii->m_debug_stream.getSubsectionsArray()) { if (dssr.kind() != DebugSubsectionKind::Lines) continue; @@ -1069,42 +1095,111 @@ bool SymbolFileNativePDB::ParseLineTable(CompileUnit &comp_unit) { uint64_t virtual_addr = m_index->MakeVirtualAddress(lfh->RelocSegment, lfh->RelocOffset); - const auto &checksums = cci->m_strings.checksums().getArray(); - const auto &strings = cci->m_strings.strings(); for (const LineColumnEntry &group : lines) { - // Indices in this structure are actually offsets of records in the - // DEBUG_S_FILECHECKSUMS subsection. Those entries then have an index - // into the global PDB string table. - auto iter = checksums.at(group.NameIndex); - if (iter == checksums.end()) + llvm::Expected<uint32_t> file_index_or_err = + GetFileIndex(*cii, group.NameIndex); + if (!file_index_or_err) continue; + uint32_t file_index = file_index_or_err.get(); + lldbassert(!group.LineNumbers.empty()); + CompilandIndexItem::GlobalLineTable::Entry line_entry( + LLDB_INVALID_ADDRESS, 0); + for (const LineNumberEntry &entry : group.LineNumbers) { + LineInfo cur_info(entry.Flags); - llvm::Expected<llvm::StringRef> efn = - strings.getString(iter->FileNameOffset); - if (!efn) { - llvm::consumeError(efn.takeError()); - continue; - } + if (cur_info.isAlwaysStepInto() || cur_info.isNeverStepInto()) + continue; - // LLDB wants the index of the file in the list of support files. - auto fn_iter = llvm::find(cci->m_file_list, *efn); - lldbassert(fn_iter != cci->m_file_list.end()); - uint32_t file_index = std::distance(cci->m_file_list.begin(), fn_iter); + uint64_t addr = virtual_addr + entry.Offset; - std::unique_ptr<LineSequence> sequence( - line_table->CreateLineSequenceContainer()); - lldbassert(!group.LineNumbers.empty()); + bool is_statement = cur_info.isStatement(); + bool is_prologue = IsFunctionPrologue(*cii, addr); + bool is_epilogue = IsFunctionEpilogue(*cii, addr); - for (const LineNumberEntry &entry : group.LineNumbers) { - AppendLineEntryToSequence(*line_table, *sequence, *cci, virtual_addr, - file_index, *lfh, entry); + uint32_t lno = cur_info.getStartLine(); + + line_set.emplace(addr, lno, 0, file_index, is_statement, false, + is_prologue, is_epilogue, false); + + if (line_entry.GetRangeBase() != LLDB_INVALID_ADDRESS) { + line_entry.SetRangeEnd(addr); + cii->m_global_line_table.Append(line_entry); + } + line_entry.SetRangeBase(addr); + line_entry.data = {file_index, lno}; } LineInfo last_line(group.LineNumbers.back().Flags); - TerminateLineSequence(*line_table, *lfh, virtual_addr, file_index, - last_line.getEndLine(), std::move(sequence)); + line_set.emplace(virtual_addr + lfh->CodeSize, last_line.getEndLine(), 0, + file_index, false, false, false, false, true); + + if (line_entry.GetRangeBase() != LLDB_INVALID_ADDRESS) { + line_entry.SetRangeEnd(virtual_addr + lfh->CodeSize); + cii->m_global_line_table.Append(line_entry); + } } } + cii->m_global_line_table.Sort(); + + // Parse all S_INLINESITE in this CU. + const CVSymbolArray &syms = cii->m_debug_stream.getSymbolArray(); + for (auto iter = syms.begin(); iter != syms.end();) { + if (iter->kind() != S_LPROC32 && iter->kind() != S_GPROC32) { + ++iter; + continue; + } + + uint32_t record_offset = iter.offset(); + CVSymbol func_record = + cii->m_debug_stream.readSymbolAtOffset(record_offset); + SegmentOffsetLength sol = GetSegmentOffsetAndLength(func_record); + addr_t file_vm_addr = m_index->MakeVirtualAddress(sol.so); + AddressRange func_range(file_vm_addr, sol.length, + comp_unit.GetModule()->GetSectionList()); + Address func_base = func_range.GetBaseAddress(); + PdbCompilandSymId func_id{modi, record_offset}; + + // Iterate all S_INLINESITEs in the function. + auto parse_inline_sites = [&](SymbolKind kind, PdbCompilandSymId id) { + if (kind != S_INLINESITE) + return false; + + ParseInlineSite(id, func_base); + + for (const auto &line_entry : + m_inline_sites[toOpaqueUid(id)]->line_entries) { + // If line_entry is not terminal entry, remove previous line entry at + // the same address and insert new one. Terminal entry inside an inline + // site might not be terminal entry for its parent. + if (!line_entry.is_terminal_entry) + line_set.erase(line_entry); + line_set.insert(line_entry); + } + // No longer useful after adding to line_set. + m_inline_sites[toOpaqueUid(id)]->line_entries.clear(); + return true; + }; + ParseSymbolArrayInScope(func_id, parse_inline_sites); + // Jump to the end of the function record. + iter = syms.at(getScopeEndOffset(func_record)); + } + + cii->m_global_line_table.Clear(); + + // Add line entries in line_set to line_table. + auto line_table = std::make_unique<LineTable>(&comp_unit); + std::unique_ptr<LineSequence> sequence( + line_table->CreateLineSequenceContainer()); + for (const auto &line_entry : line_set) { + line_table->AppendLineEntryToSequence( + sequence.get(), line_entry.file_addr, line_entry.line, + line_entry.column, line_entry.file_idx, + line_entry.is_start_of_statement, line_entry.is_start_of_basic_block, + line_entry.is_prologue_end, line_entry.is_epilogue_begin, + line_entry.is_terminal_entry); + } + line_table->InsertSequence(sequence.get()); + if (line_table->GetSize() == 0) return false; @@ -1117,6 +1212,33 @@ bool SymbolFileNativePDB::ParseDebugMacros(CompileUnit &comp_unit) { return false; } +llvm::Expected<uint32_t> +SymbolFileNativePDB::GetFileIndex(const CompilandIndexItem &cii, + uint32_t file_id) { + auto index_iter = m_file_indexes.find(file_id); + if (index_iter != m_file_indexes.end()) + return index_iter->getSecond(); + const auto &checksums = cii.m_strings.checksums().getArray(); + const auto &strings = cii.m_strings.strings(); + // Indices in this structure are actually offsets of records in the + // DEBUG_S_FILECHECKSUMS subsection. Those entries then have an index + // into the global PDB string table. + auto iter = checksums.at(file_id); + if (iter == checksums.end()) + return llvm::make_error<RawError>(raw_error_code::no_entry); + + llvm::Expected<llvm::StringRef> efn = strings.getString(iter->FileNameOffset); + if (!efn) { + return efn.takeError(); + } + + // LLDB wants the index of the file in the list of support files. + auto fn_iter = llvm::find(cii.m_file_list, *efn); + lldbassert(fn_iter != cii.m_file_list.end()); + m_file_indexes[file_id] = std::distance(cii.m_file_list.begin(), fn_iter); + return m_file_indexes[file_id]; +} + bool SymbolFileNativePDB::ParseSupportFiles(CompileUnit &comp_unit, FileSpecList &support_files) { std::lock_guard<std::recursive_mutex> guard(GetModuleMutex()); @@ -1141,11 +1263,223 @@ bool SymbolFileNativePDB::ParseImportedModules( return false; } +void SymbolFileNativePDB::ParseInlineSite(PdbCompilandSymId id, + Address func_addr) { + lldb::user_id_t opaque_uid = toOpaqueUid(id); + if (m_inline_sites.find(opaque_uid) != m_inline_sites.end()) + return; + + addr_t func_base = func_addr.GetFileAddress(); + CompilandIndexItem *cii = m_index->compilands().GetCompiland(id.modi); + CVSymbol sym = cii->m_debug_stream.readSymbolAtOffset(id.offset); + CompUnitSP comp_unit = GetOrCreateCompileUnit(*cii); + + InlineSiteSym inline_site(static_cast<SymbolRecordKind>(sym.kind())); + cantFail(SymbolDeserializer::deserializeAs<InlineSiteSym>(sym, inline_site)); + PdbCompilandSymId parent_id(id.modi, inline_site.Parent); + + std::shared_ptr<InlineSite> inline_site_sp = + std::make_shared<InlineSite>(parent_id); + + // Get the inlined function declaration info. + auto iter = cii->m_inline_map.find(inline_site.Inlinee); + if (iter == cii->m_inline_map.end()) + return; + InlineeSourceLine inlinee_line = iter->second; + + const FileSpecList &files = comp_unit->GetSupportFiles(); + FileSpec decl_file; + llvm::Expected<uint32_t> file_index_or_err = + GetFileIndex(*cii, inlinee_line.Header->FileID); + if (!file_index_or_err) + return; + uint32_t decl_file_idx = file_index_or_err.get(); + decl_file = files.GetFileSpecAtIndex(decl_file_idx); + uint32_t decl_line = inlinee_line.Header->SourceLineNum; + std::unique_ptr<Declaration> decl_up = + std::make_unique<Declaration>(decl_file, decl_line); + + // Parse range and line info. + uint32_t code_offset = 0; + int32_t line_offset = 0; + bool has_base = false; + bool is_new_line_offset = false; + + bool is_start_of_statement = false; + // The first instruction is the prologue end. + bool is_prologue_end = true; + + auto change_code_offset = [&](uint32_t code_delta) { + if (has_base) { + inline_site_sp->ranges.Append(RangeSourceLineVector::Entry( + code_offset, code_delta, decl_line + line_offset)); + is_prologue_end = false; + is_start_of_statement = false; + } else { + is_start_of_statement = true; + } + has_base = true; + code_offset += code_delta; + + if (is_new_line_offset) { + LineTable::Entry line_entry(func_base + code_offset, + decl_line + line_offset, 0, decl_file_idx, + true, false, is_prologue_end, false, false); + inline_site_sp->line_entries.push_back(line_entry); + is_new_line_offset = false; + } + }; + auto change_code_length = [&](uint32_t length) { + inline_site_sp->ranges.Append(RangeSourceLineVector::Entry( + code_offset, length, decl_line + line_offset)); + has_base = false; + + LineTable::Entry end_line_entry(func_base + code_offset + length, + decl_line + line_offset, 0, decl_file_idx, + false, false, false, false, true); + inline_site_sp->line_entries.push_back(end_line_entry); + }; + auto change_line_offset = [&](int32_t line_delta) { + line_offset += line_delta; + if (has_base) { + LineTable::Entry line_entry( + func_base + code_offset, decl_line + line_offset, 0, decl_file_idx, + is_start_of_statement, false, is_prologue_end, false, false); + inline_site_sp->line_entries.push_back(line_entry); + } else { + // Add line entry in next call to change_code_offset. + is_new_line_offset = true; + } + }; + + for (auto &annot : inline_site.annotations()) { + switch (annot.OpCode) { + case BinaryAnnotationsOpCode::CodeOffset: + case BinaryAnnotationsOpCode::ChangeCodeOffset: + case BinaryAnnotationsOpCode::ChangeCodeOffsetBase: + change_code_offset(annot.U1); + break; + case BinaryAnnotationsOpCode::ChangeLineOffset: + change_line_offset(annot.S1); + break; + case BinaryAnnotationsOpCode::ChangeCodeLength: + change_code_length(annot.U1); + code_offset += annot.U1; + break; + case BinaryAnnotationsOpCode::ChangeCodeOffsetAndLineOffset: + change_code_offset(annot.U1); + change_line_offset(annot.S1); + break; + case BinaryAnnotationsOpCode::ChangeCodeLengthAndCodeOffset: + change_code_offset(annot.U2); + change_code_length(annot.U1); + break; + default: + break; + } + } + + inline_site_sp->ranges.Sort(); + inline_site_sp->ranges.CombineConsecutiveEntriesWithEqualData(); + + // Get the inlined function callsite info. + std::unique_ptr<Declaration> callsite_up; + if (!inline_site_sp->ranges.IsEmpty()) { + auto *entry = inline_site_sp->ranges.GetEntryAtIndex(0); + addr_t base_offset = entry->GetRangeBase(); + if (cii->m_debug_stream.readSymbolAtOffset(parent_id.offset).kind() == + S_INLINESITE) { + // Its parent is another inline site, lookup parent site's range vector + // for callsite line. + ParseInlineSite(parent_id, func_base); + std::shared_ptr<InlineSite> parent_site = + m_inline_sites[toOpaqueUid(parent_id)]; + FileSpec &parent_decl_file = + parent_site->inline_function_info->GetDeclaration().GetFile(); + if (auto *parent_entry = + parent_site->ranges.FindEntryThatContains(base_offset)) { + callsite_up = + std::make_unique<Declaration>(parent_decl_file, parent_entry->data); + } + } else { + // Its parent is a function, lookup global line table for callsite. + if (auto *entry = cii->m_global_line_table.FindEntryThatContains( + func_base + base_offset)) { + const FileSpec &callsite_file = + files.GetFileSpecAtIndex(entry->data.first); + callsite_up = + std::make_unique<Declaration>(callsite_file, entry->data.second); + } + } + } + + // Get the inlined function name. + CVType inlinee_cvt = m_index->ipi().getType(inline_site.Inlinee); + std::string inlinee_name; + if (inlinee_cvt.kind() == LF_MFUNC_ID) { + MemberFuncIdRecord mfr; + cantFail( + TypeDeserializer::deserializeAs<MemberFuncIdRecord>(inlinee_cvt, mfr)); + LazyRandomTypeCollection &types = m_index->tpi().typeCollection(); + inlinee_name.append(std::string(types.getTypeName(mfr.ClassType))); + inlinee_name.append("::"); + inlinee_name.append(mfr.getName().str()); + } else if (inlinee_cvt.kind() == LF_FUNC_ID) { + FuncIdRecord fir; + cantFail(TypeDeserializer::deserializeAs<FuncIdRecord>(inlinee_cvt, fir)); + TypeIndex parent_idx = fir.getParentScope(); + if (!parent_idx.isNoneType()) { + LazyRandomTypeCollection &ids = m_index->ipi().typeCollection(); + inlinee_name.append(std::string(ids.getTypeName(parent_idx))); + inlinee_name.append("::"); + } + inlinee_name.append(fir.getName().str()); + } + inline_site_sp->inline_function_info = std::make_shared<InlineFunctionInfo>( + inlinee_name.c_str(), llvm::StringRef(), decl_up.get(), + callsite_up.get()); + + m_inline_sites[opaque_uid] = inline_site_sp; +} + size_t SymbolFileNativePDB::ParseBlocksRecursive(Function &func) { std::lock_guard<std::recursive_mutex> guard(GetModuleMutex()); - GetOrCreateBlock(PdbSymUid(func.GetID()).asCompilandSym()); - // FIXME: Parse child blocks - return 1; + PdbCompilandSymId func_id = PdbSymUid(func.GetID()).asCompilandSym(); + // After we iterate through inline sites inside the function, we already get + // all the info needed, removing from the map to save memory. + std::set<uint64_t> remove_uids; + auto parse_blocks = [&](SymbolKind kind, PdbCompilandSymId id) { + if (kind == S_GPROC32 || kind == S_LPROC32 || kind == S_BLOCK32 || + kind == S_INLINESITE) { + GetOrCreateBlock(id); + if (kind == S_INLINESITE) + remove_uids.insert(toOpaqueUid(id)); + return true; + } + return false; + }; + size_t count = ParseSymbolArrayInScope(func_id, parse_blocks); + for (uint64_t uid : remove_uids) { + m_inline_sites.erase(uid); + } + return count; +} + +size_t SymbolFileNativePDB::ParseSymbolArrayInScope( + PdbCompilandSymId parent_id, + llvm::function_ref<bool(SymbolKind, PdbCompilandSymId)> fn) { + CompilandIndexItem *cii = m_index->compilands().GetCompiland(parent_id.modi); + CVSymbolArray syms = + cii->m_debug_stream.getSymbolArrayForScope(parent_id.offset); + + size_t count = 1; + for (auto iter = syms.begin(); iter != syms.end(); ++iter) { + PdbCompilandSymId child_id(parent_id.modi, iter.offset()); + if (fn(iter->kind(), child_id)) + ++count; + } + + return count; } void SymbolFileNativePDB::DumpClangAST(Stream &s) { m_ast->Dump(s); } @@ -1396,6 +1730,9 @@ size_t SymbolFileNativePDB::ParseVariablesForBlock(PdbCompilandSymId block_id) { } case S_BLOCK32: break; + case S_INLINESITE: + // TODO: Handle inline site case. + return 0; default: lldbassert(false && "Symbol is not a block!"); return 0; diff --git a/lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.h b/lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.h index 56a5ec0a464d..f1b6e34ca346 100644 --- a/lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.h +++ b/lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.h @@ -9,6 +9,7 @@ #ifndef LLDB_SOURCE_PLUGINS_SYMBOLFILE_NATIVEPDB_SYMBOLFILENATIVEPDB_H #define LLDB_SOURCE_PLUGINS_SYMBOLFILE_NATIVEPDB_SYMBOLFILENATIVEPDB_H +#include "lldb/Symbol/LineTable.h" #include "lldb/Symbol/SymbolFile.h" #include "llvm/ADT/DenseMap.h" @@ -161,6 +162,25 @@ public: void DumpClangAST(Stream &s) override; private: + struct LineTableEntryComparator { + bool operator()(const lldb_private::LineTable::Entry &lhs, + const lldb_private::LineTable::Entry &rhs) const { + return lhs.file_addr < rhs.file_addr; + } + }; + + // From address range relative to function base to source line number. + using RangeSourceLineVector = + lldb_private::RangeDataVector<uint32_t, uint32_t, int32_t>; + // InlineSite contains information in a S_INLINESITE record. + struct InlineSite { + PdbCompilandSymId parent_id; + std::shared_ptr<InlineFunctionInfo> inline_function_info; + RangeSourceLineVector ranges; + std::vector<lldb_private::LineTable::Entry> line_entries; + InlineSite(PdbCompilandSymId parent_id) : parent_id(parent_id){}; + }; + uint32_t CalculateNumCompileUnits() override; lldb::CompUnitSP ParseCompileUnitAtIndex(uint32_t index) override; @@ -225,6 +245,16 @@ private: VariableList &variables); size_t ParseVariablesForBlock(PdbCompilandSymId block_id); + llvm::Expected<uint32_t> GetFileIndex(const CompilandIndexItem &cii, + uint32_t file_id); + + size_t ParseSymbolArrayInScope( + PdbCompilandSymId parent, + llvm::function_ref<bool(llvm::codeview::SymbolKind, PdbCompilandSymId)> + fn); + + void ParseInlineSite(PdbCompilandSymId inline_site_id, Address func_addr); + llvm::BumpPtrAllocator m_allocator; lldb::addr_t m_obj_load_address = 0; @@ -241,6 +271,9 @@ private: llvm::DenseMap<lldb::user_id_t, lldb::FunctionSP> m_functions; llvm::DenseMap<lldb::user_id_t, lldb::CompUnitSP> m_compilands; llvm::DenseMap<lldb::user_id_t, lldb::TypeSP> m_types; + llvm::DenseMap<lldb::user_id_t, std::shared_ptr<InlineSite>> m_inline_sites; + // A map from file id in records to file index in support files. + llvm::DenseMap<uint32_t, uint32_t> m_file_indexes; }; } // namespace npdb diff --git a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp index 88c3aedb4c6b..51b34669ebad 100644 --- a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp +++ b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp @@ -1345,7 +1345,30 @@ namespace { bool IsValueParam(const clang::TemplateArgument &argument) { return argument.getKind() == TemplateArgument::Integral; } + +void AddAccessSpecifierDecl(clang::CXXRecordDecl *cxx_record_decl, + ASTContext &ct, + clang::AccessSpecifier previous_access, + clang::AccessSpecifier access_specifier) { + if (!cxx_record_decl->isClass() && !cxx_record_decl->isStruct()) + return; + if (previous_access != access_specifier) { + // For struct, don't add AS_public if it's the first AccessSpecDecl. + // For class, don't add AS_private if it's the first AccessSpecDecl. + if ((cxx_record_decl->isStruct() && + previous_access == clang::AccessSpecifier::AS_none && + access_specifier == clang::AccessSpecifier::AS_public) || + (cxx_record_decl->isClass() && + previous_access == clang::AccessSpecifier::AS_none && + access_specifier == clang::AccessSpecifier::AS_private)) { + return; + } + cxx_record_decl->addDecl( + AccessSpecDecl::Create(ct, access_specifier, cxx_record_decl, + SourceLocation(), SourceLocation())); + } } +} // namespace static TemplateParameterList *CreateTemplateParameterList( ASTContext &ast, @@ -1453,7 +1476,7 @@ void TypeSystemClang::CreateFunctionTemplateSpecializationInfo( /// as `int I = 3`. static bool TemplateParameterAllowsValue(NamedDecl *param, const TemplateArgument &value) { - if (auto *type_param = llvm::dyn_cast<TemplateTypeParmDecl>(param)) { + if (llvm::isa<TemplateTypeParmDecl>(param)) { // Compare the argument kind, i.e. ensure that <typename> != <int>. if (value.getKind() != TemplateArgument::Type) return false; @@ -2552,6 +2575,22 @@ ClangASTMetadata *TypeSystemClang::GetMetadata(const clang::Type *object) { return nullptr; } +void TypeSystemClang::SetCXXRecordDeclAccess(const clang::CXXRecordDecl *object, + clang::AccessSpecifier access) { + if (access == clang::AccessSpecifier::AS_none) + m_cxx_record_decl_access.erase(object); + else + m_cxx_record_decl_access[object] = access; +} + +clang::AccessSpecifier +TypeSystemClang::GetCXXRecordDeclAccess(const clang::CXXRecordDecl *object) { + auto It = m_cxx_record_decl_access.find(object); + if (It != m_cxx_record_decl_access.end()) + return It->second; + return clang::AccessSpecifier::AS_none; +} + clang::DeclContext * TypeSystemClang::GetDeclContextForType(const CompilerType &type) { return GetDeclContextForType(ClangUtil::GetQualType(type)); @@ -7276,9 +7315,17 @@ clang::FieldDecl *TypeSystemClang::AddFieldToRecordType( } if (field) { - field->setAccess( - TypeSystemClang::ConvertAccessTypeToAccessSpecifier(access)); - + clang::AccessSpecifier access_specifier = + TypeSystemClang::ConvertAccessTypeToAccessSpecifier(access); + field->setAccess(access_specifier); + + if (clang::CXXRecordDecl *cxx_record_decl = + llvm::dyn_cast<CXXRecordDecl>(record_decl)) { + AddAccessSpecifierDecl(cxx_record_decl, ast->getASTContext(), + ast->GetCXXRecordDeclAccess(cxx_record_decl), + access_specifier); + ast->SetCXXRecordDeclAccess(cxx_record_decl, access_specifier); + } record_decl->addDecl(field); VerifyDecl(field); @@ -7657,6 +7704,11 @@ clang::CXXMethodDecl *TypeSystemClang::AddMethodToCXXRecordType( cxx_method_decl->setParams(llvm::ArrayRef<clang::ParmVarDecl *>(params)); + AddAccessSpecifierDecl(cxx_record_decl, getASTContext(), + GetCXXRecordDeclAccess(cxx_record_decl), + access_specifier); + SetCXXRecordDeclAccess(cxx_record_decl, access_specifier); + cxx_record_decl->addDecl(cxx_method_decl); // Sometimes the debug info will mention a constructor (default/copy/move), @@ -8190,6 +8242,11 @@ bool TypeSystemClang::CompleteTagDeclarationDefinition( if (qual_type.isNull()) return false; + TypeSystemClang *lldb_ast = + llvm::dyn_cast<TypeSystemClang>(type.GetTypeSystem()); + if (lldb_ast == nullptr) + return false; + // Make sure we use the same methodology as // TypeSystemClang::StartTagDeclarationDefinition() as to how we start/end // the definition. @@ -8220,6 +8277,8 @@ bool TypeSystemClang::CompleteTagDeclarationDefinition( cxx_record_decl->setHasLoadedFieldsFromExternalStorage(true); cxx_record_decl->setHasExternalLexicalStorage(false); cxx_record_decl->setHasExternalVisibleStorage(false); + lldb_ast->SetCXXRecordDeclAccess(cxx_record_decl, + clang::AccessSpecifier::AS_none); return true; } } @@ -8233,10 +8292,6 @@ bool TypeSystemClang::CompleteTagDeclarationDefinition( if (enum_decl->isCompleteDefinition()) return true; - TypeSystemClang *lldb_ast = - llvm::dyn_cast<TypeSystemClang>(type.GetTypeSystem()); - if (lldb_ast == nullptr) - return false; clang::ASTContext &ast = lldb_ast->getASTContext(); /// TODO This really needs to be fixed. diff --git a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h index f3a07397ec44..e0f5906778a1 100644 --- a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h +++ b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h @@ -196,6 +196,11 @@ public: ClangASTMetadata *GetMetadata(const clang::Decl *object); ClangASTMetadata *GetMetadata(const clang::Type *object); + void SetCXXRecordDeclAccess(const clang::CXXRecordDecl *object, + clang::AccessSpecifier access); + clang::AccessSpecifier + GetCXXRecordDeclAccess(const clang::CXXRecordDecl *object); + // Basic Types CompilerType GetBuiltinTypeForEncodingAndBitSize(lldb::Encoding encoding, size_t bit_size) override; @@ -1080,6 +1085,12 @@ private: /// Maps Types to their associated ClangASTMetadata. TypeMetadataMap m_type_metadata; + typedef llvm::DenseMap<const clang::CXXRecordDecl *, clang::AccessSpecifier> + CXXRecordDeclAccessMap; + /// Maps CXXRecordDecl to their most recent added method/field's + /// AccessSpecifier. + CXXRecordDeclAccessMap m_cxx_record_decl_access; + /// The sema associated that is currently used to build this ASTContext. /// May be null if we are already done parsing this ASTContext or the /// ASTContext wasn't created by parsing source code. diff --git a/lldb/source/Symbol/Function.cpp b/lldb/source/Symbol/Function.cpp index 37479651fb45..dda9ec232715 100644 --- a/lldb/source/Symbol/Function.cpp +++ b/lldb/source/Symbol/Function.cpp @@ -195,7 +195,7 @@ Function *IndirectCallEdge::GetCallee(ModuleList &images, Status error; Value callee_addr_val; if (!call_target.Evaluate(&exe_ctx, exe_ctx.GetRegisterContext(), - /*loclist_base_addr=*/LLDB_INVALID_ADDRESS, + /*loclist_base_load_addr=*/LLDB_INVALID_ADDRESS, /*initial_value_ptr=*/nullptr, /*object_address_ptr=*/nullptr, callee_addr_val, &error)) { diff --git a/lldb/source/Symbol/Symbol.cpp b/lldb/source/Symbol/Symbol.cpp index fa7226dfd046..5ee5b0fe2223 100644 --- a/lldb/source/Symbol/Symbol.cpp +++ b/lldb/source/Symbol/Symbol.cpp @@ -680,7 +680,7 @@ void Symbol::Encode(DataEncoder &file, ConstStringTable &strtab) const { // symbol's base address doesn't have a section, then it is a constant value. // If it does have a section, we will encode the file address and re-resolve // the address when we decode it. - bool is_addr = m_addr_range.GetBaseAddress().GetSection().get() != NULL; + bool is_addr = m_addr_range.GetBaseAddress().GetSection().get() != nullptr; file.AppendU8(is_addr); file.AppendU64(m_addr_range.GetBaseAddress().GetFileAddress()); file.AppendU64(m_addr_range.GetByteSize()); diff --git a/lldb/source/Symbol/Symtab.cpp b/lldb/source/Symbol/Symtab.cpp index 75450a156c28..97dc31bc9766 100644 --- a/lldb/source/Symbol/Symtab.cpp +++ b/lldb/source/Symbol/Symtab.cpp @@ -34,7 +34,8 @@ using namespace lldb_private; Symtab::Symtab(ObjectFile *objfile) : m_objfile(objfile), m_symbols(), m_file_addr_to_index(*this), m_name_to_symbol_indices(), m_mutex(), - m_file_addr_to_index_computed(false), m_name_indexes_computed(false) { + m_file_addr_to_index_computed(false), m_name_indexes_computed(false), + m_loaded_from_cache(false), m_saved_to_cache(false) { m_name_to_symbol_indices.emplace(std::make_pair( lldb::eFunctionNameTypeNone, UniqueCStringMap<uint32_t>())); m_name_to_symbol_indices.emplace(std::make_pair( @@ -1179,7 +1180,8 @@ void Symtab::SaveToCache() { // Encode will return false if the symbol table's object file doesn't have // anything to make a signature from. if (Encode(file)) - cache->SetCachedData(GetCacheKey(), file.GetData()); + if (cache->SetCachedData(GetCacheKey(), file.GetData())) + SetWasSavedToCache(); } constexpr llvm::StringLiteral kIdentifierCStrMap("CMAP"); @@ -1343,5 +1345,7 @@ bool Symtab::LoadFromCache() { const bool result = Decode(data, &offset, signature_mismatch); if (signature_mismatch) cache->RemoveCacheFile(GetCacheKey()); + if (result) + SetWasLoadedFromCache(); return result; } diff --git a/lldb/source/Symbol/TypeSystem.cpp b/lldb/source/Symbol/TypeSystem.cpp index 0b3f7e4f3bd4..3092dc0bf0a4 100644 --- a/lldb/source/Symbol/TypeSystem.cpp +++ b/lldb/source/Symbol/TypeSystem.cpp @@ -22,7 +22,7 @@ using namespace lldb; static const size_t g_num_small_bitvector_bits = 64 - 8; static_assert(eNumLanguageTypes < g_num_small_bitvector_bits, "Languages bit vector is no longer small on 64 bit systems"); -LanguageSet::LanguageSet() : bitvector(eNumLanguageTypes, 0) {} +LanguageSet::LanguageSet() : bitvector(eNumLanguageTypes, false) {} llvm::Optional<LanguageType> LanguageSet::GetSingularLanguage() { if (bitvector.count() == 1) diff --git a/lldb/source/Target/MemoryTagMap.cpp b/lldb/source/Target/MemoryTagMap.cpp new file mode 100644 index 000000000000..846eef9209da --- /dev/null +++ b/lldb/source/Target/MemoryTagMap.cpp @@ -0,0 +1,64 @@ +//===-- MemoryTagMap.cpp --------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include "lldb/Target/MemoryTagMap.h" + +using namespace lldb_private; + +MemoryTagMap::MemoryTagMap(const MemoryTagManager *manager) + : m_manager(manager) { + assert(m_manager && "valid tag manager required to construct a MemoryTagMap"); +} + +void MemoryTagMap::InsertTags(lldb::addr_t addr, + const std::vector<lldb::addr_t> tags) { + // We're assuming that addr has no non address bits and is granule aligned. + size_t granule_size = m_manager->GetGranuleSize(); + for (auto tag : tags) { + m_addr_to_tag[addr] = tag; + addr += granule_size; + } +} + +bool MemoryTagMap::Empty() const { return m_addr_to_tag.empty(); } + +std::vector<llvm::Optional<lldb::addr_t>> +MemoryTagMap::GetTags(lldb::addr_t addr, size_t len) const { + // Addr and len might be unaligned + addr = m_manager->RemoveTagBits(addr); + MemoryTagManager::TagRange range(addr, len); + range = m_manager->ExpandToGranule(range); + + std::vector<llvm::Optional<lldb::addr_t>> tags; + lldb::addr_t end_addr = range.GetRangeEnd(); + addr = range.GetRangeBase(); + bool got_valid_tags = false; + size_t granule_size = m_manager->GetGranuleSize(); + + for (; addr < end_addr; addr += granule_size) { + llvm::Optional<lldb::addr_t> tag = GetTag(addr); + tags.push_back(tag); + if (tag) + got_valid_tags = true; + } + + // To save the caller checking if every item is llvm::None, + // we return an empty vector if we got no tags at all. + if (got_valid_tags) + return tags; + return {}; +} + +llvm::Optional<lldb::addr_t> MemoryTagMap::GetTag(lldb::addr_t addr) const { + // Here we assume that addr is granule aligned, just like when the tags + // were inserted. + auto found = m_addr_to_tag.find(addr); + if (found == m_addr_to_tag.end()) + return llvm::None; + return found->second; +} diff --git a/lldb/source/Target/Platform.cpp b/lldb/source/Target/Platform.cpp index af5ca0225169..3c331c8760df 100644 --- a/lldb/source/Target/Platform.cpp +++ b/lldb/source/Target/Platform.cpp @@ -428,6 +428,9 @@ void Platform::GetStatus(Stream &strm) { strm.Printf(" Connected: %s\n", is_connected ? "yes" : "no"); } + if (GetSDKRootDirectory()) { + strm.Format(" Sysroot: {0}\n", GetSDKRootDirectory()); + } if (GetWorkingDirectory()) { strm.Printf("WorkingDir: %s\n", GetWorkingDirectory().GetCString()); } @@ -2000,3 +2003,7 @@ size_t Platform::GetSoftwareBreakpointTrapOpcode(Target &target, return 0; } + +CompilerType Platform::GetSiginfoType(const llvm::Triple& triple) { + return CompilerType(); +} diff --git a/lldb/source/Target/RegisterContextUnwind.cpp b/lldb/source/Target/RegisterContextUnwind.cpp index 96b69640a3a3..315ccea65d1f 100644 --- a/lldb/source/Target/RegisterContextUnwind.cpp +++ b/lldb/source/Target/RegisterContextUnwind.cpp @@ -1509,7 +1509,7 @@ RegisterContextUnwind::SavedLocationForRegister( regnum.GetName(), regnum.GetAsKind(eRegisterKindLLDB)); return UnwindLLDB::RegisterSearchResult::eRegisterFound; } else { - std::string unwindplan_name(""); + std::string unwindplan_name; if (m_full_unwind_plan_sp) { unwindplan_name += "via '"; unwindplan_name += m_full_unwind_plan_sp->GetSourceName().AsCString(); diff --git a/lldb/source/Target/StackFrame.cpp b/lldb/source/Target/StackFrame.cpp index 7b4295158425..58de26b23b65 100644 --- a/lldb/source/Target/StackFrame.cpp +++ b/lldb/source/Target/StackFrame.cpp @@ -1433,13 +1433,13 @@ ValueObjectSP GetValueForDereferincingOffset(StackFrame &frame, /// Attempt to reconstruct the ValueObject for the address contained in a /// given register plus an offset. /// -/// \params [in] frame +/// \param [in] frame /// The current stack frame. /// -/// \params [in] reg +/// \param [in] reg /// The register. /// -/// \params [in] offset +/// \param [in] offset /// The offset from the register. /// /// \param [in] disassembler diff --git a/lldb/source/Target/Statistics.cpp b/lldb/source/Target/Statistics.cpp index 1b205c533519..ebddad837d14 100644 --- a/lldb/source/Target/Statistics.cpp +++ b/lldb/source/Target/Statistics.cpp @@ -34,7 +34,8 @@ json::Value StatsSuccessFail::ToJSON() const { } static double elapsed(const StatsTimepoint &start, const StatsTimepoint &end) { - StatsDuration elapsed = end.time_since_epoch() - start.time_since_epoch(); + StatsDuration::Duration elapsed = + end.time_since_epoch() - start.time_since_epoch(); return elapsed.count(); } @@ -52,12 +53,26 @@ json::Value ModuleStats::ToJSON() const { module.try_emplace("identifier", identifier); module.try_emplace("symbolTableParseTime", symtab_parse_time); module.try_emplace("symbolTableIndexTime", symtab_index_time); + module.try_emplace("symbolTableLoadedFromCache", symtab_loaded_from_cache); + module.try_emplace("symbolTableSavedToCache", symtab_saved_to_cache); module.try_emplace("debugInfoParseTime", debug_parse_time); module.try_emplace("debugInfoIndexTime", debug_index_time); module.try_emplace("debugInfoByteSize", (int64_t)debug_info_size); + module.try_emplace("debugInfoIndexLoadedFromCache", + debug_info_index_loaded_from_cache); + module.try_emplace("debugInfoIndexSavedToCache", + debug_info_index_saved_to_cache); return module; } +llvm::json::Value ConstStringStats::ToJSON() const { + json::Object obj; + obj.try_emplace<int64_t>("bytesTotal", stats.GetBytesTotal()); + obj.try_emplace<int64_t>("bytesUsed", stats.GetBytesUsed()); + obj.try_emplace<int64_t>("bytesUnused", stats.GetBytesUnused()); + return obj; +} + json::Value TargetStats::ToJSON(Target &target) { CollectStats(target); @@ -80,7 +95,8 @@ json::Value TargetStats::ToJSON(Target &target) { elapsed(*m_launch_or_attach_time, *m_first_public_stop_time); target_metrics_json.try_emplace("firstStopTime", elapsed_time); } - target_metrics_json.try_emplace("targetCreateTime", m_create_time.count()); + target_metrics_json.try_emplace("targetCreateTime", + m_create_time.get().count()); json::Array breakpoints_array; double totalBreakpointResolveTime = 0.0; @@ -144,6 +160,10 @@ llvm::json::Value DebuggerStats::ReportStatistics(Debugger &debugger, double symtab_index_time = 0.0; double debug_parse_time = 0.0; double debug_index_time = 0.0; + uint32_t symtabs_loaded = 0; + uint32_t symtabs_saved = 0; + uint32_t debug_index_loaded = 0; + uint32_t debug_index_saved = 0; uint64_t debug_info_size = 0; if (target) { json_targets.emplace_back(target->ReportStatistics()); @@ -167,13 +187,30 @@ llvm::json::Value DebuggerStats::ReportStatistics(Debugger &debugger, } module_stat.uuid = module->GetUUID().GetAsString(); module_stat.triple = module->GetArchitecture().GetTriple().str(); - module_stat.symtab_parse_time = module->GetSymtabParseTime().count(); - module_stat.symtab_index_time = module->GetSymtabIndexTime().count(); + module_stat.symtab_parse_time = module->GetSymtabParseTime().get().count(); + module_stat.symtab_index_time = module->GetSymtabIndexTime().get().count(); + Symtab *symtab = module->GetSymtab(); + if (symtab) { + module_stat.symtab_loaded_from_cache = symtab->GetWasLoadedFromCache(); + if (module_stat.symtab_loaded_from_cache) + ++symtabs_loaded; + module_stat.symtab_saved_to_cache = symtab->GetWasSavedToCache(); + if (module_stat.symtab_saved_to_cache) + ++symtabs_saved; + } SymbolFile *sym_file = module->GetSymbolFile(); if (sym_file) { module_stat.debug_index_time = sym_file->GetDebugInfoIndexTime().count(); module_stat.debug_parse_time = sym_file->GetDebugInfoParseTime().count(); module_stat.debug_info_size = sym_file->GetDebugInfoSize(); + module_stat.debug_info_index_loaded_from_cache = + sym_file->GetDebugInfoIndexWasLoadedFromCache(); + if (module_stat.debug_info_index_loaded_from_cache) + ++debug_index_loaded; + module_stat.debug_info_index_saved_to_cache = + sym_file->GetDebugInfoIndexWasSavedToCache(); + if (module_stat.debug_info_index_saved_to_cache) + ++debug_index_saved; } symtab_parse_time += module_stat.symtab_parse_time; symtab_index_time += module_stat.symtab_index_time; @@ -183,13 +220,23 @@ llvm::json::Value DebuggerStats::ReportStatistics(Debugger &debugger, json_modules.emplace_back(module_stat.ToJSON()); } + ConstStringStats const_string_stats; + json::Object json_memory{ + {"strings", const_string_stats.ToJSON()}, + }; + json::Object global_stats{ {"targets", std::move(json_targets)}, {"modules", std::move(json_modules)}, + {"memory", std::move(json_memory)}, {"totalSymbolTableParseTime", symtab_parse_time}, {"totalSymbolTableIndexTime", symtab_index_time}, + {"totalSymbolTablesLoadedFromCache", symtabs_loaded}, + {"totalSymbolTablesSavedToCache", symtabs_saved}, {"totalDebugInfoParseTime", debug_parse_time}, {"totalDebugInfoIndexTime", debug_index_time}, + {"totalDebugInfoIndexLoadedFromCache", debug_index_loaded}, + {"totalDebugInfoIndexSavedToCache", debug_index_saved}, {"totalDebugInfoByteSize", debug_info_size}, }; return std::move(global_stats); diff --git a/lldb/source/Target/Target.cpp b/lldb/source/Target/Target.cpp index fa860399aca7..01e51c0577aa 100644 --- a/lldb/source/Target/Target.cpp +++ b/lldb/source/Target/Target.cpp @@ -212,17 +212,20 @@ const lldb::ProcessSP &Target::GetProcessSP() const { return m_process_sp; } lldb::REPLSP Target::GetREPL(Status &err, lldb::LanguageType language, const char *repl_options, bool can_create) { + if (language == eLanguageTypeUnknown) + language = m_debugger.GetREPLLanguage(); + if (language == eLanguageTypeUnknown) { LanguageSet repl_languages = Language::GetLanguagesSupportingREPLs(); if (auto single_lang = repl_languages.GetSingularLanguage()) { language = *single_lang; } else if (repl_languages.Empty()) { - err.SetErrorStringWithFormat( + err.SetErrorString( "LLDB isn't configured with REPL support for any languages."); return REPLSP(); } else { - err.SetErrorStringWithFormat( + err.SetErrorString( "Multiple possible REPL languages. Please specify a language."); return REPLSP(); } diff --git a/lldb/source/Target/Thread.cpp b/lldb/source/Target/Thread.cpp index 481a39a576e9..c5f16b4e6c1d 100644 --- a/lldb/source/Target/Thread.cpp +++ b/lldb/source/Target/Thread.cpp @@ -471,9 +471,7 @@ void Thread::SetStopInfoToNothing() { StopInfo::CreateStopReasonWithSignal(*this, LLDB_INVALID_SIGNAL_NUMBER)); } -bool Thread::ThreadStoppedForAReason(void) { - return (bool)GetPrivateStopInfo(); -} +bool Thread::ThreadStoppedForAReason() { return (bool)GetPrivateStopInfo(); } bool Thread::CheckpointThreadState(ThreadStateCheckpoint &saved_state) { saved_state.register_backup_sp.reset(); diff --git a/lldb/source/Target/TraceInstructionDumper.cpp b/lldb/source/Target/TraceInstructionDumper.cpp index dc1e86481c36..d58d2dff7383 100644 --- a/lldb/source/Target/TraceInstructionDumper.cpp +++ b/lldb/source/Target/TraceInstructionDumper.cpp @@ -137,7 +137,7 @@ DumpInstructionSymbolContext(Stream &s, insn.sc.module_sp->GetFileSpec().GetFilename().AsCString()); else insn.sc.DumpStopContext(&s, insn.exe_ctx.GetTargetPtr(), insn.address, - /*show_fullpath=*/false, + /*show_fullpaths=*/false, /*show_module=*/true, /*show_inlined_frames=*/false, /*show_function_arguments=*/true, /*show_function_name=*/true); @@ -148,8 +148,8 @@ static void DumpInstructionDisassembly(Stream &s, InstructionSymbolInfo &insn) { if (!insn.instruction) return; s.Printf(" "); - insn.instruction->Dump(&s, /*show_address=*/false, /*show_bytes=*/false, - /*max_opcode_byte_size=*/0, &insn.exe_ctx, &insn.sc, + insn.instruction->Dump(&s, /*max_opcode_byte_size=*/0, /*show_address=*/false, + /*show_bytes=*/false, &insn.exe_ctx, &insn.sc, /*prev_sym_ctx=*/nullptr, /*disassembly_addr_format=*/nullptr, /*max_address_text_size=*/0); diff --git a/lldb/source/Utility/ConstString.cpp b/lldb/source/Utility/ConstString.cpp index e5e1b2387e64..142c335ddbbe 100644 --- a/lldb/source/Utility/ConstString.cpp +++ b/lldb/source/Utility/ConstString.cpp @@ -159,16 +159,15 @@ public: return nullptr; } - // Return the size in bytes that this object and any items in its collection - // of uniqued strings + data count values takes in memory. - size_t MemorySize() const { - size_t mem_size = sizeof(Pool); + ConstString::MemoryStats GetMemoryStats() const { + ConstString::MemoryStats stats; for (const auto &pool : m_string_pools) { llvm::sys::SmartScopedReader<false> rlock(pool.m_mutex); - for (const auto &entry : pool.m_string_map) - mem_size += sizeof(StringPoolEntryType) + entry.getKey().size(); + const Allocator &alloc = pool.m_string_map.getAllocator(); + stats.bytes_total += alloc.getTotalMemory(); + stats.bytes_used += alloc.getBytesAllocated(); } - return mem_size; + return stats; } protected: @@ -327,9 +326,8 @@ void ConstString::SetTrimmedCStringWithLength(const char *cstr, m_string = StringPool().GetConstTrimmedCStringWithLength(cstr, cstr_len); } -size_t ConstString::StaticMemorySize() { - // Get the size of the static string pool - return StringPool().MemorySize(); +ConstString::MemoryStats ConstString::GetMemoryStats() { + return StringPool().GetMemoryStats(); } void llvm::format_provider<ConstString>::format(const ConstString &CS, diff --git a/lldb/source/Utility/Instrumentation.cpp b/lldb/source/Utility/Instrumentation.cpp new file mode 100644 index 000000000000..861789810e1a --- /dev/null +++ b/lldb/source/Utility/Instrumentation.cpp @@ -0,0 +1,43 @@ +//===-- Instrumentation.cpp -----------------------------------------------===// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include "lldb/Utility/Instrumentation.h" +#include "llvm/Support/Signposts.h" + +#include <cstdio> +#include <cstdlib> +#include <limits> +#include <thread> + +using namespace lldb_private; +using namespace lldb_private::instrumentation; + +// Whether we're currently across the API boundary. +static thread_local bool g_global_boundary = false; + +// Instrument SB API calls with singposts when supported. +static llvm::ManagedStatic<llvm::SignpostEmitter> g_api_signposts; + +Instrumenter::Instrumenter(llvm::StringRef pretty_func, + std::string &&pretty_args) + : m_pretty_func(pretty_func), m_local_boundary(false) { + if (!g_global_boundary) { + g_global_boundary = true; + m_local_boundary = true; + g_api_signposts->startInterval(this, m_pretty_func); + } + LLDB_LOG(GetLogIfAllCategoriesSet(LIBLLDB_LOG_API), "[{0}] {1} ({2})", + m_local_boundary ? "external" : "internal", m_pretty_func, + pretty_args); +} + +Instrumenter::~Instrumenter() { + if (m_local_boundary) { + g_global_boundary = false; + g_api_signposts->endInterval(this, m_pretty_func); + } +} diff --git a/lldb/source/Utility/Log.cpp b/lldb/source/Utility/Log.cpp index ff654ec93e78..d229538073d1 100644 --- a/lldb/source/Utility/Log.cpp +++ b/lldb/source/Utility/Log.cpp @@ -30,7 +30,6 @@ #include <process.h> #else #include <unistd.h> -#include <pthread.h> #endif using namespace lldb_private; @@ -89,7 +88,7 @@ void Log::Enable(const std::shared_ptr<llvm::raw_ostream> &stream_sp, uint32_t options, uint32_t flags) { llvm::sys::ScopedWriter lock(m_mutex); - uint32_t mask = m_mask.fetch_or(flags, std::memory_order_relaxed); + MaskType mask = m_mask.fetch_or(flags, std::memory_order_relaxed); if (mask | flags) { m_options.store(options, std::memory_order_relaxed); m_stream_sp = stream_sp; @@ -100,7 +99,7 @@ void Log::Enable(const std::shared_ptr<llvm::raw_ostream> &stream_sp, void Log::Disable(uint32_t flags) { llvm::sys::ScopedWriter lock(m_mutex); - uint32_t mask = m_mask.fetch_and(~flags, std::memory_order_relaxed); + MaskType mask = m_mask.fetch_and(~flags, std::memory_order_relaxed); if (!(mask & ~flags)) { m_stream_sp.reset(); m_channel.log_ptr.store(nullptr, std::memory_order_relaxed); @@ -180,9 +179,6 @@ void Log::Warning(const char *format, ...) { } void Log::Initialize() { -#ifdef LLVM_ON_UNIX - pthread_atfork(nullptr, nullptr, &Log::DisableLoggingChild); -#endif InitializeLldbChannel(); } @@ -346,11 +342,3 @@ void Log::Format(llvm::StringRef file, llvm::StringRef function, message << payload << "\n"; WriteMessage(message.str()); } - -void Log::DisableLoggingChild() { - // Disable logging by clearing out the atomic variable after forking -- if we - // forked while another thread held the channel mutex, we would deadlock when - // trying to write to the log. - for (auto &c: *g_channel_map) - c.second.m_channel.log_ptr.store(nullptr, std::memory_order_relaxed); -} diff --git a/lldb/source/Utility/Logging.cpp b/lldb/source/Utility/Logging.cpp index 4648bec502c5..67d5d3af2640 100644 --- a/lldb/source/Utility/Logging.cpp +++ b/lldb/source/Utility/Logging.cpp @@ -16,49 +16,74 @@ using namespace lldb_private; static constexpr Log::Category g_categories[] = { - {{"api"}, {"log API calls and return values"}, LIBLLDB_LOG_API}, - {{"ast"}, {"log AST"}, LIBLLDB_LOG_AST}, - {{"break"}, {"log breakpoints"}, LIBLLDB_LOG_BREAKPOINTS}, - {{"commands"}, {"log command argument parsing"}, LIBLLDB_LOG_COMMANDS}, - {{"comm"}, {"log communication activities"}, LIBLLDB_LOG_COMMUNICATION}, - {{"conn"}, {"log connection details"}, LIBLLDB_LOG_CONNECTION}, - {{"demangle"}, {"log mangled names to catch demangler crashes"}, LIBLLDB_LOG_DEMANGLE}, - {{"dyld"}, {"log shared library related activities"}, LIBLLDB_LOG_DYNAMIC_LOADER}, - {{"event"}, {"log broadcaster, listener and event queue activities"}, LIBLLDB_LOG_EVENTS}, - {{"expr"}, {"log expressions"}, LIBLLDB_LOG_EXPRESSIONS}, - {{"formatters"}, {"log data formatters related activities"}, LIBLLDB_LOG_DATAFORMATTERS}, - {{"host"}, {"log host activities"}, LIBLLDB_LOG_HOST}, - {{"jit"}, {"log JIT events in the target"}, LIBLLDB_LOG_JIT_LOADER}, - {{"language"}, {"log language runtime events"}, LIBLLDB_LOG_LANGUAGE}, - {{"mmap"}, {"log mmap related activities"}, LIBLLDB_LOG_MMAP}, - {{"module"}, {"log module activities such as when modules are created, destroyed, replaced, and more"}, LIBLLDB_LOG_MODULES}, - {{"object"}, {"log object construction/destruction for important objects"}, LIBLLDB_LOG_OBJECT}, - {{"os"}, {"log OperatingSystem plugin related activities"}, LIBLLDB_LOG_OS}, - {{"platform"}, {"log platform events and activities"}, LIBLLDB_LOG_PLATFORM}, - {{"process"}, {"log process events and activities"}, LIBLLDB_LOG_PROCESS}, - {{"script"}, {"log events about the script interpreter"}, LIBLLDB_LOG_SCRIPT}, - {{"state"}, {"log private and public process state changes"}, LIBLLDB_LOG_STATE}, - {{"step"}, {"log step related activities"}, LIBLLDB_LOG_STEP}, - {{"symbol"}, {"log symbol related issues and warnings"}, LIBLLDB_LOG_SYMBOLS}, - {{"system-runtime"}, {"log system runtime events"}, LIBLLDB_LOG_SYSTEM_RUNTIME}, - {{"target"}, {"log target events and activities"}, LIBLLDB_LOG_TARGET}, - {{"temp"}, {"log internal temporary debug messages"}, LIBLLDB_LOG_TEMPORARY}, - {{"thread"}, {"log thread events and activities"}, LIBLLDB_LOG_THREAD}, - {{"types"}, {"log type system related activities"}, LIBLLDB_LOG_TYPES}, - {{"unwind"}, {"log stack unwind activities"}, LIBLLDB_LOG_UNWIND}, - {{"watch"}, {"log watchpoint related activities"}, LIBLLDB_LOG_WATCHPOINTS}, + {{"api"}, {"log API calls and return values"}, LLDBLog::API}, + {{"ast"}, {"log AST"}, LLDBLog::AST}, + {{"break"}, {"log breakpoints"}, LLDBLog::Breakpoints}, + {{"commands"}, {"log command argument parsing"}, LLDBLog::Commands}, + {{"comm"}, {"log communication activities"}, LLDBLog::Communication}, + {{"conn"}, {"log connection details"}, LLDBLog::Connection}, + {{"demangle"}, + {"log mangled names to catch demangler crashes"}, + LLDBLog::Demangle}, + {{"dyld"}, + {"log shared library related activities"}, + LLDBLog::DynamicLoader}, + {{"event"}, + {"log broadcaster, listener and event queue activities"}, + LLDBLog::Events}, + {{"expr"}, {"log expressions"}, LLDBLog::Expressions}, + {{"formatters"}, + {"log data formatters related activities"}, + LLDBLog::DataFormatters}, + {{"host"}, {"log host activities"}, LLDBLog::Host}, + {{"jit"}, {"log JIT events in the target"}, LLDBLog::JITLoader}, + {{"language"}, {"log language runtime events"}, LLDBLog::Language}, + {{"mmap"}, {"log mmap related activities"}, LLDBLog::MMap}, + {{"module"}, + {"log module activities such as when modules are created, destroyed, " + "replaced, and more"}, + LLDBLog::Modules}, + {{"object"}, + {"log object construction/destruction for important objects"}, + LLDBLog::Object}, + {{"os"}, {"log OperatingSystem plugin related activities"}, LLDBLog::OS}, + {{"platform"}, {"log platform events and activities"}, LLDBLog::Platform}, + {{"process"}, {"log process events and activities"}, LLDBLog::Process}, + {{"script"}, {"log events about the script interpreter"}, LLDBLog::Script}, + {{"state"}, + {"log private and public process state changes"}, + LLDBLog::State}, + {{"step"}, {"log step related activities"}, LLDBLog::Step}, + {{"symbol"}, {"log symbol related issues and warnings"}, LLDBLog::Symbols}, + {{"system-runtime"}, {"log system runtime events"}, LLDBLog::SystemRuntime}, + {{"target"}, {"log target events and activities"}, LLDBLog::Target}, + {{"temp"}, {"log internal temporary debug messages"}, LLDBLog::Temporary}, + {{"thread"}, {"log thread events and activities"}, LLDBLog::Thread}, + {{"types"}, {"log type system related activities"}, LLDBLog::Types}, + {{"unwind"}, {"log stack unwind activities"}, LLDBLog::Unwind}, + {{"watch"}, {"log watchpoint related activities"}, LLDBLog::Watchpoints}, }; -static Log::Channel g_log_channel(g_categories, LIBLLDB_LOG_DEFAULT); +static Log::Channel g_log_channel(g_categories, + LLDBLog::Process | LLDBLog::Thread | + LLDBLog::DynamicLoader | + LLDBLog::Breakpoints | + LLDBLog::Watchpoints | LLDBLog::Step | + LLDBLog::State | LLDBLog::Symbols | + LLDBLog::Target | LLDBLog::Commands); + +template <> Log::Channel &lldb_private::LogChannelFor<LLDBLog>() { + return g_log_channel; +} void lldb_private::InitializeLldbChannel() { Log::Register("lldb", g_log_channel); } -Log *lldb_private::GetLogIfAllCategoriesSet(uint32_t mask) { - return g_log_channel.GetLogIfAll(mask); +Log *lldb_private::GetLogIfAllCategoriesSet(LLDBLog mask) { + return GetLog(mask); } -Log *lldb_private::GetLogIfAnyCategoriesSet(uint32_t mask) { - return g_log_channel.GetLogIfAny(mask); +Log *lldb_private::GetLogIfAnyCategoriesSet(LLDBLog mask) { + return GetLog(mask); } diff --git a/lldb/source/Utility/Reproducer.cpp b/lldb/source/Utility/Reproducer.cpp index a306d6c1ef25..1e71dba472ed 100644 --- a/lldb/source/Utility/Reproducer.cpp +++ b/lldb/source/Utility/Reproducer.cpp @@ -362,7 +362,7 @@ llvm::Error repro::Finalize(Loader *loader) { FileSpec mapping = reproducer_root.CopyByAppendingPathComponent(FileProvider::Info::file); - if (auto ec = collector.copyFiles(/*stop_on_error=*/false)) + if (auto ec = collector.copyFiles(/*StopOnError=*/false)) return errorCodeToError(ec); collector.writeMapping(mapping.GetPath()); diff --git a/lldb/source/Utility/ReproducerInstrumentation.cpp b/lldb/source/Utility/ReproducerInstrumentation.cpp deleted file mode 100644 index b3285f4b3776..000000000000 --- a/lldb/source/Utility/ReproducerInstrumentation.cpp +++ /dev/null @@ -1,262 +0,0 @@ -//===-- ReproducerInstrumentation.cpp -------------------------------------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#include "lldb/Utility/ReproducerInstrumentation.h" -#include "lldb/Utility/Reproducer.h" -#include <cstdio> -#include <cstdlib> -#include <limits> -#include <thread> - -using namespace lldb_private; -using namespace lldb_private::repro; - -// Whether we're currently across the API boundary. -static thread_local bool g_global_boundary = false; - -void *IndexToObject::GetObjectForIndexImpl(unsigned idx) { - return m_mapping.lookup(idx); -} - -void IndexToObject::AddObjectForIndexImpl(unsigned idx, void *object) { - assert(idx != 0 && "Cannot add object for sentinel"); - m_mapping[idx] = object; -} - -std::vector<void *> IndexToObject::GetAllObjects() const { - std::vector<std::pair<unsigned, void *>> pairs; - for (auto &e : m_mapping) { - pairs.emplace_back(e.first, e.second); - } - - // Sort based on index. - std::sort(pairs.begin(), pairs.end(), - [](auto &lhs, auto &rhs) { return lhs.first < rhs.first; }); - - std::vector<void *> objects; - objects.reserve(pairs.size()); - for (auto &p : pairs) { - objects.push_back(p.second); - } - - return objects; -} - -template <> const uint8_t *Deserializer::Deserialize<const uint8_t *>() { - return Deserialize<uint8_t *>(); -} - -template <> void *Deserializer::Deserialize<void *>() { - return const_cast<void *>(Deserialize<const void *>()); -} - -template <> const void *Deserializer::Deserialize<const void *>() { - return nullptr; -} - -template <> char *Deserializer::Deserialize<char *>() { - return const_cast<char *>(Deserialize<const char *>()); -} - -template <> const char *Deserializer::Deserialize<const char *>() { - const size_t size = Deserialize<size_t>(); - if (size == std::numeric_limits<size_t>::max()) - return nullptr; - assert(HasData(size + 1)); - const char *str = m_buffer.data(); - m_buffer = m_buffer.drop_front(size + 1); -#ifdef LLDB_REPRO_INSTR_TRACE - llvm::errs() << "Deserializing with " << LLVM_PRETTY_FUNCTION << " -> \"" - << str << "\"\n"; -#endif - return str; -} - -template <> const char **Deserializer::Deserialize<const char **>() { - const size_t size = Deserialize<size_t>(); - if (size == 0) - return nullptr; - const char **r = - reinterpret_cast<const char **>(calloc(size + 1, sizeof(char *))); - for (size_t i = 0; i < size; ++i) - r[i] = Deserialize<const char *>(); - return r; -} - -void Deserializer::CheckSequence(unsigned sequence) { - if (m_expected_sequence && *m_expected_sequence != sequence) - llvm::report_fatal_error( - "The result does not match the preceding " - "function. This is probably the result of concurrent " - "use of the SB API during capture, which is currently not " - "supported."); - m_expected_sequence.reset(); -} - -bool Registry::Replay(const FileSpec &file) { - auto error_or_file = llvm::MemoryBuffer::getFile(file.GetPath()); - if (auto err = error_or_file.getError()) - return false; - - return Replay((*error_or_file)->getBuffer()); -} - -bool Registry::Replay(llvm::StringRef buffer) { - Deserializer deserializer(buffer); - return Replay(deserializer); -} - -bool Registry::Replay(Deserializer &deserializer) { -#ifndef LLDB_REPRO_INSTR_TRACE - Log *log = GetLogIfAllCategoriesSet(LIBLLDB_LOG_API); -#endif - - // Disable buffering stdout so that we approximate the way things get flushed - // during an interactive session. - setvbuf(stdout, nullptr, _IONBF, 0); - - while (deserializer.HasData(1)) { - unsigned sequence = deserializer.Deserialize<unsigned>(); - unsigned id = deserializer.Deserialize<unsigned>(); - -#ifndef LLDB_REPRO_INSTR_TRACE - LLDB_LOG(log, "Replaying {0}: {1}", id, GetSignature(id)); -#else - llvm::errs() << "Replaying " << id << ": " << GetSignature(id) << "\n"; -#endif - - deserializer.SetExpectedSequence(sequence); - GetReplayer(id)->operator()(deserializer); - } - - // Add a small artificial delay to ensure that all asynchronous events have - // completed before we exit. - std::this_thread::sleep_for(std::chrono::milliseconds(100)); - - return true; -} - -void Registry::DoRegister(uintptr_t RunID, std::unique_ptr<Replayer> replayer, - SignatureStr signature) { - const unsigned id = m_replayers.size() + 1; - assert(m_replayers.find(RunID) == m_replayers.end()); - m_replayers[RunID] = std::make_pair(std::move(replayer), id); - m_ids[id] = - std::make_pair(m_replayers[RunID].first.get(), std::move(signature)); -} - -unsigned Registry::GetID(uintptr_t addr) { - unsigned id = m_replayers[addr].second; - assert(id != 0 && "Forgot to add function to registry?"); - return id; -} - -std::string Registry::GetSignature(unsigned id) { - assert(m_ids.count(id) != 0 && "ID not in registry"); - return m_ids[id].second.ToString(); -} - -void Registry::CheckID(unsigned expected, unsigned actual) { - if (expected != actual) { - llvm::errs() << "Reproducer expected signature " << expected << ": '" - << GetSignature(expected) << "'\n"; - llvm::errs() << "Reproducer actual signature " << actual << ": '" - << GetSignature(actual) << "'\n"; - llvm::report_fatal_error( - "Detected reproducer replay divergence. Refusing to continue."); - } - -#ifdef LLDB_REPRO_INSTR_TRACE - llvm::errs() << "Replaying " << actual << ": " << GetSignature(actual) - << "\n"; -#endif -} - -Replayer *Registry::GetReplayer(unsigned id) { - assert(m_ids.count(id) != 0 && "ID not in registry"); - return m_ids[id].first; -} - -std::string Registry::SignatureStr::ToString() const { - return (result + (result.empty() ? "" : " ") + scope + "::" + name + args) - .str(); -} - -unsigned ObjectToIndex::GetIndexForObjectImpl(const void *object) { - unsigned index = m_mapping.size() + 1; - auto it = m_mapping.find(object); - if (it == m_mapping.end()) - m_mapping[object] = index; - return m_mapping[object]; -} - -Recorder::Recorder() - : m_pretty_func(), m_pretty_args(), - - m_sequence(std::numeric_limits<unsigned>::max()) { - if (!g_global_boundary) { - g_global_boundary = true; - m_local_boundary = true; - m_sequence = GetNextSequenceNumber(); - } -} - -Recorder::Recorder(llvm::StringRef pretty_func, std::string &&pretty_args) - : m_serializer(nullptr), m_pretty_func(pretty_func), - m_pretty_args(pretty_args), m_local_boundary(false), - m_result_recorded(true), - m_sequence(std::numeric_limits<unsigned>::max()) { - if (!g_global_boundary) { - g_global_boundary = true; - m_local_boundary = true; - m_sequence = GetNextSequenceNumber(); - LLDB_LOG(GetLogIfAllCategoriesSet(LIBLLDB_LOG_API), "{0} ({1})", - m_pretty_func, m_pretty_args); - } -} - -Recorder::~Recorder() { - assert(m_result_recorded && "Did you forget LLDB_RECORD_RESULT?"); - UpdateBoundary(); -} - -unsigned Recorder::GetSequenceNumber() const { - assert(m_sequence != std::numeric_limits<unsigned>::max()); - return m_sequence; -} - -void Recorder::PrivateThread() { g_global_boundary = true; } - -void Recorder::UpdateBoundary() { - if (m_local_boundary) - g_global_boundary = false; -} - -void InstrumentationData::Initialize(Serializer &serializer, - Registry ®istry) { - InstanceImpl().emplace(serializer, registry); -} - -void InstrumentationData::Initialize(Deserializer &deserializer, - Registry ®istry) { - InstanceImpl().emplace(deserializer, registry); -} - -InstrumentationData &InstrumentationData::Instance() { - if (!InstanceImpl()) - InstanceImpl().emplace(); - return *InstanceImpl(); -} - -llvm::Optional<InstrumentationData> &InstrumentationData::InstanceImpl() { - static llvm::Optional<InstrumentationData> g_instrumentation_data; - return g_instrumentation_data; -} - -std::atomic<unsigned> lldb_private::repro::Recorder::g_sequence; -std::mutex lldb_private::repro::Recorder::g_mutex; diff --git a/lldb/source/Utility/StringList.cpp b/lldb/source/Utility/StringList.cpp index baff34ae3a5e..ee1f157f16f1 100644 --- a/lldb/source/Utility/StringList.cpp +++ b/lldb/source/Utility/StringList.cpp @@ -42,7 +42,9 @@ void StringList::AppendString(const char *str) { void StringList::AppendString(const std::string &s) { m_strings.push_back(s); } -void StringList::AppendString(std::string &&s) { m_strings.push_back(s); } +void StringList::AppendString(std::string &&s) { + m_strings.push_back(std::move(s)); +} void StringList::AppendString(const char *str, size_t str_len) { if (str) @@ -53,6 +55,10 @@ void StringList::AppendString(llvm::StringRef str) { m_strings.push_back(str.str()); } +void StringList::AppendString(const llvm::Twine &str) { + m_strings.push_back(str.str()); +} + void StringList::AppendList(const char **strv, int strc) { for (int i = 0; i < strc; ++i) { if (strv[i]) @@ -133,9 +139,9 @@ void StringList::InsertStringAtIndex(size_t idx, const std::string &str) { void StringList::InsertStringAtIndex(size_t idx, std::string &&str) { if (idx < m_strings.size()) - m_strings.insert(m_strings.begin() + idx, str); + m_strings.insert(m_strings.begin() + idx, std::move(str)); else - m_strings.push_back(str); + m_strings.push_back(std::move(str)); } void StringList::DeleteStringAtIndex(size_t idx) { diff --git a/lldb/source/Utility/Timer.cpp b/lldb/source/Utility/Timer.cpp index 2f3afe4c8703..b190f35007d5 100644 --- a/lldb/source/Utility/Timer.cpp +++ b/lldb/source/Utility/Timer.cpp @@ -63,7 +63,7 @@ Timer::Timer(Timer::Category &category, const char *format, ...) TimerStack &stack = GetTimerStackForCurrentThread(); stack.push_back(this); - if (g_quiet && stack.size() <= g_display_depth) { + if (!g_quiet && stack.size() <= g_display_depth) { std::lock_guard<std::mutex> lock(GetFileMutex()); // Indent @@ -89,7 +89,7 @@ Timer::~Timer() { Signposts->endInterval(this, m_category.GetName()); TimerStack &stack = GetTimerStackForCurrentThread(); - if (g_quiet && stack.size() <= g_display_depth) { + if (!g_quiet && stack.size() <= g_display_depth) { std::lock_guard<std::mutex> lock(GetFileMutex()); ::fprintf(stdout, "%*s%.9f sec (%.9f sec)\n", int(stack.size() - 1) * TIMER_INDENT_AMOUNT, "", diff --git a/lldb/tools/driver/Driver.cpp b/lldb/tools/driver/Driver.cpp index 2ed9958e51da..233e0dd977d3 100644 --- a/lldb/tools/driver/Driver.cpp +++ b/lldb/tools/driver/Driver.cpp @@ -296,6 +296,7 @@ SBError Driver::ProcessArgs(const opt::InputArgList &args, bool &exiting) { arg_value); return error; } + m_debugger.SetREPLLanguage(m_option_data.m_repl_lang); } if (args.hasArg(OPT_repl)) { diff --git a/lldb/tools/lldb-instr/Instrument.cpp b/lldb/tools/lldb-instr/Instrument.cpp index 8fbc3e64833c..4b8725396a61 100644 --- a/lldb/tools/lldb-instr/Instrument.cpp +++ b/lldb/tools/lldb-instr/Instrument.cpp @@ -22,143 +22,6 @@ using namespace clang::tooling; static llvm::cl::OptionCategory InstrCategory("LLDB Instrumentation Generator"); -/// Get the macro name for recording method calls. -/// -/// LLDB_RECORD_METHOD -/// LLDB_RECORD_METHOD_CONST -/// LLDB_RECORD_METHOD_NO_ARGS -/// LLDB_RECORD_METHOD_CONST_NO_ARGS -/// LLDB_RECORD_STATIC_METHOD -/// LLDB_RECORD_STATIC_METHOD_NO_ARGS -static std::string GetRecordMethodMacroName(bool Static, bool Const, - bool NoArgs) { - std::string Macro; - llvm::raw_string_ostream OS(Macro); - - OS << "LLDB_RECORD"; - if (Static) - OS << "_STATIC"; - OS << "_METHOD"; - if (Const) - OS << "_CONST"; - if (NoArgs) - OS << "_NO_ARGS"; - - return OS.str(); -} - -/// Get the macro name for register methods. -/// -/// LLDB_REGISTER_CONSTRUCTOR -/// LLDB_REGISTER_METHOD -/// LLDB_REGISTER_METHOD_CONST -/// LLDB_REGISTER_STATIC_METHOD -static std::string GetRegisterMethodMacroName(bool Static, bool Const) { - std::string Macro; - llvm::raw_string_ostream OS(Macro); - - OS << "LLDB_REGISTER"; - if (Static) - OS << "_STATIC"; - OS << "_METHOD"; - if (Const) - OS << "_CONST"; - - return OS.str(); -} - -static std::string GetRecordMethodMacro(StringRef Result, StringRef Class, - StringRef Method, StringRef Signature, - StringRef Values, bool Static, - bool Const) { - std::string Macro; - llvm::raw_string_ostream OS(Macro); - - OS << GetRecordMethodMacroName(Static, Const, Values.empty()); - OS << "(" << Result << ", " << Class << ", " << Method; - - if (!Values.empty()) { - OS << ", (" << Signature << "), " << Values << ");\n\n"; - } else { - OS << ");\n\n"; - } - - return OS.str(); -} - -static std::string GetRecordConstructorMacro(StringRef Class, - StringRef Signature, - StringRef Values) { - std::string Macro; - llvm::raw_string_ostream OS(Macro); - if (!Values.empty()) { - OS << "LLDB_RECORD_CONSTRUCTOR(" << Class << ", (" << Signature << "), " - << Values << ");\n\n"; - } else { - OS << "LLDB_RECORD_CONSTRUCTOR_NO_ARGS(" << Class << ");\n\n"; - } - return OS.str(); -} - -static std::string GetRecordDummyMacro(StringRef Result, StringRef Class, - StringRef Method, StringRef Signature, - StringRef Values) { - assert(!Values.empty()); - std::string Macro; - llvm::raw_string_ostream OS(Macro); - - OS << "LLDB_RECORD_DUMMY(" << Result << ", " << Class << ", " << Method; - OS << ", (" << Signature << "), " << Values << ");\n\n"; - - return OS.str(); -} - -static std::string GetRegisterConstructorMacro(StringRef Class, - StringRef Signature) { - std::string Macro; - llvm::raw_string_ostream OS(Macro); - OS << "LLDB_REGISTER_CONSTRUCTOR(" << Class << ", (" << Signature << "));\n"; - return OS.str(); -} - -static std::string GetRegisterMethodMacro(StringRef Result, StringRef Class, - StringRef Method, StringRef Signature, - bool Static, bool Const) { - std::string Macro; - llvm::raw_string_ostream OS(Macro); - OS << GetRegisterMethodMacroName(Static, Const); - OS << "(" << Result << ", " << Class << ", " << Method << ", (" << Signature - << "));\n"; - return OS.str(); -} - -class SBReturnVisitor : public RecursiveASTVisitor<SBReturnVisitor> { -public: - SBReturnVisitor(Rewriter &R) : MyRewriter(R) {} - - bool VisitReturnStmt(ReturnStmt *Stmt) { - Expr *E = Stmt->getRetValue(); - - if (E->getBeginLoc().isMacroID()) - return false; - - SourceRange R(E->getBeginLoc(), E->getEndLoc()); - - StringRef WrittenExpr = Lexer::getSourceText( - CharSourceRange::getTokenRange(R), MyRewriter.getSourceMgr(), - MyRewriter.getLangOpts()); - - std::string ReplacementText = - "LLDB_RECORD_RESULT(" + WrittenExpr.str() + ")"; - MyRewriter.ReplaceText(R, ReplacementText); - - return true; - } - -private: - Rewriter &MyRewriter; -}; - class SBVisitor : public RecursiveASTVisitor<SBVisitor> { public: SBVisitor(Rewriter &R, ASTContext &Context) @@ -170,85 +33,40 @@ public: if (ShouldSkip(Decl)) return false; - // Skip CXXMethodDecls that already starts with a macro. This should make - // it easier to rerun the tool to find missing macros. - Stmt *Body = Decl->getBody(); - for (auto &C : Body->children()) { - if (C->getBeginLoc().isMacroID()) - return false; - break; - } - // Print 'bool' instead of '_Bool'. PrintingPolicy Policy(Context.getLangOpts()); Policy.Bool = true; - // Unsupported signatures get a dummy macro. - bool ShouldInsertDummy = false; - // Collect the functions parameter types and names. - std::vector<std::string> ParamTypes; std::vector<std::string> ParamNames; - for (auto *P : Decl->parameters()) { - QualType T = P->getType(); - ParamTypes.push_back(T.getAsString(Policy)); + if (!Decl->isStatic()) + ParamNames.push_back("this"); + for (auto *P : Decl->parameters()) ParamNames.push_back(P->getNameAsString()); - // Currently we don't support functions that have function pointers as an - // argument, in which case we insert a dummy macro. - ShouldInsertDummy |= T->isFunctionPointerType(); - } - - // Convert the two lists to string for the macros. - std::string ParamTypesStr = llvm::join(ParamTypes, ", "); - std::string ParamNamesStr = llvm::join(ParamNames, ", "); - - CXXRecordDecl *Record = Decl->getParent(); - QualType ReturnType = Decl->getReturnType(); - // Construct the macros. - std::string Macro; - if (ShouldInsertDummy) { - // Don't insert a register call for dummy macros. - Macro = GetRecordDummyMacro( - ReturnType.getAsString(Policy), Record->getNameAsString(), - Decl->getNameAsString(), ParamTypesStr, ParamNamesStr); - - } else if (isa<CXXConstructorDecl>(Decl)) { - llvm::outs() << GetRegisterConstructorMacro(Record->getNameAsString(), - ParamTypesStr); - - Macro = GetRecordConstructorMacro(Record->getNameAsString(), - ParamTypesStr, ParamNamesStr); + std::string Buffer; + llvm::raw_string_ostream Macro(Buffer); + if (ParamNames.empty()) { + Macro << "LLDB_INSTRUMENT()"; } else { - llvm::outs() << GetRegisterMethodMacro( - ReturnType.getAsString(Policy), Record->getNameAsString(), - Decl->getNameAsString(), ParamTypesStr, Decl->isStatic(), - Decl->isConst()); - - Macro = GetRecordMethodMacro( - ReturnType.getAsString(Policy), Record->getNameAsString(), - Decl->getNameAsString(), ParamTypesStr, ParamNamesStr, - Decl->isStatic(), Decl->isConst()); + Macro << "LLDB_INSTRUMENT_VA(" << llvm::join(ParamNames, ", ") << ")"; } - // Insert the macro at the beginning of the function. We don't attempt to - // fix the formatting and instead rely on clang-format to fix it after the - // tool has run. This is also the reason that the macros end with two - // newlines, counting on clang-format to normalize this in case the macro - // got inserted before an existing newline. - SourceLocation InsertLoc = Lexer::getLocForEndOfToken( - Body->getBeginLoc(), 0, MyRewriter.getSourceMgr(), - MyRewriter.getLangOpts()); - MyRewriter.InsertTextAfter(InsertLoc, Macro); - - // If the function returns a class or struct, we need to wrap its return - // statement(s). - bool ShouldRecordResult = ReturnType->isStructureOrClassType() || - ReturnType->getPointeeCXXRecordDecl(); - if (!ShouldInsertDummy && ShouldRecordResult) { - SBReturnVisitor Visitor(MyRewriter); - Visitor.TraverseDecl(Decl); + Stmt *Body = Decl->getBody(); + for (auto &C : Body->children()) { + if (C->getBeginLoc().isMacroID()) { + CharSourceRange Range = + MyRewriter.getSourceMgr().getExpansionRange(C->getSourceRange()); + MyRewriter.ReplaceText(Range, Macro.str()); + } else { + Macro << ";"; + SourceLocation InsertLoc = Lexer::getLocForEndOfToken( + Body->getBeginLoc(), 0, MyRewriter.getSourceMgr(), + MyRewriter.getLangOpts()); + MyRewriter.InsertTextAfter(InsertLoc, Macro.str()); + } + break; } return true; @@ -321,15 +139,9 @@ class SBAction : public ASTFrontendAction { public: SBAction() = default; - bool BeginSourceFileAction(CompilerInstance &CI) override { - llvm::outs() << "{\n"; - return true; - } + bool BeginSourceFileAction(CompilerInstance &CI) override { return true; } - void EndSourceFileAction() override { - llvm::outs() << "}\n"; - MyRewriter.overwriteChangedFiles(); - } + void EndSourceFileAction() override { MyRewriter.overwriteChangedFiles(); } std::unique_ptr<ASTConsumer> CreateASTConsumer(CompilerInstance &CI, StringRef File) override { diff --git a/lldb/tools/lldb-server/lldb-gdbserver.cpp b/lldb/tools/lldb-server/lldb-gdbserver.cpp index 906ae4c378b6..7648a0bb668d 100644 --- a/lldb/tools/lldb-server/lldb-gdbserver.cpp +++ b/lldb/tools/lldb-server/lldb-gdbserver.cpp @@ -27,6 +27,7 @@ #include "lldb/Host/Socket.h" #include "lldb/Host/common/NativeProcessProtocol.h" #include "lldb/Target/Process.h" +#include "lldb/Utility/Logging.h" #include "lldb/Utility/Status.h" #include "llvm/ADT/StringRef.h" #include "llvm/Option/ArgList.h" |