diff --git a/repos/libports/lib/mk/gcov-libcommon.mk b/repos/libports/lib/mk/gcov-libcommon.mk new file mode 100644 index 000000000..33471ecc6 --- /dev/null +++ b/repos/libports/lib/mk/gcov-libcommon.mk @@ -0,0 +1,45 @@ +GCOV_PORT_DIR := $(call select_from_ports,gcov) + +GCOV_DIR := $(GCOV_PORT_DIR)/src/gcov + +SRC_CC = diagnostic.cc \ + diagnostic-color.cc \ + diagnostic-show-locus.cc \ + ggc-none.cc \ + hash-table.cc \ + input.cc \ + intl.cc \ + memory-block.cc \ + pretty-print.cc \ + vec.cc \ + version.cc + +CC_OPT += -DIN_GCC + +CC_OPT_version += -DBASEVER="\"6.3.0\"" \ + -DDATESTAMP="\"\"" \ + -DREVISION="\"\"" \ + -DDEVPHASE="\"\"" \ + -DPKGVERSION="\"(GCC) \"" \ + -DBUGURL="\"\"" + +LIBS += libc gmp stdcxx + +INC_DIR += $(GCOV_DIR)/include \ + $(GCOV_DIR)/libcpp/include + +ifeq ($(filter-out $(SPECS),arm),) + INC_DIR += $(GCOV_PORT_DIR)/include/arm/gcc +endif + +ifeq ($(filter-out $(SPECS),x86_32),) + INC_DIR += $(GCOV_PORT_DIR)/include/x86_32/gcc +endif + +ifeq ($(filter-out $(SPECS),x86_64),) + INC_DIR += $(GCOV_PORT_DIR)/include/x86_64/gcc +endif + +vpath %.cc $(GCOV_DIR)/gcc + +CC_CXX_WARN_STRICT = diff --git a/repos/libports/lib/mk/gcov-libcpp.mk b/repos/libports/lib/mk/gcov-libcpp.mk new file mode 100644 index 000000000..785c5809d --- /dev/null +++ b/repos/libports/lib/mk/gcov-libcpp.mk @@ -0,0 +1,26 @@ +GCOV_PORT_DIR := $(call select_from_ports,gcov) + +GCOV_DIR := $(GCOV_PORT_DIR)/src/gcov + +SRC_CC = line-map.cc + +LIBS += libc + +INC_DIR += $(GCOV_DIR)/include \ + $(GCOV_DIR)/libcpp/include + +ifeq ($(filter-out $(SPECS),arm),) + INC_DIR += $(GCOV_PORT_DIR)/include/arm/libcpp +endif + +ifeq ($(filter-out $(SPECS),x86_32),) + INC_DIR += $(GCOV_PORT_DIR)/include/x86_32/libcpp +endif + +ifeq ($(filter-out $(SPECS),x86_64),) + INC_DIR += $(GCOV_PORT_DIR)/include/x86_64/libcpp +endif + +vpath %.cc $(GCOV_DIR)/libcpp + +CC_CXX_WARN_STRICT = diff --git a/repos/libports/lib/mk/gcov-libiberty.mk b/repos/libports/lib/mk/gcov-libiberty.mk new file mode 100644 index 000000000..667ce54d9 --- /dev/null +++ b/repos/libports/lib/mk/gcov-libiberty.mk @@ -0,0 +1,43 @@ +GCOV_PORT_DIR := $(call select_from_ports,gcov) + +GCOV_DIR := $(GCOV_PORT_DIR)/src/gcov + +SRC_C = argv.c \ + concat.c \ + cp-demangle.c \ + cplus-dem.c \ + d-demangle.c \ + filename_cmp.c \ + fopen_unlocked.c \ + hashtab.c \ + lbasename.c \ + obstack.c \ + safe-ctype.c \ + vprintf-support.c \ + xexit.c \ + xmalloc.c \ + xstrdup.c \ + xstrerror.c \ + xvasprintf.c + +CC_OPT += -DHAVE_CONFIG_H + +LIBS += libc stdcxx + +INC_DIR += $(GCOV_DIR)/include + +ifeq ($(filter-out $(SPECS),arm),) + INC_DIR += $(GCOV_PORT_DIR)/include/arm/libiberty +endif + +ifeq ($(filter-out $(SPECS),x86_32),) + INC_DIR += $(GCOV_PORT_DIR)/include/x86_32/libiberty +endif + +ifeq ($(filter-out $(SPECS),x86_64),) + INC_DIR += $(GCOV_PORT_DIR)/include/x86_64/libiberty +endif + +vpath %.c $(GCOV_DIR)/libiberty + +CC_CXX_WARN_STRICT = diff --git a/repos/libports/lib/mk/libgcov.mk b/repos/libports/lib/mk/libgcov.mk new file mode 100644 index 000000000..c8cc89bd2 --- /dev/null +++ b/repos/libports/lib/mk/libgcov.mk @@ -0,0 +1,66 @@ +# this is a static library, because some symbols are marked as hidden + +GCOV_PORT_DIR := $(call select_from_ports,gcov) + +GCOV_DIR := $(GCOV_PORT_DIR)/src/gcov + +SRC_C = libgcov-merge.c \ + libgcov-profiler.c \ + libgcov-interface.c \ + libgcov-driver.c + +SRC_CC = libc.cc + +LIBGCOV_MERGE = _gcov_merge_add \ + _gcov_merge_single \ + _gcov_merge_delta \ + _gcov_merge_ior \ + _gcov_merge_time_profile \ + _gcov_merge_icall_topn + +LIBGCOV_PROFILER = _gcov_interval_profiler \ + _gcov_pow2_profiler \ + _gcov_one_value_profiler \ + _gcov_indirect_call_profiler \ + _gcov_average_profiler \ + _gcov_ior_profiler \ + _gcov_indirect_call_profiler_v2 \ + _gcov_time_profiler \ + _gcov_indirect_call_topn_profiler + +LIBGCOV_INTERFACE = _gcov_dump \ + _gcov_flush \ + _gcov_reset + +LIBGCOV_DRIVER = _gcov + +CC_OPT += -fbuilding-libgcc -DIN_GCC -DIN_LIBGCC2 + +CC_OPT += $(addprefix -DL,$(LIBGCOV_MERGE)) +CC_OPT += $(addprefix -DL,$(LIBGCOV_PROFILER)) +CC_OPT += $(addprefix -DL,$(LIBGCOV_INTERFACE)) +CC_OPT += $(addprefix -DL,$(LIBGCOV_DRIVER)) + +INC_DIR += $(GCOV_DIR)/include \ + $(GCOV_DIR)/gcc \ + $(REP_DIR)/src/lib/gcov/libc + +ifeq ($(filter-out $(SPECS),arm),) + INC_DIR += $(GCOV_PORT_DIR)/include/arm/gcc \ + $(GCOV_PORT_DIR)/include/arm/libgcc +endif + +ifeq ($(filter-out $(SPECS),x86_32),) + INC_DIR += $(GCOV_PORT_DIR)/include/x86_32/gcc \ + $(GCOV_PORT_DIR)/include/x86_32/libgcc +endif + +ifeq ($(filter-out $(SPECS),x86_64),) + INC_DIR += $(GCOV_PORT_DIR)/include/x86_64/gcc \ + $(GCOV_PORT_DIR)/include/x86_64/libgcc +endif + +vpath %.c $(GCOV_DIR)/libgcc +vpath libc.cc $(REP_DIR)/src/lib/gcov/libc + +CC_CXX_WARN_STRICT = diff --git a/repos/libports/ports/gcov.hash b/repos/libports/ports/gcov.hash new file mode 100644 index 000000000..414a014f2 --- /dev/null +++ b/repos/libports/ports/gcov.hash @@ -0,0 +1 @@ +270978954f87ac494b04c2cc1c15c23102f07406 diff --git a/repos/libports/ports/gcov.port b/repos/libports/ports/gcov.port new file mode 100644 index 000000000..585a77da4 --- /dev/null +++ b/repos/libports/ports/gcov.port @@ -0,0 +1,151 @@ +LICENSE := GPLv2 +VERSION := 6.3.0 +DOWNLOADS := gcov.archive generated.git + +URL(gcov) := ftp://ftp.fu-berlin.de/gnu/gcc/gcc-$(VERSION)/gcc-$(VERSION).tar.bz2 +SHA(gcov) := f06ae7f3f790fbf0f018f6d40e844451e6bc3b7bc96e128e63b09825c1f8b29f +DIR(gcov) := src/gcov +SIG(gcov) := ${URL(gcov)} +KEY(gcov) := GNU + +URL(generated) := https://github.com/cproc/genode-generated.git +REV(generated) := c0b4333a7df8de45036506b9542b57349796775d +DIR(generated) := include + +TAR_OPT(gcov) := gcc-$(VERSION)/gcc/coretypes.h \ + gcc-$(VERSION)/gcc/defaults.h \ + gcc-$(VERSION)/gcc/diagnostic.c \ + gcc-$(VERSION)/gcc/diagnostic-color.c \ + gcc-$(VERSION)/gcc/diagnostic-color.h \ + gcc-$(VERSION)/gcc/diagnostic-core.h \ + gcc-$(VERSION)/gcc/diagnostic.def \ + gcc-$(VERSION)/gcc/diagnostic.h \ + gcc-$(VERSION)/gcc/diagnostic-show-locus.c \ + gcc-$(VERSION)/gcc/double-int.h \ + gcc-$(VERSION)/gcc/fixed-value.h \ + gcc-$(VERSION)/gcc/flag-types.h \ + gcc-$(VERSION)/gcc/gcov.c \ + gcc-$(VERSION)/gcc/gcov-counter.def \ + gcc-$(VERSION)/gcc/gcov-io.c \ + gcc-$(VERSION)/gcc/gcov-io.h \ + gcc-$(VERSION)/gcc/ggc.h \ + gcc-$(VERSION)/gcc/ggc-none.c \ + gcc-$(VERSION)/gcc/hash-map.h \ + gcc-$(VERSION)/gcc/hash-map-traits.h \ + gcc-$(VERSION)/gcc/hash-set.h \ + gcc-$(VERSION)/gcc/hash-table.c \ + gcc-$(VERSION)/gcc/hash-table.h \ + gcc-$(VERSION)/gcc/hash-traits.h \ + gcc-$(VERSION)/gcc/hwint.h \ + gcc-$(VERSION)/gcc/inchash.h \ + gcc-$(VERSION)/gcc/input.c \ + gcc-$(VERSION)/gcc/input.h \ + gcc-$(VERSION)/gcc/intl.c \ + gcc-$(VERSION)/gcc/intl.h \ + gcc-$(VERSION)/gcc/is-a.h \ + gcc-$(VERSION)/gcc/machmode.h \ + gcc-$(VERSION)/gcc/memory-block.cc \ + gcc-$(VERSION)/gcc/memory-block.h \ + gcc-$(VERSION)/gcc/mem-stats.h \ + gcc-$(VERSION)/gcc/mem-stats-traits.h \ + gcc-$(VERSION)/gcc/mode-classes.def \ + gcc-$(VERSION)/gcc/pretty-print.c \ + gcc-$(VERSION)/gcc/pretty-print.h \ + gcc-$(VERSION)/gcc/real.h \ + gcc-$(VERSION)/gcc/signop.h \ + gcc-$(VERSION)/gcc/statistics.h \ + gcc-$(VERSION)/gcc/system.h \ + gcc-$(VERSION)/gcc/tsystem.h \ + gcc-$(VERSION)/gcc/vec.c \ + gcc-$(VERSION)/gcc/vec.h \ + gcc-$(VERSION)/gcc/version.c \ + gcc-$(VERSION)/gcc/version.h \ + gcc-$(VERSION)/gcc/wide-int.h \ + gcc-$(VERSION)/gcc/wide-int-print.h \ + gcc-$(VERSION)/gcc/config/dbxelf.h \ + gcc-$(VERSION)/gcc/config/elfos.h \ + gcc-$(VERSION)/gcc/config/initfini-array.h \ + gcc-$(VERSION)/gcc/config/newlib-stdint.h \ + gcc-$(VERSION)/gcc/config/vxworks-dummy.h \ + gcc-$(VERSION)/gcc/config/arm/aout.h \ + gcc-$(VERSION)/gcc/config/arm/arm-cores.def \ + gcc-$(VERSION)/gcc/config/arm/arm.h \ + gcc-$(VERSION)/gcc/config/arm/arm-opts.h \ + gcc-$(VERSION)/gcc/config/arm/bpabi.h \ + gcc-$(VERSION)/gcc/config/arm/elf.h \ + gcc-$(VERSION)/gcc/config/arm/unknown-elf.h \ + gcc-$(VERSION)/gcc/config/i386/att.h \ + gcc-$(VERSION)/gcc/config/i386/biarch64.h \ + gcc-$(VERSION)/gcc/config/i386/i386elf.h \ + gcc-$(VERSION)/gcc/config/i386/i386.h \ + gcc-$(VERSION)/gcc/config/i386/i386-opts.h \ + gcc-$(VERSION)/gcc/config/i386/stringop.def \ + gcc-$(VERSION)/gcc/config/i386/unix.h \ + gcc-$(VERSION)/gcc/config/i386/x86-64.h \ + gcc-$(VERSION)/gcc/config/i386/x86-tune.def \ + gcc-$(VERSION)/include/ansidecl.h \ + gcc-$(VERSION)/include/demangle.h \ + gcc-$(VERSION)/include/environ.h \ + gcc-$(VERSION)/include/filenames.h \ + gcc-$(VERSION)/include/hashtab.h \ + gcc-$(VERSION)/include/libiberty.h \ + gcc-$(VERSION)/include/obstack.h \ + gcc-$(VERSION)/include/safe-ctype.h \ + gcc-$(VERSION)/libcpp/internal.h \ + gcc-$(VERSION)/libcpp/line-map.c \ + gcc-$(VERSION)/libcpp/system.h \ + gcc-$(VERSION)/libcpp/include/cpp-id-data.h \ + gcc-$(VERSION)/libcpp/include/cpplib.h \ + gcc-$(VERSION)/libcpp/include/line-map.h \ + gcc-$(VERSION)/libcpp/include/symtab.h \ + gcc-$(VERSION)/libgcc/gthr.h \ + gcc-$(VERSION)/libgcc/libgcov-driver.c \ + gcc-$(VERSION)/libgcc/libgcov-driver-system.c \ + gcc-$(VERSION)/libgcc/libgcov.h \ + gcc-$(VERSION)/libgcc/libgcov-interface.c \ + gcc-$(VERSION)/libgcc/libgcov-merge.c \ + gcc-$(VERSION)/libgcc/libgcov-profiler.c \ + gcc-$(VERSION)/libiberty/argv.c \ + gcc-$(VERSION)/libiberty/concat.c \ + gcc-$(VERSION)/libiberty/cp-demangle.c \ + gcc-$(VERSION)/libiberty/cp-demangle.h \ + gcc-$(VERSION)/libiberty/cplus-dem.c \ + gcc-$(VERSION)/libiberty/d-demangle.c \ + gcc-$(VERSION)/libiberty/filename_cmp.c \ + gcc-$(VERSION)/libiberty/fopen_unlocked.c \ + gcc-$(VERSION)/libiberty/hashtab.c \ + gcc-$(VERSION)/libiberty/lbasename.c \ + gcc-$(VERSION)/libiberty/obstack.c \ + gcc-$(VERSION)/libiberty/safe-ctype.c \ + gcc-$(VERSION)/libiberty/vprintf-support.c \ + gcc-$(VERSION)/libiberty/vprintf-support.h \ + gcc-$(VERSION)/libiberty/xexit.c \ + gcc-$(VERSION)/libiberty/xmalloc.c \ + gcc-$(VERSION)/libiberty/xstrdup.c \ + gcc-$(VERSION)/libiberty/xstrerror.c \ + gcc-$(VERSION)/libiberty/xvasprintf.c \ + gcc-$(VERSION)/COPYING \ + --strip-components=1 + +PATCHES := src/app/gcov/patches/*.patch \ + src/lib/gcov/patches/*.patch +PATCH_OPT := -p1 -d src/gcov + +default: symlinks + +# +# These .c files need to be compiled with g++ +# +symlinks: $(DOWNLOADS) + $(VERBOSE)ln -s diagnostic-color.c ${DIR(gcov)}/gcc/diagnostic-color.cc + $(VERBOSE)ln -s diagnostic-show-locus.c ${DIR(gcov)}/gcc/diagnostic-show-locus.cc + $(VERBOSE)ln -s diagnostic.c ${DIR(gcov)}/gcc/diagnostic.cc + $(VERBOSE)ln -s gcov.c ${DIR(gcov)}/gcc/gcov.cc + $(VERBOSE)ln -s ggc-none.c ${DIR(gcov)}/gcc/ggc-none.cc + $(VERBOSE)ln -s hash-table.c ${DIR(gcov)}/gcc/hash-table.cc + $(VERBOSE)ln -s input.c ${DIR(gcov)}/gcc/input.cc + $(VERBOSE)ln -s intl.c ${DIR(gcov)}/gcc/intl.cc + $(VERBOSE)ln -s pretty-print.c ${DIR(gcov)}/gcc/pretty-print.cc + $(VERBOSE)ln -s vec.c ${DIR(gcov)}/gcc/vec.cc + $(VERBOSE)ln -s version.c ${DIR(gcov)}/gcc/version.cc + $(VERBOSE)ln -s line-map.c ${DIR(gcov)}/libcpp/line-map.cc diff --git a/repos/libports/recipes/api/libgcov/content.mk b/repos/libports/recipes/api/libgcov/content.mk new file mode 100644 index 000000000..d309a4f5f --- /dev/null +++ b/repos/libports/recipes/api/libgcov/content.mk @@ -0,0 +1,28 @@ +content: include \ + lib/mk/libgcov.mk \ + src/gcov \ + src/lib/gcov \ + LICENSE + +PORT_DIR := $(call port_dir,$(REP_DIR)/ports/gcov) + +include: + mkdir $@ + cp -r $(PORT_DIR)/include/* $@/ + cp -r $(GENODE_DIR)/repos/os/include/file_system $@/ + +lib/mk/libgcov.mk: + $(mirror_from_rep_dir) + +src/gcov: + mkdir -p $@ + cp -r $(PORT_DIR)/src/gcov/include $@/ + cp -r $(PORT_DIR)/src/gcov/gcc $@/ + cp -r $(PORT_DIR)/src/gcov/libgcc $@/ + +src/lib/gcov: + $(mirror_from_rep_dir) + echo "LIBS = libgcov" > $@/target.mk + +LICENSE: + cp $(PORT_DIR)/src/gcov/COPYING $@ diff --git a/repos/libports/recipes/api/libgcov/hash b/repos/libports/recipes/api/libgcov/hash new file mode 100644 index 000000000..cb205033d --- /dev/null +++ b/repos/libports/recipes/api/libgcov/hash @@ -0,0 +1 @@ +2018-11-16-b 8a444f55abb26a8ae6c9d7af681db7a4ae58d12a diff --git a/repos/libports/recipes/pkg/gcov/README b/repos/libports/recipes/pkg/gcov/README new file mode 100644 index 000000000..7eea4a177 --- /dev/null +++ b/repos/libports/recipes/pkg/gcov/README @@ -0,0 +1 @@ +gcov runtime for tests executed by 'depot_autopilot.run' diff --git a/repos/libports/recipes/pkg/gcov/archives b/repos/libports/recipes/pkg/gcov/archives new file mode 100644 index 000000000..8061c01d7 --- /dev/null +++ b/repos/libports/recipes/pkg/gcov/archives @@ -0,0 +1,7 @@ +_/src/init +_/src/gcov +_/src/gmp +_/src/libc +_/src/posix +_/src/stdcxx +_/src/vfs diff --git a/repos/libports/recipes/pkg/gcov/hash b/repos/libports/recipes/pkg/gcov/hash new file mode 100644 index 000000000..aedc142f1 --- /dev/null +++ b/repos/libports/recipes/pkg/gcov/hash @@ -0,0 +1 @@ +2018-11-16-h d56715c26c3266e1dede99f928683339956e6d2d diff --git a/repos/libports/recipes/pkg/gcov/runtime b/repos/libports/recipes/pkg/gcov/runtime new file mode 100644 index 000000000..8a2bb2d79 --- /dev/null +++ b/repos/libports/recipes/pkg/gcov/runtime @@ -0,0 +1,49 @@ + + + + + + [init] child "gcov" exited with exit value 0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/repos/libports/recipes/src/gcov/content.mk b/repos/libports/recipes/src/gcov/content.mk new file mode 100644 index 000000000..2691766d1 --- /dev/null +++ b/repos/libports/recipes/src/gcov/content.mk @@ -0,0 +1,29 @@ +content: include \ + lib/mk/gcov-libcommon.mk \ + lib/mk/gcov-libcpp.mk \ + lib/mk/gcov-libiberty.mk \ + src/gcov \ + src/app/gcov \ + LICENSE + +PORT_DIR := $(call port_dir,$(REP_DIR)/ports/gcov) + +include: + mkdir $@ + cp -r $(PORT_DIR)/include/* $@/ + +lib/mk/%.mk: + $(mirror_from_rep_dir) + +src/lib/%: + $(mirror_from_rep_dir) + +src/gcov: + mkdir -p $(dir $@) + cp -r $(PORT_DIR)/src/gcov $@ + +src/app/gcov: + $(mirror_from_rep_dir) + +LICENSE: + cp $(PORT_DIR)/src/gcov/COPYING $@ diff --git a/repos/libports/recipes/src/gcov/hash b/repos/libports/recipes/src/gcov/hash new file mode 100644 index 000000000..afc28513d --- /dev/null +++ b/repos/libports/recipes/src/gcov/hash @@ -0,0 +1 @@ +2018-11-16-e 2a86e572acc3c547aeb8c249832a40c2642b05a9 diff --git a/repos/libports/recipes/src/gcov/used_apis b/repos/libports/recipes/src/gcov/used_apis new file mode 100644 index 000000000..3181c2bd8 --- /dev/null +++ b/repos/libports/recipes/src/gcov/used_apis @@ -0,0 +1,5 @@ +base +gmp +libc +posix +stdcxx diff --git a/repos/libports/src/app/gcov/patches/backtrace.patch b/repos/libports/src/app/gcov/patches/backtrace.patch new file mode 100644 index 000000000..c1fbce354 --- /dev/null +++ b/repos/libports/src/app/gcov/patches/backtrace.patch @@ -0,0 +1,75 @@ +backtrace.patch + +From: Christian Prochaska + + +--- + gcc/diagnostic-show-locus.c | 2 ++ + gcc/diagnostic.c | 11 ++++++++--- + 2 files changed, 10 insertions(+), 3 deletions(-) + +diff --git a/gcc/diagnostic-show-locus.c b/gcc/diagnostic-show-locus.c +index bf95666..b68b700 100644 +--- a/gcc/diagnostic-show-locus.c ++++ b/gcc/diagnostic-show-locus.c +@@ -24,7 +24,9 @@ along with GCC; see the file COPYING3. If not see + #include "version.h" + #include "demangle.h" + #include "intl.h" ++#if 0 + #include "backtrace.h" ++#endif + #include "diagnostic.h" + #include "diagnostic-color.h" + +diff --git a/gcc/diagnostic.c b/gcc/diagnostic.c +index 8106172..85d5eb0 100644 +--- a/gcc/diagnostic.c ++++ b/gcc/diagnostic.c +@@ -28,7 +28,9 @@ along with GCC; see the file COPYING3. If not see + #include "version.h" + #include "demangle.h" + #include "intl.h" ++#if 0 + #include "backtrace.h" ++#endif + #include "diagnostic.h" + #include "diagnostic-color.h" + +@@ -345,7 +347,7 @@ static const char * const bt_stop[] = + }; + + /* A callback function passed to the backtrace_full function. */ +- ++#if 0 + static int + bt_callback (void *data, uintptr_t pc, const char *filename, int lineno, + const char *function) +@@ -425,7 +427,7 @@ bt_err_callback (void *data ATTRIBUTE_UNUSED, const char *msg, int errnum) + fprintf (stderr, "%s%s%s\n", msg, errnum == 0 ? "" : ": ", + errnum == 0 ? "" : xstrerror (errnum)); + } +- ++#endif + /* Take any action which is expected to happen after the diagnostic + is written out. This function does not always return. */ + void +@@ -467,14 +469,17 @@ diagnostic_action_after_output (diagnostic_context *context, + case DK_ICE: + case DK_ICE_NOBT: + { ++#if 0 + struct backtrace_state *state = NULL; + if (diag_kind == DK_ICE) + state = backtrace_create_state (NULL, 0, bt_err_callback, NULL); ++#endif + int count = 0; ++#if 0 + if (state != NULL) + backtrace_full (state, 2, bt_callback, bt_err_callback, + (void *) &count); +- ++#endif + if (context->abort_on_error) + real_abort (); + diff --git a/repos/libports/src/app/gcov/patches/gcov.patch b/repos/libports/src/app/gcov/patches/gcov.patch new file mode 100644 index 000000000..68fcfe108 --- /dev/null +++ b/repos/libports/src/app/gcov/patches/gcov.patch @@ -0,0 +1,189 @@ +gcov.patch + +From: Christian Prochaska + + +--- + gcc/gcov.c | 89 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++--- + 1 file changed, 84 insertions(+), 5 deletions(-) + +diff --git a/gcc/gcov.c b/gcc/gcov.c +index 50061c7..eead285 100644 +--- a/gcc/gcov.c ++++ b/gcc/gcov.c +@@ -41,10 +41,13 @@ along with Gcov; see the file COPYING3. If not see + + #include + ++#include ++ + #define IN_GCOV 1 + #include "gcov-io.h" + #include "gcov-io.c" + ++ + /* The gcno file is generated by -ftest-coverage option. The gcda file is + generated by a program compiled with -fprofile-arcs. Their formats + are documented in gcov-io.h. */ +@@ -350,6 +353,16 @@ static int flag_all_blocks = 0; + + static int flag_function_summary = 0; + ++/* ++ * Genode autopilot mode ++ * ++ * - scans for gcov data files ++ * - strips the Genode depot path from source paths ++ * - writes results to stdout ++ */ ++ ++static int flag_genode_autopilot = 0; ++ + /* Object directory file prefix. This is the directory/file where the + graph and data files are looked for, if nonzero. */ + +@@ -407,6 +420,43 @@ static void release_structures (void); + static void release_function (function_t *); + extern int main (int, char **); + ++void process_files(const char *dir_path) ++{ ++ char new_path[strlen(dir_path) + sizeof('/') + NAME_MAX]; ++ ++ DIR *dir = opendir(dir_path); ++ ++ if (!dir) ++ return; ++ ++ struct dirent *dirent; ++ ++ while((dirent = readdir(dir)) != NULL) { ++ ++ snprintf(new_path, sizeof(new_path), "%s/%s", dir_path, dirent->d_name); ++ ++ struct stat stat_buf; ++ ++ if (stat(new_path, &stat_buf) != 0) ++ continue; ++ ++ if (S_ISDIR(stat_buf.st_mode)) { ++ process_files(new_path); ++ continue; ++ } ++ ++ if (!S_ISREG(stat_buf.st_mode)) ++ continue; ++ ++ if (!strstr(dirent->d_name, ".gcda")) ++ continue; ++ ++ process_file(new_path); ++ } ++ ++ closedir(dir); ++} ++ + int + main (int argc, char **argv) + { +@@ -437,7 +487,7 @@ main (int argc, char **argv) + sources = XNEWVEC (source_t, a_sources); + + argno = process_args (argc, argv); +- if (optind == argc) ++ if ((optind == argc) && !flag_genode_autopilot) + print_usage (true); + + if (argc - argno > 1) +@@ -445,6 +495,15 @@ main (int argc, char **argv) + + first_arg = argno; + ++ if (flag_genode_autopilot) { ++ ++ /* search .gcda files and process each one */ ++ process_files("/"); ++ ++ /* finish processing arguments */ ++ argno = argc; ++ } ++ + for (; argno != argc; argno++) + { + if (flag_display_progress) +@@ -488,7 +547,8 @@ print_usage (int error_p) + fnotice (file, " -r, --relative-only Only show data for relative sources\n"); + fnotice (file, " -s, --source-prefix DIR Source prefix to elide\n"); + fnotice (file, " -u, --unconditional-branches Show unconditional branch counts too\n"); +- fnotice (file, " -v, --version Print version number, then exit\n"); ++ fnotice (file, " -v, --version Print version number, then exit\n\n"); ++ fnotice (file, " -g, --genode-autopilot Genode autopilot mode\n"); + fnotice (file, "\nFor bug reporting instructions, please see:\n%s.\n", + bug_report_url); + exit (status); +@@ -528,6 +588,7 @@ static const struct option options[] = + { "source-prefix", required_argument, NULL, 's' }, + { "unconditional-branches", no_argument, NULL, 'u' }, + { "display-progress", no_argument, NULL, 'd' }, ++ { "genode-autopilot", no_argument, NULL, 'g' }, + { 0, 0, 0, 0 } + }; + +@@ -538,7 +599,7 @@ process_args (int argc, char **argv) + { + int opt; + +- while ((opt = getopt_long (argc, argv, "abcdfhilmno:s:pruv", options, NULL)) != ++ while ((opt = getopt_long (argc, argv, "abcdfghilmno:s:pruv", options, NULL)) != + -1) + { + switch (opt) +@@ -555,6 +616,9 @@ process_args (int argc, char **argv) + case 'f': + flag_function_summary = 1; + break; ++ case 'g': ++ flag_genode_autopilot = 1; ++ break; + case 'h': + print_usage (false); + /* print_usage will exit. */ +@@ -788,14 +852,17 @@ output_gcov_file (const char *file_name, source_t *src) + + if (src->coverage.lines) + { +- FILE *gcov_file = fopen (gcov_file_name, "w"); ++ FILE *gcov_file = flag_genode_autopilot ? ++ stdout : ++ fopen (gcov_file_name, "w"); + if (gcov_file) + { + fnotice (stdout, "Creating '%s'\n", gcov_file_name); + output_lines (gcov_file, src); + if (ferror (gcov_file)) + fnotice (stderr, "Error writing output file '%s'\n", gcov_file_name); +- fclose (gcov_file); ++ if (!flag_genode_autopilot) ++ fclose (gcov_file); + } + else + fnotice (stderr, "Could not open output file '%s'\n", gcov_file_name); +@@ -1114,6 +1181,18 @@ find_source (const char *file_name) + #endif + && IS_DIR_SEPARATOR (src->coverage.name[source_length])) + src->coverage.name += source_length + 1; ++ ++ if (flag_genode_autopilot) { ++ ++ /* strip path of the Genode depot */ ++ ++ char *depot_relative_path = strstr(src->name, "/depot/"); ++ if (depot_relative_path) { ++ src->name = depot_relative_path + strlen("/depot"); ++ src->coverage.name = src->name; ++ } ++ } ++ + if (!stat (src->name, &status)) + src->file_time = status.st_mtime; + } diff --git a/repos/libports/src/app/gcov/target.mk b/repos/libports/src/app/gcov/target.mk new file mode 100644 index 000000000..5306ba1ec --- /dev/null +++ b/repos/libports/src/app/gcov/target.mk @@ -0,0 +1,31 @@ +TARGET = gcov + +GCOV_PORT_DIR := $(call select_from_ports,gcov) + +GCOV_DIR := $(GCOV_PORT_DIR)/src/gcov + +SRC_CC = gcov.cc + +CC_OPT_gcov = -DIN_GCC -DHAVE_CONFIG_H + +INC_DIR += $(GCOV_DIR)/gcc +INC_DIR += $(GCOV_DIR)/include +INC_DIR += $(GCOV_DIR)/libcpp/include + +ifeq ($(filter-out $(SPECS),arm),) + INC_DIR += $(GCOV_PORT_DIR)/include/arm/gcc +endif + +ifeq ($(filter-out $(SPECS),x86_32),) + INC_DIR += $(GCOV_PORT_DIR)/include/x86_32/gcc +endif + +ifeq ($(filter-out $(SPECS),x86_64),) + INC_DIR += $(GCOV_PORT_DIR)/include/x86_64/gcc +endif + +LIBS += base libc posix gmp stdcxx gcov-libcommon gcov-libcpp gcov-libiberty + +vpath %.cc $(GCOV_DIR)/gcc + +CC_CXX_WARN_STRICT = diff --git a/repos/libports/src/lib/gcov/libc/libc.cc b/repos/libports/src/lib/gcov/libc/libc.cc new file mode 100644 index 000000000..e91436d05 --- /dev/null +++ b/repos/libports/src/lib/gcov/libc/libc.cc @@ -0,0 +1,241 @@ +/* + * \brief Minimal C library for libgcov + * \author Christian Prochaska + * \date 2018-11-16 + * + */ + +/* + * Copyright (C) 2018 Genode Labs GmbH + * + * This file is part of the Genode OS framework, which is distributed + * under the terms of the GNU Affero General Public License version 3. + */ + +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include "stdio.h" +} + +typedef Genode::Path Absolute_path; + +struct FILE { }; + +static FILE stderr_file; + +FILE *stderr = &stderr_file; + +struct Gcov_env +{ + Genode::Env &env; + Genode::Heap heap { env.ram(), env.rm() }; + Genode::Allocator_avl fs_alloc { &heap }; + File_system::Connection fs { env, fs_alloc, "gcov_data" }; + unsigned long seek_offset { 0 }; + + /* only one file is open at a time */ + Genode::Constructible file_handle; + FILE file; + + Gcov_env(Genode::Env &env) : env(env) { } +}; + + +static Genode::Constructible gcov_env; + + +void gcov_init(Genode::Env &env) +{ + gcov_env.construct(env); +} + + +extern "C" void abort() +{ + Genode::error("abort() called: not implemented"); + Genode::sleep_forever(); +} + + +extern void genode_atexit(void (*func)(void)); +extern "C" void atexit(void (*func)(void)) +{ + genode_atexit(func); +} + + +extern "C" int atoi(const char *nptr) +{ + Genode::error("atoi() called: not implemented"); + return 0; +} + + +extern "C" int fclose(FILE *stream) +{ + gcov_env->fs.close(*(gcov_env->file_handle)); + gcov_env->file_handle.destruct(); + return 0; +} + + +extern "C" FILE *fopen(const char *path, const char *mode) +{ + Absolute_path dir_path(path); + dir_path.strip_last_element(); + + Absolute_path file_name(path); + file_name.keep_only_last_element(); + + File_system::Dir_handle dir = File_system::ensure_dir(gcov_env->fs, dir_path.base()); + + try { + gcov_env->file_handle.construct(gcov_env->fs.file(dir, + file_name.base() + 1, + File_system::READ_WRITE, + false)); + if (Genode::strcmp(mode, "w+b", 3) == 0) + gcov_env->fs.truncate(*(gcov_env->file_handle), 0); + + } catch (File_system::Lookup_failed) { + + if (Genode::strcmp(mode, "w+b", 3) == 0) + gcov_env->file_handle.construct(gcov_env->fs.file(dir, + file_name.base() + 1, + File_system::READ_WRITE, + true)); + else + return nullptr; + } + + gcov_env->seek_offset = 0; + + return &gcov_env->file; +} + + +extern "C" int fprintf(FILE *stream, const char *format, ...) +{ + if (stream != stderr) { + Genode::error("fprintf() called: not implemented"); + return 0; + } + + va_list list; + va_start(list, format); + + Genode::vprintf(format, list); + va_end(list); + + return 0; +} + + +extern "C" size_t fread(void *ptr, size_t size, size_t nmemb, FILE *stream) +{ + size_t bytes_read = File_system::read(gcov_env->fs, *(gcov_env->file_handle), + ptr, size * nmemb, + gcov_env->seek_offset); + + gcov_env->seek_offset += bytes_read; + + if (bytes_read == (size * nmemb)) + return nmemb; + + return 0; +} + + +extern "C" void free(void *ptr) +{ + gcov_env->heap.free(ptr, 0); +} + + +extern "C" int fseek(FILE *stream, long offset, int whence) +{ + if (whence != 0) + Genode::error("fseek(): unsupported 'whence'"); + + gcov_env->seek_offset = offset; + + return 0; +} + + +extern "C" long ftell(FILE *stream) +{ + return gcov_env->seek_offset; +} + + +extern "C" size_t fwrite(const void *ptr, size_t size, size_t nmemb, FILE *stream) +{ + if (stream == stderr) { + Genode::printf((const char*)ptr); + return 0; + } + + size_t bytes_written = File_system::write(gcov_env->fs, + *(gcov_env->file_handle), + ptr, size * nmemb, + gcov_env->seek_offset); + + gcov_env->seek_offset += bytes_written; + + if (bytes_written == (size * nmemb)) + return nmemb; + + return 0; +} + + +extern "C" char *getenv(const char *name) +{ + return nullptr; +} + + +extern "C" void *malloc(size_t size) +{ + void *res = nullptr; + gcov_env->heap.alloc(size, &res); + return res; +} + + +extern "C" void setbuf(FILE *stream, char *buf) +{ + if (buf) + Genode::error("setbuf(", (void*)buf, "): not implemented"); +} + + +extern "C" char *strcpy(char *dest, const char *src) +{ + return Genode::strncpy(dest, src, Genode::strlen(src) + 1); +} + + +extern "C" size_t strlen(const char *s) +{ + return Genode::strlen(s); +} + + +extern "C" int vfprintf(FILE *stream, const char *format, va_list ap) +{ + if (stream != stderr) + return 0; + + Genode::vprintf(format, ap); + return 0; +} diff --git a/repos/libports/src/lib/gcov/libc/stdio.h b/repos/libports/src/lib/gcov/libc/stdio.h new file mode 100644 index 000000000..3e19e961b --- /dev/null +++ b/repos/libports/src/lib/gcov/libc/stdio.h @@ -0,0 +1,37 @@ +/* + * \brief Minimal C library for libgcov + * \author Christian Prochaska + * \date 2018-11-16 + * + */ + +/* + * Copyright (C) 2018 Genode Labs GmbH + * + * This file is part of the Genode OS framework, which is distributed + * under the terms of the GNU Affero General Public License version 3. + */ + +#ifndef STDIO_H +#define STDIO_H + +#include + +#define SEEK_SET 0 + +struct FILE; +typedef struct FILE FILE; + +extern FILE *stderr; + +int fclose(FILE *stream); +FILE *fopen(const char *path, const char *mode); +int fprintf(FILE *stream, const char *format, ...); +size_t fread(void *ptr, size_t size, size_t nmemb, FILE *stream); +int fseek(FILE *stream, long offset, int whence); +long ftell(FILE *stream); +size_t fwrite(const void *ptr, size_t size, size_t nmemb, FILE *stream); +void setbuf(FILE *stream, char *buf); +int vfprintf(FILE *stream, const char *format, va_list ap); + +#endif diff --git a/repos/libports/src/lib/gcov/libc/stdlib.h b/repos/libports/src/lib/gcov/libc/stdlib.h new file mode 100644 index 000000000..838cba1e9 --- /dev/null +++ b/repos/libports/src/lib/gcov/libc/stdlib.h @@ -0,0 +1,25 @@ +/* + * \brief Minimal C library for libgcov + * \author Christian Prochaska + * \date 2018-11-16 + * + */ + +/* + * Copyright (C) 2018 Genode Labs GmbH + * + * This file is part of the Genode OS framework, which is distributed + * under the terms of the GNU Affero General Public License version 3. + */ + +#ifndef STDLIB_H +#define STDLIB_H + +void abort(void); +void atexit(void (*func)(void)); +int atoi(const char *nptr); +void free(void *ptr); +char *getenv(const char *name); +void *malloc(size_t size); + +#endif diff --git a/repos/libports/src/lib/gcov/libc/string.h b/repos/libports/src/lib/gcov/libc/string.h new file mode 100644 index 000000000..4a23b37c8 --- /dev/null +++ b/repos/libports/src/lib/gcov/libc/string.h @@ -0,0 +1,23 @@ +/* + * \brief Minimal C library for libgcov + * \author Christian Prochaska + * \date 2018-11-16 + * + */ + +/* + * Copyright (C) 2018 Genode Labs GmbH + * + * This file is part of the Genode OS framework, which is distributed + * under the terms of the GNU Affero General Public License version 3. + */ + +#ifndef STRING_H +#define STRING_H + +void *memcpy(void *dest, const void *src, size_t n); +void *memset(void *s, int c, size_t n); +char *strcpy(char *dest, const char *src); +size_t strlen(const char *s); + +#endif diff --git a/repos/libports/src/lib/gcov/libc/sys/types.h b/repos/libports/src/lib/gcov/libc/sys/types.h new file mode 100644 index 000000000..edeb2f6ca --- /dev/null +++ b/repos/libports/src/lib/gcov/libc/sys/types.h @@ -0,0 +1,21 @@ +/* + * \brief Minimal C library for libgcov + * \author Christian Prochaska + * \date 2018-11-16 + * + */ + +/* + * Copyright (C) 2018 Genode Labs GmbH + * + * This file is part of the Genode OS framework, which is distributed + * under the terms of the GNU Affero General Public License version 3. + */ + +#ifndef SYS_TYPES_H +#define SYS_TYPES_H + +typedef unsigned long size_t; +typedef int pid_t; + +#endif diff --git a/repos/libports/src/lib/gcov/libc/unistd.h b/repos/libports/src/lib/gcov/libc/unistd.h new file mode 100644 index 000000000..fb73ac9a1 --- /dev/null +++ b/repos/libports/src/lib/gcov/libc/unistd.h @@ -0,0 +1,20 @@ +/* + * \brief Minimal C library for libgcov + * \author Christian Prochaska + * \date 2018-11-16 + * + */ + +/* + * Copyright (C) 2018 Genode Labs GmbH + * + * This file is part of the Genode OS framework, which is distributed + * under the terms of the GNU Affero General Public License version 3. + */ + +#ifndef UNISTD_H +#define UNISTD_H + +#define F_OK 0 + +#endif diff --git a/repos/libports/src/lib/gcov/patches/libgcov.patch b/repos/libports/src/lib/gcov/patches/libgcov.patch new file mode 100644 index 000000000..8cd67deff --- /dev/null +++ b/repos/libports/src/lib/gcov/patches/libgcov.patch @@ -0,0 +1,38 @@ +libgcov.patch + +From: Christian Prochaska + + +--- + gcc/tsystem.h | 6 ++++++ + 1 file changed, 6 insertions(+) + +diff --git a/gcc/tsystem.h b/gcc/tsystem.h +index 7dc4b54..c7a09df 100644 +--- a/gcc/tsystem.h ++++ b/gcc/tsystem.h +@@ -90,7 +90,9 @@ extern void *memset (void *, int, size_t); + #include + + /* All systems have this header. */ ++#if 0 + #include ++#endif + + #ifndef errno + extern int errno; +@@ -102,10 +104,14 @@ extern int errno; + #include + + /* GCC supplies this header. */ ++#if 0 + #include ++#endif + + /* If these system headers do not exist, fixincludes must create them. */ ++#if 0 + #include ++#endif + + #endif /* inhibit_libc */ +