qnx backtrace实现

QNX的backtrace与Linux的不一样

QNX下无 #include

QNX参考资料

https://www.qnx.com/developers/docs/7.1/index.html#com.qnx.doc.neutrino.technotes/topic/backtrace.html

示例程序 https://www.qnx.com/developers/docs/7.1/index.html#com.qnx.doc.neutrino.technotes/topic/backtrace_Print_memmap.html

#include 
#include 
#include 
#include 
#include 

int main(int argc, char *argv[])
{
    char out[1024];

    bt_accessor_t acc;
    bt_memmap_t memmap;

    if (bt_init_accessor(&acc, BT_SELF) == -1)
    {
        fprintf( stderr, "%s:%i %s (%i)%s\n", __FUNCTION__, __LINE__,
                 "bt_init_accessor", errno, strerror(errno));
        return EXIT_FAILURE;
    }

    if (bt_load_memmap( &acc, &memmap) == -1)
    {
        fprintf( stderr, "%s:%i %s (%i)%s\n", __FUNCTION__, __LINE__,
                 "bt_load_memmap", errno, strerror(errno));
        return EXIT_FAILURE;
    }

    if (bt_sprn_memmap(&memmap, out, sizeof(out)) == -1)
    {
        fprintf( stderr, "%s:%i %s (%i)%s\n", __FUNCTION__, __LINE__,
                 "bt_sprn_memmap", errno, strerror(errno));
        return EXIT_FAILURE;
    }

    /* Make sure that the string is null-terminated. */
    out[sizeof(out) - 1] = '\0';
    puts(out);

    bt_unload_memmap( &memmap );

    if (bt_release_accessor(&acc) == -1)
    {
        fprintf( stderr, "%s:%i %s (%i)%s\n", __FUNCTION__, __LINE__,
                 "bt_release_accessor", errno, strerror(errno));
        return EXIT_FAILURE;
    }

    return EXIT_SUCCESS;
}

你可能感兴趣的:(linux,qnx,backtrace,堆栈打印)