File: __init__.py

package info (click to toggle)
libkdumpfile 0.5.4-3
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 3,800 kB
  • sloc: ansic: 34,639; sh: 3,853; python: 1,490; makefile: 755
file content (251 lines) | stat: -rw-r--r-- 7,915 bytes parent folder | download | duplicates (3)
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
#!/usr/bin/env python
# vim:sw=4 ts=4 et

from _addrxlat import *
from addrxlat.exceptions import *
import sys

class FullAddress(FullAddress):
    def __init__(self, addrspace=NOADDR, addr=0, *args, **kwargs):
        super(FullAddress, self).__init__(*args, **kwargs)
        self.addrspace = addrspace
        self.addr = addr

    def __repr__(self):
        return '%s(%r, %r)' % (self.__class__.__name__, self.addrspace, self.addr)

    def conv(self, addrspace, ctx, sys):
        status = super(FullAddress, self).conv(addrspace, ctx, sys)
        if status != OK:
            raise get_exception(status, ctx.get_err())

    def copy(self):
        "make a copy of self"
        return type(self)(addrspace=self.addrspace, addr=self.addr)

class Context(Context):
    def __init__(self, *args, **kwargs):
        super(Context, self).__init__(*args, **kwargs)
        self.convert = convert

    def __repr__(self):
        return '%s()' % (self.__class__.__name__,)

class Method(Method):
    def __init__(self, kind, target_as=NOADDR, param=(), *args, **kwargs):
        super(Method, self).__init__(*args, **kwargs)
        self.convert = convert
        self.target_as = target_as
        self.param = param

    def __repr__(self):
        return '%s(%r, %r, %r)' % (
            self.__class__.__name__,
            self.kind,
            self.target_as,
            self.param)

class CustomMethod(CustomMethod):
    def __init__(self, target_as=NOADDR, *args, **kwargs):
        super(CustomMethod, self).__init__(*args, **kwargs)
        self.convert = convert
        self.target_as = target_as

    def __repr__(self):
        return '%s(%r)' % (
            self.__class__.__name__,
            self.target_as)

class LinearMethod(LinearMethod):
    def __init__(self, target_as=NOADDR, off=0, *args, **kwargs):
        super(LinearMethod, self).__init__(*args, **kwargs)
        self.convert = convert
        self.target_as = target_as
        self.off = off

    def __repr__(self):
        return '%s(%r, %r)' % (
            self.__class__.__name__,
            self.target_as,
            self.off)

class PageTableMethod(PageTableMethod):
    def __init__(self, target_as=NOADDR, root=None, pte_format=PTE_NONE, fields=(), *args, **kwargs):
        super(PageTableMethod, self).__init__(*args, **kwargs)
        self.convert = convert
        self.target_as = target_as
        self.root = root
        self.pte_format = pte_format
        self.fields = fields

    def __repr__(self):
        return '%s(%r, %r, %r, %r)' % (
            self.__class__.__name__,
            self.target_as,
            self.root,
            self.pte_format,
            self.fields)

class LookupMethod(LookupMethod):
    def __init__(self, target_as=NOADDR, endoff=0, tbl=(), *args, **kwargs):
        super(LookupMethod, self).__init__(*args, **kwargs)
        self.convert = convert
        self.target_as = target_as
        self.endoff = endoff
        self.tbl = tbl

    def __repr__(self):
        return '%s(%r, %r, %r)' % (
            self.__class__.__name__,
            self.target_as,
            self.endoff,
            self.tbl)

class MemoryArrayMethod(MemoryArrayMethod):
    def __init__(self, target_as=NOADDR, base=None, shift=0, elemsz=0, valsz=0, *args, **kwargs):
        super(MemoryArrayMethod, self).__init__(*args, **kwargs)
        self.convert = convert
        self.target_as = target_as
        self.base = base
        self.shift = shift
        self.elemsz = elemsz
        self.valsz = valsz

    def __repr__(self):
        return '%s(%r, %r, %r, %r, %r)' % (
            self.__class__.__name__,
            self.target_as,
            self.base,
            self.shift,
            self.elemsz,
            self.valsz)

