34 Commits

Author SHA1 Message Date
Narayan Kamath
fbb32f6440 Better systrace slices for application startup.
This change adds three new timeslices :

- PostFork : As soon as possible after the app forks from the
  zygote. Can be used in conjunction with the system_server
  "Start proc:" event to derive an upper bound on fork() and
  zygote overhead.

- RuntimeInit & ActivityThreadMain for ZygoteInit#runtimeInit
  and ActivityThread#main.

ActivityThread#handleBindApplication and higher level functions
are already well instrumented in systrace. handleBindApplication
should occur immediately after ActivityThread#main.

Note that we use the Activity manager tag to make it easier to
correlate these new events with surrounding events (Start proc
and handleBindApplication) that are already using the AM tag.

bug: 21632700
Change-Id: Ibc01f1721f962c913f3c02a51763b6feb1eb6a4d
2015-06-16 12:06:31 +01:00
Mark Salyzyn
fc737fb76c app_main missing include for sys/stat.h
app_main.c gets sys/stat.h inherited from
private/android_filesystem_config.h it should
not rely on this in the future. The intent is
to move fs_config function into libcutils and
thus deprecate any need for sys/stat.h in this
include file.

Bug: 19908228
Change-Id: I477b825e582742113f849aaa1df50c41e496b6f6
2015-04-01 16:02:32 +00:00
Douglas Leung
7e7c603182 Add mips64 support to app_process.
Change-Id: Ieb05a212606f02ebad119a0aea0ed92773ace214
2014-12-17 20:27:25 -08:00
Andreas Gampe
cfedceb8c1 Frameworks/base: Turn on -Wall -Werror in cmds
Fix small warnings, turn on -Wall -Werror.

Change-Id: Iab1f01a7c7ebd6ba832b75067c5e395f380a1b8b
2014-11-07 14:33:51 -08:00
Jeff Brown
00c0cd4a24 Clean entire arg block when setting process name.
When Android processes fork from Zygote, we rewrite the command line
with a new name, eg. "system_server".  When we do this, we should
fill the entire block with zeros to remove corrupted argument
information that may otherwise remain in the /proc/<pid>/cmdline buffer
and be seen in tools and stack dumps.

Fixed an issue where VM options could be overwritten after setting
the nice name if the name was too long.

Bug: 17474152
Change-Id: Ie6cf9ed7752a04300a340e26cd6812bb35c59e1b
2014-09-11 14:19:52 -07:00
Alex Light
55471dcd0f Change /dalvik-cache to be owned by root.
Bug: 16875245

(cherry picked from commit 79bf4007f559e194205f632b23d2bfb6f8d1e7ba)

Change-Id: I29a70215a2207bc4e0db02ab751d32a68edf4b66
2014-08-28 17:02:37 -07:00
Narayan Kamath
6eb1b2611c Fix x86 build in app_process.
Look for __i386__ and not __x86__.

Change-Id: Iffa3709f9d0c96cce17f3183a6f036a78eccc787
2014-04-30 16:45:07 +01:00
Narayan Kamath
dfacf855fd Merge "Create arch specific cache dirs during zygote startup." 2014-04-30 08:34:56 +00:00
Narayan Kamath
d1e127e141 Create arch specific cache dirs during zygote startup.
The runtime expects them to exist before it's launched.
The boot image / art files are created during the first
zygote launch.

Change-Id: I5ed0ad4854dc7785246344c8f6eaf54e560feb7d
2014-04-30 09:26:05 +01:00
Nick Kralevich
195c73c9b2 Set NO_NEW_PRIVS on zygote init
When app_process/zygote starts, make sure PR_SET_NO_NEW_PRIVS is set.
This prevents zygote spawned apps from acquiring new privileges
on exec.

In particular, this allows the CTS test
android.os.cts.SecurityFeaturesTest#testNoNewPrivs() to pass if ART is set
as the default runtime.

