Testing with CppUnit, compiled with gcc, produce stack trace
<p>I have a lot of C++ test-cases that are all implemented using the CppUnit unit testing framework. </p>

<p>In our project we have tons of statements in various test-classes and various helper classes - short - spread around the whole testing code - which all somewhere deep inside rely on the various <strong>CPPUNIT_ASSERT_****</strong> macros to ensure the results are as expected.</p>

<p>A typical helper function that is used during the testing framework might look like this:</p>

<pre><code>void checkMatricesEqual(const Matrix&amp; ref,const Matrix&amp; val) {
    CPPUNIT_ASSERT_EQUAL(ref.w,val.w);
    CPPUNIT_ASSERT_EQUAL(ref.h,val.h);
    ...
    ...
}
</code></pre>

<p>Now, if an assertion fails, CppUnit prints out the name of the test function, and the file.cpp:line, which is not very helpful if it points to a general test helper function like the one above. In a big testing framework the location of an error can be hard to track down then.</p>

<p>Instead, I would really love to see a stack trace as output instead. 
I know that printing a stack trace from with some chunk of code using internal gcc libraries and -g is possible <a href="https://stackoverflow.com/questions/77005/how-to-generate-a-stacktrace-when-my-gcc-c-app-crashes">How to generate a stacktrace when my gcc C++ app crashes</a>.</p>

<p>What I don't know: How can one integrate this with CppUnit?
Create a patch and override the original CppUnit functionality?
Maybe somehow hook into the generation of messages?</p>

<p>If anyone has a hint how to accomplish something like this I would really appreciate.</p>