1

I have written a C++ stack application and running it using CYGWIN g++ compiler. The application crashes as exception is not handled perfectly.

It gives me stacktrace dump as a file Stack.exe.stackdump. I am new to this StackTrace thing could some one tell me how to read it and what does it signify?

Just to make clear based on received comments, The stack data structure is just an example to make the application crash and to give stackTrace. I mean this stack trace is generated in any situation when the program crashes and unrelated to my stack data structure application, which I just used as an existing code where program crashes.

My code fragment which generates exception :

class RuntimeException{ private: string errorMsg; public: RuntimeException(const string& err){errorMsg = err;} string getMessage() const {return errorMsg;} }; class StackEmpty : public RuntimeException{ public: StackEmpty(const string& err) : RuntimeException(err){} }; template <typename E > const E& ArrayStack<E> ::top() const throw(StackEmpty) { if(empty()) throw StackEmpty("Top of Empty Stack"); return S[t]; } int main() { ArrayStack <int> A; cout << "######\n"; cout << A.top() << "\n"; cout << "######\n"; } 

The Output :

$ ./Stack ###### Aborted (core dumped) 

It generates a file Stack.exe.stackdump , which reads:

Stack trace: Frame Function Args 0022A774 7608C313 (000000C0, 0000EA60, 00000000, 0022A8A8) 0022A788 7608C2C2 (000000C0, 0000EA60, 000000A4, 0022A884) 0022A8A8 610DC559 (00000000, 00000000, 00000000, 00000000) 0022A998 610D9913 (00000000, 6110073E, 003B0023, 00230000) 0022A9F8 610D9DEE (0022A9D0, 6110073E, 003B0023, 00000006) 0022AAA8 610D9F40 (000008F4, 00000006, 00000000, 00000000) 0022AAC8 610D9F6C (00000006, 00000006, 0022AB38, 00404C6B) 0022AAF8 610DA233 (0022AB28, 611A1E9B, 0022ABAC, 00000001) 0022AB48 00404777 (00000000, 00000000, 0022AC18, 004142CB) 0022AB58 00404166 (20048588, 004460E0, 00410F78, 0040F89F) 0022AC18 004142CB (0022AC50, 00445218, 20010100, 004011B5) 0022AC68 004011EC (00000001, 0022AC90, 20010100, 612756CA) 0022ACF8 6100763A (00000000, 0022CD78, 61006C50, 00000000) End of stack trace 

I want to know what does this file signify and how to read it, googled a lot but could not find satisfactory answer.

Thanks

3
  • This question is bizarre. As NPE says you seem to be confusing two different kinds of stack. What are you actually trying to do? What's your goal? Commented Apr 10, 2013 at 6:14
  • @john I have created an stack implementation, where some exception is generated which is not handled properly and hence the (core dumped) at output, now the system generates the stackTrace to troubleshoot where the error occured. I want to figure out about this stackTrace as how to read it. Hope made my point clear.My stackDataStructure is just an example to make program crash and to generate this stackTrace. I am just asking how to read this stackTrace to figure out where the application crashed. Commented Apr 10, 2013 at 6:19
  • OK Arun Saha has given you an answer Commented Apr 10, 2013 at 6:21

2 Answers 2

2

I would try to decode the core dumped in a debugger.

gdb ./Stack.exe ./Stack.exe.stackdump backtrace 
Sign up to request clarification or add additional context in comments.

Comments

1

This gives your the call stack at the point of the crash. This is unrelated to the stack data structure you appear to be attempting to implement.

For each function on the call stack, the stack dump is showing the stack pointer, the address of the function, and the first four arguments. Instead of trying to work with the stack dump, it might be easier to troubleshoot your program using a debugger.

3 Comments

Also, find the option to generate a map file for your executable (it will be a link-flag). Using that map file, the Function column will be significantly easier to understand. (for gcc it is -Xlinker -Map=output.map, passing the ld option for a map file to the link phase.)
@NPE I am just asking about how to read this stackTrace, I know this stack has nothing to do with my data structure, there are many other situations where the application crashes. I want to know how to read this stackTrace , the stack data structure example was just to make the application crash as exception is not handled perfectly there.
@GauravK: Fair enough. It just wasn't at all clear from your question that you understood the distinction.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.