diff options
author | Robert Griebl <robert.griebl@qt.io> | 2022-05-15 01:19:58 +0200 |
---|---|---|
committer | Robert Griebl <robert.griebl@qt.io> | 2022-05-17 20:14:21 +0200 |
commit | c64ed3321fd7a4fab5b046ce7d1c81cf61aed301 (patch) | |
tree | 7a1b77b34a9c62fd724dea3ba89bcc738532d16f | |
parent | 8ba47c18814ba4178cdafa05953c79701b012516 (diff) | |
download | qtapplicationmanager-c64ed3321fd7a4fab5b046ce7d1c81cf61aed301.tar.gz |
Document all environment variables
Also make sure to check the values against what is actually documented.
Also make sure to forward all relevant variables to apps, even if they
might be running in custom containers.
Change-Id: Ie016383d49ed5fc575fadc32087ed585efc5ce99
Reviewed-by: Dominik Holland <dominik.holland@qt.io>
-rw-r--r-- | doc/container.qdoc | 2 | ||||
-rw-r--r-- | doc/debugging.qdoc | 28 | ||||
-rw-r--r-- | src/common-lib/crashhandler.cpp | 2 | ||||
-rw-r--r-- | src/common-lib/logging.cpp | 4 | ||||
-rw-r--r-- | src/main-lib/configuration.cpp | 22 | ||||
-rw-r--r-- | src/manager-lib/nativeruntime.cpp | 9 | ||||
-rw-r--r-- | src/tools/launcher-qml/launcher-qml.cpp | 2 |
7 files changed, 53 insertions, 16 deletions
diff --git a/doc/container.qdoc b/doc/container.qdoc index 1135194f..29fa7bad 100644 --- a/doc/container.qdoc +++ b/doc/container.qdoc @@ -143,7 +143,7 @@ the application. A custom container plugin must forward these variables or adjus \li A YAML, UTF-8 string encoded version of the \l{amConfigDetails}{amConfig} map. \row \li \c{AM_NO_DLT_LOGGING} - \li Tells the application to not use DLT for logging. + \li Tells the application to not use DLT for logging, if set to \c 1. \endtable \section1 Configuration diff --git a/doc/debugging.qdoc b/doc/debugging.qdoc index 56eac81b..8f8860ed 100644 --- a/doc/debugging.qdoc +++ b/doc/debugging.qdoc @@ -56,18 +56,24 @@ This is a (incomplete) list of environment variables that influence the logging \li Variable \li Description \row + \li AM_NO_CUSTOM_LOGGING + \li If set to \c 1, debug output is not redirected to DLT, colorized or nicely formatted. +\row + \li AM_NO_DLT_LOGGING + \li If set to \c 1, debug output is not redirected to DLT. +\row \li AM_STARTUP_TIMER - \li If set to 1, a startup performance analysis is printed on the console. Anything other than - 1 is interpreted as the name of a file to use, instead of the console. For more + \li If set to \c 1, a startup performance analysis is printed to the console. Anything other + than \c 1 is interpreted as the name of a file to use, instead of the console. For more information, see StartupTimer. \row \li AM_FORCE_COLOR_OUTPUT \li Can be set to \c on to force color output to the console or to \c off to disable it. Any - other value results in the default, auto-detection behavior. + other value enables the default, auto-detection behavior. \row \li AM_TIMEOUT_FACTOR \li An integer factor that slows down all timed wait statements within the application manager. - Useful if running in slow wrappers, such as Valgrind. The default value is \c 1. + Useful if running in slow wrappers, such as Valgrind. The default value is \c 1. \row \li QT_MESSAGE_PATTERN \li Setting this variable has the same effect as described in @@ -104,6 +110,20 @@ with the \c --qml-debug argument. For more information, see \l{QML Debugging Inf tasks only. They are also useful for various other tasks that involve running the application under test through a wrapper, like profiling tools. +\section2 Environment Variables + +This is a (incomplete) list of environment variables that influence debugging at runtime: + +\table +\header + \li Variable + \li Description +\row + \li AM_NO_CRASH_HANDLER + \li If set to \c 1, no crash handler is installed. Use this, if the application manager's + crash handler is interfering with other debugging tools you are using. +\endtable + \target DebugWrappers \section2 Use Debug Wrappers diff --git a/src/common-lib/crashhandler.cpp b/src/common-lib/crashhandler.cpp index a00bd93a..9cc8d465 100644 --- a/src/common-lib/crashhandler.cpp +++ b/src/common-lib/crashhandler.cpp @@ -160,7 +160,7 @@ static void initBacktrace() // uncaught std::exception derived exception (prints what()) // throw std::logic_error("test output"); - if (qEnvironmentVariableIsSet("AM_NO_CRASH_HANDLER")) + if (qEnvironmentVariableIntValue("AM_NO_CRASH_HANDLER") == 1) return; chg()->consoleInitialized = Console::ensureInitialized(); // enforce instantiation of both diff --git a/src/common-lib/logging.cpp b/src/common-lib/logging.cpp index 00cb47db..bca20a89 100644 --- a/src/common-lib/logging.cpp +++ b/src/common-lib/logging.cpp @@ -392,13 +392,13 @@ void Logging::initialize() void Logging::initialize(int argc, const char * const *argv) { - if (qEnvironmentVariableIsSet("AM_NO_CUSTOM_LOGGING")) { + if (qEnvironmentVariableIntValue("AM_NO_CUSTOM_LOGGING") == 1) { lg()->noCustomLogging = true; lg()->dltEnabled = false; return; } - if (qEnvironmentVariableIsSet("AM_NO_DLT_LOGGING")) + if (qEnvironmentVariableIntValue("AM_NO_DLT_LOGGING") == 1) lg()->dltEnabled = false; bool instantLogging = false; diff --git a/src/main-lib/configuration.cpp b/src/main-lib/configuration.cpp index 68f99b91..87fa4825 100644 --- a/src/main-lib/configuration.cpp +++ b/src/main-lib/configuration.cpp @@ -130,13 +130,23 @@ Configuration::Configuration(const QStringList &defaultConfigFilePaths, const char *description = "In addition to the command line options below, the following environment\n" "variables can be set:\n\n" - " AM_STARTUP_TIMER If set to 1, a startup performance analysis will be printed\n" - " on the console. Anything other than 1 will be interpreted\n" - " as the name of a file that is used instead of the console.\n" + " AM_STARTUP_TIMER If set to '1', a startup performance analysis is\n" + " printed to the console. Anything other than '1' is\n" + " interpreted as the name of a file to use, instead\n" + " of the console.\n" "\n" - " AM_FORCE_COLOR_OUTPUT Can be set to 'on' to force color output to the console\n" - " and to 'off' to disable it. Any other value will result\n" - " in the default, auto-detection behavior.\n"; + " AM_FORCE_COLOR_OUTPUT Can be set to 'on' to force color output to the\n" + " console and to 'off' to disable it. Any other value\n" + " enables the default, auto-detection behavior.\n" + "\n" + " AM_NO_CUSTOM_LOGGING If set to '1', debug output is not redirected to DLT,\n" + " colorized or nicely formatted.\n" + "\n" + " AM_NO_DLT_LOGGING If set to '1', debug output is not redirected to DLT.\n" + "\n" + " AM_NO_CRASH_HANDLER If set to '1', no crash handler is installed. Use\n" + " this, if the application manager's crash handler is\n" + " interfering with other debugging tools you are using.\n"; m_clp.setApplicationDescription(qSL("\n") + QCoreApplication::applicationName() + qSL("\n\n") + (additionalDescription ? (qL1S(additionalDescription) + qSL("\n\n")) : QString()) diff --git a/src/manager-lib/nativeruntime.cpp b/src/manager-lib/nativeruntime.cpp index 1ddb40fe..296d57a9 100644 --- a/src/manager-lib/nativeruntime.cpp +++ b/src/manager-lib/nativeruntime.cpp @@ -307,8 +307,15 @@ bool NativeRuntime::start() { qSL("QT_WAYLAND_SHELL_INTEGRATION"), qSL("xdg-shell")}, }; + for (const auto *var : { + "AM_STARTUP_TIMER", "AM_NO_CUSTOM_LOGGING", "AM_NO_CRASH_HANDLER", "AM_FORCE_COLOR_OUTPUT", + "AM_TIMEOUT_FACTOR", "QT_MESSAGE_PATTERN" }) { + if (qEnvironmentVariableIsSet(var)) + env.insert(QString::fromLatin1(var), qEnvironmentVariable(var)); + } + if (!Logging::isDltEnabled()) { - // sadly we still need this, since we need to disable DLT as soon as possible + // we need this to disable DLT as soon as possible env.insert(qSL("AM_NO_DLT_LOGGING"), qSL("1")); } diff --git a/src/tools/launcher-qml/launcher-qml.cpp b/src/tools/launcher-qml/launcher-qml.cpp index 3baddb6f..41933f1d 100644 --- a/src/tools/launcher-qml/launcher-qml.cpp +++ b/src/tools/launcher-qml/launcher-qml.cpp @@ -108,7 +108,7 @@ int main(int argc, char *argv[]) QCoreApplication::setOrganizationDomain(qSL("qt-project.org")); QCoreApplication::setApplicationVersion(qSL(AM_VERSION)); - if (qEnvironmentVariableIsSet("AM_NO_DLT_LOGGING")) + if (qEnvironmentVariableIntValue("AM_NO_DLT_LOGGING") == 1) Logging::setDltEnabled(false); // The common-lib is already registering the DLT Application for the application manager. |