[4/4,libbacktrace] Add tests for unused formats

Message ID 20181123205612.GA3609@delia
State New
Headers show
Series
  • Untitled series #9284
Related show

Commit Message

Tom de Vries Nov. 23, 2018, 8:56 p.m.
Hi,

When building libbacktrace, we typically use elf.c, and don't build pecoff.c,
xcoff.c or unknown.c

Add testcases that use unused format to ensure that we also build and
test those on a typical development setup.

Bootstrapped and reg-tested on x86_64.

OK for trunk?

Thanks,
- Tom

[libbacktrace] Add tests for unused formats

2018-11-23  Tom de Vries  <tdevries@suse.de>

	* configure.ac (NOT_HAVE_FORMAT_ELF, NOT_HAVE_FORMAT_PECOFF)
	(NOT_HAVE_FORMAT_UNKNOWN, NOT_HAVE_FORMAT_XCOFF_32)
	(NOT_HAVE_FORMAT_XCOFF_64): New AM_CONDITIONAL.
	* configure: Regenerate.
	* Makefile.am (check_PROGRAMS): Add test_elf, test_xcoff_32,
	test_xcoff_64, test_pecoff and test_unknown.
	* Makefile.in: Regenerate.
	* test_format.c: New file.

---
 libbacktrace/Makefile.am   |  40 ++++++++++
 libbacktrace/Makefile.in   | 182 +++++++++++++++++++++++++++++++++++++--------
 libbacktrace/configure     |  74 +++++++++++++++++-
 libbacktrace/configure.ac  |   5 ++
 libbacktrace/test_format.c |  55 ++++++++++++++
 5 files changed, 322 insertions(+), 34 deletions(-)

Comments

Tom de Vries Nov. 28, 2018, 12:33 p.m. | #1
On 23-11-18 21:56, Tom de Vries wrote:
> Hi,

> 

> When building libbacktrace, we typically use elf.c, and don't build pecoff.c,

> xcoff.c or unknown.c

> 

> Add testcases that use unused format to ensure that we also build and

> test those on a typical development setup.

> 

> Bootstrapped and reg-tested on x86_64.

> 

> OK for trunk?

> 


Hi Jeff,

to follow up on your question about relevance of the remaining patches:

If we would have had the test-cases in this patch already committed, we
would have immediately noticed that the patch I proposed here (
https://gcc.gnu.org/ml/gcc-patches/2018-11/msg01091.html ) breaks
libbacktrace for xcoff and pecoff builds.

I realized this eventually while continuing to work on PR82857, but I'd
prefer to find this sort of problem asap.

Thanks,
- Tom

> [libbacktrace] Add tests for unused formats

> 

> 2018-11-23  Tom de Vries  <tdevries@suse.de>

> 

> 	* configure.ac (NOT_HAVE_FORMAT_ELF, NOT_HAVE_FORMAT_PECOFF)

> 	(NOT_HAVE_FORMAT_UNKNOWN, NOT_HAVE_FORMAT_XCOFF_32)

> 	(NOT_HAVE_FORMAT_XCOFF_64): New AM_CONDITIONAL.

> 	* configure: Regenerate.

> 	* Makefile.am (check_PROGRAMS): Add test_elf, test_xcoff_32,

> 	test_xcoff_64, test_pecoff and test_unknown.

> 	* Makefile.in: Regenerate.

> 	* test_format.c: New file.

> 

> ---

>  libbacktrace/Makefile.am   |  40 ++++++++++

>  libbacktrace/Makefile.in   | 182 +++++++++++++++++++++++++++++++++++++--------

>  libbacktrace/configure     |  74 +++++++++++++++++-

>  libbacktrace/configure.ac  |   5 ++

>  libbacktrace/test_format.c |  55 ++++++++++++++

>  5 files changed, 322 insertions(+), 34 deletions(-)

> 

> diff --git a/libbacktrace/Makefile.am b/libbacktrace/Makefile.am

> index 4b28984c4e0..26c0b67a4c1 100644

> --- a/libbacktrace/Makefile.am

> +++ b/libbacktrace/Makefile.am

> @@ -89,6 +89,46 @@ check_PROGRAMS =

>  TESTS = $(check_PROGRAMS)

>  

>  if NATIVE

> +libbacktrace_without_format = $(libbacktrace_la_OBJECTS) \

> +	$(filter-out elf.lo pecoff.lo xcoff.lo,$(libbacktrace_la_LIBADD))

> +

> +xcoff_%.c: xcoff.c

> +	SEARCH='#error "Unknown BACKTRACE_XCOFF_SIZE"'; \

> +	REPLACE='#undef BACKTRACE_XCOFF_SIZE\n#define BACKTRACE_XCOFF_SIZE'; \

> +	$(SED) "s/^$$SEARCH\$$/$$REPLACE $*/" \

> +		$(srcdir)/xcoff.c \

> +		> $@

> +

> +if NOT_HAVE_FORMAT_ELF

> +test_elf_SOURCES = test_format.c testlib.c

> +test_elf_LDADD = $(libbacktrace_without_format) elf.lo

> +check_PROGRAMS += test_elf

> +endif

> +

> +if NOT_HAVE_FORMAT_XCOFF_32

> +test_xcoff_32_SOURCES = test_format.c xcoff_32.c testlib.c

> +test_xcoff_32_LDADD = $(libbacktrace_without_format)

> +check_PROGRAMS += test_xcoff_32

> +endif

> +

> +if NOT_HAVE_FORMAT_XCOFF_64

> +test_xcoff_64_SOURCES = test_format.c xcoff_64.c testlib.c

> +test_xcoff_64_LDADD = $(libbacktrace_without_format)

> +check_PROGRAMS += test_xcoff_64

> +endif

> +

> +if NOT_HAVE_FORMAT_PECOFF

> +test_pecoff_SOURCES = test_format.c testlib.c

> +test_pecoff_LDADD = $(libbacktrace_without_format) pecoff.lo

> +check_PROGRAMS += test_pecoff

> +endif

> +

> +if NOT_HAVE_FORMAT_UNKNOWN

> +test_unknown_SOURCES = test_format.c testlib.c

> +test_unknown_LDADD = $(libbacktrace_without_format) unknown.lo

> +check_PROGRAMS += test_unknown

> +endif

> +

>  unittest_SOURCES = unittest.c testlib.c

>  unittest_LDADD = libbacktrace.la

>  

> diff --git a/libbacktrace/Makefile.in b/libbacktrace/Makefile.in

> index c79b67636c9..6e153085e29 100644

> --- a/libbacktrace/Makefile.in

> +++ b/libbacktrace/Makefile.in

> @@ -123,21 +123,28 @@ target_triplet = @target@

>  check_PROGRAMS = $(am__EXEEXT_1) $(am__EXEEXT_2) $(am__EXEEXT_3) \

>  	$(am__EXEEXT_4) $(am__EXEEXT_5) $(am__EXEEXT_6) \

>  	$(am__EXEEXT_7) $(am__EXEEXT_8) $(am__EXEEXT_9) \

> -	$(am__EXEEXT_10) $(am__EXEEXT_11) $(am__EXEEXT_12)

> -@NATIVE_TRUE@am__append_1 = unittest btest

> -@HAVE_MMAP_TRUE@@NATIVE_TRUE@am__append_2 = btest_with_alloc

> -@NATIVE_TRUE@am__append_3 = stest

> -@HAVE_MMAP_TRUE@@NATIVE_TRUE@am__append_4 = stest_with_alloc

> -@HAVE_ZLIB_TRUE@@NATIVE_TRUE@am__append_5 = -lz

> -@NATIVE_TRUE@am__append_6 = ztest

> -@HAVE_MMAP_TRUE@@NATIVE_TRUE@am__append_7 = ztest_with_alloc

> -@NATIVE_TRUE@am__append_8 = edtest

> -@HAVE_MMAP_TRUE@@NATIVE_TRUE@am__append_9 = edtest_with_alloc

> -@HAVE_PTHREAD_TRUE@@NATIVE_TRUE@am__append_10 = ttest

> -@HAVE_MMAP_TRUE@@HAVE_PTHREAD_TRUE@@NATIVE_TRUE@am__append_11 = ttest_with_alloc

> -@HAVE_OBJCOPY_DEBUGLINK_TRUE@@NATIVE_TRUE@am__append_12 = dtest

> -@HAVE_COMPRESSED_DEBUG_TRUE@@NATIVE_TRUE@am__append_13 = ctestg ctesta

> -@HAVE_COMPRESSED_DEBUG_TRUE@@HAVE_MMAP_TRUE@@NATIVE_TRUE@am__append_14 = ctestg_with_alloc ctesta_with_alloc

> +	$(am__EXEEXT_10) $(am__EXEEXT_11) $(am__EXEEXT_12) \

> +	$(am__EXEEXT_13) $(am__EXEEXT_14) $(am__EXEEXT_15) \

> +	$(am__EXEEXT_16) $(am__EXEEXT_17)

> +@NATIVE_TRUE@@NOT_HAVE_FORMAT_ELF_TRUE@am__append_1 = test_elf

> +@NATIVE_TRUE@@NOT_HAVE_FORMAT_XCOFF_32_TRUE@am__append_2 = test_xcoff_32

> +@NATIVE_TRUE@@NOT_HAVE_FORMAT_XCOFF_64_TRUE@am__append_3 = test_xcoff_64

> +@NATIVE_TRUE@@NOT_HAVE_FORMAT_PECOFF_TRUE@am__append_4 = test_pecoff

> +@NATIVE_TRUE@@NOT_HAVE_FORMAT_UNKNOWN_TRUE@am__append_5 = test_unknown

> +@NATIVE_TRUE@am__append_6 = unittest btest

> +@HAVE_MMAP_TRUE@@NATIVE_TRUE@am__append_7 = btest_with_alloc

> +@NATIVE_TRUE@am__append_8 = stest

> +@HAVE_MMAP_TRUE@@NATIVE_TRUE@am__append_9 = stest_with_alloc

> +@HAVE_ZLIB_TRUE@@NATIVE_TRUE@am__append_10 = -lz

> +@NATIVE_TRUE@am__append_11 = ztest

> +@HAVE_MMAP_TRUE@@NATIVE_TRUE@am__append_12 = ztest_with_alloc

> +@NATIVE_TRUE@am__append_13 = edtest

> +@HAVE_MMAP_TRUE@@NATIVE_TRUE@am__append_14 = edtest_with_alloc

> +@HAVE_PTHREAD_TRUE@@NATIVE_TRUE@am__append_15 = ttest

> +@HAVE_MMAP_TRUE@@HAVE_PTHREAD_TRUE@@NATIVE_TRUE@am__append_16 = ttest_with_alloc

> +@HAVE_OBJCOPY_DEBUGLINK_TRUE@@NATIVE_TRUE@am__append_17 = dtest

> +@HAVE_COMPRESSED_DEBUG_TRUE@@NATIVE_TRUE@am__append_18 = ctestg ctesta

> +@HAVE_COMPRESSED_DEBUG_TRUE@@HAVE_MMAP_TRUE@@NATIVE_TRUE@am__append_19 = ctestg_with_alloc ctesta_with_alloc

>  subdir = .

>  ACLOCAL_M4 = $(top_srcdir)/aclocal.m4

>  am__aclocal_m4_deps = $(top_srcdir)/../config/cet.m4 \

> @@ -170,21 +177,28 @@ AM_V_lt = $(am__v_lt_@AM_V@)

>  am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@)

>  am__v_lt_0 = --silent

>  am__v_lt_1 = 

> -@NATIVE_TRUE@am__EXEEXT_1 = unittest$(EXEEXT) btest$(EXEEXT)

> -@HAVE_MMAP_TRUE@@NATIVE_TRUE@am__EXEEXT_2 = btest_with_alloc$(EXEEXT)

> -@NATIVE_TRUE@am__EXEEXT_3 = stest$(EXEEXT)

> -@HAVE_MMAP_TRUE@@NATIVE_TRUE@am__EXEEXT_4 = stest_with_alloc$(EXEEXT)

> -@NATIVE_TRUE@am__EXEEXT_5 = ztest$(EXEEXT)

> -@HAVE_MMAP_TRUE@@NATIVE_TRUE@am__EXEEXT_6 = ztest_with_alloc$(EXEEXT)

> -@NATIVE_TRUE@am__EXEEXT_7 = edtest$(EXEEXT)

> -@HAVE_MMAP_TRUE@@NATIVE_TRUE@am__EXEEXT_8 =  \

> +@NATIVE_TRUE@@NOT_HAVE_FORMAT_ELF_TRUE@am__EXEEXT_1 =  \

> +@NATIVE_TRUE@@NOT_HAVE_FORMAT_ELF_TRUE@	test_elf$(EXEEXT)

> +@NATIVE_TRUE@@NOT_HAVE_FORMAT_XCOFF_32_TRUE@am__EXEEXT_2 = test_xcoff_32$(EXEEXT)

> +@NATIVE_TRUE@@NOT_HAVE_FORMAT_XCOFF_64_TRUE@am__EXEEXT_3 = test_xcoff_64$(EXEEXT)

> +@NATIVE_TRUE@@NOT_HAVE_FORMAT_PECOFF_TRUE@am__EXEEXT_4 = test_pecoff$(EXEEXT)

> +@NATIVE_TRUE@@NOT_HAVE_FORMAT_UNKNOWN_TRUE@am__EXEEXT_5 = test_unknown$(EXEEXT)

> +@NATIVE_TRUE@am__EXEEXT_6 = unittest$(EXEEXT) btest$(EXEEXT)

> +@HAVE_MMAP_TRUE@@NATIVE_TRUE@am__EXEEXT_7 = btest_with_alloc$(EXEEXT)

> +@NATIVE_TRUE@am__EXEEXT_8 = stest$(EXEEXT)

> +@HAVE_MMAP_TRUE@@NATIVE_TRUE@am__EXEEXT_9 = stest_with_alloc$(EXEEXT)

> +@NATIVE_TRUE@am__EXEEXT_10 = ztest$(EXEEXT)

> +@HAVE_MMAP_TRUE@@NATIVE_TRUE@am__EXEEXT_11 =  \

> +@HAVE_MMAP_TRUE@@NATIVE_TRUE@	ztest_with_alloc$(EXEEXT)

> +@NATIVE_TRUE@am__EXEEXT_12 = edtest$(EXEEXT)

> +@HAVE_MMAP_TRUE@@NATIVE_TRUE@am__EXEEXT_13 =  \

>  @HAVE_MMAP_TRUE@@NATIVE_TRUE@	edtest_with_alloc$(EXEEXT)

> -@HAVE_PTHREAD_TRUE@@NATIVE_TRUE@am__EXEEXT_9 = ttest$(EXEEXT)

> -@HAVE_MMAP_TRUE@@HAVE_PTHREAD_TRUE@@NATIVE_TRUE@am__EXEEXT_10 = ttest_with_alloc$(EXEEXT)

> -@HAVE_COMPRESSED_DEBUG_TRUE@@NATIVE_TRUE@am__EXEEXT_11 =  \

> +@HAVE_PTHREAD_TRUE@@NATIVE_TRUE@am__EXEEXT_14 = ttest$(EXEEXT)

> +@HAVE_MMAP_TRUE@@HAVE_PTHREAD_TRUE@@NATIVE_TRUE@am__EXEEXT_15 = ttest_with_alloc$(EXEEXT)

> +@HAVE_COMPRESSED_DEBUG_TRUE@@NATIVE_TRUE@am__EXEEXT_16 =  \

>  @HAVE_COMPRESSED_DEBUG_TRUE@@NATIVE_TRUE@	ctestg$(EXEEXT) \

>  @HAVE_COMPRESSED_DEBUG_TRUE@@NATIVE_TRUE@	ctesta$(EXEEXT)

