Message ID | 1468662521-17780-1-git-send-email-thomas.petazzoni@free-electrons.com |
---|---|
State | Superseded |
Headers | show |
Thomas, On Sat, Jul 16, 2016 at 11:48 AM, Thomas Petazzoni <thomas.petazzoni@free-electrons.com> wrote: > Guard the usage of execinfo.h by INTEGCK_DEBUG so that by defaut, > integck builds properly on systems without <execinfo.h> (uClibc and > musl based systems). As stated in the code, the backtrace() > functionality of <execinfo.h> will anyway only work properly when > INTEGCK_DEBUG is defined (it makes all functions non-static, which is > needed for backtrace to provide some useful information). But this means in uClibc and musl systems INTEGCK_DEBUG is still not usable, right? Instead of papering over the issue we should bite the bullet and add a libmissing to mtd-utils to same functionality across all kind of libcs. IOW when mtd-utils is built against non-glibc we add -lmissing to the compiler command line.
Hello, On Sat, 16 Jul 2016 15:31:15 +0200, Richard Weinberger wrote: > But this means in uClibc and musl systems INTEGCK_DEBUG is still not > usable, right? Correct. > Instead of papering over the issue we should bite the bullet and add a > libmissing to mtd-utils to same functionality across all kind of libcs. I'm not sure you really want a copy in libmissing of the backtrace functionality. It would be so much better if mtd-utils were using autoconf to automatically detect the availability of execinfo.h, and adjust the functionality accordingly. Indeed, having the backtrace is useful, but is also not mandatory to use integck. Thomas
Thomas, On Sat, Jul 16, 2016 at 3:34 PM, Thomas Petazzoni <thomas.petazzoni@free-electrons.com> wrote: > Hello, > > On Sat, 16 Jul 2016 15:31:15 +0200, Richard Weinberger wrote: > >> But this means in uClibc and musl systems INTEGCK_DEBUG is still not >> usable, right? > > Correct. > >> Instead of papering over the issue we should bite the bullet and add a >> libmissing to mtd-utils to same functionality across all kind of libcs. > > I'm not sure you really want a copy in libmissing of the backtrace > functionality. It is not only backtraceing, there are more features we gave up in favor to non-glibc. Using a libmissing we could better deal with that. This is patch is by far not the first one to make mtd-utils work/build on non-glibc systems. > It would be so much better if mtd-utils were using autoconf to > automatically detect the availability of execinfo.h, and adjust the > functionality accordingly. Indeed, having the backtrace is useful, but > is also not mandatory to use integck. David is currently reviving my autoconf patch. That's why we're currently thinking of mechanisms to make mtd-utils better.
diff --git a/tests/fs-tests/integrity/integck.c b/tests/fs-tests/integrity/integck.c index 8badd1f..6ef817e 100644 --- a/tests/fs-tests/integrity/integck.c +++ b/tests/fs-tests/integrity/integck.c @@ -31,7 +31,9 @@ #include <getopt.h> #include <assert.h> #include <mntent.h> +#ifdef INTEGCK_DEBUG #include <execinfo.h> +#endif #include <bits/stdio_lim.h> #include <sys/mman.h> #include <sys/vfs.h> @@ -248,14 +250,18 @@ static char *random_name_buf; static void check_failed(const char *cond, const char *func, const char *file, int line) { - int error = errno, count; + int error = errno; +#ifdef INTEGCK_DEBUG + int count; void *addresses[128]; +#endif fflush(stdout); fflush(stderr); errmsg("condition '%s' failed in %s() at %s:%d", cond, func, file, line); normsg("error %d (%s)", error, strerror(error)); +#ifdef INTEGCK_DEBUG /* * Note, to make this work well you need: * 1. Make all functions non-static - add "#define static' @@ -264,6 +270,7 @@ static void check_failed(const char *cond, const char *func, const char *file, */ count = backtrace(addresses, 128); backtrace_symbols_fd(addresses, count, fileno(stdout)); +#endif exit(EXIT_FAILURE); }
Guard the usage of execinfo.h by INTEGCK_DEBUG so that by defaut, integck builds properly on systems without <execinfo.h> (uClibc and musl based systems). As stated in the code, the backtrace() functionality of <execinfo.h> will anyway only work properly when INTEGCK_DEBUG is defined (it makes all functions non-static, which is needed for backtrace to provide some useful information). Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com> --- tests/fs-tests/integrity/integck.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)