- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Getting call stack within C/C++ program
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
Discussions
Discussions
Forums
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
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
тАО11-23-2010 10:17 PM
тАО11-23-2010 10:17 PM
Is there any system call that enables to get call stack within C/C++ program?
(Sometimes) I would like to use it instead of assert().
assert(condition);
If assert() fails we have got coredump and can get call stack using gdb.
I need something like
if (!condition)
{
get-call-stack();
}
Thanks
Solved! Go to Solution.
- Tags:
- c++filt
- U_STACK_TRACE
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-24-2010 03:20 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-24-2010 03:43 AM
тАО11-24-2010 03:43 AM
Re: Getting call stack within C/C++ program
Two questions are below
// --- a.cpp ----
#include
void foo1 (int i)
{
U_STACK_TRACE();
}
void foo2 (int i1, int i2)
{
foo1 (i1 + i2);
}
int main()
{
foo2 (100, 200);
return 0;
}
// ----------
> aCC +DD64 -AA -g a.cpp
> a.out
(0) 0x4000000000000e50 _Z4foo1i + 0x40 at a.cpp:6 [./a.out]
(1) 0x4000000000000f20 _Z4foo2ii + 0x30 at a.cpp:11 [./a.out]
(2) 0x4000000000000fe0 main + 0x30 at a.cpp:16 [./a.out]
(3) 0xc000000000042450 main_opd_entry + 0x50 [/usr/lib/hpux64/dld.so]
====================
Question-1. Is it possible to print demangled names?
Ouestion-2. Is it possiblr to print also values of function arguments?
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-24-2010 04:01 AM
тАО11-24-2010 04:01 AM
Re: Getting call stack within C/C++ program
> ./a.out | & c++filt
(0) 0x4000000000000e50 foo1(int) + 0x40 at a.cpp:6 [./a.out]
(1) 0x4000000000000f20 foo2(int,int) + 0x30 at a.cpp:11 [./a.out]
(2) 0x4000000000000fe0 main + 0x30 at a.cpp:16 [./a.out]
(3) 0xc000000000042450 main_opd_entry + 0x50 [/usr/lib/hpux64/dld.so]
So, only second question: values of function arguments?
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-24-2010 05:22 AM
тАО11-24-2010 05:22 AM
Re: Getting call stack within C/C++ program
You would have to create your own. See uwx(3X) and unwind(5).
But depending on the opt level, all you can print out are the 8 parm registers and they may have been changed when you are getting a stack trace.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-24-2010 06:01 AM
тАО11-24-2010 06:01 AM