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

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [gnu-src/] [gdb-7.2/] [gdb/] [testsuite/] [gdb.threads/] [gcore-thread.exp] - Blame information for rev 330

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 330 jeremybenn
# Copyright 2002, 2003, 2004, 2007, 2008, 2009, 2010
2
# Free Software Foundation, Inc.
3
 
4
# This program is free software; you can redistribute it and/or modify
5
# it under the terms of the GNU General Public License as published by
6
# the Free Software Foundation; either version 3 of the License, or
7
# (at your option) any later version.
8
#
9
# This program is distributed in the hope that it will be useful,
10
# but WITHOUT ANY WARRANTY; without even the implied warranty of
11
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12
# GNU General Public License for more details.
13
#
14
# You should have received a copy of the GNU General Public License
15
# along with this program.  If not, see .
16
 
17
# This file was written by Michael Snyder (msnyder@redhat.com)
18
# This is a test for the gdb command "generate-core-file".
19
 
20
if $tracelevel then {
21
        strace $tracelevel
22
}
23
 
24
 
25
# Single-threaded test case
26
set testfile "pthreads"
27
set srcfile  ${testfile}.c
28
set binfile  ${objdir}/${subdir}/gcore-${testfile}
29
 
30
if [istarget "*-*-linux"] then {
31
    set target_cflags "-D_MIT_POSIX_THREADS"
32
} else {
33
    set target_cflags ""
34
}
35
 
36
if {[gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable [list debug "incdir=${objdir}"]] != "" } {
37
    return -1
38
}
39
 
40
# Now we can proceed with the real testing.
41
 
42
# Start with a fresh gdb.
43
 
44
gdb_exit
45
gdb_start
46
gdb_reinitialize_dir $srcdir/$subdir
47
gdb_load ${binfile}
48
 
49
# regexp for "horizontal" text (i.e. doesn't include newline or
50
# carriage return)
51
set horiz "\[^\n\r\]*"
52
 
53
# regexp for newline
54
set nl "\[\r\n\]+"
55
 
56
set prev_timeout $timeout
57
set timeout 30
58
 
59
gdb_test_multiple "help gcore" "help gcore" {
60
    -re "Undefined command: .gcore.*$gdb_prompt $" {
61
        # gcore command not supported -- nothing to test here.
62
        unsupported "gdb does not support gcore on this target"
63
        return -1;
64
    }
65
    -re "Save a core file .*$gdb_prompt $" {
66
        pass "help gcore"
67
    }
68
}
69
 
70
if { ! [ runto_main ] } then {
71
    untested gcore-thread.exp
72
    return -1
73
}
74
 
75
gdb_test_multiple "info threads" "threads are supported" {
76
    -re ".* main .*$gdb_prompt $" {
77
        # OK, threads are supported.
78
    }
79
    -re "${nl}$gdb_prompt $" {
80
        unsupported "gdb does not support threads on this target"
81
        return -1;
82
    }
83
}
84
 
85
# Make sure thread 1 is running
86
delete_breakpoints
87
gdb_breakpoint "thread1"
88
gdb_test "continue" "Continuing.*Breakpoint.* thread1 .*" "thread 1 is running"
89
 
90
# Make sure thread 2 is running
91
delete_breakpoints
92
gdb_breakpoint "thread2"
93
gdb_test "continue" "Continuing.*Breakpoint.* thread2 .*" "thread 2 is running"
94
 
95
set escapedfilename [string_to_regexp ${objdir}/${subdir}/gcore.test]
96
# Drop corefile
97
gdb_test_multiple "gcore ${objdir}/${subdir}/gcore.test" \
98
        "save a corefile" \
99
{
100
  -re "Saved corefile ${escapedfilename}\[\r\n\]+$gdb_prompt $" {
101
    pass "save a corefile"
102
    global core_supported
103
    set core_supported 1
104
  }
105
  -re "Can't create a corefile\[\r\n\]+$gdb_prompt $" {
106
    unsupported "save a corefile"
107
    global core_supported
108
    set core_supported 0
109
  }
110
}
111
 
112
global core_supported
113
if {!$core_supported} {
114
  return -1
115
}
116
 
117
# Now restart gdb and load the corefile.
118
gdb_exit
119
gdb_start
120
gdb_reinitialize_dir $srcdir/$subdir
121
gdb_load ${binfile}
122
 
123
gdb_test_multiple "core ${objdir}/${subdir}/gcore.test" \
124
    "re-load generated corefile" {
125
        -re ".* is not a core dump:.*$gdb_prompt $" {
126
            fail "re-load generated corefile (bad file format)"
127
            # No use proceeding from here.
128
            return;
129
        }
130
        -re ".*: No such file or directory.*$gdb_prompt $" {
131
            fail "re-load generated corefile (file not found)"
132
            # No use proceeding from here.
133
            return;
134
        }
135
        -re ".*Couldn't find .* registers in core file.*$gdb_prompt $" {
136
            fail "re-load generated corefile (incomplete note section)"
137
        }
138
        -re "Core was generated by .*$gdb_prompt $" {
139
            pass "re-load generated corefile"
140
        }
141
    }
142
 
143
# FIXME: now what can we test about the thread state?
144
# We do not know for certain that there should be at least
145
# three threads, because who knows what kind of many-to-one
146
# mapping various OS's may do?  Let's assume that there must
147
# be at least two threads:
148
 
149
gdb_test "info threads" ".*${nl}  2 ${horiz}${nl}\\* 1 .*" \
150
        "corefile contains at least two threads"
151
 
152
# One thread in the corefile should be in the "thread2" function.
153
 
154
gdb_test "info threads" ".* thread2 .*" \
155
        "a corefile thread is executing thread2"
156
 
157
# The thread2 thread should be marked as the current thread.
158
 
159
gdb_test "info threads" ".*${nl}\\* ${horiz} thread2 .*" \
160
        "thread2 is current thread in corefile"
161
 
162
set timeout $prev_timeout

powered by: WebSVN 2.1.0

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