X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/19cd5a52131b50275fa26e0e53c4a8bd333f2937..21a680050fb52ee9a91716b5fe8aca4ca96e16e5:/src/xbt/backtrace_linux.cpp diff --git a/src/xbt/backtrace_linux.cpp b/src/xbt/backtrace_linux.cpp index 097519cb5b..7cde5e37c2 100644 --- a/src/xbt/backtrace_linux.cpp +++ b/src/xbt/backtrace_linux.cpp @@ -6,6 +6,8 @@ /* This program is free software; you can redistribute it and/or modify it * under the terms of the license (GNU LGPL) which comes with this package. */ +#include +#include #include #include #include @@ -38,10 +40,9 @@ struct trace_arg { int size; }; -static _Unwind_Reason_Code -backtrace_helper (struct _Unwind_Context *ctx, void *a) +static _Unwind_Reason_Code backtrace_helper(_Unwind_Context* ctx, void* a) { - struct trace_arg *arg = (struct trace_arg *) a; + trace_arg* arg = static_cast(a); /* We are first called with address in the __backtrace function. Skip it. */ @@ -222,9 +223,12 @@ std::vector resolveBacktrace( int found = 0; /* let's look for the offset of this library in our addressing space */ - std::string maps_name = std::string("/proc/") + std::to_string(getpid()) + "maps"; + std::string maps_name = std::string("/proc/") + std::to_string(getpid()) + "/maps"; FILE* maps = fopen(maps_name.c_str(), "r"); - + if (maps == nullptr) { + XBT_CRITICAL("fopen(\"%s\") failed: %s", maps_name.c_str(), strerror(errno)); + continue; + } unsigned long int addr = strtoul(addrs[i].c_str(), &p, 16); if (*p != '\0') { XBT_CRITICAL("Cannot parse backtrace address '%s' (addr=%#lx)", addrs[i].c_str(), addr);