Fix gdb.threads/pthreads.exp error handling/printing
authorPedro Alves <pedro@palves.net>
Fri, 15 Sep 2023 18:43:55 +0000 (19:43 +0100)
committerPedro Alves <pedro@palves.net>
Wed, 27 Sep 2023 14:28:39 +0000 (15:28 +0100)
commitf3e4716cc534f9521bd97abc400d8e8f0e73ea6a
tree33e140f7d30ef54e63703cbd39d5c0cd1249bab2
parented11fb37b3f3de0f9cf056c9fce76dc7a3cc359d
Fix gdb.threads/pthreads.exp error handling/printing

On Cygwin, I noticed:

 (gdb) PASS: gdb.threads/pthreads.exp: break thread1
 continue
 Continuing.
 pthread_attr_setscope 1: No error
 [Thread 8732.0x28f8 exited with code 1]
 [Thread 8732.0xb50 exited with code 1]
 [Thread 8732.0x17f8 exited with code 1]

 Program terminated with signal SIGHUP, Hangup.
 The program no longer exists.
 (gdb) FAIL: gdb.threads/pthreads.exp: Continue to creation of first thread

Note "No error" in "pthread_attr_setscope 1: No error".  That is a bug
in the test.  It is using perror, but that prints errno, while the
pthread functions return the error directly.  Fix all cases of the
same problem, by adding a new print_error function and using it.

We now get:

  ...
  pthread_attr_setscope 1: Not supported (134)
  ...

Approved-By: Tom Tromey <tom@tromey.com>
Change-Id: I972ebc931b157bc0f9084e6ecd8916a5e39238f5
gdb/testsuite/gdb.threads/pthreads.c