OLD | NEW |
1 # Copyright (C) 2010-2012 Free Software Foundation, Inc. | 1 # Copyright (C) 2010-2012 Free Software Foundation, Inc. |
2 | 2 |
3 # This program is free software; you can redistribute it and/or modify | 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 | 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 | 5 # the Free Software Foundation; either version 3 of the License, or |
6 # (at your option) any later version. | 6 # (at your option) any later version. |
7 # | 7 # |
8 # This program is distributed in the hope that it will be useful, | 8 # This program is distributed in the hope that it will be useful, |
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of | 9 # but WITHOUT ANY WARRANTY; without even the implied warranty of |
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
60 def build_pretty_printer(): | 60 def build_pretty_printer(): |
61 pp = gdb.printing.RegexpCollectionPrettyPrinter("pp-test") | 61 pp = gdb.printing.RegexpCollectionPrettyPrinter("pp-test") |
62 | 62 |
63 pp.add_printer('struct s', '^struct s$', pp_s) | 63 pp.add_printer('struct s', '^struct s$', pp_s) |
64 pp.add_printer('s', '^s$', pp_s) | 64 pp.add_printer('s', '^s$', pp_s) |
65 | 65 |
66 # Use a lambda this time to exercise doing things this way. | 66 # Use a lambda this time to exercise doing things this way. |
67 pp.add_printer('struct ss', '^struct ss$', lambda val: pp_ss(val)) | 67 pp.add_printer('struct ss', '^struct ss$', lambda val: pp_ss(val)) |
68 pp.add_printer('ss', '^ss$', lambda val: pp_ss(val)) | 68 pp.add_printer('ss', '^ss$', lambda val: pp_ss(val)) |
69 | 69 |
| 70 pp.add_printer('enum flag_enum', '^flag_enum$', |
| 71 gdb.printing.FlagEnumerationPrinter('enum flag_enum')) |
| 72 |
70 return pp | 73 return pp |
71 | 74 |
72 | 75 |
73 gdb.printing.register_pretty_printer(gdb, lookup_function_lookup_test) | 76 gdb.printing.register_pretty_printer(gdb, lookup_function_lookup_test) |
74 my_pretty_printer = build_pretty_printer() | 77 my_pretty_printer = build_pretty_printer() |
75 gdb.printing.register_pretty_printer(gdb, my_pretty_printer) | 78 gdb.printing.register_pretty_printer(gdb, my_pretty_printer) |
76 | 79 |
77 # Exercise the "replace" argument to register pretty_printer. | 80 # Exercise the "replace" argument to register pretty_printer. |
78 saw_runtime_error = False | 81 saw_runtime_error = False |
79 try: | 82 try: |
80 gdb.printing.register_pretty_printer(gdb, my_pretty_printer, replace=False) | 83 gdb.printing.register_pretty_printer(gdb, my_pretty_printer, replace=False) |
81 except RuntimeError: | 84 except RuntimeError: |
82 saw_runtime_error = True | 85 saw_runtime_error = True |
83 pass | 86 pass |
84 if not saw_runtime_error: | 87 if not saw_runtime_error: |
85 raise RuntimeError("Missing RuntimeError from register_pretty_printer") | 88 raise RuntimeError("Missing RuntimeError from register_pretty_printer") |
86 gdb.printing.register_pretty_printer(gdb, my_pretty_printer, replace=True) | 89 gdb.printing.register_pretty_printer(gdb, my_pretty_printer, replace=True) |
OLD | NEW |