Jump to content

Backtrace with sc_report_error()


AndrewH

Recommended Posts

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.

Link to comment
Share on other sites

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.

 

Link to comment
Share on other sites

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:

 

Link to comment
Share on other sites

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);


 

 

Link to comment
Share on other sites

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.

 

 

Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...