This is the mail archive of the gdb-prs@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

threads/2312: gdbserver with pthread debugging problem


>Number:         2312
>Category:       threads
>Synopsis:       gdbserver with pthread debugging problem
>Confidential:   no
>Severity:       serious
>Priority:       high
>Responsible:    unassigned
>State:          open
>Class:          test-bug
>Submitter-Id:   net
>Arrival-Date:   Mon Sep 10 14:38:01 UTC 2007
>Closed-Date:
>Last-Modified:
>Originator:     revatik@kpitcummins.com
>Release:        gdb-6.4
>Organization:
>Environment:
OS: Linux 2.6.8
gcc: 3.4.6
./configure --target=sh3eb-linux (for gdb)
./configure --host=sh3eb-linux (for gdbserver)
>Description:
the debug on console looks as follows:
# ./gdbserver 10.10.51.39:8888 ./consumer1
Process ./consumer1 created; pid = 143
Listening on port 8888
Remote debugging from host 10.10.51.39
Sem_init of 'empty' Semaphore Success
Sem_init of 'full' Semaphore Success
00143 : __pthread_initialize_manager: manager stack: size=8160, bos=0x434100, to
s=0x4360e0
00143 : __pthread_initialize_manager: send REQ_DEBUG to manager thread
00143 : pthread_create: write REQ_CREATE to manager thread
00143 : pthread_create: before suspend(self)
00144 : __pthread_manager: before poll
00144 : __pthread_manager: after poll
00144 : __pthread_manager: before __libc_read
00144 : __pthread_manager: after __libc_read, n=148
00144 : __pthread_manager: got REQ_CREATE
00144 : pthread_handle_create: new thread pid = 145
00144 : __pthread_manager: restarting 4376416
00144 : __pthread_manager: before poll
00145 : pthread_start_thread: 

Child terminated with signal = 9 

Child terminated with signal = 0x9
GDBserver exiting
>How-To-Repeat:

>Fix:

>Release-Note:
>Audit-Trail:
>Unformatted:
----gnatsweb-attachment----
Content-Type: text/plain; name="consumer1.c"
Content-Disposition: inline; filename="consumer1.c"

    #include <stdio.h>
    #include <unistd.h>
    #include <stdlib.h>
    #include <string.h>
    #include <pthread.h>
    #include <semaphore.h>



    #define WORK_SIZE 20
    #define LEN       5



    char amsg[WORK_SIZE];    /*Global buffer to which data is to be written
                          and read from using Semaphore*/
    sem_t empty,full;       /*Semaphore*/
    int icnt = 0;           /*Counter*/



    void *writer_funct(void *);
    void *reader_funct(void *);


void *writer_funct(void *arg)
{
    int icount,iwriteptr = 0;
    char agetdata[]="Hello";
    char cdata;

    for ( icount = 0 ; icount < LEN ; icount++ )
        {
            cdata = agetdata[ icnt ];
            sem_wait( &empty );
            amsg[ iwriteptr ] = agetdata[ icnt ];
            printf(" Writer buffer[%d] =%c \n",iwriteptr,cdata );
            iwriteptr = ( iwriteptr + 1 ) % 5;
            sem_post( &full );
            icnt++;
        }

}
void *reader_funct(void *arg)
{
    int icount,ireadptr = 0;
    char cdata;

     for (  icount = 0 ; icount < LEN ; icount++    )
        {
            sem_wait( &full );
            cdata = amsg[ ireadptr ];
            printf( "\t\t Reader Buffer[%d] =%c\n",ireadptr,cdata );
            ireadptr = ( ireadptr + 1 ) % 5;
            sem_post( &empty );
            sleep(2);
        }


}
int main()
{
    pthread_t writer, reader;

    int iresult;

    iresult = sem_init(&empty,0,1);

        if ( iresult < 0 )
        {
            printf("Sem_init of 'empty' Semaphore Failed \n");
        }
        else
        {
            printf("Sem_init of 'empty' Semaphore Success\n");
        }

    iresult = sem_init(&full,0,0);

        if ( iresult < 0 )
        {
            printf("Sem_init of 'full' Semaphore Failed\n");
        }
        else
        {
            printf("Sem_init of 'full' Semaphore Success\n");
        }

    iresult = pthread_create(&writer,NULL,writer_funct,NULL);

        if ( iresult != 0 )
        {
            printf("pthread1 ---- Failure\n");
        }
        else
        {
          printf("pthread1 ---- Success \n");
        }

    iresult= pthread_create(&reader,NULL,reader_funct,NULL);

        if ( iresult < 0 )
        {
            printf("pthread2 --- Failure\n");
        }
        else
        {
            printf("pthread2 --- Success\n");
        }


    iresult = pthread_join(writer,NULL);

        if ( iresult < 0 )
        {
            printf("join1 --- Failure\n");
        }
        else
        {
        printf("join1 --- Success\n");
        }

    iresult = pthread_join(reader,NULL);

        if ( iresult < 0 )
        {
            printf("join2 --- Failure\n");
        }
        else
        {
            printf("join2 --- Success\n");
        }

    iresult= sem_destroy(&empty);

        if ( iresult < 0 )
        {
            printf("destroy1 --- Failure\n");
        }
        else
        {
        printf("destroy1 --- Success\n");
        }

    iresult = sem_destroy(&full);

        if ( iresult < 0 )
        {
            printf("destroy2 --- Failure\n");
        }
        else
        {
            printf("destroy2 --- Done\n");
        }

    return 0;

}


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]