search for: __builtin_frame_address

Displaying 12 results from an estimated 12 matches for "__builtin_frame_address".

2015 Jan 04
3
[LLVMdev] Writing my own debugger... use __builtin_frame_address or is there something better?
...and DB_GetStackPointer. The idea is that DB_GetStackPointer will save the current stack pointer... and DB_Line will go to a func that lets me read the current variables off that stack pointer, and then send them via a socket/TCP-connection... to my debugger. However... I've fooled around with __builtin_frame_address and... I can't figure out how to properly use it. int* FA1 = (int*)__builtin_frame_address(1); int P0_ = FA1[0]; int P1_ = FA1[1]; int P2_ = FA1[2]; int P3_ = FA1[3]; Something like this... but NONE of these int variables contain the actual pointers stored in the calling...
2015 Jan 04
4
[LLVMdev] Writing my own debugger... use __builtin_frame_address or is there something better?
> > On 4 Jan 2015, at 16:44, Joerg Sonnenberger <joerg at britannica.bec.de> wrote: > > On Sun, Jan 04, 2015 at 03:02:30PM +0000, John Smith wrote: >> "all I need is the ability to get the current variables off the current >> function... > > Finding the functions on the stack is easy. Finding which auto variables > are where is *much* harder. That
2019 Jun 25
3
Optimised stack direction?
...; an __attribute__((noinline)) function to compare locals from two > different, nested frames (even that's iffy though on a semantic > level). If there turned out to be a compelling enough use-case, an > intrinsic could be added to get the result more efficiently. Actually, (uintptr_t)__builtin_frame_address(0) < (uintptr_t)__builtin_frame_address(1) would probably work too. Cheers. Tim.
2013 Oct 20
2
[LLVMdev] A new builtin: __builtin_stack_pointer()
...to work! Though I'm still testing it in all our situations for LLVMLinux. It looks like I can get this to work with LLVM 3.3 and the LLVMLinux kernel patches. Thanks! However, I'd still like to see __builtin_stack_pointer() added since it is simple, obvious, and mirrors other builtins like __builtin_frame_address(). Behan -- Behan Webster behanw at converseincode.com
2019 Jun 25
2
Optimised stack direction?
Why does LLVM struggle to optimize the following stack direction check? #include <stdint.h> inline int stack_direction() { int x = 0; int y = 0; return uintptr_t(&x) < uintptr_t(&y); } int main(int argc, const char * argv[]) { return stack_direction(); } It generates the following assembly: main: # @main lea rcx, [rsp - 8] lea rdx, [rsp - 4] xor eax, eax
2013 Nov 05
0
[LLVMdev] A new builtin: __builtin_stack_pointer()
...testing it in all our situations > for LLVMLinux. It looks like I can get this to work with LLVM 3.3 and > the LLVMLinux kernel patches. Thanks! > > However, I'd still like to see __builtin_stack_pointer() added since it > is simple, obvious, and mirrors other builtins like > __builtin_frame_address(). Ping on this? It seems like a legitimate builtin to have in clang, if only for compatibility and the nicer IR representation. Alp. > > Behan > -- http://www.nuanti.com the browser experts
2013 Oct 10
3
[LLVMdev] A new builtin: __builtin_stack_pointer()
.../clang/Basic/Builtins.def +++ b/include/clang/Basic/Builtins.def @@ -437,6 +437,7 @@ BUILTIN(__builtin_strstr, "c*cC*cC*", "nF") BUILTIN(__builtin_return_address, "v*IUi", "n") BUILTIN(__builtin_extract_return_addr, "v*v*", "n") BUILTIN(__builtin_frame_address, "v*IUi", "n") +BUILTIN(__builtin_stack_pointer, "v*", "n") BUILTIN(__builtin_flt_rounds, "i", "nc") BUILTIN(__builtin_setjmp, "iv**", "j") BUILTIN(__builtin_longjmp, "vv**i", "r") diff --git a/li...
2004 Oct 18
3
[LLVMdev] Fix for non-standard variable length array + Visual C X86 specific code
Paolo Invernizzi wrote: > There was a similar problem some time ago, and was resolved with alloca. > I think it's a better solution to use the stack instead of the heap... I tend to agree, but the constructors won't get called if it's an object array -- anyway, this particular case there was no objects, just pointers and bools so alloca should be fine. I'll leave it to
2015 Aug 05
2
[LLVMdev] Cc llvmdev: Re: llvm bpf debug info. Re: [RFC PATCH v4 3/3] bpf: Introduce function for outputing data to perf event
...t;> >> >> Kernel side verifier allows us to do arithmetic computation using two >> local variable >> address or local variable address and R11. Therefore, we can compute >> the location >> of a local variable using: >> >> mark = &my_var_a - __builtin_frame_address(0); >> >> If the stack allocation is fixed (if the location is never reused), >> the above 'mark' >> can be uniquely identify a local variable. That's why I'm interesting >> in it. However >> I'm not sure whether the prerequestion is hold. &...
2013 Nov 05
1
[LLVMdev] A new builtin: __builtin_stack_pointer()
...ituations >> for LLVMLinux. It looks like I can get this to work with LLVM 3.3 and >> the LLVMLinux kernel patches. Thanks! >> >> However, I'd still like to see __builtin_stack_pointer() added since it >> is simple, obvious, and mirrors other builtins like >> __builtin_frame_address(). > Ping on this? Sorry. Been away from my desk for 2 weeks (Linux Con, Embedded Linux Con, and a week teaching). Just catching up this week. The suggested work around DOES work for many situations, but is ugly. However it allows the LLVMLinux patches to work with clang/LLVM 3.3 right now whic...
2013 Oct 10
0
[LLVMdev] A new builtin: __builtin_stack_pointer()
On Oct 10, 2013, at 12:32 PM, Behan Webster <behanw at converseincode.com> wrote: > One of the issues the LLVMLinux project is having is with the use of > named registers in the Linux kernel code. The kernel uses something like > this in order to assign a C variable name to a register (one for each > kernel arch). > > register unsigned long current_stack_pointer
2014 Nov 03
8
[LLVMdev] [PATCH] Protection against stack-based memory corruption errors using SafeStack
...ity ("default"))) +__attribute__((noinline)) +void *__safestack_get_unsafe_stack_ptr() { + return __GET_UNSAFE_STACK_PTR(); +} + +extern "C" +__attribute__((visibility ("default"))) +__attribute__((noinline)) +void *__safestack_get_safe_stack_ptr() { + return (char*) __builtin_frame_address(0) + 2*sizeof(void*); +} + +#ifdef __linux__ +// Run safestack initialization before any other constructors +// FIXME: can we do something similar on Mac or FreeBSD? +extern "C" { +__attribute__((section(".preinit_array"), used)) +void (*__llvm__safestack_preinit)(void) = __llvm...