AndrewH Posted March 2, 2018 Report Share Posted March 2, 2018 Does anyone know if it is possible to see the call stack when sc_report_error() is called? Here's an example of the output under lldb when my systemC program is run. The call to sc_report_error() causes the program to exit, leaving no call stack. Error: (E5) out of bounds In file: /usr/local/systemc/include/sysc/datatypes/bit/sc_bit_proxies.h:2487 In process: x.y.z @ 5 ns Process 10618 exited with status = 1 (0x00000001) Is there a configuration flag to cause sc_report_error() to not cause an exit()? Thanks in advance for your help. Quote Link to comment Share on other sites More sharing options...
David Black Posted March 2, 2018 Report Share Posted March 2, 2018 I suspect your problem is not understanding that the default action for SC_ERROR is to throw an exception. So you have two choices: 1. Surround calls with a try/catch block. 2. Change the default action to SC_DISPLAY without SC_THROW. I would also suggest you use the SC_REPORT_ERROR() macro so that you get the file and line number where the call originated. Quote Link to comment Share on other sites More sharing options...
Roman Popov Posted March 3, 2018 Report Share Posted March 3, 2018 If you want to see stacktrace in LLDB, then just set a breakpoint in sc_report_error(). If you want to see a stacktrace when you run simulation without debugger, then use Boost::Stacktrace http://www.boost.org/doc/libs/1_65_1/doc/html/stacktrace.html maehne 1 Quote Link to comment Share on other sites More sharing options...
AndrewH Posted March 6, 2018 Author Report Share Posted March 6, 2018 On 3/2/2018 at 3:31 PM, David Black said: I suspect your problem is not understanding that the default action for SC_ERROR is to throw an exception. So you have two choices: 1. Surround calls with a try/catch block. 2. Change the default action to SC_DISPLAY without SC_THROW. I would also suggest you use the SC_REPORT_ERROR() macro so that you get the file and line number where the call originated. 1. Doesn't try/catch block work only within that thread? 2. Can you kindly point me to documentation on how to change the default action of SC_ERROR? I couldn't find it in the UserGuide and did not find useful googling the internet. I would like to change it to SC_ABORT and change the abort handler to use Boost to dump the stack (as Roman suggested above). Yes, SC_REPORT_ERROR() is being used and in the output that I showed above, it is identifying a system C include file as the place where SC_REPORT_ERROR() is called. On 3/2/2018 at 6:16 PM, Roman Popov said: Quote Link to comment Share on other sites More sharing options...
Roman Popov Posted March 6, 2018 Report Share Posted March 6, 2018 34 minutes ago, AndrewH said: Can you kindly point me to documentation on how to change the default action of SC_ERROR? I couldn't find it in the UserGuide and did not find useful googling the internet. Did you checked SystemC standard? 8.3 sc_report_handler. You can try doing it like this: void my_handler(const sc_report& r, const sc_actions & a) { sc_report_handler::default_handler(r,a); } sc_report_handler::set_handler(my_handler); Quote Link to comment Share on other sites More sharing options...
David Black Posted March 7, 2018 Report Share Posted March 7, 2018 Using your own report handler is a bit extreme; although, instructive. I suggest using the sc_report_handler::set_action() method. Please read the standards document (downloadable from IEEE via link on Accellera). It's quite readable. Philipp A Hartmann 1 Quote Link to comment Share on other sites More sharing options...
AndrewH Posted March 14, 2018 Author Report Share Posted March 14, 2018 Thanks for all of the suggestions. It turns out that the file name and line number in the output that I originally posted can be used to set a breakpoint and from there a call stack can be dumped (with bt). This approach is a bit like what Roman had suggested. I was also able to get sc_report_handler::set_action() to work. It's great to have all of the options suggested here. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.