Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 29966ecceb5d0d02b8298bf1b85703a8a2c9b0ed (plain) (blame)
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
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
# *****************************************************************************
# * Copyright (c) 2011, 2013 Wind River Systems, Inc. and others.
# * All rights reserved. This program and the accompanying materials
# * are made available under the terms of the Eclipse Public License v1.0
# * which accompanies this distribution, and is available at
# * http://www.eclipse.org/legal/epl-v10.html
# *
# * Contributors:
# *     Wind River Systems - initial API and implementation
# *****************************************************************************

from .. import symbols
from ... import channel
from ...channel.Command import Command


class Context(symbols.Symbol):
    def __init__(self, props):
        super(Context, self).__init__(props)
        self.value = channel.toByteArray(props.get(symbols.PROP_VALUE))

    def getValue(self):
        return self.value


class SymbolsProxy(symbols.SymbolsService):

    def __init__(self, channel):
        self.channel = channel

    def getContext(self, contextID, done):
        done = self._makeCallback(done)
        service = self

        class GetContextCommand(Command):
            def __init__(self):
                super(GetContextCommand, self).__init__(service.channel,
                                                        service, "getContext",
                                                        (contextID,))

            def done(self, error, args):
                ctx = None
                if not error:
                    assert len(args) == 2
                    error = self.toError(args[0])
                    if args[1]:
                        ctx = Context(args[1])
                done.doneGetContext(self.token, error, ctx)
        return GetContextCommand().token

    def getChildren(self, parent_context_id, done):
        done = self._makeCallback(done)
        service = self

        class GetChildrenCommand(Command):

            def __init__(self):
                super(GetChildrenCommand, self).__init__(service.channel,
                                                         service,
                                                         "getChildren",
                                                         (parent_context_id,))

            def done(self, error, args):
                contexts = None
                if not error:
                    assert len(args) == 2
                    error = self.toError(args[0])
                    contexts = args[1]
                done.doneGetChildren(self.token, error, contexts)
        return GetChildrenCommand().token

    def getLocationInfo(self, symbolID, done):
        """Retrieve symbol location information.
        @param symbol_id - symbol ID.
        @param done - call back interface called when operation is completed.
        @return - pending command handle.
        """
        done = self._makeCallback(done)
        service = self

        class GetLocationInfoCommand(Command):
            def __init__(self):
                super(GetLocationInfoCommand, self).__init__(service.channel,
                                                             service,
                                                             "getLocationInfo",
                                                             (symbolID,))

            def done(self, error, args):
                props = None
                if not error:
                    assert len(args) == 2
                    error = self.toError(args[0])
                    props = args[1]
                done.doneGetContext(self.token, error, props)
        return GetLocationInfoCommand().token

    def getSymFileInfo(self, contextID, address, done):
        """Get symbol file info for a module that contains given address in a
        memory space.
        @param contextID - a memory space (process) ID.
        @param address - an address in the memory space.
        @param done - call back interface called when operation is completed.
        @return - pending command handle.
        """
        done = self._makeCallback(done)
        service = self

        class GetSymFileInfoCommand(Command):
            def __init__(self):
                super(GetSymFileInfoCommand, self).__init__(service.channel,
                                                            service,
                                                            "getSymFileInfo",
                                                            (contextID,
                                                             address,))

            def done(self, error, args):
                props = None
                if not error:
                    assert len(args) == 2
                    error = self.toError(args[0])
                    props = args[1]
                done.doneGetContext(self.token, error, props)
        return GetSymFileInfoCommand().token

    def find(self, context_id, ip, name, done):
        done = self._makeCallback(done)
        service = self

        class FindCommand(Command):

            def __init__(self):
                super(FindCommand, self).__init__(service.channel, service,
                                                  "find", (context_id, ip,
                                                           name))

            def done(self, error, args):
                symbolID = None
                if not error:
                    assert len(args) == 2
                    error = self.toError(args[0])
                    symbolID = args[1]
                done.doneFind(self.token, error, symbolID)
        return FindCommand().token

    def findByName(self, context_id, ip, name, done):
        done = self._makeCallback(done)
        service = self

        class FindByNameCommand(Command):

            def __init__(self):
                super(FindByNameCommand, self).__init__(service.channel,
                                                        service, "findByName",
                                                        (context_id, ip, name))

            def done(self, error, args):
                ids = []
                if not error:
                    assert len(args) >= 2
                    error = self.toError(args[0])
                    if not error:
                        ids = args[1:]
                done.doneFind(self.token, error, ids)
        return FindByNameCommand().token

    def findInScope(self, context_id, ip, scope_id, name, done):
        done = self._makeCallback(done)
        service = self

        class FindInScopeCommand(Command):

            def __init__(self):
                super(FindInScopeCommand, self).__init__(service.channel,
                                                         service,
                                                         "findInScope",
                                                         (context_id, ip,
                                                          scope_id, name))

            def done(self, error, args):
                ids = []
                if not error:
                    assert len(args) >= 2
                    error = self.toError(args[0])
                    if not error:
                        ids = args[1:]
                done.doneFind(self.token, error, ids)
        return FindInScopeCommand().token

    def findByAddr(self, context_id, addr, done):
        done = self._makeCallback(done)
        service = self

        class FindByAddrCommand(Command):

            def __init__(self):
                super(FindByAddrCommand, self).__init__(service.channel,
                                                        service, "findByAddr",
                                                        (context_id, addr))

            def done(self, error, args):
                symbolID = None
                if not error:
                    assert len(args) == 2
                    error = self.toError(args[0])
                    symbolID = args[1]
                done.doneFind(self.token, error, symbolID)
        return FindByAddrCommand().token

    def list(self, context_id, done):  # @ReservedAssignment
        done = self._makeCallback(done)
        service = self

        class ListCommand(Command):

            def __init__(self):
                super(ListCommand, self).__init__(service.channel, service,
                                                  "list", (context_id,))

            def done(self, error, args):
                lst = None
                if not error:
                    assert len(args) == 2
                    error = self.toError(args[0])
                    lst = args[1]
                done.doneList(self.token, error, lst)
        return ListCommand().token

    def getArrayType(self, type_id, length, done):
        done = self._makeCallback(done)
        service = self

        class GetArrayTypeCommand(Command):

            def __init__(self):
                super(GetArrayTypeCommand, self).__init__(service.channel,
                                                          service,
                                                          "getArrayType",
                                                          (type_id, length))

            def done(self, error, args):
                symbolID = None
                if not error:
                    assert len(args) == 2
                    error = self.toError(args[0])
                    symbolID = args[1]
                done.doneGetArrayType(self.token, error, symbolID)
        return GetArrayTypeCommand().token

    def findFrameInfo(self, context_id, address, done):
        done = self._makeCallback(done)
        service = self

        class FindFrameInfoCommand(Command):

            def __init__(self):
                super(FindFrameInfoCommand, self).__init__(service.channel,
                                                           service,
                                                           "findFrameInfo",
                                                           (context_id,
                                                            address))

            def done(self, error, args):
                address = None
                size = None
                fp_cmds = None
                reg_cmds = None
                if not error:
                    assert len(args) == 5
                    error = self.toError(args[0])
                    address, size, fp_cmds, reg_cmds = args[1:5]
                done.doneFindFrameInfo(self.token, error, address, size,
                                       fp_cmds, reg_cmds)
        return FindFrameInfoCommand().token

Back to the top