Bug 1791481 - Avoid tail-call optimization of call to GetAndCheckStackTrace. r=mstange

While here, change the gtest to display how many tests passed.

Differential Revision: https://phabricator.services.mozilla.com/D157888
This commit is contained in:
Mike Hommey 2022-10-04 05:16:06 +00:00
Родитель 8d11692199
Коммит cbd2293129
3 изменённых файлов: 9 добавлений и 7 удалений

Просмотреть файл

@ -1560,7 +1560,7 @@ static __attribute__((noinline)) unsigned long __getpc(void) {
// This function must not be inlined into its callers. Doing so will
// cause the expected-vs-actual backtrace consistency checking to
// fail. Prints summary results to |aLUL|'s logging sink and also
// returns a boolean indicating whether or not the test passed.
// returns a boolean indicating whether or not the test failed.
static __attribute__((noinline)) bool GetAndCheckStackTrace(
LUL* aLUL, const char* dstring) {
// Get hold of the current unwind-start registers.
@ -1790,7 +1790,7 @@ static __attribute__((noinline)) bool GetAndCheckStackTrace(
buf[sizeof(buf) - 1] = 0;
aLUL->mLog(buf);
return passed;
return !passed;
}
// Macro magic to create a set of 8 mutually recursive functions with
@ -1819,7 +1819,8 @@ static __attribute__((noinline)) bool GetAndCheckStackTrace(
if (*strP == '\0') { \
/* We've come to the end of the director string. */ \
/* Take a stack snapshot. */ \
return GetAndCheckStackTrace(aLUL, strPorig); \
/* We purposefully use a negation to avoid tail-call optimization */ \
return !GetAndCheckStackTrace(aLUL, strPorig); \
} else { \
/* Recurse onwards. This is a bit subtle. The obvious */ \
/* thing to do here is call onwards directly, from within the */ \

Просмотреть файл

@ -1681,7 +1681,7 @@ static __attribute__((noinline)) unsigned long __getpc(void) {
// This function must not be inlined into its callers. Doing so will
// cause the expected-vs-actual backtrace consistency checking to
// fail. Prints summary results to |aLUL|'s logging sink and also
// returns a boolean indicating whether or not the test passed.
// returns a boolean indicating whether or not the test failed.
static __attribute__((noinline)) bool GetAndCheckStackTrace(
LUL* aLUL, const char* dstring) {
// Get hold of the current unwind-start registers.
@ -1911,7 +1911,7 @@ static __attribute__((noinline)) bool GetAndCheckStackTrace(
buf[sizeof(buf) - 1] = 0;
aLUL->mLog(buf);
return passed;
return !passed;
}
// Macro magic to create a set of 8 mutually recursive functions with
@ -1940,7 +1940,8 @@ static __attribute__((noinline)) bool GetAndCheckStackTrace(
if (*strP == '\0') { \
/* We've come to the end of the director string. */ \
/* Take a stack snapshot. */ \
return GetAndCheckStackTrace(aLUL, strPorig); \
/* We purposefully use a negation to avoid tail-call optimization */ \
return !GetAndCheckStackTrace(aLUL, strPorig); \
} else { \
/* Recurse onwards. This is a bit subtle. The obvious */ \
/* thing to do here is call onwards directly, from within the */ \

Просмотреть файл

@ -45,7 +45,7 @@ TEST(LulIntegration, unwind_consistency)
int nTests = 0, nTestsPassed = 0;
RunLulUnitTests(&nTests, &nTestsPassed, lul);
EXPECT_TRUE(nTests == 6) << "Unexpected number of tests";
EXPECT_TRUE(nTestsPassed == nTests) << "Not all tests passed";
EXPECT_EQ(nTestsPassed, nTests) << "Not all tests passed";
delete lul;
}