OpenCores
URL https://opencores.org/ocsvn/openrisc_2011-10-31/openrisc_2011-10-31/trunk

Subversion Repositories openrisc_2011-10-31

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

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

Line No. Rev Author Line
1 330 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
 
41
set testfile "thread_events"
42
set srcfile ${testfile}.c
43
set binfile ${objdir}/${subdir}/${testfile}
44
 
45
if {[gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable [list debug "incdir=${objdir}"]] != "" } {
46
    return -1
47
}
48
 
49
proc gdb_test_thread_start {messages_enabled command pattern message} {
50
  global gdb_prompt
51
 
52
  if { $messages_enabled } {
53
    set events_expected 1
54
  } else {
55
    set events_expected 0
56
  }
57
  set events_seen 0
58
 
59
  return [gdb_test_multiple $command $message {
60
    -re "\\\[New Thread \[^\]\]*\\\]\r\n" {
61
      incr events_seen;
62
      exp_continue;
63
    }
64
    -re "\[\r\n\]*($pattern)\[\r\n\]+$gdb_prompt $" {
65
      if { $events_seen != $events_expected } {
66
        fail "$message (saw $events_seen, expected $events_expected)"
67
      } else {
68
        pass "$message"
69
      }
70
    }
71
  }]
72
}
73
 
74
proc gdb_test_thread_exit {messages_enabled command pattern message} {
75
  global gdb_prompt
76
 
77
  if { $messages_enabled } {
78
    set events_expected 1
79
  } else {
80
    set events_expected 0
81
  }
82
  set events_seen 0
83
 
84
  return [gdb_test_multiple $command $message {
85
    -re "\\\[Thread \[^\]\]* exited\\\]\r\n" {
86
      incr events_seen
87
      exp_continue;
88
    }
89
    -re "\[\r\n\]*($pattern)\[\r\n\]+$gdb_prompt $" {
90
      if { $events_seen != $events_expected } {
91
        fail "$message (saw $events_seen, expected $events_expected)"
92
      } else {
93
        pass "$message"
94
      }
95
    }
96
  }]
97
}
98
 
99
proc test_thread_messages {enabled} {
100
  global srcdir subdir binfile srcfile
101
 
102
  if { $enabled } {
103
    set enabled_string "with messages enabled"
104
  } else {
105
    set enabled_string "with messages disabled"
106
  }
107
 
108
  gdb_start
109
  gdb_reinitialize_dir $srcdir/$subdir
110
  gdb_load ${binfile}
111
 
112
  if { $enabled } {
113
     gdb_test "set print thread-events on"
114
  } else {
115
     gdb_test "set print thread-events off"
116
  }
117
 
118
  # The initial thread may log a 'New Thread' message, but we don't
119
  # check for it.
120
  if ![runto_main] then {
121
     fail "Can't run to main $enabled_string"
122
     return 1
123
  }
124
 
125
  gdb_test "break threadfunc" \
126
      "Breakpoint.*at.* file .*$srcfile, line.*" \
127
      "breakpoint at threadfunc $enabled_string"
128
  gdb_test "break after_join_func" \
129
      "Breakpoint.*at.* file .*$srcfile, line.*" \
130
      "breakpoint at after_join_func $enabled_string"
131
 
132
  # continue to threadfunc breakpoint.  A thread will start.
133
  # Expect to see a thread start message, if messages are enabled.
134
  gdb_test_thread_start $enabled "continue" \
135
       ".*Breakpoint .*,.*threadfunc.*at.*$srcfile:.*" \
136
       "continue to threadfunc $enabled_string"
137
 
138
  # continue to after_join_func breakpoint.  A thread will exit.
139
  # Expect to see a thread exit message, if messages are enabled.
140
  gdb_test_thread_exit $enabled "continue" \
141
       ".*Breakpoint .*,.*after_join_func.*at.*$srcfile:.*" \
142
       "continue to after_join_func $enabled_string"
143
 
144
  delete_breakpoints
145
 
146
  gdb_exit
147
}
148
 
149
test_thread_messages 0
150
test_thread_messages 1

powered by: WebSVN 2.1.0

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