Go to the documentation of this file.
58 #include "config/the_isa.hh"
62 #include "params/Process.hh"
81 static LoaderList loaders;
89 process_loaders().emplace_back(
this);
95 for (
auto &loader: process_loaders()) {
96 Process *
p = loader->load(params, obj_file);
107 if (directory.back() !=
'/')
115 useArchPT(params->useArchPT),
116 kvmInSE(params->kvmInSE),
120 argv(params->cmd), envp(params->env),
121 executable(params->executable),
123 hostCwd(checkPathRedirect(tgtCwd)),
124 release(params->release),
125 _uid(params->uid), _euid(params->euid),
126 _gid(params->gid), _egid(params->egid),
127 _pid(params->pid), _ppid(params->ppid),
128 _pgid(params->pgid), drivers(params->drivers),
129 fds(make_shared<
FDArray>(params->input, params->
output, params->errout)),
136 if (!ret_pair.second)
170 #define CLONE_FILES 0
173 #define CLONE_THREAD 0
194 for (
auto map : mappings) {
218 std::shared_ptr<FDArray> nfds = np->
fds;
219 for (
int tgt_fd = 0; tgt_fd <
fds->getSize(); tgt_fd++) {
220 std::shared_ptr<FDEntry> this_fde = (*fds)[tgt_fd];
222 nfds->setFDEntry(tgt_fd,
nullptr);
225 nfds->setFDEntry(tgt_fd, this_fde->clone());
227 auto this_hbfd = std::dynamic_pointer_cast<HBFDEntry>(this_fde);
231 int this_sim_fd = this_hbfd->getSimFD();
232 if (this_sim_fd <= 2)
235 int np_sim_fd = dup(this_sim_fd);
236 assert(np_sim_fd != -1);
238 auto nhbfd = std::dynamic_pointer_cast<HBFDEntry>((*nfds)[tgt_fd]);
239 nhbfd->setSimFD(np_sim_fd);
258 using namespace Stats;
262 .
desc(
"Number of system calls")
271 if (*it == context_id) {
276 warn(
"Unable to find thread context to revoke");
293 fatal(
"Process %s is not associated with any HW contexts!\n",
name());
314 fds->updateFileOffsets();
363 warn(
"Checkpoints for file descriptors currently do not work.");
375 warn(
"Checkpoints for file descriptors currently do not work.");
395 if (
d->match(filename))
414 std::string tail = abs_path.substr(
path->appPath().size());
418 for (
auto host_path :
path->hostPaths()) {
419 if (access((host_path + tail).c_str(), R_OK) == 0) {
421 return host_path + tail;
427 return path->hostPaths()[0] + tail;
440 if (!interp || !interp->relocatable())
455 mmap_end =
mmapGrowsDown() ? ld_bias : mmap_end + interp_mapsize;
458 interp->updateBias(ld_bias);
486 if (filename.empty() ||
startswith(filename,
"/"))
492 auto path_base = std::string();
493 if (host_filesystem) {
505 auto absolute_path = path_base + filename;
507 return absolute_path;
511 ProcessParams::create()
523 fatal_if(!process,
"Unknown error creating process object.");
std::set< int > PIDs
Process set to track which PIDs have already been allocated.
#define fatal(...)
This implements a cprintf based fatal() function.
virtual void regStats()
Callback to set stat parameters.
static void output(const char *filename)
std::string tgtCwd
The cwd members are used to track changes to the current working directory for the purpose of executi...
std::vector< std::string > envp
virtual void activate()=0
Set the status to Active.
virtual Addr bias() const
bool write(const PortProxy &proxy) const
std::shared_ptr< FDArray > fds
Addr getPageBytes() const
Get the page bytes for the ISA.
std::vector< std::string > argv
ObjectFile * createObjectFile(const std::string &fname, bool raw)
std::vector< RedirectPath * > redirectPaths
EmulationPageTable * pTable
virtual MemoryImage buildImage() const =0
std::unique_ptr< SETranslatingPortProxy > initVirtMem
void unserialize(CheckpointIn &cp) override
Unserialize an object.
void unserialize(CheckpointIn &cp) override
Unserialize an object.
static std::string normalize(std::string &directory)
Stats::Scalar numSyscalls
@ Drained
Buffers drained, ready for serialization/handover.
void writeBlob(Addr addr, const void *p, int size) const
Same as tryWriteBlob, but insists on success.
void getMappings(std::vector< std::pair< Addr, Addr >> *addr_mappings)
void serialize(CheckpointOut &cp) const override
Serialize an object.
DrainState
Object drain/handover states.
::Loader::ObjectFile * getInterpreter()
void revokeThreadContext(int context_id)
After delegating a thread context to a child process no longer should relate to the ThreadContext.
EmulatedDriver is an abstract base class for fake SE-mode device drivers.
SymbolTable debugSymbolTable
Global unified debugging symbol table (for target).
T divCeil(const T &a, const U &b)
const SymbolTable & symtab() const
ThreadContext is the external interface to all thread state for anything outside of the CPU.
virtual void clone(ThreadContext *old_tc, ThreadContext *new_tc, Process *new_p, RegVal flags)
std::string checkPathRedirect(const std::string &filename)
Redirect file path if it matches any keys initialized by system object.
void allocateMem(Addr vaddr, int64_t size, bool clobber=false)
void init() override
init() is called after all C++ SimObjects have been created and all ports are connected.
static Process * tryLoaders(ProcessParams *params, ::Loader::ObjectFile *obj_file)
::Loader::MemoryImage image
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
::Loader::ObjectFile * objFile
Derived & name(const std::string &name)
Set the name and marks this stat to print at the end of simulation.
const Params * params() const
std::vector< ContextID > contextIds
::Loader::MemoryImage interpImage
std::vector< EmulatedDriver * > drivers
DrainState drain() override
Draining is the process of clearing out the states of SimObjects.These are the SimObjects that are pa...
virtual const std::string name() const
virtual PortProxy & getVirtProxy()=0
virtual ObjectFile * getInterpreter() const
virtual bool mmapGrowsDown() const
Does mmap region grow upward or downward from mmapEnd? Most platforms grow downward,...
std::string absolutePath(const std::string &path, bool host_fs)
Return an absolute path given a relative path paired with the current working directory of the proces...
Overload hash function for BasicBlockRange type.
bool startswith(const char *s, const char *prefix)
Return true if 's' starts with the prefix string 'prefix'.
void initState() override
initState() is called on each SimObject when not restoring from a checkpoint.
T roundUp(const T &val, const U &align)
This function is used to align addresses in memory.
bool map(Addr vaddr, Addr paddr, int size, bool cacheable=true)
Maps a contiguous range of virtual addresses in this process's address space to a contiguous range of...
std::ostream CheckpointOut
void replicatePage(Addr vaddr, Addr new_paddr, ThreadContext *old_tc, ThreadContext *new_tc, bool alloc_page)
Addr allocPhysPages(int npages)
Allocate npages contiguous unused physical pages.
bool fixupFault(Addr vaddr)
Attempt to fix up a fault at vaddr by allocating a page on the stack.
void regStats() override
Callback to set stat parameters.
#define fatal_if(cond,...)
Conditional fatal macro that checks the supplied condition and only causes a fatal error if the condi...
virtual void map(Addr vaddr, Addr paddr, int64_t size, uint64_t flags=0)
Maps a virtual memory region to a physical memory region.
Process(ProcessParams *params, EmulationPageTable *pTable, ::Loader::ObjectFile *obj_file)
Derived & desc(const std::string &_desc)
Set the description and marks this stat to print at the end of simulation.
void readBlob(Addr addr, void *p, int size) const
Higher level interfaces based on the above.
EmulatedDriver * findDriver(std::string filename)
Find an emulated device driver.
bool translate(Addr vaddr, Addr &paddr)
Translate function.
static std::stack< std::string > path
std::shared_ptr< MemState > memState
void serialize(CheckpointOut &cp) const override
Serialize an object.
Abstract superclass for simulation objects.
Generated on Wed Sep 30 2020 14:01:59 for gem5 by doxygen 1.8.17