#include <unistd.h>
#include <array>
+#include <csignal>
#include <map>
#include <string>
#include <vector>
#if THE_ISA == ALPHA_ISA
#include "arch/alpha/linux/process.hh"
+
#elif THE_ISA == SPARC_ISA
#include "arch/sparc/linux/process.hh"
#include "arch/sparc/solaris/process.hh"
+
#elif THE_ISA == MIPS_ISA
#include "arch/mips/linux/process.hh"
+
#elif THE_ISA == ARM_ISA
-#include "arch/arm/linux/process.hh"
#include "arch/arm/freebsd/process.hh"
+#include "arch/arm/linux/process.hh"
+
#elif THE_ISA == X86_ISA
#include "arch/x86/linux/process.hh"
+
#elif THE_ISA == POWER_ISA
#include "arch/power/linux/process.hh"
+
#elif THE_ISA == RISCV_ISA
#include "arch/riscv/linux/process.hh"
+
#else
#error "THE_ISA not set"
#endif
_pid(params->pid), _ppid(params->ppid),
_pgid(params->pgid), drivers(params->drivers),
fds(make_shared<FDArray>(params->input, params->output, params->errout)),
- maxStackSize(params->maxStackSize),
childClearTID(0)
{
if (_pid >= System::maxPID)
_tgid = params->pid;
exitGroup = new bool();
- memState = new MemState();
sigchld = new bool();
if (!debugSymbolTable) {
!objFile->loadLocalSymbols(debugSymbolTable) ||
!objFile->loadWeakSymbols(debugSymbolTable)) {
delete debugSymbolTable;
- debugSymbolTable = NULL;
+ debugSymbolTable = nullptr;
}
}
}
Process::clone(ThreadContext *otc, ThreadContext *ntc,
Process *np, TheISA::IntReg flags)
{
+#ifndef CLONE_VM
+#define CLONE_VM 0
+#endif
+#ifndef CLONE_FILES
+#define CLONE_FILES 0
+#endif
+#ifndef CLONE_THREAD
+#define CLONE_THREAD 0
+#endif
if (CLONE_VM & flags) {
/**
* Share the process memory address space between the new process
np->pTable = pTable;
ntc->getMemProxy().setPageTable(np->pTable);
- delete np->memState;
np->memState = memState;
} else {
/**
if (ThreadContext::Halted == it->status())
return it;
}
- return NULL;
+ return nullptr;
}
void
bool
Process::fixupStackFault(Addr vaddr)
{
+ Addr stack_min = memState->getStackMin();
+ Addr stack_base = memState->getStackBase();
+ Addr max_stack_size = memState->getMaxStackSize();
+
// Check if this is already on the stack and there's just no page there
// yet.
- if (vaddr >= memState->stackMin && vaddr < memState->stackBase) {
+ if (vaddr >= stack_min && vaddr < stack_base) {
allocateMem(roundDown(vaddr, PageBytes), PageBytes);
return true;
}
// We've accessed the next page of the stack, so extend it to include
// this address.
- if (vaddr < memState->stackMin
- && vaddr >= memState->stackBase - maxStackSize) {
- while (vaddr < memState->stackMin) {
- memState->stackMin -= TheISA::PageBytes;
- if (memState->stackBase - memState->stackMin > maxStackSize)
+ if (vaddr < stack_min && vaddr >= stack_base - max_stack_size) {
+ while (vaddr < stack_min) {
+ stack_min -= TheISA::PageBytes;
+ if (stack_base - stack_min > max_stack_size)
fatal("Maximum stack size exceeded\n");
- allocateMem(memState->stackMin, TheISA::PageBytes);
+ allocateMem(stack_min, TheISA::PageBytes);
inform("Increasing stack size by one page.");
- };
+ }
+ memState->setStackMin(stack_min);
return true;
}
return false;
void
Process::serialize(CheckpointOut &cp) const
{
- SERIALIZE_SCALAR(memState->brkPoint);
- SERIALIZE_SCALAR(memState->stackBase);
- SERIALIZE_SCALAR(memState->stackSize);
- SERIALIZE_SCALAR(memState->stackMin);
- SERIALIZE_SCALAR(memState->nextThreadStackBase);
- SERIALIZE_SCALAR(memState->mmapEnd);
pTable->serialize(cp);
/**
* Checkpoints for file descriptors currently do not work. Need to
void
Process::unserialize(CheckpointIn &cp)
{
- UNSERIALIZE_SCALAR(memState->brkPoint);
- UNSERIALIZE_SCALAR(memState->stackBase);
- UNSERIALIZE_SCALAR(memState->stackSize);
- UNSERIALIZE_SCALAR(memState->stackMin);
- UNSERIALIZE_SCALAR(memState->nextThreadStackBase);
- UNSERIALIZE_SCALAR(memState->mmapEnd);
pTable->unserialize(cp);
/**
* Checkpoints for file descriptors currently do not work. Need to
numSyscalls++;
SyscallDesc *desc = getDesc(callnum);
- if (desc == NULL)
+ if (desc == nullptr)
fatal("Syscall %d out of range", callnum);
desc->doSyscall(callnum, this, tc, fault);
return d;
}
- return NULL;
+ return nullptr;
}
void
// We are allocating the memory area; set the bias to the lowest address
// in the allocated memory region.
- Addr *end = &memState->mmapEnd;
- Addr ld_bias = mmapGrowsDown() ? *end - interp_mapsize : *end;
+ Addr mmap_end = memState->getMmapEnd();
+ Addr ld_bias = mmapGrowsDown() ? mmap_end - interp_mapsize : mmap_end;
// Adjust the process mmap area to give the interpreter room; the real
// execve system call would just invoke the kernel's internal mmap
// functions to make these adjustments.
- *end = mmapGrowsDown() ? ld_bias : *end + interp_mapsize;
+ mmap_end = mmapGrowsDown() ? ld_bias : mmap_end + interp_mapsize;
+ memState->setMmapEnd(mmap_end);
interp->updateBias(ld_bias);
}
Process *
ProcessParams::create()
{
- Process *process = NULL;
+ Process *process = nullptr;
// If not specified, set the executable parameter equal to the
// simulated system's zeroth command line parameter
}
ObjectFile *obj_file = createObjectFile(executable);
- if (obj_file == NULL) {
+ if (obj_file == nullptr) {
fatal("Can't load object file %s", executable);
}
#error "THE_ISA not set"
#endif
- if (process == NULL)
+ if (process == nullptr)
fatal("Unknown error creating process object.");
return process;
}