#elif defined BSD
ptrace(PT_TRACE_ME, 0, nullptr, 0);
#else
-# error "ptrace not declared on this platform"
+# error "no ptrace equivalent coded for this platform"
#endif
if(errno != 0 || raise(SIGSTOP) != 0)
xbt_die("Could not wait for the model-checker");
using simgrid::mc::remote;
+#ifdef __linux__
+# define WAITPID_CHECKED_FLAGS __WALL
+#else
+# define WAITPID_CHECKED_FLAGS 0
+#endif
+
// Hardcoded index for now:
#define SOCKET_FD_INDEX 0
#define SIGNAL_FD_INDEX 1
int status;
// The model-checked process SIGSTOP itself to signal it's ready:
- pid_t res = waitpid(pid, &status, __WALL);
+ pid_t res = waitpid(pid, &status, WAITPID_CHECKED_FLAGS);
if (res < 0 || !WIFSTOPPED(status) || WSTOPSIG(status) != SIGSTOP)
xbt_die("Could not wait model-checked process");
setup_ignore();
+#ifdef __linux__
ptrace(PTRACE_SETOPTIONS, pid, nullptr, PTRACE_O_TRACEEXIT);
ptrace(PTRACE_CONT, pid, 0, 0);
+#elif defined BSD
+ ptrace(PT_CONTINUE, pid, (caddr_t)1, 0);
+#else
+# error "no ptrace equivalent coded for this platform"
+#endif
}
static const std::pair<const char*, const char*> ignored_local_variables[] = {
if (pid == this->process().pid()) {
// From PTRACE_O_TRACEEXIT:
+#ifdef __linux__
if (status>>8 == (SIGTRAP | (PTRACE_EVENT_EXIT<<8))) {
if (ptrace(PTRACE_GETEVENTMSG, this->process().pid(), 0, &status) == -1)
xbt_die("Could not get exit status");
mc_model_checker->exit(SIMGRID_MC_EXIT_PROGRAM_CRASH);
}
}
+#endif
// We don't care about signals, just reinject them:
if (WIFSTOPPED(status)) {
XBT_DEBUG("Stopped with signal %i", (int) WSTOPSIG(status));
- if (ptrace(PTRACE_CONT, this->process().pid(), 0, WSTOPSIG(status)) == -1)
+ errno = 0;
+#ifdef __linux__
+ ptrace(PTRACE_CONT, this->process().pid(), 0, WSTOPSIG(status));
+#elif defined BSD
+ ptrace(PT_CONTINUE, this->process().pid(), nullptr, WSTOPSIG(status));
+#endif
+ if (errno != 0)
xbt_die("Could not PTRACE_CONT");
}
#include <string.h> // memcpy, memcmp
#include <sys/mman.h>
+#ifdef __FreeBSD__
+# define MAP_POPULATE MAP_PREFAULT_READ
+#endif
#include <xbt/base.h>
#include <xbt/log.h>
{
size_t old_bytesize = this->capacity_ << xbt_pagebits;
size_t new_bytesize = size << xbt_pagebits;
+ void *new_memory;
// Expand the memory region by moving it into another
// virtual memory address if necessary:
- void* new_memory = mremap(this->memory_, old_bytesize, new_bytesize, MREMAP_MAYMOVE);
+#if HAVE_MREMAP
+ new_memory = mremap(this->memory_, old_bytesize, new_bytesize, MREMAP_MAYMOVE);
if (new_memory == MAP_FAILED)
xbt_die("Could not mremap snapshot pages.");
+#else
+ if (new_bytesize > old_bytesize) {
+ // Grow: first try to add new space after current map
+ new_memory = mmap((char *)this->memory_ + old_bytesize,
+ new_bytesize-old_bytesize,
+ PROT_READ|PROT_WRITE,
+ MAP_PRIVATE|MAP_ANONYMOUS|MAP_POPULATE,
+ -1, 0);
+ if (new_memory == MAP_FAILED)
+ xbt_die("Could not mremap snapshot pages.");
+ // Check if expanding worked
+ if (new_memory != (char *)this->memory_ + old_bytesize) {
+ // New memory segment could not be put at the end of this->memory_,
+ // so cancel this one and try to rellocate everything and copy data
+ munmap(new_memory, new_bytesize-old_bytesize);
+ new_memory = mmap(nullptr,
+ new_bytesize,
+ PROT_READ|PROT_WRITE,
+ MAP_PRIVATE|MAP_ANONYMOUS|MAP_POPULATE,
+ -1, 0);
+ if (new_memory == MAP_FAILED)
+ xbt_die("Could not mremap snapshot pages.");
+ memcpy(new_memory, this->memory_, old_bytesize);
+ munmap(this->memory_, old_bytesize);
+ }
+ }
+ else {
+ // We don't have functions to shrink a mapping, so leave memory as
+ // it is for now
+ new_memory = this->memory_;
+ }
+#endif
this->capacity_ = size;
this->memory_ = new_memory;
#include <string.h>
// On x86_64, libunwind unw_context_t has the same layout as ucontext_t:
+#include <sys/types.h>
#include <sys/ucontext.h>
+#ifdef __FreeBSD__
+typedef register_t greg_t;
+#endif
#include <libunwind.h>
#ifdef __x86_64
mcontext_t* mcontext = &context->uc_mcontext;
switch (regnum) {
+# ifdef __linux__
case UNW_X86_64_RAX: return &mcontext->gregs[REG_RAX];
case UNW_X86_64_RDX: return &mcontext->gregs[REG_RDX];
case UNW_X86_64_RCX: return &mcontext->gregs[REG_RCX];
case UNW_X86_64_R14: return &mcontext->gregs[REG_R14];
case UNW_X86_64_R15: return &mcontext->gregs[REG_R15];
case UNW_X86_64_RIP: return &mcontext->gregs[REG_RIP];
+# elif defined __FreeBSD__
+ case UNW_X86_64_RAX: return &mcontext->mc_rax;
+ case UNW_X86_64_RDX: return &mcontext->mc_rdx;
+ case UNW_X86_64_RCX: return &mcontext->mc_rcx;
+ case UNW_X86_64_RBX: return &mcontext->mc_rbx;
+ case UNW_X86_64_RSI: return &mcontext->mc_rsi;
+ case UNW_X86_64_RDI: return &mcontext->mc_rdi;
+ case UNW_X86_64_RBP: return &mcontext->mc_rbp;
+ case UNW_X86_64_RSP: return &mcontext->mc_rsp;
+ case UNW_X86_64_R8: return &mcontext->mc_r8;
+ case UNW_X86_64_R9: return &mcontext->mc_r9;
+ case UNW_X86_64_R10: return &mcontext->mc_r10;
+ case UNW_X86_64_R11: return &mcontext->mc_r11;
+ case UNW_X86_64_R12: return &mcontext->mc_r12;
+ case UNW_X86_64_R13: return &mcontext->mc_r13;
+ case UNW_X86_64_R14: return &mcontext->mc_r14;
+ case UNW_X86_64_R15: return &mcontext->mc_r15;
+ case UNW_X86_64_RIP: return &mcontext->mc_rip;
+# else
+# error "Unable to get register from ucontext, please add your case"
+# endif
default: return nullptr;
}
#else
// Take a copy of the context for our own purpose:
this->unwindContext_ = *c;
#if SIMGRID_PROCESSOR_x86_64 || SIMGRID_PROCESSOR_i686
+# ifdef __linux__
// On x86_64, ucontext_t contains a pointer to itself for FP registers.
// We don't really need support for FR registers as they are caller saved
// and probably never use those fields as libunwind-x86_64 does not read
// Let's ignore this and see what happens:
this->unwindContext_.uc_mcontext.fpregs = nullptr;
+# endif
#else
// Do we need to do any fixup like this?
#error Target CPU type is not handled.
memreg.end_addr = vmentries[i].kve_end;
/* Permissions */
- memreg.prot = 0;
+ memreg.prot = PROT_NONE;
if (vmentries[i].kve_protection & KVME_PROT_READ)
memreg.prot |= PROT_READ;
if (vmentries[i].kve_protection & KVME_PROT_WRITE)
memreg.prot |= PROT_WRITE;
if (vmentries[i].kve_protection & KVME_PROT_EXEC)
memreg.prot |= PROT_EXEC;
- if (memreg.prot == 0)
- memreg.prot |= PROT_NONE;
/* Private (copy-on-write) or shared? */
if (vmentries[i].kve_flags & KVME_FLAG_COW)
/* Inode */
memreg.inode = vmentries[i].kve_vn_fileid;
- /*
- * Path. Linuxize result by giving an anonymous mapping a path from
- * the previous mapping... provided previous is vnode and has a path.
- */
+ /*
+ * Path. Linuxize result by giving an anonymous mapping a path from
+ * the previous mapping, provided previous is vnode and has a path,
+ * and mark the stack.
+ */
if (vmentries[i].kve_path[0] != '\0')
memreg.pathname = vmentries[i].kve_path;
else if (vmentries[i].kve_type == KVME_TYPE_DEFAULT
&& vmentries[i-1].kve_type == KVME_TYPE_VNODE
&& vmentries[i-1].kve_path[0] != '\0')
memreg.pathname = vmentries[i-1].kve_path;
+ else if (vmentries[i].kve_type == KVME_TYPE_DEFAULT
+ && vmentries[i].kve_flags & KVME_FLAG_GROWS_DOWN)
+ memreg.pathname = "[stack]";
+
+ /*
+ * One last dirty modification: remove write permission from shared
+ * libraries private clean pages. This is necessary because simgrid
+ * later identifies mappings based on the permissions that are expected
+ * when running the Linux kernel.
+ */
+ if (vmentries[i].kve_type == KVME_TYPE_VNODE
+ && ! (vmentries[i].kve_flags & KVME_FLAG_NEEDS_COPY))
+ memreg.prot &= ~PROT_WRITE;
ret.push_back(std::move(memreg));
}
foreach (test ${umpire_tests_passing} ${umpire_tests_deadlock} ${umpire_tests_problematic} )
add_executable(${test} ${test}.c)
target_link_libraries(${test} simgrid)
- set_source_files_properties(${test}.c PROPERTIES COMPILE_FLAGS "-Wno-error")
+ set_source_files_properties(${test}.c PROPERTIES COMPILE_FLAGS "-Wno-error -Wno-return-type")
set(umpire_tesh ${umpire_tesh} ${test})
set(files_to_clean ${files_to_clean} ${CMAKE_CURRENT_BINARY_DIR}/${test}.tesh)
endforeach(test)
MPI_Irecv (buf1, buf_size, MPI_INT,
MPI_ANY_SOURCE, 0, MPI_COMM_WORLD, &req);
- printf("Proc 0: Request number - %d\n",req);
+ printf("Proc 0: Request number - %p\n",req);
MPI_Send (buf0, buf_size, MPI_INT, 1, 0, MPI_COMM_WORLD);
MPI_Send (buf0, buf_size, MPI_INT, 1, 0, MPI_COMM_WORLD);
MPI_Wait (&req, &status);
- printf("Proc 0: Request number after wait test- %d\n",req);
+ printf("Proc 0: Request number after wait test- %p\n",req);
}
else if (rank == 1)
{
MPI_Irecv (buf1, buf_size, MPI_INT,
MPI_ANY_SOURCE, 0, MPI_COMM_WORLD, &req);
- printf("Proc 1: Request number - %d\n",req);
+ printf("Proc 1: Request number - %p\n",req);
MPI_Send (buf1, buf_size, MPI_INT, 0, 0, MPI_COMM_WORLD);
MPI_Send (buf1, buf_size, MPI_INT, 0, 0, MPI_COMM_WORLD);
MPI_Wait (&req, &status);
- printf("Proc 1: Request number after wait test- %d\n",req);
+ printf("Proc 1: Request number after wait test- %p\n",req);
}
MPI_Barrier (MPI_COMM_WORLD);
main (int argc, char **argv)
{
int rank;
- int comm = MPI_COMM_WORLD;
+ MPI_Comm comm = MPI_COMM_WORLD;
char processor_name[128];
int namelen = 128;
int buf0[buf_size];
{
int nprocs = -1;
int rank = -1;
- int comm = MPI_COMM_WORLD;
+ MPI_Comm comm = MPI_COMM_WORLD;
char processor_name[128];
int namelen = 128;
int bbuf[(BUF_SIZE + MPI_BSEND_OVERHEAD) * 2 * NUM_BSEND_TYPES];
{
int nprocs = -1;
int rank = -1;
- int comm = MPI_COMM_WORLD;
+ MPI_Comm comm = MPI_COMM_WORLD;
char processor_name[128];
int namelen = 128;
int i, j, k, basic_extent;
int rank = -1;
int tag1 = 0;
int tag2 = 0;
- int comm = MPI_COMM_WORLD;
+ MPI_Comm comm = MPI_COMM_WORLD;
char processor_name[128];
int namelen = 128;
int buf0[128];
{
int nprocs = -1;
int rank = -1;
- int comm = MPI_COMM_WORLD;
+ MPI_Comm comm = MPI_COMM_WORLD;
char processor_name[128];
int namelen = 128;
int sbuf[buf_size];
{
int nprocs = -1;
int rank = -1;
- int comm = MPI_COMM_WORLD;
+ MPI_Comm comm = MPI_COMM_WORLD;
char processor_name[128];
int namelen = 128;
int buf0[buf_size];
{
int nprocs = -1;
int rank = -1;
- int comm = MPI_COMM_WORLD;
+ MPI_Comm comm = MPI_COMM_WORLD;
char processor_name[128];
int namelen = 128;
int buf0[buf_size];
{
int nprocs = -1;
int rank = -1;
- int comm = MPI_COMM_WORLD;
+ MPI_Comm comm = MPI_COMM_WORLD;
char processor_name[128];
int namelen = 128;
MPI_Comm inverted_comm;
{
int nprocs = -1;
int rank = -1;
- int comm = MPI_COMM_WORLD;
+ MPI_Comm comm = MPI_COMM_WORLD;
char processor_name[128];
int namelen = 128;
MPI_Comm nc1;
{
int nprocs = -1;
int rank = -1;
- int comm = MPI_COMM_WORLD;
+ MPI_Comm comm = MPI_COMM_WORLD;
char processor_name[128];
int namelen = 128;
MPI_Comm newcomm;
{
int nprocs = -1;
int rank = -1;
- int comm = MPI_COMM_WORLD;
+ MPI_Comm comm = MPI_COMM_WORLD;
char processor_name[128];
int namelen = 128;
MPI_Comm newcomm;
MPI_Comm_size (newcomm, &nsize);
MPI_Comm_rank (newcomm, &nrank);
- printf ("world task %d/%d/%d maps to new comm task %d/%d/%d\n",
+ printf ("world task %p/%d/%d maps to new comm task %p/%d/%d\n",
comm, nprocs, rank, newcomm, nsize, nrank);
if (nrank == 0)
MPI_Bcast (&dat, 1, MPI_INT, 0, newcomm);
- printf ("world task %d/%d/%d maps to new comm task %d/%d/%d --> %d\n",
+ printf ("world task %p/%d/%d maps to new comm task %p/%d/%d --> %d\n",
comm, nprocs, rank, newcomm, nsize, nrank, dat);
}
{
int nprocs = -1;
int rank = -1;
- int comm = MPI_COMM_WORLD;
+ MPI_Comm comm = MPI_COMM_WORLD;
char processor_name[128];
int namelen = 128;
MPI_Comm newcomm;
{
int nprocs = -1;
int rank = -1;
- int comm = MPI_COMM_WORLD;
+ MPI_Comm comm = MPI_COMM_WORLD;
char processor_name[128];
int namelen = 128;
MPI_Comm newcomm;
MPI_Comm_size (newcomm, &nsize);
MPI_Comm_rank (newcomm, &nrank);
- printf ("world task %d/%d/%d maps to new comm task %d/%d/%d\n",
+ printf ("world task %p/%d/%d maps to new comm task %p/%d/%d\n",
comm, nprocs, rank, newcomm, nsize, nrank);
}
#define buf_size 32000
+int
main (int argc, char **argv)
{
int nprocs = -1;
{
int nprocs = -1;
int rank = -1;
- int comm = MPI_COMM_WORLD;
+ MPI_Comm comm = MPI_COMM_WORLD;
int i;
char processor_name[128];
int namelen = 128;
{
int nprocs = -1;
int rank = -1;
- int comm = MPI_COMM_WORLD;
+ MPI_Comm comm = MPI_COMM_WORLD;
int i;
char processor_name[128];
int namelen = 128;
{
int nprocs = -1;
int rank = -1;
- int comm = MPI_COMM_WORLD;
+ MPI_Comm comm = MPI_COMM_WORLD;
char processor_name[128];
int namelen = 128;
int i;
{
int nprocs = -1;
int rank = -1;
- int comm = MPI_COMM_WORLD;
+ MPI_Comm comm = MPI_COMM_WORLD;
char processor_name[128];
int namelen = 128;
int i;
hello.c -- simple hello world app
*/
-
+#include <stdio.h>
#ifndef lint
static char *rcsid = "$Header: /usr/gapps/asde/cvs-vault/umpire/tests/hello.c,v 1.2 2000/12/04 19:09:46 bronis Exp $";
#endif
#include "mpi.h"
+int
main (int argc, char **argv)
{
int nprocs = -1;
#define buf_size 128
-mydelay () /* about 6 seconds */
+int mydelay () /* about 6 seconds */
{
int i;
int val;
int rank = -1;
int tag1 = 31;
int tag2 = 32;
- int comm = MPI_COMM_WORLD;
+ MPI_Comm comm = MPI_COMM_WORLD;
char processor_name[128];
int namelen = 128;
int buf0[buf_size];
{
int nprocs = -1;
int rank = -1;
- int comm = MPI_COMM_WORLD;
+ MPI_Comm comm = MPI_COMM_WORLD;
char processor_name[128];
int namelen = 128;
int buf[buf_size];
{
int nprocs = -1;
int rank = -1;
- int comm = MPI_COMM_WORLD;
+ MPI_Comm comm = MPI_COMM_WORLD;
char processor_name[128];
int namelen = 128;
int buf[BUF_SIZE * 2];
{
int nprocs = -1;
int rank = -1;
- int comm = MPI_COMM_WORLD;
+ MPI_Comm comm = MPI_COMM_WORLD;
char processor_name[128];
int namelen = 128;
int buf[BUF_SIZE * 2];
{
int nprocs = -1;
int rank = -1;
- int comm = MPI_COMM_WORLD;
+ MPI_Comm comm = MPI_COMM_WORLD;
char processor_name[128];
int namelen = 128;
int buf[BUF_SIZE * 2];
{
int nprocs = -1;
int rank = -1;
- int comm = MPI_COMM_WORLD;
+ MPI_Comm comm = MPI_COMM_WORLD;
char processor_name[128];
int namelen = 128;
int buf[BUF_SIZE * 2];
{
int nprocs = -1;
int rank = -1;
- int comm = MPI_COMM_WORLD;
+ MPI_Comm comm = MPI_COMM_WORLD;
char processor_name[128];
int namelen = 128;
int buf[BUF_SIZE * 2];
{
int nprocs = -1;
int rank = -1;
- int comm = MPI_COMM_WORLD;
+ MPI_Comm comm = MPI_COMM_WORLD;
char processor_name[128];
int namelen = 128;
int buf[buf_size];
{
int nprocs = -1;
int rank = -1;
- int comm = MPI_COMM_WORLD;
+ MPI_Comm comm = MPI_COMM_WORLD;
int i;
char processor_name[128];
int namelen = 128;
{
int nprocs = -1;
int rank = -1;
- int comm = MPI_COMM_WORLD;
+ MPI_Comm comm = MPI_COMM_WORLD;
int i;
char processor_name[128];
int namelen = 128;
{
int nprocs = -1;
int rank = -1;
- int comm = MPI_COMM_WORLD;
+ MPI_Comm comm = MPI_COMM_WORLD;
char processor_name[128];
int namelen = 128;
int bbuf[(BUF_SIZE + MPI_BSEND_OVERHEAD) * 2 * NUM_BSEND_TYPES];
{
int nprocs = -1;
int rank = -1;
- int comm = MPI_COMM_WORLD;
+ MPI_Comm comm = MPI_COMM_WORLD;
char processor_name[128];
int namelen = 128;
int buf[BUF_SIZE * 2 + SLOP];
{
int nprocs = -1;
int rank = -1;
- int comm = MPI_COMM_WORLD;
+ MPI_Comm comm = MPI_COMM_WORLD;
char processor_name[128];
int namelen = 128;
int buf[BUF_SIZE * 2 + SLOP];
{
int nprocs = -1;
int rank = -1;
- int comm = MPI_COMM_WORLD;
+ MPI_Comm comm = MPI_COMM_WORLD;
char processor_name[128];
int namelen = 128;
int buf[BUF_SIZE * 2 + SLOP];
{
int nprocs = -1;
int rank = -1;
- int comm = MPI_COMM_WORLD;
+ MPI_Comm comm = MPI_COMM_WORLD;
char processor_name[128];
int namelen = 128;
int buf[BUF_SIZE * 2 + SLOP];
{
int nprocs = -1;
int rank = -1;
- int comm = MPI_COMM_WORLD;
+ MPI_Comm comm = MPI_COMM_WORLD;
char processor_name[128];
int namelen = 128;
- int i, basic_extent;
- int blocklens[3], displs[3];
+ int i;
+ MPI_Aint basic_extent;
+ int blocklens[3];
+ MPI_Aint displs[3];
MPI_Datatype structtypes[3];
MPI_Datatype newtype[2];
MPI_Request aReq[2];
MPI_Type_extent (newtype[0], &basic_extent);
if (basic_extent != sizeof (test_small_struct_t)) {
- fprintf (stderr, "(%d): Unexpected extent for small struct\n");
+ fprintf (stderr, "(%d): Unexpected extent for small struct\n", rank);
MPI_Abort (MPI_COMM_WORLD, 666);
}
MPI_Type_extent (newtype[1], &basic_extent);
if (basic_extent != sizeof (test_big_struct_t)) {
- fprintf (stderr, "(%d): Unexpected extent for big struct\n");
+ fprintf (stderr, "(%d): Unexpected extent for big struct\n", rank);
MPI_Abort (MPI_COMM_WORLD, 666);
}
{
int nprocs = -1;
int rank = -1;
- int comm = MPI_COMM_WORLD;
+ MPI_Comm comm = MPI_COMM_WORLD;
char processor_name[128];
int namelen = 128;
int bbuf[(BUF_SIZE + MPI_BSEND_OVERHEAD) * 2 * NUM_BSEND_TYPES];
{
int nprocs = -1;
int rank = -1;
- int comm = MPI_COMM_WORLD;
+ MPI_Comm comm = MPI_COMM_WORLD;
char processor_name[128];
int namelen = 128;
int i;
{
int nprocs = -1;
int rank = -1;
- int comm = MPI_COMM_WORLD;
+ MPI_Comm comm = MPI_COMM_WORLD;
char processor_name[128];
int namelen = 128;
MPI_Datatype newtype;
{
int nprocs = -1;
int rank = -1;
- int comm = MPI_COMM_WORLD;
+ MPI_Comm comm = MPI_COMM_WORLD;
char processor_name[128];
int namelen = 128;
int i, j, k, basic_extent;
{
int nprocs = -1;
int rank = -1;
- int comm = MPI_COMM_WORLD;
+ MPI_Comm comm = MPI_COMM_WORLD;
char processor_name[128];
int namelen = 128;
int i;
{
int nprocs = -1;
int rank = -1;
- int comm = MPI_COMM_WORLD;
+ MPI_Comm comm = MPI_COMM_WORLD;
char processor_name[128];
int namelen = 128;
MPI_Datatype newtype, newtype2;
{
int nprocs = -1;
int rank = -1;
- int comm = MPI_COMM_WORLD;
+ MPI_Comm comm = MPI_COMM_WORLD;
char processor_name[128];
int namelen = 128;
int i;
{
int nprocs = -1;
int rank = -1;
- int comm = MPI_COMM_WORLD;
+ MPI_Comm comm = MPI_COMM_WORLD;
char processor_name[128];
int namelen = 128;
MPI_Datatype newtype;