1
0
mirror of https://github.com/pgbackrest/pgbackrest.git synced 2026-05-22 10:15:16 +02:00

Improve libbacktrace implementation.

The libbacktrace feature has not been working since the move to meson because libbacktrace detection was not added to the meson build. Add libbacktrace to meson and improve the feature so that it can be compiled into release builds.

The prior implementation fetched line numbers with each stack trace push. Not only was this slow but it missed any functions that were not being tracked on our stack.

Instead just examine the backtrace when an error happens and merge it with the info we have on our stack. If the backtrace is not available then the output remains as before.

Also remove --backtrace from test.pl since the library is now auto-detected.

Leave this library out of the production build for now to give it a little time to shake out in testing.
This commit is contained in:
David Steele
2023-01-11 11:19:26 +07:00
parent 0dd2997714
commit c826429123
16 changed files with 348 additions and 115 deletions
+4 -11
View File
@@ -84,7 +84,6 @@ test.pl [options]
--no-coverage don't run coverage on C unit tests (saves time)
--no-coverage-report run coverage but don't generate coverage report (saves time)
--no-optimize don't do compile optimization for C (saves compile time)
--backtrace enable backtrace when available (adds stack trace line numbers -- very slow)
--profile generate profile info
--no-debug don't generate a debug build
--scale scale performance tests
@@ -158,7 +157,6 @@ my $bGenOnly = false;
my $bGenCheck = false;
my $bMinGen = false;
my $bCodeCount = false;
my $bBackTrace = false;
my $bProfile = false;
my $bNoValgrind = false;
my $bNoOptimize = false;
@@ -208,7 +206,6 @@ GetOptions ('q|quiet' => \$bQuiet,
'gen-check' => \$bGenCheck,
'min-gen' => \$bMinGen,
'code-count' => \$bCodeCount,
'backtrace' => \$bBackTrace,
'profile' => \$bProfile,
'no-valgrind' => \$bNoValgrind,
'no-optimize' => \$bNoOptimize,
@@ -729,12 +726,9 @@ eval
$rhBinBuild->{$strBuildVM} = false;
# Build configure/compile options and see if they have changed from the previous build
my $strCFlags =
(vmWithBackTrace($strBuildVM) && $bBackTrace ? ' -DWITH_BACKTRACE' : '') .
($bDebugTestTrace ? ' -DDEBUG_TEST_TRACE' : '');
my $strLdFlags = vmWithBackTrace($strBuildVM) && $bBackTrace ? '-lbacktrace' : '';
my $strCFlags = ($bDebugTestTrace ? ' -DDEBUG_TEST_TRACE' : '');
my $strConfigOptions = (vmDebugIntegration($strBuildVM) ? ' --enable-test' : '');
my $strBuildFlags = "CFLAGS_EXTRA=${strCFlags}\nLDFLAGS_EXTRA=${strLdFlags}\nCONFIGURE=${strConfigOptions}";
my $strBuildFlags = "CFLAGS_EXTRA=${strCFlags}\nCONFIGURE=${strConfigOptions}";
my $strBuildFlagFile = "${strBinPath}/${strBuildVM}/build.flags";
my $bBuildOptionsDiffer = buildPutDiffers($oStorageBackRest, $strBuildFlagFile, $strBuildFlags);
@@ -760,8 +754,7 @@ eval
executeTest(
'docker exec -i -u ' . TEST_USER . ' test-build ' .
"${strMakeCmd} -s -j ${iBuildMax}" . ($bLogDetail ? '' : ' --silent') .
" --directory ${strBuildPath} CFLAGS_EXTRA='${strCFlags}'" .
($strLdFlags ne '' ? " LDFLAGS_EXTRA='${strLdFlags}'" : ''),
" --directory ${strBuildPath} CFLAGS_EXTRA='${strCFlags}'",
{bShowOutputAsync => $bLogDetail});
}
}
@@ -1062,7 +1055,7 @@ eval
$oStorageTest, $strBackRestBase, $strTestPath, $$oyTestRun[$iTestIdx], $bDryRun, $bVmOut, $iVmIdx, $iVmMax,
$strMakeCmd, $iTestIdx, $iTestMax, $strLogLevel, $strLogLevelTest, $strLogLevelTestFile, !$bNoLogTimestamp,
$bShowOutputAsync, $bNoCleanup, $iRetry, !$bNoValgrind, !$bNoCoverage, $bCoverageSummary, !$bNoOptimize,
$bBackTrace, $bProfile, $iScale, $strTimeZone, !$bNoDebug, $bDebugTestTrace,
$bProfile, $iScale, $strTimeZone, !$bNoDebug, $bDebugTestTrace,
$iBuildMax / $iVmMax < 1 ? 1 : int($iBuildMax / $iVmMax));
$iTestIdx++;