Gabe Black has submitted this change and it was merged. ( https://gem5-review.googlesource.com/c/public/gem5/+/13190 )

Change subject: systemc: Modify reportifyException to keep sc_reports in scope.
......................................................................

systemc: Modify reportifyException to keep sc_reports in scope.

reportifyException was sometimes indirectly creating temporary
sc_report objects which would go out of scope when they were
returned. The later code which tried to print them would then read
garbage.

Change-Id: I0a744eb029c62bf2ffee83db0a0e6dcbe3e60f7d
Reviewed-on: https://gem5-review.googlesource.com/c/13190
Reviewed-by: Gabe Black <[email protected]>
Maintainer: Gabe Black <[email protected]>
---
M src/systemc/core/sc_main.cc
M src/systemc/core/scheduler.cc
M src/systemc/core/scheduler.hh
3 files changed, 8 insertions(+), 10 deletions(-)

Approvals:
  Gabe Black: Looks good to me, approved; Looks good to me, approved



diff --git a/src/systemc/core/sc_main.cc b/src/systemc/core/sc_main.cc
index e9df6a1..59ec9f8 100644
--- a/src/systemc/core/sc_main.cc
+++ b/src/systemc/core/sc_main.cc
@@ -81,8 +81,7 @@
                 resultStr = r.what();
             } catch (...) {
                 // There was some other type of exception we need to wrap.
-                const sc_report *r = ::sc_gem5::reportifyException();
-                resultStr = r->what();
+                resultStr = ::sc_gem5::reportifyException().what();
             }
             ::sc_gem5::Kernel::scMainFinished(true);
             ::sc_gem5::scheduler.clear();
diff --git a/src/systemc/core/scheduler.cc b/src/systemc/core/scheduler.cc
index fe1d7c2..d575055 100644
--- a/src/systemc/core/scheduler.cc
+++ b/src/systemc/core/scheduler.cc
@@ -418,11 +418,10 @@
 }

 void
-Scheduler::throwToScMain(const ::sc_core::sc_report *r)
+Scheduler::throwToScMain()
 {
-    if (!r)
-        r = reportifyException();
-    _throwToScMain = r;
+    ::sc_core::sc_report report = reportifyException();
+    _throwToScMain = &report;
     status(StatusOther);
     scMain->run();
 }
@@ -462,7 +461,7 @@

 } // anonymous namespace

-const ::sc_core::sc_report *
+const ::sc_core::sc_report
 reportifyException()
 {
     ::sc_core::sc_report_handler_proc old_handler =
@@ -488,7 +487,7 @@
         }
     } catch (const ::sc_core::sc_report &r) {
         ::sc_core::sc_report_handler::set_handler(old_handler);
-        return &r;
+        return r;
     }
     panic("No exception thrown in reportifyException.");
 }
diff --git a/src/systemc/core/scheduler.hh b/src/systemc/core/scheduler.hh
index de9d627..83585dd 100644
--- a/src/systemc/core/scheduler.hh
+++ b/src/systemc/core/scheduler.hh
@@ -365,7 +365,7 @@

     uint64_t changeStamp() { return _changeStamp; }

-    void throwToScMain(const ::sc_core::sc_report *r=nullptr);
+    void throwToScMain();

     Status status() { return _status; }
     void status(Status s) { _status = s; }
@@ -511,7 +511,7 @@
     scheduler.completeTimeSlot(this);
 }

-const ::sc_core::sc_report *reportifyException();
+const ::sc_core::sc_report reportifyException();

 } // namespace sc_gem5


--
To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/13190
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: I0a744eb029c62bf2ffee83db0a0e6dcbe3e60f7d
Gerrit-Change-Number: 13190
Gerrit-PatchSet: 5
Gerrit-Owner: Gabe Black <[email protected]>
Gerrit-Reviewer: Andreas Sandberg <[email protected]>
Gerrit-Reviewer: Gabe Black <[email protected]>
Gerrit-Reviewer: Giacomo Travaglini <[email protected]>
Gerrit-Reviewer: Jason Lowe-Power <[email protected]>
Gerrit-Reviewer: Matthias Jung <[email protected]>
Gerrit-MessageType: merged
_______________________________________________
gem5-dev mailing list
[email protected]
http://m5sim.org/mailman/listinfo/gem5-dev

Reply via email to