ART: Refactor abort code
Remove Runtime::Aborter and let Runtime::Abort set the abort message
on target.
This works around a missing tail-call optimization that leads to a
superfluous frame on the call-stack when aborting.
Partially reverts commit 3fec9ac0d5af1358d216eb2fdc2000ec0205f3f0.
(cherry picked from commit 51d80ccca5eb2ea0eef0de836dcc03e0545f63db)
Bug: 62810360
Test: m test-art-host
Test: Manual inspection of abort dump
Change-Id: Ie4efc8bbdc8b665b23081b37a11921fe26b182b4
diff --git a/cmdline/cmdline.h b/cmdline/cmdline.h
index 98010d7..18ca944 100644
--- a/cmdline/cmdline.h
+++ b/cmdline/cmdline.h
@@ -295,7 +295,7 @@
template <typename Args = CmdlineArgs>
struct CmdlineMain {
int Main(int argc, char** argv) {
- InitLogging(argv, Runtime::Aborter);
+ InitLogging(argv, Runtime::Abort);
std::unique_ptr<Args> args = std::unique_ptr<Args>(CreateArguments());
args_ = args.get();
diff --git a/cmdline/cmdline_parser_test.cc b/cmdline/cmdline_parser_test.cc
index 9f12f64..08d0415 100644
--- a/cmdline/cmdline_parser_test.cc
+++ b/cmdline/cmdline_parser_test.cc
@@ -123,7 +123,7 @@
using RuntimeParser = ParsedOptions::RuntimeParser;
static void SetUpTestCase() {
- art::InitLogging(nullptr, art::Runtime::Aborter); // argv = null
+ art::InitLogging(nullptr, art::Runtime::Abort); // argv = null
}
virtual void SetUp() {
diff --git a/dex2oat/dex2oat.cc b/dex2oat/dex2oat.cc
index 5fd7abc..35f221f 100644
--- a/dex2oat/dex2oat.cc
+++ b/dex2oat/dex2oat.cc
@@ -1122,7 +1122,7 @@
original_argc = argc;
original_argv = argv;
- InitLogging(argv, Runtime::Aborter);
+ InitLogging(argv, Runtime::Abort);
// Skip over argv[0].
argv++;
diff --git a/dexdump/dexdump_main.cc b/dexdump/dexdump_main.cc
index 74cae3c..606d4f8 100644
--- a/dexdump/dexdump_main.cc
+++ b/dexdump/dexdump_main.cc
@@ -60,7 +60,7 @@
*/
int dexdumpDriver(int argc, char** argv) {
// Art specific set up.
- InitLogging(argv, Runtime::Aborter);
+ InitLogging(argv, Runtime::Abort);
MemMap::Init();
// Reset options.
diff --git a/dexlayout/dexdiag.cc b/dexlayout/dexdiag.cc
index 78860e3..c14cd5f 100644
--- a/dexlayout/dexdiag.cc
+++ b/dexlayout/dexdiag.cc
@@ -465,7 +465,7 @@
}
// Art specific set up.
- InitLogging(argv, Runtime::Aborter);
+ InitLogging(argv, Runtime::Abort);
MemMap::Init();
#ifdef ART_TARGET_ANDROID
diff --git a/dexlayout/dexlayout_main.cc b/dexlayout/dexlayout_main.cc
index 3c627ea..33d62de 100644
--- a/dexlayout/dexlayout_main.cc
+++ b/dexlayout/dexlayout_main.cc
@@ -67,7 +67,7 @@
*/
int DexlayoutDriver(int argc, char** argv) {
// Art specific set up.
- InitLogging(argv, Runtime::Aborter);
+ InitLogging(argv, Runtime::Abort);
MemMap::Init();
Options options;
diff --git a/dexlist/dexlist.cc b/dexlist/dexlist.cc
index efe1aad..f1bb088 100644
--- a/dexlist/dexlist.cc
+++ b/dexlist/dexlist.cc
@@ -213,7 +213,7 @@
*/
int dexlistDriver(int argc, char** argv) {
// Art specific set up.
- InitLogging(argv, Runtime::Aborter);
+ InitLogging(argv, Runtime::Abort);
MemMap::Init();
// Reset options.
diff --git a/dexoptanalyzer/dexoptanalyzer.cc b/dexoptanalyzer/dexoptanalyzer.cc
index 9a2eb7f..e2c159a 100644
--- a/dexoptanalyzer/dexoptanalyzer.cc
+++ b/dexoptanalyzer/dexoptanalyzer.cc
@@ -127,7 +127,7 @@
original_argc = argc;
original_argv = argv;
- InitLogging(argv, Runtime::Aborter);
+ InitLogging(argv, Runtime::Abort);
// Skip over the command name.
argv++;
argc--;
diff --git a/patchoat/patchoat.cc b/patchoat/patchoat.cc
index e750ede..06de285 100644
--- a/patchoat/patchoat.cc
+++ b/patchoat/patchoat.cc
@@ -780,7 +780,7 @@
}
static int patchoat(int argc, char **argv) {
- InitLogging(argv, Runtime::Aborter);
+ InitLogging(argv, Runtime::Abort);
MemMap::Init();
const bool debug = kIsDebugBuild;
orig_argc = argc;
diff --git a/profman/profman.cc b/profman/profman.cc
index adef0d0..c4a6629 100644
--- a/profman/profman.cc
+++ b/profman/profman.cc
@@ -178,7 +178,7 @@
original_argc = argc;
original_argv = argv;
- InitLogging(argv, Runtime::Aborter);
+ InitLogging(argv, Runtime::Abort);
// Skip over the command name.
argv++;
diff --git a/runtime/common_runtime_test.cc b/runtime/common_runtime_test.cc
index 01c6641..fee5e2b 100644
--- a/runtime/common_runtime_test.cc
+++ b/runtime/common_runtime_test.cc
@@ -59,7 +59,7 @@
// everything else. In case you want to see all messages, comment out the line.
setenv("ANDROID_LOG_TAGS", "*:e", 1);
- art::InitLogging(argv, art::Runtime::Aborter);
+ art::InitLogging(argv, art::Runtime::Abort);
LOG(INFO) << "Running main() from common_runtime_test.cc...";
testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();
diff --git a/runtime/runtime.cc b/runtime/runtime.cc
index 74e291e..1cdf142 100644
--- a/runtime/runtime.cc
+++ b/runtime/runtime.cc
@@ -480,6 +480,10 @@
void Runtime::Abort(const char* msg) {
gAborting++; // set before taking any locks
+#ifdef ART_TARGET_ANDROID
+ android_set_abort_message(msg);
+#endif
+
// Ensure that we don't have multiple threads trying to abort at once,
// which would result in significantly worse diagnostics.
MutexLock mu(Thread::Current(), *Locks::abort_lock_);
@@ -565,7 +569,7 @@
bool Runtime::ParseOptions(const RuntimeOptions& raw_options,
bool ignore_unrecognized,
RuntimeArgumentMap* runtime_options) {
- InitLogging(/* argv */ nullptr, Aborter); // Calls Locks::Init() as a side effect.
+ InitLogging(/* argv */ nullptr, Abort); // Calls Locks::Init() as a side effect.
bool parsed = ParsedOptions::Parse(raw_options, ignore_unrecognized, runtime_options);
if (!parsed) {
LOG(ERROR) << "Failed to parse options";
@@ -2354,14 +2358,6 @@
}
}
-NO_RETURN
-void Runtime::Aborter(const char* abort_message) {
-#ifdef ART_TARGET_ANDROID
- android_set_abort_message(abort_message);
-#endif
- Runtime::Abort(abort_message);
-}
-
RuntimeCallbacks* Runtime::GetRuntimeCallbacks() {
return callbacks_.get();
}
diff --git a/runtime/runtime.h b/runtime/runtime.h
index 992c5c8..d2410aa 100644
--- a/runtime/runtime.h
+++ b/runtime/runtime.h
@@ -657,9 +657,6 @@
return cha_;
}
- NO_RETURN
- static void Aborter(const char* abort_message);
-
void AttachAgent(const std::string& agent_arg);
const std::list<ti::Agent>& GetAgents() const {