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

Subversion Repositories openrisc_2011-10-31

[/] [openrisc/] [tags/] [gnu-src/] [gdb-7.2/] [gdb-7.2-or32-1.0rc1/] [gdb/] [testsuite/] [gdb.python/] [py-prettyprint.exp] - Blame information for rev 341

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 330 jeremybenn
# Copyright (C) 2008, 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 is part of the GDB testsuite.  It tests Python-based
17
# pretty-printing for the CLI.
18
 
19
if $tracelevel then {
20
    strace $tracelevel
21
}
22
 
23
set testfile "py-prettyprint"
24
set srcfile ${testfile}.c
25
set binfile ${objdir}/${subdir}/${testfile}
26
 
27
# Start with a fresh gdb.
28
gdb_exit
29
gdb_start
30
 
31
# Skip all tests if Python scripting is not enabled.
32
if { [skip_python_tests] } { continue }
33
 
34
# Run a command in GDB, and report a failure if a Python exception is thrown.
35
# If report_pass is true, report a pass if no exception is thrown.
36
proc gdb_py_test_silent_cmd {cmd name report_pass} {
37
  global gdb_prompt
38
 
39
  gdb_test_multiple $cmd $name {
40
      -re "Traceback.*$gdb_prompt $"  { fail $name }
41
      -re "$gdb_prompt $"             { if $report_pass { pass $name } }
42
  }
43
}
44
 
45
proc run_lang_tests {lang} {
46
    global srcdir subdir srcfile binfile testfile hex
47
    if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable "debug $lang"] != "" } {
48
        untested "Couldn't compile ${srcfile} in $lang mode"
49
        return -1
50
    }
51
 
52
    set nl "\[\r\n\]+"
53
 
54
    # Start with a fresh gdb.
55
    gdb_exit
56
    gdb_start
57
    gdb_reinitialize_dir $srcdir/$subdir
58
    gdb_load ${binfile}
59
 
60
    if ![runto_main ] then {
61
        perror "couldn't run to breakpoint"
62
        return
63
    }
64
 
65
    gdb_test_no_output "set print pretty on"
66
 
67
    gdb_test "b [gdb_get_line_number {break to inspect} ${testfile}.c ]" \
68
        ".*Breakpoint.*"
69
    gdb_test "continue" ".*Breakpoint.*"
70
 
71
    set remote_python_file [remote_download host ${srcdir}/${subdir}/${testfile}.py]
72
 
73
    gdb_test_no_output "python execfile ('${remote_python_file}')"
74
 
75
    gdb_test "print ss" " = a=< a=<1> b=<$hex>> b=< a=<2> b=<$hex>>"
76
    gdb_test "print ssa\[1\]" " = a=< a=<5> b=<$hex>> b=< a=<6> b=<$hex>>"
77
    gdb_test "print ssa" " = {a=< a=<3> b=<$hex>> b=< a=<4> b=<$hex>>, a=< a=<5> b=<$hex>> b=< a=<6> b=<$hex>>}"
78
 
79
    gdb_test "print arraystruct" " = {$nl *y = 7, *$nl *x = { a=<23> b=<$hex>,  a=<24> b=<$hex>} *$nl *}"
80
 
81
    if {$lang == "c++"} {
82
        gdb_test "print cps" "=  a=<8> b=<$hex>"
83
        gdb_test "print cpss" " = {$nl *zss = 9, *$nl *s =  a=<10> b=<$hex>$nl}"
84
        gdb_test "print cpssa\[0\]" " = {$nl *zss = 11, *$nl *s =  a=<12> b=<$hex>$nl}"
85
        gdb_test "print cpssa\[1\]" " = {$nl *zss = 13, *$nl *s =  a=<14> b=<$hex>$nl}"
86
        gdb_test "print cpssa" " = {{$nl *zss = 11, *$nl *s =  a=<12> b=<$hex>$nl *}, {$nl *zss = 13, *$nl *s =  a=<14> b=<$hex>$nl *}}"
87
        gdb_test "print sss" "= a=<15> b=< a=<8> b=<$hex>>"
88
        gdb_test "print ref" "= a=<15> b=< a=<8> b=<$hex>>"
89
        gdb_test "print derived" \
90
            " = \{.* = pp class name: Vbase1.* = \{.* = pp value variable is: 1,.*members of Vbase2:.*_vptr.Vbase2 = $hex.* = \{.*members of Vbase3.*members of Derived:.*value = 2.*"
91
        gdb_test "print ns " "\"embedded\\\\000null\\\\000string\""
92
        gdb_py_test_silent_cmd "set print elements 3" "" 1
93
        gdb_test "print ns" "emb\.\.\.."
94
        gdb_py_test_silent_cmd "set print elements 10" "" 1
95
        gdb_test "print ns" "embedded\\\\000n\.\.\.."
96
        gdb_py_test_silent_cmd "set print elements 200" "" 1
97
    }
98
 
99
    gdb_test "print x" " = \"this is x\""
100
    gdb_test "print cstring" " = \"const string\""
101
 
102
    gdb_test "print estring" "\"embedded x\\\\201\\\\202\\\\203\\\\204\""
103
    gdb_test "print c" " = container \"container\" with 2 elements = {$nl *.0. = 23,$nl *.1. = 72$nl}"
104
 
105
    gdb_test "print nstype" " = {$nl *.0. = 7,$nl *.1. = 42$nl}"
106
    gdb_test "continue" "Program exited normally\."
107
 
108
    remote_file host delete ${remote_python_file}
109
}
110
 
111
run_lang_tests "c"
112
run_lang_tests "c++"
113
 
114
# Run various other tests.
115
 
116
if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable "debug"] != "" } {
117
    untested "Couldn't compile ${srcfile}"
118
    return -1
119
}
120
 
121
# Start with a fresh gdb.
122
gdb_exit
123
gdb_start
124
gdb_reinitialize_dir $srcdir/$subdir
125
gdb_load ${binfile}
126
 
127
if ![runto_main ] then {
128
    perror "couldn't run to breakpoint"
129
    return
130
}
131
 
132
gdb_test "b [gdb_get_line_number {break to inspect} ${testfile}.c ]" \
133
    ".*Breakpoint.*"
134
gdb_test "continue" ".*Breakpoint.*"
135
 
136
set remote_python_file [remote_download host ${srcdir}/${subdir}/${testfile}.py]
137
 
138
gdb_test_no_output "python execfile ('${remote_python_file}')"
139
 
140
gdb_test "print ss" " = a=< a=<1> b=<$hex>> b=< a=<2> b=<$hex>>" \
141
    "print ss enabled #1"
142
 
143
gdb_test_no_output "python disable_lookup_function ()"
144
 
145
gdb_test "print ss" " = {a = {a = 1, b = $hex}, b = {a = 2, b = $hex}}" \
146
    "print ss disabled"
147
 
148
gdb_test_no_output "python enable_lookup_function ()"
149
 
150
gdb_test "print ss" " = a=< a=<1> b=<$hex>> b=< a=<2> b=<$hex>>" \
151
    "print ss enabled #2"
152
 
153
remote_file host delete ${remote_python_file}

powered by: WebSVN 2.1.0

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