[pidcat] Display package:process_name in process birth/death messages

Summary: Making sense of a birth/death message is made easier by specifying which process it applies to, and not just the component or the pid.

Test Plan: Run, monitor message lines when cycling a multi-process app, inject None as a process name to check resilience.
This commit is contained in:
Louis Boval
2014-03-12 23:27:39 -07:00
parent b19221ac33
commit 97b9c28813
+14 -11
View File
@@ -162,23 +162,26 @@ def match_packages(token):
def parse_death(tag, message): def parse_death(tag, message):
if tag != 'ActivityManager': if tag != 'ActivityManager':
return None return None, None
kill = PID_KILL.match(message) kill = PID_KILL.match(message)
if kill: if kill:
pid = kill.group(1) pid = kill.group(1)
if match_packages(kill.group(2)) and pid in pids: package_line = kill.group(2)
return pid if match_packages(package_line) and pid in pids:
return pid, package_line
leave = PID_LEAVE.match(message) leave = PID_LEAVE.match(message)
if leave: if leave:
pid = leave.group(2) pid = leave.group(2)
if match_packages(leave.group(1)) and pid in pids: package_line = leave.group(1)
return pid if match_packages(package_line) and pid in pids:
return pid, package_line
death = PID_DEATH.match(message) death = PID_DEATH.match(message)
if death: if death:
pid = death.group(2) pid = death.group(2)
if match_packages(death.group(1)) and pid in pids: package_line = death.group(1)
return pid if match_packages(package_line) and pid in pids:
return None return pid, package_line
return None, None
while adb.poll() is None: while adb.poll() is None:
try: try:
@@ -209,19 +212,19 @@ while adb.poll() is None:
linebuf = '\n' linebuf = '\n'
linebuf += colorize(' ' * (header_size - 1), bg=WHITE) linebuf += colorize(' ' * (header_size - 1), bg=WHITE)
linebuf += indent_wrap(' Process created for %s\n' % target) linebuf += indent_wrap(' Process %s created for %s\n' % (line_package, target))
linebuf += colorize(' ' * (header_size - 1), bg=WHITE) linebuf += colorize(' ' * (header_size - 1), bg=WHITE)
linebuf += ' PID: %s UID: %s GIDs: %s' % (line_pid, line_uid, line_gids) linebuf += ' PID: %s UID: %s GIDs: %s' % (line_pid, line_uid, line_gids)
linebuf += '\n' linebuf += '\n'
print(linebuf) print(linebuf)
last_tag = None # Ensure next log gets a tag printed last_tag = None # Ensure next log gets a tag printed
dead_pid = parse_death(tag, message) dead_pid, dead_pname = parse_death(tag, message)
if dead_pid: if dead_pid:
pids.remove(dead_pid) pids.remove(dead_pid)
linebuf = '\n' linebuf = '\n'
linebuf += colorize(' ' * (header_size - 1), bg=RED) linebuf += colorize(' ' * (header_size - 1), bg=RED)
linebuf += ' Process %s ended' % dead_pid linebuf += ' Process %s (PID: %s) ended' % (dead_pname, dead_pid)
linebuf += '\n' linebuf += '\n'
print(linebuf) print(linebuf)
last_tag = None # Ensure next log gets a tag printed last_tag = None # Ensure next log gets a tag printed