JDevlieghere created this revision. JDevlieghere added reviewers: mib, friss, jasonmolenda. JDevlieghere added a project: LLDB. JDevlieghere requested review of this revision.
Add an option to not present the TCC dialog on behalf of the inferior. The motivation is the scenario of running the LLDB test suite from an external hard drive. If the inferior is responsible, every test needs to be granted access to the external volume. If LLDB takes responsibility, approval needs to be granted only once. https://reviews.llvm.org/D85237 Files: lldb/include/lldb/Target/Target.h lldb/include/lldb/lldb-enumerations.h lldb/packages/Python/lldbsuite/test/lldbtest.py lldb/source/Commands/CommandObjectProcess.cpp lldb/source/Host/macosx/objcxx/Host.mm lldb/source/Target/Target.cpp lldb/source/Target/TargetProperties.td lldb/test/Shell/lit-lldb-init.in
Index: lldb/test/Shell/lit-lldb-init.in =================================================================== --- lldb/test/Shell/lit-lldb-init.in +++ lldb/test/Shell/lit-lldb-init.in @@ -4,3 +4,4 @@ settings set interpreter.echo-comment-commands false settings set symbols.clang-modules-cache-path "@LLDB_TEST_MODULE_CACHE_LLDB@" settings set target.auto-apply-fixits false +settings set target.disable-tcc true Index: lldb/source/Target/TargetProperties.td =================================================================== --- lldb/source/Target/TargetProperties.td +++ lldb/source/Target/TargetProperties.td @@ -111,6 +111,9 @@ def DisableSTDIO: Property<"disable-stdio", "Boolean">, DefaultFalse, Desc<"Disable stdin/stdout for process (e.g. for a GUI application)">; + def DisableTCC: Property<"disable-tcc", "Boolean">, + DefaultFalse, + Desc<"Disable making the inferior responsible for the TCC prompt.">; def InlineStrategy: Property<"inline-breakpoint-strategy", "Enum">, DefaultEnumValue<"eInlineBreakpointsAlways">, EnumValues<"OptionEnumValues(g_inline_breakpoint_enums)">, Index: lldb/source/Target/Target.cpp =================================================================== --- lldb/source/Target/Target.cpp +++ lldb/source/Target/Target.cpp @@ -3430,6 +3430,8 @@ }); m_collection_sp->SetValueChangedCallback( ePropertyDisableASLR, [this] { DisableASLRValueChangedCallback(); }); + m_collection_sp->SetValueChangedCallback( + ePropertyDisableTCC, [this] { DisableTCCValueChangedCallback(); }); m_collection_sp->SetValueChangedCallback( ePropertyDisableSTDIO, [this] { DisableSTDIOValueChangedCallback(); }); @@ -3468,6 +3470,7 @@ ErrorPathValueChangedCallback(); DetachOnErrorValueChangedCallback(); DisableASLRValueChangedCallback(); + DisableTCCValueChangedCallback(); DisableSTDIOValueChangedCallback(); } @@ -3550,6 +3553,17 @@ m_collection_sp->SetPropertyAtIndexAsBoolean(nullptr, idx, b); } +bool TargetProperties::GetDisableTCC() const { + const uint32_t idx = ePropertyDisableTCC; + return m_collection_sp->GetPropertyAtIndexAsBoolean( + nullptr, idx, g_target_properties[idx].default_uint_value != 0); +} + +void TargetProperties::SetDisableTCC(bool b) { + const uint32_t idx = ePropertyDisableTCC; + m_collection_sp->SetPropertyAtIndexAsBoolean(nullptr, idx, b); +} + bool TargetProperties::GetDetachOnError() const { const uint32_t idx = ePropertyDetachOnError; return m_collection_sp->GetPropertyAtIndexAsBoolean( @@ -3941,6 +3955,8 @@ } SetDetachOnError(launch_info.GetFlags().Test(lldb::eLaunchFlagDetachOnError)); SetDisableASLR(launch_info.GetFlags().Test(lldb::eLaunchFlagDisableASLR)); + SetDisableTCC( + launch_info.GetFlags().Test(lldb::eLaunchFlagDisableInferiorTCC)); SetDisableSTDIO(launch_info.GetFlags().Test(lldb::eLaunchFlagDisableSTDIO)); } @@ -4004,6 +4020,13 @@ m_launch_info.GetFlags().Clear(lldb::eLaunchFlagDisableASLR); } +void TargetProperties::DisableTCCValueChangedCallback() { + if (GetDisableTCC()) + m_launch_info.GetFlags().Set(lldb::eLaunchFlagDisableInferiorTCC); + else + m_launch_info.GetFlags().Clear(lldb::eLaunchFlagDisableInferiorTCC); +} + void TargetProperties::DisableSTDIOValueChangedCallback() { if (GetDisableSTDIO()) m_launch_info.GetFlags().Set(lldb::eLaunchFlagDisableSTDIO); Index: lldb/source/Host/macosx/objcxx/Host.mm =================================================================== --- lldb/source/Host/macosx/objcxx/Host.mm +++ lldb/source/Host/macosx/objcxx/Host.mm @@ -1098,7 +1098,8 @@ // When lldb is ran through a graphical session, this makes the debuggee // process responsible for the TCC prompts. Otherwise, lldb will use the // launching process privileges. - if (is_graphical && launch_info.GetFlags().Test(eLaunchFlagDebug)) { + if (is_graphical && launch_info.GetFlags().Test(eLaunchFlagDebug) && + !launch_info.GetFlags().Test(eLaunchFlagDisableInferiorTCC)) { error.SetError(setup_posix_spawn_responsible_flag(&attr), eErrorTypePOSIX); if (error.Fail()) { LLDB_LOG(log, "error: {0}, setup_posix_spawn_responsible_flag(&attr)", Index: lldb/source/Commands/CommandObjectProcess.cpp =================================================================== --- lldb/source/Commands/CommandObjectProcess.cpp +++ lldb/source/Commands/CommandObjectProcess.cpp @@ -184,6 +184,9 @@ else m_options.launch_info.GetFlags().Clear(eLaunchFlagDisableASLR); + if (target->GetDisableTCC()) + m_options.launch_info.GetFlags().Set(eLaunchFlagDisableInferiorTCC); + if (target->GetDetachOnError()) m_options.launch_info.GetFlags().Set(eLaunchFlagDetachOnError); Index: lldb/packages/Python/lldbsuite/test/lldbtest.py =================================================================== --- lldb/packages/Python/lldbsuite/test/lldbtest.py +++ lldb/packages/Python/lldbsuite/test/lldbtest.py @@ -717,6 +717,9 @@ # differ in the debug info, which is not being hashed. "settings set symbols.enable-external-lookup false", + # Make the debugger responsible for the TCC dialog. + "settings set target.disable-tcc true", + # Disable fix-its by default so that incorrect expressions in tests don't # pass just because Clang thinks it has a fix-it. "settings set target.auto-apply-fixits false", Index: lldb/include/lldb/lldb-enumerations.h =================================================================== --- lldb/include/lldb/lldb-enumerations.h +++ lldb/include/lldb/lldb-enumerations.h @@ -126,6 +126,9 @@ eLaunchFlagShellExpandArguments = (1u << 10), ///< Perform shell-style argument expansion eLaunchFlagCloseTTYOnExit = (1u << 11), ///< Close the open TTY on exit + eLaunchFlagDisableInferiorTCC = + (1u << 12), ///< Make the debugger instead of the inferior responsible + ///< for the TCC prompt on macOS. }; /// Thread Run Modes. Index: lldb/include/lldb/Target/Target.h =================================================================== --- lldb/include/lldb/Target/Target.h +++ lldb/include/lldb/Target/Target.h @@ -93,6 +93,10 @@ void SetDisableASLR(bool b); + bool GetDisableTCC() const; + + void SetDisableTCC(bool b); + bool GetDetachOnError() const; void SetDetachOnError(bool b); @@ -225,6 +229,7 @@ void ErrorPathValueChangedCallback(); void DetachOnErrorValueChangedCallback(); void DisableASLRValueChangedCallback(); + void DisableTCCValueChangedCallback(); void DisableSTDIOValueChangedCallback(); Environment ComputeEnvironment() const;
_______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits