syscall_emul.hh (11386:94c09b607a84) syscall_emul.hh (11392:5967db4cff04)
1/*
2 * Copyright (c) 2012-2013, 2015 ARM Limited
3 * Copyright (c) 2015 Advanced Micro Devices, Inc.
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

--- 43 unchanged lines hidden (view full) ---

52///
53/// @file syscall_emul.hh
54///
55/// This file defines objects used to emulate syscalls from the target
56/// application on the host machine.
57
58#ifdef __CYGWIN32__
59#include <sys/fcntl.h> // for O_BINARY
1/*
2 * Copyright (c) 2012-2013, 2015 ARM Limited
3 * Copyright (c) 2015 Advanced Micro Devices, Inc.
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

--- 43 unchanged lines hidden (view full) ---

52///
53/// @file syscall_emul.hh
54///
55/// This file defines objects used to emulate syscalls from the target
56/// application on the host machine.
57
58#ifdef __CYGWIN32__
59#include <sys/fcntl.h> // for O_BINARY
60
60#endif
61#endif
62#include <fcntl.h>
61#include <sys/mman.h>
62#include <sys/stat.h>
63#include <sys/time.h>
64#include <sys/uio.h>
63#include <sys/mman.h>
64#include <sys/stat.h>
65#include <sys/time.h>
66#include <sys/uio.h>
65#include <fcntl.h>
66
67#include <cerrno>
68#include <string>
69
70#include "base/chunk_generator.hh"
71#include "base/intmath.hh" // for RoundUp
67
68#include <cerrno>
69#include <string>
70
71#include "base/chunk_generator.hh"
72#include "base/intmath.hh" // for RoundUp
73#include "base/loader/object_file.hh"
72#include "base/misc.hh"
73#include "base/trace.hh"
74#include "base/types.hh"
75#include "config/the_isa.hh"
76#include "cpu/base.hh"
77#include "cpu/thread_context.hh"
78#include "debug/SyscallBase.hh"
79#include "debug/SyscallVerbose.hh"

--- 1269 unchanged lines hidden (view full) ---

1349 // on the specified offset into the file.
1350 uint64_t size = std::min((uint64_t)file_stat.st_size - offset,
1351 length);
1352 tp.writeBlob(start, pmap, size);
1353
1354 // Cleanup the mmap region before exiting this function.
1355 munmap(pmap, length);
1356
74#include "base/misc.hh"
75#include "base/trace.hh"
76#include "base/types.hh"
77#include "config/the_isa.hh"
78#include "cpu/base.hh"
79#include "cpu/thread_context.hh"
80#include "debug/SyscallBase.hh"
81#include "debug/SyscallVerbose.hh"

--- 1269 unchanged lines hidden (view full) ---

1351 // on the specified offset into the file.
1352 uint64_t size = std::min((uint64_t)file_stat.st_size - offset,
1353 length);
1354 tp.writeBlob(start, pmap, size);
1355
1356 // Cleanup the mmap region before exiting this function.
1357 munmap(pmap, length);
1358
1359 // Maintain the symbol table for dynamic executables.
1360 // The loader will call mmap to map the images into its address
1361 // space and we intercept that here. We can verify that we are
1362 // executing inside the loader by checking the program counter value.
1363 // XXX: with multiprogrammed workloads or multi-node configurations,
1364 // this will not work since there is a single global symbol table.
1365 ObjectFile *interpreter = p->getInterpreter();
1366 if (interpreter) {
1367 Addr text_start = interpreter->textBase();
1368 Addr text_end = text_start + interpreter->textSize();
1369
1370 Addr pc = tc->pcState().pc();
1371
1372 if (pc >= text_start && pc < text_end) {
1373 FDEntry *fde = p->getFDEntry(tgt_fd);
1374
1375 ObjectFile *lib = createObjectFile(fde->filename);
1376
1377 if (lib) {
1378 lib->loadAllSymbols(debugSymbolTable,
1379 lib->textBase(), start);
1380 }
1381 }
1382 }
1383
1357 // Note that we do not zero out the remainder of the mapping. This
1358 // is done by a real system, but it probably will not affect
1359 // execution (hopefully).
1360 }
1361
1362 return start;
1363}
1364

--- 243 unchanged lines hidden ---
1384 // Note that we do not zero out the remainder of the mapping. This
1385 // is done by a real system, but it probably will not affect
1386 // execution (hopefully).
1387 }
1388
1389 return start;
1390}
1391

--- 243 unchanged lines hidden ---