diff options
author | Evan Martin <martine@danga.com> | 2010-12-05 00:09:50 (GMT) |
---|---|---|
committer | Evan Martin <martine@danga.com> | 2010-12-05 00:09:50 (GMT) |
commit | 42d237e7841679b27cd5dcae82d143d86a87a807 (patch) | |
tree | 253b0cf88ecf3b0404146a7c7945dd4c660afa04 /src/util.cc | |
parent | d0025e234cf3fc0a13f45d179880578285609b59 (diff) | |
download | Ninja-42d237e7841679b27cd5dcae82d143d86a87a807.zip Ninja-42d237e7841679b27cd5dcae82d143d86a87a807.tar.gz Ninja-42d237e7841679b27cd5dcae82d143d86a87a807.tar.bz2 |
move src into subdir
Diffstat (limited to 'src/util.cc')
-rw-r--r-- | src/util.cc | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/src/util.cc b/src/util.cc new file mode 100644 index 0000000..7a1c4e6 --- /dev/null +++ b/src/util.cc @@ -0,0 +1,24 @@ +#include "util.h" + +#include <execinfo.h> +#include <stdarg.h> +#include <stdio.h> +#include <stdlib.h> + +void DumpBacktrace(int skip_frames) { + void* stack[256]; + int size = backtrace(stack, 256); + ++skip_frames; // Skip ourselves as well. + backtrace_symbols_fd(stack + skip_frames, size - skip_frames, 2); +} + +void Fatal(const char* msg, ...) { + va_list ap; + fprintf(stderr, "FATAL: "); + va_start(ap, msg); + vfprintf(stderr, msg, ap); + va_end(ap); + fprintf(stderr, "\n"); + DumpBacktrace(1); + exit(1); +} |