00001
00002
#ifndef STACK_TRACE_H
00003
#define STACK_TRACE_H
00004
00005
#include "common.h"
00006
#include "nmstl_util.h"
00007
#include "execinfo.h"
00008
00009
#include <unistd.h>
00010
#include <sys/types.h>
00011
#include <sys/wait.h>
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
struct sigcontext;
00030
00031 BOREALIS_NAMESPACE_BEGIN;
00032
00033 class StackTrace {
00034
public:
00035
static StackTrace *
save(
unsigned int skip_frames = 0);
00036
static string
get(
unsigned int skip_frames = 0);
00037
00038
static StackTrace *
save(
const sigcontext& ctx);
00039
static string
get(
const sigcontext& ctx);
00040
00041
~StackTrace();
00042
00043 string
as_string()
const {
00044
return "StackTrace(" +
to_string(_frames.size()) +
" frames)";
00045 }
00046
00047 string
repr() const;
00048
00049 private:
00050 static string exec(const
char *const argv[]);
00051 static string basename(string path);
00052
00053
StackTrace(
unsigned int skip_frames, const sigcontext *);
00054
00055 vector<
void*> _frames;
00056 mutable string _trace;
00057 };
00058
00059 BOREALIS_NAMESPACE_END;
00060 #endif