MCPcopy Create free account
hub / github.com/iovisor/bcc / decode

Method decode

src/python/bcc/disassembler.py:234–305  ·  view source on GitHub ↗
(cls, i, w, w1)

Source from the content-addressed store, hash-verified

232
233 @classmethod
234 def decode(cls, i, w, w1):
235 try:
236 name, opclass, op, bits = cls.opcodes[w.opcode]
237 if opclass == 'dstimm':
238 return 'r%d %s %d' % (w.dst, op, w.imm), 0
239
240 elif opclass == 'dstimm_bw':
241 return 'r%d %s 0x%x' % (w.dst, op, w.immu), 0
242
243 elif opclass == 'joff':
244 return 'goto %s <%d>' % ('%+d' % (w.offset),
245 i + w.offset + 1), 0
246
247 elif opclass == 'dstsrc':
248 return 'r%d %s r%d' % (w.dst, op, w.src), 0
249
250 elif opclass == 'jdstimmoff':
251 return 'if r%d %s %d goto pc%s <%d>' % (w.dst, op, w.imm,
252 '%+d' % (w.offset),
253 i + w.offset + 1), 0
254
255 elif opclass == 'jdstsrcoff':
256 return 'if r%d %s r%d goto pc%s <%d>' % (w.dst, op, w.src,
257 '%+d' % (w.offset),
258 i + w.offset + 1), 0
259
260 elif opclass == 'lddw':
261 # imm contains the file descriptor (FD) of the map being loaded;
262 # the kernel will translate this into the proper address
263 if w1 is None:
264 raise Exception("lddw requires two instructions to be disassembled")
265 if w1.imm == 0:
266 return 'r%d = <map at fd #%d>' % (w.dst, w.imm), 1
267 imm = (w1.imm << 32) | w.imm
268 return 'r%d = 0x%x' % (w.dst, imm), 1
269
270 elif opclass == 'ldabs':
271 return 'r0 = *(u%s*)skb[%s]' % (bits, w.imm), 0
272
273 elif opclass == 'ldind':
274 return 'r0 = *(u%d*)skb[r%d %s]' % (bits, w.src,
275 '%+d' % (w.imm)), 0
276
277 elif opclass == 'ldstsrcoff':
278 return 'r%d = *(u%d*)(r%d %s)' % (w.dst, bits, w.src,
279 '%+d' % (w.offset)), 0
280
281 elif opclass == 'sdstoffimm':
282 return '*(u%d*)(r%d %s) = %d' % (bits, w.dst,
283 '%+d' % (w.offset), w.imm), 0
284
285 elif opclass == 'sdstoffsrc':
286 return '*(u%d*)(r%d %s) = r%d' % (bits, w.dst,
287 '%+d' % (w.offset), w.src), 0
288
289 elif opclass == 'dst':
290 return 'r%d = %s (u%s)r%d' % (w.dst, op, bits, w.dst), 0
291

Callers 15

print_eventFunction · 0.80
get_processes_statsFunction · 0.80
opensnoop.pyFile · 0.80
print_eventFunction · 0.80
print_eventFunction · 0.80
print_eventFunction · 0.80
print_eventFunction · 0.80
offcputime.pyFile · 0.80
print_eventFunction · 0.80
print_eventFunction · 0.80
print_outstandingFunction · 0.80

Calls

no outgoing calls

Tested by 5

Get_libc_pathFunction · 0.64
test_log_debugMethod · 0.64
test_log_no_debugMethod · 0.64
test_simple_binaryMethod · 0.64