aboutsummaryrefslogtreecommitdiff
path: root/gdb/testsuite/gdb.threads/attach-non-stop.c
diff options
context:
space:
mode:
authorPedro Alves <pedro@palves.net>2020-12-23 13:39:18 +0000
committerPedro Alves <pedro@palves.net>2021-02-03 01:14:42 +0000
commit92234eb192f11b1981acb46a3a5e725360b89d6f (patch)
treeb3d33211e8b2f53d97ca6def0f65ea84d6b32c54 /gdb/testsuite/gdb.threads/attach-non-stop.c
parent621cc310717334b330e6301759dad62e641486f6 (diff)
downloadbinutils-92234eb192f11b1981acb46a3a5e725360b89d6f.zip
binutils-92234eb192f11b1981acb46a3a5e725360b89d6f.tar.gz
binutils-92234eb192f11b1981acb46a3a5e725360b89d6f.tar.bz2
Testcase for attaching in non-stop mode
This adds a testcase exercising attaching to a multi-threaded process, in all combinations of: - set non-stop on/off - maint target non-stop off/on - "attach" vs "attach &" This exercises the bugs fixed in the two previous patches. gdb/testsuite/ChangeLog: * gdb.threads/attach-non-stop.c: New file. * gdb.threads/attach-non-stop.exp: New file.
Diffstat (limited to 'gdb/testsuite/gdb.threads/attach-non-stop.c')
-rw-r--r--gdb/testsuite/gdb.threads/attach-non-stop.c58
1 files changed, 58 insertions, 0 deletions
diff --git a/gdb/testsuite/gdb.threads/attach-non-stop.c b/gdb/testsuite/gdb.threads/attach-non-stop.c
new file mode 100644
index 0000000..23a8b25
--- /dev/null
+++ b/gdb/testsuite/gdb.threads/attach-non-stop.c
@@ -0,0 +1,58 @@
+/* This testcase is part of GDB, the GNU debugger.
+
+ Copyright 2021 Free Software Foundation, Inc.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+#define _GNU_SOURCE
+#include <assert.h>
+#include <pthread.h>
+#include <unistd.h>
+
+/* Number of threads we'll create. */
+static const int n_threads = 10;
+
+/* Entry point for threads. Loops forever. */
+
+void *
+thread_func (void *arg)
+{
+ while (1)
+ sleep (1);
+
+ return NULL;
+}
+
+int
+main (int argc, char **argv)
+{
+ int i;
+
+ alarm (30);
+
+ /* Spawn the test threads. */
+ for (i = 0; i < n_threads; ++i)
+ {
+ pthread_t child;
+ int rc;
+
+ rc = pthread_create (&child, NULL, thread_func, NULL);
+ assert (rc == 0);
+ }
+
+ while (1)
+ sleep (1);
+
+ return 0;
+}