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.
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 b224ec7..d957869 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 c0ab21d..92d60b2 100644
--- a/dex2oat/dex2oat.cc
+++ b/dex2oat/dex2oat.cc
@@ -1133,7 +1133,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 29707af..fa232a7 100644
--- a/dexlist/dexlist.cc
+++ b/dexlist/dexlist.cc
@@ -211,7 +211,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 848eb8d..149960e 100644
--- a/patchoat/patchoat.cc
+++ b/patchoat/patchoat.cc
@@ -783,7 +783,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 f763b8e..e5e106b 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 5beac1a..6441a44 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 c11e4bd..72dee77 100644
--- a/runtime/runtime.cc
+++ b/runtime/runtime.cc
@@ -485,6 +485,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_);
@@ -570,7 +574,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";
@@ -2358,14 +2362,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 2505d87..af9d215 100644
--- a/runtime/runtime.h
+++ b/runtime/runtime.h
@@ -649,9 +649,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 {