[gem5-dev] Change in gem5/gem5[master]: sim-se: bugfix for 54c77aa055e

2019-04-29 Thread Brandon Potter (Gerrit)
Brandon Potter has submitted this change and it was merged. (  
https://gem5-review.googlesource.com/c/public/gem5/+/18448 )


Change subject: sim-se: bugfix for 54c77aa055e
..

sim-se: bugfix for 54c77aa055e

54c77aa055e introduced a bug which manifests as cyclical
dependency on a member initialization for the Process
class.

The current working directory (cwd) parameter is passed into
Process to initialize both the target and host versions of the
cwd. (The target and host versions may differ if the faux
filesystem is used.) The host cwd init invoked methods which
rely on the host cwd already being initialized. To avoid the
bug, the code will now rely on using the targets cwd version,
but will issue checks against the redirect paths.

Change-Id: I4ab644a3e00737dbf249f5d6faf20a26ceb04248
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/18448
Reviewed-by: Jason Lowe-Power 
Maintainer: Jason Lowe-Power 
Tested-by: kokoro 
---
M src/sim/process.cc
1 file changed, 15 insertions(+), 18 deletions(-)

Approvals:
  Jason Lowe-Power: Looks good to me, approved; Looks good to me, approved
  kokoro: Regressions pass



diff --git a/src/sim/process.cc b/src/sim/process.cc
index 10c68fe..d400b5d 100644
--- a/src/sim/process.cc
+++ b/src/sim/process.cc
@@ -456,19 +456,16 @@
 std::string
 Process::checkPathRedirect(const std::string )
 {
-// If the input parameter contains a relative path, convert it. Note,
-// the return value for this method should always return an absolute
-// path on the host filesystem. The return value will be used to
-// open and manipulate the path specified by the input parameter. Since
-// all filesystem handling in syscall mode is passed through to the  
host,

-// we deal only with host paths.
-auto host_fs_abs_path = absolutePath(filename, true);
+// If the input parameter contains a relative path, convert it.
+// The target version of the current working directory is fine since
+// we immediately convert it using redirect paths into a host version.
+auto abs_path = absolutePath(filename, false);

 for (auto path : system->redirectPaths) {
 // Search through the redirect paths to see if a starting  
substring of

 // our path falls into any buckets which need to redirected.
-if (startswith(host_fs_abs_path, path->appPath())) {
-std::string tail =  
host_fs_abs_path.substr(path->appPath().size());

+if (startswith(abs_path, path->appPath())) {
+std::string tail = abs_path.substr(path->appPath().size());

 // If this path needs to be redirected, search through a list
 // of targets to see if we can match a valid file (or  
directory).

@@ -486,7 +483,7 @@
 }

 // The path does not need to be redirected.
-return host_fs_abs_path;
+return abs_path;
 }

 void
@@ -543,17 +540,17 @@
 if (filename.empty() || startswith(filename, "/"))
 return filename;

-// Verify that the current working directories are initialized  
properly.

-// These members should be set initially via params from 'Process.py',
-// although they may change over time depending on what the application
-// does during simulation.
-assert(!tgtCwd.empty());
-assert(!hostCwd.empty());
-
 // Construct the absolute path given the current working directory for
 // either the host filesystem or target filesystem. The distinction  
only

 // matters if filesystem redirection is utilized in the simulation.
-auto path_base = host_filesystem ? hostCwd : tgtCwd;
+auto path_base = std::string();
+if (host_filesystem) {
+path_base = hostCwd;
+assert(!hostCwd.empty());
+} else {
+path_base = tgtCwd;
+assert(!tgtCwd.empty());
+}

 // Add a trailing '/' if the current working directory did not have  
one.

 normalize(path_base);

--
To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/18448
To unsubscribe, or for help writing mail filters, visit  
https://gem5-review.googlesource.com/settings


Gerrit-Project: public/gem5
Gerrit-Branch: master
Gerrit-Change-Id: I4ab644a3e00737dbf249f5d6faf20a26ceb04248
Gerrit-Change-Number: 18448
Gerrit-PatchSet: 2
Gerrit-Owner: Brandon Potter 
Gerrit-Reviewer: Brandon Potter 
Gerrit-Reviewer: Giacomo Travaglini 
Gerrit-Reviewer: Jason Lowe-Power 
Gerrit-Reviewer: kokoro 
Gerrit-MessageType: merged
___
gem5-dev mailing list
gem5-dev@gem5.org
http://m5sim.org/mailman/listinfo/gem5-dev

[gem5-dev] Change in gem5/gem5[master]: sim-se: bugfix for 54c77aa055e

2019-04-29 Thread Brandon Potter (Gerrit)
Brandon Potter has uploaded this change for review. (  
https://gem5-review.googlesource.com/c/public/gem5/+/18448



Change subject: sim-se: bugfix for 54c77aa055e
..

sim-se: bugfix for 54c77aa055e

54c77aa055e introduced a bug which manifests as cyclical
dependency on a member initialization for the Process
class.

The current working directory (cwd) parameter is passed into
Process to initialize both the target and host versions of the
cwd. (The target and host versions may differ if the faux
filesystem is used.) The host cwd init invoked methods which
rely on the host cwd already being initialized. To avoid the
bug, the code will now rely on using the targets cwd version,
but will issue checks against the redirect paths.

Change-Id: I4ab644a3e00737dbf249f5d6faf20a26ceb04248
---
M src/sim/process.cc
1 file changed, 15 insertions(+), 18 deletions(-)



diff --git a/src/sim/process.cc b/src/sim/process.cc
index 10c68fe..d400b5d 100644
--- a/src/sim/process.cc
+++ b/src/sim/process.cc
@@ -456,19 +456,16 @@
 std::string
 Process::checkPathRedirect(const std::string )
 {
-// If the input parameter contains a relative path, convert it. Note,
-// the return value for this method should always return an absolute
-// path on the host filesystem. The return value will be used to
-// open and manipulate the path specified by the input parameter. Since
-// all filesystem handling in syscall mode is passed through to the  
host,

-// we deal only with host paths.
-auto host_fs_abs_path = absolutePath(filename, true);
+// If the input parameter contains a relative path, convert it.
+// The target version of the current working directory is fine since
+// we immediately convert it using redirect paths into a host version.
+auto abs_path = absolutePath(filename, false);

 for (auto path : system->redirectPaths) {
 // Search through the redirect paths to see if a starting  
substring of

 // our path falls into any buckets which need to redirected.
-if (startswith(host_fs_abs_path, path->appPath())) {
-std::string tail =  
host_fs_abs_path.substr(path->appPath().size());

+if (startswith(abs_path, path->appPath())) {
+std::string tail = abs_path.substr(path->appPath().size());

 // If this path needs to be redirected, search through a list
 // of targets to see if we can match a valid file (or  
directory).

@@ -486,7 +483,7 @@
 }

 // The path does not need to be redirected.
-return host_fs_abs_path;
+return abs_path;
 }

 void
@@ -543,17 +540,17 @@
 if (filename.empty() || startswith(filename, "/"))
 return filename;

-// Verify that the current working directories are initialized  
properly.

-// These members should be set initially via params from 'Process.py',
-// although they may change over time depending on what the application
-// does during simulation.
-assert(!tgtCwd.empty());
-assert(!hostCwd.empty());
-
 // Construct the absolute path given the current working directory for
 // either the host filesystem or target filesystem. The distinction  
only

 // matters if filesystem redirection is utilized in the simulation.
-auto path_base = host_filesystem ? hostCwd : tgtCwd;
+auto path_base = std::string();
+if (host_filesystem) {
+path_base = hostCwd;
+assert(!hostCwd.empty());
+} else {
+path_base = tgtCwd;
+assert(!tgtCwd.empty());
+}

 // Add a trailing '/' if the current working directory did not have  
one.

 normalize(path_base);

--
To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/18448
To unsubscribe, or for help writing mail filters, visit  
https://gem5-review.googlesource.com/settings


Gerrit-Project: public/gem5
Gerrit-Branch: master
Gerrit-Change-Id: I4ab644a3e00737dbf249f5d6faf20a26ceb04248
Gerrit-Change-Number: 18448
Gerrit-PatchSet: 1
Gerrit-Owner: Brandon Potter 
Gerrit-MessageType: newchange
___
gem5-dev mailing list
gem5-dev@gem5.org
http://m5sim.org/mailman/listinfo/gem5-dev