tst_qmessagehandler: disable the backtrace tests outside of x86

As the comment says, on most RISC platforms, the return address need not
be on the stack in the first place. In fact, in all ones currently
supported by Qt, it's passed in a register to the callee, which has the
option of simply saving it in a callee-save register when calling leaf
functions. Even if it is using a frame pointer, the compiler can simply
use any register. That means unwinding the stack is not possible in the
absence of either debug information or stack-unwind information, neither
of which backtrace(3) will use.

Strictly speaking, even on x86 the compiler can use the RBP register for
any purpose and thus make getting the backtrace() impossible, but in
practice it seems to work.

Fixes: QTBUG-121389
Pick-to: 6.7
Change-Id: I5dd50a1a7ca5424d9e7afffd17acbd01ef916f5d
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
This commit is contained in:
Thiago Macieira 2024-01-22 09:56:14 -08:00
parent dc2ae08e02
commit 03f1ea3dcb

View File

@ -802,6 +802,10 @@ void tst_qmessagehandler::qMessagePattern_data()
#ifdef __GLIBC__
# if QT_CONFIG(static)
// These test cases don't work with static Qt builds
# elif !defined(Q_PROCESSOR_X86)
// On most RISC platforms, call frames do not have to be stored to the
// stack (the return pointer may be saved in any callee-saved register), so
// this test isn't reliable.
# elif defined(QT_ASAN_ENABLED)
// These tests produce far more call frames under ASan
# else
@ -812,10 +816,9 @@ void tst_qmessagehandler::qMessagePattern_data()
"[MyClass::myFunction|MyClass::mySlot1|?" BACKTRACE_HELPER_NAME "?|",
// QMetaObject::invokeMethodImpl calls internal function
// (QMetaMethodPrivate::invokeImpl, at the tims of this writing), which
// (QMetaMethodPrivate::invokeImpl, at the time of this writing), which
// will usually show only as ?libQt6Core.so? or equivalent, so we skip
// end of backtrace, actual message
"|" QT_NAMESPACE_STR "QMetaObject::invokeMethodImpl] from_a_function 34"
};
QTest::newRow("backtrace") << "[%{backtrace}] %{message}" << true << expectedBacktrace;