From: Manoj Iyer <manjo@austin.ibm.com>
To: Michael Chastain <mec.gnu@mindspring.com>
Cc: gdb-patches@sources.redhat.com, gilliam@us.ibm.com
Subject: [RFC] New thread testcase.
Date: Tue, 10 Aug 2004 06:10:00 -0000 [thread overview]
Message-ID: <Pine.LNX.4.58.0408091818400.18782@lazy> (raw)
In-Reply-To: <4117F82B.nail1N111PN0T@mindspring.com>
[-- Attachment #1: Type: TEXT/PLAIN, Size: 1003 bytes --]
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 +
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
[-- Attachment #2: C program --]
[-- Type: TEXT/x-csrc, Size: 1906 bytes --]
/*
* 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 #3: expect script --]
[-- Type: TEXT/PLAIN, Size: 3735 bytes --]
# 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 Manoj Iyer. (manjo@austin.ibm.com)
# Test break points and single step on thread functions.
#
# Test Purpose:
# - Test that breakpoints, single step, and bracktrace works on a threaded
# application. On ppc64 system this test is known to fail due to kernel bug
# in ptrace system call.
#
# Test Strategy:
# - tbug.c creates 2 threads
# - start gdb
# - create 2 breakpoints #1 main() #2 tf() (the thread function)
# - run gdb till #1 main() breakpoint is reached
# - continue to breakpoint #2 tf()
# - single step to first instruction in the thread function tf()
# - backtrace from thread function tf()
# - delete all breakpoints
# - exit gdb.
if $tracelevel then {
strace $tracelevel
}
set prms_id 0
set bug_id 0
set testfile "tbug"
set srcfile ${testfile}.c
set binfile ${objdir}/${subdir}/${testfile}
if {[gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable [list debug "incdir=${objdir}"]] != "" } {
return -1
}
gdb_start
gdb_reinitialize_dir $srcdir/$subdir
gdb_load ${binfile}
if ![runto_main] then {
fail "Can't run to main"
return 1;
}
#
# set breakpoint at thread fucntion tf
#
gdb_test "break tf" \
"Breakpoint.*at.* file .*$srcfile, line.*" \
"breakpoint tf"
#
#
# continue to tf() breakpoint #2
#
send_gdb "continue\n"
gdb_expect {
-re ".*Breakpoint 2.*tf.* at .*tbug.* .*\r\n$gdb_prompt $" {
pass "continue to tf";
}
-re ".*$gdb_prompt $" {
fail "continue to tf";
return 1;
}
timeout {
fail "continue to tf (timeout)";
return 1;
}
}
#
# step through the thread function.
#
send_gdb "step\n"
gdb_expect {
-re "39.*sprintf.* .*\r\n$gdb_prompt $" {
pass "step to next instruction in tf";
}
-re ".*$gdb_prompt $" {
fail "step to next instruction in tf";
return 1;
}
timeout {
fail "step to next instruction in tf (timeout)";
return 1;
}
}
#
# backtrace from thread function.
#
send_gdb "backtrace\n"
gdb_expect {
-re ".*3.* .*0x.* in clone.* from .*libc.*$" {
pass "backtrace from thread function";
}
-re ".*$gdb_prompt $" {
fail "backtrace from thread function";
return 1;
}
timeout {
fail "backtrace from thread function (timeout)";
return 1;
}
}
#
# delete all breakpoints
#
send_gdb "delete\n"
gdb_expect 100 {
-re "Delete all breakpoints.*$" {
send_gdb "y\n";
exp_continue
}
-re ".*$gdb_prompt $" {
# no more breakpoints then do nothing
}
timeout {
perror "Delete all breakpoints in delete_breakpoints (timeout)";
return 0;
}
}
#
# exit gdb
#
gdb_exit
next prev parent reply other threads:[~2004-08-10 6:10 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-08-09 22:18 [patch/testsuite/mi/copyright] gdb.mi/mi2-*.exp: update copyright years Michael Chastain
2004-08-10 6:10 ` Manoj Iyer [this message]
2004-08-10 7:24 ` [RFC] New thread testcase Michael Chastain
2004-08-10 15:13 ` Andrew Cagney
2004-08-10 20:22 ` Manoj Iyer
2004-08-10 20:33 ` Andrew Cagney
2004-08-10 20:44 ` Manoj Iyer
2004-08-12 16:04 ` Andrew Cagney
2004-08-27 3:25 ` Michael Snyder
2004-08-27 13:48 ` Manoj Iyer
2004-08-10 20:13 ` Manoj Iyer
2004-08-12 0:26 ` Michael Snyder
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=Pine.LNX.4.58.0408091818400.18782@lazy \
--to=manjo@austin.ibm.com \
--cc=gdb-patches@sources.redhat.com \
--cc=gilliam@us.ibm.com \
--cc=mec.gnu@mindspring.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox