X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/46955720acf99b23cd091630130b67954dcd3f3c..4e1fee193fdffe48d9fe250087ab4e5ae6342532:/src/xbt/backtrace_linux.cpp diff --git a/src/xbt/backtrace_linux.cpp b/src/xbt/backtrace_linux.cpp index 40966765df..80de20ae18 100644 --- a/src/xbt/backtrace_linux.cpp +++ b/src/xbt/backtrace_linux.cpp @@ -1,7 +1,7 @@ /* backtrace_linux - backtrace displaying on linux platform */ /* This file is included by ex.cpp on need (have execinfo.h, popen & addrline)*/ -/* Copyright (c) 2008-2017. The SimGrid Team. All rights reserved. */ +/* Copyright (c) 2008-2018. The SimGrid Team. All rights reserved. */ /* 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. */ @@ -136,10 +136,14 @@ static std::string get_binary_path() return ""; } +std::vector resolveBacktrace(xbt_backtrace_location_t const* loc, std::size_t count) // deprecated +{ + return resolve_backtrace(loc, count); +} + //FIXME: This code could be greatly improved/simplifyied with // http://cairo.sourcearchive.com/documentation/1.9.4/backtrace-symbols_8c-source.html -std::vector resolveBacktrace( - xbt_backtrace_location_t const* loc, std::size_t count) +std::vector resolve_backtrace(xbt_backtrace_location_t const* loc, std::size_t count) { std::vector result; @@ -187,9 +191,7 @@ std::vector resolveBacktrace( XBT_VERB("Fire a first command: '%s'", cmd.c_str()); FILE* pipe = popen(cmd.c_str(), "r"); - if (not pipe) { - xbt_die("Cannot fork addr2line to display the backtrace"); - } + xbt_assert(pipe, "Cannot fork addr2line to display the backtrace"); /* To read the output of addr2line */ char line_func[1024]; @@ -200,7 +202,7 @@ std::vector resolveBacktrace( line_func[strlen(line_func) - 1] = '\0'; } else { XBT_VERB("Cannot run fgets to look for symbol %zu, addr %s", i, addrs[i].c_str()); - strncpy(line_func, "???",3); + strncpy(line_func, "???", 4); } if (fgets(line_pos, 1024, pipe)) { line_pos[strlen(line_pos) - 1] = '\0'; @@ -286,7 +288,7 @@ std::vector resolveBacktrace( /* Here we go, fire an addr2line up */ std::string subcmd = std::string(ADDR2LINE) + " -f -e " + p + " " + addrs[i]; - XBT_VERB("Fire a new command: '%s'", subcmd.c_str()); + XBT_VERB("Fire another command: '%s'", subcmd.c_str()); FILE* subpipe = popen(subcmd.c_str(), "r"); if (not subpipe) { xbt_die("Cannot fork addr2line to display the backtrace"); @@ -295,7 +297,7 @@ std::vector resolveBacktrace( line_func[strlen(line_func) - 1] = '\0'; } else { XBT_VERB("Cannot read result of subcommand %s", subcmd.c_str()); - strncpy(line_func, "???",3); + strncpy(line_func, "???", 4); } if (fgets(line_pos, 1024, subpipe)) { line_pos[strlen(line_pos) - 1] = '\0';