Operating System - HP-UX
1753747 Members
5023 Online
108799 Solutions
New Discussion юеВ

stack pointer values using uxw - show strange behaviour

 
SOLVED
Go to solution
Adarsh Thampan
Advisor

stack pointer values using uxw - show strange behaviour

Hi ,

I am trying to print the stack pointer values in each frame of my stack. I am using the attached code , basically i step through the frame one by one and print the SP and IP . Although the IP is printed correctly , I get the same SP value for all frames.

I have attached the source and the output.

Thanks,
Adarsh
18 REPLIES 18
Dennis Handly
Acclaimed Contributor

Re: stack pointer values using uxw - show strange behaviour

>I get the same SP value for all frames.

There probably isn't anything wrong with that. You need to print out tuples:
PC, SP and BSP

In your case BSP (the RSE stack pointer) should change.
Adarsh Thampan
Advisor

Re: stack pointer values using uxw - show strange behaviour

In HPPARISC , we get the current frame SP and previous SP using U_get_previous_frame API .

In Itanium also we need the current frame SP and previous frame SP.

You are syaing that the SP value is same fro all frames in Itanium .

Can you explain why this difference >
Dennis Handly
Acclaimed Contributor

Re: stack pointer values using uxw - show strange behaviour

>In Itanium also we need the current frame SP and previous frame SP.

On Integrity you have contexts not frames.
Conceptually you have the tuple PC, SP and BSP as an unique identifier for each context. And you use uwx_step(3X) to find the previous context.

>You are saying that the SP value is same for all frames in Integrity.

No, I'm saying your trivial test case doesn't need user stack frames for some of the functions. It only needs RSE stack frames for those different contexts. That's why you need both SP and BSP.

Re: stack pointer values using uxw - show strange behaviour

unwind library on IPF is different. you have to use uwx_step(3X) to get to the previous frame. are you using this?

Re: stack pointer values using uxw - show strange behaviour

sorry, missed to look at your code snippet.
Adarsh Thampan
Advisor

Re: stack pointer values using uxw - show strange behaviour

Dennis,

My code does an exception tracing , and as a part of the tracing I need to print the SP and framesize of all the frames within the current stack( one that caused the exception).

Now for AIX,Linux we just print the SP and calculate the frame size ( current SP - previous SP) .

I tried to do the same in HP Itanium , but since the SP values are all the same it seems my logic is wrong, BTW I have note read about the Itanium architecture.

Now it looks you are suggesting to use a combination of the RSE as well ( I assume it is the register stack) and the memory stack.

So how do I know when to use RSE with BSP and when to use memory stack with SP.

Thanks,
Adarsh.

Re: stack pointer values using uxw - show strange behaviour

the logic of current SP - previous SP to calculate the frame size may not hold good always. for example there may be non-contiguous pieces.

you have to read the itanium runtime architecture guide which provides a wealth of information. get it here: http://www.intel.com/design/itanium/downloads/245358.htm

it clearly tells when the memory stack is used and when RSE is used, etc.
Dennis Handly
Acclaimed Contributor

Re: stack pointer values using uxw - show strange behaviour

>My code does an exception tracing

You mean stack tracing on a signal or some some software condition?

You do know about U_STACK_TRACE(3) and _UNW_STACK_TRACE(3)?

>as a part of the tracing I need to print the SP and framesize of all the frames within the current stack (one that caused the exception).

You must print the SP and BSP of all contexts.

>but since the SP values are all the same it seems my logic is wrong

There is nothing wrong with the logic. The user framesize IS 0. You could print the RSE framesize.

>Now it looks you are suggesting to use a combination of the RSE as well

Yes. You should print both.

>how do I know when to use RSE with BSP and when to use memory stack with SP.

You always print SP and BSP and if you want, print the memory stack framesize and the RSE stack framesize.
Adarsh Thampan
Advisor

Re: stack pointer values using uxw - show strange behaviour

Hi ,

Is there direct way to know if the frame resides on teh register stack or memory stack ?

Thanks,
Adarsh.