- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- stack pointer values using uxw - show strange beh...
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-25-2010 05:33 AM
02-25-2010 05:33 AM
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
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-25-2010 09:18 AM
02-25-2010 09:18 AM
Re: stack pointer values using uxw - show strange behaviour
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-25-2010 06:27 PM
02-25-2010 06:27 PM
Re: stack pointer values using uxw - show strange behaviour
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 >
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-25-2010 09:19 PM
02-25-2010 09:19 PM
Re: stack pointer values using uxw - show strange behaviour
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-25-2010 09:24 PM
02-25-2010 09:24 PM
Re: stack pointer values using uxw - show strange behaviour
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-25-2010 09:31 PM
02-25-2010 09:31 PM
Re: stack pointer values using uxw - show strange behaviour
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-25-2010 10:42 PM
02-25-2010 10:42 PM
Re: stack pointer values using uxw - show strange behaviour
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-25-2010 10:53 PM
02-25-2010 10:53 PM
Re: stack pointer values using uxw - show strange behaviour
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-25-2010 11:11 PM
02-25-2010 11:11 PM
Re: stack pointer values using uxw - show strange behaviour
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-26-2010 05:35 AM
02-26-2010 05:35 AM
Re: stack pointer values using uxw - show strange behaviour
Is there direct way to know if the frame resides on teh register stack or memory stack ?
Thanks,
Adarsh.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-26-2010 12:40 PM
02-26-2010 12:40 PM
SolutionYou are asking the wrong question.
Every function (context) has both a memory stack and a register stack. With the memory stack possibly being of size 0.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-27-2010 04:18 AM
02-27-2010 04:18 AM
Re: stack pointer values using uxw - show strange behaviour
In Linux and Solaris I just had a memory stack to worry about and I could just has to use the SP and framesize value.
I am sure there is a way since the gdb on Itanoium does display the backtrace , along with the stackpointer values for each frame in the stack . I just need to do the same.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-27-2010 11:32 AM
02-27-2010 11:32 AM
Re: stack pointer values using uxw - show strange behaviour
difference in stack pointer is seen when the memory stack size is non zero. or else you can see only BSP changing.
looks like gdb uses other mechanisms to get the frame size. it is not a simple arithmetic based on register values between contexts.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-27-2010 05:54 PM
02-27-2010 05:54 PM
Re: stack pointer values using uxw - show strange behaviour
Your program already knows how to find the SP value. In your other thread I told you how to compute the framesize:
http://forums.itrc.hp.com/service/forums/questionanswer.do?threadId=1407123
>along with the SP values for each frame in the stack.
Yes, "info frame" will do that for the current frame.
>Suprateeka: cannot show the difference in stack pointer.
Sure you can. The difference is 0.
>add alloca(3C) to each of your calls or have more than 8 parameters being passed to the function calls, etc.
Why work that hard? If you want a non-zero sized frame, have some local variables, that you use:
char buf[1024 * 1024];
>looks like gdb uses other mechanisms to get the frame size. it is not a simple arithmetic based on register values between contexts.
Sure it is that simple. The "other" method is only needed if you want to distinguish between the fixed size frame and an any alloca(3) parts.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-27-2010 09:19 PM
02-27-2010 09:19 PM
Re: stack pointer values using uxw - show strange behaviour
I have attached teh sample program that prints out framesize usng both SP and BSP for memory stack and register stack coresspondingly.
I have observed the following:-
1> Using SP the framesize is mostly 0, even if I use some local variables.
2> Using BSP I seem to get some correct values of framesize.
Can I always use BSP to get the framesize for any function in my code. In case not , please explain why ?
I am unclear about the fact that under what circumstances does a function use
1. only register stack
2. only memory stack ( I am not sure whether this is possible in Itanium).
3. Both register and memory stack.
P.S - My program need is to use 32 bit binaries only.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-27-2010 10:20 PM
02-27-2010 10:20 PM
Re: stack pointer values using uxw - show strange behaviour
you are just declaring the buffers. you have to use it in your code or the compiler may optimize it away.
> I am unclear about the fact that under what circumstances does a function use
1. only register stack
2. only memory stack ( I am not sure whether this is possible in Itanium).
3. Both register and memory stack.
as far as i know, its always both register and memory stack. and for trivial functions, the memory stack is of zero size.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-27-2010 10:25 PM
02-27-2010 10:25 PM
Re: stack pointer values using uxw - show strange behaviour
no. it is because a function may also have memory stack size which is not reflected by bsp values. you have to consider both sp and bsp.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-27-2010 11:12 PM
02-27-2010 11:12 PM
Re: stack pointer values using uxw - show strange behaviour
>framesize=psp-sp;
This should be reversed.
>%d for function %s \n",
You should not print a space before the newline.
>if I use some local variables.
As I cautioned you, you have to really use them, not just define them.
>2> Using BSP I seem to get some correct values of framesize.
You wouldn't know if this was correct until you looked at the machine code.
>Can I always use BSP to get the framesize for any function in my code.
Of course not. There are two stack "frames" and you must have two sizes.
>I am unclear about the fact that under what circumstances does a function use
>1. only register stack
>2. only memory stack
>3. Both register and memory stack.
You should assume it always uses both. As I said, they can have zero size.
>Suprateeka: you have to consider both sp and bsp.
Right. There is no need to special case a zero size. Zero is a valid size.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-01-2010 08:39 PM
03-01-2010 08:39 PM