A
lgorithmique
N
umérique
D
istribuée
Public GIT Repository
projects
/
simgrid.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Use s4u API in example.
[simgrid.git]
/
src
/
xbt
/
backtrace_linux.cpp
diff --git
a/src/xbt/backtrace_linux.cpp
b/src/xbt/backtrace_linux.cpp
index
7fa8051
..
5b23cb1
100644
(file)
--- a/
src/xbt/backtrace_linux.cpp
+++ b/
src/xbt/backtrace_linux.cpp
@@
-21,7
+21,6
@@
#include <xbt/backtrace.hpp>
#include "xbt/ex.h"
#include "xbt/log.h"
#include <xbt/backtrace.hpp>
#include "xbt/ex.h"
#include "xbt/log.h"
-#include "xbt/str.h"
#include "xbt/module.h" /* xbt_binary_name */
#include "src/xbt_modinter.h" /* backtrace initialization headers */
#if SIMGRID_HAVE_MC
#include "xbt/module.h" /* xbt_binary_name */
#include "src/xbt_modinter.h" /* backtrace initialization headers */
#if SIMGRID_HAVE_MC
@@
-39,10
+38,9
@@
struct trace_arg {
int size;
};
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<trace_arg*>(a)
;
/* We are first called with address in the __backtrace function.
Skip it. */
/* We are first called with address in the __backtrace function.
Skip it. */
@@
-223,8
+221,8
@@
std::vector<std::string> resolveBacktrace(
int found = 0;
/* let's look for the offset of this library in our addressing space */
int found = 0;
/* let's look for the offset of this library in our addressing space */
-
char* maps_name = bprintf("/proc/%d/maps", (int) getpid())
;
- FILE* maps
= fopen(maps_name
, "r");
+
std::string maps_name = std::string("/proc/") + std::to_string(getpid()) + "maps"
;
+ FILE* maps
= fopen(maps_name.c_str()
, "r");
unsigned long int addr = strtoul(addrs[i].c_str(), &p, 16);
if (*p != '\0') {
unsigned long int addr = strtoul(addrs[i].c_str(), &p, 16);
if (*p != '\0') {
@@
-255,7
+253,6
@@
std::vector<std::string> resolveBacktrace(
}
}
fclose(maps);
}
}
fclose(maps);
- free(maps_name);
addrs[i].clear();
if (not found) {
addrs[i].clear();
if (not found) {
@@
-287,27
+284,26
@@
std::vector<std::string> resolveBacktrace(
*p2 = '\0';
/* Here we go, fire an addr2line up */
*p2 = '\0';
/* Here we go, fire an addr2line up */
-
char* subcmd = bprintf("%s -f -e %s %s", ADDR2LINE, p, addrs[i].c_str())
;
+
std::string subcmd = std::string(ADDR2LINE) + " -f -e " + p + " " + addrs[i]
;
free(p);
free(p);
- XBT_VERB("Fire a new command: '%s'", subcmd);
- FILE* subpipe = popen(subcmd, "r");
+ XBT_VERB("Fire a new command: '%s'", subcmd
.c_str()
);
+ FILE* subpipe = popen(subcmd
.c_str()
, "r");
if (not subpipe) {
xbt_die("Cannot fork addr2line to display the backtrace");
}
if (fgets(line_func, 1024, subpipe)) {
line_func[strlen(line_func) - 1] = '\0';
} else {
if (not subpipe) {
xbt_die("Cannot fork addr2line to display the backtrace");
}
if (fgets(line_func, 1024, subpipe)) {
line_func[strlen(line_func) - 1] = '\0';
} else {
- XBT_VERB("Cannot read result of subcommand %s", subcmd);
+ XBT_VERB("Cannot read result of subcommand %s", subcmd
.c_str()
);
strncpy(line_func, "???",3);
}
if (fgets(line_pos, 1024, subpipe)) {
line_pos[strlen(line_pos) - 1] = '\0';
} else {
strncpy(line_func, "???",3);
}
if (fgets(line_pos, 1024, subpipe)) {
line_pos[strlen(line_pos) - 1] = '\0';
} else {
- XBT_VERB("Cannot read result of subcommand %s", subcmd);
+ XBT_VERB("Cannot read result of subcommand %s", subcmd
.c_str()
);
strncpy(line_pos, backtrace_syms[i],1024);
}
pclose(subpipe);
strncpy(line_pos, backtrace_syms[i],1024);
}
pclose(subpipe);
- free(subcmd);
}
/* check whether the trick worked */
}
/* check whether the trick worked */