This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Porting UnitTest++ to C6455

Other Parts Discussed in Thread: SYSBIOS

I have ported the UnitTest++ framework to a CCS v.5.1 project running on the DSK 6455.  UnitTest++ is an open source unit testing framework for C++.  It has a set of self-tests that can be run to determine if the framework itself is operating correctly.  Most of the 175 self-tests pass, but there is one failure I would like to ask about.

Without getting into too much detail about how UnitTest++ works, I'll say the failed test is intentionally causing an exception in order to see if the test reports this as a failure condition.   A try/catch construct is used to trap the exception.  Several of the other self-tests also generate intentional exceptions, and these are handled correctly as expected.  But the unique thing about the test in question is that (I suspect) it creates an internal CPU Instruction Fetch exception which apparently cannot be intercepted by the try/catch.  Instead, I get the following error message in the console and my application is terminated (note there were a bunch of register values printed too, but I'm not sure it's worth taking up all the space to add them here):

     Exception at 0x0

     EFR=0x2 NRP=0x[C64XP_0] 0

     Internal exception: IERR=0x1

     Instruction fetch exception

     ti.sysbios.family.c64p.Exception: line 248: E_exceptionMin: pc = 0x0088cf44, sp = 0x0090b1f8.

     xdc.runtime.Error.raise: terminating execution

 

The method used by UnitTest++ to generate the exception is the following line of code:

     reinterpret_cast< void (*) () >(0) ();

This code seems to be basically making a function call through a function pointer that is 0.   No surprise this generates an exception, but that is what they want to do for the test.  I can generate the same error with the following code:

     void (*FuncPtr) ();

     FuncPtr = 0;

     (*FuncPtr) ();

So, finally to my question: is there a way to configure or build my project so the try/catch will catch the exception rather than have it terminate?  I looked into perhaps setting up some exception hook function via the Exception module in the xdc tool in hopes I could run my own function instead of the SYS/BIOS Exception_handler() function.  I can see in Exception_handler() where it might call my exception hook function.  But unfortunately, I can also see that it apparently will still fall through and call Error_raise() which is what terminates my application.

My worst-case solution is to add conditional compiles to the UnitTest++ code so this one test is left out.  I can see the UnitTest++ developers have already done this for the MINGW platform.  I was just hoping there was some simple way to avoid this on the TI DSP.

Other info about my configuration is as follows:

SYS/BIOS 6.32.5.54

Compiler TI v7.3.1

Output format: COFF Little Endian

XDCtools 3.22.04.46

Linking to rts64plus_eh.lib

Enable C++ exception handling checked

Any information you can provide is appreciated.  Thanks.

Jeff Vernon

  • Jeff,

    Jeff Vernon said:
    is there a way to configure or build my project so the try/catch will catch the exception rather than have it terminate?

    No.

    You can learn about CPU exceptions in the CPU & Instruction Set Reference Guide.

    All exceptions are intended to generate a Non-Maskable Interrupt which places the return address in the NRP register for the possibility of returning to the place of the exception. But not all exceptions are recoverable. If the NRP is set to an invalid address because the PC was at an invalid address, then the exception handler cannot return to a valid address; it does not know about your try/catch construct.

    If you want to understand more about the BIOS exception handling, we can move this to the BIOS forum or you can post a new question there if this answers your question here, even if not the answer you wanted.

    Regards,
    RandyP

  • Randy,

     

    Thanks.  That is what I suspected.  I will move forward with the approach of  eliminating this particular test.  It's the only test out of all the UnitTest++ self-tests that has a problem.