base: Improve error message occurs when base couldn't open a file
authorHoa Nguyen <hoanguyen@ucdavis.edu>
Tue, 30 Jun 2020 02:31:15 +0000 (19:31 -0700)
committerHoa Nguyen <hoanguyen@ucdavis.edu>
Tue, 30 Jun 2020 18:53:18 +0000 (18:53 +0000)
Change-Id: Icaa571216f0eed4527a6aaddcf0c6814ad282c56
Signed-off-by: Hoa Nguyen <hoanguyen@ucdavis.edu>
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/30794
Reviewed-by: Giacomo Travaglini <giacomo.travaglini@arm.com>
Reviewed-by: Jason Lowe-Power <power.jg@gmail.com>
Maintainer: Jason Lowe-Power <power.jg@gmail.com>
Tested-by: kokoro <noreply+kokoro@google.com>
src/base/output.cc

index 47b8aa7f4de25b5b283b920bf7bef54e55b1ac3a..5703a379caf9fdcfafffedc36ab4c94c253eeeeb 100644 (file)
@@ -84,9 +84,11 @@ OutputFile<StreamType>::OutputFile(const OutputDirectory &dir,
     _mode(mode), _recreateable(recreateable),
     _fstream(static_cast<stream_type_t *>(_stream))
 {
-    _fstream->open(dir.resolve(_name).c_str(), _mode);
+    std::string resolved_path = dir.resolve(_name);
 
-    assert(_fstream->is_open());
+    _fstream->open(resolved_path.c_str(), _mode);
+
+    panic_if(!_fstream->is_open(), "Failed to open \"%s\"\n", resolved_path);
 }
 
 template<class StreamType>