Operating System - HP-UX
1833461 Members
3078 Online
110052 Solutions
New Discussion

Calculate HP Itanium Stack frame size

 
SOLVED
Go to solution
Adarsh Thampan
Advisor

Calculate HP Itanium Stack frame size

Folks ,

We need to calculate the frame size of a given stack frame in HP Itanium.

We have an API in HP PARISC
"int U_get_previous_frame_x(cframe_info *curr_frame,pframe_info prev_frame,int size);"

From the above API using the pframe_info structure and cframe_info structure ,we can get the frame size by using the "curr_frame_size" and "prev_frame_size" member values.

We need to calculate similarly the frame size for current and previous stack frames in HP Itanium.

We are using the "uwx" API's in HP Itanium for stack traversing/stepping, but we are unable to find any API on how to calculate the frame size for current and previous frames.

Thanks,
Adarsh.
11 REPLIES 11
Dennis Handly
Acclaimed Contributor

Re: Calculate HP Integrity Stack frame size

>We have an API in HP PA-RISC

(Do not even think about those or model on those for Integrity.)

>We need to calculate similarly the frame size for current and previous stack frames in HP Integrity?

Why? The unwind(5) routines have been completely rewritten so you don't need to compute silly stuff like that. It just works.

If you want to compute the framesize, you can just subtract the r12, SP register values.

Adarsh Thampan
Advisor

Re: Calculate HP Itanium Stack frame size

Teh code is legacy and it to be supported on Itanium . Hence we would need this information.

Can you explain in details "subtract the r12, SP register values " .Also mention how do I get the r12 and SP register values ?
Dennis Handly
Acclaimed Contributor

Re: Calculate HP Integrity Stack frame size

>The code is legacy and it to be supported on Integrity. Hence we would need this information.

If you are unwinding the stack, you must throw this code away and port to the uwx APIs, unwind(5).

>Can you explain in details "subtract the r12, SP register values". Also mention how do I get the r12 and SP register values?

You need to explain why you need the framesize. If you think you need it to unwind, you don't. If you think you need to format your output the same as before, you may want to rethink that.

To get registers: _UNW_getGR(3X)

Subtract the r12 (the real name for SP), register values from the adjoining frames.

Adarsh Thampan
Advisor

Re: Calculate HP Itanium Stack frame size

We are porting a leagacy C code which does its own excpetion tracing , hence the design of the modules are such that it requires the regsiter values and framesize.

I agree that we could use unwind and uwx functions completely and eradicate the whole old stuff but in doing that I will have to rewrite a lot of code and maybe re-design as well .

Can you gimme some artefact that neatly explains the Itanium registers and their contents and also the the frame structure( if any) that holds all these values ?

Dennis Handly
Acclaimed Contributor

Re: Calculate HP Itanium Stack frame size

>We are porting a legacy C code which does its own exception tracing

You can just call U_STACK_TRACE or its variants.

>hence the design of the modules are such that it requires the register values and framesize.

None of these values are useful in calling unwind(5). Unless you just like to print out hex numbers. :-)
There are 128 GRs and FRs. There are 64 PRs. And 8 BRs. And 128 ARs. And 82 CRs.

>I agree that we could use unwind and uwx functions completely

You have no choice but to use uwx. (But perhaps not completely?)

>Can you gimme some artifact that neatly explains the Itanium registers and their contents and also the the frame structure (if any) that holds all these values?

You need to look for Itanium runtime conventions. Note there are two stacks, the user stack and the RSE stack. Start here:
http://h21007.www2.hp.com/portal/site/dspp/menuitem.863c3e4cbcdc3f3515b49c108973a801?ciid=821ffd06ab1b7110VgnVCM100000275d6e10RCRD
Dennis Handly
Acclaimed Contributor

Re: Calculate HP Integrity Stack frame size

It might be helpful to attach an example stack trace output format.

Adarsh Thampan
Advisor

Re: Calculate HP Itanium Stack frame size

HI ,

I have attached the list of registers that are being displayed as a part of the exception trace for HP PARISC application.

Now we need to display similar set of register values , since we are porting this on HP Itanium .

Please help us in identifying the set of registers ,
Dennis Handly
Acclaimed Contributor

Re: Calculate HP Integrity Stack frame size

>I have attached the list of registers that are being displayed as a part of the exception trace for PA-RISC application.

I don't think any of these registers are in Integrity. Also, while these are defined in , this file doesn't exist on Integrity.
ucontext_t contains mcontext_t, which is an opaque struct.

You must use the functions in uc_access(3) to get register values.

>we need to display similar set of register values

About the best you can do is dump all that uc_access(3) provides.
If you use gdb's "info all-reg", you can see a list of all registers.

Adarsh Thampan
Advisor

Re: Calculate HP Itanium Stack frame size

Yes , You are correct .

The registers that I had attached are PARISC registers whose contents were displayed as a prt of the exception tracing.

Now we are porting thsi application to HPItanium , hence we need to know the corressponding registers in Itanium that case be used for exception tracing.

Dennis Handly
Acclaimed Contributor

Re: Calculate HP Integrity Stack frame size

>hence we need to know the corresponding registers

Do you still have a question here that's not explained by uc_access(3)?

>be used for exception tracing.

Note: On HP-UX, these are called signals, not to be confused with C++ exceptions.

Dennis Handly
Acclaimed Contributor
Solution

Re: Calculate HP Integrity Stack frame size

From a recent thread:
http://h30499.www3.hp.com/t5/Languages-and-Scripting/Return-address-of-a-function-in-a-frame/m-p/4591378


You can get the UWX_REG_PSP pseudo register and then subtract to get the framesize.