This is the mail archive of the gdb-patches@sources.redhat.com 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]

[RFC] New thread testcase.


Please find attached a new thread test that tests GDB functions like
break, step etc from a thread function. This testcase uncovered a problem
in GDB32 on ppc64 machine due to a generic kernel bug in ptrace().

For example:

(gdb) break tf
Breakpoint 2 at 0x10000594: file tbug.c, line 15.
(gdb) run
Starting program: /home/public/test-tools/gdb/tbug
[Thread debugging using libthread_db enabled]
[New Thread 1074020384 (LWP 26710)]
reading register pc (#64): No such process.
(gdb) cont
Continuing.
reading register pc (#64): No such process.
(gdb) cont
Continuing.
reading register pc (#64): No such process.
(gdb) cont
Continuing.
reading register pc (#64): No such process.
(gdb) quit
The program is running.  Exit anyway? (y or n) y

Thanks
----- ----
Manoj Iyer
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+ Cognito ergo sum                                                          +
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
/*
* Copyright (C) 2004 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 2 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, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.

* Please email any bugs, comments, and/or additions to this file to:
* bug-gdb@prep.ai.mit.edu

* This file was written by Steve Munroe. (sjmunroe@us.ibm.com)
* Test break points and single step on thread functions.
*/

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

#define N       2

static void *
tf (void *arg)
{
    int n = (int) (long int) arg;
    char number[160];
    sprintf(number, "tf(%ld): begin", (long)arg);
    puts (number);

    sleep (100);
    sprintf(number, "tf(%ld): end", (long)arg);
    puts (number);
    return NULL;
}

int main (int argc, char *argv[])
{
    int n;
    pthread_t th[N];

    for (n = 0; n < N; ++n)
    if (pthread_create (&th[n], NULL, tf, (void *) (long int) n) != 0)
    {
        sleep(2);
        puts ("create failed");
        exit (1);
    }

    puts("after create");

    for (n = 0; n < N; ++n)
    if (pthread_join (th[n], NULL) != 0)
    {
        puts ("join failed");
        exit (1);
    }

    puts("after join");
              return 0;
}

Attachment: thread_check.exp
Description: expect script


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