Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!seismo!mimsy!chris From: chris@mimsy.UUCP (Chris Torek) Newsgroups: comp.lang.c,comp.unix.wizards Subject: Re: who called a C routine - get it from the stack frame Message-ID: <4660@mimsy.UUCP> Date: Fri, 5-Dec-86 15:25:54 EST Article-I.D.: mimsy.4660 Posted: Fri Dec 5 15:25:54 1986 Date-Received: Fri, 5-Dec-86 22:31:37 EST References: <810@hropus.UUCP> <961@cuuxb.UUCP> Distribution: comp Organization: U of Maryland, Dept. of Computer Science, Coll. Pk., MD 20742 Lines: 38 Xref: mnetor comp.lang.c:263 comp.unix.wizards:258 In article <961@cuuxb.UUCP> wbp@cuuxb.UUCP (Walt Pesch) writes: >Oh, well, you asked! Time to get down into the mud... For System V, >the following dirty trick should work: Getting down in the mud is right; this kind of thing is hardly portable. But `for System V' is not true: The operation is *machine* specific, not *operating system* specific (though there are machines on which the operating system might affect the method). Here is some 4.2/4.3BSD Vax Unix code to do the trick. #include #include #include main() { f(); g(); exit(0); } f() { g(); } g() { register struct frame *fr; /* r11 */ asm(" movl fp,r11"); /* set fr=frame */ printf("g: will return to address %x\n", fr->fr_savpc); } -- In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 7690) UUCP: seismo!mimsy!chris ARPA/CSNet: chris@mimsy.umd.edu