1 # DExTer : Debugging Experience Tester
4 # Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
5 # See https://llvm.org/LICENSE.txt for license information.
6 # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 """Set of data classes for representing the complete debug program state at a
8 fixed point in execution.
13 from collections
import OrderedDict
14 from pathlib
import PurePath
15 from typing
import List
19 def __init__(self
, path
: str = None, lineno
: int = None, column
: int = None):
21 path
= os
.path
.normcase(path
)
27 return "{}({}:{})".format(self
.path
, self
.lineno
, self
.column
)
29 def match(self
, other
) -> bool:
30 """Returns true iff all the properties that appear in `self` have the
31 same value in `other`, but not necessarily vice versa.
33 if not other
or not isinstance(other
, SourceLocation
):
37 other
.path
is None or (PurePath(self
.path
) != PurePath(other
.path
))
41 if self
.lineno
and (self
.lineno
!= other
.lineno
):
44 if self
.column
and (self
.column
!= other
.column
):
54 is_inlined
: bool = None,
55 location
: SourceLocation
= None,
56 watches
: OrderedDict
= None,
61 self
.function
= function
62 self
.is_inlined
= is_inlined
63 self
.location
= location
64 self
.watches
= watches
67 return "{}{}: {} | {}".format(
69 " (inlined)" if self
.is_inlined
else "",
71 {k
: str(self
.watches
[k
]) for k
in self
.watches
},
74 def match(self
, other
) -> bool:
75 """Returns true iff all the properties that appear in `self` have the
76 same value in `other`, but not necessarily vice versa.
78 if not other
or not isinstance(other
, StackFrame
):
81 if self
.location
and not self
.location
.match(other
.location
):
85 for name
in iter(self
.watches
):
87 if isinstance(self
.watches
[name
], dict):
88 for attr
in iter(self
.watches
[name
]):
90 getattr(other
.watches
[name
], attr
, None)
91 != self
.watches
[name
][attr
]
95 if other
.watches
[name
].value
!= self
.watches
[name
]:
104 def __init__(self
, frames
: List
[StackFrame
] = None):
110 lambda enum
: "Frame {}: {}".format(enum
[0], enum
[1]),
111 enumerate(self
.frames
),
115 def match(self
, other
) -> bool:
116 """Returns true iff all the properties that appear in `self` have the
117 same value in `other`, but not necessarily vice versa.
119 if not other
or not isinstance(other
, ProgramState
):
123 for idx
, frame
in enumerate(self
.frames
):
125 if not frame
.match(other
.frames
[idx
]):
127 except (IndexError, KeyError):