process.cc revision 11854
12SN/A/* 210298Salexandru.dutu@amd.com * Copyright (c) 2014 Advanced Micro Devices, Inc. 38852Sandreas.hansson@arm.com * Copyright (c) 2012 ARM Limited 48852Sandreas.hansson@arm.com * All rights reserved 58852Sandreas.hansson@arm.com * 68852Sandreas.hansson@arm.com * The license below extends only to copyright in the software and shall 78852Sandreas.hansson@arm.com * not be construed as granting a license to any other intellectual 88852Sandreas.hansson@arm.com * property including but not limited to intellectual property relating 98852Sandreas.hansson@arm.com * to a hardware implementation of the functionality of the software 108852Sandreas.hansson@arm.com * licensed hereunder. You may use the software subject to the license 118852Sandreas.hansson@arm.com * terms below provided that you ensure that this notice is replicated 128852Sandreas.hansson@arm.com * unmodified and in its entirety in all distributions of the software, 138852Sandreas.hansson@arm.com * modified or unmodified, in source code or in binary form. 148852Sandreas.hansson@arm.com * 151762SN/A * Copyright (c) 2001-2005 The Regents of The University of Michigan 162SN/A * All rights reserved. 172SN/A * 182SN/A * Redistribution and use in source and binary forms, with or without 192SN/A * modification, are permitted provided that the following conditions are 202SN/A * met: redistributions of source code must retain the above copyright 212SN/A * notice, this list of conditions and the following disclaimer; 222SN/A * redistributions in binary form must reproduce the above copyright 232SN/A * notice, this list of conditions and the following disclaimer in the 242SN/A * documentation and/or other materials provided with the distribution; 252SN/A * neither the name of the copyright holders nor the names of its 262SN/A * contributors may be used to endorse or promote products derived from 272SN/A * this software without specific prior written permission. 282SN/A * 292SN/A * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 302SN/A * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 312SN/A * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 322SN/A * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 332SN/A * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 342SN/A * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 352SN/A * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 362SN/A * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 372SN/A * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 382SN/A * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 392SN/A * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 402665Ssaidi@eecs.umich.edu * 412665Ssaidi@eecs.umich.edu * Authors: Nathan Binkert 422665Ssaidi@eecs.umich.edu * Steve Reinhardt 432665Ssaidi@eecs.umich.edu * Ali Saidi 442SN/A */ 452SN/A 4611793Sbrandon.potter@amd.com#include "sim/process.hh" 4711793Sbrandon.potter@amd.com 488229Snate@binkert.org#include <fcntl.h> 492SN/A#include <unistd.h> 506712Snate@binkert.org 5111800Sbrandon.potter@amd.com#include <array> 5210930Sbrandon.potter@amd.com#include <map> 532SN/A#include <string> 5411800Sbrandon.potter@amd.com#include <vector> 552SN/A 5611793Sbrandon.potter@amd.com#include "base/intmath.hh" 5756SN/A#include "base/loader/object_file.hh" 581158SN/A#include "base/loader/symtab.hh" 59146SN/A#include "base/statistics.hh" 606658Snate@binkert.org#include "config/the_isa.hh" 612680Sktlim@umich.edu#include "cpu/thread_context.hh" 622378SN/A#include "mem/page_table.hh" 638706Sandreas.hansson@arm.com#include "mem/se_translating_port_proxy.hh" 645154Sgblack@eecs.umich.edu#include "params/Process.hh" 6511800Sbrandon.potter@amd.com#include "sim/emul_driver.hh" 6611794Sbrandon.potter@amd.com#include "sim/syscall_desc.hh" 672378SN/A#include "sim/system.hh" 682SN/A 692715Sstever@eecs.umich.edu#if THE_ISA == ALPHA_ISA 702715Sstever@eecs.umich.edu#include "arch/alpha/linux/process.hh" 712715Sstever@eecs.umich.edu#elif THE_ISA == SPARC_ISA 722715Sstever@eecs.umich.edu#include "arch/sparc/linux/process.hh" 732715Sstever@eecs.umich.edu#include "arch/sparc/solaris/process.hh" 742715Sstever@eecs.umich.edu#elif THE_ISA == MIPS_ISA 752715Sstever@eecs.umich.edu#include "arch/mips/linux/process.hh" 765335Shines@cs.fsu.edu#elif THE_ISA == ARM_ISA 775335Shines@cs.fsu.edu#include "arch/arm/linux/process.hh" 7810810Sbr@bsdpad.com#include "arch/arm/freebsd/process.hh" 794157Sgblack@eecs.umich.edu#elif THE_ISA == X86_ISA 804166Sgblack@eecs.umich.edu#include "arch/x86/linux/process.hh" 816691Stjones1@inf.ed.ac.uk#elif THE_ISA == POWER_ISA 826691Stjones1@inf.ed.ac.uk#include "arch/power/linux/process.hh" 8311723Sar4jc@virginia.edu#elif THE_ISA == RISCV_ISA 8411723Sar4jc@virginia.edu#include "arch/riscv/linux/process.hh" 852715Sstever@eecs.umich.edu#else 862715Sstever@eecs.umich.edu#error "THE_ISA not set" 872715Sstever@eecs.umich.edu#endif 882715Sstever@eecs.umich.edu 892715Sstever@eecs.umich.edu 902SN/Ausing namespace std; 912107SN/Ausing namespace TheISA; 922SN/A 932SN/A// current number of allocated processes 942SN/Aint num_processes = 0; 952SN/A 9610930Sbrandon.potter@amd.comstatic int 9710930Sbrandon.potter@amd.comopenFile(const string& filename, int flags, mode_t mode) 9810930Sbrandon.potter@amd.com{ 9910930Sbrandon.potter@amd.com int sim_fd = open(filename.c_str(), flags, mode); 10010930Sbrandon.potter@amd.com if (sim_fd != -1) 10110930Sbrandon.potter@amd.com return sim_fd; 10210930Sbrandon.potter@amd.com fatal("Unable to open %s with mode %O", filename, mode); 10310930Sbrandon.potter@amd.com} 10410930Sbrandon.potter@amd.com 10510930Sbrandon.potter@amd.comstatic int 10610930Sbrandon.potter@amd.comopenInputFile(const string &filename) 10710930Sbrandon.potter@amd.com{ 10810930Sbrandon.potter@amd.com return openFile(filename, O_RDONLY, 0); 10910930Sbrandon.potter@amd.com} 11010930Sbrandon.potter@amd.com 11110930Sbrandon.potter@amd.comstatic int 11210930Sbrandon.potter@amd.comopenOutputFile(const string &filename) 11310930Sbrandon.potter@amd.com{ 11410930Sbrandon.potter@amd.com return openFile(filename, O_WRONLY | O_CREAT | O_TRUNC, 0664); 11510930Sbrandon.potter@amd.com} 11610930Sbrandon.potter@amd.com 11711851Sbrandon.potter@amd.comProcess::Process(ProcessParams * params, ObjectFile * obj_file) 1187532Ssteve.reinhardt@amd.com : SimObject(params), system(params->system), 11910559Sandreas.hansson@arm.com brk_point(0), stack_base(0), stack_size(0), stack_min(0), 1208852Sandreas.hansson@arm.com max_stack_size(params->max_stack_size), 12110559Sandreas.hansson@arm.com next_thread_stack_base(0), 12210299Salexandru.dutu@amd.com useArchPT(params->useArchPT), 12310554Salexandru.dutu@amd.com kvmInSE(params->kvmInSE), 12410299Salexandru.dutu@amd.com pTable(useArchPT ? 12511813Sbaz21@cam.ac.uk static_cast<PageTableBase *>(new ArchPageTable(name(), params->pid, 12611813Sbaz21@cam.ac.uk system)) : 12711813Sbaz21@cam.ac.uk static_cast<PageTableBase *>(new FuncPageTable(name(), params->pid))), 1288852Sandreas.hansson@arm.com initVirtMem(system->getSystemPort(), this, 12910929Sbrandon.potter@amd.com SETranslatingPortProxy::Always), 13010930Sbrandon.potter@amd.com fd_array(make_shared<array<FDEntry, NUM_FDS>>()), 13110930Sbrandon.potter@amd.com imap {{"", -1}, 13210930Sbrandon.potter@amd.com {"cin", STDIN_FILENO}, 13310930Sbrandon.potter@amd.com {"stdin", STDIN_FILENO}}, 13410930Sbrandon.potter@amd.com oemap{{"", -1}, 13510930Sbrandon.potter@amd.com {"cout", STDOUT_FILENO}, 13610930Sbrandon.potter@amd.com {"stdout", STDOUT_FILENO}, 13710930Sbrandon.potter@amd.com {"cerr", STDERR_FILENO}, 13811801Sbrandon.potter@amd.com {"stderr", STDERR_FILENO}}, 13911851Sbrandon.potter@amd.com objFile(obj_file), 14011851Sbrandon.potter@amd.com argv(params->cmd), envp(params->env), cwd(params->cwd), 14111851Sbrandon.potter@amd.com executable(params->executable), 14211801Sbrandon.potter@amd.com _uid(params->uid), _euid(params->euid), 14311801Sbrandon.potter@amd.com _gid(params->gid), _egid(params->egid), 14411851Sbrandon.potter@amd.com _pid(params->pid), _ppid(params->ppid), 14511851Sbrandon.potter@amd.com drivers(params->drivers) 1462SN/A{ 14710930Sbrandon.potter@amd.com int sim_fd; 14810930Sbrandon.potter@amd.com std::map<string,int>::iterator it; 1495154Sgblack@eecs.umich.edu 15010930Sbrandon.potter@amd.com // Search through the input options and set fd if match is found; 15110930Sbrandon.potter@amd.com // otherwise, open an input file and seek to location. 15210932Sbrandon.potter@amd.com FDEntry *fde_stdin = getFDEntry(STDIN_FILENO); 15310930Sbrandon.potter@amd.com if ((it = imap.find(params->input)) != imap.end()) 15410930Sbrandon.potter@amd.com sim_fd = it->second; 15510930Sbrandon.potter@amd.com else 15610930Sbrandon.potter@amd.com sim_fd = openInputFile(params->input); 15710930Sbrandon.potter@amd.com fde_stdin->set(sim_fd, params->input, O_RDONLY, -1, false); 1585154Sgblack@eecs.umich.edu 15910930Sbrandon.potter@amd.com // Search through the output/error options and set fd if match is found; 16010930Sbrandon.potter@amd.com // otherwise, open an output file and seek to location. 16110932Sbrandon.potter@amd.com FDEntry *fde_stdout = getFDEntry(STDOUT_FILENO); 16210930Sbrandon.potter@amd.com if ((it = oemap.find(params->output)) != oemap.end()) 16310930Sbrandon.potter@amd.com sim_fd = it->second; 1645154Sgblack@eecs.umich.edu else 16510930Sbrandon.potter@amd.com sim_fd = openOutputFile(params->output); 16610930Sbrandon.potter@amd.com fde_stdout->set(sim_fd, params->output, O_WRONLY | O_CREAT | O_TRUNC, 16710930Sbrandon.potter@amd.com 0664, false); 1685154Sgblack@eecs.umich.edu 16910932Sbrandon.potter@amd.com FDEntry *fde_stderr = getFDEntry(STDERR_FILENO); 17010930Sbrandon.potter@amd.com if (params->output == params->errout) 17110930Sbrandon.potter@amd.com // Reuse the same file descriptor if these match. 17210930Sbrandon.potter@amd.com sim_fd = fde_stdout->fd; 17310930Sbrandon.potter@amd.com else if ((it = oemap.find(params->errout)) != oemap.end()) 17410930Sbrandon.potter@amd.com sim_fd = it->second; 1755154Sgblack@eecs.umich.edu else 17610930Sbrandon.potter@amd.com sim_fd = openOutputFile(params->errout); 17710930Sbrandon.potter@amd.com fde_stderr->set(sim_fd, params->errout, O_WRONLY | O_CREAT | O_TRUNC, 17810930Sbrandon.potter@amd.com 0664, false); 1792SN/A 18011386Ssteve.reinhardt@amd.com mmap_end = 0; 1812SN/A // other parameters will be initialized when the program is loaded 18211851Sbrandon.potter@amd.com 18311851Sbrandon.potter@amd.com // load up symbols, if any... these may be used for debugging or 18411851Sbrandon.potter@amd.com // profiling. 18511851Sbrandon.potter@amd.com if (!debugSymbolTable) { 18611851Sbrandon.potter@amd.com debugSymbolTable = new SymbolTable(); 18711851Sbrandon.potter@amd.com if (!objFile->loadGlobalSymbols(debugSymbolTable) || 18811851Sbrandon.potter@amd.com !objFile->loadLocalSymbols(debugSymbolTable) || 18911851Sbrandon.potter@amd.com !objFile->loadWeakSymbols(debugSymbolTable)) { 19011851Sbrandon.potter@amd.com // didn't load any symbols 19111851Sbrandon.potter@amd.com delete debugSymbolTable; 19211851Sbrandon.potter@amd.com debugSymbolTable = NULL; 19311851Sbrandon.potter@amd.com } 19411851Sbrandon.potter@amd.com } 1952SN/A} 1962SN/A 1972SN/Avoid 1982SN/AProcess::regStats() 1992SN/A{ 20011522Sstephan.diestelhorst@arm.com SimObject::regStats(); 20111522Sstephan.diestelhorst@arm.com 202729SN/A using namespace Stats; 2032SN/A 2042SN/A num_syscalls 2058240Snate@binkert.org .name(name() + ".num_syscalls") 2062SN/A .desc("Number of system calls") 2072SN/A ; 2082SN/A} 2092SN/A 21010930Sbrandon.potter@amd.comvoid 21110932Sbrandon.potter@amd.comProcess::inheritFDArray(Process *p) 2122SN/A{ 21310930Sbrandon.potter@amd.com fd_array = p->fd_array; 2142SN/A} 2152SN/A 2165713Shsul@eecs.umich.eduThreadContext * 2175713Shsul@eecs.umich.eduProcess::findFreeContext() 2182SN/A{ 21910929Sbrandon.potter@amd.com for (int id : contextIds) { 22010929Sbrandon.potter@amd.com ThreadContext *tc = system->getThreadContext(id); 22110929Sbrandon.potter@amd.com if (tc->status() == ThreadContext::Halted) 2225713Shsul@eecs.umich.edu return tc; 2235512SMichael.Adler@intel.com } 2245713Shsul@eecs.umich.edu return NULL; 2252SN/A} 2262SN/A 2271395SN/Avoid 2287532Ssteve.reinhardt@amd.comProcess::initState() 2291395SN/A{ 2305713Shsul@eecs.umich.edu if (contextIds.empty()) 2315713Shsul@eecs.umich.edu fatal("Process %s is not associated with any HW contexts!\n", name()); 2322378SN/A 2332680Sktlim@umich.edu // first thread context for this process... initialize & enable 2345713Shsul@eecs.umich.edu ThreadContext *tc = system->getThreadContext(contextIds[0]); 2351395SN/A 2361634SN/A // mark this context as active so it will start ticking. 23710407Smitch.hayenga@arm.com tc->activate(); 23810298Salexandru.dutu@amd.com 23910298Salexandru.dutu@amd.com pTable->initState(tc); 2401395SN/A} 2412SN/A 24210913Sandreas.sandberg@arm.comDrainState 24310913Sandreas.sandberg@arm.comProcess::drain() 24410905Sandreas.sandberg@arm.com{ 24510932Sbrandon.potter@amd.com findFileOffsets(); 24610913Sandreas.sandberg@arm.com return DrainState::Drained; 24710905Sandreas.sandberg@arm.com} 24810905Sandreas.sandberg@arm.com 2492SN/Aint 25010932Sbrandon.potter@amd.comProcess::allocFD(int sim_fd, const string& filename, int flags, int mode, 25110932Sbrandon.potter@amd.com bool pipe) 2522SN/A{ 25310930Sbrandon.potter@amd.com for (int free_fd = 0; free_fd < fd_array->size(); free_fd++) { 25410932Sbrandon.potter@amd.com FDEntry *fde = getFDEntry(free_fd); 25510930Sbrandon.potter@amd.com if (fde->isFree()) { 25610930Sbrandon.potter@amd.com fde->set(sim_fd, filename, flags, mode, pipe); 2571970SN/A return free_fd; 2581970SN/A } 2592SN/A } 2602SN/A 26110930Sbrandon.potter@amd.com fatal("Out of target file descriptors"); 2621970SN/A} 2632SN/A 2641970SN/Avoid 26510932Sbrandon.potter@amd.comProcess::resetFDEntry(int tgt_fd) 2661970SN/A{ 26710932Sbrandon.potter@amd.com FDEntry *fde = getFDEntry(tgt_fd); 26810930Sbrandon.potter@amd.com assert(fde->fd > -1); 2691970SN/A 27010930Sbrandon.potter@amd.com fde->reset(); 2712SN/A} 2722SN/A 2732SN/Aint 27410932Sbrandon.potter@amd.comProcess::getSimFD(int tgt_fd) 2752SN/A{ 27610932Sbrandon.potter@amd.com FDEntry *entry = getFDEntry(tgt_fd); 27710930Sbrandon.potter@amd.com return entry ? entry->fd : -1; 2782SN/A} 2792SN/A 28010930Sbrandon.potter@amd.comFDEntry * 28110932Sbrandon.potter@amd.comProcess::getFDEntry(int tgt_fd) 2825282Srstrong@cs.ucsd.edu{ 28310930Sbrandon.potter@amd.com assert(0 <= tgt_fd && tgt_fd < fd_array->size()); 28410930Sbrandon.potter@amd.com return &(*fd_array)[tgt_fd]; 28510929Sbrandon.potter@amd.com} 2865282Srstrong@cs.ucsd.edu 28710929Sbrandon.potter@amd.comint 28810932Sbrandon.potter@amd.comProcess::getTgtFD(int sim_fd) 28910929Sbrandon.potter@amd.com{ 29010930Sbrandon.potter@amd.com for (int index = 0; index < fd_array->size(); index++) 29110930Sbrandon.potter@amd.com if ((*fd_array)[index].fd == sim_fd) 29210929Sbrandon.potter@amd.com return index; 29310929Sbrandon.potter@amd.com return -1; 2945282Srstrong@cs.ucsd.edu} 2957487Ssteve.reinhardt@amd.com 2968601Ssteve.reinhardt@amd.comvoid 2978601Ssteve.reinhardt@amd.comProcess::allocateMem(Addr vaddr, int64_t size, bool clobber) 2988601Ssteve.reinhardt@amd.com{ 29910318Sandreas.hansson@arm.com int npages = divCeil(size, (int64_t)PageBytes); 3008601Ssteve.reinhardt@amd.com Addr paddr = system->allocPhysPages(npages); 30111294Sandreas.hansson@arm.com pTable->map(vaddr, paddr, size, 30211294Sandreas.hansson@arm.com clobber ? PageTableBase::Clobber : PageTableBase::Zero); 3038601Ssteve.reinhardt@amd.com} 3048601Ssteve.reinhardt@amd.com 3054434Ssaidi@eecs.umich.edubool 3068539Sgblack@eecs.umich.eduProcess::fixupStackFault(Addr vaddr) 3074434Ssaidi@eecs.umich.edu{ 3088539Sgblack@eecs.umich.edu // Check if this is already on the stack and there's just no page there 3098539Sgblack@eecs.umich.edu // yet. 3104434Ssaidi@eecs.umich.edu if (vaddr >= stack_min && vaddr < stack_base) { 31110318Sandreas.hansson@arm.com allocateMem(roundDown(vaddr, PageBytes), PageBytes); 3124434Ssaidi@eecs.umich.edu return true; 3134434Ssaidi@eecs.umich.edu } 3144434Ssaidi@eecs.umich.edu 3158539Sgblack@eecs.umich.edu // We've accessed the next page of the stack, so extend it to include 3168539Sgblack@eecs.umich.edu // this address. 3175154Sgblack@eecs.umich.edu if (vaddr < stack_min && vaddr >= stack_base - max_stack_size) { 3185154Sgblack@eecs.umich.edu while (vaddr < stack_min) { 3195154Sgblack@eecs.umich.edu stack_min -= TheISA::PageBytes; 3208539Sgblack@eecs.umich.edu if (stack_base - stack_min > max_stack_size) 3215154Sgblack@eecs.umich.edu fatal("Maximum stack size exceeded\n"); 3228601Ssteve.reinhardt@amd.com allocateMem(stack_min, TheISA::PageBytes); 3235823Ssaidi@eecs.umich.edu inform("Increasing stack size by one page."); 3245154Sgblack@eecs.umich.edu }; 3254434Ssaidi@eecs.umich.edu return true; 3264434Ssaidi@eecs.umich.edu } 3274434Ssaidi@eecs.umich.edu return false; 3284434Ssaidi@eecs.umich.edu} 3294434Ssaidi@eecs.umich.edu 3305282Srstrong@cs.ucsd.eduvoid 33110932Sbrandon.potter@amd.comProcess::fixFileOffsets() 3327487Ssteve.reinhardt@amd.com{ 33310930Sbrandon.potter@amd.com auto seek = [] (FDEntry *fde) 33410930Sbrandon.potter@amd.com { 33510930Sbrandon.potter@amd.com if (lseek(fde->fd, fde->fileOffset, SEEK_SET) < 0) 33610930Sbrandon.potter@amd.com fatal("Unable to see to location in %s", fde->filename); 33710930Sbrandon.potter@amd.com }; 3385282Srstrong@cs.ucsd.edu 33910930Sbrandon.potter@amd.com std::map<string,int>::iterator it; 3405282Srstrong@cs.ucsd.edu 34110930Sbrandon.potter@amd.com // Search through the input options and set fd if match is found; 34210930Sbrandon.potter@amd.com // otherwise, open an input file and seek to location. 34310932Sbrandon.potter@amd.com FDEntry *fde_stdin = getFDEntry(STDIN_FILENO); 34411785Sjthestness@gmail.com 34511785Sjthestness@gmail.com // Check if user has specified a different input file, and if so, use it 34611785Sjthestness@gmail.com // instead of the file specified in the checkpoint. This also resets the 34711785Sjthestness@gmail.com // file offset from the checkpointed value 34811785Sjthestness@gmail.com string new_in = ((ProcessParams*)params())->input; 34911785Sjthestness@gmail.com if (new_in != fde_stdin->filename) { 35011785Sjthestness@gmail.com warn("Using new input file (%s) rather than checkpointed (%s)\n", 35111785Sjthestness@gmail.com new_in, fde_stdin->filename); 35211785Sjthestness@gmail.com fde_stdin->filename = new_in; 35311785Sjthestness@gmail.com fde_stdin->fileOffset = 0; 35411785Sjthestness@gmail.com } 35511785Sjthestness@gmail.com 35610930Sbrandon.potter@amd.com if ((it = imap.find(fde_stdin->filename)) != imap.end()) { 35710930Sbrandon.potter@amd.com fde_stdin->fd = it->second; 35810930Sbrandon.potter@amd.com } else { 35910930Sbrandon.potter@amd.com fde_stdin->fd = openInputFile(fde_stdin->filename); 36010930Sbrandon.potter@amd.com seek(fde_stdin); 3615282Srstrong@cs.ucsd.edu } 3625282Srstrong@cs.ucsd.edu 36310930Sbrandon.potter@amd.com // Search through the output/error options and set fd if match is found; 36410930Sbrandon.potter@amd.com // otherwise, open an output file and seek to location. 36510932Sbrandon.potter@amd.com FDEntry *fde_stdout = getFDEntry(STDOUT_FILENO); 36611785Sjthestness@gmail.com 36711785Sjthestness@gmail.com // Check if user has specified a different output file, and if so, use it 36811785Sjthestness@gmail.com // instead of the file specified in the checkpoint. This also resets the 36911785Sjthestness@gmail.com // file offset from the checkpointed value 37011785Sjthestness@gmail.com string new_out = ((ProcessParams*)params())->output; 37111785Sjthestness@gmail.com if (new_out != fde_stdout->filename) { 37211785Sjthestness@gmail.com warn("Using new output file (%s) rather than checkpointed (%s)\n", 37311785Sjthestness@gmail.com new_out, fde_stdout->filename); 37411785Sjthestness@gmail.com fde_stdout->filename = new_out; 37511785Sjthestness@gmail.com fde_stdout->fileOffset = 0; 37611785Sjthestness@gmail.com } 37711785Sjthestness@gmail.com 37810930Sbrandon.potter@amd.com if ((it = oemap.find(fde_stdout->filename)) != oemap.end()) { 37910930Sbrandon.potter@amd.com fde_stdout->fd = it->second; 38010930Sbrandon.potter@amd.com } else { 38110930Sbrandon.potter@amd.com fde_stdout->fd = openOutputFile(fde_stdout->filename); 38210930Sbrandon.potter@amd.com seek(fde_stdout); 3835282Srstrong@cs.ucsd.edu } 3845282Srstrong@cs.ucsd.edu 38510932Sbrandon.potter@amd.com FDEntry *fde_stderr = getFDEntry(STDERR_FILENO); 38611785Sjthestness@gmail.com 38711785Sjthestness@gmail.com // Check if user has specified a different error file, and if so, use it 38811785Sjthestness@gmail.com // instead of the file specified in the checkpoint. This also resets the 38911785Sjthestness@gmail.com // file offset from the checkpointed value 39011785Sjthestness@gmail.com string new_err = ((ProcessParams*)params())->errout; 39111785Sjthestness@gmail.com if (new_err != fde_stderr->filename) { 39211785Sjthestness@gmail.com warn("Using new error file (%s) rather than checkpointed (%s)\n", 39311785Sjthestness@gmail.com new_err, fde_stderr->filename); 39411785Sjthestness@gmail.com fde_stderr->filename = new_err; 39511785Sjthestness@gmail.com fde_stderr->fileOffset = 0; 39611785Sjthestness@gmail.com } 39711785Sjthestness@gmail.com 39810930Sbrandon.potter@amd.com if (fde_stdout->filename == fde_stderr->filename) { 39910930Sbrandon.potter@amd.com // Reuse the same file descriptor if these match. 40010930Sbrandon.potter@amd.com fde_stderr->fd = fde_stdout->fd; 40110930Sbrandon.potter@amd.com } else if ((it = oemap.find(fde_stderr->filename)) != oemap.end()) { 40210930Sbrandon.potter@amd.com fde_stderr->fd = it->second; 40310930Sbrandon.potter@amd.com } else { 40410930Sbrandon.potter@amd.com fde_stderr->fd = openOutputFile(fde_stderr->filename); 40510930Sbrandon.potter@amd.com seek(fde_stderr); 4065514SMichael.Adler@intel.com } 4075282Srstrong@cs.ucsd.edu 40810930Sbrandon.potter@amd.com for (int tgt_fd = 3; tgt_fd < fd_array->size(); tgt_fd++) { 40910932Sbrandon.potter@amd.com FDEntry *fde = getFDEntry(tgt_fd); 41010930Sbrandon.potter@amd.com if (fde->fd == -1) 41110930Sbrandon.potter@amd.com continue; 4125282Srstrong@cs.ucsd.edu 41310930Sbrandon.potter@amd.com if (fde->isPipe) { 41410930Sbrandon.potter@amd.com if (fde->filename == "PIPE-WRITE") 41510930Sbrandon.potter@amd.com continue; 41610930Sbrandon.potter@amd.com assert(fde->filename == "PIPE-READ"); 4175282Srstrong@cs.ucsd.edu 41810930Sbrandon.potter@amd.com int fds[2]; 41910930Sbrandon.potter@amd.com if (pipe(fds) < 0) 42010930Sbrandon.potter@amd.com fatal("Unable to create new pipe"); 4215282Srstrong@cs.ucsd.edu 42210930Sbrandon.potter@amd.com fde->fd = fds[0]; 4235282Srstrong@cs.ucsd.edu 42410932Sbrandon.potter@amd.com FDEntry *fde_write = getFDEntry(fde->readPipeSource); 42511378Sbrandon.potter@amd.com assert(fde_write->filename == "PIPE-WRITE"); 42610930Sbrandon.potter@amd.com fde_write->fd = fds[1]; 42710930Sbrandon.potter@amd.com } else { 42810930Sbrandon.potter@amd.com fde->fd = openFile(fde->filename.c_str(), fde->flags, fde->mode); 42910930Sbrandon.potter@amd.com seek(fde); 4305282Srstrong@cs.ucsd.edu } 4315282Srstrong@cs.ucsd.edu } 4325282Srstrong@cs.ucsd.edu} 4337487Ssteve.reinhardt@amd.com 4345282Srstrong@cs.ucsd.eduvoid 43510932Sbrandon.potter@amd.comProcess::findFileOffsets() 4367487Ssteve.reinhardt@amd.com{ 43710930Sbrandon.potter@amd.com for (auto& fde : *fd_array) { 43810930Sbrandon.potter@amd.com if (fde.fd != -1) 43910930Sbrandon.potter@amd.com fde.fileOffset = lseek(fde.fd, 0, SEEK_CUR); 4405282Srstrong@cs.ucsd.edu } 4415282Srstrong@cs.ucsd.edu} 4425282Srstrong@cs.ucsd.edu 4435282Srstrong@cs.ucsd.eduvoid 4447487Ssteve.reinhardt@amd.comProcess::setReadPipeSource(int read_pipe_fd, int source_fd) 4457487Ssteve.reinhardt@amd.com{ 44610932Sbrandon.potter@amd.com FDEntry *fde = getFDEntry(read_pipe_fd); 44710930Sbrandon.potter@amd.com assert(source_fd >= -1); 44810930Sbrandon.potter@amd.com fde->readPipeSource = source_fd; 4495282Srstrong@cs.ucsd.edu} 4505282Srstrong@cs.ucsd.edu 4513311Ssaidi@eecs.umich.eduvoid 45210905Sandreas.sandberg@arm.comProcess::serialize(CheckpointOut &cp) const 4533311Ssaidi@eecs.umich.edu{ 4543311Ssaidi@eecs.umich.edu SERIALIZE_SCALAR(brk_point); 4553311Ssaidi@eecs.umich.edu SERIALIZE_SCALAR(stack_base); 4563311Ssaidi@eecs.umich.edu SERIALIZE_SCALAR(stack_size); 4573311Ssaidi@eecs.umich.edu SERIALIZE_SCALAR(stack_min); 4583311Ssaidi@eecs.umich.edu SERIALIZE_SCALAR(next_thread_stack_base); 4593311Ssaidi@eecs.umich.edu SERIALIZE_SCALAR(mmap_end); 46010905Sandreas.sandberg@arm.com pTable->serialize(cp); 46110930Sbrandon.potter@amd.com for (int x = 0; x < fd_array->size(); x++) { 46210930Sbrandon.potter@amd.com (*fd_array)[x].serializeSection(cp, csprintf("FDEntry%d", x)); 4635282Srstrong@cs.ucsd.edu } 4643311Ssaidi@eecs.umich.edu 4653311Ssaidi@eecs.umich.edu} 4663311Ssaidi@eecs.umich.edu 4673311Ssaidi@eecs.umich.eduvoid 46810905Sandreas.sandberg@arm.comProcess::unserialize(CheckpointIn &cp) 4693311Ssaidi@eecs.umich.edu{ 4703311Ssaidi@eecs.umich.edu UNSERIALIZE_SCALAR(brk_point); 4713311Ssaidi@eecs.umich.edu UNSERIALIZE_SCALAR(stack_base); 4723311Ssaidi@eecs.umich.edu UNSERIALIZE_SCALAR(stack_size); 4733311Ssaidi@eecs.umich.edu UNSERIALIZE_SCALAR(stack_min); 4743311Ssaidi@eecs.umich.edu UNSERIALIZE_SCALAR(next_thread_stack_base); 4753311Ssaidi@eecs.umich.edu UNSERIALIZE_SCALAR(mmap_end); 47610905Sandreas.sandberg@arm.com pTable->unserialize(cp); 47710930Sbrandon.potter@amd.com for (int x = 0; x < fd_array->size(); x++) { 47810932Sbrandon.potter@amd.com FDEntry *fde = getFDEntry(x); 47910930Sbrandon.potter@amd.com fde->unserializeSection(cp, csprintf("FDEntry%d", x)); 4807487Ssteve.reinhardt@amd.com } 48110932Sbrandon.potter@amd.com fixFileOffsets(); 4826820SLisa.Hsu@amd.com // The above returns a bool so that you could do something if you don't 4836820SLisa.Hsu@amd.com // find the param in the checkpoint if you wanted to, like set a default 48410930Sbrandon.potter@amd.com // but in this case we'll just stick with the instantiated value if not 48510929Sbrandon.potter@amd.com // found. 4863311Ssaidi@eecs.umich.edu} 4872SN/A 4889110Ssteve.reinhardt@amd.combool 48910558Salexandru.dutu@amd.comProcess::map(Addr vaddr, Addr paddr, int size, bool cacheable) 4909110Ssteve.reinhardt@amd.com{ 49110558Salexandru.dutu@amd.com pTable->map(vaddr, paddr, size, 49211294Sandreas.hansson@arm.com cacheable ? PageTableBase::Zero : PageTableBase::Uncacheable); 4939110Ssteve.reinhardt@amd.com return true; 4949110Ssteve.reinhardt@amd.com} 4959110Ssteve.reinhardt@amd.com 4962378SN/Avoid 49711851Sbrandon.potter@amd.comProcess::syscall(int64_t callnum, ThreadContext *tc) 4982093SN/A{ 4992093SN/A num_syscalls++; 5002093SN/A 5012093SN/A SyscallDesc *desc = getDesc(callnum); 5022093SN/A if (desc == NULL) 5032093SN/A fatal("Syscall %d out of range", callnum); 5042093SN/A 5052680Sktlim@umich.edu desc->doSyscall(callnum, this, tc); 5062093SN/A} 5072SN/A 5086701Sgblack@eecs.umich.eduIntReg 50911851Sbrandon.potter@amd.comProcess::getSyscallArg(ThreadContext *tc, int &i, int width) 5106701Sgblack@eecs.umich.edu{ 5116701Sgblack@eecs.umich.edu return getSyscallArg(tc, i); 5126701Sgblack@eecs.umich.edu} 5136701Sgblack@eecs.umich.edu 51410496Ssteve.reinhardt@amd.comEmulatedDriver * 51511851Sbrandon.potter@amd.comProcess::findDriver(std::string filename) 51610496Ssteve.reinhardt@amd.com{ 51710496Ssteve.reinhardt@amd.com for (EmulatedDriver *d : drivers) { 51810496Ssteve.reinhardt@amd.com if (d->match(filename)) 51910496Ssteve.reinhardt@amd.com return d; 52010496Ssteve.reinhardt@amd.com } 52110496Ssteve.reinhardt@amd.com 52210496Ssteve.reinhardt@amd.com return NULL; 52310496Ssteve.reinhardt@amd.com} 52410496Ssteve.reinhardt@amd.com 52511389Sbrandon.potter@amd.comvoid 52611851Sbrandon.potter@amd.comProcess::updateBias() 52711389Sbrandon.potter@amd.com{ 52811389Sbrandon.potter@amd.com ObjectFile *interp = objFile->getInterpreter(); 52911389Sbrandon.potter@amd.com 53011389Sbrandon.potter@amd.com if (!interp || !interp->relocatable()) 53111389Sbrandon.potter@amd.com return; 53211389Sbrandon.potter@amd.com 53311389Sbrandon.potter@amd.com // Determine how large the interpreters footprint will be in the process 53411389Sbrandon.potter@amd.com // address space. 53511389Sbrandon.potter@amd.com Addr interp_mapsize = roundUp(interp->mapSize(), TheISA::PageBytes); 53611389Sbrandon.potter@amd.com 53711389Sbrandon.potter@amd.com // We are allocating the memory area; set the bias to the lowest address 53811389Sbrandon.potter@amd.com // in the allocated memory region. 53911389Sbrandon.potter@amd.com Addr ld_bias = mmapGrowsDown() ? mmap_end - interp_mapsize : mmap_end; 54011389Sbrandon.potter@amd.com 54111389Sbrandon.potter@amd.com // Adjust the process mmap area to give the interpreter room; the real 54211389Sbrandon.potter@amd.com // execve system call would just invoke the kernel's internal mmap 54311389Sbrandon.potter@amd.com // functions to make these adjustments. 54411389Sbrandon.potter@amd.com mmap_end = mmapGrowsDown() ? ld_bias : mmap_end + interp_mapsize; 54511389Sbrandon.potter@amd.com 54611389Sbrandon.potter@amd.com interp->updateBias(ld_bias); 54711389Sbrandon.potter@amd.com} 54811389Sbrandon.potter@amd.com 54911392Sbrandon.potter@amd.comObjectFile * 55011851Sbrandon.potter@amd.comProcess::getInterpreter() 55111392Sbrandon.potter@amd.com{ 55211392Sbrandon.potter@amd.com return objFile->getInterpreter(); 55311392Sbrandon.potter@amd.com} 55411392Sbrandon.potter@amd.com 55511389Sbrandon.potter@amd.comAddr 55611851Sbrandon.potter@amd.comProcess::getBias() 55711389Sbrandon.potter@amd.com{ 55811392Sbrandon.potter@amd.com ObjectFile *interp = getInterpreter(); 55911389Sbrandon.potter@amd.com 56011389Sbrandon.potter@amd.com return interp ? interp->bias() : objFile->bias(); 56111389Sbrandon.potter@amd.com} 56211389Sbrandon.potter@amd.com 56311389Sbrandon.potter@amd.comAddr 56411851Sbrandon.potter@amd.comProcess::getStartPC() 56511389Sbrandon.potter@amd.com{ 56611392Sbrandon.potter@amd.com ObjectFile *interp = getInterpreter(); 56711389Sbrandon.potter@amd.com 56811389Sbrandon.potter@amd.com return interp ? interp->entryPoint() : objFile->entryPoint(); 56911389Sbrandon.potter@amd.com} 57011389Sbrandon.potter@amd.com 57111851Sbrandon.potter@amd.comProcess * 57211851Sbrandon.potter@amd.comProcessParams::create() 5732715Sstever@eecs.umich.edu{ 57411851Sbrandon.potter@amd.com Process *process = NULL; 5752715Sstever@eecs.umich.edu 57611140Sjthestness@gmail.com // If not specified, set the executable parameter equal to the 57711140Sjthestness@gmail.com // simulated system's zeroth command line parameter 57811851Sbrandon.potter@amd.com if (executable == "") { 57911851Sbrandon.potter@amd.com executable = cmd[0]; 58011140Sjthestness@gmail.com } 58111140Sjthestness@gmail.com 58211851Sbrandon.potter@amd.com ObjectFile *obj_file = createObjectFile(executable); 58311851Sbrandon.potter@amd.com if (obj_file == NULL) { 58411851Sbrandon.potter@amd.com fatal("Can't load object file %s", executable); 5852715Sstever@eecs.umich.edu } 5862715Sstever@eecs.umich.edu 5875089Sgblack@eecs.umich.edu#if THE_ISA == ALPHA_ISA 58811851Sbrandon.potter@amd.com if (obj_file->getArch() != ObjectFile::Alpha) 5895753Ssteve.reinhardt@amd.com fatal("Object file architecture does not match compiled ISA (Alpha)."); 5905753Ssteve.reinhardt@amd.com 59111851Sbrandon.potter@amd.com switch (obj_file->getOpSys()) { 5925753Ssteve.reinhardt@amd.com case ObjectFile::UnknownOpSys: 5935753Ssteve.reinhardt@amd.com warn("Unknown operating system; assuming Linux."); 5945753Ssteve.reinhardt@amd.com // fall through 5952715Sstever@eecs.umich.edu case ObjectFile::Linux: 59611851Sbrandon.potter@amd.com process = new AlphaLinuxProcess(this, obj_file); 5972715Sstever@eecs.umich.edu break; 5982715Sstever@eecs.umich.edu 5992715Sstever@eecs.umich.edu default: 6002715Sstever@eecs.umich.edu fatal("Unknown/unsupported operating system."); 6012715Sstever@eecs.umich.edu } 6022715Sstever@eecs.umich.edu#elif THE_ISA == SPARC_ISA 60311851Sbrandon.potter@amd.com if (obj_file->getArch() != ObjectFile::SPARC64 && 60411851Sbrandon.potter@amd.com obj_file->getArch() != ObjectFile::SPARC32) 6052715Sstever@eecs.umich.edu fatal("Object file architecture does not match compiled ISA (SPARC)."); 60611851Sbrandon.potter@amd.com switch (obj_file->getOpSys()) { 6075753Ssteve.reinhardt@amd.com case ObjectFile::UnknownOpSys: 6085753Ssteve.reinhardt@amd.com warn("Unknown operating system; assuming Linux."); 6095753Ssteve.reinhardt@amd.com // fall through 6102715Sstever@eecs.umich.edu case ObjectFile::Linux: 61111851Sbrandon.potter@amd.com if (obj_file->getArch() == ObjectFile::SPARC64) { 61211851Sbrandon.potter@amd.com process = new Sparc64LinuxProcess(this, obj_file); 6134111Sgblack@eecs.umich.edu } else { 61411851Sbrandon.potter@amd.com process = new Sparc32LinuxProcess(this, obj_file); 6154111Sgblack@eecs.umich.edu } 6162715Sstever@eecs.umich.edu break; 6172715Sstever@eecs.umich.edu 6182715Sstever@eecs.umich.edu case ObjectFile::Solaris: 61911851Sbrandon.potter@amd.com process = new SparcSolarisProcess(this, obj_file); 6202715Sstever@eecs.umich.edu break; 6215753Ssteve.reinhardt@amd.com 6222715Sstever@eecs.umich.edu default: 6232715Sstever@eecs.umich.edu fatal("Unknown/unsupported operating system."); 6242715Sstever@eecs.umich.edu } 6254157Sgblack@eecs.umich.edu#elif THE_ISA == X86_ISA 62611851Sbrandon.potter@amd.com if (obj_file->getArch() != ObjectFile::X86_64 && 62711851Sbrandon.potter@amd.com obj_file->getArch() != ObjectFile::I386) 6284166Sgblack@eecs.umich.edu fatal("Object file architecture does not match compiled ISA (x86)."); 62911851Sbrandon.potter@amd.com switch (obj_file->getOpSys()) { 6305753Ssteve.reinhardt@amd.com case ObjectFile::UnknownOpSys: 6315753Ssteve.reinhardt@amd.com warn("Unknown operating system; assuming Linux."); 6325753Ssteve.reinhardt@amd.com // fall through 6334166Sgblack@eecs.umich.edu case ObjectFile::Linux: 63411851Sbrandon.potter@amd.com if (obj_file->getArch() == ObjectFile::X86_64) { 63511851Sbrandon.potter@amd.com process = new X86_64LinuxProcess(this, obj_file); 6365874Sgblack@eecs.umich.edu } else { 63711851Sbrandon.potter@amd.com process = new I386LinuxProcess(this, obj_file); 6385874Sgblack@eecs.umich.edu } 6394166Sgblack@eecs.umich.edu break; 6405753Ssteve.reinhardt@amd.com 6414157Sgblack@eecs.umich.edu default: 6424157Sgblack@eecs.umich.edu fatal("Unknown/unsupported operating system."); 6434157Sgblack@eecs.umich.edu } 6442715Sstever@eecs.umich.edu#elif THE_ISA == MIPS_ISA 64511851Sbrandon.potter@amd.com if (obj_file->getArch() != ObjectFile::Mips) 6462715Sstever@eecs.umich.edu fatal("Object file architecture does not match compiled ISA (MIPS)."); 64711851Sbrandon.potter@amd.com switch (obj_file->getOpSys()) { 6485753Ssteve.reinhardt@amd.com case ObjectFile::UnknownOpSys: 6495753Ssteve.reinhardt@amd.com warn("Unknown operating system; assuming Linux."); 6505753Ssteve.reinhardt@amd.com // fall through 6512715Sstever@eecs.umich.edu case ObjectFile::Linux: 65211851Sbrandon.potter@amd.com process = new MipsLinuxProcess(this, obj_file); 6532715Sstever@eecs.umich.edu break; 6542715Sstever@eecs.umich.edu 6552715Sstever@eecs.umich.edu default: 6562715Sstever@eecs.umich.edu fatal("Unknown/unsupported operating system."); 6572715Sstever@eecs.umich.edu } 6585335Shines@cs.fsu.edu#elif THE_ISA == ARM_ISA 65911851Sbrandon.potter@amd.com ObjectFile::Arch arch = obj_file->getArch(); 66010037SARM gem5 Developers if (arch != ObjectFile::Arm && arch != ObjectFile::Thumb && 66110037SARM gem5 Developers arch != ObjectFile::Arm64) 6625335Shines@cs.fsu.edu fatal("Object file architecture does not match compiled ISA (ARM)."); 66311851Sbrandon.potter@amd.com switch (obj_file->getOpSys()) { 6645753Ssteve.reinhardt@amd.com case ObjectFile::UnknownOpSys: 6655753Ssteve.reinhardt@amd.com warn("Unknown operating system; assuming Linux."); 6665753Ssteve.reinhardt@amd.com // fall through 6675335Shines@cs.fsu.edu case ObjectFile::Linux: 66810037SARM gem5 Developers if (arch == ObjectFile::Arm64) { 66911851Sbrandon.potter@amd.com process = new ArmLinuxProcess64(this, obj_file, 67011851Sbrandon.potter@amd.com obj_file->getArch()); 67110037SARM gem5 Developers } else { 67211851Sbrandon.potter@amd.com process = new ArmLinuxProcess32(this, obj_file, 67311851Sbrandon.potter@amd.com obj_file->getArch()); 67410037SARM gem5 Developers } 6755335Shines@cs.fsu.edu break; 67610810Sbr@bsdpad.com case ObjectFile::FreeBSD: 67710810Sbr@bsdpad.com if (arch == ObjectFile::Arm64) { 67811851Sbrandon.potter@amd.com process = new ArmFreebsdProcess64(this, obj_file, 67911851Sbrandon.potter@amd.com obj_file->getArch()); 68010810Sbr@bsdpad.com } else { 68111851Sbrandon.potter@amd.com process = new ArmFreebsdProcess32(this, obj_file, 68211851Sbrandon.potter@amd.com obj_file->getArch()); 68310810Sbr@bsdpad.com } 68410810Sbr@bsdpad.com break; 6856392Ssaidi@eecs.umich.edu case ObjectFile::LinuxArmOABI: 6866392Ssaidi@eecs.umich.edu fatal("M5 does not support ARM OABI binaries. Please recompile with an" 6876392Ssaidi@eecs.umich.edu " EABI compiler."); 6885335Shines@cs.fsu.edu default: 6895335Shines@cs.fsu.edu fatal("Unknown/unsupported operating system."); 6905335Shines@cs.fsu.edu } 6916691Stjones1@inf.ed.ac.uk#elif THE_ISA == POWER_ISA 69211851Sbrandon.potter@amd.com if (obj_file->getArch() != ObjectFile::Power) 6936691Stjones1@inf.ed.ac.uk fatal("Object file architecture does not match compiled ISA (Power)."); 69411851Sbrandon.potter@amd.com switch (obj_file->getOpSys()) { 6956691Stjones1@inf.ed.ac.uk case ObjectFile::UnknownOpSys: 6966691Stjones1@inf.ed.ac.uk warn("Unknown operating system; assuming Linux."); 6976691Stjones1@inf.ed.ac.uk // fall through 6986691Stjones1@inf.ed.ac.uk case ObjectFile::Linux: 69911851Sbrandon.potter@amd.com process = new PowerLinuxProcess(this, obj_file); 7006691Stjones1@inf.ed.ac.uk break; 7016691Stjones1@inf.ed.ac.uk 7026691Stjones1@inf.ed.ac.uk default: 7036691Stjones1@inf.ed.ac.uk fatal("Unknown/unsupported operating system."); 7046691Stjones1@inf.ed.ac.uk } 70511723Sar4jc@virginia.edu#elif THE_ISA == RISCV_ISA 70611851Sbrandon.potter@amd.com if (obj_file->getArch() != ObjectFile::Riscv) 70711723Sar4jc@virginia.edu fatal("Object file architecture does not match compiled ISA (RISCV)."); 70811851Sbrandon.potter@amd.com switch (obj_file->getOpSys()) { 70911723Sar4jc@virginia.edu case ObjectFile::UnknownOpSys: 71011723Sar4jc@virginia.edu warn("Unknown operating system; assuming Linux."); 71111723Sar4jc@virginia.edu // fall through 71211723Sar4jc@virginia.edu case ObjectFile::Linux: 71311851Sbrandon.potter@amd.com process = new RiscvLinuxProcess(this, obj_file); 71411723Sar4jc@virginia.edu break; 71511723Sar4jc@virginia.edu default: 71611723Sar4jc@virginia.edu fatal("Unknown/unsupported operating system."); 71711723Sar4jc@virginia.edu } 7182715Sstever@eecs.umich.edu#else 7192715Sstever@eecs.umich.edu#error "THE_ISA not set" 7202715Sstever@eecs.umich.edu#endif 7212715Sstever@eecs.umich.edu 7222715Sstever@eecs.umich.edu if (process == NULL) 7232715Sstever@eecs.umich.edu fatal("Unknown error creating process object."); 7242715Sstever@eecs.umich.edu return process; 7252715Sstever@eecs.umich.edu} 72611854Sbrandon.potter@amd.com 72711854Sbrandon.potter@amd.comstd::string 72811854Sbrandon.potter@amd.comProcess::fullPath(const std::string &file_name) 72911854Sbrandon.potter@amd.com{ 73011854Sbrandon.potter@amd.com if (file_name[0] == '/' || cwd.empty()) 73111854Sbrandon.potter@amd.com return file_name; 73211854Sbrandon.potter@amd.com 73311854Sbrandon.potter@amd.com std::string full = cwd; 73411854Sbrandon.potter@amd.com 73511854Sbrandon.potter@amd.com if (cwd[cwd.size() - 1] != '/') 73611854Sbrandon.potter@amd.com full += '/'; 73711854Sbrandon.potter@amd.com 73811854Sbrandon.potter@amd.com return full + file_name; 73911854Sbrandon.potter@amd.com} 740