How do I debug a test for libstdc++?

Jonathan Wakely jwakely.gcc@gmail.com
Tue Mar 7 14:08:53 GMT 2023


On Tue, 7 Mar 2023 at 13:49, Dimitrij Mijoski via Libstdc++
<libstdc++@gcc.gnu.org> wrote:
>
> My question consists of three subquestions.
>
> Q1. How do i get a debug build of libstdc++?
> I think I know the answer here and it is to use the configuration option --enable-libstdcxx-debug. See https://gcc.gnu.org/onlinedocs/libstdc++/manual/configure.html .

Right. But that's to build a debug lib for installation, not for use
by the testsuite.

Another option is just to build the normal library with different
flags, or just build a specific file that way:
rm src/c++11/codecvt.{o,lo}
make CXXFLAGS="-O0 -g" -C src/c++11
make all -j4
Now the normal libstdc++.so will include an unoptimized codecvt.o

> Q2. How do I run the testsuite against the debug build?
> My guess is that it has something to do with target_board,
> make check-target-libstdc++-v3 RUNTESTFLAGS="--target_board=..."

I don't think that is the way to go. It would be possible to do it via
a target board, but not easy.

> Q3. How do I break into a test case with a debugger?
> I discovered the tool gccsrcdir/contrib/repro_fail, but it is only useful to debug compilation tests, not execution tests. It is there to debug GCC itself.

You can't get the test harness to run with a debugger. Just build the
test by hand and run it under gdb by hand.

In the testsuite directory the libstdc++.log file shows the full
command used to compile every test, and the LD_LIBRARY_PATH used to
run it (so it finds the just-built libs).

Just find the test you're interested in, copy the command shown after
"spawn -ignore SIGHUP" and run that command (in the testsuite dir) to
produce an executable. You can alter the flags to suit (e.g. adding
-static-libstdc++ if you don't want to have to set LD_LIBRARY_PATH or
similar). If you built a debug library instead of just rebuilding
specific object files without optimization, you can adjust the -L
options to find the debug lib (which is in src/debug/.libs instead of
src/.libs)

Then you can just debug the executable as normal.


More information about the Libstdc++ mailing list