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
Merge branch 'master' into xbt_random
[simgrid.git]
/
src
/
mc
/
inspect
/
mc_unw_vmread.cpp
diff --git
a/src/mc/inspect/mc_unw_vmread.cpp
b/src/mc/inspect/mc_unw_vmread.cpp
index
9075f7b
..
d75ec4d
100644
(file)
--- a/
src/mc/inspect/mc_unw_vmread.cpp
+++ b/
src/mc/inspect/mc_unw_vmread.cpp
@@
-1,9
+1,11
@@
-/* Copyright (c) 2015-2019. The SimGrid Team.
- * All rights reserved. */
+/* Copyright (c) 2015-2019. 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. */
/* 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 "src/mc/inspect/mc_unw.hpp"
+#include "src/mc/remote/RemoteClient.hpp"
+
#include <sys/types.h>
#include <sys/uio.h>
#include <sys/types.h>
#include <sys/uio.h>
@@
-11,13
+13,8
@@
#include <libunwind-ptrace.h>
#include <libunwind.h>
#include <libunwind-ptrace.h>
#include <libunwind.h>
-#include "src/mc/mc_unw.hpp"
-#include "src/mc/remote/RemoteClient.hpp"
-
/** \file
* Libunwind namespace implementation using process_vm_readv.
/** \file
* Libunwind namespace implementation using process_vm_readv.
- *.
- * This implem
*/
/** Partial structure of libunwind-ptrace context in order to get the PID
*/
/** Partial structure of libunwind-ptrace context in order to get the PID
@@
-39,8
+36,7
@@
static inline pid_t _UPT_getpid(void* arg)
return info->pid;
}
return info->pid;
}
-/** Read from the memory, avoid using `ptrace` (libunwind method)
- */
+/** Read from the memory, avoid using `ptrace` (libunwind method) */
static int access_mem(const unw_addr_space_t as, const unw_word_t addr, unw_word_t* const valp, const int write,
void* const arg)
{
static int access_mem(const unw_addr_space_t as, const unw_word_t addr, unw_word_t* const valp, const int write,
void* const arg)
{
@@
-49,7
+45,7
@@
static int access_mem(const unw_addr_space_t as, const unw_word_t addr, unw_word
pid_t pid = _UPT_getpid(arg);
size_t size = sizeof(unw_word_t);
pid_t pid = _UPT_getpid(arg);
size_t size = sizeof(unw_word_t);
-#if HAVE_PROCESS_VM_READV
+#if HAVE_PROCESS_VM_READV
/* linux but not freebsd */
// process_vm_read implementation.
// This is only available since Linux 3.2.
// process_vm_read implementation.
// This is only available since Linux 3.2.
@@
-75,27
+71,24
@@
static int access_mem(const unw_addr_space_t as, const unw_word_t addr, unw_word
int fd = simgrid::mc::open_vm(pid, O_RDONLY);
if (fd < 0)
return -UNW_EINVAL;
int fd = simgrid::mc::open_vm(pid, O_RDONLY);
if (fd < 0)
return -UNW_EINVAL;
- while (1) {
+
+ while (count > 0) {
ssize_t nread = pread(fd, buf, count, off);
if (nread == 0) {
close(fd);
return -UNW_EINVAL;
}
if (nread == -1)
ssize_t nread = pread(fd, buf, count, off);
if (nread == 0) {
close(fd);
return -UNW_EINVAL;
}
if (nread == -1)
- break;
+ // ptrace implementation.
+ // We need to have PTRACE_ATTACH-ed it before.
+ return _UPT_access_mem(as, addr, valp, write, arg);
+
count -= nread;
buf += nread;
off += nread;
count -= nread;
buf += nread;
off += nread;
- if (count == 0) {
- close(fd);
- return 0;
- }
}
close(fd);
}
close(fd);
-
- // ptrace implementation.
- // We need to have PTRACE_ATTACH-ed it before.
- return _UPT_access_mem(as, addr, valp, write, arg);
+ return 0;
}
namespace simgrid {
}
namespace simgrid {
@@
-107,7
+100,7
@@
namespace unw {
* does not use ptrace() to read the target process memory by
* `process_vm_readv()` or `/dev/${pid}/mem` if possible.
*
* does not use ptrace() to read the target process memory by
* `process_vm_readv()` or `/dev/${pid}/mem` if possible.
*
- * Does not support any MC-specific behavio
u
r (privatization, snapshots)
+ * Does not support any MC-specific behavior (privatization, snapshots)
* and `ucontext_t`.
*
* It works with `void*` contexts allocated with `_UPT_create(pid)`.
* and `ucontext_t`.
*
* It works with `void*` contexts allocated with `_UPT_create(pid)`.