This is the mail archive of the java@gcc.gnu.org mailing list for the Java project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [freenet-tech] Technology / Features


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;
}


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]