OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-old/] [gdb-7.1/] [gdb/] [testsuite/] [gdb.threads/] [step2.exp] - Diff between revs 227 and 816

Go to most recent revision | Only display areas with differences | Details | Blame | View Log

Rev 227 Rev 816
# step2.exp -- Expect script to test gdb step.c
# step2.exp -- Expect script to test gdb step.c
# Copyright (C) 1992, 1997, 2007, 2008, 2009, 2010
# Copyright (C) 1992, 1997, 2007, 2008, 2009, 2010
# Free Software Foundation, Inc.
# 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
# the Free Software Foundation; either version 3 of the License, or
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
# (at your option) any later version.
#
#
# This program is distributed in the hope that it will be useful,
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
# GNU General Public License for more details.
#
#
# You should have received a copy of the GNU General Public License
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see .
# along with this program.  If not, see .
# This file was written by Jeff Law. (law@cygnus.com)
# This file was written by Jeff Law. (law@cygnus.com)
#
#
if $tracelevel then {
if $tracelevel then {
        strace $tracelevel
        strace $tracelevel
}
}
set program_exited 0
set program_exited 0
# A simple and crude test to see that we can step two threads independently
# A simple and crude test to see that we can step two threads independently
proc test_multi_threaded_stepping {} {
proc test_multi_threaded_stepping {} {
    global gdb_prompt
    global gdb_prompt
    global hex
    global hex
    global srcfile
    global srcfile
    global decimal
    global decimal
    # Set breakpoints in code that we know is executed in only
    # Set breakpoints in code that we know is executed in only
    # thread of control.
    # thread of control.
    gdb_test "break thread1" \
    gdb_test "break thread1" \
             "Break.* at $hex: file .*$srcfile, line $decimal\\."
             "Break.* at $hex: file .*$srcfile, line $decimal\\."
    gdb_test "break thread2" \
    gdb_test "break thread2" \
             "Break.* at $hex: file .*$srcfile, line $decimal\\."
             "Break.* at $hex: file .*$srcfile, line $decimal\\."
    # the order in which things happen is indeterminate.  So we basically
    # the order in which things happen is indeterminate.  So we basically
    # look for a set of events and note that each one happens and that
    # look for a set of events and note that each one happens and that
    # all of the required events have happened when we're done.
    # all of the required events have happened when we're done.
    #
    #
    # Right now we only verify that both threads start and that they
    # Right now we only verify that both threads start and that they
    # both call pthread_cond_wait twice.
    # both call pthread_cond_wait twice.
    set thread1started 0
    set thread1started 0
    set thread1condwait 0
    set thread1condwait 0
    set thread2started 0
    set thread2started 0
    set thread2condwait 0
    set thread2condwait 0
    send_gdb "run\n"
    send_gdb "run\n"
    gdb_expect {
    gdb_expect {
        -re "The program .* has been started already.*y or n. $" {
        -re "The program .* has been started already.*y or n. $" {
            send_gdb "y\n"
            send_gdb "y\n"
            exp_continue
            exp_continue
        }
        }
        -re ".*Breakpoint \[0-9\]+,.*thread1.* at .*$srcfile:.*\[\t \].*$gdb_prompt $" {
        -re ".*Breakpoint \[0-9\]+,.*thread1.* at .*$srcfile:.*\[\t \].*$gdb_prompt $" {
            if { $thread1started != 0 } then {
            if { $thread1started != 0 } then {
                fail "thread1 started"
                fail "thread1 started"
                return
                return
            } else {
            } else {
                set thread1started 1
                set thread1started 1
                pass "thread1 started"
                pass "thread1 started"
            }
            }
            send_gdb "step\n"
            send_gdb "step\n"
            exp_continue
            exp_continue
        }
        }
        -re ".*Breakpoint \[0-9\]+,.*thread2.* at .*$srcfile:.*\[\t \].*$gdb_prompt $" {
        -re ".*Breakpoint \[0-9\]+,.*thread2.* at .*$srcfile:.*\[\t \].*$gdb_prompt $" {
            if { $thread2started != 0 } then {
            if { $thread2started != 0 } then {
                fail "thread2 started"
                fail "thread2 started"
                return
                return
            } else {
            } else {
                set thread2started 1
                set thread2started 1
                pass "thread2 started"
                pass "thread2 started"
            }
            }
            send_gdb "step\n"
            send_gdb "step\n"
            exp_continue
            exp_continue
        }
        }
        -re ".*pthread_cond_wait.*cv_a.*$gdb_prompt" {
        -re ".*pthread_cond_wait.*cv_a.*$gdb_prompt" {
            if { $thread1started == 0 } then {
            if { $thread1started == 0 } then {
                fail "thread1 condwait"
                fail "thread1 condwait"
                return
                return
            }
            }
            if { $thread1condwait < 2 } then {
            if { $thread1condwait < 2 } then {
                pass "thread1 condwait"
                pass "thread1 condwait"
                incr thread1condwait
                incr thread1condwait
            }
            }
            if { $thread2condwait == 2 } then {
            if { $thread2condwait == 2 } then {
                pass "multi threaded stepping"
                pass "multi threaded stepping"
                return
                return
            }
            }
            send_gdb "step\n"
            send_gdb "step\n"
            exp_continue
            exp_continue
        }
        }
        -re ".*pthread_cond_wait.*cv_b.*$gdb_prompt" {
        -re ".*pthread_cond_wait.*cv_b.*$gdb_prompt" {
            if { $thread2started == 0 } then {
            if { $thread2started == 0 } then {
                fail "thread2 condwait"
                fail "thread2 condwait"
                return
                return
            }
            }
            if { $thread2condwait < 2 } then {
            if { $thread2condwait < 2 } then {
                pass "thread2 condwait"
                pass "thread2 condwait"
                incr thread2condwait
                incr thread2condwait
            }
            }
            if { $thread1condwait == 2 } then {
            if { $thread1condwait == 2 } then {
                pass "multi threaded stepping"
                pass "multi threaded stepping"
                return
                return
            }
            }
            send_gdb "step\n"
            send_gdb "step\n"
            exp_continue
            exp_continue
        }
        }
        -re "$gdb_prompt" {
        -re "$gdb_prompt" {
            send_gdb "step\n"
            send_gdb "step\n"
            exp_continue
            exp_continue
        }
        }
        default { fail "multi threaded stepping" }
        default { fail "multi threaded stepping" }
    }
    }
}
}
# Check to see if we have an executable to test.  If not, then either we
# Check to see if we have an executable to test.  If not, then either we
# haven't tried to compile one, or the compilation failed for some reason.
# haven't tried to compile one, or the compilation failed for some reason.
# In either case, just notify the user and skip the tests in this file.
# In either case, just notify the user and skip the tests in this file.
set binfile "step"
set binfile "step"
set srcfile "step.c"
set srcfile "step.c"
if ![file exists $objdir/$subdir/$binfile] then {
if ![file exists $objdir/$subdir/$binfile] then {
    if $all_flag then {
    if $all_flag then {
        warning "$binfile does not exist; tests suppressed."
        warning "$binfile does not exist; tests suppressed."
    }
    }
    return
    return
}
}
set prms_id 0
set prms_id 0
set bug_id 0
set bug_id 0
# Start with a fresh gdb.
# Start with a fresh gdb.
gdb_exit
gdb_exit
gdb_start
gdb_start
gdb_reinitialize_dir $srcdir/$subdir
gdb_reinitialize_dir $srcdir/$subdir
gdb_load $objdir/$subdir/$binfile
gdb_load $objdir/$subdir/$binfile
test_multi_threaded_stepping
test_multi_threaded_stepping
 
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.