Go to the documentation of this file.
61 #include "params/Process.hh"
80 static LoaderList loaders;
88 process_loaders().emplace_back(
this);
95 for (
auto &loader_it : process_loaders()) {
107 if (directory.back() !=
'/')
108 return directory +
'/';
133 "Number of system calls")
139 if (!ret_pair.second)
173 #define CLONE_FILES 0
176 #define CLONE_THREAD 0
179 #define CLONE_VFORK 0
200 for (
auto map : mappings) {
224 std::shared_ptr<FDArray> nfds = np->
fds;
225 for (
int tgt_fd = 0; tgt_fd <
fds->getSize(); tgt_fd++) {
226 std::shared_ptr<FDEntry> this_fde = (*fds)[tgt_fd];
228 nfds->setFDEntry(tgt_fd,
nullptr);
231 nfds->setFDEntry(tgt_fd, this_fde->clone());
233 auto this_hbfd = std::dynamic_pointer_cast<HBFDEntry>(this_fde);
237 int this_sim_fd = this_hbfd->getSimFD();
238 if (this_sim_fd <= 2)
241 int np_sim_fd = dup(this_sim_fd);
242 assert(np_sim_fd != -1);
244 auto nhbfd = std::dynamic_pointer_cast<HBFDEntry>((*nfds)[tgt_fd]);
245 nhbfd->setSimFD(np_sim_fd);
268 if (*it == context_id) {
273 warn(
"Unable to find thread context to revoke");
290 fatal(
"Process %s is not associated with any HW contexts!\n",
name());
311 fds->updateFileOffsets();
328 warn(
"Process::allocateMem: addr %#x already mapped\n",
vaddr);
376 warn(
"Checkpoints for pipes, device drivers and sockets do not work.");
384 fds->unserialize(cp);
389 warn(
"Checkpoints for pipes, device drivers and sockets do not work.");
409 if (
d->match(filename))
428 std::string tail = abs_path.substr(
path->appPath().size());
432 for (
auto host_path :
path->hostPaths()) {
433 if (access((host_path + tail).c_str(), R_OK) == 0) {
435 return host_path + tail;
441 return path->hostPaths()[0] + tail;
454 if (!interp || !interp->relocatable())
469 mmap_end =
mmapGrowsDown() ? ld_bias : mmap_end + interp_mapsize;
472 interp->updateBias(ld_bias);
500 if (filename.empty() ||
startswith(filename,
"/"))
506 auto path_base = std::string();
507 if (host_filesystem) {
519 auto absolute_path = path_base + filename;
521 return absolute_path;
525 ProcessParams::create()
const
529 const std::string &exec = (executable ==
"") ? cmd[0] : executable;
532 fatal_if(!obj_file,
"Cannot load object file %s.", exec);
535 fatal_if(!process,
"Unknown error creating process object.");
#define fatal(...)
This implements a cprintf based fatal() function.
static std::string normalize(const std::string &directory)
std::vector< EmulatedDriver * > drivers
std::set< int > PIDs
Process set to track which PIDs have already been allocated.
void writeBlob(Addr addr, const void *p, int size) const
Same as tryWriteBlob, but insists on success.
loader::MemoryImage interpImage
virtual void clone(ThreadContext *old_tc, ThreadContext *new_tc, Process *new_p, RegVal flags)
EmulatedDriver * findDriver(std::string filename)
Find an emulated device driver.
std::unique_ptr< SETranslatingPortProxy > initVirtMem
std::string tgtCwd
The cwd members are used to track changes to the current working directory for the purpose of executi...
statistics::Scalar numSyscalls
static void output(const char *filename)
static std::stack< std::string > path
void serialize(CheckpointOut &cp) const override
Serialize an object.
virtual ObjectFile * getInterpreter() const
void initState() override
initState() is called on each SimObject when not restoring from a checkpoint.
bool startswith(const char *s, const char *prefix)
Return true if 's' starts with the prefix string 'prefix'.
bool translate(Addr vaddr, Addr &paddr)
Translate function.
virtual ContextID contextId() const =0
virtual void activate()=0
Set the status to Active.
void getMappings(std::vector< std::pair< Addr, Addr >> *addr_mappings)
const Entry * lookup(Addr vaddr)
Lookup function.
std::shared_ptr< FDArray > fds
const SymbolTable & symtab() const
void serialize(CheckpointOut &cp) const override
Serialize an object.
std::shared_ptr< MemState > memState
void allocateMem(Addr vaddr, int64_t size, bool clobber=false)
bool fixupFault(Addr vaddr)
Attempt to fix up a fault at vaddr by allocating a page on the stack.
uint64_t childClearTID
Calls a futex wakeup at the address specified by this pointer when this process exits.
std::vector< RedirectPath * > redirectPaths
DrainState
Object drain/handover states.
static Process * tryLoaders(const ProcessParams ¶ms, loader::ObjectFile *obj_file)
ThreadContext is the external interface to all thread state for anything outside of the CPU.
void unserialize(CheckpointIn &cp) override
Unserialize an object.
virtual std::string name() const
virtual PortProxy & getVirtProxy()=0
const Params & params() const
#define ADD_STAT(n,...)
Convenience macro to add a stat to a statistics group.
EmulationPageTable * pTable
std::vector< std::string > argv
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...
virtual Addr bias() const
Process(const ProcessParams ¶ms, EmulationPageTable *pTable, loader::ObjectFile *obj_file)
std::string checkPathRedirect(const std::string &filename)
Redirect file path if it matches any keys initialized by system object.
void readBlob(Addr addr, void *p, int size) const
Higher level interfaces based on the above.
Abstract superclass for simulation objects.
@ Drained
Buffers drained, ready for serialization/handover.
void replicatePage(Addr vaddr, Addr new_paddr, ThreadContext *old_tc, ThreadContext *new_tc, bool alloc_page)
Addr allocPhysPages(int npages, int poolID=0)
Allocate npages contiguous unused physical pages.
loader::ObjectFile * getInterpreter()
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
std::vector< std::string > envp
ObjectFile * createObjectFile(const std::string &fname, bool raw)
static constexpr T divCeil(const T &a, const U &b)
EmulatedDriver is an abstract base class for fake SE-mode device drivers.
virtual void map(Addr vaddr, Addr paddr, int64_t size, uint64_t flags=0)
Maps a virtual memory region to a physical memory region.
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...
Overload hash function for BasicBlockRange type.
static constexpr T roundUp(const T &val, const U &align)
This function is used to align addresses in memory.
virtual bool mmapGrowsDown() const
Does mmap region grow upward or downward from mmapEnd? Most platforms grow downward,...
bool write(const PortProxy &proxy) const
void revokeThreadContext(int context_id)
After delegating a thread context to a child process no longer should relate to the ThreadContext.
void init() override
init() is called after all C++ SimObjects have been created and all ports are connected.
std::ostream CheckpointOut
std::vector< ContextID > contextIds
virtual MemoryImage buildImage() const =0
DrainState drain() override
Draining is the process of clearing out the states of SimObjects.These are the SimObjects that are pa...
SymbolTable debugSymbolTable
Global unified debugging symbol table (for target).
#define fatal_if(cond,...)
Conditional fatal macro that checks the supplied condition and only causes a fatal error if the condi...
Reference material can be found at the JEDEC website: UFS standard http://www.jedec....
std::vector< ContextID > vforkContexts
loader::MemoryImage image
loader::ObjectFile * objFile
void unserialize(CheckpointIn &cp) override
Unserialize an object.
Generated on Tue Sep 21 2021 12:24:36 for gem5 by doxygen 1.8.17