mirror of
https://github.com/imcarlost/pidcat-repl.git
synced 2026-08-08 23:17:43 -04:00
reintegrated pull request #71 (https://github.com/JakeWharton/pidcat/pull/71) onto master
This commit is contained in:
@@ -140,6 +140,7 @@ TAGTYPES = {
|
|||||||
'F': colorize(' F ', fg=BLACK, bg=RED),
|
'F': colorize(' F ', fg=BLACK, bg=RED),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
PID_LINE = re.compile(r'^\w+\s+(\w+)\s+\w+\s+\w+\s+\w+\s+\w+\s+\w+\s+\w\s([\w|\.]+)$')
|
||||||
PID_START = re.compile(r'^.*: Start proc ([a-zA-Z0-9._:]+) for ([a-z]+ [^:]+): pid=(\d+) uid=(\d+) gids=(.*)$')
|
PID_START = re.compile(r'^.*: Start proc ([a-zA-Z0-9._:]+) for ([a-z]+ [^:]+): pid=(\d+) uid=(\d+) gids=(.*)$')
|
||||||
PID_START_DALVIK = re.compile(r'^E/dalvikvm\(\s*(\d+)\): >>>>> ([a-zA-Z0-9._:]+) \[ userId:0 \| appId:(\d+) \]$')
|
PID_START_DALVIK = re.compile(r'^E/dalvikvm\(\s*(\d+)\): >>>>> ([a-zA-Z0-9._:]+) \[ userId:0 \| appId:(\d+) \]$')
|
||||||
PID_KILL = re.compile(r'^Killing (\d+):([a-zA-Z0-9._:]+)/[^:]+: (.*)$')
|
PID_KILL = re.compile(r'^Killing (\d+):([a-zA-Z0-9._:]+)/[^:]+: (.*)$')
|
||||||
@@ -149,13 +150,14 @@ LOG_LINE = re.compile(r'^([A-Z])/(.+?)\( *(\d+)\): (.*?)$')
|
|||||||
BUG_LINE = re.compile(r'.*nativeGetEnabledTags.*')
|
BUG_LINE = re.compile(r'.*nativeGetEnabledTags.*')
|
||||||
BACKTRACE_LINE = re.compile(r'^#(.*?)pc\s(.*?)$')
|
BACKTRACE_LINE = re.compile(r'^#(.*?)pc\s(.*?)$')
|
||||||
|
|
||||||
adb_command = ['adb']
|
base_adb_command = ['adb']
|
||||||
if args.device_serial:
|
if args.device_serial:
|
||||||
adb_command.extend(['-s', args.device_serial])
|
base_adb_command.extend(['-s', args.device_serial])
|
||||||
if args.use_device:
|
if args.use_device:
|
||||||
adb_command.append('-d')
|
base_adb_command.append('-d')
|
||||||
if args.use_emulator:
|
if args.use_emulator:
|
||||||
adb_command.append('-e')
|
base_adb_command.append('-e')
|
||||||
|
adb_command = base_adb_command[:]
|
||||||
adb_command.append('logcat')
|
adb_command.append('logcat')
|
||||||
|
|
||||||
# Clear log before starting logcat
|
# Clear log before starting logcat
|
||||||
@@ -224,6 +226,24 @@ def parse_start_proc(line):
|
|||||||
return line_package, '', line_pid, line_uid, ''
|
return line_package, '', line_pid, line_uid, ''
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
ps_command = base_adb_command + ['shell', 'ps']
|
||||||
|
ps_pid = subprocess.Popen(ps_command, stdin=PIPE, stdout=PIPE, stderr=PIPE)
|
||||||
|
while ps_pid.poll() is None:
|
||||||
|
try:
|
||||||
|
line = ps_pid.stdout.readline().decode('utf-8', 'replace').strip()
|
||||||
|
except KeyboardInterrupt:
|
||||||
|
break
|
||||||
|
if len(line) == 0:
|
||||||
|
break
|
||||||
|
|
||||||
|
pid_match = PID_LINE.match(line)
|
||||||
|
if pid_match is not None:
|
||||||
|
pid = pid_match.group(1)
|
||||||
|
proc = pid_match.group(2)
|
||||||
|
if proc in catchall_package:
|
||||||
|
seen_pids = True
|
||||||
|
pids.add(pid)
|
||||||
|
|
||||||
while adb.poll() is None:
|
while adb.poll() is None:
|
||||||
try:
|
try:
|
||||||
line = adb.stdout.readline().decode('utf-8', 'replace').strip()
|
line = adb.stdout.readline().decode('utf-8', 'replace').strip()
|
||||||
|
|||||||
Reference in New Issue
Block a user