Add dex2oat -g to control whether the compiled code has debugger support.
Change-Id: I69c83f707d874fee0464929769b1f1f28e9d97ee
diff --git a/src/common_test.h b/src/common_test.h
index f7b9fec..f487f05 100644
--- a/src/common_test.h
+++ b/src/common_test.h
@@ -339,7 +339,7 @@
runtime_->CreateCalleeSaveMethod(instruction_set, type), type);
}
}
- compiler_.reset(new Compiler(instruction_set, false, 2, NULL));
+ compiler_.reset(new Compiler(instruction_set, false, 2, false, NULL));
Heap::VerifyHeap(); // Check for heap corruption before the test
}
diff --git a/src/compiler.cc b/src/compiler.cc
index 37a7414..75f7484 100644
--- a/src/compiler.cc
+++ b/src/compiler.cc
@@ -202,7 +202,7 @@
};
Compiler::Compiler(InstructionSet instruction_set, bool image, size_t thread_count,
- const std::set<std::string>* image_classes)
+ bool support_debugging, const std::set<std::string>* image_classes)
: instruction_set_(instruction_set),
jni_compiler_(instruction_set),
compiled_classes_lock_("compiled classes lock"),
@@ -210,6 +210,7 @@
compiled_invoke_stubs_lock_("compiled invoke stubs lock"),
image_(image),
thread_count_(thread_count),
+ support_debugging_(support_debugging),
stats_(new AOTCompilationStats),
image_classes_(image_classes)
#if defined(ART_USE_LLVM_COMPILER)
diff --git a/src/compiler.h b/src/compiler.h
index ce2d3c2..b889a32 100644
--- a/src/compiler.h
+++ b/src/compiler.h
@@ -51,7 +51,7 @@
// can assume will be in the image, with NULL implying all available
// classes.
explicit Compiler(InstructionSet instruction_set, bool image, size_t thread_count,
- const std::set<std::string>* image_classes);
+ bool support_debugging, const std::set<std::string>* image_classes);
~Compiler();
@@ -61,6 +61,10 @@
// Compile a single Method
void CompileOne(const Method* method);
+ bool IsDebuggingSupported() {
+ return support_debugging_;
+ }
+
InstructionSet GetInstructionSet() const {
return instruction_set_;
}
@@ -187,6 +191,7 @@
bool image_;
size_t thread_count_;
+ bool support_debugging_;
uint64_t start_ns_;
UniquePtr<AOTCompilationStats> stats_;
diff --git a/src/compiler/Compiler.h b/src/compiler/Compiler.h
index a7dc798..d07fe18 100644
--- a/src/compiler/Compiler.h
+++ b/src/compiler/Compiler.h
@@ -56,7 +56,6 @@
kPromoteRegs,
kTrackLiveTemps,
kSkipLargeMethodOptimization,
- kGenCodeForDebugger,
};
/* Type of allocation for memory tuning */
diff --git a/src/compiler/Frontend.cc b/src/compiler/Frontend.cc
index 3b03a35..701e245 100644
--- a/src/compiler/Frontend.cc
+++ b/src/compiler/Frontend.cc
@@ -33,7 +33,6 @@
//(1 << kPromoteRegs) |
//(1 << kTrackLiveTemps) |
//(1 << kSkipLargeMethodOptimization) |
- //(1 << kGenCodeForDebugger) |
0;
uint32_t compilerDebugFlags = 0 | // Enable debug/testing modes
@@ -787,7 +786,7 @@
}
/* Are we generating code for the debugger? */
- if (cUnit->disableOpt & (1 << kGenCodeForDebugger)) {
+ if (compiler.IsDebuggingSupported()) {
cUnit->genDebugger = true;
// Yes, disable most optimizations
cUnit->disableOpt |= (
diff --git a/src/dex2oat.cc b/src/dex2oat.cc
index a42f946..7f4a132 100644
--- a/src/dex2oat.cc
+++ b/src/dex2oat.cc
@@ -108,12 +108,12 @@
class Dex2Oat {
public:
- static Dex2Oat* Create(Runtime::Options& options, size_t thread_count) {
+ static Dex2Oat* Create(Runtime::Options& options, size_t thread_count, bool support_debugging) {
UniquePtr<Runtime> runtime(CreateRuntime(options));
if (runtime.get() == NULL) {
return NULL;
}
- return new Dex2Oat(runtime.release(), thread_count);
+ return new Dex2Oat(runtime.release(), thread_count, support_debugging);
}
~Dex2Oat() {
@@ -206,7 +206,7 @@
class_loader.get()->reset(PathClassLoader::AllocCompileTime(class_path_files));
}
- Compiler compiler(instruction_set_, image, thread_count_, image_classes);
+ Compiler compiler(instruction_set_, image, thread_count_, support_debugging_, image_classes);
compiler.CompileAll(class_loader->get(), dex_files);
if (!OatWriter::Create(oat_file, class_loader->get(), dex_files, compiler)) {
@@ -247,8 +247,11 @@
private:
- explicit Dex2Oat(Runtime* runtime, size_t thread_count)
- : runtime_(runtime), thread_count_(thread_count), start_ns_(NanoTime()) {
+ explicit Dex2Oat(Runtime* runtime, size_t thread_count, bool support_debugging)
+ : runtime_(runtime),
+ thread_count_(thread_count),
+ support_debugging_(support_debugging),
+ start_ns_(NanoTime()) {
}
static Runtime* CreateRuntime(Runtime::Options& options) {
@@ -373,6 +376,7 @@
Runtime* runtime_;
size_t thread_count_;
+ bool support_debugging_;
uint64_t start_ns_;
DISALLOW_IMPLICIT_CONSTRUCTORS(Dex2Oat);
@@ -426,6 +430,7 @@
std::string host_prefix;
std::vector<const char*> runtime_args;
int thread_count = 2;
+ bool support_debugging = false;
for (int i = 0; i < argc; i++) {
const StringPiece option(argv[i]);
@@ -451,6 +456,8 @@
if (!ParseInt(oat_fd_str, &oat_fd)) {
Usage("could not parse --oat-fd argument '%s' as an integer", oat_fd_str);
}
+ } else if (option.starts_with("-g")) {
+ support_debugging = true;
} else if (option.starts_with("-j")) {
const char* thread_count_str = option.substr(strlen("-j")).data();
if (!ParseInt(thread_count_str, &thread_count)) {
@@ -596,7 +603,7 @@
options.push_back(std::make_pair(runtime_args[i], reinterpret_cast<void*>(NULL)));
}
- UniquePtr<Dex2Oat> dex2oat(Dex2Oat::Create(options, thread_count));
+ UniquePtr<Dex2Oat> dex2oat(Dex2Oat::Create(options, thread_count, support_debugging));
// If --image-classes was specified, calculate the full list of classes to include in the image
UniquePtr<const std::set<std::string> > image_classes(NULL);
diff --git a/src/oat_test.cc b/src/oat_test.cc
index b27595e..0ca581a 100644
--- a/src/oat_test.cc
+++ b/src/oat_test.cc
@@ -29,7 +29,7 @@
SirtRef<ClassLoader> class_loader(NULL);
if (compile) {
- compiler_.reset(new Compiler(kThumb2, false, 2, NULL));
+ compiler_.reset(new Compiler(kThumb2, false, 2, false, NULL));
compiler_->CompileAll(class_loader.get(), class_linker->GetBootClassPath());
}