Merge "Refactor jit debugger interface and its ELF creation."
diff --git a/cmdline/cmdline_parser_test.cc b/cmdline/cmdline_parser_test.cc
index 5d67206..70cc07e 100644
--- a/cmdline/cmdline_parser_test.cc
+++ b/cmdline/cmdline_parser_test.cc
@@ -375,7 +375,7 @@
TEST_F(CmdlineParserTest, TestJdwpProviderDefault) {
const char* opt_args = "-XjdwpProvider:default";
- EXPECT_SINGLE_PARSE_VALUE(JdwpProvider::kInternal, opt_args, M::JdwpProvider);
+ EXPECT_SINGLE_PARSE_VALUE(JdwpProvider::kAdbConnection, opt_args, M::JdwpProvider);
} // TEST_F
TEST_F(CmdlineParserTest, TestJdwpProviderInternal) {
diff --git a/cmdline/cmdline_types.h b/cmdline/cmdline_types.h
index d0d6bfd..2bc7409 100644
--- a/cmdline/cmdline_types.h
+++ b/cmdline/cmdline_types.h
@@ -77,10 +77,10 @@
"Example: -XjdwpProvider:internal for internal jdwp implementation\n"
"Example: -XjdwpProvider:adbconnection for adb connection mediated jdwp implementation\n"
"Example: -XjdwpProvider:default for the default jdwp implementation"
- " (currently internal)\n");
- } else if (option == "internal" || option == "default") {
+ " (currently adbconnection)\n");
+ } else if (option == "internal") {
return Result::Success(JdwpProvider::kInternal);
- } else if (option == "adbconnection") {
+ } else if (option == "adbconnection" || option == "default") {
return Result::Success(JdwpProvider::kAdbConnection);
} else if (option == "none") {
return Result::Success(JdwpProvider::kNone);
diff --git a/runtime/Android.bp b/runtime/Android.bp
index e30a06c..07764b8 100644
--- a/runtime/Android.bp
+++ b/runtime/Android.bp
@@ -67,8 +67,13 @@
"liblog",
// For common macros.
"libbase",
+ "libz",
],
- export_include_dirs: ["."],
+
+ // Exporting "." would shadow the system elf.h with our elf.h,
+ // which in turn breaks any tools that reference this library.
+ // export_include_dirs: ["."],
+
// ART's macros.h depends on libbase's macros.h.
// Note: runtime_options.h depends on cmdline. But we don't really want to export this
// generically. dex2oat takes care of it itself.
@@ -78,11 +83,6 @@
art_cc_library {
name: "libdexfile",
defaults: ["libdexfile_defaults"],
- vendor_available: true,
- vndk: {
- enabled: true,
- support_system_process: true,
- },
// Leave the symbols in the shared library so that stack unwinders can
// produce meaningful name resolution.
strip: {
diff --git a/runtime/dexopt_test.cc b/runtime/dexopt_test.cc
index d93d767..037d1fb 100644
--- a/runtime/dexopt_test.cc
+++ b/runtime/dexopt_test.cc
@@ -213,8 +213,8 @@
// Ensure a chunk of memory is reserved for the image space.
// The reservation_end includes room for the main space that has to come
// right after the image in case of the GSS collector.
- uintptr_t reservation_start = ART_BASE_ADDRESS;
- uintptr_t reservation_end = ART_BASE_ADDRESS + 384 * MB;
+ uint64_t reservation_start = ART_BASE_ADDRESS;
+ uint64_t reservation_end = ART_BASE_ADDRESS + 384 * MB;
std::unique_ptr<BacktraceMap> map(BacktraceMap::Create(getpid(), true));
ASSERT_TRUE(map.get() != nullptr) << "Failed to build process map";
diff --git a/runtime/gc/heap.cc b/runtime/gc/heap.cc
index 6da092c..b1932d1 100644
--- a/runtime/gc/heap.cc
+++ b/runtime/gc/heap.cc
@@ -3484,10 +3484,8 @@
const uint64_t bytes_allocated_during_gc = bytes_allocated + freed_bytes -
bytes_allocated_before_gc;
// Calculate when to perform the next ConcurrentGC.
- // Calculate the estimated GC duration.
- const double gc_duration_seconds = NsToMs(current_gc_iteration_.GetDurationNs()) / 1000.0;
// Estimate how many remaining bytes we will have when we need to start the next GC.
- size_t remaining_bytes = bytes_allocated_during_gc * gc_duration_seconds;
+ size_t remaining_bytes = bytes_allocated_during_gc;
remaining_bytes = std::min(remaining_bytes, kMaxConcurrentRemainingBytes);
remaining_bytes = std::max(remaining_bytes, kMinConcurrentRemainingBytes);
if (UNLIKELY(remaining_bytes > max_allowed_footprint_)) {
diff --git a/runtime/native/dalvik_system_ZygoteHooks.cc b/runtime/native/dalvik_system_ZygoteHooks.cc
index fd80aae..e22726b 100644
--- a/runtime/native/dalvik_system_ZygoteHooks.cc
+++ b/runtime/native/dalvik_system_ZygoteHooks.cc
@@ -173,6 +173,7 @@
DEBUG_JAVA_DEBUGGABLE = 1 << 8,
DISABLE_VERIFIER = 1 << 9,
ONLY_USE_SYSTEM_OAT_FILES = 1 << 10,
+ DISABLE_HIDDEN_API_CHECKS = 1 << 11,
};
static uint32_t EnableDebugFeatures(uint32_t runtime_flags) {
@@ -284,6 +285,11 @@
runtime_flags &= ~ONLY_USE_SYSTEM_OAT_FILES;
}
+ if ((runtime_flags & DISABLE_HIDDEN_API_CHECKS) != 0) {
+ Runtime::Current()->DisableHiddenApiChecks();
+ runtime_flags &= ~DISABLE_HIDDEN_API_CHECKS;
+ }
+
if (runtime_flags != 0) {
LOG(ERROR) << StringPrintf("Unknown bits set in runtime_flags: %#x", runtime_flags);
}
@@ -331,6 +337,9 @@
}
}
+ DCHECK(!is_system_server || !Runtime::Current()->AreHiddenApiChecksEnabled())
+ << "SystemServer should be forked with DISABLE_HIDDEN_API_CHECKS";
+
if (instruction_set != nullptr && !is_system_server) {
ScopedUtfChars isa_string(env, instruction_set);
InstructionSet isa = GetInstructionSetFromString(isa_string.c_str());
diff --git a/runtime/native_stack_dump.cc b/runtime/native_stack_dump.cc
index fa46709..2fef70b 100644
--- a/runtime/native_stack_dump.cc
+++ b/runtime/native_stack_dump.cc
@@ -333,15 +333,15 @@
os << prefix << StringPrintf("#%02zu pc ", it->num);
bool try_addr2line = false;
if (!BacktraceMap::IsValid(it->map)) {
- os << StringPrintf(Is64BitInstructionSet(kRuntimeISA) ? "%016" PRIxPTR " ???"
- : "%08" PRIxPTR " ???",
+ os << StringPrintf(Is64BitInstructionSet(kRuntimeISA) ? "%016" PRIx64 " ???"
+ : "%08" PRIx64 " ???",
it->pc);
} else {
- os << StringPrintf(Is64BitInstructionSet(kRuntimeISA) ? "%016" PRIxPTR " "
- : "%08" PRIxPTR " ",
+ os << StringPrintf(Is64BitInstructionSet(kRuntimeISA) ? "%016" PRIx64 " "
+ : "%08" PRIx64 " ",
it->rel_pc);
if (it->map.name.empty()) {
- os << StringPrintf("<anonymous:%" PRIxPTR ">", it->map.start);
+ os << StringPrintf("<anonymous:%" PRIx64 ">", it->map.start);
} else {
os << it->map.name;
}
@@ -361,7 +361,7 @@
PcIsWithinQuickCode(current_method, it->pc)) {
const void* start_of_code = current_method->GetEntryPointFromQuickCompiledCode();
os << current_method->JniLongName() << "+"
- << (it->pc - reinterpret_cast<uintptr_t>(start_of_code));
+ << (it->pc - reinterpret_cast<uint64_t>(start_of_code));
} else {
os << "???";
}
diff --git a/runtime/parsed_options.cc b/runtime/parsed_options.cc
index 2f60162..92eb703 100644
--- a/runtime/parsed_options.cc
+++ b/runtime/parsed_options.cc
@@ -330,6 +330,8 @@
.Define("-Xtarget-sdk-version:_")
.WithType<int>()
.IntoKey(M::TargetSdkVersion)
+ .Define("-Xno-hidden-api-checks")
+ .IntoKey(M::NoHiddenApiChecks)
.Ignore({
"-ea", "-da", "-enableassertions", "-disableassertions", "--runtime-arg", "-esa",
"-dsa", "-enablesystemassertions", "-disablesystemassertions", "-Xrs", "-Xint:_",
diff --git a/runtime/runtime.cc b/runtime/runtime.cc
index 007d361..33bebe0 100644
--- a/runtime/runtime.cc
+++ b/runtime/runtime.cc
@@ -265,6 +265,7 @@
oat_file_manager_(nullptr),
is_low_memory_mode_(false),
safe_mode_(false),
+ do_hidden_api_checks_(false),
dump_native_stack_on_sig_quit_(true),
pruned_dalvik_cache_(false),
// Initially assume we perceive jank in case the process state is never updated.
@@ -1168,6 +1169,10 @@
target_sdk_version_ = runtime_options.GetOrDefault(Opt::TargetSdkVersion);
+ if (runtime_options.Exists(Opt::NoHiddenApiChecks)) {
+ do_hidden_api_checks_ = false;
+ }
+
no_sig_chain_ = runtime_options.Exists(Opt::NoSigChain);
force_native_bridge_ = runtime_options.Exists(Opt::ForceNativeBridge);
diff --git a/runtime/runtime.h b/runtime/runtime.h
index 6d2887c..022a1be 100644
--- a/runtime/runtime.h
+++ b/runtime/runtime.h
@@ -520,6 +520,14 @@
bool IsVerificationEnabled() const;
bool IsVerificationSoftFail() const;
+ void DisableHiddenApiChecks() {
+ do_hidden_api_checks_ = false;
+ }
+
+ bool AreHiddenApiChecksEnabled() const {
+ return do_hidden_api_checks_;
+ }
+
bool IsDexFileFallbackEnabled() const {
return allow_dex_file_fallback_;
}
@@ -957,6 +965,9 @@
// Whether the application should run in safe mode, that is, interpreter only.
bool safe_mode_;
+ // Whether access checks on hidden API should be performed.
+ bool do_hidden_api_checks_;
+
// Whether threads should dump their native stack on SIGQUIT.
bool dump_native_stack_on_sig_quit_;
diff --git a/runtime/runtime_options.def b/runtime/runtime_options.def
index 3996989..6e1a68b 100644
--- a/runtime/runtime_options.def
+++ b/runtime/runtime_options.def
@@ -119,6 +119,7 @@
RUNTIME_OPTIONS_KEY (verifier::VerifyMode, \
Verify, verifier::VerifyMode::kEnable)
RUNTIME_OPTIONS_KEY (int, TargetSdkVersion, Runtime::kUnsetSdkVersion)
+RUNTIME_OPTIONS_KEY (Unit, NoHiddenApiChecks)
RUNTIME_OPTIONS_KEY (std::string, NativeBridge)
RUNTIME_OPTIONS_KEY (unsigned int, ZygoteMaxFailedBoots, 10)
RUNTIME_OPTIONS_KEY (Unit, NoDexFileFallback)
diff --git a/runtime/ti/agent.cc b/runtime/ti/agent.cc
index 62bdde6..15c514e 100644
--- a/runtime/ti/agent.cc
+++ b/runtime/ti/agent.cc
@@ -117,15 +117,18 @@
: JavaVMExt::GetLibrarySearchPath(env, class_loader));
bool needs_native_bridge = false;
+ std::string nativeloader_error_msg;
void* dlopen_handle = android::OpenNativeLibrary(env,
Runtime::Current()->GetTargetSdkVersion(),
name_.c_str(),
class_loader,
library_path.get(),
&needs_native_bridge,
- error_msg);
+ &nativeloader_error_msg);
if (dlopen_handle == nullptr) {
- *error_msg = StringPrintf("Unable to dlopen %s: %s", name_.c_str(), dlerror());
+ *error_msg = StringPrintf("Unable to dlopen %s: %s",
+ name_.c_str(),
+ nativeloader_error_msg.c_str());
*error = kLoadingError;
return nullptr;
}
diff --git a/test/071-dexfile-get-static-size/build b/test/071-dexfile-get-static-size/build
index 0bba66d..412ee6d 100755
--- a/test/071-dexfile-get-static-size/build
+++ b/test/071-dexfile-get-static-size/build
@@ -16,15 +16,13 @@
./default-build "$@"
-# Create and add as resources to the test jar file:
+# Bundle with the test the following resources:
# 1. test1.dex
# 2. test2.dex
# 3. test-jar.jar, containing test1.dex as classes.dex
# 4. multi-jar.jar, containing test1.dex as classes.dex and test2.dex as classes2.dex
mkdir test-jar
-cp test1.dex test-jar/classes.dex
-cp test2.dex test-jar/classes2.dex
-zip -j test-jar.jar test-jar/classes.dex
-zip -j multi-jar.jar test-jar/classes.dex test-jar/classes2.dex
-jar uf ${TEST_NAME}.jar test1.dex test2.dex test-jar.jar multi-jar.jar
-
+cp res/test1.dex test-jar/classes.dex
+cp res/test2.dex test-jar/classes2.dex
+zip -j res/test-jar.jar test-jar/classes.dex
+zip -j res/multi-jar.jar test-jar/classes.dex test-jar/classes2.dex
diff --git a/test/071-dexfile-get-static-size/test1.dex b/test/071-dexfile-get-static-size/res/test1.dex
similarity index 100%
rename from test/071-dexfile-get-static-size/test1.dex
rename to test/071-dexfile-get-static-size/res/test1.dex
Binary files differ
diff --git a/test/071-dexfile-get-static-size/test2.dex b/test/071-dexfile-get-static-size/res/test2.dex
similarity index 100%
rename from test/071-dexfile-get-static-size/test2.dex
rename to test/071-dexfile-get-static-size/res/test2.dex
Binary files differ
diff --git a/test/071-dexfile-get-static-size/src/Main.java b/test/071-dexfile-get-static-size/src/Main.java
index 4bf4538..8dbbba5 100644
--- a/test/071-dexfile-get-static-size/src/Main.java
+++ b/test/071-dexfile-get-static-size/src/Main.java
@@ -14,26 +14,9 @@
* limitations under the License.
*/
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.io.FileOutputStream;
-import java.lang.reflect.Constructor;
import java.lang.reflect.Method;
public class Main {
- private static void extractResource(String resource, String filename) throws Exception {
- ClassLoader loader = Main.class.getClassLoader();
- InputStream is = loader.getResourceAsStream(resource);
- OutputStream os = new FileOutputStream(filename);
- int read;
- byte[] buf = new byte[4096];
- while ((read = is.read(buf)) >= 0) {
- os.write(buf, 0, read);
- }
- is.close();
- os.close();
- }
-
private static long getDexFileSize(String filename) throws Exception {
ClassLoader loader = Main.class.getClassLoader();
Class<?> DexFile = loader.loadClass("dalvik.system.DexFile");
@@ -47,8 +30,7 @@
}
private static void test(String resource) throws Exception {
- String filename = System.getenv("DEX_LOCATION") + "/" + resource;
- extractResource(resource, filename);
+ String filename = System.getenv("DEX_LOCATION") + "/res/" + resource;
long size = getDexFileSize(filename);
System.out.println("Size for " + resource + ": " + size);
}
diff --git a/test/README.md b/test/README.md
index c68b40b..350350e 100644
--- a/test/README.md
+++ b/test/README.md
@@ -9,6 +9,8 @@
this can be used to exercise "API mismatch" situations by replacing
class files created in the first pass. The "src-ex" directory is
built separately, and is intended for exercising class loaders.
+Resources can be stored in the "res" directory, which is distributed
+together with the executable files.
The gtests are in named directories and contain a .java source
file.
diff --git a/test/etc/run-test-jar b/test/etc/run-test-jar
index 631b14a..5e40b86 100755
--- a/test/etc/run-test-jar
+++ b/test/etc/run-test-jar
@@ -806,6 +806,10 @@
if [ "$PROFILE" = "y" ] || [ "$RANDOM_PROFILE" = "y" ]; then
adb push profile $DEX_LOCATION
fi
+ # Copy resource folder
+ if [ -d res ]; then
+ adb push res $DEX_LOCATION
+ fi
else
adb shell rm -r $DEX_LOCATION >/dev/null 2>&1
adb shell mkdir -p $DEX_LOCATION >/dev/null 2>&1
@@ -814,7 +818,10 @@
if [ "$PROFILE" = "y" ] || [ "$RANDOM_PROFILE" = "y" ]; then
adb push profile $DEX_LOCATION >/dev/null 2>&1
fi
-
+ # Copy resource folder
+ if [ -d res ]; then
+ adb push res $DEX_LOCATION >/dev/null 2>&1
+ fi
fi
LD_LIBRARY_PATH=/data/$TEST_DIRECTORY/art/$ISA