xtd 0.2.0
Loading...
Searching...
No Matches

◆ get_frames()

const stack_frame_collection & xtd::diagnostics::stack_trace::get_frames ( ) const
noexcept

Returns a copy of all stack frames in the current stack trace.

Returns
An array of type xtd::diagnostics::stack_frame representing the function calls in the stack trace.
Examples
The following code example demonstrates enumerating the frames in a xtd::diagnostics::stack_trace.
stack_trace st(1, true);
stack_trace::stack_frame_collection st_frames = st.get_frames();
for(const stack_frame& sf : st_frames) {
console::write_line("Method: {}", sf.get_method());
}
static void write_line()
Writes the current line terminator to the standard output stream using the specified format informati...
Provides information about a xtd::diagnostics::stack_frame, which represents a function call on the c...
Definition stack_frame.h:46
xtd::array< xtd::diagnostics::stack_frame > stack_frame_collection
Represents a stack_frame collection.
Definition stack_trace.h:46
Represents a stack trace, which is an ordered collection of one or more stack frames.
Definition stack_trace.h:40
Remarks
Use the returned xtd::diagnostics::stack_frame array to enumerate and examine function calls in the xtd::diagnostics::stack_trace. The size of the returned array is equal to the frame_count() property value.
The xtd::diagnostics::stack_frame array elements are in reverse chronological order. The xtd::diagnostics::stack_frame at array index 0 represents the most recent function call in the stack trace and the last frame pushed onto the call stack. The xtd::diagnostics::stack_frame at array index frame_count() minus 1 represents the oldest function call in the stack trace and the first frame pushed onto the call stack.
Use the get_frames() method to obtain all stack frames in a stack trace; use the get_frame(size_t) method to obtain a specific stack frame in a stack trace. The xtd::diagnostics::stack_frame indexes are ordered alike by the two methods. For example, the xtd::diagnostics::stack_frame at index 0 in the array returned by get_frames() is equivalent to the xtd::diagnostics::stack_frame returned by get_frame(size_t) with an input index of 0.