]> git.pld-linux.org Git - packages/gdb.git/blob - gdb-simultaneous-step-resume-breakpoint-test.patch
- typo
[packages/gdb.git] / gdb-simultaneous-step-resume-breakpoint-test.patch
1 --- /dev/null   2009-09-25 12:44:54.497650251 +0200
2 +++ ./gdb/testsuite/gdb.threads/simultaneous-step-resume-breakpoint.exp 2009-09-25 17:27:12.000000000 +0200
3 @@ -0,0 +1,65 @@
4 +# Copyright (C) 2009 Free Software Foundation, Inc.
5 +
6 +# This program is free software; you can redistribute it and/or modify
7 +# it under the terms of the GNU General Public License as published by
8 +# the Free Software Foundation; either version 3 of the License, or
9 +# (at your option) any later version.
10 +#
11 +# This program is distributed in the hope that it will be useful,
12 +# but WITHOUT ANY WARRANTY; without even the implied warranty of
13 +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 +# GNU General Public License for more details.
15 +#
16 +# You should have received a copy of the GNU General Public License
17 +# along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
18 +
19 +# Test multiple threads stepping into a .debug_line-less function with
20 +# a breakpoint placed on its return-to-caller point.
21 +
22 +set testfile simultaneous-step-resume-breakpoint
23 +set srcfile ${testfile}.c
24 +set binfile ${objdir}/${subdir}/${testfile}
25 +
26 +if {[gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
27 +    return -1
28 +}
29 +
30 +gdb_exit
31 +gdb_start
32 +gdb_reinitialize_dir $srcdir/$subdir
33 +
34 +# Ensure we have no debuginfo for the `sleep' call itself (=for libc).
35 +gdb_test "set debug-file-directory /DoesNotExist"
36 +
37 +gdb_load ${binfile}
38 +if ![runto_main] {
39 +   return -1
40 +}
41 +
42 +# Red Hat vendor patch does set it to "step" by default.
43 +gdb_test "set scheduler-locking off"
44 +
45 +gdb_breakpoint [gdb_get_line_number "final-exit"]
46 +
47 +gdb_breakpoint [gdb_get_line_number "sleep-call"]
48 +gdb_continue_to_breakpoint "sleep-call"
49 +
50 +gdb_test "step" "sleep-call.*" "step thread 1"
51 +gdb_test "step" "sleep-call.*" "step thread 2"
52 +gdb_test "step" "sleep-after.*" "step thread 3"
53 +
54 +set test "first continue"
55 +gdb_test_multiple "continue" $test {
56 +    -re "final-exit.*$gdb_prompt $" {
57 +       # gdb-7.0.
58 +       pass $test
59 +       return
60 +    }
61 +    -re "sleep-after.*$gdb_prompt $" {
62 +       # Fedora/RHEL branch.
63 +       pass $test
64 +    }
65 +}
66 +
67 +gdb_test "continue" "sleep-after.*" "second continue"
68 +gdb_test "continue" "final-exit.*" "third continue"
69 --- /dev/null   2009-09-25 12:44:54.497650251 +0200
70 +++ ./gdb/testsuite/gdb.threads/simultaneous-step-resume-breakpoint.c   2009-09-25 17:29:42.000000000 +0200
71 @@ -0,0 +1,79 @@
72 +/* Copyright 2009 Free Software Foundation, Inc.
73 +
74 +   Written by Fred Fish of Cygnus Support
75 +   Contributed by Cygnus Support
76 +
77 +   This file is part of GDB.
78 +
79 +   This program is free software; you can redistribute it and/or modify
80 +   it under the terms of the GNU General Public License as published by
81 +   the Free Software Foundation; either version 3 of the License, or
82 +   (at your option) any later version.
83 +
84 +   This program is distributed in the hope that it will be useful,
85 +   but WITHOUT ANY WARRANTY; without even the implied warranty of
86 +   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
87 +   GNU General Public License for more details.
88 +
89 +   You should have received a copy of the GNU General Public License
90 +   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
91 +
92 +/* Test multiple threads stepping into a .debug_line-less function with
93 +   a breakpoint placed on its return-to-caller point.  */
94 +
95 +#include <pthread.h>
96 +#include <assert.h>
97 +#include <unistd.h>
98 +#include <errno.h>
99 +#include <stdio.h>
100 +
101 +#define THREADS 3
102 +
103 +static void *
104 +func (void *unused)
105 +{
106 +  int i;
107 +
108 +  errno = 0;
109 +  i = 0xdeadf00d;
110 +  i = sleep (THREADS); /* sleep-call */
111 +  if (errno != 0)      /* sleep-after */
112 +    perror ("sleep");
113 +
114 +  /* The GDB bug with forgotten step-resume breakpoint could leave stale
115 +     breakpoint on the I assignment making it a nop.  */
116 +  if (i == 0xdeadf00d)
117 +    assert (0);
118 +
119 +  assert (i == 0);
120 +
121 +  pthread_exit (NULL);
122 +}
123 +
124 +int
125 +main (void)
126 +{
127 +  pthread_t threads[THREADS];
128 +  int threadi;
129 +
130 +  for (threadi = 0; threadi < THREADS; threadi++)
131 +    {
132 +      int i;
133 +
134 +      i = pthread_create (&threads[threadi], NULL, func, NULL);
135 +      assert (i == 0);
136 +
137 +      i = sleep (1);
138 +      assert (i == 0);
139 +    }
140 +
141 +  for (threadi = 0; threadi < THREADS; threadi++)
142 +    {
143 +      int i;
144 +
145 +      i = pthread_join (threads[threadi], NULL);
146 +      assert (i == 0);
147 +    }
148 +
149 +  return 0;    /* final-exit */
150 +}
This page took 0.054693 seconds and 3 git commands to generate.