trace-mt.c revision 1.5
1/* This testcase is part of GDB, the GNU debugger. 2 3 Copyright 2012-2015 Free Software Foundation, Inc. 4 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. 9 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. 14 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/>. */ 17 18#include <pthread.h> 19 20#ifdef SYMBOL_PREFIX 21#define SYMBOL(str) SYMBOL_PREFIX #str 22#else 23#define SYMBOL(str) #str 24#endif 25/* Called from asm. */ 26static void __attribute__((used)) 27func (void) 28{} 29 30static void * 31thread_function(void *arg) 32{ 33 /* `set_point1' is the label at which to set a fast tracepoint. The 34 insn at the label must be large enough to fit a fast tracepoint 35 jump. */ 36 asm (" .global " SYMBOL(set_point1) "\n" 37 SYMBOL(set_point1) ":\n" 38#if (defined __x86_64__ || defined __i386__) 39 " call " SYMBOL(func) "\n" 40#endif 41 ); 42} 43 44static void 45end (void) 46{} 47 48int 49main (int argc, char *argv[], char *envp[]) 50{ 51 pthread_t threads[2]; 52 int i; 53 54 for (i = 0; i < 2; i++) 55 pthread_create (&threads[i], NULL, thread_function, NULL); 56 57 for (i = 0; i < 2; i++) 58 pthread_join (threads[i], NULL); 59 60 end (); 61 62 return 0; 63} 64