From 2f2d56e2e33455ac0b093262b6ee89b988c67ec4 Mon Sep 17 00:00:00 2001 From: PulkoMandy Date: Mon, 1 Apr 2019 22:48:51 +0200 Subject: [PATCH] Move stack_trace.cpp to generic directory. 4 architectures are using it, so it is generic enough. Make it error out for platforms where the stack grows in the other direction. Another implementation can be added for them. Change-Id: Ia52b5dd34da7b5ebcca0782af079c43d72ba3a8e Reviewed-on: https://review.haiku-os.org/c/1340 Reviewed-by: waddlesplash --- .../os/arch/{x86_common => generic}/stack_trace.cpp | 8 ++++++++ src/system/libroot/os/arch/ppc/Jamfile | 2 +- src/system/libroot/os/arch/sparc/Jamfile | 1 + src/system/libroot/os/arch/x86/Jamfile | 3 --- src/system/libroot/os/arch/x86_64/Jamfile | 5 +---- 5 files changed, 11 insertions(+), 8 deletions(-) rename src/system/libroot/os/arch/{x86_common => generic}/stack_trace.cpp (90%) diff --git a/src/system/libroot/os/arch/x86_common/stack_trace.cpp b/src/system/libroot/os/arch/generic/stack_trace.cpp similarity index 90% rename from src/system/libroot/os/arch/x86_common/stack_trace.cpp rename to src/system/libroot/os/arch/generic/stack_trace.cpp index 48b82ae0df..41ac99693c 100644 --- a/src/system/libroot/os/arch/x86_common/stack_trace.cpp +++ b/src/system/libroot/os/arch/generic/stack_trace.cpp @@ -6,8 +6,10 @@ * Michael Lotz, mmlr@mlotz.ch */ +#include #include +#ifdef STACK_GROWS_DOWNWARDS /*! Captures a stack trace (the return addresses) of the current thread. \param returnAddresses The array the return address shall be written to. @@ -45,3 +47,9 @@ __arch_get_stack_trace(addr_t* returnAddresses, int32 maxCount, return count; } + +#else + +#error Implementation needed for upwards growing stacks + +#endif diff --git a/src/system/libroot/os/arch/ppc/Jamfile b/src/system/libroot/os/arch/ppc/Jamfile index cdbf5725e0..88711765a2 100644 --- a/src/system/libroot/os/arch/ppc/Jamfile +++ b/src/system/libroot/os/arch/ppc/Jamfile @@ -17,7 +17,6 @@ for architectureObject in [ MultiArchSubDirSetup ppc ] { byteorder.S compatibility.c # only here until the places where those functions # are used are fixed - stack_trace.cpp stack_frame.c # systeminfo.c system_time.c @@ -27,6 +26,7 @@ for architectureObject in [ MultiArchSubDirSetup ppc ] { tls.c generic_system_time_nsecs.cpp + stack_trace.cpp ; } } diff --git a/src/system/libroot/os/arch/sparc/Jamfile b/src/system/libroot/os/arch/sparc/Jamfile index 43d9ed6aff..65fadaea06 100644 --- a/src/system/libroot/os/arch/sparc/Jamfile +++ b/src/system/libroot/os/arch/sparc/Jamfile @@ -27,6 +27,7 @@ for architectureObject in [ MultiArchSubDirSetup sparc ] { generic_atomic.cpp generic_system_time_nsecs.cpp + stack_trace.cpp ; } } diff --git a/src/system/libroot/os/arch/x86/Jamfile b/src/system/libroot/os/arch/x86/Jamfile index 98821562b8..8fda6b8ff5 100644 --- a/src/system/libroot/os/arch/x86/Jamfile +++ b/src/system/libroot/os/arch/x86/Jamfile @@ -17,8 +17,6 @@ for architectureObject in [ MultiArchSubDirSetup x86 x86_gcc2 ] { ; } - SEARCH_SOURCE += [ FDirName $(SUBDIR) $(DOTDOT) x86_common ] ; - MergeObject <$(architecture)>os_arch_$(TARGET_ARCH).o : atomic.S byteorder.S @@ -31,7 +29,6 @@ for architectureObject in [ MultiArchSubDirSetup x86 x86_gcc2 ] { $(compatibilitySources) - # sources from x86_common stack_trace.cpp ; } diff --git a/src/system/libroot/os/arch/x86_64/Jamfile b/src/system/libroot/os/arch/x86_64/Jamfile index 86e96d19f4..e4670b3638 100644 --- a/src/system/libroot/os/arch/x86_64/Jamfile +++ b/src/system/libroot/os/arch/x86_64/Jamfile @@ -12,7 +12,6 @@ for architectureObject in [ MultiArchSubDirSetup x86_64 ] { SEARCH_SOURCE += [ FDirName $(SUBDIR) $(DOTDOT) generic ] - [ FDirName $(SUBDIR) $(DOTDOT) x86_common ] ; MergeObject <$(architecture)>os_arch_$(TARGET_ARCH).o : @@ -24,11 +23,9 @@ for architectureObject in [ MultiArchSubDirSetup x86_64 ] { time.cpp tls.cpp - # sources from x86_common - stack_trace.cpp - # sources from generic generic_atomic.cpp + stack_trace.cpp ; } }