2 // Copyright Oliver Kowalke 2014.
3 // Distributed under the Boost Software License, Version 1.0.
4 // (See accompanying file LICENSE_1_0.txt or copy at
5 // http://www.boost.org/LICENSE_1_0.txt)
12 #include <libunwind.h>
14 #include <boost/context/execution_context.hpp>
16 namespace ctx = boost::context;
20 unw_context_t context;
21 unw_getcontext( & context);
22 unw_init_local( & cursor, & context);
23 while ( 0 < unw_step( & cursor) ) {
24 unw_word_t offset, pc;
25 unw_get_reg( & cursor, UNW_REG_IP, & pc);
29 std::cout << "0x" << pc << ":";
32 if ( 0 == unw_get_proc_name( & cursor, sym, sizeof( sym), & offset) ) {
33 std::cout << " (" << sym << "+0x" << offset << ")" << std::endl;
35 std::cout << " -- error: unable to obtain symbol name for this frame" << std::endl;
48 ctx::execution_context< void > f1( ctx::execution_context< void > && ctxm) {
50 return std::move( ctxm);
54 ctx::execution_context< void > ctx1( f1);
56 std::cout << "main: done" << std::endl;