3 class OutcomeBasicOutcomePrinter(object):
4 """Print an outcome::basic_outcome<T>"""
6 def __init__(self
, val
):
10 if self
.val
['_state']['_status']['status_value'] & 1 == 1:
11 yield ('value', self
.val
['_state']['_value'])
12 if self
.val
['_state']['_status']['status_value'] & 2 == 2:
13 yield ('error', self
.val
['_state']['_error'])
14 if self
.val
['_state']['_status']['status_value'] & 4 == 4:
15 yield ('exception', self
.val
['_ptr'])
17 def display_hint(self
):
21 if self
.val
['_state']['_status']['status_value'] & 54 == 54:
22 return 'errored (errno, moved from) + exceptioned'
23 if self
.val
['_state']['_status']['status_value'] & 50 == 50:
24 return 'errored (errno, moved from)'
25 if self
.val
['_state']['_status']['status_value'] & 38 == 38:
26 return 'errored + exceptioned (moved from)'
27 if self
.val
['_state']['_status']['status_value'] & 36 == 36:
28 return 'exceptioned (moved from)'
29 if self
.val
['_state']['_status']['status_value'] & 35 == 35:
30 return 'errored (moved from)'
31 if self
.val
['_state']['_status']['status_value'] & 33 == 33:
32 return 'valued (moved from)'
33 if self
.val
['_state']['_status']['status_value'] & 22 == 22:
34 return 'errored (errno) + exceptioned'
35 if self
.val
['_state']['_status']['status_value'] & 18 == 18:
36 return 'errored (errno)'
37 if self
.val
['_state']['_status']['status_value'] & 6 == 6:
38 return 'errored + exceptioned'
39 if self
.val
['_state']['_status']['status_value'] & 4 == 4:
41 if self
.val
['_state']['_status']['status_value'] & 2 == 2:
43 if self
.val
['_state']['_status']['status_value'] & 1 == 1:
45 if self
.val
['_state']['_status']['status_value'] & 0xff == 0:
49 def build_pretty_printer():
50 pp
= gdb
.printing
.RegexpCollectionPrettyPrinter("outcome_v2")
51 pp
.add_printer('outcome_v2::basic_result', '^outcome_v2[_0-9a-f]*::basic_result<.*>$', OutcomeBasicOutcomePrinter
)
52 pp
.add_printer('outcome_v2::basic_outcome', '^outcome_v2[_0-9a-f]*::basic_outcome<.*>$', OutcomeBasicOutcomePrinter
)
55 def register_printers(obj
= None):
56 gdb
.printing
.register_pretty_printer(obj
, build_pretty_printer(), replace
= True)
58 register_printers(gdb
.current_objfile())