getting %ebp from within a function call

G

Gabe McArthur

I'm constructing a garbage collector. I have a way of scanning the
stack precisely, but I need to be able to trace back through the stack
via %ebp. I kind of don't want to have to alter the compiler and add
the overhead by adding a pushl %ebp before each void *gc_alloc(/*void
*ebp,*/ size_t), so I was wondering if anyone out there had any not-
too-devilishly-voodoo-y solution to getting the current function's
base pointer. Maybe it's in the C standard, but I can't find it.

I can alter the compiler, to be sure, but I wanted to know if there
was some easier/lazier/more cost-efficient way of doing things.
-Gabe
 
U

user923005

I'm constructing a garbage collector. I have a way of scanning the
stack precisely, but I need to be able to trace back through the stack
via %ebp. I kind of don't want to have to alter the compiler and add
the overhead by adding a pushl %ebp before each void *gc_alloc(/*void
*ebp,*/ size_t), so I was wondering if anyone out there had any not-
too-devilishly-voodoo-y solution to getting the current function's
base pointer. Maybe it's in the C standard, but I can't find it.

I can alter the compiler, to be sure, but I wanted to know if there
was some easier/lazier/more cost-efficient way of doing things.
-Gabe

I guess you are using the GCC compiler because of the AT&T Gas syntax
you are using.
Try the gcc compiler newsgroup and ask about inline assembly.
 
S

santosh

Gabe said:
I'm constructing a garbage collector. I have a way of scanning the
stack precisely, but I need to be able to trace back through the stack
via %ebp. I kind of don't want to have to alter the compiler and add
the overhead by adding a pushl %ebp before each void *gc_alloc(/*void
*ebp,*/ size_t), so I was wondering if anyone out there had any not-
too-devilishly-voodoo-y solution to getting the current function's
base pointer. Maybe it's in the C standard, but I can't find it.

No, the C standard has no requirement for a stack, and certainly not
for a base pointer.

You'll probably need to use atleast inline assembler instructions.

A quick post to the gcc mailing-list ought to clear up your problem.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,432
Messages
2,571,680
Members
48,796
Latest member
Greg L.

Latest Threads

Top