Change-Id: I81139cda999c7b1430242561aad28f566e9b6da0
2014-04-29 15:10:58 -07:00
Elliott Hughes
6bd762289b Fix a typo in an assertion.
Change-Id: I3e97bb3cb8070c0ec0c6b97769f1da3e7b4ef8f5
2014-04-23 16:54:33 -07:00
Narayan Kamath
90c75cf02e Don't compare String8s to NULL.
Use String8::isEmpty instead. Note that this code path is hit
only if the zygote calls ::exit, and that never happens unless
the VM invocation fails.

Change-Id: I0e7d3a86a79b12b2174ca3bf0dbe1904e33c041a
2014-04-12 12:25:50 +01:00
Narayan Kamath
d35d3e5d39 Dual zygote cleanup.
- Use different process names for the 32 / 64 bit zygote.
- Pass command line arguments correctly. The first unmatched
  argument must be passed through to the java main class.

Change-Id: I952ebbdbba941f118d992354b9bd0ada2dade417
2014-04-10 12:15:39 +01:00
Narayan Kamath
c41638cb75 Make zygotes aware of their supported ABIs.
Query system properties for the list of ABIs and pass
it as a command line argument to ZygoteInit.

Also add a new Zygote command that returns this list of
ABIs to peers.

Change-Id: I68034c6f63fa626911122579a011a0a25a8cda94
2014-04-09 13:41:15 +01:00
Narayan Kamath
22ec1eefa4 Clean up argc / argv processing for runtime args.
- Make copies of argc, argv before argv is potentially
  overwritten with the process name.
- Allow multiple command line arguments to be passed to
  ZygoteInit (this is required for some of the 64 bit
  zygote work).
- Add an explanatory comment about how these argments
  are processed.

Change-Id: I752be69c5c0f97ed17d1a3dded19f46ee00929b0
2014-04-09 13:39:41 +01:00
Narayan Kamath
a23fcd7be8 Remove ProcessState::mArgc,mArgV,mArgLen
These look like historical oddities, and weren't really being
used for anything useful.

Process:setArgV0 was being called by android.util.Process, but
that functionality can be moved directly into the implementation
of that class.

bug: 13647418

Change-Id: I216c8f8a4c065f0cf3a61f19f9e32decd26f93f6
2014-04-03 12:29:07 +00:00
Nick Kralevich
d53afd2b05 revert ADDR_COMPAT_LAYOUT workaround.
Stop working around bad applications by setting ADDR_COMPAT_LAYOUT.
ADDR_COMPAT_LAYOUT is undesirable because it reduces the amount of
address space available to an application.

The Android emulator, in both 4.3 and 4.4, does not set
ADDR_COMPAT_LAYOUT. Anyone needing to test their application on a
version of Android without ADDR_COMPAT_LAYOUT can use the emulator
and reproduce the failures.

Change-Id: I8f753acc205798bd7f031026c7ece12d26de562c
2013-09-18 14:29:46 -07:00
Nick Kralevich
fc8bd4d3f4 am 35587a0c: Merge "Don\'t set ADDR_COMPAT_LAYOUT on the emulator"
* commit '35587a0c47c33a8eed7817dc705dbf502f7b5b60':
  Don't set ADDR_COMPAT_LAYOUT on the emulator
2013-04-23 17:06:58 -07:00
Nick Kralevich
fc17dc2548 Don't set ADDR_COMPAT_LAYOUT on the emulator
Don't work around third party app bugs on the emulator.

Change-Id: I4440fcd56b72e3a74881ddec2a469f037a060525
2013-04-23 15:40:03 -07:00
Jamie Gennis
6ad0452e63 Disable tracing from Zygote
This change disables all atrace tracing in Zygote immediately after it is
initialized.  This is necessary because Zygote has no way to receive
notifications that the enabled trace tags have been changed.  Tracing is
re-enabled when other processes fork from Zygote.

Change-Id: If2983858fb0c4890ba9ab041849b1c4d98f66c13
2013-04-16 22:15:21 +00:00
Nick Kralevich
9a9350550a app_process: don't pollute the environment
Give a hoot — don't pollute!

