[Lldb-commits] [PATCH] D68968: [android/process info] Introduce bundle id

Dan Albert via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Thu Oct 17 12:54:44 PDT 2019


danalbert added a subscriber: enh.
danalbert added a comment.

In D68968#1710520 <https://reviews.llvm.org/D68968#1710520>, @labath wrote:

> Independently, I am wondering if there's a better way to link the process id to a bundle. Using argv[0] might be ok if we're using it just for display purposes, but if we're going to be doing other stuff based on that identifier, it would be better to get it from a more reliable source. Unfortunately, I was not able to find a more "reasonable source", but maybe @danalbert has an idea.


@enh might



================
Comment at: lldb/source/Host/linux/Host.cpp:220-222
+  if (process_info.GetNameAsStringRef().empty() &&
+      !process_info.GetArg0().empty()) {
+    process_info.SetBundleID(process_info.GetArg0());
----------------
labath wrote:
> wallace wrote:
> > labath wrote:
> > > How sure are we that the app processes are the only ones which have the exe link unreadable? Will that be true on all phones or just the recent ones with all the selinux stuff?
> > > 
> > > I was hoping that there is some more reliable way of fetching this information, but there doesn't seem to be anything except [[ https://developer.android.com/reference/android/app/ActivityManager.RunningAppProcessInfo.html | ActivityManager.RunningAppProcessInfo ]], which I don't know if it can be accessed from lldb, either host- or device-side.
> > > 
> > > @danalbert, any ideas here?
> > Another option I've just discovered is to invoke `pm list packages` to get the list of all apks and if an Arg0 is in that list, then it's a package.
> > That seems good enough
> That should prevent us accidentally setting an incorrect bundle id, but it does not prevent a process from deliberately changing its argv[0] to the name of some other installed package. That seems suboptimal, particularly if we're later going to use start using the bundle id for other than just display purposes (e.g. for issuing "am kill" commands). So, I am still wondering if we shouldn't go back to using argv[0] for the purpose of "process list", and leave the "bundle id" field for cases where we can get this information from a more reliable source (e.g. reading it from the apk, or fetching it from the android package manager, etc). What do you think?
@enh 


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D68968/new/

https://reviews.llvm.org/D68968





More information about the lldb-commits mailing list