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

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [gnu-src/] [gdb-7.1/] [gdb/] [testsuite/] [gdb.threads/] [thread_events.exp] - Blame information for rev 248

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 227 jeremybenn
# Copyright (C) 2007, 2009, 2010 Free Software Foundation, Inc.
2
 
3
# This program is free software; you can redistribute it and/or modify
4
# it under the terms of the GNU General Public License as published by
5
# the Free Software Foundation; either version 3 of the License, or
6
# (at your option) any later version.
7
#
8
# This program is distributed in the hope that it will be useful,
9
# but WITHOUT ANY WARRANTY; without even the implied warranty of
10
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11
# GNU General Public License for more details.
12
#
13
# You should have received a copy of the GNU General Public License
14
# along with this program.  If not, see .
15
 
16
# This file was written by Chris Demetriou (cgd@google.com).
17
# It tests printing of thread event (start, exit) information, and
18
# disabling of those messages.
19
#
20
# Note: the format of thread event messages (and also whether or not
21
# messages are printed and can be disabled) is dependent on the target
22
# thread support code.
23
 
24
# This test has only been verified with Linux targets, and would need
25
# to be generalized to support other targets
26
if ![istarget *-*-linux*] then {
27
    return
28
}
29
 
30
# When using gdbserver, even on Linux, we don't get notifications
31
# about new threads.  This is expected, so don't test for that.
32
if [is_remote target] then {
33
    return
34
}
35
 
36
if $tracelevel then {
37
        strace $tracelevel
38
}
39
 
40
set prms_id 0
41
set bug_id 0
42
 
43
set testfile "thread_events"
44
set srcfile ${testfile}.c
45
set binfile ${objdir}/${subdir}/${testfile}
46
 
47
if {[gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable [list debug "incdir=${objdir}"]] != "" } {
48
    return -1
49
}
50
 
51
proc gdb_test_thread_start {messages_enabled command pattern message} {
52
  global gdb_prompt
53
 
54
  if { $messages_enabled } {
55
    set events_expected 1
56
  } else {
57
    set events_expected 0
58
  }
59
  set events_seen 0
60
 
61
  return [gdb_test_multiple $command $message {
62
    -re "\\\[New Thread \[^\]\]*\\\]\r\n" {
63
      incr events_seen;
64
      exp_continue;
65
    }
66
    -re "\[\r\n\]*($pattern)\[\r\n\]+$gdb_prompt $" {
67
      if { $events_seen != $events_expected } {
68
        fail "$message (saw $events_seen, expected $events_expected)"
69
      } else {
70
        pass "$message"
71
      }
72
    }
73
  }]
74
}
75
 
76
proc gdb_test_thread_exit {messages_enabled command pattern message} {
77
  global gdb_prompt
78
 
79
  if { $messages_enabled } {
80
    set events_expected 1
81
  } else {
82
    set events_expected 0
83
  }
84
  set events_seen 0
85
 
86
  return [gdb_test_multiple $command $message {
87
    -re "\\\[Thread \[^\]\]* exited\\\]\r\n" {
88
      incr events_seen
89
      exp_continue;
90
    }
91
    -re "\[\r\n\]*($pattern)\[\r\n\]+$gdb_prompt $" {
92
      if { $events_seen != $events_expected } {
93
        fail "$message (saw $events_seen, expected $events_expected)"
94
      } else {
95
        pass "$message"
96
      }
97
    }
98
  }]
99
}
100
 
101
proc test_thread_messages {enabled} {
102
  global srcdir subdir binfile srcfile
103
 
104
  if { $enabled } {
105
    set enabled_string "with messages enabled"
106
  } else {
107
    set enabled_string "with messages disabled"
108
  }
109
 
110
  gdb_start
111
  gdb_reinitialize_dir $srcdir/$subdir
112
  gdb_load ${binfile}
113
 
114
  if { $enabled } {
115
     gdb_test "set print thread-events on"
116
  } else {
117
     gdb_test "set print thread-events off"
118
  }
119
 
120
  # The initial thread may log a 'New Thread' message, but we don't
121
  # check for it.
122
  if ![runto_main] then {
123
     fail "Can't run to main $enabled_string"
124
     return 1
125
  }
126
 
127
  gdb_test "break threadfunc" \
128
      "Breakpoint.*at.* file .*$srcfile, line.*" \
129
      "breakpoint at threadfunc $enabled_string"
130
  gdb_test "break after_join_func" \
131
      "Breakpoint.*at.* file .*$srcfile, line.*" \
132
      "breakpoint at after_join_func $enabled_string"
133
 
134
  # continue to threadfunc breakpoint.  A thread will start.
135
  # Expect to see a thread start message, if messages are enabled.
136
  gdb_test_thread_start $enabled "continue" \
137
       ".*Breakpoint .*,.*threadfunc.*at.*$srcfile:.*" \
138
       "continue to threadfunc $enabled_string"
139
 
140
  # continue to after_join_func breakpoint.  A thread will exit.
141
  # Expect to see a thread exit message, if messages are enabled.
142
  gdb_test_thread_exit $enabled "continue" \
143
       ".*Breakpoint .*,.*after_join_func.*at.*$srcfile:.*" \
144
       "continue to after_join_func $enabled_string"
145
 
146
  delete_breakpoints
147
 
148
  gdb_exit
149
}
150
 
151
test_thread_messages 0
152
test_thread_messages 1

powered by: WebSVN 2.1.0

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