mirror of
https://github.com/espressif/binutils-gdb.git
synced 2025-07-02 02:45:37 +08:00
* gdb.base/info-os.c (main): Retry resource acquisition until an
available one is found. * gdb.base/info-os.exp: Collect resource keys from the program and use them in matching.
This commit is contained in:
@ -1,3 +1,10 @@
|
|||||||
|
2012-07-03 Stan Shebs <stan@codesourcery.com>
|
||||||
|
|
||||||
|
* gdb.base/info-os.c (main): Retry resource acquisition until an
|
||||||
|
available one is found.
|
||||||
|
* gdb.base/info-os.exp: Collect resource keys from the program
|
||||||
|
and use them in matching.
|
||||||
|
|
||||||
2012-07-02 Jan Kratochvil <jan.kratochvil@redhat.com>
|
2012-07-02 Jan Kratochvil <jan.kratochvil@redhat.com>
|
||||||
|
|
||||||
* gdb.threads/gcore-thread.exp: Remove variable libthread_db_seen.
|
* gdb.threads/gcore-thread.exp: Remove variable libthread_db_seen.
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/* This testcase is part of GDB, the GNU debugger.
|
/* This testcase is part of GDB, the GNU debugger.
|
||||||
|
|
||||||
Copyright 2011 Free Software Foundation, Inc.
|
Copyright 2011, 2012 Free Software Foundation, Inc.
|
||||||
|
|
||||||
This program is free software; you can redistribute it and/or modify
|
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
|
it under the terms of the GNU General Public License as published by
|
||||||
@ -36,6 +36,7 @@ int
|
|||||||
main (void)
|
main (void)
|
||||||
{
|
{
|
||||||
const int flags = IPC_CREAT | 0666;
|
const int flags = IPC_CREAT | 0666;
|
||||||
|
key_t shmkey = 3925, semkey = 7428, msgkey = 5294;
|
||||||
int shmid, semid, msqid;
|
int shmid, semid, msqid;
|
||||||
FILE *fd;
|
FILE *fd;
|
||||||
pthread_t thread;
|
pthread_t thread;
|
||||||
@ -43,22 +44,53 @@ main (void)
|
|||||||
int sock;
|
int sock;
|
||||||
unsigned short port;
|
unsigned short port;
|
||||||
socklen_t size;
|
socklen_t size;
|
||||||
int status;
|
int status, try, retries = 1000;
|
||||||
|
|
||||||
if ((shmid = shmget (3925, 4096, flags | IPC_EXCL)) < 0)
|
for (try = 0; try < retries; ++try)
|
||||||
{
|
{
|
||||||
/* Attempt to delete the existing shared-memory region, then
|
shmid = shmget (shmkey, 4096, flags | IPC_EXCL);
|
||||||
recreate it. */
|
if (shmid >= 0)
|
||||||
shmctl (shmget (3925, 4096, flags), IPC_RMID, NULL);
|
break;
|
||||||
if ((shmid = shmget (3925, 4096, flags | IPC_EXCL)) < 0)
|
|
||||||
|
++shmkey;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (shmid < 0)
|
||||||
{
|
{
|
||||||
printf ("Cannot create shared-memory region.\n");
|
printf ("Cannot create shared-memory region after %d tries.\n", retries);
|
||||||
return 1;
|
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
semid = semget (7428, 1, flags);
|
|
||||||
msqid = msgget (5294, flags);
|
|
||||||
fd = fopen ("/dev/null", "r");
|
fd = fopen ("/dev/null", "r");
|
||||||
|
|
||||||
/* Lock the mutex to prevent the new thread from finishing immediately. */
|
/* Lock the mutex to prevent the new thread from finishing immediately. */
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
# Copyright 2011 Free Software Foundation, Inc.
|
# Copyright 2011, 2012 Free Software Foundation, Inc.
|
||||||
|
|
||||||
# This program is free software; you can redistribute it and/or modify
|
# 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
|
# it under the terms of the GNU General Public License as published by
|
||||||
@ -52,7 +52,15 @@ gdb_test_multiple "call getpid()" $test {
|
|||||||
gdb_breakpoint ${srcfile}:[gdb_get_line_number "Set breakpoint here"]
|
gdb_breakpoint ${srcfile}:[gdb_get_line_number "Set breakpoint here"]
|
||||||
gdb_continue_to_breakpoint "Set breakpoint here"
|
gdb_continue_to_breakpoint "Set breakpoint here"
|
||||||
|
|
||||||
# Get IDs of the IPC object instances.
|
# Get keys and IDs of the IPC object instances.
|
||||||
|
set shmkey -1
|
||||||
|
set test "get shared memory key"
|
||||||
|
gdb_test_multiple "print shmkey" $test {
|
||||||
|
-re ".* = ($decimal).*$gdb_prompt $" {
|
||||||
|
set shmkey $expect_out(1,string)
|
||||||
|
pass $test
|
||||||
|
}
|
||||||
|
}
|
||||||
set shmid -1
|
set shmid -1
|
||||||
set test "get shared memory ID"
|
set test "get shared memory ID"
|
||||||
gdb_test_multiple "print shmid" $test {
|
gdb_test_multiple "print shmid" $test {
|
||||||
@ -62,6 +70,15 @@ gdb_test_multiple "print shmid" $test {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
set semkey -1
|
||||||
|
set test "get semaphore key"
|
||||||
|
gdb_test_multiple "print semkey" $test {
|
||||||
|
-re ".* = ($decimal).*$gdb_prompt $" {
|
||||||
|
set semkey $expect_out(1,string)
|
||||||
|
pass $test
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
set semid -1
|
set semid -1
|
||||||
set test "get semaphore ID"
|
set test "get semaphore ID"
|
||||||
gdb_test_multiple "print semid" $test {
|
gdb_test_multiple "print semid" $test {
|
||||||
@ -71,6 +88,15 @@ gdb_test_multiple "print semid" $test {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
set msgkey -1
|
||||||
|
set test "get message queue key"
|
||||||
|
gdb_test_multiple "print msgkey" $test {
|
||||||
|
-re ".* = ($decimal).*$gdb_prompt $" {
|
||||||
|
set msgkey $expect_out(1,string)
|
||||||
|
pass $test
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
set msqid -1
|
set msqid -1
|
||||||
set test "get message queue ID"
|
set test "get message queue ID"
|
||||||
gdb_test_multiple "print msqid" $test {
|
gdb_test_multiple "print msqid" $test {
|
||||||
@ -138,20 +164,16 @@ expect_multiline "info os files" "$inferior_pid +info-os +\\d+ +/dev/null" "get
|
|||||||
expect_multiline "info os sockets" "0\\.0\\.0\\.0 +$port +0\\.0\\.0\\.0 +0 +LISTEN +\\S+ +INET +STREAM" "get internet-domain sockets"
|
expect_multiline "info os sockets" "0\\.0\\.0\\.0 +$port +0\\.0\\.0\\.0 +0 +LISTEN +\\S+ +INET +STREAM" "get internet-domain sockets"
|
||||||
|
|
||||||
# key shmid perm size creator command last op command num attached user group creator user creator group last shmat() time last shmdt() time last shmctl() time
|
# key shmid perm size creator command last op command num attached user group creator user creator group last shmat() time last shmdt() time last shmctl() time
|
||||||
expect_multiline "info os shm" "3925 +$shmid +666 +4096 +info-os .*" "get shared-memory regions"
|
expect_multiline "info os shm" "$shmkey +$shmid +666 +4096 +info-os .*" "get shared-memory regions"
|
||||||
|
|
||||||
# key semid perm num semaphores user group creator user creator group last semop() time last semctl() time
|
# key semid perm num semaphores user group creator user creator group last semop() time last semctl() time
|
||||||
expect_multiline "info os semaphores" "7428 +$semid +666 +1 .*" "get semaphores"
|
expect_multiline "info os semaphores" "$semkey +$semid +666 +1 .*" "get semaphores"
|
||||||
|
|
||||||
# key msqid perm num used bytes num messages last msgsnd() command last msgrcv() command user group creator user creator group last msgsnd() time last msgrcv() time last msgctl() time
|
# key msqid perm num used bytes num messages last msgsnd() command last msgrcv() command user group creator user creator group last msgsnd() time last msgrcv() time last msgctl() time
|
||||||
expect_multiline "info os msg" "5294 +$msqid +666 .*" "get message queues"
|
expect_multiline "info os msg" "$msgkey +$msqid +666 .*" "get message queues"
|
||||||
|
|
||||||
|
|
||||||
# The SysV IPC primitives linger on after the creating process is killed
|
# The SysV IPC primitives linger on after the creating process is killed
|
||||||
# unless they are destroyed explicitly, so allow the test program to tidy
|
# unless they are destroyed explicitly, so allow the test program to tidy
|
||||||
# up after itself. Note that the test program attempts to delete and
|
# up after itself.
|
||||||
# recreate the shared-memory region if it already exists, in case a
|
|
||||||
# previous run failed before having a chance to clean up. The tests for
|
|
||||||
# semaphores and message queues should still work with primitives from
|
|
||||||
# previous runs.
|
|
||||||
send_gdb "continue\n"
|
send_gdb "continue\n"
|
||||||
|
Reference in New Issue
Block a user