how to know the instruction address of calling function within called function?

how to know the instruction address of calling function within called function?

Post by Jianlin Cha » Tue, 12 Dec 1995 04:00:00



Suppose function A call B, are there any ways to know the address of last instruction in A just
before calling B from within B? I would like to do some profiling by substituting B by a routine with record
the time spent on B. I also would like to know the time spent on B in different locations of A
where B is called. If I can know the address of last instruction in A just before calling B, from
debuging info of the excutables, I can find its source code address, therefore know the
time spent on B in differnet locations of A.

I don't want to make any changes to A. "-pg" compiler option for profiling is of no use either,
because there is no source code for B, and there is no object code for B with profiling codes in,
so you can't know the total time spent on B, but only the self time spent on B.

Thanks very much.
--



Kingston, Ontario K7L 3N6        Tel: (613) 545-2723 (o)
Canada                           Fax: (613) 545-6463
Home address:
58 1/2 Chatham St.               Tel: (613) 547-1353 (h)
Kingston, ON K7K 4G8

 
 
 

how to know the instruction address of calling function within called function?

Post by Pierre Lagie » Thu, 14 Dec 1995 04:00:00


You can extract the information from the stack. What you need is to know which
register handles the stack addr and how the frames are managed inside the
stack.

Cheers,
Pierre.

 
 
 

how to know the instruction address of calling function within called function?

Post by Jianlin Cha » Sat, 16 Dec 1995 04:00:00


Could you please give me details? Thanks very much.

p.s. Your e-mail address is not valid.


> You can extract the information from the stack. What you need is to know which
> register handles the stack addr and how the frames are managed inside the
> stack.

> Cheers,
> Pierre.

--



Kingston, Ontario K7L 3N6        Tel: (613) 545-2723 (o)
Canada                           Fax: (613) 545-6463
Home address:
58 1/2 Chatham St.               Tel: (613) 547-1353 (h)
Kingston, ON K7K 4G8