[llvm-commits] Implement the GET_CALLER_PC macro, stub the GET_CURRENT_FRAME macro (issue 5630065)
timurrrr at google.com
timurrrr at google.com
Mon Feb 6 05:49:02 PST 2012
Reviewers: kcc1,
Message:
Hi Kostya,
Can you please review this small patch?
Regarding the GET_CURRENT_FRAME - see the other e-mail in your inbox; we
can un-stub it later if we decide it's needed.
Thanks,
Timur
http://codereview.appspot.com/5630065/diff/1/lib/asan/asan_internal.h
File lib/asan/asan_internal.h (right):
http://codereview.appspot.com/5630065/diff/1/lib/asan/asan_internal.h#newcode218
lib/asan/asan_internal.h:218:
(uintptr_t)__builtin_extract_return_address(__builtin_return_address(0))
Looks like the __builtin_return_address macro was slightly misused
See http://gcc.gnu.org/onlinedocs/gcc/Return-Address.html
Description:
Implement the GET_CALLER_PC macro, stub the GET_CURRENT_FRAME macro
Please review this at http://codereview.appspot.com/5630065/
Affected files:
M lib/asan/asan_internal.h
Index: lib/asan/asan_internal.h
diff --git a/lib/asan/asan_internal.h b/lib/asan/asan_internal.h
index
713f17c06af3e6a2fba8a50b5a6b6101d20864cf..53656a1f6ffebf6ab93e17254a395b9d81a71a59
100644
--- a/lib/asan/asan_internal.h
+++ b/lib/asan/asan_internal.h
@@ -21,6 +21,8 @@
#include <stdlib.h> // for size_t, uintptr_t, etc.
#if defined(_WIN32)
+# include <intrin.h>
+
// There's no <stdint.h> in Visual Studio 9, so we have to define
[u]int*_t.
typedef unsigned __int8 uint8_t;
typedef unsigned __int16 uint16_t;
@@ -212,12 +214,13 @@ const size_t kPageSizeBits = 12;
const size_t kPageSize = 1UL << kPageSizeBits;
#ifndef _WIN32
-#define GET_CALLER_PC() (uintptr_t)__builtin_return_address(0)
-#define GET_CURRENT_FRAME() (uintptr_t)__builtin_frame_address(0)
+# define GET_CALLER_PC() \
+
(uintptr_t)__builtin_extract_return_address(__builtin_return_address(0))
+# define GET_CURRENT_FRAME() (uintptr_t)__builtin_frame_address(0)
#else
-// TODO(timurrrr): implement.
-#define GET_CALLER_PC() (uintptr_t)0
-#define GET_CURRENT_FRAME() (uintptr_t)0
+# define GET_CALLER_PC() (uintptr_t)_ReturnAddress()
+// TODO(timurrrr): We don't unwind on Windows - do we need this?
+# define GET_CURRENT_FRAME() (uintptr_t)0xDEADBEEF
#endif
#define GET_BP_PC_SP \
More information about the llvm-commits
mailing list