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 <gabeblack@google.com>
Maintainer: Gabe Black <gabeblack@google.com>
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();
}
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();
}
} // anonymous namespace
-const ::sc_core::sc_report *
+const ::sc_core::sc_report
reportifyException()
{
::sc_core::sc_report_handler_proc old_handler =
}
} 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.");
}
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; }
scheduler.completeTimeSlot(this);
}
-const ::sc_core::sc_report *reportifyException();
+const ::sc_core::sc_report reportifyException();
} // namespace sc_gem5