Deleted Added
sdiff udiff text old ( 13883:f44e21d3aaa7 ) new ( 13906:005b70666608 )
full compact
1/*
2 * Copyright (c) 2014-2016 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

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

451 }
452
453 return nullptr;
454}
455
456std::string
457Process::checkPathRedirect(const std::string &filename)
458{
459 // If the input parameter contains a relative path, convert it. Note,
460 // the return value for this method should always return an absolute
461 // path on the host filesystem. The return value will be used to
462 // open and manipulate the path specified by the input parameter. Since
463 // all filesystem handling in syscall mode is passed through to the host,
464 // we deal only with host paths.
465 auto host_fs_abs_path = absolutePath(filename, true);
466
467 for (auto path : system->redirectPaths) {
468 // Search through the redirect paths to see if a starting substring of
469 // our path falls into any buckets which need to redirected.
470 if (startswith(host_fs_abs_path, path->appPath())) {
471 std::string tail = host_fs_abs_path.substr(path->appPath().size());
472
473 // If this path needs to be redirected, search through a list
474 // of targets to see if we can match a valid file (or directory).
475 for (auto host_path : path->hostPaths()) {
476 if (access((host_path + tail).c_str(), R_OK) == 0) {
477 // Return the valid match.
478 return host_path + tail;
479 }
480 }
481 // The path needs to be redirected, but the file or directory
482 // does not exist on the host filesystem. Return the first
483 // host path as a default.
484 return path->hostPaths()[0] + tail;
485 }
486 }
487
488 // The path does not need to be redirected.
489 return host_fs_abs_path;
490}
491
492void
493Process::updateBias()
494{
495 ObjectFile *interp = objFile->getInterpreter();
496
497 if (!interp || !interp->relocatable())

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

538}
539
540std::string
541Process::absolutePath(const std::string &filename, bool host_filesystem)
542{
543 if (filename.empty() || startswith(filename, "/"))
544 return filename;
545
546 // Verify that the current working directories are initialized properly.
547 // These members should be set initially via params from 'Process.py',
548 // although they may change over time depending on what the application
549 // does during simulation.
550 assert(!tgtCwd.empty());
551 assert(!hostCwd.empty());
552
553 // Construct the absolute path given the current working directory for
554 // either the host filesystem or target filesystem. The distinction only
555 // matters if filesystem redirection is utilized in the simulation.
556 auto path_base = host_filesystem ? hostCwd : tgtCwd;
557
558 // Add a trailing '/' if the current working directory did not have one.
559 normalize(path_base);
560
561 // Append the filename onto the current working path.
562 auto absolute_path = path_base + filename;
563
564 return absolute_path;

--- 162 unchanged lines hidden ---