Operating System - HP-UX
1827788 Members
2606 Online
109969 Solutions
New Discussion

Re: Finding the function that contains the return address.

 

Finding the function that contains the return address.

Hi,
We are working on an Exception tracking and stack unwinding application where we store the return address of all the frames in the stack. From the return address we need to find the function block . We have the code in HPPARISC which does this and we are trying to port it to HPItanium. We check whether the return address is in the range of Dll map base data's start address and end address and convert the address to an offset relative to Image start address then add 0x1000 to account for subspace offset. We have similar code in Linux and Aix also but here it doesn't add 0x1000 for the subspace offset. So for HPItanium should we add this offset ? Please have a look at the HPPARISC code snippet

/*--------------------------------------------------------------------*
* Is Address in the Image of the DllMap? *
*--------------------------------------------------------------------*/
if ( lRetn >= pTre->SAddr && lRetn <= pTre->EAddr)
{
/*--------------------------------------------------------------------*
* Convert the Address to an Offset relative to Image Start Address *
* Note: We must add 0x1000 to the result to account for sub-space *
* offset. *
*--------------------------------------------------------------------*/
prTre = pTre; /* Set as DllMap to return */
lOffs = PTROPR(PST_DODWORD,lRetn,-,pTre->SAddr);
lOffs += 4096; /* Account for subspace offset */
pEfr->Offs = lOffs; /* Set Offset in Stak Ele */


Thanks
1 REPLY 1
Dennis Handly
Acclaimed Contributor

Re: Finding the function that contains the return address.

>From the return address we need to find the function block.

The function name? Or are you trying to write a debugger?
There is no reason for this PA code. unwind(5) provides functions that do this.

(You don't have this subspace offset.)