process.cc revision 11852:df43a146a38a
1/* 2 * Copyright (c) 2014 Advanced Micro Devices, Inc. 3 * Copyright (c) 2012 ARM Limited 4 * All rights reserved 5 * 6 * The license below extends only to copyright in the software and shall 7 * not be construed as granting a license to any other intellectual 8 * property including but not limited to intellectual property relating 9 * to a hardware implementation of the functionality of the software 10 * licensed hereunder. You may use the software subject to the license 11 * terms below provided that you ensure that this notice is replicated 12 * unmodified and in its entirety in all distributions of the software, 13 * modified or unmodified, in source code or in binary form. 14 * 15 * Copyright (c) 2001-2005 The Regents of The University of Michigan 16 * All rights reserved. 17 * 18 * Redistribution and use in source and binary forms, with or without 19 * modification, are permitted provided that the following conditions are 20 * met: redistributions of source code must retain the above copyright 21 * notice, this list of conditions and the following disclaimer; 22 * redistributions in binary form must reproduce the above copyright 23 * notice, this list of conditions and the following disclaimer in the 24 * documentation and/or other materials provided with the distribution; 25 * neither the name of the copyright holders nor the names of its 26 * contributors may be used to endorse or promote products derived from 27 * this software without specific prior written permission. 28 * 29 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 30 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 31 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 32 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 33 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 34 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 35 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 36 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 37 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 38 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 39 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 40 * 41 * Authors: Nathan Binkert 42 * Steve Reinhardt 43 * Ali Saidi 44 */ 45 46#include "sim/process.hh" 47 48#include <fcntl.h> 49#include <unistd.h> 50 51#include <array> 52#include <map> 53#include <string> 54#include <vector> 55 56#include "base/intmath.hh" 57#include "base/loader/object_file.hh" 58#include "base/loader/symtab.hh" 59#include "base/statistics.hh" 60#include "config/the_isa.hh" 61#include "cpu/thread_context.hh" 62#include "mem/page_table.hh" 63#include "mem/se_translating_port_proxy.hh" 64#include "params/Process.hh" 65#include "sim/emul_driver.hh" 66#include "sim/syscall_desc.hh" 67#include "sim/system.hh" 68 69#if THE_ISA == ALPHA_ISA 70#include "arch/alpha/linux/process.hh" 71#elif THE_ISA == SPARC_ISA 72#include "arch/sparc/linux/process.hh" 73#include "arch/sparc/solaris/process.hh" 74#elif THE_ISA == MIPS_ISA 75#include "arch/mips/linux/process.hh" 76#elif THE_ISA == ARM_ISA 77#include "arch/arm/linux/process.hh" 78#include "arch/arm/freebsd/process.hh" 79#elif THE_ISA == X86_ISA 80#include "arch/x86/linux/process.hh" 81#elif THE_ISA == POWER_ISA 82#include "arch/power/linux/process.hh" 83#elif THE_ISA == RISCV_ISA 84#include "arch/riscv/linux/process.hh" 85#else 86#error "THE_ISA not set" 87#endif 88 89 90using namespace std; 91using namespace TheISA; 92 93// current number of allocated processes 94int num_processes = 0; 95 96template<class IntType> 97 98AuxVector<IntType>::AuxVector(IntType type, IntType val) 99{ 100 a_type = TheISA::htog(type); 101 a_val = TheISA::htog(val); 102} 103 104template struct AuxVector<uint32_t>; 105template struct AuxVector<uint64_t>; 106 107static int 108openFile(const string& filename, int flags, mode_t mode) 109{ 110 int sim_fd = open(filename.c_str(), flags, mode); 111 if (sim_fd != -1) 112 return sim_fd; 113 fatal("Unable to open %s with mode %O", filename, mode); 114} 115 116static int 117openInputFile(const string &filename) 118{ 119 return openFile(filename, O_RDONLY, 0); 120} 121 122static int 123openOutputFile(const string &filename) 124{ 125 return openFile(filename, O_WRONLY | O_CREAT | O_TRUNC, 0664); 126} 127 128Process::Process(ProcessParams * params, ObjectFile * obj_file) 129 : SimObject(params), system(params->system), 130 brk_point(0), stack_base(0), stack_size(0), stack_min(0), 131 max_stack_size(params->max_stack_size), 132 next_thread_stack_base(0), 133 useArchPT(params->useArchPT), 134 kvmInSE(params->kvmInSE), 135 pTable(useArchPT ? 136 static_cast<PageTableBase *>(new ArchPageTable(name(), params->pid, 137 system)) : 138 static_cast<PageTableBase *>(new FuncPageTable(name(), params->pid))), 139 initVirtMem(system->getSystemPort(), this, 140 SETranslatingPortProxy::Always), 141 fd_array(make_shared<array<FDEntry, NUM_FDS>>()), 142 imap {{"", -1}, 143 {"cin", STDIN_FILENO}, 144 {"stdin", STDIN_FILENO}}, 145 oemap{{"", -1}, 146 {"cout", STDOUT_FILENO}, 147 {"stdout", STDOUT_FILENO}, 148 {"cerr", STDERR_FILENO}, 149 {"stderr", STDERR_FILENO}}, 150 objFile(obj_file), 151 argv(params->cmd), envp(params->env), cwd(params->cwd), 152 executable(params->executable), 153 _uid(params->uid), _euid(params->euid), 154 _gid(params->gid), _egid(params->egid), 155 _pid(params->pid), _ppid(params->ppid), 156 drivers(params->drivers) 157{ 158 int sim_fd; 159 std::map<string,int>::iterator it; 160 161 // Search through the input options and set fd if match is found; 162 // otherwise, open an input file and seek to location. 163 FDEntry *fde_stdin = getFDEntry(STDIN_FILENO); 164 if ((it = imap.find(params->input)) != imap.end()) 165 sim_fd = it->second; 166 else 167 sim_fd = openInputFile(params->input); 168 fde_stdin->set(sim_fd, params->input, O_RDONLY, -1, false); 169 170 // Search through the output/error options and set fd if match is found; 171 // otherwise, open an output file and seek to location. 172 FDEntry *fde_stdout = getFDEntry(STDOUT_FILENO); 173 if ((it = oemap.find(params->output)) != oemap.end()) 174 sim_fd = it->second; 175 else 176 sim_fd = openOutputFile(params->output); 177 fde_stdout->set(sim_fd, params->output, O_WRONLY | O_CREAT | O_TRUNC, 178 0664, false); 179 180 FDEntry *fde_stderr = getFDEntry(STDERR_FILENO); 181 if (params->output == params->errout) 182 // Reuse the same file descriptor if these match. 183 sim_fd = fde_stdout->fd; 184 else if ((it = oemap.find(params->errout)) != oemap.end()) 185 sim_fd = it->second; 186 else 187 sim_fd = openOutputFile(params->errout); 188 fde_stderr->set(sim_fd, params->errout, O_WRONLY | O_CREAT | O_TRUNC, 189 0664, false); 190 191 mmap_end = 0; 192 // other parameters will be initialized when the program is loaded 193 194 // load up symbols, if any... these may be used for debugging or 195 // profiling. 196 if (!debugSymbolTable) { 197 debugSymbolTable = new SymbolTable(); 198 if (!objFile->loadGlobalSymbols(debugSymbolTable) || 199 !objFile->loadLocalSymbols(debugSymbolTable) || 200 !objFile->loadWeakSymbols(debugSymbolTable)) { 201 // didn't load any symbols 202 delete debugSymbolTable; 203 debugSymbolTable = NULL; 204 } 205 } 206} 207 208 209void 210Process::regStats() 211{ 212 SimObject::regStats(); 213 214 using namespace Stats; 215 216 num_syscalls 217 .name(name() + ".num_syscalls") 218 .desc("Number of system calls") 219 ; 220} 221 222void 223Process::inheritFDArray(Process *p) 224{ 225 fd_array = p->fd_array; 226} 227 228ThreadContext * 229Process::findFreeContext() 230{ 231 for (int id : contextIds) { 232 ThreadContext *tc = system->getThreadContext(id); 233 if (tc->status() == ThreadContext::Halted) 234 return tc; 235 } 236 return NULL; 237} 238 239void 240Process::initState() 241{ 242 if (contextIds.empty()) 243 fatal("Process %s is not associated with any HW contexts!\n", name()); 244 245 // first thread context for this process... initialize & enable 246 ThreadContext *tc = system->getThreadContext(contextIds[0]); 247 248 // mark this context as active so it will start ticking. 249 tc->activate(); 250 251 pTable->initState(tc); 252} 253 254DrainState 255Process::drain() 256{ 257 findFileOffsets(); 258 return DrainState::Drained; 259} 260 261int 262Process::allocFD(int sim_fd, const string& filename, int flags, int mode, 263 bool pipe) 264{ 265 for (int free_fd = 0; free_fd < fd_array->size(); free_fd++) { 266 FDEntry *fde = getFDEntry(free_fd); 267 if (fde->isFree()) { 268 fde->set(sim_fd, filename, flags, mode, pipe); 269 return free_fd; 270 } 271 } 272 273 fatal("Out of target file descriptors"); 274} 275 276void 277Process::resetFDEntry(int tgt_fd) 278{ 279 FDEntry *fde = getFDEntry(tgt_fd); 280 assert(fde->fd > -1); 281 282 fde->reset(); 283} 284 285int 286Process::getSimFD(int tgt_fd) 287{ 288 FDEntry *entry = getFDEntry(tgt_fd); 289 return entry ? entry->fd : -1; 290} 291 292FDEntry * 293Process::getFDEntry(int tgt_fd) 294{ 295 assert(0 <= tgt_fd && tgt_fd < fd_array->size()); 296 return &(*fd_array)[tgt_fd]; 297} 298 299int 300Process::getTgtFD(int sim_fd) 301{ 302 for (int index = 0; index < fd_array->size(); index++) 303 if ((*fd_array)[index].fd == sim_fd) 304 return index; 305 return -1; 306} 307 308void 309Process::allocateMem(Addr vaddr, int64_t size, bool clobber) 310{ 311 int npages = divCeil(size, (int64_t)PageBytes); 312 Addr paddr = system->allocPhysPages(npages); 313 pTable->map(vaddr, paddr, size, 314 clobber ? PageTableBase::Clobber : PageTableBase::Zero); 315} 316 317bool 318Process::fixupStackFault(Addr vaddr) 319{ 320 // Check if this is already on the stack and there's just no page there 321 // yet. 322 if (vaddr >= stack_min && vaddr < stack_base) { 323 allocateMem(roundDown(vaddr, PageBytes), PageBytes); 324 return true; 325 } 326 327 // We've accessed the next page of the stack, so extend it to include 328 // this address. 329 if (vaddr < stack_min && vaddr >= stack_base - max_stack_size) { 330 while (vaddr < stack_min) { 331 stack_min -= TheISA::PageBytes; 332 if (stack_base - stack_min > max_stack_size) 333 fatal("Maximum stack size exceeded\n"); 334 allocateMem(stack_min, TheISA::PageBytes); 335 inform("Increasing stack size by one page."); 336 }; 337 return true; 338 } 339 return false; 340} 341 342void 343Process::fixFileOffsets() 344{ 345 auto seek = [] (FDEntry *fde) 346 { 347 if (lseek(fde->fd, fde->fileOffset, SEEK_SET) < 0) 348 fatal("Unable to see to location in %s", fde->filename); 349 }; 350 351 std::map<string,int>::iterator it; 352 353 // Search through the input options and set fd if match is found; 354 // otherwise, open an input file and seek to location. 355 FDEntry *fde_stdin = getFDEntry(STDIN_FILENO); 356 357 // Check if user has specified a different input file, and if so, use it 358 // instead of the file specified in the checkpoint. This also resets the 359 // file offset from the checkpointed value 360 string new_in = ((ProcessParams*)params())->input; 361 if (new_in != fde_stdin->filename) { 362 warn("Using new input file (%s) rather than checkpointed (%s)\n", 363 new_in, fde_stdin->filename); 364 fde_stdin->filename = new_in; 365 fde_stdin->fileOffset = 0; 366 } 367 368 if ((it = imap.find(fde_stdin->filename)) != imap.end()) { 369 fde_stdin->fd = it->second; 370 } else { 371 fde_stdin->fd = openInputFile(fde_stdin->filename); 372 seek(fde_stdin); 373 } 374 375 // Search through the output/error options and set fd if match is found; 376 // otherwise, open an output file and seek to location. 377 FDEntry *fde_stdout = getFDEntry(STDOUT_FILENO); 378 379 // Check if user has specified a different output file, and if so, use it 380 // instead of the file specified in the checkpoint. This also resets the 381 // file offset from the checkpointed value 382 string new_out = ((ProcessParams*)params())->output; 383 if (new_out != fde_stdout->filename) { 384 warn("Using new output file (%s) rather than checkpointed (%s)\n", 385 new_out, fde_stdout->filename); 386 fde_stdout->filename = new_out; 387 fde_stdout->fileOffset = 0; 388 } 389 390 if ((it = oemap.find(fde_stdout->filename)) != oemap.end()) { 391 fde_stdout->fd = it->second; 392 } else { 393 fde_stdout->fd = openOutputFile(fde_stdout->filename); 394 seek(fde_stdout); 395 } 396 397 FDEntry *fde_stderr = getFDEntry(STDERR_FILENO); 398 399 // Check if user has specified a different error file, and if so, use it 400 // instead of the file specified in the checkpoint. This also resets the 401 // file offset from the checkpointed value 402 string new_err = ((ProcessParams*)params())->errout; 403 if (new_err != fde_stderr->filename) { 404 warn("Using new error file (%s) rather than checkpointed (%s)\n", 405 new_err, fde_stderr->filename); 406 fde_stderr->filename = new_err; 407 fde_stderr->fileOffset = 0; 408 } 409 410 if (fde_stdout->filename == fde_stderr->filename) { 411 // Reuse the same file descriptor if these match. 412 fde_stderr->fd = fde_stdout->fd; 413 } else if ((it = oemap.find(fde_stderr->filename)) != oemap.end()) { 414 fde_stderr->fd = it->second; 415 } else { 416 fde_stderr->fd = openOutputFile(fde_stderr->filename); 417 seek(fde_stderr); 418 } 419 420 for (int tgt_fd = 3; tgt_fd < fd_array->size(); tgt_fd++) { 421 FDEntry *fde = getFDEntry(tgt_fd); 422 if (fde->fd == -1) 423 continue; 424 425 if (fde->isPipe) { 426 if (fde->filename == "PIPE-WRITE") 427 continue; 428 assert(fde->filename == "PIPE-READ"); 429 430 int fds[2]; 431 if (pipe(fds) < 0) 432 fatal("Unable to create new pipe"); 433 434 fde->fd = fds[0]; 435 436 FDEntry *fde_write = getFDEntry(fde->readPipeSource); 437 assert(fde_write->filename == "PIPE-WRITE"); 438 fde_write->fd = fds[1]; 439 } else { 440 fde->fd = openFile(fde->filename.c_str(), fde->flags, fde->mode); 441 seek(fde); 442 } 443 } 444} 445 446void 447Process::findFileOffsets() 448{ 449 for (auto& fde : *fd_array) { 450 if (fde.fd != -1) 451 fde.fileOffset = lseek(fde.fd, 0, SEEK_CUR); 452 } 453} 454 455void 456Process::setReadPipeSource(int read_pipe_fd, int source_fd) 457{ 458 FDEntry *fde = getFDEntry(read_pipe_fd); 459 assert(source_fd >= -1); 460 fde->readPipeSource = source_fd; 461} 462 463void 464Process::serialize(CheckpointOut &cp) const 465{ 466 SERIALIZE_SCALAR(brk_point); 467 SERIALIZE_SCALAR(stack_base); 468 SERIALIZE_SCALAR(stack_size); 469 SERIALIZE_SCALAR(stack_min); 470 SERIALIZE_SCALAR(next_thread_stack_base); 471 SERIALIZE_SCALAR(mmap_end); 472 pTable->serialize(cp); 473 for (int x = 0; x < fd_array->size(); x++) { 474 (*fd_array)[x].serializeSection(cp, csprintf("FDEntry%d", x)); 475 } 476 477} 478 479void 480Process::unserialize(CheckpointIn &cp) 481{ 482 UNSERIALIZE_SCALAR(brk_point); 483 UNSERIALIZE_SCALAR(stack_base); 484 UNSERIALIZE_SCALAR(stack_size); 485 UNSERIALIZE_SCALAR(stack_min); 486 UNSERIALIZE_SCALAR(next_thread_stack_base); 487 UNSERIALIZE_SCALAR(mmap_end); 488 pTable->unserialize(cp); 489 for (int x = 0; x < fd_array->size(); x++) { 490 FDEntry *fde = getFDEntry(x); 491 fde->unserializeSection(cp, csprintf("FDEntry%d", x)); 492 } 493 fixFileOffsets(); 494 // The above returns a bool so that you could do something if you don't 495 // find the param in the checkpoint if you wanted to, like set a default 496 // but in this case we'll just stick with the instantiated value if not 497 // found. 498} 499 500 501bool 502Process::map(Addr vaddr, Addr paddr, int size, bool cacheable) 503{ 504 pTable->map(vaddr, paddr, size, 505 cacheable ? PageTableBase::Zero : PageTableBase::Uncacheable); 506 return true; 507} 508 509 510void 511Process::syscall(int64_t callnum, ThreadContext *tc) 512{ 513 num_syscalls++; 514 515 SyscallDesc *desc = getDesc(callnum); 516 if (desc == NULL) 517 fatal("Syscall %d out of range", callnum); 518 519 desc->doSyscall(callnum, this, tc); 520} 521 522IntReg 523Process::getSyscallArg(ThreadContext *tc, int &i, int width) 524{ 525 return getSyscallArg(tc, i); 526} 527 528 529EmulatedDriver * 530Process::findDriver(std::string filename) 531{ 532 for (EmulatedDriver *d : drivers) { 533 if (d->match(filename)) 534 return d; 535 } 536 537 return NULL; 538} 539 540void 541Process::updateBias() 542{ 543 ObjectFile *interp = objFile->getInterpreter(); 544 545 if (!interp || !interp->relocatable()) 546 return; 547 548 // Determine how large the interpreters footprint will be in the process 549 // address space. 550 Addr interp_mapsize = roundUp(interp->mapSize(), TheISA::PageBytes); 551 552 // We are allocating the memory area; set the bias to the lowest address 553 // in the allocated memory region. 554 Addr ld_bias = mmapGrowsDown() ? mmap_end - interp_mapsize : mmap_end; 555 556 // Adjust the process mmap area to give the interpreter room; the real 557 // execve system call would just invoke the kernel's internal mmap 558 // functions to make these adjustments. 559 mmap_end = mmapGrowsDown() ? ld_bias : mmap_end + interp_mapsize; 560 561 interp->updateBias(ld_bias); 562} 563 564 565ObjectFile * 566Process::getInterpreter() 567{ 568 return objFile->getInterpreter(); 569} 570 571 572Addr 573Process::getBias() 574{ 575 ObjectFile *interp = getInterpreter(); 576 577 return interp ? interp->bias() : objFile->bias(); 578} 579 580 581Addr 582Process::getStartPC() 583{ 584 ObjectFile *interp = getInterpreter(); 585 586 return interp ? interp->entryPoint() : objFile->entryPoint(); 587} 588 589 590Process * 591ProcessParams::create() 592{ 593 Process *process = NULL; 594 595 // If not specified, set the executable parameter equal to the 596 // simulated system's zeroth command line parameter 597 if (executable == "") { 598 executable = cmd[0]; 599 } 600 601 ObjectFile *obj_file = createObjectFile(executable); 602 if (obj_file == NULL) { 603 fatal("Can't load object file %s", executable); 604 } 605 606#if THE_ISA == ALPHA_ISA 607 if (obj_file->getArch() != ObjectFile::Alpha) 608 fatal("Object file architecture does not match compiled ISA (Alpha)."); 609 610 switch (obj_file->getOpSys()) { 611 case ObjectFile::UnknownOpSys: 612 warn("Unknown operating system; assuming Linux."); 613 // fall through 614 case ObjectFile::Linux: 615 process = new AlphaLinuxProcess(this, obj_file); 616 break; 617 618 default: 619 fatal("Unknown/unsupported operating system."); 620 } 621#elif THE_ISA == SPARC_ISA 622 if (obj_file->getArch() != ObjectFile::SPARC64 && 623 obj_file->getArch() != ObjectFile::SPARC32) 624 fatal("Object file architecture does not match compiled ISA (SPARC)."); 625 switch (obj_file->getOpSys()) { 626 case ObjectFile::UnknownOpSys: 627 warn("Unknown operating system; assuming Linux."); 628 // fall through 629 case ObjectFile::Linux: 630 if (obj_file->getArch() == ObjectFile::SPARC64) { 631 process = new Sparc64LinuxProcess(this, obj_file); 632 } else { 633 process = new Sparc32LinuxProcess(this, obj_file); 634 } 635 break; 636 637 638 case ObjectFile::Solaris: 639 process = new SparcSolarisProcess(this, obj_file); 640 break; 641 642 default: 643 fatal("Unknown/unsupported operating system."); 644 } 645#elif THE_ISA == X86_ISA 646 if (obj_file->getArch() != ObjectFile::X86_64 && 647 obj_file->getArch() != ObjectFile::I386) 648 fatal("Object file architecture does not match compiled ISA (x86)."); 649 switch (obj_file->getOpSys()) { 650 case ObjectFile::UnknownOpSys: 651 warn("Unknown operating system; assuming Linux."); 652 // fall through 653 case ObjectFile::Linux: 654 if (obj_file->getArch() == ObjectFile::X86_64) { 655 process = new X86_64LinuxProcess(this, obj_file); 656 } else { 657 process = new I386LinuxProcess(this, obj_file); 658 } 659 break; 660 661 default: 662 fatal("Unknown/unsupported operating system."); 663 } 664#elif THE_ISA == MIPS_ISA 665 if (obj_file->getArch() != ObjectFile::Mips) 666 fatal("Object file architecture does not match compiled ISA (MIPS)."); 667 switch (obj_file->getOpSys()) { 668 case ObjectFile::UnknownOpSys: 669 warn("Unknown operating system; assuming Linux."); 670 // fall through 671 case ObjectFile::Linux: 672 process = new MipsLinuxProcess(this, obj_file); 673 break; 674 675 default: 676 fatal("Unknown/unsupported operating system."); 677 } 678#elif THE_ISA == ARM_ISA 679 ObjectFile::Arch arch = obj_file->getArch(); 680 if (arch != ObjectFile::Arm && arch != ObjectFile::Thumb && 681 arch != ObjectFile::Arm64) 682 fatal("Object file architecture does not match compiled ISA (ARM)."); 683 switch (obj_file->getOpSys()) { 684 case ObjectFile::UnknownOpSys: 685 warn("Unknown operating system; assuming Linux."); 686 // fall through 687 case ObjectFile::Linux: 688 if (arch == ObjectFile::Arm64) { 689 process = new ArmLinuxProcess64(this, obj_file, 690 obj_file->getArch()); 691 } else { 692 process = new ArmLinuxProcess32(this, obj_file, 693 obj_file->getArch()); 694 } 695 break; 696 case ObjectFile::FreeBSD: 697 if (arch == ObjectFile::Arm64) { 698 process = new ArmFreebsdProcess64(this, obj_file, 699 obj_file->getArch()); 700 } else { 701 process = new ArmFreebsdProcess32(this, obj_file, 702 obj_file->getArch()); 703 } 704 break; 705 case ObjectFile::LinuxArmOABI: 706 fatal("M5 does not support ARM OABI binaries. Please recompile with an" 707 " EABI compiler."); 708 default: 709 fatal("Unknown/unsupported operating system."); 710 } 711#elif THE_ISA == POWER_ISA 712 if (obj_file->getArch() != ObjectFile::Power) 713 fatal("Object file architecture does not match compiled ISA (Power)."); 714 switch (obj_file->getOpSys()) { 715 case ObjectFile::UnknownOpSys: 716 warn("Unknown operating system; assuming Linux."); 717 // fall through 718 case ObjectFile::Linux: 719 process = new PowerLinuxProcess(this, obj_file); 720 break; 721 722 default: 723 fatal("Unknown/unsupported operating system."); 724 } 725#elif THE_ISA == RISCV_ISA 726 if (obj_file->getArch() != ObjectFile::Riscv) 727 fatal("Object file architecture does not match compiled ISA (RISCV)."); 728 switch (obj_file->getOpSys()) { 729 case ObjectFile::UnknownOpSys: 730 warn("Unknown operating system; assuming Linux."); 731 // fall through 732 case ObjectFile::Linux: 733 process = new RiscvLinuxProcess(this, obj_file); 734 break; 735 default: 736 fatal("Unknown/unsupported operating system."); 737 } 738#else 739#error "THE_ISA not set" 740#endif 741 742 if (process == NULL) 743 fatal("Unknown error creating process object."); 744 return process; 745} 746