[2/4] testsuite/glib-2.34: Match/consume optional libthread_db related output

Message ID 20210610172641.1052704-3-kevinb@redhat.com
State New
Headers show
Series
  • libthread_db initialization changes related to upcoming glibc-2.34
Related show

Commit Message

Lancelot SIX via Gdb-patches June 10, 2021, 5:26 p.m.
When using glibc-2.34, we now see messages related to the loading of
the thread library for non-thread programs.  E.g.  for the test case,
gdb.base/execl-update-breakpoints.exp, we will see the following when
starting the program:

(gdb) break -qualified main
Breakpoint 1 at 0x100118c: file /ironwood1/sourceware-git/f34-2-glibc244_fix/bld/../../worktree-glibc244_fix/gdb/testsuite/gdb.base/execl-update-breakpoints.c, line 34.
(gdb) run
Starting program: [...]/execl-update-breakpoints1
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib64/libthread_db.so.1".

The two lines of output related to libthread_db are new; we didn't see
these in the past.  This is a side effect of libc now containing the
pthread API - we can no longer tell whether the program is
multi-threaded by simply looking for libpthread.so.  That said, I
think that we now want to load libthread_db anyway since it's used to
resolve TLS variables; i.e. we need it for correctly determining the
value of errno.

This commit adds the necessary regular expressions to match this
(optional) additional output in the two tests which were failing
without it.

gdb/testsuite/ChangeLog:

	* gdb.base/execl-update-breakpoints.exp: Add regular
	expression for optionally matching output related to
	libthread_db.
	* gdb.base/fork-print-inferior-events.exp: Likewise.
---
 gdb/testsuite/gdb.base/execl-update-breakpoints.exp   | 1 +
 gdb/testsuite/gdb.base/fork-print-inferior-events.exp | 3 ++-
 2 files changed, 3 insertions(+), 1 deletion(-)

-- 
2.31.1

Comments

Lancelot SIX via Gdb-patches June 11, 2021, 7:13 p.m. | #1
On 2021-06-10 1:26 p.m., Kevin Buettner via Gdb-patches wrote:
> When using glibc-2.34, we now see messages related to the loading of

> the thread library for non-thread programs.  E.g.  for the test case,

> gdb.base/execl-update-breakpoints.exp, we will see the following when

> starting the program:

> 

> (gdb) break -qualified main

> Breakpoint 1 at 0x100118c: file /ironwood1/sourceware-git/f34-2-glibc244_fix/bld/../../worktree-glibc244_fix/gdb/testsuite/gdb.base/execl-update-breakpoints.c, line 34.

> (gdb) run

> Starting program: [...]/execl-update-breakpoints1

> [Thread debugging using libthread_db enabled]

> Using host libthread_db library "/lib64/libthread_db.so.1".

> 

> The two lines of output related to libthread_db are new; we didn't see

> these in the past.  This is a side effect of libc now containing the

> pthread API - we can no longer tell whether the program is

> multi-threaded by simply looking for libpthread.so.  That said, I

> think that we now want to load libthread_db anyway since it's used to

> resolve TLS variables; i.e. we need it for correctly determining the

> value of errno.

> 

> This commit adds the necessary regular expressions to match this

> (optional) additional output in the two tests which were failing

> without it.



LGTM, thanks.

Simon

Patch

diff --git a/gdb/testsuite/gdb.base/execl-update-breakpoints.exp b/gdb/testsuite/gdb.base/execl-update-breakpoints.exp
index 63e741e85cd..f9cd7e861c4 100644
--- a/gdb/testsuite/gdb.base/execl-update-breakpoints.exp
+++ b/gdb/testsuite/gdb.base/execl-update-breakpoints.exp
@@ -132,6 +132,7 @@  proc test { always_inserted } {
 	"Continuing\\.\r\n" \
 	"${not_nl} is executing new program: ${not_nl}\r\n" \
 	"(Reading ${not_nl} from remote target\\.\\.\\.\r\n)*" \
+	"(?:.Thread debugging using .*? enabled.\r\nUsing .*? library .*?\\.\r\n)?" \
 	"\r\n" \
 	"Breakpoint 1, main.*$gdb_prompt $"
     set message "continue across exec"
diff --git a/gdb/testsuite/gdb.base/fork-print-inferior-events.exp b/gdb/testsuite/gdb.base/fork-print-inferior-events.exp
index 10afaf6110a..eda0f50ca7b 100644
--- a/gdb/testsuite/gdb.base/fork-print-inferior-events.exp
+++ b/gdb/testsuite/gdb.base/fork-print-inferior-events.exp
@@ -59,6 +59,7 @@  set detach_child_re "${reading_re}\\\[Detaching after fork from child .*\\\]\r\n
 set detach_parent_re "${reading_re}\\\[Detaching after fork from parent .*\\\]\r\n"
 set new_inf_re "${reading_re}\\\[New inferior $decimal \\(.*\\)\\\]\r\n"
 set inf_detached_re "${reading_re}\\\[Inferior $decimal \\(.*\\) detached\\\]\r\n"
+set thread_db_re "(?:\\\[Thread debugging using .*? enabled\\\]\r\nUsing .*? library .*?\\.\r\n)?"
 
 set expected_output [list \
 			 "${attach_child_re}${new_inf_re}${detach_parent_re}${inf_detached_re}" \
@@ -84,7 +85,7 @@  foreach_with_prefix print_inferior_events { "on" "off" } {
 	    set output [lindex $expected_output $i]
 	    # Always add the "Starting program..." string so that we
 	    # match exactly the lines we want.
-	    set output "Starting program: $binfile\\s*\r\n${output}${exited_normally_re}"
+	    set output "Starting program: $binfile\\s*\r\n${thread_db_re}${output}${thread_db_re}${exited_normally_re}"
 	    set i [expr $i + 1]
 	    gdb_test "run" $output
 	}