public inbox for libstdc++@gcc.gnu.org
 help / color / mirror / Atom feed
* How do I debug a test for libstdc++?
@ 2023-03-07 13:49 Dimitrij Mijoski
  2023-03-07 14:08 ` Jonathan Wakely
  0 siblings, 1 reply; 2+ messages in thread
From: Dimitrij Mijoski @ 2023-03-07 13:49 UTC (permalink / raw)
  To: libstdc++

[-- Attachment #1: Type: text/plain, Size: 660 bytes --]

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 .

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=..."

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.

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: How do I debug a test for libstdc++?
  2023-03-07 13:49 How do I debug a test for libstdc++? Dimitrij Mijoski
@ 2023-03-07 14:08 ` Jonathan Wakely
  0 siblings, 0 replies; 2+ messages in thread
From: Jonathan Wakely @ 2023-03-07 14:08 UTC (permalink / raw)
  To: Dimitrij Mijoski; +Cc: libstdc++

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.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-03-07 14:09 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-03-07 13:49 How do I debug a test for libstdc++? Dimitrij Mijoski
2023-03-07 14:08 ` Jonathan Wakely

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).