[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [UNIKRAFT PATCH 3/3] plat/kvm, build: Change the default directory in which *.gcda files are generated.
Set GCOV_PREFIX and GCOV_PREFIX_STRIP. GCOV_PREFIX is a runtime environment variable that determines the root directory where the gcov output files (*.gcda) are written. GCOV_PREFIX_STRIP=X is also a runtime variable and has the effect of stripping X elements from the path found in the object files. Thus, the default path in which the *.gcda files were generated was changed with the help of the two environment variables. Now the files are saved to the path given exclusively by the GCOV_PREFIX environment variable, GCOV_PREFIX_STRIP being large enough to skip the entire default path. Signed-off-by: Alice Suiu <alicesuiu17@xxxxxxxxx> --- Makefile.uk | 6 +----- plat/kvm/shutdown.c | 34 +++++++++++++++++++++------------- 2 files changed, 22 insertions(+), 18 deletions(-) diff --git a/Makefile.uk b/Makefile.uk index e201785..510769a 100644 --- a/Makefile.uk +++ b/Makefile.uk @@ -40,11 +40,7 @@ LDFLAGS-$(CONFIG_OPTIMIZE_LTO) += $(COMPFLAGS) $(COMPFLAGS-y) $(ARCHF LDFLAGS-$(CONFIG_OPTIMIZE_PGO_GENERATE) += $(COMPFLAGS) $(COMPFLAGS-y) $(ARCHFLAGS) $(ARCHFLAGS-y) -fprofile-generate # PGO - profile-use phase -LDFLAGS-$(CONFIG_OPTIMIZE_PGO_USE) += $(COMPFLAGS) $(COMPFLAGS-y) $(ARCHFLAGS) $(ARCHFLAGS-y) -O3 -fprofile-use=main.gcda - -# ASAN -COMPFLAGS-$(CONFIG_OPTIMIZE_ASAN) += -fsanitize=address -LDFLAGS-$(CONFIG_OPTIMIZE_ASAN) += $(COMPFLAGS) $(COMPFLAGS-y) $(ARCHFLAGS) $(ARCHFLAGS-y) -fsanitize=address +LDFLAGS-$(CONFIG_OPTIMIZE_PGO_USE) += $(COMPFLAGS) $(COMPFLAGS-y) $(ARCHFLAGS) $(ARCHFLAGS-y) -fprofile-use DBGFLAGS-$(CONFIG_DEBUG_SYMBOLS_LVL0) += -g0 DBGFLAGS-$(CONFIG_DEBUG_SYMBOLS_LVL1) += -g1 diff --git a/plat/kvm/shutdown.c b/plat/kvm/shutdown.c index 9ca909f..ad0cd18 100644 --- a/plat/kvm/shutdown.c +++ b/plat/kvm/shutdown.c @@ -30,22 +30,30 @@ #if CONFIG_OPTIMIZE_PGO_GENERATE #include <sys/stat.h> #include <sys/types.h> +#include <dirent.h> -#define GCOV_GENERATE_FILE "/home/alice/Documents/Diploma/Comp-opt/apps/helloworld/build/apphelloworld/main.gcda" +#define GCOV_GENERATED_DIR "/gcov_profiling" +#define GCOV_PREFIX_STRIP_LENGTH "100" -void create_hierarchy() +void set_path_gcov_files() { - mkdir("/home", 0777); - mkdir("/home/alice", 0777); - mkdir("/home/alice/Documents", 0777); - mkdir("/home/alice/Documents/Diploma", 0777); - mkdir("/home/alice/Documents/Diploma/Comp-opt", 0777); - mkdir("/home/alice/Documents/Diploma/Comp-opt/apps", 0777); - mkdir("/home/alice/Documents/Diploma/Comp-opt/apps/helloworld", 0777); - mkdir("/home/alice/Documents/Diploma/Comp-opt/apps/helloworld/build", 0777); - mkdir("/home/alice/Documents/Diploma/Comp-opt/apps/helloworld/build/apphelloworld", 0777); -} + const char *gcov_prefix; + const char *gcov_strip; + + gcov_prefix = getenv("GCOV_PREFIX"); + if (!gcov_prefix) + setenv("GCOV_PREFIX", GCOV_GENERATED_DIR, 1); + gcov_strip = getenv("GCOV_PREFIX_STRIP"); + if (!gcov_strip) + setenv("GCOV_PREFIX_STRIP", GCOV_PREFIX_STRIP_LENGTH, 1); + + DIR* dir = opendir(GCOV_GENERATED_DIR); + if (dir) + closedir(dir); + else if (ENOENT == errno) + mkdir(GCOV_GENERATED_DIR, 0777); +} #endif static void cpu_halt(void) __noreturn; @@ -55,7 +63,7 @@ void ukplat_terminate(enum ukplat_gstate request __unused) { #if CONFIG_OPTIMIZE_PGO_GENERATE - create_hierarchy(); + set_path_gcov_files(); __gcov_exit(); #endif -- 2.17.1
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |