diff options
48 files changed, 1068 insertions, 789 deletions
diff --git a/libsframe/Makefile.am b/libsframe/Makefile.am index eec6c46..c31eec9 100644 --- a/libsframe/Makefile.am +++ b/libsframe/Makefile.am @@ -56,18 +56,6 @@ libsframe_la_LDFLAGS = $(libsframe_version_info) $(libsframe_version_script) EXTRA_DIST = libtool-version libsframe.ver diststuff: $(EXTRA_DIST) info -if HAVE_SFRAME_AS - libsframebt_la_SOURCES = sframe-backtrace.c sframe-backtrace-err.c - libsframebt_la_CPPFLAGS = -I$(srcdir) -I$(srcdir)/../include - libsframebt_la_CFLAGS = -Wa,--gsframe -if INSTALL_LIBBFD - lib_LTLIBRARIES += libsframebt.la - include_HEADERS += $(INCDIR)/sframe-backtrace-api.h -else - noinst_LTLIBRARIES += libsframebt.la -endif -endif - include doc/local.mk include testsuite/local.mk diff --git a/libsframe/Makefile.in b/libsframe/Makefile.in index 03ac628..d2c5ad1 100644 --- a/libsframe/Makefile.in +++ b/libsframe/Makefile.in @@ -108,20 +108,18 @@ POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ target_triplet = @target@ -@HAVE_SFRAME_AS_TRUE@@INSTALL_LIBBFD_TRUE@am__append_1 = libsframebt.la -@HAVE_SFRAME_AS_TRUE@@INSTALL_LIBBFD_TRUE@am__append_2 = $(INCDIR)/sframe-backtrace-api.h -@HAVE_SFRAME_AS_TRUE@@INSTALL_LIBBFD_FALSE@am__append_3 = libsframebt.la -@BUILD_INFO_TRUE@am__append_4 = doc/sframe-spec.texi -@BUILD_INFO_TRUE@am__append_5 = texput.log -@BUILD_INFO_TRUE@am__append_6 = doc/sframe-spec.info +@BUILD_INFO_TRUE@am__append_1 = doc/sframe-spec.texi +@BUILD_INFO_TRUE@am__append_2 = texput.log +@BUILD_INFO_TRUE@am__append_3 = doc/sframe-spec.info check_PROGRAMS = $(am__EXEEXT_1) -@HAVE_COMPAT_DEJAGNU_TRUE@am__append_7 = testsuite/libsframe.decode/be-flipping \ +@HAVE_COMPAT_DEJAGNU_TRUE@am__append_4 = testsuite/libsframe.decode/be-flipping \ @HAVE_COMPAT_DEJAGNU_TRUE@ testsuite/libsframe.decode/frecnt-1 \ @HAVE_COMPAT_DEJAGNU_TRUE@ testsuite/libsframe.decode/frecnt-2 \ @HAVE_COMPAT_DEJAGNU_TRUE@ testsuite/libsframe.encode/encode-1 \ @HAVE_COMPAT_DEJAGNU_TRUE@ testsuite/libsframe.find/findfre-1 \ @HAVE_COMPAT_DEJAGNU_TRUE@ testsuite/libsframe.find/findfunc-1 \ @HAVE_COMPAT_DEJAGNU_TRUE@ testsuite/libsframe.find/plt-findfre-1 +@HAVE_DL_ITERATE_PHDR_TRUE@@HAVE_SFRAME_AS_TRUE@am__append_5 = testsuite/libsframe.stacktrace/libsframest/libsframest.la subdir = . ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/../bfd/acinclude.m4 \ @@ -191,20 +189,19 @@ libsframe_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(libsframe_la_LDFLAGS) $(LDFLAGS) -o $@ @INSTALL_LIBBFD_FALSE@am_libsframe_la_rpath = @INSTALL_LIBBFD_TRUE@am_libsframe_la_rpath = -rpath $(libdir) -libsframebt_la_LIBADD = -am__libsframebt_la_SOURCES_DIST = sframe-backtrace.c \ - sframe-backtrace-err.c -@HAVE_SFRAME_AS_TRUE@am_libsframebt_la_OBJECTS = \ -@HAVE_SFRAME_AS_TRUE@ libsframebt_la-sframe-backtrace.lo \ -@HAVE_SFRAME_AS_TRUE@ libsframebt_la-sframe-backtrace-err.lo -libsframebt_la_OBJECTS = $(am_libsframebt_la_OBJECTS) -libsframebt_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC \ - $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CCLD) \ - $(libsframebt_la_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o \ - $@ -@HAVE_SFRAME_AS_TRUE@@INSTALL_LIBBFD_FALSE@am_libsframebt_la_rpath = -@HAVE_SFRAME_AS_TRUE@@INSTALL_LIBBFD_TRUE@am_libsframebt_la_rpath = \ -@HAVE_SFRAME_AS_TRUE@@INSTALL_LIBBFD_TRUE@ -rpath $(libdir) +testsuite_libsframe_stacktrace_libsframest_libsframest_la_DEPENDENCIES = \ + ${top_builddir}/libsframe.la +am__dirstamp = $(am__leading_dot)dirstamp +am_testsuite_libsframe_stacktrace_libsframest_libsframest_la_OBJECTS = testsuite/libsframe.stacktrace/libsframest/testsuite_libsframe_stacktrace_libsframest_libsframest_la-sframe-stacktrace.lo \ + testsuite/libsframe.stacktrace/libsframest/testsuite_libsframe_stacktrace_libsframest_libsframest_la-sframe-state.lo \ + testsuite/libsframe.stacktrace/libsframest/testsuite_libsframe_stacktrace_libsframest_libsframest_la-sframe-stacktrace-err.lo +testsuite_libsframe_stacktrace_libsframest_libsframest_la_OBJECTS = $(am_testsuite_libsframe_stacktrace_libsframest_libsframest_la_OBJECTS) +testsuite_libsframe_stacktrace_libsframest_libsframest_la_LINK = \ + $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ + $(LIBTOOLFLAGS) --mode=link $(CCLD) \ + $(testsuite_libsframe_stacktrace_libsframest_libsframest_la_CFLAGS) \ + $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ +@HAVE_DL_ITERATE_PHDR_TRUE@@HAVE_SFRAME_AS_TRUE@am_testsuite_libsframe_stacktrace_libsframest_libsframest_la_rpath = @HAVE_COMPAT_DEJAGNU_TRUE@am__EXEEXT_1 = testsuite/libsframe.decode/be-flipping$(EXEEXT) \ @HAVE_COMPAT_DEJAGNU_TRUE@ testsuite/libsframe.decode/frecnt-1$(EXEEXT) \ @HAVE_COMPAT_DEJAGNU_TRUE@ testsuite/libsframe.decode/frecnt-2$(EXEEXT) \ @@ -212,7 +209,6 @@ libsframebt_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC \ @HAVE_COMPAT_DEJAGNU_TRUE@ testsuite/libsframe.find/findfre-1$(EXEEXT) \ @HAVE_COMPAT_DEJAGNU_TRUE@ testsuite/libsframe.find/findfunc-1$(EXEEXT) \ @HAVE_COMPAT_DEJAGNU_TRUE@ testsuite/libsframe.find/plt-findfre-1$(EXEEXT) -am__dirstamp = $(am__leading_dot)dirstamp am_testsuite_libsframe_decode_be_flipping_OBJECTS = testsuite/libsframe.decode/testsuite_libsframe_decode_be_flipping-be-flipping.$(OBJEXT) testsuite_libsframe_decode_be_flipping_OBJECTS = \ $(am_testsuite_libsframe_decode_be_flipping_OBJECTS) @@ -282,7 +278,8 @@ AM_V_CCLD = $(am__v_CCLD_@AM_V@) am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@) am__v_CCLD_0 = @echo " CCLD " $@; am__v_CCLD_1 = -SOURCES = $(libsframe_la_SOURCES) $(libsframebt_la_SOURCES) \ +SOURCES = $(libsframe_la_SOURCES) \ + $(testsuite_libsframe_stacktrace_libsframest_libsframest_la_SOURCES) \ $(testsuite_libsframe_decode_be_flipping_SOURCES) \ $(testsuite_libsframe_decode_frecnt_1_SOURCES) \ $(testsuite_libsframe_decode_frecnt_2_SOURCES) \ @@ -291,7 +288,7 @@ SOURCES = $(libsframe_la_SOURCES) $(libsframebt_la_SOURCES) \ $(testsuite_libsframe_find_findfunc_1_SOURCES) \ $(testsuite_libsframe_find_plt_findfre_1_SOURCES) DIST_SOURCES = $(libsframe_la_SOURCES) \ - $(am__libsframebt_la_SOURCES_DIST) \ + $(testsuite_libsframe_stacktrace_libsframest_libsframest_la_SOURCES) \ $(testsuite_libsframe_decode_be_flipping_SOURCES) \ $(testsuite_libsframe_decode_frecnt_1_SOURCES) \ $(testsuite_libsframe_decode_frecnt_2_SOURCES) \ @@ -333,7 +330,7 @@ DVIS = doc/sframe-spec.dvi PDFS = doc/sframe-spec.pdf PSS = doc/sframe-spec.ps HTMLS = doc/sframe-spec.html -TEXINFOS = $(am__append_4) +TEXINFOS = $(am__append_1) TEXI2DVI = texi2dvi TEXI2PDF = $(TEXI2DVI) --pdf --batch MAKEINFOHTML = $(MAKEINFO) --html @@ -344,8 +341,7 @@ am__can_run_installinfo = \ n|no|NO) false;; \ *) (install-info --version) >/dev/null 2>&1;; \ esac -am__include_HEADERS_DIST = $(INCDIR)/sframe-backtrace-api.h \ - $(INCDIR)/sframe.h $(INCDIR)/sframe-api.h +am__include_HEADERS_DIST = $(INCDIR)/sframe.h $(INCDIR)/sframe-api.h HEADERS = $(include_HEADERS) am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) \ $(LISP)config.h.in @@ -376,6 +372,8 @@ am__DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/config.h.in \ $(srcdir)/testsuite/libsframe.decode/local.mk \ $(srcdir)/testsuite/libsframe.encode/local.mk \ $(srcdir)/testsuite/libsframe.find/local.mk \ + $(srcdir)/testsuite/libsframe.stacktrace/libsframest/local.mk \ + $(srcdir)/testsuite/libsframe.stacktrace/local.mk \ $(srcdir)/testsuite/local.mk $(top_srcdir)/../ar-lib \ $(top_srcdir)/../compile $(top_srcdir)/../config.guess \ $(top_srcdir)/../config.sub $(top_srcdir)/../depcomp \ @@ -542,9 +540,9 @@ ACLOCAL_AMFLAGS = -I .. -I ../config -I ../bfd AUTOMAKE_OPTIONS = dejagnu foreign no-texinfo.tex info-in-builddir subdir-objects # Variables that we might accumulate conditionally or in subdirs. -info_TEXINFOS = $(am__append_4) -DISTCLEANFILES = $(am__append_5) -MAINTAINERCLEANFILES = $(am__append_6) +info_TEXINFOS = $(am__append_1) +DISTCLEANFILES = $(am__append_2) +MAINTAINERCLEANFILES = $(am__append_3) INCDIR = $(srcdir)/../include # include libctf for swap.h AM_CPPFLAGS = -I$(srcdir) -I$(srcdir)/../include -I$(srcdir)/../libctf @@ -555,19 +553,14 @@ libsframe_version_info = -version-info `grep -v '^\#' $(srcdir)/libtool-version` # not support symbol versioning, there is no need to fall back on libtool's # -export-symbols option. @HAVE_LD_VERSION_SCRIPT_TRUE@@HAVE_SOLARIS_LD_TRUE@libsframe_version_script = -Wl,-M -Wl,$(srcdir)/libsframe.ver -@INSTALL_LIBBFD_TRUE@lib_LTLIBRARIES = libsframe.la $(am__append_1) -@INSTALL_LIBBFD_FALSE@include_HEADERS = $(am__append_2) -@INSTALL_LIBBFD_TRUE@include_HEADERS = $(INCDIR)/sframe.h \ -@INSTALL_LIBBFD_TRUE@ $(INCDIR)/sframe-api.h $(am__append_2) -@INSTALL_LIBBFD_FALSE@noinst_LTLIBRARIES = libsframe.la \ -@INSTALL_LIBBFD_FALSE@ $(am__append_3) +@INSTALL_LIBBFD_TRUE@lib_LTLIBRARIES = libsframe.la +@INSTALL_LIBBFD_FALSE@include_HEADERS = +@INSTALL_LIBBFD_TRUE@include_HEADERS = $(INCDIR)/sframe.h $(INCDIR)/sframe-api.h +@INSTALL_LIBBFD_FALSE@noinst_LTLIBRARIES = libsframe.la libsframe_la_SOURCES = sframe.c sframe-dump.c sframe-error.c libsframe_la_CPPFLAGS = $(AM_CPPFLAGS) libsframe_la_LDFLAGS = $(libsframe_version_info) $(libsframe_version_script) EXTRA_DIST = libtool-version libsframe.ver -@HAVE_SFRAME_AS_TRUE@libsframebt_la_SOURCES = sframe-backtrace.c sframe-backtrace-err.c -@HAVE_SFRAME_AS_TRUE@libsframebt_la_CPPFLAGS = -I$(srcdir) -I$(srcdir)/../include -@HAVE_SFRAME_AS_TRUE@libsframebt_la_CFLAGS = -Wa,--gsframe @BUILD_INFO_TRUE@AM_MAKEINFOFLAGS = --no-split # Setup the testing framework @@ -595,6 +588,17 @@ testsuite_libsframe_find_findfunc_1_CPPFLAGS = -I${top_srcdir}/../include -Wall testsuite_libsframe_find_plt_findfre_1_SOURCES = testsuite/libsframe.find/plt-findfre-1.c testsuite_libsframe_find_plt_findfre_1_LDADD = ${top_builddir}/libsframe.la testsuite_libsframe_find_plt_findfre_1_CPPFLAGS = -I${top_srcdir}/../include -Wall +check_LTLIBRARIES = $(am__append_5) +testsuite_libsframe_stacktrace_libsframest_libsframest_la_SOURCES = testsuite/libsframe.stacktrace/libsframest/sframe-stacktrace.c \ + testsuite/libsframe.stacktrace/libsframest/sframe-state.c \ + testsuite/libsframe.stacktrace/libsframest/sframe-stacktrace-err.c + +testsuite_libsframe_stacktrace_libsframest_libsframest_la_LIBADD = ${top_builddir}/libsframe.la +testsuite_libsframe_stacktrace_libsframest_libsframest_la_CPPFLAGS = -I${top_srcdir}/../include \ + -I${top_srcdir}/testsuite/libsframe.stacktrace/libsframest/include \ + -Wall -Wno-unused-but-set-variable + +testsuite_libsframe_stacktrace_libsframest_libsframest_la_CFLAGS = -Wa,--gsframe all: config.h $(MAKE) $(AM_MAKEFLAGS) all-am @@ -602,7 +606,7 @@ all: config.h .SUFFIXES: .c .dvi .lo .o .obj .ps am--refresh: Makefile @: -$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(srcdir)/doc/local.mk $(srcdir)/testsuite/local.mk $(srcdir)/testsuite/libsframe.decode/local.mk $(srcdir)/testsuite/libsframe.encode/local.mk $(srcdir)/testsuite/libsframe.find/local.mk $(am__configure_deps) +$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(srcdir)/doc/local.mk $(srcdir)/testsuite/local.mk $(srcdir)/testsuite/libsframe.decode/local.mk $(srcdir)/testsuite/libsframe.encode/local.mk $(srcdir)/testsuite/libsframe.find/local.mk $(srcdir)/testsuite/libsframe.stacktrace/local.mk $(srcdir)/testsuite/libsframe.stacktrace/libsframest/local.mk $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ @@ -624,7 +628,7 @@ Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status echo ' cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__depfiles_maybe)'; \ cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__depfiles_maybe);; \ esac; -$(srcdir)/doc/local.mk $(srcdir)/testsuite/local.mk $(srcdir)/testsuite/libsframe.decode/local.mk $(srcdir)/testsuite/libsframe.encode/local.mk $(srcdir)/testsuite/libsframe.find/local.mk $(am__empty): +$(srcdir)/doc/local.mk $(srcdir)/testsuite/local.mk $(srcdir)/testsuite/libsframe.decode/local.mk $(srcdir)/testsuite/libsframe.encode/local.mk $(srcdir)/testsuite/libsframe.find/local.mk $(srcdir)/testsuite/libsframe.stacktrace/local.mk $(srcdir)/testsuite/libsframe.stacktrace/libsframest/local.mk $(am__empty): $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) $(SHELL) ./config.status --recheck @@ -650,6 +654,17 @@ $(srcdir)/config.h.in: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) distclean-hdr: -rm -f config.h stamp-h1 +clean-checkLTLIBRARIES: + -test -z "$(check_LTLIBRARIES)" || rm -f $(check_LTLIBRARIES) + @list='$(check_LTLIBRARIES)'; \ + locs=`for p in $$list; do echo $$p; done | \ + sed 's|^[^/]*$$|.|; s|/[^/]*$$||; s|$$|/so_locations|' | \ + sort -u`; \ + test -z "$$locs" || { \ + echo rm -f $${locs}; \ + rm -f $${locs}; \ + } + install-libLTLIBRARIES: $(lib_LTLIBRARIES) @$(NORMAL_INSTALL) @list='$(lib_LTLIBRARIES)'; test -n "$(libdir)" || list=; \ @@ -698,9 +713,24 @@ clean-noinstLTLIBRARIES: libsframe.la: $(libsframe_la_OBJECTS) $(libsframe_la_DEPENDENCIES) $(EXTRA_libsframe_la_DEPENDENCIES) $(AM_V_CCLD)$(libsframe_la_LINK) $(am_libsframe_la_rpath) $(libsframe_la_OBJECTS) $(libsframe_la_LIBADD) $(LIBS) - -libsframebt.la: $(libsframebt_la_OBJECTS) $(libsframebt_la_DEPENDENCIES) $(EXTRA_libsframebt_la_DEPENDENCIES) - $(AM_V_CCLD)$(libsframebt_la_LINK) $(am_libsframebt_la_rpath) $(libsframebt_la_OBJECTS) $(libsframebt_la_LIBADD) $(LIBS) +testsuite/libsframe.stacktrace/libsframest/$(am__dirstamp): + @$(MKDIR_P) testsuite/libsframe.stacktrace/libsframest + @: > testsuite/libsframe.stacktrace/libsframest/$(am__dirstamp) +testsuite/libsframe.stacktrace/libsframest/$(DEPDIR)/$(am__dirstamp): + @$(MKDIR_P) testsuite/libsframe.stacktrace/libsframest/$(DEPDIR) + @: > testsuite/libsframe.stacktrace/libsframest/$(DEPDIR)/$(am__dirstamp) +testsuite/libsframe.stacktrace/libsframest/testsuite_libsframe_stacktrace_libsframest_libsframest_la-sframe-stacktrace.lo: \ + testsuite/libsframe.stacktrace/libsframest/$(am__dirstamp) \ + testsuite/libsframe.stacktrace/libsframest/$(DEPDIR)/$(am__dirstamp) +testsuite/libsframe.stacktrace/libsframest/testsuite_libsframe_stacktrace_libsframest_libsframest_la-sframe-state.lo: \ + testsuite/libsframe.stacktrace/libsframest/$(am__dirstamp) \ + testsuite/libsframe.stacktrace/libsframest/$(DEPDIR)/$(am__dirstamp) +testsuite/libsframe.stacktrace/libsframest/testsuite_libsframe_stacktrace_libsframest_libsframest_la-sframe-stacktrace-err.lo: \ + testsuite/libsframe.stacktrace/libsframest/$(am__dirstamp) \ + testsuite/libsframe.stacktrace/libsframest/$(DEPDIR)/$(am__dirstamp) + +testsuite/libsframe.stacktrace/libsframest/libsframest.la: $(testsuite_libsframe_stacktrace_libsframest_libsframest_la_OBJECTS) $(testsuite_libsframe_stacktrace_libsframest_libsframest_la_DEPENDENCIES) $(EXTRA_testsuite_libsframe_stacktrace_libsframest_libsframest_la_DEPENDENCIES) testsuite/libsframe.stacktrace/libsframest/$(am__dirstamp) + $(AM_V_CCLD)$(testsuite_libsframe_stacktrace_libsframest_libsframest_la_LINK) $(am_testsuite_libsframe_stacktrace_libsframest_libsframest_la_rpath) $(testsuite_libsframe_stacktrace_libsframest_libsframest_la_OBJECTS) $(testsuite_libsframe_stacktrace_libsframest_libsframest_la_LIBADD) $(LIBS) clean-checkPROGRAMS: @list='$(check_PROGRAMS)'; test -n "$$list" || exit 0; \ @@ -783,6 +813,8 @@ mostlyclean-compile: -rm -f testsuite/libsframe.decode/*.$(OBJEXT) -rm -f testsuite/libsframe.encode/*.$(OBJEXT) -rm -f testsuite/libsframe.find/*.$(OBJEXT) + -rm -f testsuite/libsframe.stacktrace/libsframest/*.$(OBJEXT) + -rm -f testsuite/libsframe.stacktrace/libsframest/*.lo distclean-compile: -rm -f *.tab.c @@ -790,8 +822,6 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libsframe_la-sframe-dump.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libsframe_la-sframe-error.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libsframe_la-sframe.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libsframebt_la-sframe-backtrace-err.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libsframebt_la-sframe-backtrace.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@testsuite/libsframe.decode/$(DEPDIR)/testsuite_libsframe_decode_be_flipping-be-flipping.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@testsuite/libsframe.decode/$(DEPDIR)/testsuite_libsframe_decode_frecnt_1-frecnt-1.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@testsuite/libsframe.decode/$(DEPDIR)/testsuite_libsframe_decode_frecnt_2-frecnt-2.Po@am__quote@ @@ -799,6 +829,9 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@testsuite/libsframe.find/$(DEPDIR)/testsuite_libsframe_find_findfre_1-findfre-1.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@testsuite/libsframe.find/$(DEPDIR)/testsuite_libsframe_find_findfunc_1-findfunc-1.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@testsuite/libsframe.find/$(DEPDIR)/testsuite_libsframe_find_plt_findfre_1-plt-findfre-1.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@testsuite/libsframe.stacktrace/libsframest/$(DEPDIR)/testsuite_libsframe_stacktrace_libsframest_libsframest_la-sframe-stacktrace-err.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@testsuite/libsframe.stacktrace/libsframest/$(DEPDIR)/testsuite_libsframe_stacktrace_libsframest_libsframest_la-sframe-stacktrace.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@testsuite/libsframe.stacktrace/libsframest/$(DEPDIR)/testsuite_libsframe_stacktrace_libsframest_libsframest_la-sframe-state.Plo@am__quote@ .c.o: @am__fastdepCC_TRUE@ $(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`;\ @@ -845,19 +878,26 @@ libsframe_la-sframe-error.lo: sframe-error.c @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libsframe_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libsframe_la-sframe-error.lo `test -f 'sframe-error.c' || echo '$(srcdir)/'`sframe-error.c -libsframebt_la-sframe-backtrace.lo: sframe-backtrace.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libsframebt_la_CPPFLAGS) $(CPPFLAGS) $(libsframebt_la_CFLAGS) $(CFLAGS) -MT libsframebt_la-sframe-backtrace.lo -MD -MP -MF $(DEPDIR)/libsframebt_la-sframe-backtrace.Tpo -c -o libsframebt_la-sframe-backtrace.lo `test -f 'sframe-backtrace.c' || echo '$(srcdir)/'`sframe-backtrace.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libsframebt_la-sframe-backtrace.Tpo $(DEPDIR)/libsframebt_la-sframe-backtrace.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='sframe-backtrace.c' object='libsframebt_la-sframe-backtrace.lo' libtool=yes @AMDEPBACKSLASH@ +testsuite/libsframe.stacktrace/libsframest/testsuite_libsframe_stacktrace_libsframest_libsframest_la-sframe-stacktrace.lo: testsuite/libsframe.stacktrace/libsframest/sframe-stacktrace.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(testsuite_libsframe_stacktrace_libsframest_libsframest_la_CPPFLAGS) $(CPPFLAGS) $(testsuite_libsframe_stacktrace_libsframest_libsframest_la_CFLAGS) $(CFLAGS) -MT testsuite/libsframe.stacktrace/libsframest/testsuite_libsframe_stacktrace_libsframest_libsframest_la-sframe-stacktrace.lo -MD -MP -MF testsuite/libsframe.stacktrace/libsframest/$(DEPDIR)/testsuite_libsframe_stacktrace_libsframest_libsframest_la-sframe-stacktrace.Tpo -c -o testsuite/libsframe.stacktrace/libsframest/testsuite_libsframe_stacktrace_libsframest_libsframest_la-sframe-stacktrace.lo `test -f 'testsuite/libsframe.stacktrace/libsframest/sframe-stacktrace.c' || echo '$(srcdir)/'`testsuite/libsframe.stacktrace/libsframest/sframe-stacktrace.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) testsuite/libsframe.stacktrace/libsframest/$(DEPDIR)/testsuite_libsframe_stacktrace_libsframest_libsframest_la-sframe-stacktrace.Tpo testsuite/libsframe.stacktrace/libsframest/$(DEPDIR)/testsuite_libsframe_stacktrace_libsframest_libsframest_la-sframe-stacktrace.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='testsuite/libsframe.stacktrace/libsframest/sframe-stacktrace.c' object='testsuite/libsframe.stacktrace/libsframest/testsuite_libsframe_stacktrace_libsframest_libsframest_la-sframe-stacktrace.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(testsuite_libsframe_stacktrace_libsframest_libsframest_la_CPPFLAGS) $(CPPFLAGS) $(testsuite_libsframe_stacktrace_libsframest_libsframest_la_CFLAGS) $(CFLAGS) -c -o testsuite/libsframe.stacktrace/libsframest/testsuite_libsframe_stacktrace_libsframest_libsframest_la-sframe-stacktrace.lo `test -f 'testsuite/libsframe.stacktrace/libsframest/sframe-stacktrace.c' || echo '$(srcdir)/'`testsuite/libsframe.stacktrace/libsframest/sframe-stacktrace.c + +testsuite/libsframe.stacktrace/libsframest/testsuite_libsframe_stacktrace_libsframest_libsframest_la-sframe-state.lo: testsuite/libsframe.stacktrace/libsframest/sframe-state.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(testsuite_libsframe_stacktrace_libsframest_libsframest_la_CPPFLAGS) $(CPPFLAGS) $(testsuite_libsframe_stacktrace_libsframest_libsframest_la_CFLAGS) $(CFLAGS) -MT testsuite/libsframe.stacktrace/libsframest/testsuite_libsframe_stacktrace_libsframest_libsframest_la-sframe-state.lo -MD -MP -MF testsuite/libsframe.stacktrace/libsframest/$(DEPDIR)/testsuite_libsframe_stacktrace_libsframest_libsframest_la-sframe-state.Tpo -c -o testsuite/libsframe.stacktrace/libsframest/testsuite_libsframe_stacktrace_libsframest_libsframest_la-sframe-state.lo `test -f 'testsuite/libsframe.stacktrace/libsframest/sframe-state.c' || echo '$(srcdir)/'`testsuite/libsframe.stacktrace/libsframest/sframe-state.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) testsuite/libsframe.stacktrace/libsframest/$(DEPDIR)/testsuite_libsframe_stacktrace_libsframest_libsframest_la-sframe-state.Tpo testsuite/libsframe.stacktrace/libsframest/$(DEPDIR)/testsuite_libsframe_stacktrace_libsframest_libsframest_la-sframe-state.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='testsuite/libsframe.stacktrace/libsframest/sframe-state.c' object='testsuite/libsframe.stacktrace/libsframest/testsuite_libsframe_stacktrace_libsframest_libsframest_la-sframe-state.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libsframebt_la_CPPFLAGS) $(CPPFLAGS) $(libsframebt_la_CFLAGS) $(CFLAGS) -c -o libsframebt_la-sframe-backtrace.lo `test -f 'sframe-backtrace.c' || echo '$(srcdir)/'`sframe-backtrace.c +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(testsuite_libsframe_stacktrace_libsframest_libsframest_la_CPPFLAGS) $(CPPFLAGS) $(testsuite_libsframe_stacktrace_libsframest_libsframest_la_CFLAGS) $(CFLAGS) -c -o testsuite/libsframe.stacktrace/libsframest/testsuite_libsframe_stacktrace_libsframest_libsframest_la-sframe-state.lo `test -f 'testsuite/libsframe.stacktrace/libsframest/sframe-state.c' || echo '$(srcdir)/'`testsuite/libsframe.stacktrace/libsframest/sframe-state.c -libsframebt_la-sframe-backtrace-err.lo: sframe-backtrace-err.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libsframebt_la_CPPFLAGS) $(CPPFLAGS) $(libsframebt_la_CFLAGS) $(CFLAGS) -MT libsframebt_la-sframe-backtrace-err.lo -MD -MP -MF $(DEPDIR)/libsframebt_la-sframe-backtrace-err.Tpo -c -o libsframebt_la-sframe-backtrace-err.lo `test -f 'sframe-backtrace-err.c' || echo '$(srcdir)/'`sframe-backtrace-err.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libsframebt_la-sframe-backtrace-err.Tpo $(DEPDIR)/libsframebt_la-sframe-backtrace-err.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='sframe-backtrace-err.c' object='libsframebt_la-sframe-backtrace-err.lo' libtool=yes @AMDEPBACKSLASH@ +testsuite/libsframe.stacktrace/libsframest/testsuite_libsframe_stacktrace_libsframest_libsframest_la-sframe-stacktrace-err.lo: testsuite/libsframe.stacktrace/libsframest/sframe-stacktrace-err.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(testsuite_libsframe_stacktrace_libsframest_libsframest_la_CPPFLAGS) $(CPPFLAGS) $(testsuite_libsframe_stacktrace_libsframest_libsframest_la_CFLAGS) $(CFLAGS) -MT testsuite/libsframe.stacktrace/libsframest/testsuite_libsframe_stacktrace_libsframest_libsframest_la-sframe-stacktrace-err.lo -MD -MP -MF testsuite/libsframe.stacktrace/libsframest/$(DEPDIR)/testsuite_libsframe_stacktrace_libsframest_libsframest_la-sframe-stacktrace-err.Tpo -c -o testsuite/libsframe.stacktrace/libsframest/testsuite_libsframe_stacktrace_libsframest_libsframest_la-sframe-stacktrace-err.lo `test -f 'testsuite/libsframe.stacktrace/libsframest/sframe-stacktrace-err.c' || echo '$(srcdir)/'`testsuite/libsframe.stacktrace/libsframest/sframe-stacktrace-err.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) testsuite/libsframe.stacktrace/libsframest/$(DEPDIR)/testsuite_libsframe_stacktrace_libsframest_libsframest_la-sframe-stacktrace-err.Tpo testsuite/libsframe.stacktrace/libsframest/$(DEPDIR)/testsuite_libsframe_stacktrace_libsframest_libsframest_la-sframe-stacktrace-err.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='testsuite/libsframe.stacktrace/libsframest/sframe-stacktrace-err.c' object='testsuite/libsframe.stacktrace/libsframest/testsuite_libsframe_stacktrace_libsframest_libsframest_la-sframe-stacktrace-err.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libsframebt_la_CPPFLAGS) $(CPPFLAGS) $(libsframebt_la_CFLAGS) $(CFLAGS) -c -o libsframebt_la-sframe-backtrace-err.lo `test -f 'sframe-backtrace-err.c' || echo '$(srcdir)/'`sframe-backtrace-err.c +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(testsuite_libsframe_stacktrace_libsframest_libsframest_la_CPPFLAGS) $(CPPFLAGS) $(testsuite_libsframe_stacktrace_libsframest_libsframest_la_CFLAGS) $(CFLAGS) -c -o testsuite/libsframe.stacktrace/libsframest/testsuite_libsframe_stacktrace_libsframest_libsframest_la-sframe-stacktrace-err.lo `test -f 'testsuite/libsframe.stacktrace/libsframest/sframe-stacktrace-err.c' || echo '$(srcdir)/'`testsuite/libsframe.stacktrace/libsframest/sframe-stacktrace-err.c testsuite/libsframe.decode/testsuite_libsframe_decode_be_flipping-be-flipping.o: testsuite/libsframe.decode/be-flipping.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(testsuite_libsframe_decode_be_flipping_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT testsuite/libsframe.decode/testsuite_libsframe_decode_be_flipping-be-flipping.o -MD -MP -MF testsuite/libsframe.decode/$(DEPDIR)/testsuite_libsframe_decode_be_flipping-be-flipping.Tpo -c -o testsuite/libsframe.decode/testsuite_libsframe_decode_be_flipping-be-flipping.o `test -f 'testsuite/libsframe.decode/be-flipping.c' || echo '$(srcdir)/'`testsuite/libsframe.decode/be-flipping.c @@ -965,6 +1005,7 @@ clean-libtool: -rm -rf testsuite/libsframe.decode/.libs testsuite/libsframe.decode/_libs -rm -rf testsuite/libsframe.encode/.libs testsuite/libsframe.encode/_libs -rm -rf testsuite/libsframe.find/.libs testsuite/libsframe.find/_libs + -rm -rf testsuite/libsframe.stacktrace/libsframest/.libs testsuite/libsframe.stacktrace/libsframest/_libs distclean-libtool: -rm -f libtool config.lt @@ -1387,7 +1428,7 @@ distcleancheck: distclean $(distcleancheck_listfiles) ; \ exit 1; } >&2 check-am: all-am - $(MAKE) $(AM_MAKEFLAGS) $(check_PROGRAMS) + $(MAKE) $(AM_MAKEFLAGS) $(check_LTLIBRARIES) $(check_PROGRAMS) $(MAKE) $(AM_MAKEFLAGS) check-DEJAGNU check: check-am all-am: Makefile $(INFO_DEPS) $(LTLIBRARIES) $(HEADERS) config.h @@ -1428,6 +1469,8 @@ distclean-generic: -rm -f testsuite/libsframe.encode/$(am__dirstamp) -rm -f testsuite/libsframe.find/$(DEPDIR)/$(am__dirstamp) -rm -f testsuite/libsframe.find/$(am__dirstamp) + -rm -f testsuite/libsframe.stacktrace/libsframest/$(DEPDIR)/$(am__dirstamp) + -rm -f testsuite/libsframe.stacktrace/libsframest/$(am__dirstamp) -test -z "$(DISTCLEANFILES)" || rm -f $(DISTCLEANFILES) maintainer-clean-generic: @@ -1437,13 +1480,13 @@ maintainer-clean-generic: @BUILD_INFO_FALSE@html-local: clean: clean-am -clean-am: clean-aminfo clean-checkPROGRAMS clean-generic \ - clean-libLTLIBRARIES clean-libtool clean-noinstLTLIBRARIES \ - mostlyclean-am +clean-am: clean-aminfo clean-checkLTLIBRARIES clean-checkPROGRAMS \ + clean-generic clean-libLTLIBRARIES clean-libtool \ + clean-noinstLTLIBRARIES mostlyclean-am distclean: distclean-am -rm -f $(am__CONFIG_DISTCLEAN_FILES) - -rm -rf ./$(DEPDIR) testsuite/libsframe.decode/$(DEPDIR) testsuite/libsframe.encode/$(DEPDIR) testsuite/libsframe.find/$(DEPDIR) + -rm -rf ./$(DEPDIR) testsuite/libsframe.decode/$(DEPDIR) testsuite/libsframe.encode/$(DEPDIR) testsuite/libsframe.find/$(DEPDIR) testsuite/libsframe.stacktrace/libsframest/$(DEPDIR) -rm -f Makefile distclean-am: clean-am distclean-DEJAGNU distclean-compile \ distclean-generic distclean-hdr distclean-libtool \ @@ -1583,7 +1626,7 @@ installcheck-am: maintainer-clean: maintainer-clean-am -rm -f $(am__CONFIG_DISTCLEAN_FILES) -rm -rf $(top_srcdir)/autom4te.cache - -rm -rf ./$(DEPDIR) testsuite/libsframe.decode/$(DEPDIR) testsuite/libsframe.encode/$(DEPDIR) testsuite/libsframe.find/$(DEPDIR) + -rm -rf ./$(DEPDIR) testsuite/libsframe.decode/$(DEPDIR) testsuite/libsframe.encode/$(DEPDIR) testsuite/libsframe.find/$(DEPDIR) testsuite/libsframe.stacktrace/libsframest/$(DEPDIR) -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-aminfo \ maintainer-clean-generic @@ -1608,15 +1651,16 @@ uninstall-am: uninstall-dvi-am uninstall-html-am \ .MAKE: all check-am install-am install-strip .PHONY: CTAGS GTAGS TAGS all all-am am--refresh check check-DEJAGNU \ - check-am clean clean-aminfo clean-checkPROGRAMS clean-cscope \ - clean-generic clean-libLTLIBRARIES clean-libtool \ - clean-noinstLTLIBRARIES cscope cscopelist-am ctags ctags-am \ - dist dist-all dist-bzip2 dist-gzip dist-info dist-lzip \ - dist-shar dist-tarZ dist-xz dist-zip distcheck distclean \ - distclean-DEJAGNU distclean-compile distclean-generic \ - distclean-hdr distclean-libtool distclean-tags distcleancheck \ - distdir distuninstallcheck dvi dvi-am html html-am html-local \ - info info-am install install-am install-data install-data-am \ + check-am clean clean-aminfo clean-checkLTLIBRARIES \ + clean-checkPROGRAMS clean-cscope clean-generic \ + clean-libLTLIBRARIES clean-libtool clean-noinstLTLIBRARIES \ + cscope cscopelist-am ctags ctags-am dist dist-all dist-bzip2 \ + dist-gzip dist-info dist-lzip dist-shar dist-tarZ dist-xz \ + dist-zip distcheck distclean distclean-DEJAGNU \ + distclean-compile distclean-generic distclean-hdr \ + distclean-libtool distclean-tags distcleancheck distdir \ + distuninstallcheck dvi dvi-am html html-am html-local info \ + info-am install install-am install-data install-data-am \ install-dvi install-dvi-am install-exec install-exec-am \ install-html install-html-am install-includeHEADERS \ install-info install-info-am install-libLTLIBRARIES \ @@ -1654,12 +1698,13 @@ check-DEJAGNU: site.exp CC="$(CC)" \ CROSS_COMPILE="$(CROSS_COMPILE)" \ COMPAT_DEJAGNU="$(COMPAT_DEJAGNU)" \ - CFLAGS="$(CFLAGS) -I$(top_srcdir)/../include -I$(top_srcdir) -I$(top_builddir)" \ + HAVE_DL_ITERATE_PHDR="$(HAVE_DL_ITERATE_PHDR)" \ + CFLAGS="$(CFLAGS) -I$(top_srcdir)/../include -I$(top_srcdir) -I$(top_srcdir)/testsuite/libsframe.stacktrace/libsframest/include -I$(top_builddir)" \ $(RUNTESTFLAGS); \ else echo "WARNING: could not find \`runtest'" 1>&2; :;\ fi -# libsframe encoder/decoder/find testsuite +# libsframe encoder/decoder/stacktracer testsuite # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. diff --git a/libsframe/config.h.in b/libsframe/config.h.in index 74810fd..b6ab632 100644 --- a/libsframe/config.h.in +++ b/libsframe/config.h.in @@ -3,6 +3,9 @@ /* Define to 1 if you have the <byteswap.h> header file. */ #undef HAVE_BYTESWAP_H +/* Define to 1 if you have the declaration of `', and to 0 if you don't. */ +#undef HAVE_DECL_ + /* Define to 1 if you have the declaration of `bswap_16', and to 0 if you don't. */ #undef HAVE_DECL_BSWAP_16 @@ -18,6 +21,9 @@ /* Define to 1 if you have the <dlfcn.h> header file. */ #undef HAVE_DLFCN_H +/* Define if dl_iterate_phdr is available. */ +#undef HAVE_DL_ITERATE_PHDR + /* Define to 1 if you have the <endian.h> header file. */ #undef HAVE_ENDIAN_H @@ -27,6 +33,9 @@ /* Define to 1 if you have the <inttypes.h> header file. */ #undef HAVE_INTTYPES_H +/* Define to 1 if you have the <link.h> header file. */ +#undef HAVE_LINK_H + /* Define to 1 if you have the <memory.h> header file. */ #undef HAVE_MEMORY_H diff --git a/libsframe/configure b/libsframe/configure index 5f4d613..03b1b47 100755 --- a/libsframe/configure +++ b/libsframe/configure @@ -634,6 +634,8 @@ ac_subst_vars='am__EXEEXT_FALSE am__EXEEXT_TRUE LTLIBOBJS LIBOBJS +HAVE_DL_ITERATE_PHDR_FALSE +HAVE_DL_ITERATE_PHDR_TRUE bfdincludedir bfdlibdir target_noncanonical @@ -11565,7 +11567,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 11568 "configure" +#line 11570 "configure" #include "confdefs.h" #if HAVE_DLFCN_H @@ -11671,7 +11673,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 11674 "configure" +#line 11676 "configure" #include "confdefs.h" #if HAVE_DLFCN_H @@ -12856,6 +12858,67 @@ cat >>confdefs.h <<_ACEOF _ACEOF +for ac_header in link.h +do : + ac_fn_c_check_header_mongrel "$LINENO" "link.h" "ac_cv_header_link_h" "$ac_includes_default" +if test "x$ac_cv_header_link_h" = xyes; then : + cat >>confdefs.h <<_ACEOF +#define HAVE_LINK_H 1 +_ACEOF + +fi + +done + +if test "$ac_cv_header_link_h" = "no"; then + have_dl_iterate_phdr=no +else + ac_fn_c_check_func "$LINENO" "dl_iterate_phdr" "ac_cv_func_dl_iterate_phdr" +if test "x$ac_cv_func_dl_iterate_phdr" = xyes; then : + have_dl_iterate_phdr=yes +else + have_dl_iterate_phdr=no +fi + +fi +if test "$have_dl_iterate_phdr" = "yes"; then + +$as_echo "#define HAVE_DL_ITERATE_PHDR 1" >>confdefs.h + +fi + if test "x$have_dl_iterate_phdr" = "xyes"; then + HAVE_DL_ITERATE_PHDR_TRUE= + HAVE_DL_ITERATE_PHDR_FALSE='#' +else + HAVE_DL_ITERATE_PHDR_TRUE='#' + HAVE_DL_ITERATE_PHDR_FALSE= +fi + + +for ac_header in link.h +do : + ac_fn_c_check_header_mongrel "$LINENO" "link.h" "ac_cv_header_link_h" "$ac_includes_default" +if test "x$ac_cv_header_link_h" = xyes; then : + cat >>confdefs.h <<_ACEOF +#define HAVE_LINK_H 1 +_ACEOF + +fi + +done + +ac_fn_c_check_decl "$LINENO" "" "ac_cv_have_decl_" "$ac_includes_default" +if test "x$ac_cv_have_decl_" = xyes; then : + ac_have_decl=1 +else + ac_have_decl=0 +fi + +cat >>confdefs.h <<_ACEOF +#define HAVE_DECL_ $ac_have_decl +_ACEOF + + ac_config_files="$ac_config_files Makefile" ac_config_headers="$ac_config_headers config.h" @@ -13021,6 +13084,10 @@ if test -z "${INSTALL_LIBBFD_TRUE}" && test -z "${INSTALL_LIBBFD_FALSE}"; then as_fn_error $? "conditional \"INSTALL_LIBBFD\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi +if test -z "${HAVE_DL_ITERATE_PHDR_TRUE}" && test -z "${HAVE_DL_ITERATE_PHDR_FALSE}"; then + as_fn_error $? "conditional \"HAVE_DL_ITERATE_PHDR\" was never defined. +Usually this means the macro was only invoked conditionally." "$LINENO" 5 +fi : "${CONFIG_STATUS=./config.status}" ac_write_fail=0 diff --git a/libsframe/configure.ac b/libsframe/configure.ac index 3059303..fdd4a6d 100644 --- a/libsframe/configure.ac +++ b/libsframe/configure.ac @@ -138,6 +138,25 @@ AC_CHECK_HEADERS(byteswap.h endian.h) dnl Check for bswap_{16,32,64} AC_CHECK_DECLS([bswap_16, bswap_32, bswap_64], [], [], [[#include <byteswap.h>]]) +dnl Check for dl_iterate_phdr. Used in the libsframe.stacktrace testsuite. +dnl The stacktrace testsuite is NOT built and run for build != target. +AC_CHECK_HEADERS(link.h) +if test "$ac_cv_header_link_h" = "no"; then + have_dl_iterate_phdr=no +else + AC_CHECK_FUNC([dl_iterate_phdr], + [have_dl_iterate_phdr=yes], + [have_dl_iterate_phdr=no]) +fi +if test "$have_dl_iterate_phdr" = "yes"; then + AC_DEFINE(HAVE_DL_ITERATE_PHDR, 1, [Define if dl_iterate_phdr is available.]) +fi +AM_CONDITIONAL([HAVE_DL_ITERATE_PHDR], [test "x$have_dl_iterate_phdr" = "xyes"]) + +dnl Check for dl_iterate_phdr +AC_CHECK_HEADERS(link.h) +AC_CHECK_DECLS + AC_CONFIG_FILES(Makefile) AC_CONFIG_HEADERS(config.h) AC_OUTPUT diff --git a/libsframe/sframe-backtrace.c b/libsframe/sframe-backtrace.c deleted file mode 100644 index 65fa018..0000000 --- a/libsframe/sframe-backtrace.c +++ /dev/null @@ -1,609 +0,0 @@ -/* sframe-backtrace.c - The SFrame backtracer. - - Copyright (C) 2022 Free Software Foundation, Inc. - - This file is part of libsframebt. - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. */ - -#include "config.h" -#include <link.h> -#include <stdlib.h> -#include <stdio.h> -#include <inttypes.h> -#include <stdbool.h> -#include <assert.h> -#include <execinfo.h> -#include <unistd.h> -#include <fcntl.h> -#include <string.h> -#include <ucontext.h> -#include <stdarg.h> -#include "ansidecl.h" -#include "sframe-api.h" -#include "sframe-backtrace-api.h" -#include "sframe-backtrace-regs.h" - -#ifndef PT_SFRAME -#define PT_SFRAME 0x6474e554 /* FIXME. */ -#endif - -#define _sf_printflike_(string_index, first_to_check) ATTRIBUTE_PRINTF (1, 2) - -static bool _sframe_unwind_debug; /* Control for printing out debug info. */ -static const int no_of_entries = NUM_OF_DSOS; - -/* SFrame decode data for the main module or a DSO. */ -struct sframe_decode_data -{ - char *sfdd_data; /* SFrame decode data. */ - int sfdd_data_size; /* SFrame decode data size. */ - uint64_t sfdd_text_vma; /* Text segment's virtual address. */ - int sfdd_text_size; /* Text segment's size. */ - uint64_t sfdd_sframe_vma; /* SFrame segment's virtual address. */ - sframe_decoder_ctx *sfdd_sframe_ctx; /* SFrame decoder context. */ -}; - -/* List that holds SFrame info for the shared libraries. */ -struct dso_cfi_list -{ - int alloced; /* Entries allocated. */ - int used; /* Entries used. */ - struct sframe_decode_data *entry; /* DSO's decode data. */ -}; - -/* Data that's passed through sframe_callback. */ -struct sframe_unwind_info -{ - int sui_fd; /* File descriptor. */ - struct sframe_decode_data sui_ctx; /* The decode data. */ - struct dso_cfi_list sui_dsos; /* The DSO list. */ -}; - -static void -sframe_unwind_init_debug (void) -{ - static int inited; - - if (!inited) - { - _sframe_unwind_debug = getenv ("SFRAME_UNWIND_DEBUG") != NULL; - inited = 1; - } -} - -_sf_printflike_ (1, 2) -static void -debug_printf (const char *format, ...) -{ - if (_sframe_unwind_debug == true) - { - va_list args; - - va_start (args, format); - __builtin_vprintf (format, args); - va_end (args); - } -} - -/* sframe_bt_errno - Check if there is error code in ERRP. */ - -static int -sframe_bt_errno (const int *errp) -{ - if (errp == NULL) - return 0; - - return (*errp != SFRAME_BT_OK); -} - -/* sframe_bt_set_errno - Store the specified error code ERROR into ERRP if - it is non-NULL. */ - -static void -sframe_bt_set_errno (int *errp, int error) -{ - if (errp != NULL) - *errp = error; -} - -/* sframe_add_dso - Add .sframe info in D_DATA, which is associated with - a dynamic shared object, to D_LIST. */ - -static void -sframe_add_dso (struct dso_cfi_list *d_list, - struct sframe_decode_data d_data, - int *errp) -{ - if (d_list->alloced == 0) - { - d_list->entry = malloc (no_of_entries * sizeof (struct sframe_decode_data)); - if (d_list->entry == NULL) - { - sframe_bt_set_errno (errp, SFRAME_BT_ERR_MALLOC); - return; - } - memset (d_list->entry, 0, - no_of_entries * sizeof (struct sframe_decode_data)); - d_list->alloced = no_of_entries; - } - else if (d_list->used == d_list->alloced) - { - d_list->entry = realloc (d_list->entry, - ((d_list->alloced + no_of_entries) - * sizeof (struct sframe_decode_data))); - if (d_list->entry == NULL) - { - sframe_bt_set_errno (errp, SFRAME_BT_ERR_REALLOC); - return; - } - - memset (&d_list->entry[d_list->alloced], 0, - no_of_entries * sizeof (struct sframe_decode_data)); - d_list->alloced += no_of_entries; - } - - sframe_bt_set_errno (errp, SFRAME_BT_OK); - d_list->entry[d_list->used++] = d_data; -} - -/* sframe_free_cfi - Free up space allocated for .sframe info for CF. */ - -static void -sframe_free_cfi (struct sframe_unwind_info *sf) -{ - struct dso_cfi_list *d_list; - int i; - - if (sf == NULL) - return; - - free (sf->sui_ctx.sfdd_data); - sframe_decoder_free (&sf->sui_ctx.sfdd_sframe_ctx); - close (sf->sui_fd); - - d_list = &sf-> sui_dsos; - if (d_list == NULL) - return; - - for (i = 0; i < d_list->used; ++i) - { - free (d_list->entry[i].sfdd_data); - sframe_decoder_free (&d_list->entry[i].sfdd_sframe_ctx); - } - - free (d_list->entry); -} - -/* sframe_find_context - Find the decode data that contains ADDR from CF. - Return the pointer to the decode data or NULL. */ - -static struct sframe_decode_data * -sframe_find_context (struct sframe_unwind_info *sf, uint64_t addr) -{ - struct dso_cfi_list *d_list; - struct sframe_decode_data sdec_data; - int i; - - if (sf == NULL) - return NULL; - - if (sf->sui_ctx.sfdd_text_vma < addr - && sf->sui_ctx.sfdd_text_vma + sf->sui_ctx.sfdd_text_size > addr) - return &sf->sui_ctx; - - d_list = &sf->sui_dsos; - for (i = 0; i < sf->sui_dsos.used; ++i) - { - sdec_data = d_list->entry[i]; - if ((sdec_data.sfdd_text_vma <= addr) - && (sdec_data.sfdd_text_vma + sdec_data.sfdd_text_size >= addr)) - return &d_list->entry[i]; - } - - return NULL; -} - -/* sframe_valid_addr - Check if ADDR is valid in CF. The address is considered - invalid, with regards to SFrame, if it's not in any address range of the - main module or any of its DSO's. Return 1 if valid, 0 otherwise. */ - -static int -sframe_valid_addr (struct sframe_unwind_info *sf, uint64_t addr) -{ - struct sframe_decode_data *cdp; - - if (sf == NULL) - return 0; - - cdp = sframe_find_context (sf, addr); - return cdp ? 1 : 0; -} - -/* sframe_load_ctx - Call decoder to create and set up the SFrame info for - either the main module or one of the DSOs from CF, based on the input - RADDR argument. Return the newly created decode context or NULL. */ - -static sframe_decoder_ctx * -sframe_load_ctx (struct sframe_unwind_info *sf, uint64_t raddr) -{ - sframe_decoder_ctx *nctx; - struct sframe_decode_data *cdp; - - if (sf == NULL) - return NULL; - - cdp = sframe_find_context (sf, raddr); - if (cdp == NULL) - return NULL; - - if (cdp->sfdd_sframe_ctx == NULL) - { - int err; - nctx = sframe_decode (cdp->sfdd_data, cdp->sfdd_data_size, &err); - if (nctx == NULL) - return NULL; - cdp->sfdd_sframe_ctx = nctx; - return nctx; - } - - return NULL; -} - -/* sframe_update_ctx - Check if need to do a decode context switch, based on - the input RADDR argument, from CF. A new decode context will be created - and set up if it isn't already done so. Return the new decode context in - CTX and vma in CFI_VMA. */ - -static void -sframe_update_ctx (struct sframe_unwind_info *sf, uint64_t raddr, - sframe_decoder_ctx **ctx, uint64_t *cfi_vma) -{ - sframe_decoder_ctx *nctx; - struct sframe_decode_data *cdp; - - cdp = sframe_find_context (sf, raddr); - if (cdp != NULL) - { - if (cdp->sfdd_sframe_ctx == NULL) - { - int err; - nctx = sframe_decode (cdp->sfdd_data, cdp->sfdd_data_size, &err); - if (nctx == NULL) - { - *ctx = NULL; - return; - } - cdp->sfdd_sframe_ctx = nctx; - } - *ctx = cdp->sfdd_sframe_ctx; - *cfi_vma = cdp->sfdd_sframe_vma; - } -} - -/* get_contents - Return contents at ADDR from file descriptor FD. */ - -static uint64_t -get_contents (int fd, uint64_t addr, int *errp) -{ - uint64_t data; - size_t sz; - - sframe_bt_set_errno (errp, SFRAME_BT_OK); - if (lseek (fd, addr, SEEK_SET) == -1) - { - sframe_bt_set_errno (errp, SFRAME_BT_ERR_LSEEK); - return 0; - } - sz = read (fd, &data, sizeof (uint64_t)); - if (sz != sizeof (uint64_t)) - { - sframe_bt_set_errno (errp, SFRAME_BT_ERR_READ); - return 0; - } - - return data; -} - -/* sframe_fd_open - Open /proc image associated with the process id and return - the file descriptor. */ - -static int -sframe_fd_open (int *errp) -{ - int fd; - - if ((fd = open ("/proc/self/mem", O_CLOEXEC)) == -1) - { - sframe_bt_set_errno (errp, SFRAME_BT_ERR_OPEN); - return -1; - } - - return fd; -} - -/* sframe_callback - The callback from dl_iterate_phdr with header info - in INFO. - Return SFrame info for either the main module or a DSO in DATA. */ - -static int -sframe_callback (struct dl_phdr_info *info, - size_t size ATTRIBUTE_UNUSED, - void *data) -{ - struct sframe_unwind_info *sf = (struct sframe_unwind_info *) data; - int p_type, i, fd, sframe_err; - ssize_t len; - uint64_t text_vma = 0; - int text_size = 0; - - if (data == NULL || info == NULL) - return 1; - - debug_printf ("-- name: %s %14p\n", info->dlpi_name, (void *)info->dlpi_addr); - - for (i = 0; i < info->dlpi_phnum; i++) - { - debug_printf (" %2d: [%" PRIu64 "; memsz %" PRIu64 "] flags: 0x%x; \n", i, - (uint64_t) info->dlpi_phdr[i].p_vaddr, - (uint64_t) info->dlpi_phdr[i].p_memsz, - info->dlpi_phdr[i].p_flags); - - p_type = info->dlpi_phdr[i].p_type; - if (p_type == PT_LOAD && info->dlpi_phdr[i].p_flags & PF_X) - { - text_vma = info->dlpi_addr + info->dlpi_phdr[i].p_vaddr; - text_size = info->dlpi_phdr[i].p_memsz; - continue; - } - if (p_type != PT_SFRAME) - continue; - - if (info->dlpi_name[0] == '\0') /* the main module. */ - { - fd = sframe_fd_open (&sframe_err); - if (fd == -1) - return 1; - if (lseek (fd, info->dlpi_addr + info->dlpi_phdr[i].p_vaddr, - SEEK_SET) == -1) - { - sframe_bt_set_errno (&sframe_err, SFRAME_BT_ERR_LSEEK); - return 1; - } - - sf->sui_ctx.sfdd_data = malloc (info->dlpi_phdr[i].p_memsz); - if (sf->sui_ctx.sfdd_data == NULL) - { - sframe_bt_set_errno (&sframe_err, SFRAME_BT_ERR_MALLOC); - return 1; - } - - len = read (fd, sf->sui_ctx.sfdd_data, info->dlpi_phdr[i].p_memsz); - if (len == -1 || len != (ssize_t) info->dlpi_phdr[i].p_memsz) - { - sframe_bt_set_errno (&sframe_err, SFRAME_BT_ERR_READ); - return 1; - } - - assert (text_vma); - sf->sui_ctx.sfdd_data_size = len; - sf->sui_ctx.sfdd_sframe_vma = info->dlpi_addr + info->dlpi_phdr[i].p_vaddr; - sf->sui_fd = fd; - sf->sui_ctx.sfdd_text_vma = text_vma; - sf->sui_ctx.sfdd_text_size = text_size; - text_vma = 0; - return 0; - } - else - { /* a dynamic shared object. */ - struct sframe_decode_data dt; - memset (&dt, 0, sizeof (struct sframe_decode_data)); - assert (sf->sui_fd); - if (lseek (sf->sui_fd, info->dlpi_addr + info->dlpi_phdr[i].p_vaddr, - SEEK_SET) == -1) - { - sframe_bt_set_errno (&sframe_err, SFRAME_BT_ERR_LSEEK); - return 1; - } - - dt.sfdd_data = malloc (info->dlpi_phdr[i].p_memsz); - if (dt.sfdd_data == NULL) - { - sframe_bt_set_errno (&sframe_err, SFRAME_BT_ERR_MALLOC); - return 1; - } - - len = read (sf->sui_fd, dt.sfdd_data, info->dlpi_phdr[i].p_memsz); - if (len == -1 || len != (ssize_t) info->dlpi_phdr[i].p_memsz) - { - sframe_bt_set_errno (&sframe_err, SFRAME_BT_ERR_READ); - return 1; - } - - assert (text_vma); - dt.sfdd_data_size = len; - dt.sfdd_sframe_vma = info->dlpi_addr + info->dlpi_phdr[i].p_vaddr; - dt.sfdd_text_vma = text_vma; - dt.sfdd_text_size = text_size; - text_vma = 0; - sframe_add_dso (&sf->sui_dsos, dt, &sframe_err); - if (sframe_err != SFRAME_BT_OK) - return 1; - return 0; - } - } - - return 0; -} - -/* sframe_unwind - Unwind the stack backtrace for CF. If successful, - store the return addresses in RA_LST. The RA_SIZE argument specifies - the maximum number of return addresses that can be stored in RA_LST - and contains the number of the addresses collected. */ - -static void -sframe_unwind (struct sframe_unwind_info *sf, void **ra_lst, - int *ra_size, int *errp) -{ - uint64_t cfa, return_addr, ra_stack_loc, rfp_stack_loc; - int8_t fixed_ra_offset; - sframe_decoder_ctx *ctx; - int cfa_offset, rfp_offset, errnum, i, count; - sframe_frame_row_entry fred, *frep = &fred; - uint64_t pc, rfp, rsp, ra, cfi_vma; - ucontext_t context, *cp = &context; - - if (sf == NULL || ra_lst == NULL || ra_size == NULL) - { - sframe_bt_set_errno (errp, SFRAME_BT_ERR_ARG); - return; - } - - /* Get the user context for its registers. */ - if (getcontext (cp) != 0) - { - sframe_bt_set_errno (errp, SFRAME_BT_ERR_GETCONTEXT); - return; - } - sframe_bt_set_errno (errp, SFRAME_BT_OK); - - pc = get_context_pc (cp); - rsp = get_context_rsp (cp); - rfp = get_context_rfp (cp); - ra = get_context_ra (cp); - - /* Load and set up the decoder. */ - ctx = sframe_load_ctx (sf, pc); - if (ctx == NULL) - { - sframe_bt_set_errno (errp, SFRAME_BT_ERR_DECODE); - return; - } - cfi_vma = sf->sui_ctx.sfdd_sframe_vma; - count = *ra_size; - - for (i = 0; i < count; ++i) - { - pc -= cfi_vma; - errnum = sframe_find_fre (ctx, pc, frep); - if (errnum == 0) - { - cfa_offset = sframe_fre_get_cfa_offset (ctx, frep, &errnum); - if (errnum == SFRAME_ERR_FREOFFSET_NOPRESENT) - { - sframe_bt_set_errno (errp, SFRAME_BT_ERR_CFA_OFFSET); - return; - } - - cfa = ((frep->fre_info & 0x1) == SFRAME_BASE_REG_SP - ? rsp : rfp) + cfa_offset; - -#ifdef __x86_64__ - /* For x86, read the return address from the fixed RA offset from - the SFrame header. RA must be at location CFA - 8. */ - fixed_ra_offset = sframe_decoder_get_fixed_ra_offset (ctx); - if (fixed_ra_offset == SFRAME_CFA_FIXED_RA_INVALID) - return; - - ra_stack_loc = cfa + fixed_ra_offset; - return_addr = get_contents (sf->sui_fd, ra_stack_loc, errp); - if (sframe_bt_errno (errp)) - return; -#else -#ifdef __aarch64__ - int ra_offset = sframe_fre_get_ra_offset (ctx, frep, &errnum); - if (errnum == 0) - { - ra_stack_loc = cfa + ra_offset; - return_addr = get_contents (sf->sui_fd, ra_stack_loc, errp); - if (sframe_bt_errno (errp)) - return; - } - else - return_addr = ra; -#endif -#endif - - /* Validate and add return address to the list. */ - if (sframe_valid_addr (sf, return_addr) == 0) - { - i -= 1; - goto find_fre_ra_err; - } - if (i != 0) /* exclude self. */ - ra_lst[i-1] = (void *)return_addr; - - /* Set up for the next frame. */ - rfp_offset = sframe_fre_get_fp_offset (ctx, frep, &errnum); - if (errnum == 0) - { - rfp_stack_loc = cfa + rfp_offset; - rfp = get_contents (sf->sui_fd, rfp_stack_loc, errp); - if (sframe_bt_errno (errp)) - return; - } - rsp = cfa; - pc = return_addr; - - /* Check if need to update the decoder context and vma. */ - sframe_update_ctx (sf, return_addr, &ctx, &cfi_vma); - if (ctx == NULL) - { - sframe_bt_set_errno (errp, SFRAME_BT_ERR_DECODE); - return; - } - } - else - { - i -= 1; - goto find_fre_ra_err; - } - } - -find_fre_ra_err: - *ra_size = i; -} - -/* sframe_backtrace - Main API that user program calls to get a backtrace. - The BUFFER argument provides space for the list of the return addresses - and the SIZE argument specifies the maximum number of addresses that - can be stored in the buffer. Return the number of return addresses - collected or -1 if there is any error. */ - -int -sframe_backtrace (void **buffer, int size, int *errp) -{ - struct sframe_unwind_info sframeinfo; - - sframe_unwind_init_debug (); - - memset (&sframeinfo, 0, sizeof (struct sframe_unwind_info)); - - /* find and set up the .sframe sections. */ - (void) dl_iterate_phdr (sframe_callback, (void *)&sframeinfo); - if (sframeinfo.sui_fd == 0) - { - sframe_bt_set_errno (errp, SFRAME_BT_ERR_NOTPRESENT); - return -1; - } - - /* Do the stack unwinding. */ - sframe_unwind (&sframeinfo, buffer, &size, errp); - if (sframe_bt_errno (errp)) - size = -1; - - sframe_free_cfi (&sframeinfo); - - return size; -} diff --git a/libsframe/testsuite/libsframe.stacktrace/libsframest/README b/libsframe/testsuite/libsframe.stacktrace/libsframest/README new file mode 100644 index 0000000..c3b1e03 --- /dev/null +++ b/libsframe/testsuite/libsframe.stacktrace/libsframest/README @@ -0,0 +1,7 @@ +libsframest +=========== + +libsframest is the SFrame stack tracer library. + +The current usecase libsframest fulfills here is: aid testing stack +tracing in libsframe testsuite. diff --git a/include/sframe-backtrace-api.h b/libsframe/testsuite/libsframe.stacktrace/libsframest/include/sframe-stacktrace-api.h index b9537bf..43a23bb 100644 --- a/include/sframe-backtrace-api.h +++ b/libsframe/testsuite/libsframe.stacktrace/libsframest/include/sframe-stacktrace-api.h @@ -1,8 +1,8 @@ -/* Public API to SFrame backtrace. +/* Public API to SFrame stacktracer. - Copyright (C) 2022 Free Software Foundation, Inc. + Copyright (C) 2023 Free Software Foundation, Inc. - This file is part of libsframebt. + This file is part of libsframest. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -28,7 +28,7 @@ extern "C" enum sframe_bt_errcode { SFRAME_BT_OK, - SFRAME_BT_ERR_NOTPRESENT, + SFRAME_BT_ERR_BAD_SFSTATE, SFRAME_BT_ERR_ARG, SFRAME_BT_ERR_MALLOC, SFRAME_BT_ERR_REALLOC, @@ -39,20 +39,27 @@ enum sframe_bt_errcode SFRAME_BT_ERR_GETCONTEXT, SFRAME_BT_ERR_DECODE, SFRAME_BT_ERR_CFA_OFFSET, + SFRAME_BT_ERR_FRE_INVAL, }; +#define SFRAME_BT_ERR ((int) -1) + #define NUM_OF_DSOS 32 /* Number of DSOs. */ #define ENUM_ARRAY_SIZE(a) (sizeof (a) / sizeof ((a)[0])) -/* Get the backtrace of the calling program by storing return addresses +/* Get the stacktrace of the calling program by storing return addresses in BUFFER. The SIZE argument specifies the maximum number of addresses that can be stored in the buffer. Return the number of return addresses collected or -1 if there is any error. */ -extern int sframe_backtrace (void **buffer, int size, int *errp); +extern int sframe_stacktrace (void **buffer, int size, int *errp); extern const char *sframe_bt_errmsg (enum sframe_bt_errcode ecode); +extern int sframe_bt_ret_set_errno (int *errp, int error); + +extern int sframe_bt_errno (const int *errp); + #ifdef __cplusplus } #endif diff --git a/libsframe/testsuite/libsframe.stacktrace/libsframest/local.mk b/libsframe/testsuite/libsframe.stacktrace/libsframest/local.mk new file mode 100644 index 0000000..60673ba --- /dev/null +++ b/libsframe/testsuite/libsframe.stacktrace/libsframest/local.mk @@ -0,0 +1,16 @@ +check_LTLIBRARIES = + +if HAVE_SFRAME_AS +if HAVE_DL_ITERATE_PHDR + check_LTLIBRARIES += %D%/libsframest.la +endif +endif + +%C%_libsframest_la_SOURCES = %D%/sframe-stacktrace.c \ + %D%/sframe-state.c \ + %D%/sframe-stacktrace-err.c +%C%_libsframest_la_LIBADD = ${top_builddir}/libsframe.la +%C%_libsframest_la_CPPFLAGS = -I${top_srcdir}/../include \ + -I${top_srcdir}/%D%/include \ + -Wall -Wno-unused-but-set-variable +%C%_libsframest_la_CFLAGS = -Wa,--gsframe diff --git a/libsframe/sframe-backtrace-err.c b/libsframe/testsuite/libsframe.stacktrace/libsframest/sframe-stacktrace-err.c index 935509e..4f64b4d 100644 --- a/libsframe/sframe-backtrace-err.c +++ b/libsframe/testsuite/libsframe.stacktrace/libsframest/sframe-stacktrace-err.c @@ -1,8 +1,8 @@ -/* sframe-backtrace-err.c - SFrame Backtrace Error table. +/* sframe-stacktrace-err.c - SFrame Stacktrace Error table. - Copyright (C) 2022 Free Software Foundation, Inc. + Copyright (C) 2023 Free Software Foundation, Inc. - This file is part of libsframebt. + This file is part of libsframest. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -18,14 +18,14 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. */ #include "config.h" -#include "sframe-backtrace-api.h" +#include "sframe-stacktrace-api.h" -/* SFrame backtrace error messages. */ +/* SFrame stacktrace error messages. */ static const char *const sframe_bt_errlist[] = { "", - "File does not contain SFrame data", - "Iterating shared object reading error", + "Failed to setup SFrame state for stack tracing", + "Bad arguments; Unhealthy SFrame state possible", "Failed to malloc memory space", "Failed to realloc memory space", "Failed to open file", @@ -34,7 +34,8 @@ static const char *const sframe_bt_errlist[] = "Failed to read from a file descriptor", "Failed to get the user context", "Failed to set up decode data", - "Illegal CFA offset" + "Illegal CFA offset", + "Corrupt FRE" }; /* Return the error message associated with the error code. */ @@ -47,3 +48,24 @@ sframe_bt_errmsg (enum sframe_bt_errcode ecode) return sframe_bt_errlist[ecode]; } + +/* sframe_bt_errno - Check if there is error code in ERRP. */ + +int +sframe_bt_errno (const int *errp) +{ + if (!errp) + return 0; + + return (*errp != SFRAME_BT_OK); +} + +int +sframe_bt_ret_set_errno (int *errp, int error) +{ + if (errp) + *errp = error; + + return error; +} + diff --git a/libsframe/sframe-backtrace-regs.h b/libsframe/testsuite/libsframe.stacktrace/libsframest/sframe-stacktrace-regs.h index 1932869..88da50b 100644 --- a/libsframe/sframe-backtrace-regs.h +++ b/libsframe/testsuite/libsframe.stacktrace/libsframest/sframe-stacktrace-regs.h @@ -1,8 +1,8 @@ -/* The SFrame backtracer - accessing target registers. +/* The SFrame stacktracer - accessing target registers. - Copyright (C) 2022 Free Software Foundation, Inc. + Copyright (C) 2023 Free Software Foundation, Inc. - This file is part of libsframebt. + This file is part of libsframest. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -20,6 +20,9 @@ #include <stdint.h> #include <ucontext.h> +#ifndef SFRAME_STACKTRACE_REGS_H +#define SFRAME_STACKTRACE_REGS_H + #if defined (__x86_64__) static inline uint64_t @@ -75,3 +78,5 @@ get_context_ra (ucontext_t *cp) } #endif + +#endif /* SFRAME_STACKTRACE_REGS_H. */ diff --git a/libsframe/testsuite/libsframe.stacktrace/libsframest/sframe-stacktrace.c b/libsframe/testsuite/libsframe.stacktrace/libsframest/sframe-stacktrace.c new file mode 100644 index 0000000..521c86f --- /dev/null +++ b/libsframe/testsuite/libsframe.stacktrace/libsframest/sframe-stacktrace.c @@ -0,0 +1,229 @@ +/* sframe-stacktrace.c - The SFrame stacktracer. + + Copyright (C) 2023 Free Software Foundation, Inc. + + This file is part of libsframest. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. */ + +#include "config.h" +#include <link.h> +#include <stdlib.h> +#include <stdio.h> +#include <inttypes.h> +#include <stdbool.h> +#include <assert.h> +#include <execinfo.h> +#include <unistd.h> +#include <fcntl.h> +#include <string.h> +#include <ucontext.h> +#include <stdarg.h> +#include "ansidecl.h" +#include "sframe-api.h" +#include "sframe-stacktrace-api.h" +#include "sframe-stacktrace-regs.h" +#include "sframe-state.h" + +#define STACK_ELEM_SIZE sizeof(uint64_t) + +/* Get the 8 bytes at ADDR from file descriptor FD. */ + +static int +get_contents_8b (int fd, uint64_t addr, uint64_t *data) +{ + size_t sz = 0; + int err = 0; + + if (data == NULL) + return sframe_bt_ret_set_errno (&err, SFRAME_BT_ERR_ARG); + + if (lseek (fd, addr, SEEK_SET) == -1) + return sframe_bt_ret_set_errno (&err, SFRAME_BT_ERR_LSEEK); + + sz = read (fd, data, STACK_ELEM_SIZE); + if (sz != STACK_ELEM_SIZE) + return sframe_bt_ret_set_errno (&err, SFRAME_BT_ERR_READ); + + return SFRAME_BT_OK; +} + +/* sframe_valid_addr_p - Check if ADDR is valid in CF. The address is considered + invalid, with regards to SFrame, if it's not in any address range of the + main module or any of its DSO's. Return 1 if valid, 0 otherwise. */ + +static int +sframe_valid_addr_p (struct sframe_state *sf, uint64_t addr) +{ + struct sframe_stinfo *cdp; + + if (sf == NULL) + return 0; + + cdp = sframe_find_context (sf, addr); + return cdp ? 1 : 0; +} + +/* Unwind the stack and collect the stacktrace given SFrame unwind info SF. + If successful, store the return addresses in RA_LST. The RA_SIZE argument + specifies the maximum number of return addresses that can be stored in + RA_LST and contains the number of the addresses collected. */ + +static int +sframe_unwind (struct sframe_state *sf, void **ra_lst, + int *ra_size) +{ + uint64_t cfa, return_addr, ra_stack_loc, rfp_stack_loc; + int8_t fixed_ra_offset; + sframe_decoder_ctx *ctx; + int cfa_offset, rfp_offset, errnum, i, count; + sframe_frame_row_entry fred, *frep = &fred; + uint64_t pc, rfp, rsp, ra, cfi_vma; + ucontext_t context, *cp = &context; + int err = 0; + + if (sf == NULL || ra_lst == NULL || ra_size == NULL) + return sframe_bt_ret_set_errno (&err, SFRAME_BT_ERR_ARG); + + /* Get the user context for its registers. */ + if (getcontext (cp) != 0) + return sframe_bt_ret_set_errno (&err, SFRAME_BT_ERR_GETCONTEXT); + + pc = get_context_pc (cp); + rsp = get_context_rsp (cp); + rfp = get_context_rfp (cp); + ra = get_context_ra (cp); + + /* Load and set up the decoder. */ + ctx = sframe_load_ctx (sf, pc); + if (ctx == NULL) + return sframe_bt_ret_set_errno (&err, SFRAME_BT_ERR_DECODE); + + cfi_vma = sf->sui_ctx.sfdd_sframe_vma; + count = *ra_size; + + for (i = 0; i < count; ++i) + { + pc -= cfi_vma; + errnum = sframe_find_fre (ctx, pc, frep); + if (errnum == 0) + { + cfa_offset = sframe_fre_get_cfa_offset (ctx, frep, &errnum); + if (errnum == SFRAME_ERR_FREOFFSET_NOPRESENT) + return sframe_bt_ret_set_errno (&err, SFRAME_BT_ERR_CFA_OFFSET); + + cfa = ((frep->fre_info & 0x1) == SFRAME_BASE_REG_SP + ? rsp : rfp) + cfa_offset; + +#ifdef __x86_64__ + /* For x86, read the return address from the fixed RA offset from + the SFrame header. RA must be at location CFA - 8. */ + fixed_ra_offset = sframe_decoder_get_fixed_ra_offset (ctx); + if (fixed_ra_offset == SFRAME_CFA_FIXED_RA_INVALID) + return sframe_bt_ret_set_errno (&err, SFRAME_BT_ERR_FRE_INVAL); + + ra_stack_loc = cfa + fixed_ra_offset; + errnum = get_contents_8b (sf->sui_fd, ra_stack_loc, &return_addr); + if (sframe_bt_errno (&errnum)) + return sframe_bt_ret_set_errno (&err, SFRAME_BT_ERR_FRE_INVAL); +#else +#ifdef __aarch64__ + int ra_offset = sframe_fre_get_ra_offset (ctx, frep, &errnum); + if (errnum == 0) + { + ra_stack_loc = cfa + ra_offset; + errnum = get_contents_8b (sf->sui_fd, ra_stack_loc, &return_addr); + if (sframe_bt_errno (&errnum)) + return sframe_bt_ret_set_errno (&err, SFRAME_BT_ERR_FRE_INVAL); + } + else + return_addr = ra; +#endif +#endif + + /* Validate and add return address to the list. */ + if (sframe_valid_addr_p (sf, return_addr) == 0) + { + i -= 1; + goto find_fre_ra_err; + } + if (i != 0) /* exclude self. */ + ra_lst[i-1] = (void *)return_addr; + + /* Set up for the next frame. */ + rfp_offset = sframe_fre_get_fp_offset (ctx, frep, &errnum); + if (errnum == 0) + { + rfp_stack_loc = cfa + rfp_offset; + errnum = get_contents_8b (sf->sui_fd, rfp_stack_loc, &rfp); + if (sframe_bt_errno (&errnum)) + return sframe_bt_ret_set_errno (&err, SFRAME_BT_ERR_FRE_INVAL); + } + rsp = cfa; + pc = return_addr; + + /* Check if need to update the decoder context and vma. */ + sframe_update_ctx (sf, return_addr, &ctx, &cfi_vma); + if (ctx == NULL) + return sframe_bt_ret_set_errno (&err, SFRAME_BT_ERR_DECODE); + } + else + { + i -= 1; + goto find_fre_ra_err; + } + } + +find_fre_ra_err: + *ra_size = i; + + return SFRAME_BT_OK; +} + +/* Main API that user program calls to get a stacktrace. + + The BUFFER argument provides space for the list of the return addresses + and the SIZE argument specifies the maximum number of addresses that + can be stored in the buffer. + + Returns the number of return addresses collected or -1 if there is any + error. ERRP is set with the error code if any. */ + +int +sframe_stacktrace (void **buffer, int size, int *errp) +{ + struct sframe_state sframeinfo; + + sframe_unwind_init_debug (); + + memset (&sframeinfo, 0, sizeof (struct sframe_state)); + + /* Find the .sframe sections and setup the SFrame state for generating stack + traces. */ + (void) dl_iterate_phdr (sframe_callback, (void *)&sframeinfo); + if (sframeinfo.sui_fd == 0) + { + sframe_bt_ret_set_errno (errp, SFRAME_BT_ERR_BAD_SFSTATE); + return -1; + } + + /* Do the stack unwinding. */ + *errp = sframe_unwind (&sframeinfo, buffer, &size); + if (sframe_bt_errno (errp)) + size = -1; + + sframe_free_cfi (&sframeinfo); + + return size; +} diff --git a/libsframe/testsuite/libsframe.stacktrace/libsframest/sframe-state.c b/libsframe/testsuite/libsframe.stacktrace/libsframest/sframe-state.c new file mode 100644 index 0000000..bb78c1a --- /dev/null +++ b/libsframe/testsuite/libsframe.stacktrace/libsframest/sframe-state.c @@ -0,0 +1,380 @@ +/* sframe-state.c - The SFrame state for stacktracing. + + Copyright (C) 2023 Free Software Foundation, Inc. + + This file is part of libsframest. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. */ + +#include "config.h" +#include <link.h> +#include <stdlib.h> +#include <stdio.h> +#include <inttypes.h> +#include <stdbool.h> +#include <assert.h> +#include <execinfo.h> +#include <unistd.h> +#include <fcntl.h> +#include <string.h> +#include <ucontext.h> +#include <stdarg.h> +#include "ansidecl.h" +#include "sframe-api.h" +#include "sframe-stacktrace-api.h" +#include "sframe-stacktrace-regs.h" +#include "sframe-state.h" + +#define _sf_printflike_(string_index, first_to_check) ATTRIBUTE_PRINTF (1, 2) + +static bool _sframe_unwind_debug; /* Control for printing out debug info. */ +static const int no_of_entries = NUM_OF_DSOS; + +void +sframe_unwind_init_debug (void) +{ + static int inited; + + if (!inited) + { + _sframe_unwind_debug = getenv ("SFRAME_UNWIND_DEBUG") != NULL; + inited = 1; + } +} + +_sf_printflike_ (1, 2) +static void +debug_printf (const char *format, ...) +{ + if (_sframe_unwind_debug == true) + { + va_list args; + + va_start (args, format); + __builtin_vprintf (format, args); + va_end (args); + } +} + +#if 0 +/* sframe_bt_set_errno - Store the specified error code ERROR into ERRP if + it is non-NULL. */ + +static void +sframe_bt_set_errno (int *errp, int error) +{ + if (errp != NULL) + *errp = error; +} + +#endif + +/* sframe_add_dso - Add .sframe info in D_DATA, which is associated with + a dynamic shared object, to D_LIST. */ + +static int +sframe_add_dso (struct sframe_stinfo_list *d_list, + struct sframe_stinfo d_data) +{ + int err = 0; + + if (d_list->alloced == 0) + { + d_list->entry = malloc (no_of_entries * sizeof (struct sframe_stinfo)); + if (d_list->entry == NULL) + return sframe_bt_ret_set_errno (&err, SFRAME_BT_ERR_MALLOC); + + memset (d_list->entry, 0, + no_of_entries * sizeof (struct sframe_stinfo)); + d_list->alloced = no_of_entries; + } + else if (d_list->used == d_list->alloced) + { + d_list->entry = realloc (d_list->entry, + ((d_list->alloced + no_of_entries) + * sizeof (struct sframe_stinfo))); + if (d_list->entry == NULL) + return sframe_bt_ret_set_errno (&err, SFRAME_BT_ERR_REALLOC); + + memset (&d_list->entry[d_list->alloced], 0, + no_of_entries * sizeof (struct sframe_stinfo)); + d_list->alloced += no_of_entries; + } + + sframe_bt_ret_set_errno (&err, SFRAME_BT_OK); + d_list->entry[d_list->used++] = d_data; + + return SFRAME_BT_OK; +} + +/* sframe_free_cfi - Free up space allocated for .sframe info for CF. */ + +void +sframe_free_cfi (struct sframe_state *sf) +{ + struct sframe_stinfo_list *d_list; + int i; + + if (sf == NULL) + return; + + // free (sf->sui_ctx.sfdd_data); + sframe_decoder_free (&sf->sui_ctx.sfdd_sframe_ctx); + close (sf->sui_fd); + + d_list = &sf-> sui_dsos; + if (d_list == NULL) + return; + + for (i = 0; i < d_list->used; ++i) + { + // free (d_list->entry[i].sfdd_data); + sframe_decoder_free (&d_list->entry[i].sfdd_sframe_ctx); + } + + free (d_list->entry); +} + +/* sframe_find_context - Find the decode data that contains ADDR from CF. + Return the pointer to the decode data or NULL. */ + +struct sframe_stinfo * +sframe_find_context (struct sframe_state *sf, uint64_t addr) +{ + struct sframe_stinfo_list *d_list; + struct sframe_stinfo sdec_data; + int i; + + if (sf == NULL) + return NULL; + + if (sf->sui_ctx.sfdd_text_vma < addr + && sf->sui_ctx.sfdd_text_vma + sf->sui_ctx.sfdd_text_size > addr) + return &sf->sui_ctx; + + d_list = &sf->sui_dsos; + for (i = 0; i < sf->sui_dsos.used; ++i) + { + sdec_data = d_list->entry[i]; + if ((sdec_data.sfdd_text_vma <= addr) + && (sdec_data.sfdd_text_vma + sdec_data.sfdd_text_size >= addr)) + return &d_list->entry[i]; + } + + return NULL; +} + +/* sframe_load_ctx - Call decoder to create and set up the SFrame info for + either the main module or one of the DSOs from CF, based on the input + RADDR argument. Return the newly created decode context or NULL. */ + +sframe_decoder_ctx * +sframe_load_ctx (struct sframe_state *sf, uint64_t raddr) +{ + sframe_decoder_ctx *nctx; + struct sframe_stinfo *cdp; + + if (sf == NULL) + return NULL; + + cdp = sframe_find_context (sf, raddr); + if (cdp == NULL) + return NULL; + + if (cdp->sfdd_sframe_ctx == NULL) + { + int err; + nctx = sframe_decode (cdp->sfdd_data, cdp->sfdd_data_size, &err); + if (nctx == NULL) + return NULL; + cdp->sfdd_sframe_ctx = nctx; + return nctx; + } + + return NULL; +} + +/* sframe_update_ctx - Check if need to do a decode context switch, based on + the input RADDR argument, from CF. A new decode context will be created + and set up if it isn't already done so. Return the new decode context in + CTX and vma in CFI_VMA. */ + +void +sframe_update_ctx (struct sframe_state *sf, uint64_t raddr, + sframe_decoder_ctx **ctx, uint64_t *cfi_vma) +{ + sframe_decoder_ctx *nctx; + struct sframe_stinfo *cdp; + + cdp = sframe_find_context (sf, raddr); + if (cdp != NULL) + { + if (cdp->sfdd_sframe_ctx == NULL) + { + int err; + nctx = sframe_decode (cdp->sfdd_data, cdp->sfdd_data_size, &err); + if (nctx == NULL) + { + *ctx = NULL; + return; + } + cdp->sfdd_sframe_ctx = nctx; + } + *ctx = cdp->sfdd_sframe_ctx; + *cfi_vma = cdp->sfdd_sframe_vma; + } +} + +/* sframe_fd_open - Open /proc image associated with the process id and return + the file descriptor. */ + +static int +sframe_fd_open (int *errp) +{ + int fd; + + if ((fd = open ("/proc/self/mem", O_CLOEXEC)) == -1) + { + sframe_bt_ret_set_errno (errp, SFRAME_BT_ERR_OPEN); + return -1; + } + + return fd; +} + +/* The callback from dl_iterate_phdr with header info in INFO. + Return SFrame info for either the main module or a DSO in DATA. */ + +int +sframe_callback (struct dl_phdr_info *info, + size_t size ATTRIBUTE_UNUSED, + void *data) +{ + struct sframe_state *sf = (struct sframe_state *) data; + int p_type, i, fd, sframe_err; + ssize_t len; + uint64_t text_vma = 0; + int text_size = 0; + + if (data == NULL || info == NULL) + return 1; + + debug_printf ("-- name: %s %14p\n", info->dlpi_name, (void *)info->dlpi_addr); + + for (i = 0; i < info->dlpi_phnum; i++) + { + debug_printf (" %2d: [%" PRIu64 "; memsz %" PRIu64 "] flags: 0x%x; \n", i, + (uint64_t) info->dlpi_phdr[i].p_vaddr, + (uint64_t) info->dlpi_phdr[i].p_memsz, + info->dlpi_phdr[i].p_flags); + + p_type = info->dlpi_phdr[i].p_type; + if (p_type == PT_LOAD && info->dlpi_phdr[i].p_flags & PF_X) + { + text_vma = info->dlpi_addr + info->dlpi_phdr[i].p_vaddr; + text_size = info->dlpi_phdr[i].p_memsz; + continue; + } + if (p_type != PT_SFRAME) + continue; + + if (info->dlpi_name[0] == '\0') /* the main module. */ + { + fd = sframe_fd_open (&sframe_err); + if (fd == -1) + return 1; +#if 0 + if (lseek (fd, info->dlpi_addr + info->dlpi_phdr[i].p_vaddr, + SEEK_SET) == -1) + { + sframe_bt_ret_set_errno (&sframe_err, SFRAME_BT_ERR_LSEEK); + return 1; + } +#endif + + // sf->sui_ctx.sfdd_data = malloc (info->dlpi_phdr[i].p_memsz); + sf->sui_ctx.sfdd_data = (char *)(info->dlpi_addr + info->dlpi_phdr[i].p_vaddr); +#if 0 + if (sf->sui_ctx.sfdd_data == NULL) + { + sframe_bt_ret_set_errno (&sframe_err, SFRAME_BT_ERR_MALLOC); + return 1; + } + + len = read (fd, sf->sui_ctx.sfdd_data, info->dlpi_phdr[i].p_memsz); + if (len == -1 || len != (ssize_t) info->dlpi_phdr[i].p_memsz) + { + sframe_bt_ret_set_errno (&sframe_err, SFRAME_BT_ERR_READ); + return 1; + } +#endif + len = info->dlpi_phdr[i].p_memsz; + + assert (text_vma); + sf->sui_ctx.sfdd_data_size = len; + sf->sui_ctx.sfdd_sframe_vma = info->dlpi_addr + info->dlpi_phdr[i].p_vaddr; + sf->sui_fd = fd; + sf->sui_ctx.sfdd_text_vma = text_vma; + sf->sui_ctx.sfdd_text_size = text_size; + text_vma = 0; + return 0; + } + else + { /* a dynamic shared object. */ + struct sframe_stinfo dt; + memset (&dt, 0, sizeof (struct sframe_stinfo)); + assert (sf->sui_fd); +#if 0 + if (lseek (sf->sui_fd, info->dlpi_addr + info->dlpi_phdr[i].p_vaddr, + SEEK_SET) == -1) + { + sframe_bt_ret_set_errno (&sframe_err, SFRAME_BT_ERR_LSEEK); + return 1; + } +#endif + + // dt.sfdd_data = malloc (info->dlpi_phdr[i].p_memsz); + dt.sfdd_data = (char *)(info->dlpi_addr + info->dlpi_phdr[i].p_vaddr); +#if 0 + if (dt.sfdd_data == NULL) + { + sframe_bt_ret_set_errno (&sframe_err, SFRAME_BT_ERR_MALLOC); + return 1; + } + + len = read (sf->sui_fd, dt.sfdd_data, info->dlpi_phdr[i].p_memsz); + if (len == -1 || len != (ssize_t) info->dlpi_phdr[i].p_memsz) + { + sframe_bt_ret_set_errno (&sframe_err, SFRAME_BT_ERR_READ); + return 1; + } +#endif + len = info->dlpi_phdr[i].p_memsz; + assert (text_vma); + dt.sfdd_data_size = len; + dt.sfdd_sframe_vma = info->dlpi_addr + info->dlpi_phdr[i].p_vaddr; + dt.sfdd_text_vma = text_vma; + dt.sfdd_text_size = text_size; + text_vma = 0; + + sframe_err = sframe_add_dso (&sf->sui_dsos, dt); + // FIXME TODO + if (sframe_err != SFRAME_BT_OK) + return 1; + return 0; + } + } + + return 0; +} diff --git a/libsframe/testsuite/libsframe.stacktrace/libsframest/sframe-state.h b/libsframe/testsuite/libsframe.stacktrace/libsframest/sframe-state.h new file mode 100644 index 0000000..9795411 --- /dev/null +++ b/libsframe/testsuite/libsframe.stacktrace/libsframest/sframe-state.h @@ -0,0 +1,89 @@ +/* sframe-state.h - The SFrame state for stacktracing. + + Copyright (C) 2023 Free Software Foundation, Inc. + + This file is part of libsframest. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. */ + +#ifndef SFRAME_STATE_H +#define SFRAME_STATE_H + +#include "config.h" +#include <link.h> +#include <stdlib.h> +#include <stdio.h> +#include <inttypes.h> +#include <stdbool.h> +#include <assert.h> +#include <execinfo.h> +#include <unistd.h> +#include <fcntl.h> +#include <string.h> +#include <ucontext.h> +#include <stdarg.h> +#include "ansidecl.h" +#include "sframe-api.h" +#include "sframe-stacktrace-api.h" +#include "sframe-stacktrace-regs.h" + +#ifndef PT_SFRAME +#define PT_SFRAME 0x6474e554 /* FIXME. */ +#endif + +/* SFrame decode data for the main module or a DSO. */ +struct sframe_stinfo +{ + char *sfdd_data; /* SFrame decode data. */ + int sfdd_data_size; /* SFrame decode data size. */ + uint64_t sfdd_text_vma; /* Text segment's virtual address. */ + int sfdd_text_size; /* Text segment's size. */ + uint64_t sfdd_sframe_vma; /* SFrame segment's virtual address. */ + sframe_decoder_ctx *sfdd_sframe_ctx; /* SFrame decoder context. */ +}; + +/* List that holds SFrame info for the shared libraries. */ +struct sframe_stinfo_list +{ + int alloced; /* Entries allocated. */ + int used; /* Entries used. */ + struct sframe_stinfo *entry; /* DSO's decode data. */ +}; + +/* Data that's passed through sframe_callback. */ +struct sframe_state +{ + int sui_fd; /* File descriptor. */ + struct sframe_stinfo sui_ctx; /* The decode data. */ + struct sframe_stinfo_list sui_dsos; /* The DSO list. */ +}; + + +void sframe_unwind_init_debug (void); + +int sframe_callback (struct dl_phdr_info *info, + size_t size ATTRIBUTE_UNUSED, + void *data); + +void sframe_update_ctx (struct sframe_state *sf, uint64_t raddr, + sframe_decoder_ctx **ctx, uint64_t *cfi_vma); + +sframe_decoder_ctx *sframe_load_ctx (struct sframe_state *sf, uint64_t raddr); + +struct sframe_stinfo * +sframe_find_context (struct sframe_state *sf, uint64_t addr); + +void sframe_free_cfi (struct sframe_state *sf); + +#endif /* SFRAME_STATE_H. */ diff --git a/libsframe/testsuite/libsframe.stacktrace/local.mk b/libsframe/testsuite/libsframe.stacktrace/local.mk new file mode 100644 index 0000000..370b54f --- /dev/null +++ b/libsframe/testsuite/libsframe.stacktrace/local.mk @@ -0,0 +1 @@ +include %D%/libsframest/local.mk diff --git a/libsframe/testsuite/libsframe.unwind/solib-lib1.c b/libsframe/testsuite/libsframe.stacktrace/solib-lib1.c index 16c77ca..16c77ca 100644 --- a/libsframe/testsuite/libsframe.unwind/solib-lib1.c +++ b/libsframe/testsuite/libsframe.stacktrace/solib-lib1.c diff --git a/libsframe/testsuite/libsframe.unwind/solib-lib1.h b/libsframe/testsuite/libsframe.stacktrace/solib-lib1.h index d40eac0..d40eac0 100644 --- a/libsframe/testsuite/libsframe.unwind/solib-lib1.h +++ b/libsframe/testsuite/libsframe.stacktrace/solib-lib1.h diff --git a/libsframe/testsuite/libsframe.unwind/solib-lib2.c b/libsframe/testsuite/libsframe.stacktrace/solib-lib2.c index 9ba3096..ba590fd 100644 --- a/libsframe/testsuite/libsframe.unwind/solib-lib2.c +++ b/libsframe/testsuite/libsframe.stacktrace/solib-lib2.c @@ -1,7 +1,7 @@ #include <execinfo.h> #include <stdlib.h> #include <string.h> -#include "sframe-backtrace-api.h" +#include "sframe-stacktrace-api.h" #include "solib-lib2.h" #define BT_BUF_SIZE 100 @@ -22,7 +22,7 @@ adder2 (unsigned int a, unsigned int b, int (*call)(int)) int i, nptrs, err; char **strings; - nptrs = sframe_backtrace (buffer, BT_BUF_SIZE, &err); + nptrs = sframe_stacktrace (buffer, BT_BUF_SIZE, &err); if (err) { printf ("SFrame error: %s\n", sframe_bt_errmsg (err)); @@ -30,7 +30,7 @@ adder2 (unsigned int a, unsigned int b, int (*call)(int)) } if (nptrs != 4) { - printf ("sframe_backtrace failed: %d %d\n", nptrs, err); + printf ("sframe_stacktrace failed: %d %d\n", nptrs, err); return (-1); } diff --git a/libsframe/testsuite/libsframe.unwind/solib-lib2.h b/libsframe/testsuite/libsframe.stacktrace/solib-lib2.h index 61b7212..61b7212 100644 --- a/libsframe/testsuite/libsframe.unwind/solib-lib2.h +++ b/libsframe/testsuite/libsframe.stacktrace/solib-lib2.h diff --git a/libsframe/testsuite/libsframe.unwind/solib-main.c b/libsframe/testsuite/libsframe.stacktrace/solib-main.c index d0bd806..4adf536 100644 --- a/libsframe/testsuite/libsframe.unwind/solib-main.c +++ b/libsframe/testsuite/libsframe.stacktrace/solib-main.c @@ -16,7 +16,7 @@ #include <execinfo.h> #include <stdio.h> #include <stdlib.h> -#include "sframe-backtrace-api.h" +#include "sframe-stacktrace-api.h" #include "solib-lib1.h" #include "solib-lib2.h" diff --git a/libsframe/testsuite/libsframe.unwind/solib-main.d b/libsframe/testsuite/libsframe.stacktrace/solib-main.d index 483ded5..483ded5 100644 --- a/libsframe/testsuite/libsframe.unwind/solib-main.d +++ b/libsframe/testsuite/libsframe.stacktrace/solib-main.d diff --git a/libsframe/testsuite/libsframe.unwind/solib.exp b/libsframe/testsuite/libsframe.stacktrace/solib.exp index 9ea8ce7..9ea8ce7 100644 --- a/libsframe/testsuite/libsframe.unwind/solib.exp +++ b/libsframe/testsuite/libsframe.stacktrace/solib.exp diff --git a/libsframe/testsuite/libsframe.unwind/backtrace-1.c b/libsframe/testsuite/libsframe.stacktrace/stacktrace-1.c index ef59404..d1d35e3 100644 --- a/libsframe/testsuite/libsframe.unwind/backtrace-1.c +++ b/libsframe/testsuite/libsframe.stacktrace/stacktrace-1.c @@ -28,7 +28,7 @@ #include <stdio.h> #include <stdlib.h> #include <string.h> -#include "sframe-backtrace-api.h" +#include "sframe-stacktrace-api.h" #define BT_BUF_SIZE 100 @@ -50,7 +50,7 @@ show_bt () /* Call the unwinder to get an array of return addresses. */ // nptrs = backtrace (buffer, BT_BUF_SIZE); - nptrs = sframe_backtrace (buffer, BT_BUF_SIZE, &err); + nptrs = sframe_stacktrace (buffer, BT_BUF_SIZE, &err); if (err) { printf ("SFrame error: %s (%d)\n", sframe_bt_errmsg (err), nptrs); @@ -81,8 +81,7 @@ show_bt () free(strings); - printf ("%s: backtrace-1\n", - (j == nptrs) ? "PASS" : "FAIL"); + printf ("%s: stacktrace-1\n", (j == nptrs) ? "PASS" : "FAIL"); } int __attribute__((__noinline__)) ATTRIBUTE_NOCLONE @@ -98,10 +97,10 @@ main () void *buffer[BT_BUF_SIZE]; int nptrs, err; - /* The following call to sframe_backtrace () also prevents sibling call + /* The following call to sframe_stacktrace () also prevents sibling call optimization in main (). */ /* Call the unwinder to get an array of return addresses. */ - nptrs = sframe_backtrace (buffer, BT_BUF_SIZE, &err); + nptrs = sframe_stacktrace (buffer, BT_BUF_SIZE, &err); if (nptrs == -1) { printf ("SFrame error: %s (%d)\n", sframe_bt_errmsg (err), nptrs); diff --git a/libsframe/testsuite/libsframe.stacktrace/stacktrace-1.lk b/libsframe/testsuite/libsframe.stacktrace/stacktrace-1.lk new file mode 100644 index 0000000..d0fe8c6 --- /dev/null +++ b/libsframe/testsuite/libsframe.stacktrace/stacktrace-1.lk @@ -0,0 +1,4 @@ +# source: stacktrace-1.c +# cflags: -O2 +# link: on +PASS: stacktrace-1 diff --git a/libsframe/testsuite/libsframe.unwind/backtrace.c b/libsframe/testsuite/libsframe.stacktrace/stacktrace-2.c index 3e00b76..cd36196 100644 --- a/libsframe/testsuite/libsframe.unwind/backtrace.c +++ b/libsframe/testsuite/libsframe.stacktrace/stacktrace-2.c @@ -28,7 +28,7 @@ #include <stdio.h> #include <stdlib.h> #include <string.h> -#include "sframe-backtrace-api.h" +#include "sframe-stacktrace-api.h" #define BT_BUF_SIZE 100 @@ -50,7 +50,7 @@ show_bt () char **strings; /* Call the unwinder to get an array of return addresses. */ - nptrs = sframe_backtrace (buffer, BT_BUF_SIZE, &err); + nptrs = sframe_stacktrace (buffer, BT_BUF_SIZE, &err); if (nptrs != 5) { printf ("SFrame error: %s (%d)\n", sframe_bt_errmsg (err), nptrs); @@ -71,7 +71,7 @@ show_bt () free(strings); - printf ("%s: backtrace test\n", j == nptrs ? "PASS" : "FAIL"); + printf ("%s: stacktrace-2\n", (j == nptrs) ? "PASS" : "FAIL"); } int __attribute__((__noinline__)) ATTRIBUTE_NOCLONE @@ -81,7 +81,7 @@ baz () int nptrs, err; /* Call the unwinder to get an array of return addresses. */ - nptrs = sframe_backtrace (buffer, BT_BUF_SIZE, &err); + nptrs = sframe_stacktrace (buffer, BT_BUF_SIZE, &err); if (nptrs == -1) { printf ("SFrame error: %s (%d)\n", sframe_bt_errmsg (err), nptrs); @@ -99,7 +99,7 @@ bar () int nptrs, err; /* Call the unwinder to get an array of return addresses. */ - nptrs = sframe_backtrace (buffer, BT_BUF_SIZE, &err); + nptrs = sframe_stacktrace (buffer, BT_BUF_SIZE, &err); if (nptrs == -1) { printf ("SFrame error: %s (%d)\n", sframe_bt_errmsg (err), nptrs); @@ -116,7 +116,7 @@ foo () int nptrs, err; /* Call the unwinder to get an array of return addresses. */ - nptrs = sframe_backtrace (buffer, BT_BUF_SIZE, &err); + nptrs = sframe_stacktrace (buffer, BT_BUF_SIZE, &err); if (nptrs == -1) { printf ("SFrame error: %s (%d)\n", sframe_bt_errmsg (err), nptrs); @@ -133,7 +133,7 @@ main () int nptrs, err; /* Call the unwinder to get an array of return addresses. */ - nptrs = sframe_backtrace (buffer, BT_BUF_SIZE, &err); + nptrs = sframe_stacktrace (buffer, BT_BUF_SIZE, &err); if (nptrs == -1) { printf ("SFrame error: %s (%d)\n", sframe_bt_errmsg (err), nptrs); diff --git a/libsframe/testsuite/libsframe.stacktrace/stacktrace-2.lk b/libsframe/testsuite/libsframe.stacktrace/stacktrace-2.lk new file mode 100644 index 0000000..b61730e --- /dev/null +++ b/libsframe/testsuite/libsframe.stacktrace/stacktrace-2.lk @@ -0,0 +1,3 @@ +# source: stacktrace-2.c +# link: on +PASS: stacktrace-2 diff --git a/libsframe/testsuite/libsframe.unwind/ttest.c b/libsframe/testsuite/libsframe.stacktrace/stacktrace-3.c index 342ba14..3d54096 100644 --- a/libsframe/testsuite/libsframe.unwind/ttest.c +++ b/libsframe/testsuite/libsframe.stacktrace/stacktrace-3.c @@ -19,7 +19,7 @@ #include <stdio.h> #include <stdlib.h> #include <string.h> -#include "sframe-backtrace-api.h" +#include "sframe-stacktrace-api.h" #ifdef __has_attribute # if !__has_attribute (noclone) @@ -50,7 +50,7 @@ void myfunc3 (void) char **strings; /* Call the unwinder to get an array of return addresses. */ - nptrs = sframe_backtrace (buffer, BT_BUF_SIZE, &err); + nptrs = sframe_stacktrace (buffer, BT_BUF_SIZE, &err); if (nptrs == -1 || nptrs != 6) { printf ("SFrame error: %s (%d)\n", sframe_bt_errmsg (err), nptrs); @@ -71,7 +71,8 @@ void myfunc3 (void) free(strings); - printf ("%s: unwind test\n", j == nptrs ? "PASS" : "FAIL"); + printf ("%s: stacktrace with static function\n", + (j == nptrs) ? "PASS" : "FAIL"); } static void __attribute__((__noinline__)) ATTRIBUTE_NOCLONE @@ -82,7 +83,7 @@ myfunc2 (void) int nptrs, err; /* Call the unwinder to get an array of return addresses. */ - nptrs = sframe_backtrace (buffer, BT_BUF_SIZE, &err); + nptrs = sframe_stacktrace (buffer, BT_BUF_SIZE, &err); if (nptrs == -1) { printf ("SFrame error: %s (%d)\n", sframe_bt_errmsg (err), nptrs); @@ -99,7 +100,7 @@ myfunc (int ncalls) int nptrs, err; /* Call the unwinder to get an array of return addresses. */ - nptrs = sframe_backtrace (buffer, BT_BUF_SIZE, &err); + nptrs = sframe_stacktrace (buffer, BT_BUF_SIZE, &err); if (nptrs == -1) { printf ("SFrame error: %s (%d)\n", sframe_bt_errmsg (err), nptrs); diff --git a/libsframe/testsuite/libsframe.stacktrace/stacktrace-3.lk b/libsframe/testsuite/libsframe.stacktrace/stacktrace-3.lk new file mode 100644 index 0000000..bb7caf5 --- /dev/null +++ b/libsframe/testsuite/libsframe.stacktrace/stacktrace-3.lk @@ -0,0 +1,3 @@ +# source: stacktrace-3.c +# link: on +PASS: stacktrace with static function diff --git a/libsframe/testsuite/libsframe.unwind/backtrace-fp-attr-1.c b/libsframe/testsuite/libsframe.stacktrace/stacktrace-fp-attr-1.c index ef01e97..2ba4a18 100644 --- a/libsframe/testsuite/libsframe.unwind/backtrace-fp-attr-1.c +++ b/libsframe/testsuite/libsframe.stacktrace/stacktrace-fp-attr-1.c @@ -28,7 +28,7 @@ #include <stdio.h> #include <stdlib.h> #include <string.h> -#include "sframe-backtrace-api.h" +#include "sframe-stacktrace-api.h" #define BT_BUF_SIZE 100 @@ -51,7 +51,7 @@ show_bt () char **strings; /* Call the unwinder to get an array of return addresses. */ - nptrs = sframe_backtrace (buffer, BT_BUF_SIZE, &err); + nptrs = sframe_stacktrace (buffer, BT_BUF_SIZE, &err); if (err) { printf ("SFrame error: %s (%d)\n", sframe_bt_errmsg (err), nptrs); @@ -78,7 +78,7 @@ show_bt () free(strings); - printf ("%s: backtrace with omit-frame-pointer attr\n", + printf ("%s: stacktrace with omit-frame-pointer attr\n", (j == nptrs) ? "PASS" : "FAIL"); } diff --git a/libsframe/testsuite/libsframe.stacktrace/stacktrace-fp-attr-1.lk b/libsframe/testsuite/libsframe.stacktrace/stacktrace-fp-attr-1.lk new file mode 100644 index 0000000..7cae811 --- /dev/null +++ b/libsframe/testsuite/libsframe.stacktrace/stacktrace-fp-attr-1.lk @@ -0,0 +1,4 @@ +# source: stacktrace-fp-attr-1.c +# cflags: -fno-omit-frame-pointer -fno-optimize-sibling-calls +# link: on +PASS: stacktrace with omit-frame-pointer attr diff --git a/libsframe/testsuite/libsframe.unwind/backtrace-fp-attr-2.c b/libsframe/testsuite/libsframe.stacktrace/stacktrace-fp-attr-2.c index ee62b20..0a87d27 100644 --- a/libsframe/testsuite/libsframe.unwind/backtrace-fp-attr-2.c +++ b/libsframe/testsuite/libsframe.stacktrace/stacktrace-fp-attr-2.c @@ -28,7 +28,7 @@ #include <stdio.h> #include <stdlib.h> #include <string.h> -#include "sframe-backtrace-api.h" +#include "sframe-stacktrace-api.h" #define BT_BUF_SIZE 100 @@ -52,7 +52,7 @@ show_bt () char **strings; /* Call the unwinder to get an array of return addresses. */ - nptrs = sframe_backtrace (buffer, BT_BUF_SIZE, &err); + nptrs = sframe_stacktrace (buffer, BT_BUF_SIZE, &err); if (err) { printf ("SFrame error: %s (%d)\n", sframe_bt_errmsg (err), nptrs); @@ -79,7 +79,7 @@ show_bt () free(strings); - printf ("%s: backtrace with no-omit-frame-pointer attr\n", + printf ("%s: stacktrace with no-omit-frame-pointer attr\n", (j == nptrs) ? "PASS" : "FAIL"); } diff --git a/libsframe/testsuite/libsframe.stacktrace/stacktrace-fp-attr-2.lk b/libsframe/testsuite/libsframe.stacktrace/stacktrace-fp-attr-2.lk new file mode 100644 index 0000000..5cad0f2 --- /dev/null +++ b/libsframe/testsuite/libsframe.stacktrace/stacktrace-fp-attr-2.lk @@ -0,0 +1,4 @@ +# source: stacktrace-fp-attr-2.c +# cflags: -fomit-frame-pointer -fno-optimize-sibling-calls +# link: on +PASS: stacktrace with no-omit-frame-pointer attr diff --git a/libsframe/testsuite/libsframe.unwind/inline.c b/libsframe/testsuite/libsframe.stacktrace/stacktrace-inline-1.c index fc753fc..c63f714 100644 --- a/libsframe/testsuite/libsframe.unwind/inline.c +++ b/libsframe/testsuite/libsframe.stacktrace/stacktrace-inline-1.c @@ -19,9 +19,9 @@ #include <stdio.h> #include <stdlib.h> #include <string.h> -#include "sframe-backtrace-api.h" +#include "sframe-stacktrace-api.h" -#define ATTR __attribute__((always_inline)) +#define ALWAYS_INLINE __attribute__((always_inline)) #define BT_BUF_SIZE 32 @@ -40,20 +40,20 @@ void bar(void) x += y; } -inline ATTR int func1(void) +inline ALWAYS_INLINE int func1(void) { bar (); return x * y; } -inline ATTR int func2(void) +inline ALWAYS_INLINE int func2(void) { void *buffer[BT_BUF_SIZE]; int ok = 0, nptrs, err; char **strings; /* Call the unwinder to get an array of return addresses. */ - nptrs = sframe_backtrace (buffer, BT_BUF_SIZE, &err); + nptrs = sframe_stacktrace (buffer, BT_BUF_SIZE, &err); if (nptrs == -1) { printf ("SFrame error: %s\n", sframe_bt_errmsg (err)); @@ -73,7 +73,7 @@ inline ATTR int func2(void) free(strings); - printf ("%s: unwind test\n", ok == 1 ? "PASS" : "FAIL"); + printf ("%s: stacktrace with inlined function\n", ok == 1 ? "PASS" : "FAIL"); return x * func1 (); } diff --git a/libsframe/testsuite/libsframe.stacktrace/stacktrace-inline-1.lk b/libsframe/testsuite/libsframe.stacktrace/stacktrace-inline-1.lk new file mode 100644 index 0000000..db39ce6 --- /dev/null +++ b/libsframe/testsuite/libsframe.stacktrace/stacktrace-inline-1.lk @@ -0,0 +1,3 @@ +# source: stacktrace-inline-1.c +# link: on +PASS: stacktrace with inlined function diff --git a/libsframe/testsuite/libsframe.unwind/inline-cmds.c b/libsframe/testsuite/libsframe.stacktrace/stacktrace-inline-2.c index bc15545..3b0ee91 100644 --- a/libsframe/testsuite/libsframe.unwind/inline-cmds.c +++ b/libsframe/testsuite/libsframe.stacktrace/stacktrace-inline-2.c @@ -29,7 +29,7 @@ #include <stdlib.h> #include <string.h> #include <execinfo.h> -#include "sframe-backtrace-api.h" +#include "sframe-stacktrace-api.h" #define BT_BUF_SIZE 10 @@ -77,7 +77,7 @@ inline ATTR void inlined_fn(void) char **strings; /* Call the unwinder to get an array of return addresses. */ int j, err; - int nptrs = sframe_backtrace (buffer, BT_BUF_SIZE, &err); + int nptrs = sframe_stacktrace (buffer, BT_BUF_SIZE, &err); if (nptrs == -1 || nptrs != 2) { printf ("SFrame error: %s (%d)\n", sframe_bt_errmsg (err), nptrs); @@ -98,7 +98,8 @@ inline ATTR void inlined_fn(void) break; free(strings); - printf ("%s: inline-cmds test\n", j == nptrs ? "PASS" : "FAIL"); + printf ("%s: stacktrace with inlined function test 2\n", + (j == nptrs) ? "PASS" : "FAIL"); } void noinline(void) diff --git a/libsframe/testsuite/libsframe.stacktrace/stacktrace-inline-2.lk b/libsframe/testsuite/libsframe.stacktrace/stacktrace-inline-2.lk new file mode 100644 index 0000000..5428e5e --- /dev/null +++ b/libsframe/testsuite/libsframe.stacktrace/stacktrace-inline-2.lk @@ -0,0 +1,3 @@ +# source: stacktrace-inline-2.c +# link: on +PASS: stacktrace with inlined function test 2 diff --git a/libsframe/testsuite/libsframe.unwind/tailcall.c b/libsframe/testsuite/libsframe.stacktrace/stacktrace-tailcall-1.c index fd3add2..83e12c2 100644 --- a/libsframe/testsuite/libsframe.unwind/tailcall.c +++ b/libsframe/testsuite/libsframe.stacktrace/stacktrace-tailcall-1.c @@ -17,7 +17,7 @@ #include <stdio.h> #include <stdlib.h> #include <string.h> -#include "sframe-backtrace-api.h" +#include "sframe-stacktrace-api.h" #ifdef __has_attribute # if !__has_attribute (noclone) @@ -46,7 +46,7 @@ void show_bt () char **strings; /* Call the unwinder to get an array of return addresses. */ - nptrs = sframe_backtrace (buffer, BT_BUF_SIZE, &err); + nptrs = sframe_stacktrace (buffer, BT_BUF_SIZE, &err); if (nptrs == -1 || nptrs != 4) { printf ("SFrame error: %s (%d)\n", sframe_bt_errmsg (err), nptrs); @@ -67,7 +67,7 @@ void show_bt () free(strings); - printf ("%s: tailcall test\n", j == nptrs ? "PASS" : "FAIL"); + printf ("%s: stacktrace tailcall test\n", j == nptrs ? "PASS" : "FAIL"); } /* An example of tail recursive function. */ @@ -78,7 +78,7 @@ dec (int n) int nptrs, err; /* Call the unwinder to get an array of return addresses. */ - nptrs = sframe_backtrace (buffer, BT_BUF_SIZE, &err); + nptrs = sframe_stacktrace (buffer, BT_BUF_SIZE, &err); if (nptrs == -1) { printf ("SFrame error: %s (%d)\n", sframe_bt_errmsg (err), nptrs); diff --git a/libsframe/testsuite/libsframe.stacktrace/stacktrace-tailcall-1.lk b/libsframe/testsuite/libsframe.stacktrace/stacktrace-tailcall-1.lk new file mode 100644 index 0000000..b0b50d7 --- /dev/null +++ b/libsframe/testsuite/libsframe.stacktrace/stacktrace-tailcall-1.lk @@ -0,0 +1,3 @@ +# source: stacktrace-tailcall-1.c +# link: on +PASS: stacktrace tailcall test diff --git a/libsframe/testsuite/libsframe.unwind/unwind.exp b/libsframe/testsuite/libsframe.stacktrace/stacktrace.exp index 510b92e..bc1e847 100644 --- a/libsframe/testsuite/libsframe.unwind/unwind.exp +++ b/libsframe/testsuite/libsframe.stacktrace/stacktrace.exp @@ -18,11 +18,12 @@ # MA 02110-1301, USA. # -# Run the tests only if sframebt library exists. +# Run the tests only if libsframest library exists. -if [catch "exec ls $objdir/.libs/libsframebt.la" status] then { - verbose -log "$objdir/.libs/libsframebt.la not found."; - verbose -log "Skipping SFrame unwind tests"; +if [catch "exec ls $objdir/testsuite/libsframe.stacktrace/libsframest/.libs/libsframest.la" status] then { + verbose -log \ + "$objdir/testsuite/libsframe.stacktrace/libsframest/.libs/libsframest.la not found."; + verbose -log "Skipping SFrame stacktrace tests"; return; } @@ -107,7 +108,7 @@ proc run_unwind_test { name } { } # Compile and link the unwind program. - set comp_output [compile_link_one_host_cc $opts(unwind) "tmpdir/test_x" "./.libs/libsframebt.la ./.libs/libsframe.la"] + set comp_output [compile_link_one_host_cc $opts(unwind) "tmpdir/test_x" "./testsuite/libsframe.stacktrace/libsframest/.libs/libsframest.la ./.libs/libsframe.la"] if { $comp_output != ""} { send_log "compilation of unwind program $opts(unwind) failed with <$comp_output>" @@ -122,7 +123,7 @@ proc run_unwind_test { name } { if { [llength $opts(source)] > 0 } { set unwind "" if { $run_ld } { - set unwind_output "tmpdir/test_x ./.libs/libsframebt.a ./.libs/libsframe.a" + set unwind_output "tmpdir/test_x ./testsuite/libsframe.stacktrace/libsframest/.libs/libsframest.a ./.libs/libsframe.a" # set unwind_output "tmpdir/out.so" # set unwind_flags "-fPIC $shared $opts(link_flags)" } else { diff --git a/libsframe/testsuite/libsframe.unwind/backtrace-1.lk b/libsframe/testsuite/libsframe.unwind/backtrace-1.lk deleted file mode 100644 index ba677d1..0000000 --- a/libsframe/testsuite/libsframe.unwind/backtrace-1.lk +++ /dev/null @@ -1,4 +0,0 @@ -# source: backtrace-1.c -# cflags: -O2 -# link: on -PASS: backtrace-1 diff --git a/libsframe/testsuite/libsframe.unwind/backtrace-fp-attr-1.lk b/libsframe/testsuite/libsframe.unwind/backtrace-fp-attr-1.lk deleted file mode 100644 index f1f0621..0000000 --- a/libsframe/testsuite/libsframe.unwind/backtrace-fp-attr-1.lk +++ /dev/null @@ -1,4 +0,0 @@ -# source: backtrace-fp-attr-1.c -# cflags: -fno-omit-frame-pointer -fno-optimize-sibling-calls -# link: on -PASS: backtrace with omit-frame-pointer attr diff --git a/libsframe/testsuite/libsframe.unwind/backtrace-fp-attr-2.lk b/libsframe/testsuite/libsframe.unwind/backtrace-fp-attr-2.lk deleted file mode 100644 index 5de5105..0000000 --- a/libsframe/testsuite/libsframe.unwind/backtrace-fp-attr-2.lk +++ /dev/null @@ -1,4 +0,0 @@ -# source: backtrace-fp-attr-2.c -# cflags: -fomit-frame-pointer -fno-optimize-sibling-calls -# link: on -PASS: backtrace with no-omit-frame-pointer attr diff --git a/libsframe/testsuite/libsframe.unwind/backtrace.lk b/libsframe/testsuite/libsframe.unwind/backtrace.lk deleted file mode 100644 index fdc78eb..0000000 --- a/libsframe/testsuite/libsframe.unwind/backtrace.lk +++ /dev/null @@ -1,3 +0,0 @@ -# source: backtrace.c -# link: on -PASS: backtrace test diff --git a/libsframe/testsuite/libsframe.unwind/inline-cmds.lk b/libsframe/testsuite/libsframe.unwind/inline-cmds.lk deleted file mode 100644 index 053b66b..0000000 --- a/libsframe/testsuite/libsframe.unwind/inline-cmds.lk +++ /dev/null @@ -1,3 +0,0 @@ -# source: inline-cmds.c -# link: on -PASS: inline-cmds test diff --git a/libsframe/testsuite/libsframe.unwind/inline.lk b/libsframe/testsuite/libsframe.unwind/inline.lk deleted file mode 100644 index 88f846b..0000000 --- a/libsframe/testsuite/libsframe.unwind/inline.lk +++ /dev/null @@ -1,3 +0,0 @@ -# source: inline.c -# link: on -PASS: unwind test diff --git a/libsframe/testsuite/libsframe.unwind/tailcall.lk b/libsframe/testsuite/libsframe.unwind/tailcall.lk deleted file mode 100644 index 3d7ab98..0000000 --- a/libsframe/testsuite/libsframe.unwind/tailcall.lk +++ /dev/null @@ -1,3 +0,0 @@ -# source: tailcall.c -# link: on -PASS: tailcall test diff --git a/libsframe/testsuite/libsframe.unwind/ttest.lk b/libsframe/testsuite/libsframe.unwind/ttest.lk deleted file mode 100644 index 80aa224..0000000 --- a/libsframe/testsuite/libsframe.unwind/ttest.lk +++ /dev/null @@ -1,3 +0,0 @@ -# source: ttest.c -# link: on -PASS: unwind test diff --git a/libsframe/testsuite/local.mk b/libsframe/testsuite/local.mk index 5e5ba92..06724f1 100644 --- a/libsframe/testsuite/local.mk +++ b/libsframe/testsuite/local.mk @@ -14,12 +14,14 @@ check-DEJAGNU: site.exp CC="$(CC)" \ CROSS_COMPILE="$(CROSS_COMPILE)" \ COMPAT_DEJAGNU="$(COMPAT_DEJAGNU)" \ - CFLAGS="$(CFLAGS) -I$(top_srcdir)/../include -I$(top_srcdir) -I$(top_builddir)" \ + HAVE_DL_ITERATE_PHDR="$(HAVE_DL_ITERATE_PHDR)" \ + CFLAGS="$(CFLAGS) -I$(top_srcdir)/../include -I$(top_srcdir) -I$(top_srcdir)/testsuite/libsframe.stacktrace/libsframest/include -I$(top_builddir)" \ $(RUNTESTFLAGS); \ else echo "WARNING: could not find \`runtest'" 1>&2; :;\ fi -# libsframe encoder/decoder/find testsuite +# libsframe encoder/decoder/stacktracer testsuite include %D%/libsframe.decode/local.mk include %D%/libsframe.encode/local.mk include %D%/libsframe.find/local.mk +include %D%/libsframe.stacktrace/local.mk |