simpleperf reads argv[0] from /proc/<pid>/cmdline for display purposes. If not for display, a package name is expected from user inputs.
On Thu, Oct 17, 2019 at 1:33 PM enh <e...@google.com> wrote: > nothing i know of. +yabinc might have dealt with this with simpleperf... > > On Thu, Oct 17, 2019 at 12:54 PM Dan Albert via Phabricator > <revi...@reviews.llvm.org> wrote: > > > > 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 > > > > > > >
_______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits