mirror of
https://github.com/imcarlost/pidcat-repl.git
synced 2026-08-08 23:17:43 -04:00
[pidcat] Allow package to specify a process as well …
Summary: Android apps can use multiple processes (eg, chrome), which are identified as <package_name>:<process_name> in logs. The names are defined in the manifest. The main process is referred to as simply <package_name> by android. Add the ability to specify a target process as part of what was until now the package name in pidcat, or all processes if no process is specified. Usage: * pidcat <package_name> will match all of an app's processes (catchall). * pidcat <package_name>:<process_name> will match a given named process. ** In particular, pidcat <package_name>: will ensure only the app's main/default process is matched. Test Plan: Run the script, try out with no process, empty (aka default) process, named process. Try multiple entries.
This commit is contained in:
@@ -44,6 +44,13 @@ parser.add_argument('-e', '--emulator', dest='use_emulator', action='store_true'
|
|||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
min_level = LOG_LEVELS_MAP[args.min_level]
|
min_level = LOG_LEVELS_MAP[args.min_level]
|
||||||
|
|
||||||
|
# Store the names of packages for which to match all processes.
|
||||||
|
catchall_package = filter(lambda package: package.find(":") == -1, args.package)
|
||||||
|
# Store the name of processes to match exactly.
|
||||||
|
named_processes = filter(lambda package: package.find(":") != -1, args.package)
|
||||||
|
# Convert default process names from <package>: (cli notation) to <package> (android notation) in the exact names match group.
|
||||||
|
named_processes = map(lambda package: package if package.find(":") != len(package) - 1 else package[:-1], named_processes)
|
||||||
|
|
||||||
header_size = args.tag_width + 1 + 3 + 1 # space, level, space
|
header_size = args.tag_width + 1 + 3 + 1 # space, level, space
|
||||||
|
|
||||||
width = -1
|
width = -1
|
||||||
@@ -157,8 +164,10 @@ app_pid = None
|
|||||||
def match_packages(token):
|
def match_packages(token):
|
||||||
if len(args.package) == 0:
|
if len(args.package) == 0:
|
||||||
return True
|
return True
|
||||||
|
if token in named_processes:
|
||||||
|
return True
|
||||||
index = token.find(':')
|
index = token.find(':')
|
||||||
return (token in args.package) if index == -1 else (token[:index] in args.package)
|
return (token in catchall_package) if index == -1 else (token[:index] in catchall_package)
|
||||||
|
|
||||||
def parse_death(tag, message):
|
def parse_death(tag, message):
|
||||||
if tag != 'ActivityManager':
|
if tag != 'ActivityManager':
|
||||||
|
|||||||
Reference in New Issue
Block a user