process.cc (8766:b0773af78423) process.cc (8784:05fb20d7064b)
1/*
2 * Copyright (c) 2001-2005 The Regents of The University of Michigan
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are
7 * met: redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer;
9 * redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution;
12 * neither the name of the copyright holders nor the names of its
13 * contributors may be used to endorse or promote products derived from
14 * this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 *
28 * Authors: Nathan Binkert
29 * Steve Reinhardt
30 * Ali Saidi
31 */
32
33#include <fcntl.h>
34#include <unistd.h>
35
36#include <cstdio>
37#include <string>
38
39#include "base/loader/object_file.hh"
40#include "base/loader/symtab.hh"
41#include "base/intmath.hh"
42#include "base/statistics.hh"
43#include "config/full_system.hh"
44#include "config/the_isa.hh"
45#include "cpu/thread_context.hh"
46#include "mem/page_table.hh"
47#include "mem/physical.hh"
48#include "mem/translating_port.hh"
49#include "params/LiveProcess.hh"
50#include "params/Process.hh"
51#include "sim/debug.hh"
52#include "sim/process.hh"
53#include "sim/process_impl.hh"
54#include "sim/stats.hh"
55#include "sim/syscall_emul.hh"
56#include "sim/system.hh"
57
58#if THE_ISA == ALPHA_ISA
59#include "arch/alpha/linux/process.hh"
60#include "arch/alpha/tru64/process.hh"
61#elif THE_ISA == SPARC_ISA
62#include "arch/sparc/linux/process.hh"
63#include "arch/sparc/solaris/process.hh"
64#elif THE_ISA == MIPS_ISA
65#include "arch/mips/linux/process.hh"
66#elif THE_ISA == ARM_ISA
67#include "arch/arm/linux/process.hh"
68#elif THE_ISA == X86_ISA
69#include "arch/x86/linux/process.hh"
70#elif THE_ISA == POWER_ISA
71#include "arch/power/linux/process.hh"
72#else
73#error "THE_ISA not set"
74#endif
75
76
77using namespace std;
78using namespace TheISA;
79
80// current number of allocated processes
81int num_processes = 0;
82
83template<class IntType>
84AuxVector<IntType>::AuxVector(IntType type, IntType val)
85{
86 a_type = TheISA::htog(type);
87 a_val = TheISA::htog(val);
88}
89
90template class AuxVector<uint32_t>;
91template class AuxVector<uint64_t>;
92
93Process::Process(ProcessParams * params)
94 : SimObject(params), system(params->system),
95 max_stack_size(params->max_stack_size)
96{
97 string in = params->input;
98 string out = params->output;
99 string err = params->errout;
100
101 // initialize file descriptors to default: same as simulator
102 int stdin_fd, stdout_fd, stderr_fd;
103
104 if (in == "stdin" || in == "cin")
105 stdin_fd = STDIN_FILENO;
106 else if (in == "None")
107 stdin_fd = -1;
108 else
109 stdin_fd = Process::openInputFile(in);
110
111 if (out == "stdout" || out == "cout")
112 stdout_fd = STDOUT_FILENO;
113 else if (out == "stderr" || out == "cerr")
114 stdout_fd = STDERR_FILENO;
115 else if (out == "None")
116 stdout_fd = -1;
117 else
118 stdout_fd = Process::openOutputFile(out);
119
120 if (err == "stdout" || err == "cout")
121 stderr_fd = STDOUT_FILENO;
122 else if (err == "stderr" || err == "cerr")
123 stderr_fd = STDERR_FILENO;
124 else if (err == "None")
125 stderr_fd = -1;
126 else if (err == out)
127 stderr_fd = stdout_fd;
128 else
129 stderr_fd = Process::openOutputFile(err);
130
131 M5_pid = system->allocatePID();
132 // initialize first 3 fds (stdin, stdout, stderr)
133 Process::FdMap *fdo = &fd_map[STDIN_FILENO];
134 fdo->fd = stdin_fd;
135 fdo->filename = in;
136 fdo->flags = O_RDONLY;
137 fdo->mode = -1;
138 fdo->fileOffset = 0;
139
140 fdo = &fd_map[STDOUT_FILENO];
141 fdo->fd = stdout_fd;
142 fdo->filename = out;
143 fdo->flags = O_WRONLY | O_CREAT | O_TRUNC;
144 fdo->mode = 0774;
145 fdo->fileOffset = 0;
146
147 fdo = &fd_map[STDERR_FILENO];
148 fdo->fd = stderr_fd;
149 fdo->filename = err;
150 fdo->flags = O_WRONLY;
151 fdo->mode = -1;
152 fdo->fileOffset = 0;
153
154
155 // mark remaining fds as free
156 for (int i = 3; i <= MAX_FD; ++i) {
157 Process::FdMap *fdo = &fd_map[i];
158 fdo->fd = -1;
159 }
160
161 mmap_start = mmap_end = 0;
162 nxm_start = nxm_end = 0;
163 pTable = new PageTable(this);
164 // other parameters will be initialized when the program is loaded
165}
166
167
168void
169Process::regStats()
170{
171 using namespace Stats;
172
173 num_syscalls
174 .name(name() + ".num_syscalls")
175 .desc("Number of system calls")
176 ;
177}
178
179//
180// static helper functions
181//
182int
183Process::openInputFile(const string &filename)
184{
185 int fd = open(filename.c_str(), O_RDONLY);
186
187 if (fd == -1) {
188 perror(NULL);
189 cerr << "unable to open \"" << filename << "\" for reading\n";
190 fatal("can't open input file");
191 }
192
193 return fd;
194}
195
196
197int
198Process::openOutputFile(const string &filename)
199{
200 int fd = open(filename.c_str(), O_WRONLY | O_CREAT | O_TRUNC, 0664);
201
202 if (fd == -1) {
203 perror(NULL);
204 cerr << "unable to open \"" << filename << "\" for writing\n";
205 fatal("can't open output file");
206 }
207
208 return fd;
209}
210
211ThreadContext *
212Process::findFreeContext()
213{
214 int size = contextIds.size();
215 ThreadContext *tc;
216 for (int i = 0; i < size; ++i) {
217 tc = system->getThreadContext(contextIds[i]);
218 if (tc->status() == ThreadContext::Halted) {
219 // inactive context, free to use
220 return tc;
221 }
222 }
223 return NULL;
224}
225
226void
227Process::initState()
228{
229 if (contextIds.empty())
230 fatal("Process %s is not associated with any HW contexts!\n", name());
231
232 // first thread context for this process... initialize & enable
233 ThreadContext *tc = system->getThreadContext(contextIds[0]);
234
235 // mark this context as active so it will start ticking.
236 tc->activate(0);
237
238 Port *mem_port;
239 mem_port = system->physmem->getPort("functional");
240 initVirtMem = new TranslatingPort("process init port", this,
241 TranslatingPort::Always);
242 mem_port->setPeer(initVirtMem);
243 initVirtMem->setPeer(mem_port);
244}
245
246// map simulator fd sim_fd to target fd tgt_fd
247void
248Process::dup_fd(int sim_fd, int tgt_fd)
249{
250 if (tgt_fd < 0 || tgt_fd > MAX_FD)
251 panic("Process::dup_fd tried to dup past MAX_FD (%d)", tgt_fd);
252
253 Process::FdMap *fdo = &fd_map[tgt_fd];
254 fdo->fd = sim_fd;
255}
256
257
258// generate new target fd for sim_fd
259int
260Process::alloc_fd(int sim_fd, string filename, int flags, int mode, bool pipe)
261{
262 // in case open() returns an error, don't allocate a new fd
263 if (sim_fd == -1)
264 return -1;
265
266 // find first free target fd
267 for (int free_fd = 0; free_fd <= MAX_FD; ++free_fd) {
268 Process::FdMap *fdo = &fd_map[free_fd];
269 if (fdo->fd == -1) {
270 fdo->fd = sim_fd;
271 fdo->filename = filename;
272 fdo->mode = mode;
273 fdo->fileOffset = 0;
274 fdo->flags = flags;
275 fdo->isPipe = pipe;
276 fdo->readPipeSource = 0;
277 return free_fd;
278 }
279 }
280
281 panic("Process::alloc_fd: out of file descriptors!");
282}
283
284
285// free target fd (e.g., after close)
286void
287Process::free_fd(int tgt_fd)
288{
289 Process::FdMap *fdo = &fd_map[tgt_fd];
290 if (fdo->fd == -1)
291 warn("Process::free_fd: request to free unused fd %d", tgt_fd);
292
293 fdo->fd = -1;
294 fdo->filename = "NULL";
295 fdo->mode = 0;
296 fdo->fileOffset = 0;
297 fdo->flags = 0;
298 fdo->isPipe = false;
299 fdo->readPipeSource = 0;
300}
301
302
303// look up simulator fd for given target fd
304int
305Process::sim_fd(int tgt_fd)
306{
307 if (tgt_fd < 0 || tgt_fd > MAX_FD)
308 return -1;
309
310 return fd_map[tgt_fd].fd;
311}
312
313Process::FdMap *
314Process::sim_fd_obj(int tgt_fd)
315{
316 if (tgt_fd < 0 || tgt_fd > MAX_FD)
317 return NULL;
318
319 return &fd_map[tgt_fd];
320}
321
322bool
323Process::fixupStackFault(Addr vaddr)
324{
325 // Check if this is already on the stack and there's just no page there
326 // yet.
327 if (vaddr >= stack_min && vaddr < stack_base) {
328 pTable->allocate(roundDown(vaddr, VMPageSize), VMPageSize);
329 return true;
330 }
331
332 // We've accessed the next page of the stack, so extend it to include
333 // this address.
334 if (vaddr < stack_min && vaddr >= stack_base - max_stack_size) {
335 while (vaddr < stack_min) {
336 stack_min -= TheISA::PageBytes;
337 if (stack_base - stack_min > max_stack_size)
338 fatal("Maximum stack size exceeded\n");
339 if (stack_base - stack_min > 8 * 1024 * 1024)
340 fatal("Over max stack size for one thread\n");
341 pTable->allocate(stack_min, TheISA::PageBytes);
342 inform("Increasing stack size by one page.");
343 };
344 return true;
345 }
346 warn("Not extending stack: address %#x isn't at the end of the stack.",
347 vaddr);
348 return false;
349}
350
351// find all offsets for currently open files and save them
352void
353Process::fix_file_offsets()
354{
355 Process::FdMap *fdo_stdin = &fd_map[STDIN_FILENO];
356 Process::FdMap *fdo_stdout = &fd_map[STDOUT_FILENO];
357 Process::FdMap *fdo_stderr = &fd_map[STDERR_FILENO];
358 string in = fdo_stdin->filename;
359 string out = fdo_stdout->filename;
360 string err = fdo_stderr->filename;
361
362 // initialize file descriptors to default: same as simulator
363 int stdin_fd, stdout_fd, stderr_fd;
364
365 if (in == "stdin" || in == "cin")
366 stdin_fd = STDIN_FILENO;
367 else if (in == "None")
368 stdin_fd = -1;
369 else {
370 // open standard in and seek to the right location
371 stdin_fd = Process::openInputFile(in);
372 if (lseek(stdin_fd, fdo_stdin->fileOffset, SEEK_SET) < 0)
373 panic("Unable to seek to correct location in file: %s", in);
374 }
375
376 if (out == "stdout" || out == "cout")
377 stdout_fd = STDOUT_FILENO;
378 else if (out == "stderr" || out == "cerr")
379 stdout_fd = STDERR_FILENO;
380 else if (out == "None")
381 stdout_fd = -1;
382 else {
383 stdout_fd = Process::openOutputFile(out);
384 if (lseek(stdout_fd, fdo_stdout->fileOffset, SEEK_SET) < 0)
385 panic("Unable to seek to correct location in file: %s", out);
386 }
387
388 if (err == "stdout" || err == "cout")
389 stderr_fd = STDOUT_FILENO;
390 else if (err == "stderr" || err == "cerr")
391 stderr_fd = STDERR_FILENO;
392 else if (err == "None")
393 stderr_fd = -1;
394 else if (err == out)
395 stderr_fd = stdout_fd;
396 else {
397 stderr_fd = Process::openOutputFile(err);
398 if (lseek(stderr_fd, fdo_stderr->fileOffset, SEEK_SET) < 0)
399 panic("Unable to seek to correct location in file: %s", err);
400 }
401
402 fdo_stdin->fd = stdin_fd;
403 fdo_stdout->fd = stdout_fd;
404 fdo_stderr->fd = stderr_fd;
405
406
407 for (int free_fd = 3; free_fd <= MAX_FD; ++free_fd) {
408 Process::FdMap *fdo = &fd_map[free_fd];
409 if (fdo->fd != -1) {
410 if (fdo->isPipe){
411 if (fdo->filename == "PIPE-WRITE")
412 continue;
413 else {
414 assert (fdo->filename == "PIPE-READ");
415 //create a new pipe
416 int fds[2];
417 int pipe_retval = pipe(fds);
418
419 if (pipe_retval < 0) {
420 // error
421 panic("Unable to create new pipe.");
422 }
423 fdo->fd = fds[0]; //set read pipe
424 Process::FdMap *fdo_write = &fd_map[fdo->readPipeSource];
425 if (fdo_write->filename != "PIPE-WRITE")
426 panic ("Couldn't find write end of the pipe");
427
428 fdo_write->fd = fds[1];//set write pipe
429 }
430 } else {
431 //Open file
432 int fd = open(fdo->filename.c_str(), fdo->flags, fdo->mode);
433
434 if (fd == -1)
435 panic("Unable to open file: %s", fdo->filename);
436 fdo->fd = fd;
437
438 //Seek to correct location before checkpoint
439 if (lseek(fd,fdo->fileOffset, SEEK_SET) < 0)
440 panic("Unable to seek to correct location in file: %s",
441 fdo->filename);
442 }
443 }
444 }
445}
446
447void
448Process::find_file_offsets()
449{
450 for (int free_fd = 0; free_fd <= MAX_FD; ++free_fd) {
451 Process::FdMap *fdo = &fd_map[free_fd];
452 if (fdo->fd != -1) {
453 fdo->fileOffset = lseek(fdo->fd, 0, SEEK_CUR);
454 } else {
455 fdo->filename = "NULL";
456 fdo->fileOffset = 0;
457 }
458 }
459}
460
461void
462Process::setReadPipeSource(int read_pipe_fd, int source_fd)
463{
464 Process::FdMap *fdo = &fd_map[read_pipe_fd];
465 fdo->readPipeSource = source_fd;
466}
467
468void
469Process::FdMap::serialize(std::ostream &os)
470{
471 SERIALIZE_SCALAR(fd);
472 SERIALIZE_SCALAR(isPipe);
473 SERIALIZE_SCALAR(filename);
474 SERIALIZE_SCALAR(flags);
475 SERIALIZE_SCALAR(readPipeSource);
476 SERIALIZE_SCALAR(fileOffset);
477}
478
479void
480Process::FdMap::unserialize(Checkpoint *cp, const std::string &section)
481{
482 UNSERIALIZE_SCALAR(fd);
483 UNSERIALIZE_SCALAR(isPipe);
484 UNSERIALIZE_SCALAR(filename);
485 UNSERIALIZE_SCALAR(flags);
486 UNSERIALIZE_SCALAR(readPipeSource);
487 UNSERIALIZE_SCALAR(fileOffset);
488}
489
490void
491Process::serialize(std::ostream &os)
492{
493 SERIALIZE_SCALAR(brk_point);
494 SERIALIZE_SCALAR(stack_base);
495 SERIALIZE_SCALAR(stack_size);
496 SERIALIZE_SCALAR(stack_min);
497 SERIALIZE_SCALAR(next_thread_stack_base);
498 SERIALIZE_SCALAR(mmap_start);
499 SERIALIZE_SCALAR(mmap_end);
500 SERIALIZE_SCALAR(nxm_start);
501 SERIALIZE_SCALAR(nxm_end);
502 find_file_offsets();
503 pTable->serialize(os);
504 for (int x = 0; x <= MAX_FD; x++) {
505 nameOut(os, csprintf("%s.FdMap%d", name(), x));
506 fd_map[x].serialize(os);
507 }
508 SERIALIZE_SCALAR(M5_pid);
509
510}
511
512void
513Process::unserialize(Checkpoint *cp, const std::string &section)
514{
515 UNSERIALIZE_SCALAR(brk_point);
516 UNSERIALIZE_SCALAR(stack_base);
517 UNSERIALIZE_SCALAR(stack_size);
518 UNSERIALIZE_SCALAR(stack_min);
519 UNSERIALIZE_SCALAR(next_thread_stack_base);
520 UNSERIALIZE_SCALAR(mmap_start);
521 UNSERIALIZE_SCALAR(mmap_end);
522 UNSERIALIZE_SCALAR(nxm_start);
523 UNSERIALIZE_SCALAR(nxm_end);
524 pTable->unserialize(cp, section);
525 for (int x = 0; x <= MAX_FD; x++) {
526 fd_map[x].unserialize(cp, csprintf("%s.FdMap%d", section, x));
527 }
528 fix_file_offsets();
529 UNSERIALIZE_OPT_SCALAR(M5_pid);
530 // The above returns a bool so that you could do something if you don't
531 // find the param in the checkpoint if you wanted to, like set a default
532 // but in this case we'll just stick with the instantianted value if not
533 // found.
534}
535
536
537////////////////////////////////////////////////////////////////////////
538//
539// LiveProcess member definitions
540//
541////////////////////////////////////////////////////////////////////////
542
543
544LiveProcess::LiveProcess(LiveProcessParams * params, ObjectFile *_objFile)
545 : Process(params), objFile(_objFile),
546 argv(params->cmd), envp(params->env), cwd(params->cwd)
547{
548 __uid = params->uid;
549 __euid = params->euid;
550 __gid = params->gid;
551 __egid = params->egid;
552 __pid = params->pid;
553 __ppid = params->ppid;
554
555 prog_fname = params->cmd[0];
556
557 // load up symbols, if any... these may be used for debugging or
558 // profiling.
559 if (!debugSymbolTable) {
560 debugSymbolTable = new SymbolTable();
561 if (!objFile->loadGlobalSymbols(debugSymbolTable) ||
562 !objFile->loadLocalSymbols(debugSymbolTable)) {
563 // didn't load any symbols
564 delete debugSymbolTable;
565 debugSymbolTable = NULL;
566 }
567 }
568}
569
570void
571LiveProcess::syscall(int64_t callnum, ThreadContext *tc)
572{
1/*
2 * Copyright (c) 2001-2005 The Regents of The University of Michigan
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are
7 * met: redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer;
9 * redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution;
12 * neither the name of the copyright holders nor the names of its
13 * contributors may be used to endorse or promote products derived from
14 * this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 *
28 * Authors: Nathan Binkert
29 * Steve Reinhardt
30 * Ali Saidi
31 */
32
33#include <fcntl.h>
34#include <unistd.h>
35
36#include <cstdio>
37#include <string>
38
39#include "base/loader/object_file.hh"
40#include "base/loader/symtab.hh"
41#include "base/intmath.hh"
42#include "base/statistics.hh"
43#include "config/full_system.hh"
44#include "config/the_isa.hh"
45#include "cpu/thread_context.hh"
46#include "mem/page_table.hh"
47#include "mem/physical.hh"
48#include "mem/translating_port.hh"
49#include "params/LiveProcess.hh"
50#include "params/Process.hh"
51#include "sim/debug.hh"
52#include "sim/process.hh"
53#include "sim/process_impl.hh"
54#include "sim/stats.hh"
55#include "sim/syscall_emul.hh"
56#include "sim/system.hh"
57
58#if THE_ISA == ALPHA_ISA
59#include "arch/alpha/linux/process.hh"
60#include "arch/alpha/tru64/process.hh"
61#elif THE_ISA == SPARC_ISA
62#include "arch/sparc/linux/process.hh"
63#include "arch/sparc/solaris/process.hh"
64#elif THE_ISA == MIPS_ISA
65#include "arch/mips/linux/process.hh"
66#elif THE_ISA == ARM_ISA
67#include "arch/arm/linux/process.hh"
68#elif THE_ISA == X86_ISA
69#include "arch/x86/linux/process.hh"
70#elif THE_ISA == POWER_ISA
71#include "arch/power/linux/process.hh"
72#else
73#error "THE_ISA not set"
74#endif
75
76
77using namespace std;
78using namespace TheISA;
79
80// current number of allocated processes
81int num_processes = 0;
82
83template<class IntType>
84AuxVector<IntType>::AuxVector(IntType type, IntType val)
85{
86 a_type = TheISA::htog(type);
87 a_val = TheISA::htog(val);
88}
89
90template class AuxVector<uint32_t>;
91template class AuxVector<uint64_t>;
92
93Process::Process(ProcessParams * params)
94 : SimObject(params), system(params->system),
95 max_stack_size(params->max_stack_size)
96{
97 string in = params->input;
98 string out = params->output;
99 string err = params->errout;
100
101 // initialize file descriptors to default: same as simulator
102 int stdin_fd, stdout_fd, stderr_fd;
103
104 if (in == "stdin" || in == "cin")
105 stdin_fd = STDIN_FILENO;
106 else if (in == "None")
107 stdin_fd = -1;
108 else
109 stdin_fd = Process::openInputFile(in);
110
111 if (out == "stdout" || out == "cout")
112 stdout_fd = STDOUT_FILENO;
113 else if (out == "stderr" || out == "cerr")
114 stdout_fd = STDERR_FILENO;
115 else if (out == "None")
116 stdout_fd = -1;
117 else
118 stdout_fd = Process::openOutputFile(out);
119
120 if (err == "stdout" || err == "cout")
121 stderr_fd = STDOUT_FILENO;
122 else if (err == "stderr" || err == "cerr")
123 stderr_fd = STDERR_FILENO;
124 else if (err == "None")
125 stderr_fd = -1;
126 else if (err == out)
127 stderr_fd = stdout_fd;
128 else
129 stderr_fd = Process::openOutputFile(err);
130
131 M5_pid = system->allocatePID();
132 // initialize first 3 fds (stdin, stdout, stderr)
133 Process::FdMap *fdo = &fd_map[STDIN_FILENO];
134 fdo->fd = stdin_fd;
135 fdo->filename = in;
136 fdo->flags = O_RDONLY;
137 fdo->mode = -1;
138 fdo->fileOffset = 0;
139
140 fdo = &fd_map[STDOUT_FILENO];
141 fdo->fd = stdout_fd;
142 fdo->filename = out;
143 fdo->flags = O_WRONLY | O_CREAT | O_TRUNC;
144 fdo->mode = 0774;
145 fdo->fileOffset = 0;
146
147 fdo = &fd_map[STDERR_FILENO];
148 fdo->fd = stderr_fd;
149 fdo->filename = err;
150 fdo->flags = O_WRONLY;
151 fdo->mode = -1;
152 fdo->fileOffset = 0;
153
154
155 // mark remaining fds as free
156 for (int i = 3; i <= MAX_FD; ++i) {
157 Process::FdMap *fdo = &fd_map[i];
158 fdo->fd = -1;
159 }
160
161 mmap_start = mmap_end = 0;
162 nxm_start = nxm_end = 0;
163 pTable = new PageTable(this);
164 // other parameters will be initialized when the program is loaded
165}
166
167
168void
169Process::regStats()
170{
171 using namespace Stats;
172
173 num_syscalls
174 .name(name() + ".num_syscalls")
175 .desc("Number of system calls")
176 ;
177}
178
179//
180// static helper functions
181//
182int
183Process::openInputFile(const string &filename)
184{
185 int fd = open(filename.c_str(), O_RDONLY);
186
187 if (fd == -1) {
188 perror(NULL);
189 cerr << "unable to open \"" << filename << "\" for reading\n";
190 fatal("can't open input file");
191 }
192
193 return fd;
194}
195
196
197int
198Process::openOutputFile(const string &filename)
199{
200 int fd = open(filename.c_str(), O_WRONLY | O_CREAT | O_TRUNC, 0664);
201
202 if (fd == -1) {
203 perror(NULL);
204 cerr << "unable to open \"" << filename << "\" for writing\n";
205 fatal("can't open output file");
206 }
207
208 return fd;
209}
210
211ThreadContext *
212Process::findFreeContext()
213{
214 int size = contextIds.size();
215 ThreadContext *tc;
216 for (int i = 0; i < size; ++i) {
217 tc = system->getThreadContext(contextIds[i]);
218 if (tc->status() == ThreadContext::Halted) {
219 // inactive context, free to use
220 return tc;
221 }
222 }
223 return NULL;
224}
225
226void
227Process::initState()
228{
229 if (contextIds.empty())
230 fatal("Process %s is not associated with any HW contexts!\n", name());
231
232 // first thread context for this process... initialize & enable
233 ThreadContext *tc = system->getThreadContext(contextIds[0]);
234
235 // mark this context as active so it will start ticking.
236 tc->activate(0);
237
238 Port *mem_port;
239 mem_port = system->physmem->getPort("functional");
240 initVirtMem = new TranslatingPort("process init port", this,
241 TranslatingPort::Always);
242 mem_port->setPeer(initVirtMem);
243 initVirtMem->setPeer(mem_port);
244}
245
246// map simulator fd sim_fd to target fd tgt_fd
247void
248Process::dup_fd(int sim_fd, int tgt_fd)
249{
250 if (tgt_fd < 0 || tgt_fd > MAX_FD)
251 panic("Process::dup_fd tried to dup past MAX_FD (%d)", tgt_fd);
252
253 Process::FdMap *fdo = &fd_map[tgt_fd];
254 fdo->fd = sim_fd;
255}
256
257
258// generate new target fd for sim_fd
259int
260Process::alloc_fd(int sim_fd, string filename, int flags, int mode, bool pipe)
261{
262 // in case open() returns an error, don't allocate a new fd
263 if (sim_fd == -1)
264 return -1;
265
266 // find first free target fd
267 for (int free_fd = 0; free_fd <= MAX_FD; ++free_fd) {
268 Process::FdMap *fdo = &fd_map[free_fd];
269 if (fdo->fd == -1) {
270 fdo->fd = sim_fd;
271 fdo->filename = filename;
272 fdo->mode = mode;
273 fdo->fileOffset = 0;
274 fdo->flags = flags;
275 fdo->isPipe = pipe;
276 fdo->readPipeSource = 0;
277 return free_fd;
278 }
279 }
280
281 panic("Process::alloc_fd: out of file descriptors!");
282}
283
284
285// free target fd (e.g., after close)
286void
287Process::free_fd(int tgt_fd)
288{
289 Process::FdMap *fdo = &fd_map[tgt_fd];
290 if (fdo->fd == -1)
291 warn("Process::free_fd: request to free unused fd %d", tgt_fd);
292
293 fdo->fd = -1;
294 fdo->filename = "NULL";
295 fdo->mode = 0;
296 fdo->fileOffset = 0;
297 fdo->flags = 0;
298 fdo->isPipe = false;
299 fdo->readPipeSource = 0;
300}
301
302
303// look up simulator fd for given target fd
304int
305Process::sim_fd(int tgt_fd)
306{
307 if (tgt_fd < 0 || tgt_fd > MAX_FD)
308 return -1;
309
310 return fd_map[tgt_fd].fd;
311}
312
313Process::FdMap *
314Process::sim_fd_obj(int tgt_fd)
315{
316 if (tgt_fd < 0 || tgt_fd > MAX_FD)
317 return NULL;
318
319 return &fd_map[tgt_fd];
320}
321
322bool
323Process::fixupStackFault(Addr vaddr)
324{
325 // Check if this is already on the stack and there's just no page there
326 // yet.
327 if (vaddr >= stack_min && vaddr < stack_base) {
328 pTable->allocate(roundDown(vaddr, VMPageSize), VMPageSize);
329 return true;
330 }
331
332 // We've accessed the next page of the stack, so extend it to include
333 // this address.
334 if (vaddr < stack_min && vaddr >= stack_base - max_stack_size) {
335 while (vaddr < stack_min) {
336 stack_min -= TheISA::PageBytes;
337 if (stack_base - stack_min > max_stack_size)
338 fatal("Maximum stack size exceeded\n");
339 if (stack_base - stack_min > 8 * 1024 * 1024)
340 fatal("Over max stack size for one thread\n");
341 pTable->allocate(stack_min, TheISA::PageBytes);
342 inform("Increasing stack size by one page.");
343 };
344 return true;
345 }
346 warn("Not extending stack: address %#x isn't at the end of the stack.",
347 vaddr);
348 return false;
349}
350
351// find all offsets for currently open files and save them
352void
353Process::fix_file_offsets()
354{
355 Process::FdMap *fdo_stdin = &fd_map[STDIN_FILENO];
356 Process::FdMap *fdo_stdout = &fd_map[STDOUT_FILENO];
357 Process::FdMap *fdo_stderr = &fd_map[STDERR_FILENO];
358 string in = fdo_stdin->filename;
359 string out = fdo_stdout->filename;
360 string err = fdo_stderr->filename;
361
362 // initialize file descriptors to default: same as simulator
363 int stdin_fd, stdout_fd, stderr_fd;
364
365 if (in == "stdin" || in == "cin")
366 stdin_fd = STDIN_FILENO;
367 else if (in == "None")
368 stdin_fd = -1;
369 else {
370 // open standard in and seek to the right location
371 stdin_fd = Process::openInputFile(in);
372 if (lseek(stdin_fd, fdo_stdin->fileOffset, SEEK_SET) < 0)
373 panic("Unable to seek to correct location in file: %s", in);
374 }
375
376 if (out == "stdout" || out == "cout")
377 stdout_fd = STDOUT_FILENO;
378 else if (out == "stderr" || out == "cerr")
379 stdout_fd = STDERR_FILENO;
380 else if (out == "None")
381 stdout_fd = -1;
382 else {
383 stdout_fd = Process::openOutputFile(out);
384 if (lseek(stdout_fd, fdo_stdout->fileOffset, SEEK_SET) < 0)
385 panic("Unable to seek to correct location in file: %s", out);
386 }
387
388 if (err == "stdout" || err == "cout")
389 stderr_fd = STDOUT_FILENO;
390 else if (err == "stderr" || err == "cerr")
391 stderr_fd = STDERR_FILENO;
392 else if (err == "None")
393 stderr_fd = -1;
394 else if (err == out)
395 stderr_fd = stdout_fd;
396 else {
397 stderr_fd = Process::openOutputFile(err);
398 if (lseek(stderr_fd, fdo_stderr->fileOffset, SEEK_SET) < 0)
399 panic("Unable to seek to correct location in file: %s", err);
400 }
401
402 fdo_stdin->fd = stdin_fd;
403 fdo_stdout->fd = stdout_fd;
404 fdo_stderr->fd = stderr_fd;
405
406
407 for (int free_fd = 3; free_fd <= MAX_FD; ++free_fd) {
408 Process::FdMap *fdo = &fd_map[free_fd];
409 if (fdo->fd != -1) {
410 if (fdo->isPipe){
411 if (fdo->filename == "PIPE-WRITE")
412 continue;
413 else {
414 assert (fdo->filename == "PIPE-READ");
415 //create a new pipe
416 int fds[2];
417 int pipe_retval = pipe(fds);
418
419 if (pipe_retval < 0) {
420 // error
421 panic("Unable to create new pipe.");
422 }
423 fdo->fd = fds[0]; //set read pipe
424 Process::FdMap *fdo_write = &fd_map[fdo->readPipeSource];
425 if (fdo_write->filename != "PIPE-WRITE")
426 panic ("Couldn't find write end of the pipe");
427
428 fdo_write->fd = fds[1];//set write pipe
429 }
430 } else {
431 //Open file
432 int fd = open(fdo->filename.c_str(), fdo->flags, fdo->mode);
433
434 if (fd == -1)
435 panic("Unable to open file: %s", fdo->filename);
436 fdo->fd = fd;
437
438 //Seek to correct location before checkpoint
439 if (lseek(fd,fdo->fileOffset, SEEK_SET) < 0)
440 panic("Unable to seek to correct location in file: %s",
441 fdo->filename);
442 }
443 }
444 }
445}
446
447void
448Process::find_file_offsets()
449{
450 for (int free_fd = 0; free_fd <= MAX_FD; ++free_fd) {
451 Process::FdMap *fdo = &fd_map[free_fd];
452 if (fdo->fd != -1) {
453 fdo->fileOffset = lseek(fdo->fd, 0, SEEK_CUR);
454 } else {
455 fdo->filename = "NULL";
456 fdo->fileOffset = 0;
457 }
458 }
459}
460
461void
462Process::setReadPipeSource(int read_pipe_fd, int source_fd)
463{
464 Process::FdMap *fdo = &fd_map[read_pipe_fd];
465 fdo->readPipeSource = source_fd;
466}
467
468void
469Process::FdMap::serialize(std::ostream &os)
470{
471 SERIALIZE_SCALAR(fd);
472 SERIALIZE_SCALAR(isPipe);
473 SERIALIZE_SCALAR(filename);
474 SERIALIZE_SCALAR(flags);
475 SERIALIZE_SCALAR(readPipeSource);
476 SERIALIZE_SCALAR(fileOffset);
477}
478
479void
480Process::FdMap::unserialize(Checkpoint *cp, const std::string &section)
481{
482 UNSERIALIZE_SCALAR(fd);
483 UNSERIALIZE_SCALAR(isPipe);
484 UNSERIALIZE_SCALAR(filename);
485 UNSERIALIZE_SCALAR(flags);
486 UNSERIALIZE_SCALAR(readPipeSource);
487 UNSERIALIZE_SCALAR(fileOffset);
488}
489
490void
491Process::serialize(std::ostream &os)
492{
493 SERIALIZE_SCALAR(brk_point);
494 SERIALIZE_SCALAR(stack_base);
495 SERIALIZE_SCALAR(stack_size);
496 SERIALIZE_SCALAR(stack_min);
497 SERIALIZE_SCALAR(next_thread_stack_base);
498 SERIALIZE_SCALAR(mmap_start);
499 SERIALIZE_SCALAR(mmap_end);
500 SERIALIZE_SCALAR(nxm_start);
501 SERIALIZE_SCALAR(nxm_end);
502 find_file_offsets();
503 pTable->serialize(os);
504 for (int x = 0; x <= MAX_FD; x++) {
505 nameOut(os, csprintf("%s.FdMap%d", name(), x));
506 fd_map[x].serialize(os);
507 }
508 SERIALIZE_SCALAR(M5_pid);
509
510}
511
512void
513Process::unserialize(Checkpoint *cp, const std::string &section)
514{
515 UNSERIALIZE_SCALAR(brk_point);
516 UNSERIALIZE_SCALAR(stack_base);
517 UNSERIALIZE_SCALAR(stack_size);
518 UNSERIALIZE_SCALAR(stack_min);
519 UNSERIALIZE_SCALAR(next_thread_stack_base);
520 UNSERIALIZE_SCALAR(mmap_start);
521 UNSERIALIZE_SCALAR(mmap_end);
522 UNSERIALIZE_SCALAR(nxm_start);
523 UNSERIALIZE_SCALAR(nxm_end);
524 pTable->unserialize(cp, section);
525 for (int x = 0; x <= MAX_FD; x++) {
526 fd_map[x].unserialize(cp, csprintf("%s.FdMap%d", section, x));
527 }
528 fix_file_offsets();
529 UNSERIALIZE_OPT_SCALAR(M5_pid);
530 // The above returns a bool so that you could do something if you don't
531 // find the param in the checkpoint if you wanted to, like set a default
532 // but in this case we'll just stick with the instantianted value if not
533 // found.
534}
535
536
537////////////////////////////////////////////////////////////////////////
538//
539// LiveProcess member definitions
540//
541////////////////////////////////////////////////////////////////////////
542
543
544LiveProcess::LiveProcess(LiveProcessParams * params, ObjectFile *_objFile)
545 : Process(params), objFile(_objFile),
546 argv(params->cmd), envp(params->env), cwd(params->cwd)
547{
548 __uid = params->uid;
549 __euid = params->euid;
550 __gid = params->gid;
551 __egid = params->egid;
552 __pid = params->pid;
553 __ppid = params->ppid;
554
555 prog_fname = params->cmd[0];
556
557 // load up symbols, if any... these may be used for debugging or
558 // profiling.
559 if (!debugSymbolTable) {
560 debugSymbolTable = new SymbolTable();
561 if (!objFile->loadGlobalSymbols(debugSymbolTable) ||
562 !objFile->loadLocalSymbols(debugSymbolTable)) {
563 // didn't load any symbols
564 delete debugSymbolTable;
565 debugSymbolTable = NULL;
566 }
567 }
568}
569
570void
571LiveProcess::syscall(int64_t callnum, ThreadContext *tc)
572{
573#if !FULL_SYSTEM
574 num_syscalls++;
575
576 SyscallDesc *desc = getDesc(callnum);
577 if (desc == NULL)
578 fatal("Syscall %d out of range", callnum);
579
580 desc->doSyscall(callnum, this, tc);
573 num_syscalls++;
574
575 SyscallDesc *desc = getDesc(callnum);
576 if (desc == NULL)
577 fatal("Syscall %d out of range", callnum);
578
579 desc->doSyscall(callnum, this, tc);
581#endif
582}
583
584IntReg
585LiveProcess::getSyscallArg(ThreadContext *tc, int &i, int width)
586{
587 return getSyscallArg(tc, i);
588}
589
590LiveProcess *
591LiveProcess::create(LiveProcessParams * params)
592{
593 LiveProcess *process = NULL;
594
595 string executable =
596 params->executable == "" ? params->cmd[0] : params->executable;
597 ObjectFile *objFile = createObjectFile(executable);
598 if (objFile == NULL) {
599 fatal("Can't load object file %s", executable);
600 }
601
602 if (objFile->isDynamic())
603 fatal("Object file is a dynamic executable however only static "
604 "executables are supported!\n Please recompile your "
605 "executable as a static binary and try again.\n");
606
580}
581
582IntReg
583LiveProcess::getSyscallArg(ThreadContext *tc, int &i, int width)
584{
585 return getSyscallArg(tc, i);
586}
587
588LiveProcess *
589LiveProcess::create(LiveProcessParams * params)
590{
591 LiveProcess *process = NULL;
592
593 string executable =
594 params->executable == "" ? params->cmd[0] : params->executable;
595 ObjectFile *objFile = createObjectFile(executable);
596 if (objFile == NULL) {
597 fatal("Can't load object file %s", executable);
598 }
599
600 if (objFile->isDynamic())
601 fatal("Object file is a dynamic executable however only static "
602 "executables are supported!\n Please recompile your "
603 "executable as a static binary and try again.\n");
604
607#if !FULL_SYSTEM
608#if THE_ISA == ALPHA_ISA
609 if (objFile->getArch() != ObjectFile::Alpha)
610 fatal("Object file architecture does not match compiled ISA (Alpha).");
611
612 switch (objFile->getOpSys()) {
613 case ObjectFile::Tru64:
614 process = new AlphaTru64Process(params, objFile);
615 break;
616
617 case ObjectFile::UnknownOpSys:
618 warn("Unknown operating system; assuming Linux.");
619 // fall through
620 case ObjectFile::Linux:
621 process = new AlphaLinuxProcess(params, objFile);
622 break;
623
624 default:
625 fatal("Unknown/unsupported operating system.");
626 }
627#elif THE_ISA == SPARC_ISA
628 if (objFile->getArch() != ObjectFile::SPARC64 &&
629 objFile->getArch() != ObjectFile::SPARC32)
630 fatal("Object file architecture does not match compiled ISA (SPARC).");
631 switch (objFile->getOpSys()) {
632 case ObjectFile::UnknownOpSys:
633 warn("Unknown operating system; assuming Linux.");
634 // fall through
635 case ObjectFile::Linux:
636 if (objFile->getArch() == ObjectFile::SPARC64) {
637 process = new Sparc64LinuxProcess(params, objFile);
638 } else {
639 process = new Sparc32LinuxProcess(params, objFile);
640 }
641 break;
642
643
644 case ObjectFile::Solaris:
645 process = new SparcSolarisProcess(params, objFile);
646 break;
647
648 default:
649 fatal("Unknown/unsupported operating system.");
650 }
651#elif THE_ISA == X86_ISA
652 if (objFile->getArch() != ObjectFile::X86_64 &&
653 objFile->getArch() != ObjectFile::I386)
654 fatal("Object file architecture does not match compiled ISA (x86).");
655 switch (objFile->getOpSys()) {
656 case ObjectFile::UnknownOpSys:
657 warn("Unknown operating system; assuming Linux.");
658 // fall through
659 case ObjectFile::Linux:
660 if (objFile->getArch() == ObjectFile::X86_64) {
661 process = new X86_64LinuxProcess(params, objFile);
662 } else {
663 process = new I386LinuxProcess(params, objFile);
664 }
665 break;
666
667 default:
668 fatal("Unknown/unsupported operating system.");
669 }
670#elif THE_ISA == MIPS_ISA
671 if (objFile->getArch() != ObjectFile::Mips)
672 fatal("Object file architecture does not match compiled ISA (MIPS).");
673 switch (objFile->getOpSys()) {
674 case ObjectFile::UnknownOpSys:
675 warn("Unknown operating system; assuming Linux.");
676 // fall through
677 case ObjectFile::Linux:
678 process = new MipsLinuxProcess(params, objFile);
679 break;
680
681 default:
682 fatal("Unknown/unsupported operating system.");
683 }
684#elif THE_ISA == ARM_ISA
685 if (objFile->getArch() != ObjectFile::Arm &&
686 objFile->getArch() != ObjectFile::Thumb)
687 fatal("Object file architecture does not match compiled ISA (ARM).");
688 switch (objFile->getOpSys()) {
689 case ObjectFile::UnknownOpSys:
690 warn("Unknown operating system; assuming Linux.");
691 // fall through
692 case ObjectFile::Linux:
693 process = new ArmLinuxProcess(params, objFile, objFile->getArch());
694 break;
695 case ObjectFile::LinuxArmOABI:
696 fatal("M5 does not support ARM OABI binaries. Please recompile with an"
697 " EABI compiler.");
698 default:
699 fatal("Unknown/unsupported operating system.");
700 }
701#elif THE_ISA == POWER_ISA
702 if (objFile->getArch() != ObjectFile::Power)
703 fatal("Object file architecture does not match compiled ISA (Power).");
704 switch (objFile->getOpSys()) {
705 case ObjectFile::UnknownOpSys:
706 warn("Unknown operating system; assuming Linux.");
707 // fall through
708 case ObjectFile::Linux:
709 process = new PowerLinuxProcess(params, objFile);
710 break;
711
712 default:
713 fatal("Unknown/unsupported operating system.");
714 }
715#else
716#error "THE_ISA not set"
717#endif
605#if THE_ISA == ALPHA_ISA
606 if (objFile->getArch() != ObjectFile::Alpha)
607 fatal("Object file architecture does not match compiled ISA (Alpha).");
608
609 switch (objFile->getOpSys()) {
610 case ObjectFile::Tru64:
611 process = new AlphaTru64Process(params, objFile);
612 break;
613
614 case ObjectFile::UnknownOpSys:
615 warn("Unknown operating system; assuming Linux.");
616 // fall through
617 case ObjectFile::Linux:
618 process = new AlphaLinuxProcess(params, objFile);
619 break;
620
621 default:
622 fatal("Unknown/unsupported operating system.");
623 }
624#elif THE_ISA == SPARC_ISA
625 if (objFile->getArch() != ObjectFile::SPARC64 &&
626 objFile->getArch() != ObjectFile::SPARC32)
627 fatal("Object file architecture does not match compiled ISA (SPARC).");
628 switch (objFile->getOpSys()) {
629 case ObjectFile::UnknownOpSys:
630 warn("Unknown operating system; assuming Linux.");
631 // fall through
632 case ObjectFile::Linux:
633 if (objFile->getArch() == ObjectFile::SPARC64) {
634 process = new Sparc64LinuxProcess(params, objFile);
635 } else {
636 process = new Sparc32LinuxProcess(params, objFile);
637 }
638 break;
639
640
641 case ObjectFile::Solaris:
642 process = new SparcSolarisProcess(params, objFile);
643 break;
644
645 default:
646 fatal("Unknown/unsupported operating system.");
647 }
648#elif THE_ISA == X86_ISA
649 if (objFile->getArch() != ObjectFile::X86_64 &&
650 objFile->getArch() != ObjectFile::I386)
651 fatal("Object file architecture does not match compiled ISA (x86).");
652 switch (objFile->getOpSys()) {
653 case ObjectFile::UnknownOpSys:
654 warn("Unknown operating system; assuming Linux.");
655 // fall through
656 case ObjectFile::Linux:
657 if (objFile->getArch() == ObjectFile::X86_64) {
658 process = new X86_64LinuxProcess(params, objFile);
659 } else {
660 process = new I386LinuxProcess(params, objFile);
661 }
662 break;
663
664 default:
665 fatal("Unknown/unsupported operating system.");
666 }
667#elif THE_ISA == MIPS_ISA
668 if (objFile->getArch() != ObjectFile::Mips)
669 fatal("Object file architecture does not match compiled ISA (MIPS).");
670 switch (objFile->getOpSys()) {
671 case ObjectFile::UnknownOpSys:
672 warn("Unknown operating system; assuming Linux.");
673 // fall through
674 case ObjectFile::Linux:
675 process = new MipsLinuxProcess(params, objFile);
676 break;
677
678 default:
679 fatal("Unknown/unsupported operating system.");
680 }
681#elif THE_ISA == ARM_ISA
682 if (objFile->getArch() != ObjectFile::Arm &&
683 objFile->getArch() != ObjectFile::Thumb)
684 fatal("Object file architecture does not match compiled ISA (ARM).");
685 switch (objFile->getOpSys()) {
686 case ObjectFile::UnknownOpSys:
687 warn("Unknown operating system; assuming Linux.");
688 // fall through
689 case ObjectFile::Linux:
690 process = new ArmLinuxProcess(params, objFile, objFile->getArch());
691 break;
692 case ObjectFile::LinuxArmOABI:
693 fatal("M5 does not support ARM OABI binaries. Please recompile with an"
694 " EABI compiler.");
695 default:
696 fatal("Unknown/unsupported operating system.");
697 }
698#elif THE_ISA == POWER_ISA
699 if (objFile->getArch() != ObjectFile::Power)
700 fatal("Object file architecture does not match compiled ISA (Power).");
701 switch (objFile->getOpSys()) {
702 case ObjectFile::UnknownOpSys:
703 warn("Unknown operating system; assuming Linux.");
704 // fall through
705 case ObjectFile::Linux:
706 process = new PowerLinuxProcess(params, objFile);
707 break;
708
709 default:
710 fatal("Unknown/unsupported operating system.");
711 }
712#else
713#error "THE_ISA not set"
714#endif
718#endif
719
720 if (process == NULL)
721 fatal("Unknown error creating process object.");
722 return process;
723}
724
725LiveProcess *
726LiveProcessParams::create()
727{
728 return LiveProcess::create(this);
729}
715
716 if (process == NULL)
717 fatal("Unknown error creating process object.");
718 return process;
719}
720
721LiveProcess *
722LiveProcessParams::create()
723{
724 return LiveProcess::create(this);
725}