> -@HAVE_COMPRESSED_DEBUG_TRUE@@HAVE_MMAP_TRUE@@NATIVE_TRUE@am__EXEEXT_12 = ctestg_with_alloc$(EXEEXT) \

> +@HAVE_COMPRESSED_DEBUG_TRUE@@HAVE_MMAP_TRUE@@NATIVE_TRUE@am__EXEEXT_17 = ctestg_with_alloc$(EXEEXT) \

>  @HAVE_COMPRESSED_DEBUG_TRUE@@HAVE_MMAP_TRUE@@NATIVE_TRUE@	ctesta_with_alloc$(EXEEXT)

>  @NATIVE_TRUE@am_btest_OBJECTS = btest-btest.$(OBJEXT) \

>  @NATIVE_TRUE@	btest-testlib.$(OBJEXT)

> @@ -258,6 +272,32 @@ stest_OBJECTS = $(am_stest_OBJECTS)

>  stest_with_alloc_OBJECTS = $(am_stest_with_alloc_OBJECTS)

>  @HAVE_MMAP_TRUE@@NATIVE_TRUE@stest_with_alloc_DEPENDENCIES =  \

>  @HAVE_MMAP_TRUE@@NATIVE_TRUE@	$(libbacktrace_with_alloc)

> +@NATIVE_TRUE@@NOT_HAVE_FORMAT_ELF_TRUE@am_test_elf_OBJECTS =  \

> +@NATIVE_TRUE@@NOT_HAVE_FORMAT_ELF_TRUE@	test_format.$(OBJEXT) \

> +@NATIVE_TRUE@@NOT_HAVE_FORMAT_ELF_TRUE@	testlib.$(OBJEXT)

> +test_elf_OBJECTS = $(am_test_elf_OBJECTS)

> +@NATIVE_TRUE@@NOT_HAVE_FORMAT_ELF_TRUE@test_elf_DEPENDENCIES = $(libbacktrace_without_format) \

> +@NATIVE_TRUE@@NOT_HAVE_FORMAT_ELF_TRUE@	elf.lo

> +@NATIVE_TRUE@@NOT_HAVE_FORMAT_PECOFF_TRUE@am_test_pecoff_OBJECTS = test_format.$(OBJEXT) \

> +@NATIVE_TRUE@@NOT_HAVE_FORMAT_PECOFF_TRUE@	testlib.$(OBJEXT)

> +test_pecoff_OBJECTS = $(am_test_pecoff_OBJECTS)

> +@NATIVE_TRUE@@NOT_HAVE_FORMAT_PECOFF_TRUE@test_pecoff_DEPENDENCIES = $(libbacktrace_without_format) \

> +@NATIVE_TRUE@@NOT_HAVE_FORMAT_PECOFF_TRUE@	pecoff.lo

> +@NATIVE_TRUE@@NOT_HAVE_FORMAT_UNKNOWN_TRUE@am_test_unknown_OBJECTS = test_format.$(OBJEXT) \

> +@NATIVE_TRUE@@NOT_HAVE_FORMAT_UNKNOWN_TRUE@	testlib.$(OBJEXT)

> +test_unknown_OBJECTS = $(am_test_unknown_OBJECTS)

> +@NATIVE_TRUE@@NOT_HAVE_FORMAT_UNKNOWN_TRUE@test_unknown_DEPENDENCIES = $(libbacktrace_without_format) \

> +@NATIVE_TRUE@@NOT_HAVE_FORMAT_UNKNOWN_TRUE@	unknown.lo

> +@NATIVE_TRUE@@NOT_HAVE_FORMAT_XCOFF_32_TRUE@am_test_xcoff_32_OBJECTS = test_format.$(OBJEXT) \

> +@NATIVE_TRUE@@NOT_HAVE_FORMAT_XCOFF_32_TRUE@	xcoff_32.$(OBJEXT) \

> +@NATIVE_TRUE@@NOT_HAVE_FORMAT_XCOFF_32_TRUE@	testlib.$(OBJEXT)

> +test_xcoff_32_OBJECTS = $(am_test_xcoff_32_OBJECTS)

> +@NATIVE_TRUE@@NOT_HAVE_FORMAT_XCOFF_32_TRUE@test_xcoff_32_DEPENDENCIES = $(libbacktrace_without_format)

> +@NATIVE_TRUE@@NOT_HAVE_FORMAT_XCOFF_64_TRUE@am_test_xcoff_64_OBJECTS = test_format.$(OBJEXT) \

> +@NATIVE_TRUE@@NOT_HAVE_FORMAT_XCOFF_64_TRUE@	xcoff_64.$(OBJEXT) \

> +@NATIVE_TRUE@@NOT_HAVE_FORMAT_XCOFF_64_TRUE@	testlib.$(OBJEXT)

> +test_xcoff_64_OBJECTS = $(am_test_xcoff_64_OBJECTS)

> +@NATIVE_TRUE@@NOT_HAVE_FORMAT_XCOFF_64_TRUE@test_xcoff_64_DEPENDENCIES = $(libbacktrace_without_format)

>  @HAVE_PTHREAD_TRUE@@NATIVE_TRUE@am_ttest_OBJECTS =  \

>  @HAVE_PTHREAD_TRUE@@NATIVE_TRUE@	ttest-ttest.$(OBJEXT) \

>  @HAVE_PTHREAD_TRUE@@NATIVE_TRUE@	ttest-testlib.$(OBJEXT)

> @@ -338,9 +378,12 @@ SOURCES = $(libbacktrace_la_SOURCES) $(EXTRA_libbacktrace_la_SOURCES) \

>  	$(ctesta_with_alloc_SOURCES) $(ctestg_SOURCES) \

>  	$(ctestg_with_alloc_SOURCES) $(edtest_SOURCES) \

>  	$(edtest_with_alloc_SOURCES) $(stest_SOURCES) \

> -	$(stest_with_alloc_SOURCES) $(ttest_SOURCES) \

> -	$(ttest_with_alloc_SOURCES) $(unittest_SOURCES) \

> -	$(ztest_SOURCES) $(ztest_with_alloc_SOURCES)

> +	$(stest_with_alloc_SOURCES) $(test_elf_SOURCES) \

> +	$(test_pecoff_SOURCES) $(test_unknown_SOURCES) \

> +	$(test_xcoff_32_SOURCES) $(test_xcoff_64_SOURCES) \

> +	$(ttest_SOURCES) $(ttest_with_alloc_SOURCES) \

> +	$(unittest_SOURCES) $(ztest_SOURCES) \

> +	$(ztest_with_alloc_SOURCES)

>  am__can_run_installinfo = \

>    case $$AM_UPDATE_INFO_DIR in \

>      n|no|NO) false;; \

> @@ -748,7 +791,20 @@ libbacktrace_la_LIBADD = \

>  	$(ALLOC_FILE)

>  

>  libbacktrace_la_DEPENDENCIES = $(libbacktrace_la_LIBADD)

> -TESTS = $(check_PROGRAMS) $(am__append_12)

> +TESTS = $(check_PROGRAMS) $(am__append_17)

> +@NATIVE_TRUE@libbacktrace_without_format = $(libbacktrace_la_OBJECTS) \

> +@NATIVE_TRUE@	$(filter-out elf.lo pecoff.lo xcoff.lo,$(libbacktrace_la_LIBADD))

> +

> +@NATIVE_TRUE@@NOT_HAVE_FORMAT_ELF_TRUE@test_elf_SOURCES = test_format.c testlib.c

> +@NATIVE_TRUE@@NOT_HAVE_FORMAT_ELF_TRUE@test_elf_LDADD = $(libbacktrace_without_format) elf.lo

> +@NATIVE_TRUE@@NOT_HAVE_FORMAT_XCOFF_32_TRUE@test_xcoff_32_SOURCES = test_format.c xcoff_32.c testlib.c

> +@NATIVE_TRUE@@NOT_HAVE_FORMAT_XCOFF_32_TRUE@test_xcoff_32_LDADD = $(libbacktrace_without_format)

> +@NATIVE_TRUE@@NOT_HAVE_FORMAT_XCOFF_64_TRUE@test_xcoff_64_SOURCES = test_format.c xcoff_64.c testlib.c

> +@NATIVE_TRUE@@NOT_HAVE_FORMAT_XCOFF_64_TRUE@test_xcoff_64_LDADD = $(libbacktrace_without_format)

> +@NATIVE_TRUE@@NOT_HAVE_FORMAT_PECOFF_TRUE@test_pecoff_SOURCES = test_format.c testlib.c

> +@NATIVE_TRUE@@NOT_HAVE_FORMAT_PECOFF_TRUE@test_pecoff_LDADD = $(libbacktrace_without_format) pecoff.lo

> +@NATIVE_TRUE@@NOT_HAVE_FORMAT_UNKNOWN_TRUE@test_unknown_SOURCES = test_format.c testlib.c

> +@NATIVE_TRUE@@NOT_HAVE_FORMAT_UNKNOWN_TRUE@test_unknown_LDADD = $(libbacktrace_without_format) unknown.lo

>  @NATIVE_TRUE@unittest_SOURCES = unittest.c testlib.c

>  @NATIVE_TRUE@unittest_LDADD = libbacktrace.la

>  @NATIVE_TRUE@btest_SOURCES = btest.c testlib.c

> @@ -767,7 +823,7 @@ TESTS = $(check_PROGRAMS) $(am__append_12)

>  @HAVE_MMAP_TRUE@@NATIVE_TRUE@stest_with_alloc_LDADD = $(libbacktrace_with_alloc)

>  @NATIVE_TRUE@ztest_SOURCES = ztest.c testlib.c

>  @NATIVE_TRUE@ztest_CFLAGS = -DSRCDIR=\"$(srcdir)\"

> -@NATIVE_TRUE@ztest_LDADD = libbacktrace.la $(am__append_5) \

> +@NATIVE_TRUE@ztest_LDADD = libbacktrace.la $(am__append_10) \

>  @NATIVE_TRUE@	$(CLOCK_GETTIME_LINK)

>  @HAVE_MMAP_TRUE@@NATIVE_TRUE@ztest_with_alloc_SOURCES = $(ztest_SOURCES)

>  @HAVE_MMAP_TRUE@@NATIVE_TRUE@ztest_with_alloc_CFLAGS = $(ztest_CFLAGS)

