/*
 @ 0xCCCCCCCC
*/

#if defined(_MSC_VER)
#pragma once
#endif

#ifndef KBASE_STACK_WALKER_H_
#define KBASE_STACK_WALKER_H_

#include <array>

#include "kbase/basic_macros.h"

#if defined(OS_WIN)
struct _CONTEXT;
using CONTEXT = _CONTEXT;
#endif

namespace kbase {

class StackWalker {
public:
    StackWalker() noexcept;

#if defined(OS_WIN)
    // Dumps a callstack for an exception case.
    explicit StackWalker(CONTEXT* context);
#endif

    ~StackWalker() = default;

    DEFAULT_COPY(StackWalker);

    DEFAULT_MOVE(StackWalker);

    void DumpCallStack(std::ostream& stream);

    std::string CallStackToString();

private:
    static constexpr size_t kMaxStackFrames = 64U;
    std::array<void*, kMaxStackFrames> stack_frames_ { nullptr };
    size_t valid_frame_count_ = 0;
};

}   // namespace kbase

#endif  // KBASE_STACK_WALKER_H_

/*
 @ 0xCCCCCCCC
*/

#if defined(_MSC_VER)
#pragma once
#endif

#ifndef KBASE_STACK_WALKER_H_
#define KBASE_STACK_WALKER_H_

#include <array>

#include "kbase/basic_macros.h"

#if defined(OS_WIN)
struct _CONTEXT;
using CONTEXT = _CONTEXT;
#endif

namespace kbase {

class StackWalker {
public:
    StackWalker() noexcept;

#if defined(OS_WIN)
    // Dumps a callstack for an exception case.
    explicit StackWalker(CONTEXT* context);
#endif

    ~StackWalker() = default;

    DEFAULT_COPY(StackWalker);

    DEFAULT_MOVE(StackWalker);

    void DumpCallStack(std::ostream& stream);

    std::string CallStackToString();

private:
    static constexpr size_t kMaxStackFrames = 64U;
    std::array<void*, kMaxStackFrames> stack_frames_ {{nullptr}};
    size_t valid_frame_count_ = 0;
};

}   // namespace kbase

#endif  // KBASE_STACK_WALKER_H_

Fix missing braces warning for initialization of subobjects
Fix missing braces warning for initialization of subobjects

This warning should be a compiler bug, however, we still decide to follow
the suggestion.

Interestingly, this braces enforcement on GCC 5.4 will show up as an error
but have gone away on newer versions.