class Range(Range):
    def __init__(self, endoff=0, meth=SYS_METH_NONE, *args, **kwargs):
        super(Range, self).__init__(*args, **kwargs)
        self.endoff = endoff
        self.meth = meth

    def __repr__(self):
        return '%s(%r, %r)' % (
            self.__class__.__name__,
            self.endoff,
            self.meth)

class Map(Map):
    def __init__(self, *args, **kwargs):
        super(Map, self).__init__(*args, **kwargs)
        self.convert = convert

    def __repr__(self):
        return '%s()' % (self.__class__.__name__)

    def set(self, addr, range):
        status = super(Map, self).set(addr, range)
        if status != OK:
            raise get_exception(status)

class System(System):
    def __init__(self, *args, **kwargs):
        super(System, self).__init__(*args, **kwargs)
        self.convert = convert

    def __repr__(self):
        return '%s()' % (self.__class__.__name__)

    def os_init(self, ctx, arch, *args, **kwargs):
        status = super(System, self).os_init(ctx, arch, *args, **kwargs)
        if status != OK:
            raise get_exception(status, ctx.get_err())

class Step(Step):
    def __init__(self, ctx, sys=None, meth=None, *args, **kwargs):
        super(Step, self).__init__(*args, **kwargs)
        self.convert = convert
        if sys is not None:
            self.sys = sys
        if meth is not None:
            self.meth = meth

    def __repr__(self):
        return '%s(%r, %r, %r)' % (
            self.__class__.__name__,
            self.ctx,
            self.sys,
            self.meth)

    def launch(self, *args, **kwargs):
        status = super(Step, self).launch(*args, **kwargs)
        if status != OK:
            raise get_exception(status, self.ctx.get_err())

    def step(self, *args, **kwargs):
        status = super(Step, self).step(*args, **kwargs)
        if status != OK:
            raise get_exception(status, self.ctx.get_err())

    def walk(self, *args, **kwargs):
        status = super(Step, self).walk(*args, **kwargs)
        if status != OK:
            raise get_exception(status, self.ctx.get_err())

class Operator(Operator):
    def __init__(self, ctx, sys=None, caps=None):
        super(Operator, self).__init__()
        self.convert = convert
        if sys is not None:
            self.sys = sys
        if caps is not None:
            self.caps = caps

    def __repr__(self):
        return '%s(%r, %r)' % (
            self.__class__.__name__,
            self.ctx,
            self.sys)

    def __call__(self, *args, **kwargs):
        (status, result) = super(Operator, self).__call__(*args, **kwargs)
        if status != OK:
            raise get_exception(status, self.ctx.get_err())
        return result

convert = TypeConvert()
convert.FullAddress = FullAddress
convert.Context = Context
convert.Method = Method
convert.CustomMethod = CustomMethod
convert.LinearMethod = LinearMethod
convert.PageTableMethod = PageTableMethod
convert.LookupMethod = LookupMethod
convert.MemoryArrayMethod = MemoryArrayMethod
convert.Range = Range
convert.Map = Map
convert.System = System
convert.Step = Step
convert.Operator = Operator

import inspect as _inspect
_values = globals().values()
if sys.version_info.major >= 3:
    _values = list(_values)
for _cls in _values:
    if not _inspect.isclass(_cls):
        continue
    for _name, _method in _inspect.getmembers(_cls,
                                              lambda x:
                                              (_inspect.ismethod(x),
                                               _inspect.isfunction(x))
                                              [sys.version_info.major >= 3]):
        if _method.__doc__:
            continue
        for _parent in _inspect.getmro(_cls)[1:]:
            if hasattr(_parent, _name):
                if _inspect.ismethod(_method):
                    _method.__func__.__doc__ = getattr(_parent, _name).__doc__
                else:
                    _method.__doc__ = getattr(_parent, _name).__doc__
                break

# Free up temporary variables
del _values, _cls, _name, _method, _parent, _inspect