Change-Id: I30d6c05cecab483f0e9d8063907f7bc0ef2bb104
2013-03-15 13:14:52 -07:00
Nick Kralevich
1fe21bd1b6 Never call app_main more than once
Different kernels seem to handle ADDR_COMPAT_LAYOUT differently,
sometimes passing it to its children, sometimes not. If it's not
passed to its child successfully, we can end up in a restart loop.

Instead of testing for the presence of ADDR_COMPAT_LAYOUT, use an
environment variable instead, which is handled more predictably.

Bug: 8392487
Change-Id: Ia531dd2abb4e1cd46f3430d844e644f53581f530
2013-03-15 11:59:03 -07:00
Nick Kralevich
5fa1ee779e Don't use ADDR_COMPAT_LAYOUT on the emulator
For the emulator, we want people to see memory as it
actually is, not how we're hacking around buggy apps. Don't
set ADDR_COMPAT_LAYOUT on the emulator.

For reasons that I don't understand, personality(ADDR_COMPAT_LAYOUT)
does not persist across an exec on the emulator. app_main gets
into a tight loop restarting itself because of this. This change
also works around that bug.

Change-Id: Ia73a7d2d623c25cf39d248145d97307945d554da
2013-03-14 16:31:34 -07:00
Nick Kralevich
8a0a929422 Respawn app_main if ADDR_COMPAT_LAYOUT is not set
Bug: 8358800
Change-Id: Id81aa26d74dfd16a49f0ee5926ea2cdb3c2106d8
2013-03-14 15:21:12 -07:00
Steve Block
3762c31172 Rename (IF_)LOGE(_IF) to (IF_)ALOGE(_IF) DO NOT MERGE
See https://android-git.corp.google.com/g/#/c/157220

Bug: 5449033
Change-Id: Ic9c19d30693bd56755f55906127cd6bd7126096c
2012-01-08 13:19:13 +00:00
Steve Block
71f2cf116a Rename (IF_)LOGV(_IF) to (IF_)ALOGV(_IF) DO NOT MERGE
See https://android-git.corp.google.com/g/#/c/143865

Bug: 5449033
Change-Id: I0122812ed6ff6f5b59fe4a43ab8bff0577adde0a
2011-10-26 09:57:54 +01:00
Jeff Brown
10e8971286 Eliminate single-process mode.
Bug: 5010576

Change-Id: Id450dc83efed4897d1e4ff451530fed14457aace
2011-07-08 19:54:07 -07:00
Jeff Brown
ebed7d6e35 Support wrapping app processes to inject debug instrumentation.
Bug: 4437846

Change-Id: I4552501c693716b14714afb5c5248edaca9547ab
2011-05-24 12:01:25 -07:00
Elliott Hughes
d195e5ab40 Replace a custom AndroidRuntime::findClass with a more targeted fix.
This seems simpler and more contained, and I think the comment explaining
why hoop-jumping is necessary is a bit clearer now.

Change-Id: Ief4afd7cbb42188ed835fce23e497520bdb753a8
2011-04-13 16:43:15 -07:00
Brian Carlstrom
de6d1d889e Move LOG_ALWAYS_FATAL to end of app_process
Since LOG_ALWAYS_FATAL is always fatal and code after it is by
definition unreachable, put the call after other diagnostic output.

Change-Id: Ib3a515a04125d8e4f6e8af3a6f59226e8f0dd9cd
2010-10-07 16:02:11 -07:00
Mathias Agopian
0795272aa2 move libbinder's header files under includes/binder 2009-05-20 12:55:03 -07:00
The Android Open Source Project
9066cfe988 auto import from //depot/cupcake/@135843 2009-03-03 19:31:44 -08:00
The Android Open Source Project
d83a98f4ce auto import from //depot/cupcake/@135843 2009-03-03 18:28:45 -08:00
The Android Open Source Project
54b6cfa9a9 Initial Contribution 2008-10-21 07:00:00 -07:00