File: pretty-printers.exp

package info (click to toggle)
mdds 3.2.1-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 4,828 kB
  • sloc: cpp: 21,913; exp: 6,696; makefile: 698; ansic: 616; python: 602; sh: 428; lisp: 8
file content (56 lines) | stat: -rw-r--r-- 1,230 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# SPDX-FileCopyrightText: 2019 David Tardon
#
# SPDX-License-Identifier: GPL-3.0-or-later

# Procedures specific for pretty printers' tests.

# override flags--we do not want changed -data-directory
set INTERNAL_GDBFLAGS "-nw -nx"

proc pp_gdb_init {binfile dir} {
    gdb_exit
    gdb_start
    gdb_reinitialize_dir $dir
    gdb_load $binfile

    gdb_test_no_output "set python print-stack full"
    gdb_test_no_output "set print pretty off"
}

proc pp_load_printers {modules {regfunc "register_pretty_printers"}} {
    set commands [list]
    foreach module $modules {
        lappend commands "python import $module" "python $module.${regfunc}(gdb)"
    }

    foreach command $commands {
        if { [gdb_test_no_output "$command"] } {
            return 0
        }
    }

    return 1
}

proc pp_finish {} {
    set ok [gdb_breakpoint stop]
    if { $ok } {
        gdb_continue_to_breakpoint stop
        set ok [expr [gdb_test finish {.*}] ? 0 : 1]
    }
    return $ok
}

proc pp_run_test {func} {
    set ok [runto test_$func]
    if { $ok } {
        set ok [pp_finish]
    }
    return $ok
}

proc pp_test {var result} {
    return [gdb_test "print $var" "= $result"]
}

# vim: set shiftwidth=4 tabstop=4 expandtab: