]> granicus.if.org Git - esp-idf/commitdiff
heap: __builtin_return_address argument has to be a literal value
authorIvan Grokhotkov <ivan@espressif.com>
Thu, 6 Dec 2018 07:12:17 +0000 (15:12 +0800)
committerIvan Grokhotkov <ivan@espressif.com>
Thu, 6 Dec 2018 08:14:14 +0000 (16:14 +0800)
Clang does not accept const int as an argument of __builtin_return_address.

Ref LLVM-14

components/heap/heap_trace.c

index bb1cc6eda84aed2ff81e38c560eacdd4f3d58add..3c9154ef726be103137e45cfb4e300a738852e91 100644 (file)
@@ -271,11 +271,14 @@ inline static uint32_t get_ccount(void)
     return ccount;
 }
 
+// Caller is 2 stack frames deeper than we care about
+#define STACK_OFFSET  2
+
 #define TEST_STACK(N) do {                                              \
         if (STACK_DEPTH == N) {                                         \
             return;                                                     \
         }                                                               \
-        callers[N] = __builtin_return_address(N+offset);                \
+        callers[N] = __builtin_return_address(N+STACK_OFFSET);                \
         if (!esp_ptr_executable(callers[N])) {                          \
             return;                                                     \
         }                                                               \
@@ -288,7 +291,6 @@ inline static uint32_t get_ccount(void)
 */
 static IRAM_ATTR __attribute__((noinline)) void get_call_stack(void **callers)
 {
-    const int offset = 2; // Caller is 2 stack frames deeper than we care about
     bzero(callers, sizeof(void *) * STACK_DEPTH);
     TEST_STACK(0);
     TEST_STACK(1);