def translateBinderWrote(line, timestamp, makeDict): splitLine = line.split(' ') pid = splitLine[1] procPid = pid[:pid.find(':')] threadPid = pid[pid.find(':') + 1:] writeConsumed = splitLine[3] writeSize = splitLine[5][:-1] readConsumed = splitLine[8] readSize = splitLine[10] if makeDict: binderDict = {} binderDict.op = "binder_wrote" binderDict.pid = pid binderDict.proc = buu.getProcessNameFor(pid) binderDict.threadpid = threadpid binderDict.writesize = writeSize binderDict.readSize = readSize binderDict.writeConsumed = writeConsumed binderDict.readConsumed = readConsumed return binder_dict return ( "[%s] binder: process pid %s (%s), thread pid %s, wrote %s of %s bytes, read %s of %s bytes" % (timestamp, procPid, buu.getProcessNameFor(procPid), threadPid, writeConsumed, writeSize, readConsumed, readSize))
def translateBinderRelease(line, timestamp, makeDict): splitLine = line.split(' ') pid = splitLine[1] threads = splitLine[3][:-1] nodes = splitLine[5] irefs = splitLine[7][:-2] orefs = splitLine[9][:-1] ats = splitLine[12][:-1] buffers = splitLine[14][:-1] pages = splitLine[16] if makeDict: binderDict = {} binderDict.op = "binder_release" binderDict.pid = pid binderDict.proc = buu.getProcessNameFor(pid) binderDict.threads = threads binderDict.nodes = nodes binderDict.irefs = irefs binderDict.orefs = orefs binderDict.ats = ats binderDict.buffers = buffers binderDict.pages = pages return binderDict print( "[%s] binder_release: pid %s (%s) released %s threads, %s nodes, %s incoming refs, %s outgoing refs, %s active transactions, %s buffers, %s pages" % (timestamp, pid, buu.getProcessNameFor(pid), threads, nodes, irefs, orefs, ats, buffers, pages))
def traslateBinderWrite(line, timestamp, makeDict): splitLine = line.split(' ') pid = splitLine[1] procPid = pid[:pid.find(':')] threadPid = pid[pid.find(':') + 1:] writeSize = splitLine[3] readSize = splitLine[7] writeAddr = splitLine[5] readAddr = splitLine[9] if makeDict: binderDict = {} binderDict.op = "binder_write" binderDict.pid = pid binderDict.proc = buu.getProcessNameFor(pid) binderDict.threadpid = threadpid binderDict.writesize = writeSize binderDict.readSize = readSize binderDict.writeAddr = writeAddr binderDict.readAddr = readAddr return binder_dict return ( "[%s] binder: process pid %s (%s), thread pid %s, writing %s bytes at addr %s reading %s bytes at addr %s" % (timestamp, procPid, buu.getProcessNameFor(procPid), threadPid, writeSize, writeAddr, readSize, readAddr))
def translateBinderCloseVma(line, timestamp, makeDict): splitLine = line.split(' ') pid = splitLine[1] vma = splitLine[5] vmaStart = vma[:vma.find('-')] vmaEnd = vma[vma.find('-') + 1:] size = splitLine[6][1:] flags = splitLine[9] prot = splitLine[11] if makeDict: binderDict = {} # binderDict'op'] = "binder_closevm" # binderDict['pid'] = pid binderDict.proc = buu.getProcessNameFor(pid) binderDict.vma = vma binderDict.vmaStart = vmaStart binderDict.vmaEnd = vmaEnd binderDict.size = size binderDict.flags = flags binderDict.prot = prot return binderDict return ( "[%s] binder: pid %s (%s) closed vm area addr %s-%s, size %s, flags %s, prot %s" % (timestamp, pid, buu.getProcessNameFor(pid), vmaStart, vmaEnd, size, flags, prot))
def translateBinderMmap(line, timestamp, makeDict): splitLine = line.split(' ') pid = splitLine[1] vma = splitLine[2] vmaStart = vma[:vma.find('-')] vmaEnd = vma[vma.find('-') + 1:] size = splitLine[3][1:] flags = splitLine[6] prot = splitLine[8] name = buu.getProcessNameFor(pid) if makeDict: binderDict = {} binderDict.op = "binder_mmap" binderDict.pid = pid binderDict.proc = buu.getProcessNameFor(pid) binderDict.vma = vma binderDict.vmaStart = vmaStart binderDict.vmaEnd = vmaEnd binderDict.size = size binderDict.flags = flags binderDict.prot = prot binderDict.name = name return binderDict return ( "[%s] binder_mmap: pid %s (%s) mapped addr %s-%s, size %s, flags %s, prot %s" % (timestamp, pid, name, vmaStart, vmaEnd, size, flags, prot))
def translateBinderCommandReply(line, timestamp, makeDict): splitLine = line.split(' ') sender = splitLine[1] senderPid = sender[:sender.find(':')] senderThread = sender[sender.find(':') + 1:] debugId = splitLine[3] target = splitLine[5] targetPid = target[:target.find(':')] targetThread = target[target.find(':') + 1:] addrs = line[line.find('data'):line.find('size')] bufferAddr = addrs[addrs.find(' '):addrs.find('-')].strip() offsetsAddr = addrs[addrs.find('-') + 1:].strip() if "null" in bufferAddr: bufferAddr = "null" if "null" in offsetsAddr: offsetsAddr = "null" sizes = line[line.find('size'):] bufferSize = sizes[sizes.find(' '):sizes.find('-')].strip() offsetsSize = sizes[sizes.find('-') + 1:].strip() extra = translateBinderCommandExtras(line, line.find('size') + 1 + len(sizes)) if makeDict: binderDict = {} binderDict['op'] = "BC_REPLY" binderDict['sender'] = buu.getProcessNameFor(senderPid) binderDict['senderPid'] = senderPid binderDict['senderThread'] = senderThread binderDict['debugId'] = debugId binderDict['target'] = buu.getProcessNameFor(targetPid) binderDict['targetPid'] = targetPid binderDict['targetThread'] = targetThread binderDict['addrs'] = addrs binderDict['bufferAddr'] = bufferAddr binderDict['offsetsAddr'] = offsetsAddr binderDict['sizes'] = sizes binderDict['bufferSize'] = bufferSize binderDict['offsetsSize'] = offsetsSize binderDict['extra'] = extra return binderDict return ( "[%s] binder_command BC_REPLY: process pid %s (%s), thread pid %s -> process pid %s (%s), thread pid %s \ transaction id %s, data address %s, data size %s, offsets address %s, offsets size %s %s" % (timestamp, senderPid, buu.getProcessNameFor(senderPid), senderThread, targetPid, buu.getProcessNameFor(targetPid), targetThread, debugId, bufferAddr, bufferSize, offsetsAddr, offsetsSize, extra))
def translateBinderFlush(line, timestamp, makeDict): splitLine = line.split(' ') pid = splitLine[1] num = splitLine[3] if makeDict: binderDict = {} binderDict.op = "binder_flush" binderDict.pid = pid binderDict.proc = buu.getProcessNameFor(pid) binderDict.num = num return binderDict return ("[%s] binder_flush: pid %s (%s) woke %s threads" % (timestamp, pid, buu.getProcessNameFor(pid), num))
def translateBinderOpen(line, timestamp, makeDict): c1 = line.find(':') + 2 c2 = line.find(':', c1) pid1 = line[c1:c2] pid2 = line[c2 + 1:] name = buu.getProcessNameFor(pid2) if makeDict: binderDict = {} binderDict.timestamp = timestamp binderDict.pidfrom = pid1 binderDict.procfrom = buu.getProcessNameFor(pid1) binderDict.pidto = pid2 binderDict.procto = buu.getProcessNameFor(pid2) print("[%s] binder_open: group leader pid %s, current pid %s (%s)" % (timestamp, pid1, pid2, name))
def translateBinderReturn(line, timestamp): splitLine = line.split(' ') pid = splitLine[1] c = pid.find(':') procPid = pid[:c] threadPid = pid[c+1:] fromPid = splitLine[4] c2 = fromPid.find(':') fromProcPid = fromPid[:c2] fromThreadPid = fromPid[c2+1:-1] debugId = splitLine[3] binderDict = {} if "BR_TRANSACTION" in line : binderDict['op'] = "BR_TRANSACTION" else : binderDict['op'] = "BR_REPLY" binderDict['pid'] = pid binderDict['procpid'] = procPid binderDict['proc'] = buu.getProcessNameFor(procPid) binderDict['threadPid'] = threadPid binderDict['debugId'] = debugId # If PID is 0, this is a one way async transaction # Info from corr. binder command can help us resolve the PID if fromProcPid == '0': resolvedInfo = resolveCallForDebugId(debugId) if resolvedInfo == -1: binderDict['fromPid'] = fromProcPid binderDict['fromProc'] = 'async RPC' binderDict['fromThreadPid'] = fromThreadPid else: binderDict['fromPid'] = resolvedInfo[0] binderDict['fromProc'] = str(buu.getProcessNameFor(resolvedInfo[0])) binderDict['fromThreadPid'] = resolvedInfo[1] else: binderDict['fromPid'] = fromProcPid binderDict['fromProc'] = buu.getProcessNameFor(fromProcPid) binderDict['fromThreadPid'] = fromThreadPid binderDict['timestamp'] = timestamp return binderDict
def translateBinderCommandTransaction(line, timestamp): splitLine = line.split(' ') sender = splitLine[1] senderPid = sender[:sender.find(':')] senderThread = sender[sender.find(':')+1:] targetPid = splitLine[5] debugId = splitLine[3] binderDict = {} binderDict['op'] = "BC_TRANSACTION" binderDict['sender'] = buu.getProcessNameFor(senderPid) binderDict['senderPid'] = senderPid binderDict['senderThread'] = senderThread binderDict['targetPid'] = targetPid binderDict['target'] = buu.getProcessNameFor(targetPid) binderDict['debugId'] = debugId binderDict['timestamp'] = timestamp return binderDict
def translateBinderCommandReply(line, timestamp): splitLine = line.split(' ') sender = splitLine[1] senderPid = sender[:sender.find(':')] senderThread = sender[sender.find(':')+1:] debugId = splitLine[3] target = splitLine[5] targetPid = target[:target.find(':')] targetThread = target[target.find(':')+1:] binderDict = {} binderDict['op'] = "BC_REPLY" binderDict['sender'] = buu.getProcessNameFor(senderPid) binderDict['senderPid'] = senderPid binderDict['senderThread'] = senderThread binderDict['target'] = buu.getProcessNameFor(targetPid) binderDict['targetPid'] = targetPid binderDict['targetThread'] = targetThread binderDict['debugId'] = debugId binderDict['timestamp'] = timestamp return binderDict
def translateBinderBufferRelease(line, timestamp, makeDict): splitLine = line.split(' ') pid = splitLine[1] debugId = splitLine[4][:-1] size = splitLine[6] sizeData = size[:size.find('-')] sizeOffsets = size[size.find('-') + 1:-1] failedAt = line[line.find('at') + 2:] if "null" in failedAt: failedAt = "" else: failedAt = ", " + failedAt extra = "" end = line.find('at') + 2 pos = line.find('fd', end) pos2 = line.find('ref', end) if pos != -1 and pos2 < pos: pos = pos2 pos2 = line.find('node', end) if pos != -1 and pos2 < pos: pos = pos2 if pos != -1: extra = line[pos:] print "here" time.sleep(5) if makeDict: binderDict = {} binderDict['op'] = "binder_buffer_release" binderDict['pid'] = pid binderDict['sizeData'] = sizeData binderDict['sizeOffsets'] = sizeOffsets binderDict['debugId'] = debugId binderDict['size'] = sizeData binderDict['sizeOffsets'] = sizeOffsets binderDict['extra'] = extra return binderDict return ( "[%s] binder: process pid %s (%s) buffer release id %s, data size %s, offsets size %s %s %s" % (timestamp, pid, buu.getProcessNameFor(pid), debugId, sizeData, sizeOffsets, failedAt, extra))
def translateBinderReturn(line, timestamp, makeDict): splitLine = line.split(' ') pid = splitLine[1] c = pid.find(':') procPid = pid[:c] threadPid = pid[c + 1:] cmd = splitLine[2] transactionDebugId = splitLine[3] fromPid = splitLine[4] c2 = fromPid.find(':') fromProcPid = fromPid[:c2] fromThreadPid = fromPid[c2 + 1:-1] cmdUInt = splitLine[6][:-4] # kernel 3.4 specific bufferSize = splitLine[7] bufferDataSize = bufferSize[:bufferSize.find('-')] bufferOffsetsSize = bufferSize[bufferSize.find('-') + 1:] bufferAddresses = splitLine[9] bufferDataAddress = bufferAddresses[:bufferAddresses.find('-')] bufferOffsetsAddress = bufferAddresses[bufferAddresses.find('-') + 1:] fromString = "process pid " + fromProcPid + " (" + buu.getProcessNameFor( fromProcPid) + "), thread pid " + fromThreadPid if fromProcPid == "0": fromString = "n/a" if makeDict: binderDict = {} if "BR_TRANSACTION" in line: binderDict['op'] = "BR_TRANSACTION" else: binderDict['op'] = "BR_REPLY" binderDict['pid'] = pid binderDict['procpid'] = procPid binderDict['proc'] = buu.getProcessNameFor(procPid) binderDict['threadPid'] = threadPid binderDict['cmd'] = cmd binderDict['transactionDebugId'] = transactionDebugId binderDict['fromPid'] = fromPid binderDict['fromProcPid'] = fromProcPid binderDict['fromProc'] = buu.getProcessNameFor(fromProcPid) binderDict['fromThreadPid'] = fromThreadPid binderDict['cmdUInt'] = cmdUInt binderDict['bufferSize'] = bufferSize binderDict['bufferDataSize'] = bufferDataSize binderDict['bufferOffsetsSize'] = bufferOffsetsSize binderDict['bufferAddresses'] = bufferAddresses binderDict['bufferDataAddress'] = bufferDataAddress binderDict['bufferOffsetsAddress'] = bufferOffsetsAddress binderDict['fromString'] = fromString return binderDict return ( "[%s] binder_return %s: process pid %s (%s), thread pid %s, from %s, \ transaction id %s, command value %s, data address %s, data size %s, offsets address %s, offsets size %s" % (timestamp, cmd, procPid, buu.getProcessNameFor(procPid), threadPid, fromString, transactionDebugId, cmdUInt, bufferDataAddress, bufferDataSize, bufferOffsetsAddress, bufferOffsetsSize))