diff options
| author | 2017-06-23 15:03:31 +0000 | |
|---|---|---|
| committer | 2017-06-23 15:03:33 +0000 | |
| commit | 9c9b9364ad24b4e20b2d88e50f4e013b1f3fa093 (patch) | |
| tree | 11a60dbff92e963f67824efbb92ce064611a98ec | |
| parent | f45cf4bfb341051d9d0959f2e2619eaec71fa732 (diff) | |
| parent | 247fc334ca91c22b19ac57b9c8bbbd15a1735aa1 (diff) | |
Merge changes I8d333ea5,Ie4efc8bb
* changes:
ART: Make gAborting an atomic
ART: Refactor abort code
| -rw-r--r-- | cmdline/cmdline.h | 2 | ||||
| -rw-r--r-- | cmdline/cmdline_parser_test.cc | 2 | ||||
| -rw-r--r-- | dex2oat/dex2oat.cc | 2 | ||||
| -rw-r--r-- | dexdump/dexdump_main.cc | 2 | ||||
| -rw-r--r-- | dexlayout/dexdiag.cc | 2 | ||||
| -rw-r--r-- | dexlayout/dexlayout_main.cc | 2 | ||||
| -rw-r--r-- | dexlist/dexlist.cc | 2 | ||||
| -rw-r--r-- | dexoptanalyzer/dexoptanalyzer.cc | 2 | ||||
| -rw-r--r-- | patchoat/patchoat.cc | 2 | ||||
| -rw-r--r-- | profman/profman.cc | 2 | ||||
| -rw-r--r-- | runtime/base/logging.cc | 2 | ||||
| -rw-r--r-- | runtime/base/logging.h | 2 | ||||
| -rw-r--r-- | runtime/common_runtime_test.cc | 2 | ||||
| -rw-r--r-- | runtime/runtime.cc | 21 | ||||
| -rw-r--r-- | runtime/runtime.h | 3 |
15 files changed, 24 insertions, 26 deletions
diff --git a/cmdline/cmdline.h b/cmdline/cmdline.h index 98010d7089..18ca944383 100644 --- a/cmdline/cmdline.h +++ b/cmdline/cmdline.h @@ -295,7 +295,7 @@ struct CmdlineArgs { 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 b224ec72de..d957869a76 100644 --- a/cmdline/cmdline_parser_test.cc +++ b/cmdline/cmdline_parser_test.cc @@ -123,7 +123,7 @@ class CmdlineParserTest : public ::testing::Test { 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 c0ab21d4a0..92d60b252b 100644 --- a/dex2oat/dex2oat.cc +++ b/dex2oat/dex2oat.cc @@ -1133,7 +1133,7 @@ class Dex2Oat FINAL { 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 74cae3c961..606d4f81b1 100644 --- a/dexdump/dexdump_main.cc +++ b/dexdump/dexdump_main.cc @@ -60,7 +60,7 @@ static void usage(void) { */ 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 78860e3f96..c14cd5f807 100644 --- a/dexlayout/dexdiag.cc +++ b/dexlayout/dexdiag.cc @@ -465,7 +465,7 @@ static int DexDiagMain(int argc, char* argv[]) { } // 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 3c627ea6f0..33d62decca 100644 --- a/dexlayout/dexlayout_main.cc +++ b/dexlayout/dexlayout_main.cc @@ -67,7 +67,7 @@ static void Usage(void) { */ 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 29707af704..fa232a7634 100644 --- a/dexlist/dexlist.cc +++ b/dexlist/dexlist.cc @@ -211,7 +211,7 @@ static void usage(void) { */ 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 9a2eb7f8dd..e2c159aa5c 100644 --- a/dexoptanalyzer/dexoptanalyzer.cc +++ b/dexoptanalyzer/dexoptanalyzer.cc @@ -127,7 +127,7 @@ class DexoptAnalyzer FINAL { 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 848eb8d329..149960ee2c 100644 --- a/patchoat/patchoat.cc +++ b/patchoat/patchoat.cc @@ -783,7 +783,7 @@ static int patchoat_image(TimingLogger& timings, } 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 14b026277f..94e81c76c1 100644 --- a/profman/profman.cc +++ b/profman/profman.cc @@ -189,7 +189,7 @@ class ProfMan FINAL { original_argc = argc; original_argv = argv; - InitLogging(argv, Runtime::Aborter); + InitLogging(argv, Runtime::Abort); // Skip over the command name. argv++; diff --git a/runtime/base/logging.cc b/runtime/base/logging.cc index 2be9067e64..4776357fdf 100644 --- a/runtime/base/logging.cc +++ b/runtime/base/logging.cc @@ -85,7 +85,7 @@ void SetRuntimeDebugFlagsEnabled(bool enabled) { LogVerbosity gLogVerbosity; -unsigned int gAborting = 0; +std::atomic<unsigned int> gAborting(0); static std::unique_ptr<std::string> gCmdLine; static std::unique_ptr<std::string> gProgramInvocationName; diff --git a/runtime/base/logging.h b/runtime/base/logging.h index d8954e59d0..15f935395e 100644 --- a/runtime/base/logging.h +++ b/runtime/base/logging.h @@ -102,7 +102,7 @@ void SetRuntimeDebugFlagsEnabled(bool enabled); // 0 if not abort, non-zero if an abort is in progress. Used on fatal exit to prevents recursive // aborts. Global declaration allows us to disable some error checking to ensure fatal shutdown // makes forward progress. -extern unsigned int gAborting; +extern std::atomic<unsigned int> gAborting; // Configure logging based on ANDROID_LOG_TAGS environment variable. // We need to parse a string that looks like diff --git a/runtime/common_runtime_test.cc b/runtime/common_runtime_test.cc index 5beac1aa37..6441a44e6e 100644 --- a/runtime/common_runtime_test.cc +++ b/runtime/common_runtime_test.cc @@ -59,7 +59,7 @@ int main(int argc, char **argv) { // 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 c11e4bd448..46b4392ef4 100644 --- a/runtime/runtime.cc +++ b/runtime/runtime.cc @@ -483,7 +483,16 @@ struct AbortState { }; void Runtime::Abort(const char* msg) { - gAborting++; // set before taking any locks + auto old_value = gAborting.fetch_add(1); // set before taking any locks + +#ifdef ART_TARGET_ANDROID + if (old_value == 0) { + // Only set the first abort message. + android_set_abort_message(msg); + } +#else + UNUSED(old_value); +#endif // Ensure that we don't have multiple threads trying to abort at once, // which would result in significantly worse diagnostics. @@ -570,7 +579,7 @@ void Runtime::SweepSystemWeaks(IsMarkedVisitor* visitor) { 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 +2367,6 @@ void Runtime::RemoveSystemWeakHolder(gc::AbstractSystemWeakHolder* holder) { } } -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 2505d8706e..af9d215454 100644 --- a/runtime/runtime.h +++ b/runtime/runtime.h @@ -649,9 +649,6 @@ class Runtime { 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 { |