a59add0c2e
Since upstream GCC has changed the default C language dialect to 'gnu11', it yields multiple warnings in the GDB testsuite for missing function return types and implicit function declarations. This patch attempts to fix these. gdb/testsuite/ChangeLog: * gdb.ada/cond_lang/foo.c (callme): Add return type. * gdb.base/call-sc.c (zed): Likewise. * gdb.base/checkpoint.c (main): Likewise. * gdb.base/dump.c (main): Likewise. * gdb.base/gcore.c (main): Likewise. * gdb.base/huge.c (main): Likewise. * gdb.base/multi-forks.c (main): Likewise. * gdb.base/pr10179-a.c (main): Likewise. * gdb.base/savedregs.c (main): Likewise. * gdb.base/sigaltstack.c (main): Likewise. * gdb.base/siginfo.c (main): Likewise. * gdb.base/structs.c (zed): Likewise. * gdb.mi/mi-stack.c (callee3, callee2, callee1, main): Likewise. * gdb.mi/mi-syn-frame.c (main): Likewise. * gdb.mi/until.c (foo, main): Likewise. * gdb.base/global-var-nested-by-dso.c (b_main, c_main): Declare. * gdb.base/solib-weak.c (foo): Declare. * gdb.base/attach-twice.c: Include stdio.h. * gdb.base/weaklib1.c: Likewise. * gdb.base/weaklib2.c: Likewise. * gdb.base/catch-signal-fork.c: Include stdio.h and sys/wait.h. * gdb.mi/mi-condbreak-call-thr-state-mt.c: Include stdio.h and unistd.h. * gdb.base/attach-pie-misread.c: Include stdlib.h. * gdb.mi/mi-exit-code.c: Likewise. * gdb.base/break-interp-lib.c: Include string.h. * gdb.base/coremaker.c: Likewise. * gdb.base/testenv.c: Likewise. * gdb.python/py-finish-breakpoint.c: Likewise. * gdb.base/inferior-died.c: Include sys/wait.h. * gdb.base/fileio.c: Include time.h. * gdb.base/async-shell.c: Include unistd.h. * gdb.base/dprintf-non-stop.c: Likewise. * gdb.base/info-os.c: Likewise. * gdb.mi/mi-console.c: Likewise. * gdb.mi/watch-nonstop.c: Likewise. * gdb.python/py-events.c: Likewise. * gdb.base/async.c (baz): Move up before its invocation. * gdb.base/code_elim2.c (my_global_func): Likewise. * gdb.base/skip-solib-lib.c (multiply): Likewise. * gdb.base/advance.c (func2): Likewise.
148 lines
3.4 KiB
C
148 lines
3.4 KiB
C
/* This testcase is part of GDB, the GNU debugger.
|
|
|
|
Copyright 2011-2014 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/>. */
|
|
|
|
#include <sys/shm.h>
|
|
#include <sys/sem.h>
|
|
#include <sys/msg.h>
|
|
#include <stdio.h>
|
|
#include <pthread.h>
|
|
#include <arpa/inet.h>
|
|
#include <sys/socket.h>
|
|
#include <unistd.h>
|
|
|
|
static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
|
|
|
|
void *
|
|
thread_proc (void *args)
|
|
{
|
|
pthread_mutex_lock (&mutex);
|
|
pthread_mutex_unlock (&mutex);
|
|
}
|
|
|
|
int
|
|
main (void)
|
|
{
|
|
const int flags = IPC_CREAT | 0666;
|
|
key_t shmkey = 3925, semkey = 7428, msgkey = 5294;
|
|
int shmid, semid, msqid;
|
|
FILE *fd;
|
|
pthread_t thread;
|
|
struct sockaddr_in sock_addr;
|
|
int sock;
|
|
unsigned short port;
|
|
socklen_t size;
|
|
int status, try, retries = 1000;
|
|
|
|
for (try = 0; try < retries; ++try)
|
|
{
|
|
shmid = shmget (shmkey, 4096, flags | IPC_EXCL);
|
|
if (shmid >= 0)
|
|
break;
|
|
|
|
++shmkey;
|
|
}
|
|
|
|
if (shmid < 0)
|
|
{
|
|
printf ("Cannot create shared-memory region after %d tries.\n", retries);
|
|
return 1;
|
|
}
|
|
|
|
for (try = 0; try < retries; ++try)
|
|
{
|
|
semid = semget (semkey, 1, flags | IPC_EXCL);
|
|
if (semid >= 0)
|
|
break;
|
|
|
|
++semkey;
|
|
}
|
|
|
|
if (semid < 0)
|
|
{
|
|
printf ("Cannot create semaphore after %d tries.\n", retries);
|
|
return 1;
|
|
}
|
|
|
|
for (try = 0; try < retries; ++try)
|
|
{
|
|
msqid = msgget (msgkey, flags | IPC_EXCL);
|
|
if (msqid >= 0)
|
|
break;
|
|
|
|
++msgkey;
|
|
}
|
|
|
|
if (msqid < 0)
|
|
{
|
|
printf ("Cannot create message queue after %d tries.\n", retries);
|
|
return 1;
|
|
}
|
|
|
|
fd = fopen ("/dev/null", "r");
|
|
|
|
/* Lock the mutex to prevent the new thread from finishing immediately. */
|
|
pthread_mutex_lock (&mutex);
|
|
pthread_create (&thread, NULL, thread_proc, 0);
|
|
|
|
sock = socket (PF_INET, SOCK_STREAM, IPPROTO_TCP);
|
|
if (sock < 0)
|
|
{
|
|
printf ("Cannot create socket.\n");
|
|
return 1;
|
|
}
|
|
|
|
sock_addr.sin_family = AF_INET;
|
|
sock_addr.sin_port = 0; /* Bind to a free port. */
|
|
sock_addr.sin_addr.s_addr = htonl (INADDR_ANY);
|
|
|
|
status = bind (sock, (struct sockaddr *) &sock_addr, sizeof (sock_addr));
|
|
if (status < 0)
|
|
{
|
|
printf ("Cannot bind socket.\n");
|
|
return 1;
|
|
}
|
|
|
|
/* Find the assigned port number of the socket. */
|
|
size = sizeof (sock_addr);
|
|
status = getsockname (sock, (struct sockaddr *) &sock_addr, &size);
|
|
if (status < 0)
|
|
{
|
|
printf ("Cannot find name of socket.\n");
|
|
return 1;
|
|
}
|
|
port = ntohs (sock_addr.sin_port);
|
|
|
|
status = listen (sock, 1);
|
|
if (status < 0)
|
|
{
|
|
printf ("Cannot listen on socket.\n");
|
|
return 1;
|
|
}
|
|
|
|
/* Set breakpoint here. */
|
|
|
|
shmctl (shmid, IPC_RMID, NULL);
|
|
semctl (semid, 0, IPC_RMID, NULL);
|
|
msgctl (msqid, IPC_RMID, NULL);
|
|
fclose (fd);
|
|
close (sock);
|
|
|
|
pthread_mutex_unlock (&mutex);
|
|
pthread_join (thread, NULL);
|
|
|
|
return 0;
|
|
}
|