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
accept single quotes while converting the XML files
[simgrid.git]
/
src
/
xbt
/
memory_map.cpp
diff --git
a/src/xbt/memory_map.cpp
b/src/xbt/memory_map.cpp
index
ea28244
..
0db9b1f
100644
(file)
--- a/
src/xbt/memory_map.cpp
+++ b/
src/xbt/memory_map.cpp
@@
-27,6
+27,12
@@
XBT_LOG_NEW_DEFAULT_SUBCATEGORY(xbt_memory_map, xbt, "Logging specific to algori
namespace simgrid {
namespace xbt {
namespace simgrid {
namespace xbt {
+/**
+ * \todo This function contains many cases that do not allow for a
+ * recovery. Currently, xbt_abort() is called but we should
+ * much rather die with the specific reason so that it's easier
+ * to find out what's going on.
+ */
XBT_PRIVATE std::vector<VmMap> get_memory_map(pid_t pid)
{
#ifdef __linux__
XBT_PRIVATE std::vector<VmMap> get_memory_map(pid_t pid)
{
#ifdef __linux__
@@
-48,13
+54,17
@@
XBT_PRIVATE std::vector<VmMap> get_memory_map(pid_t pid)
char* line = nullptr;
std::size_t n = 0; /* Amount of bytes to read by xbt_getline */
while ((read = xbt_getline(&line, &n, fp)) != -1) {
char* line = nullptr;
std::size_t n = 0; /* Amount of bytes to read by xbt_getline */
while ((read = xbt_getline(&line, &n, fp)) != -1) {
+ /**
+ * The lines that we read have this format: (This is just an example)
+ * 00602000-00603000 rw-p 00002000 00:28 1837264 <complete-path-to-file>
+ */
//fprintf(stderr,"%s", line);
/* Wipeout the new line character */
line[read - 1] = '\0';
//fprintf(stderr,"%s", line);
/* Wipeout the new line character */
line[read - 1] = '\0';
- /* Tokenize the line using spaces as delimiters and store each token in lfields array. We expect 5 tokens
/
fields */
+ /* Tokenize the line using spaces as delimiters and store each token in lfields array. We expect 5 tokens
for 6
fields */
char* lfields[6];
lfields[0] = strtok(line, " ");
char* lfields[6];
lfields[0] = strtok(line, " ");
@@
-113,10
+123,14
@@
XBT_PRIVATE std::vector<VmMap> get_memory_map(pid_t pid)
if (memreg.prot == 0)
memreg.prot |= PROT_NONE;
if (memreg.prot == 0)
memreg.prot |= PROT_NONE;
- if (lfields[1][
4
] == 'p')
+ if (lfields[1][
3
] == 'p')
memreg.flags |= MAP_PRIVATE;
memreg.flags |= MAP_PRIVATE;
- else if (lfields[1][
4
] == 's')
+ else if (lfields[1][
3
] == 's')
memreg.flags |= MAP_SHARED;
memreg.flags |= MAP_SHARED;
+ else {
+ xbt_die("Flag was neither 'p' (private) nor 's' (shared). This should have never happened! Instead, the permissions column was set to: %s\n"
+ "This was the whole line that caused the trouble: %s", lfields[1], line);
+ }
/* Get the offset value */
memreg.offset = std::strtoull(lfields[2], &endptr, 16);
/* Get the offset value */
memreg.offset = std::strtoull(lfields[2], &endptr, 16);