[freenet-tech] Technology / Features
Jeff Sturm
jsturm@one-point.com
Wed Feb 27 15:42:00 GMT 2002
On 27 Feb 2002, Adam Megacz wrote:
> Andrew Haley <aph@cambridge.redhat.com> writes:
> > Well, I mean it shoudn't be hard to print a list of addresses:
>
> Where will you get that list of addresses from? =)
Why, from the stack frames, of course.
Here's a tiny example for x86:
#include <stdio.h>
void backtrace(void) {
register void *_ebp __asm__("%ebp");
unsigned int *rfp;
for (rfp = _ebp; rfp; rfp = *(unsigned int **)rfp)
printf("%p\n", rfp[1]-5);
}
void g(void) {
backtrace();
}
void f(void) {
g();
}
int main(void) {
f();
return 0;
}
More information about the Java
mailing list