1 /* This testcase is part of GDB, the GNU debugger.
3 Copyright 2009-2014 Free Software Foundation, Inc.
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 3 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>.
18 Contributed by Markus Deuling <deuling@de.ibm.com> */
26 extern spe_program_handle_t bt_spu
;
27 extern spe_program_handle_t bt2_spu
;
31 spe_thread (void * arg
)
34 unsigned int entry
= SPE_DEFAULT_ENTRY
;
35 spe_context_ptr_t
*ctx
= (spe_context_ptr_t
*) arg
;
37 spe_program_load (*ctx
, &bt_spu
);
38 spe_context_run (*ctx
, &entry
, flags
, NULL
, NULL
, NULL
);
44 indirect_handler (unsigned char *base
, unsigned long offset
)
47 unsigned int entry
= SPE_DEFAULT_ENTRY
;
48 spe_context_ptr_t ctx
= spe_context_create (0, NULL
);
50 spe_program_load (ctx
, &bt2_spu
);
51 spe_context_run (ctx
, &entry
, flags
, NULL
, NULL
, NULL
);
56 static pthread_mutex_t crash_mutex
= PTHREAD_MUTEX_INITIALIZER
;
57 static int crash_count
= 0;
60 crash_handler (unsigned char *base
, unsigned long offset
)
64 pthread_mutex_lock (&crash_mutex
);
65 count
= ++crash_count
;
66 pthread_mutex_unlock (&crash_mutex
);
79 spe_context_ptr_t ctx
[nr_t
];
83 spe_callback_handler_register (indirect_handler
, 0x11, SPE_CALLBACK_NEW
);
84 spe_callback_handler_register (crash_handler
, 0x12, SPE_CALLBACK_NEW
);
86 for (cnt
= 0; cnt
< nr_t
; cnt
++)
88 ctx
[cnt
] = spe_context_create (0, NULL
);
90 = pthread_create (&pts
[cnt
], NULL
, &spe_thread
, &ctx
[cnt
]);
93 for (cnt
= 0; cnt
< nr_t
; cnt
++)
94 pthread_join (pts
[cnt
], NULL
);
96 for (cnt
= 0; cnt
< nr_t
; cnt
++)
97 spe_context_destroy (ctx
[cnt
]);