> @@ -939,6 +995,26 @@ stest_with_alloc$(EXEEXT): $(stest_with_alloc_OBJECTS) $(stest_with_alloc_DEPEND

>  	@rm -f stest_with_alloc$(EXEEXT)

>  	$(AM_V_CCLD)$(LINK) $(stest_with_alloc_OBJECTS) $(stest_with_alloc_LDADD) $(LIBS)

>  

> +test_elf$(EXEEXT): $(test_elf_OBJECTS) $(test_elf_DEPENDENCIES) $(EXTRA_test_elf_DEPENDENCIES) 

> +	@rm -f test_elf$(EXEEXT)

> +	$(AM_V_CCLD)$(LINK) $(test_elf_OBJECTS) $(test_elf_LDADD) $(LIBS)

> +

> +test_pecoff$(EXEEXT): $(test_pecoff_OBJECTS) $(test_pecoff_DEPENDENCIES) $(EXTRA_test_pecoff_DEPENDENCIES) 

> +	@rm -f test_pecoff$(EXEEXT)

> +	$(AM_V_CCLD)$(LINK) $(test_pecoff_OBJECTS) $(test_pecoff_LDADD) $(LIBS)

> +

> +test_unknown$(EXEEXT): $(test_unknown_OBJECTS) $(test_unknown_DEPENDENCIES) $(EXTRA_test_unknown_DEPENDENCIES) 

> +	@rm -f test_unknown$(EXEEXT)

> +	$(AM_V_CCLD)$(LINK) $(test_unknown_OBJECTS) $(test_unknown_LDADD) $(LIBS)

> +

> +test_xcoff_32$(EXEEXT): $(test_xcoff_32_OBJECTS) $(test_xcoff_32_DEPENDENCIES) $(EXTRA_test_xcoff_32_DEPENDENCIES) 

> +	@rm -f test_xcoff_32$(EXEEXT)

> +	$(AM_V_CCLD)$(LINK) $(test_xcoff_32_OBJECTS) $(test_xcoff_32_LDADD) $(LIBS)

> +

> +test_xcoff_64$(EXEEXT): $(test_xcoff_64_OBJECTS) $(test_xcoff_64_DEPENDENCIES) $(EXTRA_test_xcoff_64_DEPENDENCIES) 

> +	@rm -f test_xcoff_64$(EXEEXT)

> +	$(AM_V_CCLD)$(LINK) $(test_xcoff_64_OBJECTS) $(test_xcoff_64_LDADD) $(LIBS)

> +

>  ttest$(EXEEXT): $(ttest_OBJECTS) $(ttest_DEPENDENCIES) $(EXTRA_ttest_DEPENDENCIES) 

>  	@rm -f ttest$(EXEEXT)

>  	$(AM_V_CCLD)$(ttest_LINK) $(ttest_OBJECTS) $(ttest_LDADD) $(LIBS)

> @@ -1303,6 +1379,41 @@ recheck: all $(check_PROGRAMS)

>  	        am__force_recheck=am--force-recheck \

>  	        TEST_LOGS="$$log_list"; \

>  	exit $$?

> +test_elf.log: test_elf$(EXEEXT)

> +	@p='test_elf$(EXEEXT)'; \

> +	b='test_elf'; \

> +	$(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \

> +	--log-file $$b.log --trs-file $$b.trs \

> +	$(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \

> +	"$$tst" $(AM_TESTS_FD_REDIRECT)

> +test_xcoff_32.log: test_xcoff_32$(EXEEXT)

> +	@p='test_xcoff_32$(EXEEXT)'; \

> +	b='test_xcoff_32'; \

> +	$(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \

> +	--log-file $$b.log --trs-file $$b.trs \

> +	$(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \

> +	"$$tst" $(AM_TESTS_FD_REDIRECT)

> +test_xcoff_64.log: test_xcoff_64$(EXEEXT)

> +	@p='test_xcoff_64$(EXEEXT)'; \

> +	b='test_xcoff_64'; \

> +	$(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \

> +	--log-file $$b.log --trs-file $$b.trs \

> +	$(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \

> +	"$$tst" $(AM_TESTS_FD_REDIRECT)

> +test_pecoff.log: test_pecoff$(EXEEXT)

> +	@p='test_pecoff$(EXEEXT)'; \

> +	b='test_pecoff'; \

> +	$(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \

> +	--log-file $$b.log --trs-file $$b.trs \

> +	$(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \

> +	"$$tst" $(AM_TESTS_FD_REDIRECT)

> +test_unknown.log: test_unknown$(EXEEXT)

> +	@p='test_unknown$(EXEEXT)'; \

> +	b='test_unknown'; \

> +	$(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \

> +	--log-file $$b.log --trs-file $$b.trs \

> +	$(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \

> +	"$$tst" $(AM_TESTS_FD_REDIRECT)

>  unittest.log: unittest$(EXEEXT)

>  	@p='unittest$(EXEEXT)'; \

>  	b='unittest'; \

> @@ -1563,6 +1674,13 @@ uninstall-am:

>  .PRECIOUS: Makefile

>  

>  

> +@NATIVE_TRUE@xcoff_%.c: xcoff.c

> +@NATIVE_TRUE@	SEARCH='#error "Unknown BACKTRACE_XCOFF_SIZE"'; \

> +@NATIVE_TRUE@	REPLACE='#undef BACKTRACE_XCOFF_SIZE\n#define BACKTRACE_XCOFF_SIZE'; \

> +@NATIVE_TRUE@	$(SED) "s/^$$SEARCH\$$/$$REPLACE $*/" \

> +@NATIVE_TRUE@		$(srcdir)/xcoff.c \

> +@NATIVE_TRUE@		> $@

> +

>  @NATIVE_TRUE@edtest2_build.c: gen_edtest2_build; @true

>  @NATIVE_TRUE@gen_edtest2_build: $(srcdir)/edtest2.c

>  @NATIVE_TRUE@	cat $(srcdir)/edtest2.c > tmp-edtest2_build.c

> diff --git a/libbacktrace/configure b/libbacktrace/configure

> index ad2e27cbc62..65218ecc512 100755

> --- a/libbacktrace/configure

> +++ b/libbacktrace/configure

> @@ -653,6 +653,16 @@ ALLOC_FILE

>  VIEW_FILE

>  BACKTRACE_SUPPORTS_DATA

>  BACKTRACE_SUPPORTED

> +NOT_HAVE_FORMAT_XCOFF_64_FALSE

> +NOT_HAVE_FORMAT_XCOFF_64_TRUE

> +NOT_HAVE_FORMAT_XCOFF_32_FALSE

> +NOT_HAVE_FORMAT_XCOFF_32_TRUE

> +NOT_HAVE_FORMAT_ELF_FALSE

> +NOT_HAVE_FORMAT_ELF_TRUE

> +NOT_HAVE_FORMAT_PECOFF_FALSE

> +NOT_HAVE_FORMAT_PECOFF_TRUE

> +NOT_HAVE_FORMAT_UNKNOWN_FALSE

> +NOT_HAVE_FORMAT_UNKNOWN_TRUE

>  FORMAT_FILE

>  BACKTRACE_SUPPORTS_THREADS

>  PIC_FLAG

> @@ -11442,7 +11452,7 @@ else

>    lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2

>    lt_status=$lt_dlunknown

>    cat > conftest.$ac_ext <<_LT_EOF

> -#line 11445 "configure"

> +#line 11455 "configure"

>  #include "confdefs.h"

>  

>  #if HAVE_DLFCN_H

> @@ -11548,7 +11558,7 @@ else

>    lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2

>    lt_status=$lt_dlunknown

>    cat > conftest.$ac_ext <<_LT_EOF

> -#line 11551 "configure"

> +#line 11561 "configure"

>  #include "confdefs.h"

>  

>  #if HAVE_DLFCN_H

> @@ -12452,6 +12462,30 @@ $as_echo "$as_me: WARNING: could not determine output file type" >&2;}

>     ;;

>  esac

>  

> + if test "$FORMAT_FILE" != "unknown.lo"; then

> +  NOT_HAVE_FORMAT_UNKNOWN_TRUE=

> +  NOT_HAVE_FORMAT_UNKNOWN_FALSE='#'

> +else

> +  NOT_HAVE_FORMAT_UNKNOWN_TRUE='#'

> +  NOT_HAVE_FORMAT_UNKNOWN_FALSE=

> +fi

> +

> + if test "$FORMAT_FILE" != "pecoff.lo"; then

> +  NOT_HAVE_FORMAT_PECOFF_TRUE=

> +  NOT_HAVE_FORMAT_PECOFF_FALSE='#'

> +else

> +  NOT_HAVE_FORMAT_PECOFF_TRUE='#'

> +  NOT_HAVE_FORMAT_PECOFF_FALSE=

> +fi

> +

> + if test "$FORMAT_FILE" != "elf.lo"; then

> +  NOT_HAVE_FORMAT_ELF_TRUE=

> +  NOT_HAVE_FORMAT_ELF_FALSE='#'

> +else

> +  NOT_HAVE_FORMAT_ELF_TRUE='#'

> +  NOT_HAVE_FORMAT_ELF_FALSE=

> +fi

> +

>  

>  # ELF defines.

>  elfsize=

> @@ -12478,6 +12512,22 @@ cat >>confdefs.h <<_ACEOF

>  #define BACKTRACE_XCOFF_SIZE $xcoffsize

>  _ACEOF

>  

> + if test "$xcoffsize" != "32"; then

> +  NOT_HAVE_FORMAT_XCOFF_32_TRUE=

> +  NOT_HAVE_FORMAT_XCOFF_32_FALSE='#'

> +else

> +  NOT_HAVE_FORMAT_XCOFF_32_TRUE='#'

> +  NOT_HAVE_FORMAT_XCOFF_32_FALSE=

> +fi

> +

> + if test "$xcoffsize" != "64"; then

> +  NOT_HAVE_FORMAT_XCOFF_64_TRUE=

> +  NOT_HAVE_FORMAT_XCOFF_64_FALSE='#'

> +else

> +  NOT_HAVE_FORMAT_XCOFF_64_TRUE='#'

> +  NOT_HAVE_FORMAT_XCOFF_64_FALSE=

> +fi

> +

>  

>  BACKTRACE_SUPPORTED=0

>  if test "$backtrace_supported" = "yes"; then

> @@ -13568,6 +13618,26 @@ if test -z "${MAINTAINER_MODE_TRUE}" && test -z "${MAINTAINER_MODE_FALSE}"; then

>    as_fn_error $? "conditional \"MAINTAINER_MODE\" was never defined.

>  Usually this means the macro was only invoked conditionally." "$LINENO" 5

>  fi

> +if test -z "${NOT_HAVE_FORMAT_UNKNOWN_TRUE}" && test -z "${NOT_HAVE_FORMAT_UNKNOWN_FALSE}"; then

> +  as_fn_error $? "conditional \"NOT_HAVE_FORMAT_UNKNOWN\" was never defined.

> +Usually this means the macro was only invoked conditionally." "$LINENO" 5

> +fi

> +if test -z "${NOT_HAVE_FORMAT_PECOFF_TRUE}" && test -z "${NOT_HAVE_FORMAT_PECOFF_FALSE}"; then

> +  as_fn_error $? "conditional \"NOT_HAVE_FORMAT_PECOFF\" was never defined.

> +Usually this means the macro was only invoked conditionally." "$LINENO" 5

> +fi

> +if test -z "${NOT_HAVE_FORMAT_ELF_TRUE}" && test -z "${NOT_HAVE_FORMAT_ELF_FALSE}"; then

> +  as_fn_error $? "conditional \"NOT_HAVE_FORMAT_ELF\" was never defined.

> +Usually this means the macro was only invoked conditionally." "$LINENO" 5

> +fi

> +if test -z "${NOT_HAVE_FORMAT_XCOFF_32_TRUE}" && test -z "${NOT_HAVE_FORMAT_XCOFF_32_FALSE}"; then

> +  as_fn_error $? "conditional \"NOT_HAVE_FORMAT_XCOFF_32\" was never defined.

> +Usually this means the macro was only invoked conditionally." "$LINENO" 5

> +fi

> +if test -z "${NOT_HAVE_FORMAT_XCOFF_64_TRUE}" && test -z "${NOT_HAVE_FORMAT_XCOFF_64_FALSE}"; then

> +  as_fn_error $? "conditional \"NOT_HAVE_FORMAT_XCOFF_64\" was never defined.

> +Usually this means the macro was only invoked conditionally." "$LINENO" 5

> +fi

>  if test -z "${HAVE_MMAP_TRUE}" && test -z "${HAVE_MMAP_FALSE}"; then

>    as_fn_error $? "conditional \"HAVE_MMAP\" was never defined.

>  Usually this means the macro was only invoked conditionally." "$LINENO" 5

> diff --git a/libbacktrace/configure.ac b/libbacktrace/configure.ac

> index 4eb9b06d781..5e201e65a70 100644

> --- a/libbacktrace/configure.ac

> +++ b/libbacktrace/configure.ac

> @@ -247,6 +247,9 @@ xcoff*) FORMAT_FILE="xcoff.lo"

>     ;;

>  esac

>  AC_SUBST(FORMAT_FILE)

> +AM_CONDITIONAL(NOT_HAVE_FORMAT_UNKNOWN, test "$FORMAT_FILE" != "unknown.lo")

> +AM_CONDITIONAL(NOT_HAVE_FORMAT_PECOFF, test "$FORMAT_FILE" != "pecoff.lo")

> +AM_CONDITIONAL(NOT_HAVE_FORMAT_ELF, test "$FORMAT_FILE" != "elf.lo")

>  

>  # ELF defines.

>  elfsize=

> @@ -265,6 +268,8 @@ xcoff64) xcoffsize=64 ;;

>  *)       xcoffsize=unused

>  esac

>  AC_DEFINE_UNQUOTED([BACKTRACE_XCOFF_SIZE], [$xcoffsize], [XCOFF size: 32 or 64])

> +AM_CONDITIONAL(NOT_HAVE_FORMAT_XCOFF_32, test "$xcoffsize" != "32")

> +AM_CONDITIONAL(NOT_HAVE_FORMAT_XCOFF_64, test "$xcoffsize" != "64")

>  

>  BACKTRACE_SUPPORTED=0

>  if test "$backtrace_supported" = "yes"; then

> diff --git a/libbacktrace/test_format.c b/libbacktrace/test_format.c

> new file mode 100644

> index 00000000000..bb65b8c083a

> --- /dev/null

> +++ b/libbacktrace/test_format.c

> @@ -0,0 +1,55 @@

> +/* test_format.c -- Test for libbacktrace library

> +   Copyright (C) 2018 Free Software Foundation, Inc.

> +

> +Redistribution and use in source and binary forms, with or without

> +modification, are permitted provided that the following conditions are

> +met:

> +

> +    (1) Redistributions of source code must retain the above copyright

> +    notice, this list of conditions and the following disclaimer.

> +

> +    (2) Redistributions in binary form must reproduce the above copyright

> +    notice, this list of conditions and the following disclaimer in

> +    the documentation and/or other materials provided with the

> +    distribution.

> +

> +    (3) The name of the author may not be used to

> +    endorse or promote products derived from this software without

> +    specific prior written permission.

> +

> +THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR

> +IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED

> +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE

> +DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,

> +INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES

> +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR

> +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)

> +HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,

> +STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING

> +IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE

> +POSSIBILITY OF SUCH DAMAGE.  */

> +

> +/* This program tests the externally visible interfaces of the

> +   libbacktrace library.  */

> +

> +#include <assert.h>

> +#include <stdio.h>

> +#include <stdlib.h>

> +#include <string.h>

> +#include <unistd.h>

> +

> +#include "filenames.h"

> +

> +#include "backtrace.h"

> +#include "backtrace-supported.h"

> +

> +#include "testlib.h"

> +

> +int

> +main (int argc ATTRIBUTE_UNUSED, char **argv)

> +{

> +  state = backtrace_create_state (argv[0], BACKTRACE_SUPPORTS_THREADS,

> +				  error_callback_create, NULL);

> +

> +  exit (failures ? EXIT_FAILURE : EXIT_SUCCESS);

> +}

>
Jason Merrill via Gcc-patches Nov. 29, 2018, 6:28 p.m. | #2
On Fri, Nov 23, 2018 at 12:56 PM, Tom de Vries <tdevries@suse.de> wrote:
>

> When building libbacktrace, we typically use elf.c, and don't build pecoff.c,

> xcoff.c or unknown.c

>

> Add testcases that use unused format to ensure that we also build and

> test those on a typical development setup.

>

> Bootstrapped and reg-tested on x86_64.

>

> OK for trunk?

>

> Thanks,

> - Tom

>

> [libbacktrace] Add tests for unused formats

>

> 2018-11-23  Tom de Vries  <tdevries@suse.de>

>

>         * configure.ac (NOT_HAVE_FORMAT_ELF, NOT_HAVE_FORMAT_PECOFF)

>         (NOT_HAVE_FORMAT_UNKNOWN, NOT_HAVE_FORMAT_XCOFF_32)

>         (NOT_HAVE_FORMAT_XCOFF_64): New AM_CONDITIONAL.

>         * configure: Regenerate.

>         * Makefile.am (check_PROGRAMS): Add test_elf, test_xcoff_32,

>         test_xcoff_64, test_pecoff and test_unknown.

>         * Makefile.in: Regenerate.

>         * test_format.c: New file.



Again it seems feasible to avoid GNU make features, and skip the
negative conditionals and just build the tests for all formats
including the one on the current system.  It's not worth adding the
complexity to avoid building the test.  Thanks.

Ian
Tom de Vries Nov. 30, 2018, 9:06 a.m. | #3
On 29-11-18 19:28, Ian Lance Taylor wrote:
> On Fri, Nov 23, 2018 at 12:56 PM, Tom de Vries <tdevries@suse.de> wrote:

>>

>> When building libbacktrace, we typically use elf.c, and don't build pecoff.c,

>> xcoff.c or unknown.c

>>

>> Add testcases that use unused format to ensure that we also build and

>> test those on a typical development setup.

>>

>> Bootstrapped and reg-tested on x86_64.

>>

>> OK for trunk?

>>

>> Thanks,

>> - Tom

>>

>> [libbacktrace] Add tests for unused formats

>>

>> 2018-11-23  Tom de Vries  <tdevries@suse.de>

>>

>>         * configure.ac (NOT_HAVE_FORMAT_ELF, NOT_HAVE_FORMAT_PECOFF)

>>         (NOT_HAVE_FORMAT_UNKNOWN, NOT_HAVE_FORMAT_XCOFF_32)

>>         (NOT_HAVE_FORMAT_XCOFF_64): New AM_CONDITIONAL.

>>         * configure: Regenerate.

>>         * Makefile.am (check_PROGRAMS): Add test_elf, test_xcoff_32,

>>         test_xcoff_64, test_pecoff and test_unknown.

>>         * Makefile.in: Regenerate.

>>         * test_format.c: New file.

> 

> 

> Again it seems feasible to avoid GNU make features, and skip the

> negative conditionals and just build the tests for all formats

> including the one on the current system.  It's not worth adding the

> complexity to avoid building the test.  Thanks.


Done.

OK for trunk?

Thanks,
- Tom
[libbacktrace] Add tests for unused formats

When building libbacktrace, we typically use elf.c, and don't build pecoff.c,
xcoff.c or unknown.c

Add testcases that use unused format to ensure that we also build and
test those on a typical development setup.

Bootstrapped and reg-tested on x86_64.

2018-11-23  Tom de Vries  <tdevries@suse.de>

	* Makefile.am (check_PROGRAMS): Add test_elf, test_xcoff_32,
	test_xcoff_64, test_pecoff and test_unknown.
	* Makefile.in: Regenerate.
	* test_format.c: New file.

---
 libbacktrace/Makefile.am   |  39 +++++++++++++
 libbacktrace/Makefile.in   | 139 +++++++++++++++++++++++++++++++++++++++++----
 libbacktrace/test_format.c |  55 ++++++++++++++++++
 3 files changed, 221 insertions(+), 12 deletions(-)

diff --git a/libbacktrace/Makefile.am b/libbacktrace/Makefile.am
index e7e9c7b6697..1a3680bc98c 100644
--- a/libbacktrace/Makefile.am
+++ b/libbacktrace/Makefile.am
@@ -96,6 +96,45 @@ libbacktrace_alloc_la_LIBADD = $(BACKTRACE_FILE) $(FORMAT_FILE) read.lo alloc.lo
 
 libbacktrace_alloc_la_DEPENDENCIES = $(libbacktrace_alloc_la_LIBADD)
 
+check_LTLIBRARIES += libbacktrace_noformat.la
+
+libbacktrace_noformat_la_SOURCES = $(libbacktrace_la_SOURCES)
+libbacktrace_noformat_la_LIBADD = $(BACKTRACE_FILE) $(VIEW_FILE) $(ALLOC_FILE)
+
+libbacktrace_noformat_la_DEPENDENCIES = $(libbacktrace_noformat_la_LIBADD)
+
+xcoff_%.c: xcoff.c
+	SEARCH='#error "Unknown BACKTRACE_XCOFF_SIZE"'; \
+	REPLACE='#undef BACKTRACE_XCOFF_SIZE\n#define BACKTRACE_XCOFF_SIZE'; \
+	$(SED) "s/^$$SEARCH\$$/$$REPLACE $*/" \
+		$(srcdir)/xcoff.c \
+		> $@
+
+test_elf_SOURCES = test_format.c testlib.c
+test_elf_LDADD = libbacktrace_noformat.la elf.lo
+
+check_PROGRAMS += test_elf
+
+test_xcoff_32_SOURCES = test_format.c testlib.c
+test_xcoff_32_LDADD = libbacktrace_noformat.la xcoff_32.lo
+
+check_PROGRAMS += test_xcoff_32
+
+test_xcoff_64_SOURCES = test_format.c testlib.c
+test_xcoff_64_LDADD = libbacktrace_noformat.la xcoff_64.lo
+
+check_PROGRAMS += test_xcoff_64
+
+test_pecoff_SOURCES = test_format.c testlib.c
+test_pecoff_LDADD = libbacktrace_noformat.la pecoff.lo
+
+check_PROGRAMS += test_pecoff
+
+test_unknown_SOURCES = test_format.c testlib.c
+test_unknown_LDADD = libbacktrace_noformat.la unknown.lo
+
+check_PROGRAMS += test_unknown
+
 unittest_SOURCES = unittest.c testlib.c
 unittest_LDADD = libbacktrace.la
 
diff --git a/libbacktrace/Makefile.in b/libbacktrace/Makefile.in
index 119d3d2bbc1..6eaa1e28c01 100644
--- a/libbacktrace/Makefile.in
+++ b/libbacktrace/Makefile.in
@@ -121,9 +121,10 @@ build_triplet = @build@
 host_triplet = @host@
 target_triplet = @target@
 check_PROGRAMS = $(am__EXEEXT_1) $(am__EXEEXT_2) $(am__EXEEXT_3)
-@NATIVE_TRUE@am__append_1 = unittest unittest_alloc btest btest_alloc \
-@NATIVE_TRUE@	stest stest_alloc ztest ztest_alloc edtest \
-@NATIVE_TRUE@	edtest_alloc
+@NATIVE_TRUE@am__append_1 = test_elf test_xcoff_32 test_xcoff_64 \
+@NATIVE_TRUE@	test_pecoff test_unknown unittest unittest_alloc \
+@NATIVE_TRUE@	btest btest_alloc stest stest_alloc ztest \
+@NATIVE_TRUE@	ztest_alloc edtest edtest_alloc
 @HAVE_ZLIB_TRUE@@NATIVE_TRUE@am__append_2 = -lz
 @HAVE_ZLIB_TRUE@@NATIVE_TRUE@am__append_3 = -lz
 @HAVE_PTHREAD_TRUE@@NATIVE_TRUE@am__append_4 = ttest ttest_alloc
@@ -168,11 +169,18 @@ am__objects_1 = atomic.lo dwarf.lo fileline.lo posix.lo print.lo \
 @NATIVE_TRUE@am_libbacktrace_alloc_la_OBJECTS = $(am__objects_1)
 libbacktrace_alloc_la_OBJECTS = $(am_libbacktrace_alloc_la_OBJECTS)
 @NATIVE_TRUE@am_libbacktrace_alloc_la_rpath =
-@NATIVE_TRUE@am__EXEEXT_1 = unittest$(EXEEXT) unittest_alloc$(EXEEXT) \
-@NATIVE_TRUE@	btest$(EXEEXT) btest_alloc$(EXEEXT) \
-@NATIVE_TRUE@	stest$(EXEEXT) stest_alloc$(EXEEXT) \
-@NATIVE_TRUE@	ztest$(EXEEXT) ztest_alloc$(EXEEXT) \
-@NATIVE_TRUE@	edtest$(EXEEXT) edtest_alloc$(EXEEXT)
+@NATIVE_TRUE@am_libbacktrace_noformat_la_OBJECTS = $(am__objects_1)
+libbacktrace_noformat_la_OBJECTS =  \
+	$(am_libbacktrace_noformat_la_OBJECTS)
+@NATIVE_TRUE@am_libbacktrace_noformat_la_rpath =
+@NATIVE_TRUE@am__EXEEXT_1 = test_elf$(EXEEXT) test_xcoff_32$(EXEEXT) \
+@NATIVE_TRUE@	test_xcoff_64$(EXEEXT) test_pecoff$(EXEEXT) \
+@NATIVE_TRUE@	test_unknown$(EXEEXT) unittest$(EXEEXT) \
+@NATIVE_TRUE@	unittest_alloc$(EXEEXT) btest$(EXEEXT) \
+@NATIVE_TRUE@	btest_alloc$(EXEEXT) stest$(EXEEXT) \
+@NATIVE_TRUE@	stest_alloc$(EXEEXT) ztest$(EXEEXT) \
+@NATIVE_TRUE@	ztest_alloc$(EXEEXT) edtest$(EXEEXT) \
+@NATIVE_TRUE@	edtest_alloc$(EXEEXT)
 @HAVE_PTHREAD_TRUE@@NATIVE_TRUE@am__EXEEXT_2 = ttest$(EXEEXT) \
 @HAVE_PTHREAD_TRUE@@NATIVE_TRUE@	ttest_alloc$(EXEEXT)
 @HAVE_COMPRESSED_DEBUG_TRUE@@NATIVE_TRUE@am__EXEEXT_3 =  \
@@ -245,6 +253,30 @@ stest_OBJECTS = $(am_stest_OBJECTS)
 @NATIVE_TRUE@am_stest_alloc_OBJECTS = $(am__objects_6)
 stest_alloc_OBJECTS = $(am_stest_alloc_OBJECTS)
 @NATIVE_TRUE@stest_alloc_DEPENDENCIES = libbacktrace_alloc.la
+@NATIVE_TRUE@am_test_elf_OBJECTS = test_format.$(OBJEXT) \
+@NATIVE_TRUE@	testlib.$(OBJEXT)
+test_elf_OBJECTS = $(am_test_elf_OBJECTS)
+@NATIVE_TRUE@test_elf_DEPENDENCIES = libbacktrace_noformat.la elf.lo
+@NATIVE_TRUE@am_test_pecoff_OBJECTS = test_format.$(OBJEXT) \
+@NATIVE_TRUE@	testlib.$(OBJEXT)
+test_pecoff_OBJECTS = $(am_test_pecoff_OBJECTS)
+@NATIVE_TRUE@test_pecoff_DEPENDENCIES = libbacktrace_noformat.la \
+@NATIVE_TRUE@	pecoff.lo
+@NATIVE_TRUE@am_test_unknown_OBJECTS = test_format.$(OBJEXT) \
+@NATIVE_TRUE@	testlib.$(OBJEXT)
+test_unknown_OBJECTS = $(am_test_unknown_OBJECTS)
+@NATIVE_TRUE@test_unknown_DEPENDENCIES = libbacktrace_noformat.la \
+@NATIVE_TRUE@	unknown.lo
+@NATIVE_TRUE@am_test_xcoff_32_OBJECTS = test_format.$(OBJEXT) \
+@NATIVE_TRUE@	testlib.$(OBJEXT)
+test_xcoff_32_OBJECTS = $(am_test_xcoff_32_OBJECTS)
+@NATIVE_TRUE@test_xcoff_32_DEPENDENCIES = libbacktrace_noformat.la \
+@NATIVE_TRUE@	xcoff_32.lo
+@NATIVE_TRUE@am_test_xcoff_64_OBJECTS = test_format.$(OBJEXT) \
+@NATIVE_TRUE@	testlib.$(OBJEXT)
+test_xcoff_64_OBJECTS = $(am_test_xcoff_64_OBJECTS)
+@NATIVE_TRUE@test_xcoff_64_DEPENDENCIES = libbacktrace_noformat.la \
+@NATIVE_TRUE@	xcoff_64.lo
 @HAVE_PTHREAD_TRUE@@NATIVE_TRUE@am_ttest_OBJECTS =  \
 @HAVE_PTHREAD_TRUE@@NATIVE_TRUE@	ttest-ttest.$(OBJEXT) \
 @HAVE_PTHREAD_TRUE@@NATIVE_TRUE@	ttest-testlib.$(OBJEXT)
@@ -323,13 +355,17 @@ am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@)
 am__v_CCLD_0 = @echo "  CCLD    " $@;
 am__v_CCLD_1 = 
 SOURCES = $(libbacktrace_la_SOURCES) $(EXTRA_libbacktrace_la_SOURCES) \
-	$(libbacktrace_alloc_la_SOURCES) $(btest_SOURCES) \
+	$(libbacktrace_alloc_la_SOURCES) \
+	$(libbacktrace_noformat_la_SOURCES) $(btest_SOURCES) \
 	$(btest_alloc_SOURCES) $(ctesta_SOURCES) \
 	$(ctesta_alloc_SOURCES) $(ctestg_SOURCES) \
 	$(ctestg_alloc_SOURCES) $(edtest_SOURCES) \
 	$(edtest_alloc_SOURCES) $(stest_SOURCES) \
-	$(stest_alloc_SOURCES) $(ttest_SOURCES) $(ttest_alloc_SOURCES) \
-	$(unittest_SOURCES) $(unittest_alloc_SOURCES) $(ztest_SOURCES) \
+	$(stest_alloc_SOURCES) $(test_elf_SOURCES) \
+	$(test_pecoff_SOURCES) $(test_unknown_SOURCES) \
+	$(test_xcoff_32_SOURCES) $(test_xcoff_64_SOURCES) \
+	$(ttest_SOURCES) $(ttest_alloc_SOURCES) $(unittest_SOURCES) \
+	$(unittest_alloc_SOURCES) $(ztest_SOURCES) \
 	$(ztest_alloc_SOURCES)
 am__can_run_installinfo = \
   case $$AM_UPDATE_INFO_DIR in \
@@ -739,10 +775,24 @@ libbacktrace_la_LIBADD = \
 
 libbacktrace_la_DEPENDENCIES = $(libbacktrace_la_LIBADD)
 TESTS = $(check_PROGRAMS) $(am__append_5)
-@NATIVE_TRUE@check_LTLIBRARIES = libbacktrace_alloc.la
+@NATIVE_TRUE@check_LTLIBRARIES = libbacktrace_alloc.la \
+@NATIVE_TRUE@	libbacktrace_noformat.la
 @NATIVE_TRUE@libbacktrace_alloc_la_SOURCES = $(libbacktrace_la_SOURCES)
 @NATIVE_TRUE@libbacktrace_alloc_la_LIBADD = $(BACKTRACE_FILE) $(FORMAT_FILE) read.lo alloc.lo
 @NATIVE_TRUE@libbacktrace_alloc_la_DEPENDENCIES = $(libbacktrace_alloc_la_LIBADD)
+@NATIVE_TRUE@libbacktrace_noformat_la_SOURCES = $(libbacktrace_la_SOURCES)
+@NATIVE_TRUE@libbacktrace_noformat_la_LIBADD = $(BACKTRACE_FILE) $(VIEW_FILE) $(ALLOC_FILE)
+@NATIVE_TRUE@libbacktrace_noformat_la_DEPENDENCIES = $(libbacktrace_noformat_la_LIBADD)
+@NATIVE_TRUE@test_elf_SOURCES = test_format.c testlib.c
+@NATIVE_TRUE@test_elf_LDADD = libbacktrace_noformat.la elf.lo
+@NATIVE_TRUE@test_xcoff_32_SOURCES = test_format.c testlib.c
+@NATIVE_TRUE@test_xcoff_32_LDADD = libbacktrace_noformat.la xcoff_32.lo
+@NATIVE_TRUE@test_xcoff_64_SOURCES = test_format.c testlib.c
+@NATIVE_TRUE@test_xcoff_64_LDADD = libbacktrace_noformat.la xcoff_64.lo
+@NATIVE_TRUE@test_pecoff_SOURCES = test_format.c testlib.c
+@NATIVE_TRUE@test_pecoff_LDADD = libbacktrace_noformat.la pecoff.lo
+@NATIVE_TRUE@test_unknown_SOURCES = test_format.c testlib.c
+@NATIVE_TRUE@test_unknown_LDADD = libbacktrace_noformat.la unknown.lo
 @NATIVE_TRUE@unittest_SOURCES = unittest.c testlib.c
 @NATIVE_TRUE@unittest_LDADD = libbacktrace.la
 @NATIVE_TRUE@unittest_alloc_SOURCES = $(unittest_SOURCES)
@@ -895,6 +945,9 @@ libbacktrace.la: $(libbacktrace_la_OBJECTS) $(libbacktrace_la_DEPENDENCIES) $(EX
 libbacktrace_alloc.la: $(libbacktrace_alloc_la_OBJECTS) $(libbacktrace_alloc_la_DEPENDENCIES) $(EXTRA_libbacktrace_alloc_la_DEPENDENCIES) 
 	$(AM_V_CCLD)$(LINK) $(am_libbacktrace_alloc_la_rpath) $(libbacktrace_alloc_la_OBJECTS) $(libbacktrace_alloc_la_LIBADD) $(LIBS)
 
+libbacktrace_noformat.la: $(libbacktrace_noformat_la_OBJECTS) $(libbacktrace_noformat_la_DEPENDENCIES) $(EXTRA_libbacktrace_noformat_la_DEPENDENCIES) 
+	$(AM_V_CCLD)$(LINK) $(am_libbacktrace_noformat_la_rpath) $(libbacktrace_noformat_la_OBJECTS) $(libbacktrace_noformat_la_LIBADD) $(LIBS)
+
 clean-checkPROGRAMS:
 	@list='$(check_PROGRAMS)'; test -n "$$list" || exit 0; \
 	echo " rm -f" $$list; \
@@ -944,6 +997,26 @@ stest_alloc$(EXEEXT): $(stest_alloc_OBJECTS) $(stest_alloc_DEPENDENCIES) $(EXTRA
 	@rm -f stest_alloc$(EXEEXT)
 	$(AM_V_CCLD)$(LINK) $(stest_alloc_OBJECTS) $(stest_alloc_LDADD) $(LIBS)
 
+test_elf$(EXEEXT): $(test_elf_OBJECTS) $(test_elf_DEPENDENCIES) $(EXTRA_test_elf_DEPENDENCIES) 
+	@rm -f test_elf$(EXEEXT)
+	$(AM_V_CCLD)$(LINK) $(test_elf_OBJECTS) $(test_elf_LDADD) $(LIBS)
+
+test_pecoff$(EXEEXT): $(test_pecoff_OBJECTS) $(test_pecoff_DEPENDENCIES) $(EXTRA_test_pecoff_DEPENDENCIES) 
+	@rm -f test_pecoff$(EXEEXT)
+	$(AM_V_CCLD)$(LINK) $(test_pecoff_OBJECTS) $(test_pecoff_LDADD) $(LIBS)
+
+test_unknown$(EXEEXT): $(test_unknown_OBJECTS) $(test_unknown_DEPENDENCIES) $(EXTRA_test_unknown_DEPENDENCIES) 
+	@rm -f test_unknown$(EXEEXT)
+	$(AM_V_CCLD)$(LINK) $(test_unknown_OBJECTS) $(test_unknown_LDADD) $(LIBS)
+
+test_xcoff_32$(EXEEXT): $(test_xcoff_32_OBJECTS) $(test_xcoff_32_DEPENDENCIES) $(EXTRA_test_xcoff_32_DEPENDENCIES) 
+	@rm -f test_xcoff_32$(EXEEXT)
+	$(AM_V_CCLD)$(LINK) $(test_xcoff_32_OBJECTS) $(test_xcoff_32_LDADD) $(LIBS)
+
+test_xcoff_64$(EXEEXT): $(test_xcoff_64_OBJECTS) $(test_xcoff_64_DEPENDENCIES) $(EXTRA_test_xcoff_64_DEPENDENCIES) 
+	@rm -f test_xcoff_64$(EXEEXT)
+	$(AM_V_CCLD)$(LINK) $(test_xcoff_64_OBJECTS) $(test_xcoff_64_LDADD) $(LIBS)
+
 ttest$(EXEEXT): $(ttest_OBJECTS) $(ttest_DEPENDENCIES) $(EXTRA_ttest_DEPENDENCIES) 
 	@rm -f ttest$(EXEEXT)
 	$(AM_V_CCLD)$(ttest_LINK) $(ttest_OBJECTS) $(ttest_LDADD) $(LIBS)
@@ -1312,6 +1385,41 @@ recheck: all $(check_LTLIBRARIES) $(check_PROGRAMS)
 	        am__force_recheck=am--force-recheck \
 	        TEST_LOGS="$$log_list"; \
 	exit $$?
+test_elf.log: test_elf$(EXEEXT)
+	@p='test_elf$(EXEEXT)'; \
+	b='test_elf'; \
+	$(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \
+	--log-file $$b.log --trs-file $$b.trs \
+	$(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \
+	"$$tst" $(AM_TESTS_FD_REDIRECT)
+test_xcoff_32.log: test_xcoff_32$(EXEEXT)
+	@p='test_xcoff_32$(EXEEXT)'; \
+	b='test_xcoff_32'; \
+	$(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \
+	--log-file $$b.log --trs-file $$b.trs \
+	$(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \
+	"$$tst" $(AM_TESTS_FD_REDIRECT)
+test_xcoff_64.log: test_xcoff_64$(EXEEXT)
+	@p='test_xcoff_64$(EXEEXT)'; \
+	b='test_xcoff_64'; \
+	$(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \
+	--log-file $$b.log --trs-file $$b.trs \
+	$(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \
+	"$$tst" $(AM_TESTS_FD_REDIRECT)
+test_pecoff.log: test_pecoff$(EXEEXT)
+	@p='test_pecoff$(EXEEXT)'; \
+	b='test_pecoff'; \
+	$(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \
+	--log-file $$b.log --trs-file $$b.trs \
+	$(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \
+	"$$tst" $(AM_TESTS_FD_REDIRECT)
+test_unknown.log: test_unknown$(EXEEXT)
+	@p='test_unknown$(EXEEXT)'; \
+	b='test_unknown'; \
+	$(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \
+	--log-file $$b.log --trs-file $$b.trs \
+	$(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \
+	"$$tst" $(AM_TESTS_FD_REDIRECT)
 unittest.log: unittest$(EXEEXT)
 	@p='unittest$(EXEEXT)'; \
 	b='unittest'; \
@@ -1580,6 +1688,13 @@ uninstall-am:
 .PRECIOUS: Makefile
 
 
+@NATIVE_TRUE@xcoff_%.c: xcoff.c
+@NATIVE_TRUE@	SEARCH='#error "Unknown BACKTRACE_XCOFF_SIZE"'; \
+@NATIVE_TRUE@	REPLACE='#undef BACKTRACE_XCOFF_SIZE\n#define BACKTRACE_XCOFF_SIZE'; \
+@NATIVE_TRUE@	$(SED) "s/^$$SEARCH\$$/$$REPLACE $*/" \
+@NATIVE_TRUE@		$(srcdir)/xcoff.c \
+@NATIVE_TRUE@		> $@
+
 @NATIVE_TRUE@edtest2_build.c: gen_edtest2_build; @true
 @NATIVE_TRUE@gen_edtest2_build: $(srcdir)/edtest2.c
 @NATIVE_TRUE@	cat $(srcdir)/edtest2.c > tmp-edtest2_build.c
diff --git a/libbacktrace/test_format.c b/libbacktrace/test_format.c
new file mode 100644
index 00000000000..bb65b8c083a
--- /dev/null
+++ b/libbacktrace/test_format.c
@@ -0,0 +1,55 @@
+/* test_format.c -- Test for libbacktrace library
+   Copyright (C) 2018 Free Software Foundation, Inc.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are
+met:
+
+    (1) Redistributions of source code must retain the above copyright
+    notice, this list of conditions and the following disclaimer.
+
+    (2) Redistributions in binary form must reproduce the above copyright
+    notice, this list of conditions and the following disclaimer in
+    the documentation and/or other materials provided with the
+    distribution.
+
+    (3) The name of the author may not be used to
+    endorse or promote products derived from this software without
+    specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
+INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
+IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGE.  */
+
+/* This program tests the externally visible interfaces of the
+   libbacktrace library.  */
+
+#include <assert.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+
+#include "filenames.h"
+
+#include "backtrace.h"
+#include "backtrace-supported.h"
+
+#include "testlib.h"
+
+int
+main (int argc ATTRIBUTE_UNUSED, char **argv)
+{
+  state = backtrace_create_state (argv[0], BACKTRACE_SUPPORTS_THREADS,
+				  error_callback_create, NULL);
+
+  exit (failures ? EXIT_FAILURE : EXIT_SUCCESS);
+}
Jason Merrill via Gcc-patches Nov. 30, 2018, 2:46 p.m. | #4
On Fri, Nov 30, 2018 at 1:06 AM, Tom de Vries <tdevries@suse.de> wrote:
> On 29-11-18 19:28, Ian Lance Taylor wrote:

>> On Fri, Nov 23, 2018 at 12:56 PM, Tom de Vries <tdevries@suse.de> wrote:

>>>

>>> When building libbacktrace, we typically use elf.c, and don't build pecoff.c,

>>> xcoff.c or unknown.c

>>>

>>> Add testcases that use unused format to ensure that we also build and

>>> test those on a typical development setup.

>>>

>>> Bootstrapped and reg-tested on x86_64.

>>>

>>> OK for trunk?

>>>

>>> Thanks,

>>> - Tom

>>>

>>> [libbacktrace] Add tests for unused formats

>>>

>>> 2018-11-23  Tom de Vries  <tdevries@suse.de>

>>>

>>>         * configure.ac (NOT_HAVE_FORMAT_ELF, NOT_HAVE_FORMAT_PECOFF)

>>>         (NOT_HAVE_FORMAT_UNKNOWN, NOT_HAVE_FORMAT_XCOFF_32)

>>>         (NOT_HAVE_FORMAT_XCOFF_64): New AM_CONDITIONAL.

>>>         * configure: Regenerate.

>>>         * Makefile.am (check_PROGRAMS): Add test_elf, test_xcoff_32,

>>>         test_xcoff_64, test_pecoff and test_unknown.

>>>         * Makefile.in: Regenerate.

>>>         * test_format.c: New file.

>>

>>

>> Again it seems feasible to avoid GNU make features, and skip the

>> negative conditionals and just build the tests for all formats

>> including the one on the current system.  It's not worth adding the

>> complexity to avoid building the test.  Thanks.

>

> Done.

>

> OK for trunk?


This is OK.

Thanks.

Ian
Gerald Pfeifer Dec. 29, 2018, 6:40 a.m. | #5
On Fri, 23 Nov 2018, Tom de Vries wrote:
> When building libbacktrace, we typically use elf.c, and don't build 

> pecoff.c, xcoff.c or unknown.c

> 

> Add testcases that use unused format to ensure that we also build and

> test those on a typical development setup.


This is a good idea!

> Bootstrapped and reg-tested on x86_64.


Unfortunately, on i586-unknown-freebsd11 I'm now seeing the likes of

  gmake[3]: *** [Makefile:1086: xcoff_32.lo] Error 1
  xcoff_64.c:54:29: error: extra tokens at end of #undef directive [-Werror]
     54 | #undef BACKTRACE_XCOFF_SIZEn#define BACKTRACE_XCOFF_SIZE 64
        |                             ^
  xcoff_64.c:54:29: warning: extra tokens at end of #undef directive
     54 | #undef BACKTRACE_XCOFF_SIZEn#define BACKTRACE_XCOFF_SIZE 64
        |                             ^
  cc1: all warnings being treated as errors
  gmake[3]: *** [Makefile:1086: xcoff_64.lo] Error 1

The reason is that GNU sed supports \n in the replacement pattern

  % echo "abc" | sed -E 's:b:\n:' 
  a
  c

whereas BSD sed does not

  % echo "abc" | sed -E 's:b:\n:' 
  anc

so the following in libbacktrace/Makefile.am doesn't work:

  xcoff_%.c: xcoff.c
 	SEARCH='#error "Unknown BACKTRACE_XCOFF_SIZE"'; \
	REPLACE='#undef BACKTRACE_XCOFF_SIZE\n#define BACKTRACE_XCOFF_SIZE'; \
 	$(SED) "s/^$$SEARCH\$$/$$REPLACE $*/" \
 		$(srcdir)/xcoff.c \
 		> $@



I believe that in addition to FreeBSD this probably also fails on
Solaris and Darwin.

The patch below should address this (and does in my tests), though 
my tester seems to have unrelated(?) problems right now, so better
for one of you to give a spin as well, please.

Gerald



2018-12-28  Gerald Pfeifer  <gerald@pfeifer.com>

	* Makefile.am (xcoff_%.c): Use an actual newline instead of \n.
	* Makefile.in: Regenerate.

Index: libbacktrace/Makefile.am
===================================================================
--- libbacktrace/Makefile.am	(revision 267460)
+++ libbacktrace/Makefile.am	(working copy)
@@ -105,7 +105,8 @@
 
 xcoff_%.c: xcoff.c
 	SEARCH='#error "Unknown BACKTRACE_XCOFF_SIZE"'; \
-	REPLACE='#undef BACKTRACE_XCOFF_SIZE\n#define BACKTRACE_XCOFF_SIZE'; \
+	REPLACE='#undef BACKTRACE_XCOFF_SIZE\
+	#define BACKTRACE_XCOFF_SIZE'; \
 	$(SED) "s/^$$SEARCH\$$/$$REPLACE $*/" \
 		$(srcdir)/xcoff.c \
 		> $@

Index: libbacktrace/Makefile.in
===================================================================
--- libbacktrace/Makefile.in	(revision 267460)
+++ libbacktrace/Makefile.in	(working copy)
@@ -1733,7 +1733,8 @@
 
 @NATIVE_TRUE@xcoff_%.c: xcoff.c
 @NATIVE_TRUE@	SEARCH='#error "Unknown BACKTRACE_XCOFF_SIZE"'; \
-@NATIVE_TRUE@	REPLACE='#undef BACKTRACE_XCOFF_SIZE\n#define BACKTRACE_XCOFF_SIZE'; \
+@NATIVE_TRUE@	REPLACE='#undef BACKTRACE_XCOFF_SIZE\
+@NATIVE_TRUE@	#define BACKTRACE_XCOFF_SIZE'; \
 @NATIVE_TRUE@	$(SED) "s/^$$SEARCH\$$/$$REPLACE $*/" \
 @NATIVE_TRUE@		$(srcdir)/xcoff.c \
 @NATIVE_TRUE@		> $@
Gerald Pfeifer Dec. 29, 2018, 7:03 p.m. | #6
On Fri, 28 Dec 2018, Gerald Pfeifer wrote:
> The patch below should address this (and does in my tests), though 

> my tester seems to have unrelated(?) problems right now, so better

> for one of you to give a spin as well, please.


Now successfully regression tested on i586-unknown-freebsd11.2.

> 2018-12-28  Gerald Pfeifer  <gerald@pfeifer.com>

> 

> 	* Makefile.am (xcoff_%.c): Use an actual newline instead of \n.

> 	* Makefile.in: Regenerate.


Okay to apply?

Gerald
Tom de Vries Dec. 29, 2018, 11 p.m. | #7
On 29-12-18 07:40, Gerald Pfeifer wrote:
> On Fri, 23 Nov 2018, Tom de Vries wrote:

>> When building libbacktrace, we typically use elf.c, and don't build 

>> pecoff.c, xcoff.c or unknown.c

>>

>> Add testcases that use unused format to ensure that we also build and

>> test those on a typical development setup.

> 

> This is a good idea!

> 

>> Bootstrapped and reg-tested on x86_64.

> 

> Unfortunately, on i586-unknown-freebsd11 I'm now seeing the likes of

> 

>   gmake[3]: *** [Makefile:1086: xcoff_32.lo] Error 1

>   xcoff_64.c:54:29: error: extra tokens at end of #undef directive [-Werror]

>      54 | #undef BACKTRACE_XCOFF_SIZEn#define BACKTRACE_XCOFF_SIZE 64

>         |                             ^

>   xcoff_64.c:54:29: warning: extra tokens at end of #undef directive

>      54 | #undef BACKTRACE_XCOFF_SIZEn#define BACKTRACE_XCOFF_SIZE 64

>         |                             ^

>   cc1: all warnings being treated as errors

>   gmake[3]: *** [Makefile:1086: xcoff_64.lo] Error 1

> 

> The reason is that GNU sed supports \n in the replacement pattern

> 

>   % echo "abc" | sed -E 's:b:\n:' 

>   a

>   c

> 

> whereas BSD sed does not

> 

>   % echo "abc" | sed -E 's:b:\n:' 

>   anc

> 

> so the following in libbacktrace/Makefile.am doesn't work:

> 

>   xcoff_%.c: xcoff.c

>  	SEARCH='#error "Unknown BACKTRACE_XCOFF_SIZE"'; \

> 	REPLACE='#undef BACKTRACE_XCOFF_SIZE\n#define BACKTRACE_XCOFF_SIZE'; \

>  	$(SED) "s/^$$SEARCH\$$/$$REPLACE $*/" \

>  		$(srcdir)/xcoff.c \

>  		> $@

> 

> 

> I believe that in addition to FreeBSD this probably also fails on

> Solaris and Darwin.

> 

> The patch below should address this (and does in my tests), though 

> my tester seems to have unrelated(?) problems right now, so better

> for one of you to give a spin as well, please.

> 


Hi,

thanks for finding this.

I build the patch for x86_64 and ran make check in the libbacktrace
subdirectory of the build directory, results looks good.

Thanks,
- Tom

> Gerald

> 

> 

> 

> 2018-12-28  Gerald Pfeifer  <gerald@pfeifer.com>

> 

> 	* Makefile.am (xcoff_%.c): Use an actual newline instead of \n.

> 	* Makefile.in: Regenerate.

> 

> Index: libbacktrace/Makefile.am

> ===================================================================

> --- libbacktrace/Makefile.am	(revision 267460)

> +++ libbacktrace/Makefile.am	(working copy)

> @@ -105,7 +105,8 @@

>  

>  xcoff_%.c: xcoff.c

>  	SEARCH='#error "Unknown BACKTRACE_XCOFF_SIZE"'; \

> -	REPLACE='#undef BACKTRACE_XCOFF_SIZE\n#define BACKTRACE_XCOFF_SIZE'; \

> +	REPLACE='#undef BACKTRACE_XCOFF_SIZE\

> +	#define BACKTRACE_XCOFF_SIZE'; \

>  	$(SED) "s/^$$SEARCH\$$/$$REPLACE $*/" \

>  		$(srcdir)/xcoff.c \

>  		> $@

> Index: libbacktrace/Makefile.in

> ===================================================================

> --- libbacktrace/Makefile.in	(revision 267460)

> +++ libbacktrace/Makefile.in	(working copy)

> @@ -1733,7 +1733,8 @@

>  

>  @NATIVE_TRUE@xcoff_%.c: xcoff.c

>  @NATIVE_TRUE@	SEARCH='#error "Unknown BACKTRACE_XCOFF_SIZE"'; \

> -@NATIVE_TRUE@	REPLACE='#undef BACKTRACE_XCOFF_SIZE\n#define BACKTRACE_XCOFF_SIZE'; \

> +@NATIVE_TRUE@	REPLACE='#undef BACKTRACE_XCOFF_SIZE\

> +@NATIVE_TRUE@	#define BACKTRACE_XCOFF_SIZE'; \

>  @NATIVE_TRUE@	$(SED) "s/^$$SEARCH\$$/$$REPLACE $*/" \

>  @NATIVE_TRUE@		$(srcdir)/xcoff.c \

>  @NATIVE_TRUE@		> $@

>
Gerald Pfeifer Dec. 30, 2018, 12:02 a.m. | #8
On Sun, 30 Dec 2018, Tom de Vries wrote:
> thanks for finding this.

> 

> I build the patch for x86_64 and ran make check in the libbacktrace

> subdirectory of the build directory, results looks good.


Cool, thanks!  I went ahead and committed this fix.

Note, that I *may* be offline the next nine days (don't know yet),
so in the unlikely case there's any outfall, please revert for me
(or help fix).

Thanks,
Gerald
Rainer Orth Jan. 2, 2019, 1:20 p.m. | #9
Gerald Pfeifer <gerald@pfeifer.com> writes:

> On Fri, 23 Nov 2018, Tom de Vries wrote:

>> When building libbacktrace, we typically use elf.c, and don't build 

>> pecoff.c, xcoff.c or unknown.c

>> 

>> Add testcases that use unused format to ensure that we also build and

>> test those on a typical development setup.

>

> This is a good idea!

>

>> Bootstrapped and reg-tested on x86_64.

>

> Unfortunately, on i586-unknown-freebsd11 I'm now seeing the likes of

>

>   gmake[3]: *** [Makefile:1086: xcoff_32.lo] Error 1

>   xcoff_64.c:54:29: error: extra tokens at end of #undef directive [-Werror]

>      54 | #undef BACKTRACE_XCOFF_SIZEn#define BACKTRACE_XCOFF_SIZE 64

>         |                             ^

>   xcoff_64.c:54:29: warning: extra tokens at end of #undef directive

>      54 | #undef BACKTRACE_XCOFF_SIZEn#define BACKTRACE_XCOFF_SIZE 64

>         |                             ^

>   cc1: all warnings being treated as errors

>   gmake[3]: *** [Makefile:1086: xcoff_64.lo] Error 1

>

> The reason is that GNU sed supports \n in the replacement pattern

>

>   % echo "abc" | sed -E 's:b:\n:' 

>   a

>   c

>

> whereas BSD sed does not

>

>   % echo "abc" | sed -E 's:b:\n:' 

>   anc

>

> so the following in libbacktrace/Makefile.am doesn't work:

>

>   xcoff_%.c: xcoff.c

>  	SEARCH='#error "Unknown BACKTRACE_XCOFF_SIZE"'; \

> 	REPLACE='#undef BACKTRACE_XCOFF_SIZE\n#define BACKTRACE_XCOFF_SIZE'; \

>  	$(SED) "s/^$$SEARCH\$$/$$REPLACE $*/" \

>  		$(srcdir)/xcoff.c \

>  		> $@

>

>

> I believe that in addition to FreeBSD this probably also fails on

> Solaris and Darwin.


I cannot test Darwin right now, but Solaris sed is indeed affected.  On
Solaris 10 where there's only /usr/bin/sed (and /usr/xpg4/bin/sed which
has the same issue), the failure does occur.  On Solaris 11 where I have
GNU sed earlier in PATH, the issue is hidden.

Your patch does indeed fix the problem with Solaris 10 /bin/sed.

Unfortunately, libbacktrace is one of those libraries that don't produce
Dejagnu-style .sum and .log files, so test failures are buried in the
make check output and very easily overlooked.

	Rainer

-- 
-----------------------------------------------------------------------------
Rainer Orth, Center for Biotechnology, Bielefeld University
Iain Sandoe Jan. 2, 2019, 1:26 p.m. | #10
> On 2 Jan 2019, at 13:20, Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE> wrote:

> 

> Gerald Pfeifer <gerald@pfeifer.com> writes:

> 

>> On Fri, 23 Nov 2018, Tom de Vries wrote:

>>> When building libbacktrace, we typically use elf.c, and don't build 

>>> pecoff.c, xcoff.c or unknown.c

>>> 

>>> Add testcases that use unused format to ensure that we also build and

>>> test those on a typical development setup.

>> 

>> This is a good idea!

>> 

>>> Bootstrapped and reg-tested on x86_64.

>> 

>> Unfortunately, on i586-unknown-freebsd11 I'm now seeing the likes of

>> 

>>  gmake[3]: *** [Makefile:1086: xcoff_32.lo] Error 1

>>  xcoff_64.c:54:29: error: extra tokens at end of #undef directive [-Werror]

>>     54 | #undef BACKTRACE_XCOFF_SIZEn#define BACKTRACE_XCOFF_SIZE 64

>>        |                             ^

>>  xcoff_64.c:54:29: warning: extra tokens at end of #undef directive

>>     54 | #undef BACKTRACE_XCOFF_SIZEn#define BACKTRACE_XCOFF_SIZE 64

>>        |                             ^

>>  cc1: all warnings being treated as errors

>>  gmake[3]: *** [Makefile:1086: xcoff_64.lo] Error 1

>> 

>> The reason is that GNU sed supports \n in the replacement pattern

>> 

>>  % echo "abc" | sed -E 's:b:\n:' 

>>  a

>>  c

>> 

>> whereas BSD sed does not

>> 

>>  % echo "abc" | sed -E 's:b:\n:' 

>>  anc

>> 

>> so the following in libbacktrace/Makefile.am doesn't work:

>> 

>>  xcoff_%.c: xcoff.c

>> 	SEARCH='#error "Unknown BACKTRACE_XCOFF_SIZE"'; \

>> 	REPLACE='#undef BACKTRACE_XCOFF_SIZE\n#define BACKTRACE_XCOFF_SIZE'; \

>> 	$(SED) "s/^$$SEARCH\$$/$$REPLACE $*/" \

>> 		$(srcdir)/xcoff.c \

>> 		> $@

>> 

>> 

>> I believe that in addition to FreeBSD this probably also fails on

>> Solaris and Darwin.

> 

> I cannot test Darwin right now,


I have builds running on a number of versions, will take a look 
- is it missing a “macho_xx.c” implementation, anyway ?

> but Solaris sed is indeed affected.  On

> Solaris 10 where there's only /usr/bin/sed (and /usr/xpg4/bin/sed which

> has the same issue), the failure does occur.  On Solaris 11 where I have

> GNU sed earlier in PATH, the issue is hidden.

> 

> Your patch does indeed fix the problem with Solaris 10 /bin/sed.

> 

> Unfortunately, libbacktrace is one of those libraries that don't produce

> Dejagnu-style .sum and .log files, so test failures are buried in the

> make check output and very easily overlooked.

> 

> 	Rainer

> 

> -- 

> -----------------------------------------------------------------------------

> Rainer Orth, Center for Biotechnology, Bielefeld University
Iain Sandoe Jan. 3, 2019, 11:49 a.m. | #11
> On 2 Jan 2019, at 13:26, Iain Sandoe <idsandoe@googlemail.com> wrote:

> 

> 

>> On 2 Jan 2019, at 13:20, Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE> wrote:

>> 

>> Gerald Pfeifer <gerald@pfeifer.com> writes:

>> 

>>> 

<snip>
>>> 

>>> I believe that in addition to FreeBSD this probably also fails on

>>> Solaris and Darwin.

>> 

>> I cannot test Darwin right now,

> 

> I have builds running on a number of versions, will take a look 

> - is it missing a “macho_xx.c” implementation, anyway ?


(on darwin17 / macOS 10.13)

make check-target-libbacktrace 

fails for me at trunk r267505 with:

/src-local/gcc-trunk/libbacktrace/elf.c:144:2: error: #error "Unknown BACKTRACE_ELF_SIZE"
  144 | #error "Unknown BACKTRACE_ELF_SIZE"
      |  ^~~~~

So, it looks like there’s some configury-fixing/implementation work needed for Darwin.
Iain
Tom de Vries Jan. 3, 2019, 12:49 p.m. | #12
On 02-01-19 14:20, Rainer Orth wrote:
> Unfortunately, libbacktrace is one of those libraries that don't produce

> Dejagnu-style .sum and .log files, so test failures are buried in the

> make check output and very easily overlooked.


FTR, I've filed PR88002 - "libbacktrace and libiberty tests don't use
dejagnu" for that ( https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88002 ).

Thanks,
- Tom
Jason Merrill via Gcc-patches Jan. 3, 2019, 11:10 p.m. | #13
On Thu, Jan 3, 2019 at 3:49 AM Iain Sandoe <idsandoe@googlemail.com> wrote:
>

> > On 2 Jan 2019, at 13:26, Iain Sandoe <idsandoe@googlemail.com> wrote:

> >

> >

> >> On 2 Jan 2019, at 13:20, Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE> wrote:

> >>

> >> Gerald Pfeifer <gerald@pfeifer.com> writes:

> >>

> >>>

> <snip>

> >>>

> >>> I believe that in addition to FreeBSD this probably also fails on

> >>> Solaris and Darwin.

> >>

> >> I cannot test Darwin right now,

> >

> > I have builds running on a number of versions, will take a look

> > - is it missing a “macho_xx.c” implementation, anyway ?

>

> (on darwin17 / macOS 10.13)

>

> make check-target-libbacktrace

>

> fails for me at trunk r267505 with:

>

> /src-local/gcc-trunk/libbacktrace/elf.c:144:2: error: #error "Unknown BACKTRACE_ELF_SIZE"

>   144 | #error "Unknown BACKTRACE_ELF_SIZE"

>       |  ^~~~~

>

> So, it looks like there’s some configury-fixing/implementation work needed for Darwin.


Someone needs to write a macho.c that roughly corresponds to the
existing elf.c, pecoff.c, and xcoff.c.

Ian
Iain Sandoe Jan. 7, 2019, 7:29 p.m. | #14
> On 3 Jan 2019, at 23:10, Ian Lance Taylor <iant@google.com> wrote:

> 

> On Thu, Jan 3, 2019 at 3:49 AM Iain Sandoe <idsandoe@googlemail.com> wrote:

>> 

>>> On 2 Jan 2019, at 13:26, Iain Sandoe <idsandoe@googlemail.com> wrote:

>>> 

>>> 

>>>> On 2 Jan 2019, at 13:20, Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE> wrote:

>>>> 

>>>> Gerald Pfeifer <gerald@pfeifer.com> writes:

>>>> 

>>>>> 

>> <snip>

>>>>> 

>>>>> I believe that in addition to FreeBSD this probably also fails on

>>>>> Solaris and Darwin.

>>>> 

>>>> I cannot test Darwin right now,

>>> 

>>> I have builds running on a number of versions, will take a look

>>> - is it missing a “macho_xx.c” implementation, anyway ?

>> 

>> (on darwin17 / macOS 10.13)

>> 

>> make check-target-libbacktrace

>> 

>> fails for me at trunk r267505 with:

>> 

>> /src-local/gcc-trunk/libbacktrace/elf.c:144:2: error: #error "Unknown BACKTRACE_ELF_SIZE"

>>  144 | #error "Unknown BACKTRACE_ELF_SIZE"

>>      |  ^~~~~

>> 

>> So, it looks like there’s some configury-fixing/implementation work needed for Darwin.

> 

> Someone needs to write a macho.c that roughly corresponds to the

> existing elf.c, pecoff.c, and xcoff.c.


Filed PR88745 for this.
Iain

Patch

diff --git a/libbacktrace/Makefile.am b/libbacktrace/Makefile.am
index 4b28984c4e0..26c0b67a4c1 100644
--- a/libbacktrace/Makefile.am
+++ b/libbacktrace/Makefile.am
@@ -89,6 +89,46 @@  check_PROGRAMS =
 TESTS = $(check_PROGRAMS)
 
 if NATIVE
+libbacktrace_without_format = $(libbacktrace_la_OBJECTS) \
+	$(filter-out elf.lo pecoff.lo xcoff.lo,$(libbacktrace_la_LIBADD))
+
+xcoff_%.c: xcoff.c
+	SEARCH='#error "Unknown BACKTRACE_XCOFF_SIZE"'; \
+	REPLACE='#undef BACKTRACE_XCOFF_SIZE\n#define BACKTRACE_XCOFF_SIZE'; \
+	$(SED) "s/^$$SEARCH\$$/$$REPLACE $*/" \
+		$(srcdir)/xcoff.c \
+		> $@
+
+if NOT_HAVE_FORMAT_ELF
+test_elf_SOURCES = test_format.c testlib.c
+test_elf_LDADD = $(libbacktrace_without_format) elf.lo
+check_PROGRAMS += test_elf
+endif
+
+if NOT_HAVE_FORMAT_XCOFF_32
+test_xcoff_32_SOURCES = test_format.c xcoff_32.c testlib.c
+test_xcoff_32_LDADD = $(libbacktrace_without_format)
+check_PROGRAMS += test_xcoff_32
+endif
+
+if NOT_HAVE_FORMAT_XCOFF_64
+test_xcoff_64_SOURCES = test_format.c xcoff_64.c testlib.c
+test_xcoff_64_LDADD = $(libbacktrace_without_format)
+check_PROGRAMS += test_xcoff_64
+endif
+
+if NOT_HAVE_FORMAT_PECOFF
+test_pecoff_SOURCES = test_format.c testlib.c
+test_pecoff_LDADD = $(libbacktrace_without_format) pecoff.lo
+check_PROGRAMS += test_pecoff
+endif
+
+if NOT_HAVE_FORMAT_UNKNOWN
+test_unknown_SOURCES = test_format.c testlib.c
+test_unknown_LDADD = $(libbacktrace_without_format) unknown.lo
+check_PROGRAMS += test_unknown
+endif
+
 unittest_SOURCES = unittest.c testlib.c
 unittest_LDADD = libbacktrace.la
 
diff --git a/libbacktrace/Makefile.in b/libbacktrace/Makefile.in
index c79b67636c9..6e153085e29 100644
--- a/libbacktrace/Makefile.in
+++ b/libbacktrace/Makefile.in
@@ -123,21 +123,28 @@  target_triplet = @target@
 check_PROGRAMS = $(am__EXEEXT_1) $(am__EXEEXT_2) $(am__EXEEXT_3) \
 	$(am__EXEEXT_4) $(am__EXEEXT_5) $(am__EXEEXT_6) \
 	$(am__EXEEXT_7) $(am__EXEEXT_8) $(am__EXEEXT_9) \
-	$(am__EXEEXT_10) $(am__EXEEXT_11) $(am__EXEEXT_12)
-@NATIVE_TRUE@am__append_1 = unittest btest
-@HAVE_MMAP_TRUE@@NATIVE_TRUE@am__append_2 = btest_with_alloc
-@NATIVE_TRUE@am__append_3 = stest
-@HAVE_MMAP_TRUE@@NATIVE_TRUE@am__append_4 = stest_with_alloc
-@HAVE_ZLIB_TRUE@@NATIVE_TRUE@am__append_5 = -lz
-@NATIVE_TRUE@am__append_6 = ztest
-@HAVE_MMAP_TRUE@@NATIVE_TRUE@am__append_7 = ztest_with_alloc
-@NATIVE_TRUE@am__append_8 = edtest
-@HAVE_MMAP_TRUE@@NATIVE_TRUE@am__append_9 = edtest_with_alloc
-@HAVE_PTHREAD_TRUE@@NATIVE_TRUE@am__append_10 = ttest
-@HAVE_MMAP_TRUE@@HAVE_PTHREAD_TRUE@@NATIVE_TRUE@am__append_11 = ttest_with_alloc
-@HAVE_OBJCOPY_DEBUGLINK_TRUE@@NATIVE_TRUE@am__append_12 = dtest
-@HAVE_COMPRESSED_DEBUG_TRUE@@NATIVE_TRUE@am__append_13 = ctestg ctesta
-@HAVE_COMPRESSED_DEBUG_TRUE@@HAVE_MMAP_TRUE@@NATIVE_TRUE@am__append_14 = ctestg_with_alloc ctesta_with_alloc
+	$(am__EXEEXT_10) $(am__EXEEXT_11) $(am__EXEEXT_12) \
+	$(am__EXEEXT_13) $(am__EXEEXT_14) $(am__EXEEXT_15) \
+	$(am__EXEEXT_16) $(am__EXEEXT_17)
+@NATIVE_TRUE@@NOT_HAVE_FORMAT_ELF_TRUE@am__append_1 = test_elf
+@NATIVE_TRUE@@NOT_HAVE_FORMAT_XCOFF_32_TRUE@am__append_2 = test_xcoff_32
+@NATIVE_TRUE@@NOT_HAVE_FORMAT_XCOFF_64_TRUE@am__append_3 = test_xcoff_64
+@NATIVE_TRUE@@NOT_HAVE_FORMAT_PECOFF_TRUE@am__append_4 = test_pecoff
+@NATIVE_TRUE@@NOT_HAVE_FORMAT_UNKNOWN_TRUE@am__append_5 = test_unknown
+@NATIVE_TRUE@am__append_6 = unittest btest
+@HAVE_MMAP_TRUE@@NATIVE_TRUE@am__append_7 = btest_with_alloc
+@NATIVE_TRUE@am__append_8 = stest
+@HAVE_MMAP_TRUE@@NATIVE_TRUE@am__append_9 = stest_with_alloc
+@HAVE_ZLIB_TRUE@@NATIVE_TRUE@am__append_10 = -lz
+@NATIVE_TRUE@am__append_11 = ztest
+@HAVE_MMAP_TRUE@@NATIVE_TRUE@am__append_12 = ztest_with_alloc
+@NATIVE_TRUE@am__append_13 = edtest
+@HAVE_MMAP_TRUE@@NATIVE_TRUE@am__append_14 = edtest_with_alloc
+@HAVE_PTHREAD_TRUE@@NATIVE_TRUE@am__append_15 = ttest
+@HAVE_MMAP_TRUE@@HAVE_PTHREAD_TRUE@@NATIVE_TRUE@am__append_16 = ttest_with_alloc
+@HAVE_OBJCOPY_DEBUGLINK_TRUE@@NATIVE_TRUE@am__append_17 = dtest
+@HAVE_COMPRESSED_DEBUG_TRUE@@NATIVE_TRUE@am__append_18 = ctestg ctesta
+@HAVE_COMPRESSED_DEBUG_TRUE@@HAVE_MMAP_TRUE@@NATIVE_TRUE@am__append_19 = ctestg_with_alloc ctesta_with_alloc
 subdir = .
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
 am__aclocal_m4_deps = $(top_srcdir)/../config/cet.m4 \
@@ -170,21 +177,28 @@  AM_V_lt = $(am__v_lt_@AM_V@)
 am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@)
 am__v_lt_0 = --silent
 am__v_lt_1 = 
-@NATIVE_TRUE@am__EXEEXT_1 = unittest$(EXEEXT) btest$(EXEEXT)
-@HAVE_MMAP_TRUE@@NATIVE_TRUE@am__EXEEXT_2 = btest_with_alloc$(EXEEXT)
-@NATIVE_TRUE@am__EXEEXT_3 = stest$(EXEEXT)
-@HAVE_MMAP_TRUE@@NATIVE_TRUE@am__EXEEXT_4 = stest_with_alloc$(EXEEXT)
-@NATIVE_TRUE@am__EXEEXT_5 = ztest$(EXEEXT)
-@HAVE_MMAP_TRUE@@NATIVE_TRUE@am__EXEEXT_6 = ztest_with_alloc$(EXEEXT)
-@NATIVE_TRUE@am__EXEEXT_7 = edtest$(EXEEXT)
-@HAVE_MMAP_TRUE@@NATIVE_TRUE@am__EXEEXT_8 =  \
+@NATIVE_TRUE@@NOT_HAVE_FORMAT_ELF_TRUE@am__EXEEXT_1 =  \
+@NATIVE_TRUE@@NOT_HAVE_FORMAT_ELF_TRUE@	test_elf$(EXEEXT)
+@NATIVE_TRUE@@NOT_HAVE_FORMAT_XCOFF_32_TRUE@am__EXEEXT_2 = test_xcoff_32$(EXEEXT)
+@NATIVE_TRUE@@NOT_HAVE_FORMAT_XCOFF_64_TRUE@am__EXEEXT_3 = test_xcoff_64$(EXEEXT)
+@NATIVE_TRUE@@NOT_HAVE_FORMAT_PECOFF_TRUE@am__EXEEXT_4 = test_pecoff$(EXEEXT)
+@NATIVE_TRUE@@NOT_HAVE_FORMAT_UNKNOWN_TRUE@am__EXEEXT_5 = test_unknown$(EXEEXT)
+@NATIVE_TRUE@am__EXEEXT_6 = unittest$(EXEEXT) btest$(EXEEXT)
+@HAVE_MMAP_TRUE@@NATIVE_TRUE@am__EXEEXT_7 = btest_with_alloc$(EXEEXT)
+@NATIVE_TRUE@am__EXEEXT_8 = stest$(EXEEXT)
+@HAVE_MMAP_TRUE@@NATIVE_TRUE@am__EXEEXT_9 = stest_with_alloc$(EXEEXT)
+@NATIVE_TRUE@am__EXEEXT_10 = ztest$(EXEEXT)
+@HAVE_MMAP_TRUE@@NATIVE_TRUE@am__EXEEXT_11 =  \
+@HAVE_MMAP_TRUE@@NATIVE_TRUE@	ztest_with_alloc$(EXEEXT)
+@NATIVE_TRUE@am__EXEEXT_12 = edtest$(EXEEXT)
+@HAVE_MMAP_TRUE@@NATIVE_TRUE@am__EXEEXT_13 =  \
 @HAVE_MMAP_TRUE@@NATIVE_TRUE@	edtest_with_alloc$(EXEEXT)
-@HAVE_PTHREAD_TRUE@@NATIVE_TRUE@am__EXEEXT_9 = ttest$(EXEEXT)
-@HAVE_MMAP_TRUE@@HAVE_PTHREAD_TRUE@@NATIVE_TRUE@am__EXEEXT_10 = ttest_with_alloc$(EXEEXT)
-@HAVE_COMPRESSED_DEBUG_TRUE@@NATIVE_TRUE@am__EXEEXT_11 =  \
+@HAVE_PTHREAD_TRUE@@NATIVE_TRUE@am__EXEEXT_14 = ttest$(EXEEXT)
+@HAVE_MMAP_TRUE@@HAVE_PTHREAD_TRUE@@NATIVE_TRUE@am__EXEEXT_15 = ttest_with_alloc$(EXEEXT)
+@HAVE_COMPRESSED_DEBUG_TRUE@@NATIVE_TRUE@am__EXEEXT_16 =  \
 @HAVE_COMPRESSED_DEBUG_TRUE@@NATIVE_TRUE@	ctestg$(EXEEXT) \
 @HAVE_COMPRESSED_DEBUG_TRUE@@NATIVE_TRUE@	ctesta$(EXEEXT)
-@HAVE_COMPRESSED_DEBUG_TRUE@@HAVE_MMAP_TRUE@@NATIVE_TRUE@am__EXEEXT_12 = ctestg_with_alloc$(EXEEXT) \
+@HAVE_COMPRESSED_DEBUG_TRUE@@HAVE_MMAP_TRUE@@NATIVE_TRUE@am__EXEEXT_17 = ctestg_with_alloc$(EXEEXT) \
 @HAVE_COMPRESSED_DEBUG_TRUE@@HAVE_MMAP_TRUE@@NATIVE_TRUE@	ctesta_with_alloc$(EXEEXT)
 @NATIVE_TRUE@am_btest_OBJECTS = btest-btest.$(OBJEXT) \
 @NATIVE_TRUE@	btest-testlib.$(OBJEXT)
@@ -258,6 +272,32 @@  stest_OBJECTS = $(am_stest_OBJECTS)
 stest_with_alloc_OBJECTS = $(am_stest_with_alloc_OBJECTS)
 @HAVE_MMAP_TRUE@@NATIVE_TRUE@stest_with_alloc_DEPENDENCIES =  \
 @HAVE_MMAP_TRUE@@NATIVE_TRUE@	$(libbacktrace_with_alloc)
+@NATIVE_TRUE@@NOT_HAVE_FORMAT_ELF_TRUE@am_test_elf_OBJECTS =  \
+@NATIVE_TRUE@@NOT_HAVE_FORMAT_ELF_TRUE@	test_format.$(OBJEXT) \
+@NATIVE_TRUE@@NOT_HAVE_FORMAT_ELF_TRUE@	testlib.$(OBJEXT)
+test_elf_OBJECTS = $(am_test_elf_OBJECTS)
+@NATIVE_TRUE@@NOT_HAVE_FORMAT_ELF_TRUE@test_elf_DEPENDENCIES = $(libbacktrace_without_format) \
+@NATIVE_TRUE@@NOT_HAVE_FORMAT_ELF_TRUE@	elf.lo
+@NATIVE_TRUE@@NOT_HAVE_FORMAT_PECOFF_TRUE@am_test_pecoff_OBJECTS = test_format.$(OBJEXT) \
+@NATIVE_TRUE@@NOT_HAVE_FORMAT_PECOFF_TRUE@	testlib.$(OBJEXT)
+test_pecoff_OBJECTS = $(am_test_pecoff_OBJECTS)
+@NATIVE_TRUE@@NOT_HAVE_FORMAT_PECOFF_TRUE@test_pecoff_DEPENDENCIES = $(libbacktrace_without_format) \
+@NATIVE_TRUE@@NOT_HAVE_FORMAT_PECOFF_TRUE@	pecoff.lo
+@NATIVE_TRUE@@NOT_HAVE_FORMAT_UNKNOWN_TRUE@am_test_unknown_OBJECTS = test_format.$(OBJEXT) \
+@NATIVE_TRUE@@NOT_HAVE_FORMAT_UNKNOWN_TRUE@	testlib.$(OBJEXT)
+test_unknown_OBJECTS = $(am_test_unknown_OBJECTS)
+@NATIVE_TRUE@@NOT_HAVE_FORMAT_UNKNOWN_TRUE@test_unknown_DEPENDENCIES = $(libbacktrace_without_format) \
+@NATIVE_TRUE@@NOT_HAVE_FORMAT_UNKNOWN_TRUE@	unknown.lo
+@NATIVE_TRUE@@NOT_HAVE_FORMAT_XCOFF_32_TRUE@am_test_xcoff_32_OBJECTS = test_format.$(OBJEXT) \
+@NATIVE_TRUE@@NOT_HAVE_FORMAT_XCOFF_32_TRUE@	xcoff_32.$(OBJEXT) \
+@NATIVE_TRUE@@NOT_HAVE_FORMAT_XCOFF_32_TRUE@	testlib.$(OBJEXT)
+test_xcoff_32_OBJECTS = $(am_test_xcoff_32_OBJECTS)
+@NATIVE_TRUE@@NOT_HAVE_FORMAT_XCOFF_32_TRUE@test_xcoff_32_DEPENDENCIES = $(libbacktrace_without_format)
+@NATIVE_TRUE@@NOT_HAVE_FORMAT_XCOFF_64_TRUE@am_test_xcoff_64_OBJECTS = test_format.$(OBJEXT) \
+@NATIVE_TRUE@@NOT_HAVE_FORMAT_XCOFF_64_TRUE@	xcoff_64.$(OBJEXT) \
+@NATIVE_TRUE@@NOT_HAVE_FORMAT_XCOFF_64_TRUE@	testlib.$(OBJEXT)
+test_xcoff_64_OBJECTS = $(am_test_xcoff_64_OBJECTS)
+@NATIVE_TRUE@@NOT_HAVE_FORMAT_XCOFF_64_TRUE@test_xcoff_64_DEPENDENCIES = $(libbacktrace_without_format)
 @HAVE_PTHREAD_TRUE@@NATIVE_TRUE@am_ttest_OBJECTS =  \
 @HAVE_PTHREAD_TRUE@@NATIVE_TRUE@	ttest-ttest.$(OBJEXT) \
 @HAVE_PTHREAD_TRUE@@NATIVE_TRUE@	ttest-testlib.$(OBJEXT)
@@ -338,9 +378,12 @@  SOURCES = $(libbacktrace_la_SOURCES) $(EXTRA_libbacktrace_la_SOURCES) \
 	$(ctesta_with_alloc_SOURCES) $(ctestg_SOURCES) \
 	$(ctestg_with_alloc_SOURCES) $(edtest_SOURCES) \
 	$(edtest_with_alloc_SOURCES) $(stest_SOURCES) \
-	$(stest_with_alloc_SOURCES) $(ttest_SOURCES) \
-	$(ttest_with_alloc_SOURCES) $(unittest_SOURCES) \
-	$(ztest_SOURCES) $(ztest_with_alloc_SOURCES)
+	$(stest_with_alloc_SOURCES) $(test_elf_SOURCES) \
+	$(test_pecoff_SOURCES) $(test_unknown_SOURCES) \
+	$(test_xcoff_32_SOURCES) $(test_xcoff_64_SOURCES) \
+	$(ttest_SOURCES) $(ttest_with_alloc_SOURCES) \
+	$(unittest_SOURCES) $(ztest_SOURCES) \
+	$(ztest_with_alloc_SOURCES)
 am__can_run_installinfo = \
   case $$AM_UPDATE_INFO_DIR in \
     n|no|NO) false;; \
@@ -748,7 +791,20 @@  libbacktrace_la_LIBADD = \
 	$(ALLOC_FILE)
 
 libbacktrace_la_DEPENDENCIES = $(libbacktrace_la_LIBADD)
-TESTS = $(check_PROGRAMS) $(am__append_12)
+TESTS = $(check_PROGRAMS) $(am__append_17)
+@NATIVE_TRUE@libbacktrace_without_format = $(libbacktrace_la_OBJECTS) \
+@NATIVE_TRUE@	$(filter-out elf.lo pecoff.lo xcoff.lo,$(libbacktrace_la_LIBADD))
+
+@NATIVE_TRUE@@NOT_HAVE_FORMAT_ELF_TRUE@test_elf_SOURCES = test_format.c testlib.c
+@NATIVE_TRUE@@NOT_HAVE_FORMAT_ELF_TRUE@test_elf_LDADD = $(libbacktrace_without_format) elf.lo
+@NATIVE_TRUE@@NOT_HAVE_FORMAT_XCOFF_32_TRUE@test_xcoff_32_SOURCES = test_format.c xcoff_32.c testlib.c
+@NATIVE_TRUE@@NOT_HAVE_FORMAT_XCOFF_32_TRUE@test_xcoff_32_LDADD = $(libbacktrace_without_format)
+@NATIVE_TRUE@@NOT_HAVE_FORMAT_XCOFF_64_TRUE@test_xcoff_64_SOURCES = test_format.c xcoff_64.c testlib.c
+@NATIVE_TRUE@@NOT_HAVE_FORMAT_XCOFF_64_TRUE@test_xcoff_64_LDADD = $(libbacktrace_without_format)
+@NATIVE_TRUE@@NOT_HAVE_FORMAT_PECOFF_TRUE@test_pecoff_SOURCES = test_format.c testlib.c
+@NATIVE_TRUE@@NOT_HAVE_FORMAT_PECOFF_TRUE@test_pecoff_LDADD = $(libbacktrace_without_format) pecoff.lo
+@NATIVE_TRUE@@NOT_HAVE_FORMAT_UNKNOWN_TRUE@test_unknown_SOURCES = test_format.c testlib.c
+@NATIVE_TRUE@@NOT_HAVE_FORMAT_UNKNOWN_TRUE@test_unknown_LDADD = $(libbacktrace_without_format) unknown.lo
 @NATIVE_TRUE@unittest_SOURCES = unittest.c testlib.c
 @NATIVE_TRUE@unittest_LDADD = libbacktrace.la
 @NATIVE_TRUE@btest_SOURCES = btest.c testlib.c
@@ -767,7 +823,7 @@  TESTS = $(check_PROGRAMS) $(am__append_12)
 @HAVE_MMAP_TRUE@@NATIVE_TRUE@stest_with_alloc_LDADD = $(libbacktrace_with_alloc)
 @NATIVE_TRUE@ztest_SOURCES = ztest.c testlib.c
 @NATIVE_TRUE@ztest_CFLAGS = -DSRCDIR=\"$(srcdir)\"
-@NATIVE_TRUE@ztest_LDADD = libbacktrace.la $(am__append_5) \
+@NATIVE_TRUE@ztest_LDADD = libbacktrace.la $(am__append_10) \
 @NATIVE_TRUE@	$(CLOCK_GETTIME_LINK)
 @HAVE_MMAP_TRUE@@NATIVE_TRUE@ztest_with_alloc_SOURCES = $(ztest_SOURCES)
 @HAVE_MMAP_TRUE@@NATIVE_TRUE@ztest_with_alloc_CFLAGS = $(ztest_CFLAGS)
@@ -939,6 +995,26 @@  stest_with_alloc$(EXEEXT): $(stest_with_alloc_OBJECTS) $(stest_with_alloc_DEPEND
 	@rm -f stest_with_alloc$(EXEEXT)
 	$(AM_V_CCLD)$(LINK) $(stest_with_alloc_OBJECTS) $(stest_with_alloc_LDADD) $(LIBS)
 
+test_elf$(EXEEXT): $(test_elf_OBJECTS) $(test_elf_DEPENDENCIES) $(EXTRA_test_elf_DEPENDENCIES) 
+	@rm -f test_elf$(EXEEXT)
+	$(AM_V_CCLD)$(LINK) $(test_elf_OBJECTS) $(test_elf_LDADD) $(LIBS)
+
+test_pecoff$(EXEEXT): $(test_pecoff_OBJECTS) $(test_pecoff_DEPENDENCIES) $(EXTRA_test_pecoff_DEPENDENCIES) 
+	@rm -f test_pecoff$(EXEEXT)
+	$(AM_V_CCLD)$(LINK) $(test_pecoff_OBJECTS) $(test_pecoff_LDADD) $(LIBS)
+
+test_unknown$(EXEEXT): $(test_unknown_OBJECTS) $(test_unknown_DEPENDENCIES) $(EXTRA_test_unknown_DEPENDENCIES) 
+	@rm -f test_unknown$(EXEEXT)
+	$(AM_V_CCLD)$(LINK) $(test_unknown_OBJECTS) $(test_unknown_LDADD) $(LIBS)
+
+test_xcoff_32$(EXEEXT): $(test_xcoff_32_OBJECTS) $(test_xcoff_32_DEPENDENCIES) $(EXTRA_test_xcoff_32_DEPENDENCIES) 
+	@rm -f test_xcoff_32$(EXEEXT)
+	$(AM_V_CCLD)$(LINK) $(test_xcoff_32_OBJECTS) $(test_xcoff_32_LDADD) $(LIBS)
+
+test_xcoff_64$(EXEEXT): $(test_xcoff_64_OBJECTS) $(test_xcoff_64_DEPENDENCIES) $(EXTRA_test_xcoff_64_DEPENDENCIES) 
+	@rm -f test_xcoff_64$(EXEEXT)
+	$(AM_V_CCLD)$(LINK) $(test_xcoff_64_OBJECTS) $(test_xcoff_64_LDADD) $(LIBS)
+
 ttest$(EXEEXT): $(ttest_OBJECTS) $(ttest_DEPENDENCIES) $(EXTRA_ttest_DEPENDENCIES) 
 	@rm -f ttest$(EXEEXT)
 	$(AM_V_CCLD)$(ttest_LINK) $(ttest_OBJECTS) $(ttest_LDADD) $(LIBS)
@@ -1303,6 +1379,41 @@  recheck: all $(check_PROGRAMS)
 	        am__force_recheck=am--force-recheck \
 	        TEST_LOGS="$$log_list"; \
 	exit $$?
+test_elf.log: test_elf$(EXEEXT)
+	@p='test_elf$(EXEEXT)'; \
+	b='test_elf'; \
+	$(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \
+	--log-file $$b.log --trs-file $$b.trs \
+	$(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \
+	"$$tst" $(AM_TESTS_FD_REDIRECT)
+test_xcoff_32.log: test_xcoff_32$(EXEEXT)
+	@p='test_xcoff_32$(EXEEXT)'; \
+	b='test_xcoff_32'; \
+	$(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \
+	--log-file $$b.log --trs-file $$b.trs \
+	$(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \
+	"$$tst" $(AM_TESTS_FD_REDIRECT)
+test_xcoff_64.log: test_xcoff_64$(EXEEXT)
+	@p='test_xcoff_64$(EXEEXT)'; \
+	b='test_xcoff_64'; \
+	$(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \
+	--log-file $$b.log --trs-file $$b.trs \
+	$(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \
+	"$$tst" $(AM_TESTS_FD_REDIRECT)
+test_pecoff.log: test_pecoff$(EXEEXT)
+	@p='test_pecoff$(EXEEXT)'; \
+	b='test_pecoff'; \
+	$(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \
+	--log-file $$b.log --trs-file $$b.trs \
+	$(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \
+	"$$tst" $(AM_TESTS_FD_REDIRECT)
+test_unknown.log: test_unknown$(EXEEXT)
+	@p='test_unknown$(EXEEXT)'; \
+	b='test_unknown'; \
+	$(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \
+	--log-file $$b.log --trs-file $$b.trs \
+	$(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \
+	"$$tst" $(AM_TESTS_FD_REDIRECT)
 unittest.log: unittest$(EXEEXT)
 	@p='unittest$(EXEEXT)'; \
 	b='unittest'; \
@@ -1563,6 +1674,13 @@  uninstall-am:
 .PRECIOUS: Makefile
 
 
+@NATIVE_TRUE@xcoff_%.c: xcoff.c
+@NATIVE_TRUE@	SEARCH='#error "Unknown BACKTRACE_XCOFF_SIZE"'; \
+@NATIVE_TRUE@	REPLACE='#undef BACKTRACE_XCOFF_SIZE\n#define BACKTRACE_XCOFF_SIZE'; \
+@NATIVE_TRUE@	$(SED) "s/^$$SEARCH\$$/$$REPLACE $*/" \
+@NATIVE_TRUE@		$(srcdir)/xcoff.c \
+@NATIVE_TRUE@		> $@
+
 @NATIVE_TRUE@edtest2_build.c: gen_edtest2_build; @true
 @NATIVE_TRUE@gen_edtest2_build: $(srcdir)/edtest2.c
 @NATIVE_TRUE@	cat $(srcdir)/edtest2.c > tmp-edtest2_build.c
diff --git a/libbacktrace/configure b/libbacktrace/configure
index ad2e27cbc62..65218ecc512 100755
--- a/libbacktrace/configure
+++ b/libbacktrace/configure
@@ -653,6 +653,16 @@  ALLOC_FILE
 VIEW_FILE
 BACKTRACE_SUPPORTS_DATA
 BACKTRACE_SUPPORTED
+NOT_HAVE_FORMAT_XCOFF_64_FALSE
+NOT_HAVE_FORMAT_XCOFF_64_TRUE
+NOT_HAVE_FORMAT_XCOFF_32_FALSE
+NOT_HAVE_FORMAT_XCOFF_32_TRUE
+NOT_HAVE_FORMAT_ELF_FALSE
+NOT_HAVE_FORMAT_ELF_TRUE
+NOT_HAVE_FORMAT_PECOFF_FALSE
+NOT_HAVE_FORMAT_PECOFF_TRUE
+NOT_HAVE_FORMAT_UNKNOWN_FALSE
+NOT_HAVE_FORMAT_UNKNOWN_TRUE
 FORMAT_FILE
 BACKTRACE_SUPPORTS_THREADS
 PIC_FLAG
@@ -11442,7 +11452,7 @@  else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 11445 "configure"
+#line 11455 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -11548,7 +11558,7 @@  else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 11551 "configure"
+#line 11561 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -12452,6 +12462,30 @@  $as_echo "$as_me: WARNING: could not determine output file type" >&2;}
    ;;
 esac
 
+ if test "$FORMAT_FILE" != "unknown.lo"; then
+  NOT_HAVE_FORMAT_UNKNOWN_TRUE=
+  NOT_HAVE_FORMAT_UNKNOWN_FALSE='#'
+else
+  NOT_HAVE_FORMAT_UNKNOWN_TRUE='#'
+  NOT_HAVE_FORMAT_UNKNOWN_FALSE=
+fi
+
+ if test "$FORMAT_FILE" != "pecoff.lo"; then
+  NOT_HAVE_FORMAT_PECOFF_TRUE=
+  NOT_HAVE_FORMAT_PECOFF_FALSE='#'
+else
+  NOT_HAVE_FORMAT_PECOFF_TRUE='#'
+  NOT_HAVE_FORMAT_PECOFF_FALSE=
+fi
+
+ if test "$FORMAT_FILE" != "elf.lo"; then
+  NOT_HAVE_FORMAT_ELF_TRUE=
+  NOT_HAVE_FORMAT_ELF_FALSE='#'
+else
+  NOT_HAVE_FORMAT_ELF_TRUE='#'
+  NOT_HAVE_FORMAT_ELF_FALSE=
+fi
+
 
 # ELF defines.
 elfsize=
@@ -12478,6 +12512,22 @@  cat >>confdefs.h <<_ACEOF
 #define BACKTRACE_XCOFF_SIZE $xcoffsize
 _ACEOF
 
+ if test "$xcoffsize" != "32"; then
+  NOT_HAVE_FORMAT_XCOFF_32_TRUE=
+  NOT_HAVE_FORMAT_XCOFF_32_FALSE='#'
+else
+  NOT_HAVE_FORMAT_XCOFF_32_TRUE='#'
+  NOT_HAVE_FORMAT_XCOFF_32_FALSE=
+fi
+
+ if test "$xcoffsize" != "64"; then
+  NOT_HAVE_FORMAT_XCOFF_64_TRUE=
+  NOT_HAVE_FORMAT_XCOFF_64_FALSE='#'
+else
+  NOT_HAVE_FORMAT_XCOFF_64_TRUE='#'
+  NOT_HAVE_FORMAT_XCOFF_64_FALSE=
+fi
+
 
 BACKTRACE_SUPPORTED=0
 if test "$backtrace_supported" = "yes"; then
@@ -13568,6 +13618,26 @@  if test -z "${MAINTAINER_MODE_TRUE}" && test -z "${MAINTAINER_MODE_FALSE}"; then
   as_fn_error $? "conditional \"MAINTAINER_MODE\" was never defined.
 Usually this means the macro was only invoked conditionally." "$LINENO" 5
 fi
+if test -z "${NOT_HAVE_FORMAT_UNKNOWN_TRUE}" && test -z "${NOT_HAVE_FORMAT_UNKNOWN_FALSE}"; then
+  as_fn_error $? "conditional \"NOT_HAVE_FORMAT_UNKNOWN\" was never defined.
+Usually this means the macro was only invoked conditionally." "$LINENO" 5
+fi
+if test -z "${NOT_HAVE_FORMAT_PECOFF_TRUE}" && test -z "${NOT_HAVE_FORMAT_PECOFF_FALSE}"; then
+  as_fn_error $? "conditional \"NOT_HAVE_FORMAT_PECOFF\" was never defined.
+Usually this means the macro was only invoked conditionally." "$LINENO" 5
+fi
+if test -z "${NOT_HAVE_FORMAT_ELF_TRUE}" && test -z "${NOT_HAVE_FORMAT_ELF_FALSE}"; then
+  as_fn_error $? "conditional \"NOT_HAVE_FORMAT_ELF\" was never defined.
+Usually this means the macro was only invoked conditionally." "$LINENO" 5
+fi
+if test -z "${NOT_HAVE_FORMAT_XCOFF_32_TRUE}" && test -z "${NOT_HAVE_FORMAT_XCOFF_32_FALSE}"; then
+  as_fn_error $? "conditional \"NOT_HAVE_FORMAT_XCOFF_32\" was never defined.
+Usually this means the macro was only invoked conditionally." "$LINENO" 5
+fi
+if test -z "${NOT_HAVE_FORMAT_XCOFF_64_TRUE}" && test -z "${NOT_HAVE_FORMAT_XCOFF_64_FALSE}"; then
+  as_fn_error $? "conditional \"NOT_HAVE_FORMAT_XCOFF_64\" was never defined.
+Usually this means the macro was only invoked conditionally." "$LINENO" 5
+fi
 if test -z "${HAVE_MMAP_TRUE}" && test -z "${HAVE_MMAP_FALSE}"; then
   as_fn_error $? "conditional \"HAVE_MMAP\" was never defined.
 Usually this means the macro was only invoked conditionally." "$LINENO" 5
diff --git a/libbacktrace/configure.ac b/libbacktrace/configure.ac
index 4eb9b06d781..5e201e65a70 100644
--- a/libbacktrace/configure.ac
+++ b/libbacktrace/configure.ac
@@ -247,6 +247,9 @@  xcoff*) FORMAT_FILE="xcoff.lo"
    ;;
 esac
 AC_SUBST(FORMAT_FILE)
+AM_CONDITIONAL(NOT_HAVE_FORMAT_UNKNOWN, test "$FORMAT_FILE" != "unknown.lo")
+AM_CONDITIONAL(NOT_HAVE_FORMAT_PECOFF, test "$FORMAT_FILE" != "pecoff.lo")
+AM_CONDITIONAL(NOT_HAVE_FORMAT_ELF, test "$FORMAT_FILE" != "elf.lo")
 
 # ELF defines.
 elfsize=
@@ -265,6 +268,8 @@  xcoff64) xcoffsize=64 ;;
 *)       xcoffsize=unused
 esac
 AC_DEFINE_UNQUOTED([BACKTRACE_XCOFF_SIZE], [$xcoffsize], [XCOFF size: 32 or 64])
+AM_CONDITIONAL(NOT_HAVE_FORMAT_XCOFF_32, test "$xcoffsize" != "32")
+AM_CONDITIONAL(NOT_HAVE_FORMAT_XCOFF_64, test "$xcoffsize" != "64")
 
 BACKTRACE_SUPPORTED=0
 if test "$backtrace_supported" = "yes"; then
diff --git a/libbacktrace/test_format.c b/libbacktrace/test_format.c
new file mode 100644
index 00000000000..bb65b8c083a
--- /dev/null
+++ b/libbacktrace/test_format.c
@@ -0,0 +1,55 @@ 
+/* test_format.c -- Test for libbacktrace library
+   Copyright (C) 2018 Free Software Foundation, Inc.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are
+met:
+
+    (1) Redistributions of source code must retain the above copyright
+    notice, this list of conditions and the following disclaimer.
+
+    (2) Redistributions in binary form must reproduce the above copyright
+    notice, this list of conditions and the following disclaimer in
+    the documentation and/or other materials provided with the
+    distribution.
+
+    (3) The name of the author may not be used to
+    endorse or promote products derived from this software without
+    specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
+INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
+IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGE.  */
+
+/* This program tests the externally visible interfaces of the
+   libbacktrace library.  */
+
+#include <assert.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+
+#include "filenames.h"
+
+#include "backtrace.h"
+#include "backtrace-supported.h"
+
+#include "testlib.h"
+
+int
+main (int argc ATTRIBUTE_UNUSED, char **argv)
+{
+  state = backtrace_create_state (argv[0], BACKTRACE_SUPPORTS_THREADS,
+				  error_callback_create, NULL);
+
+  exit (failures ? EXIT_FAILURE : EXIT_SUCCESS);
+}