template <typename Args = CmdlineArgs>
struct CmdlineMain {
int Main(int argc, char** argv) {
- InitLogging(argv);
+ InitLogging(argv, Runtime::Aborter);
std::unique_ptr<Args> args = std::unique_ptr<Args>(CreateArguments());
args_ = args.get();
using RuntimeParser = ParsedOptions::RuntimeParser;
static void SetUpTestCase() {
- art::InitLogging(nullptr); // argv = null
+ art::InitLogging(nullptr, art::Runtime::Aborter); // argv = null
}
virtual void SetUp() {
original_argc = argc;
original_argv = argv;
- InitLogging(argv);
+ InitLogging(argv, Runtime::Aborter);
// Skip over argv[0].
argv++;
#include <unistd.h>
#include "base/logging.h"
+#include "runtime.h"
#include "mem_map.h"
namespace art {
*/
int dexdumpDriver(int argc, char** argv) {
// Art specific set up.
- InitLogging(argv);
+ InitLogging(argv, Runtime::Aborter);
MemMap::Init();
// Reset options.
#include "base/logging.h"
#include "jit/offline_profiling_info.h"
+#include "runtime.h"
#include "mem_map.h"
namespace art {
*/
int DexlayoutDriver(int argc, char** argv) {
// Art specific set up.
- InitLogging(argv);
+ InitLogging(argv, Runtime::Aborter);
MemMap::Init();
// Reset options.
*/
int dexlistDriver(int argc, char** argv) {
// Art specific set up.
- InitLogging(argv);
+ InitLogging(argv, Runtime::Aborter);
MemMap::Init();
// Reset options.
}
static int patchoat(int argc, char **argv) {
- InitLogging(argv);
+ InitLogging(argv, Runtime::Aborter);
MemMap::Init();
const bool debug = kIsDebugBuild;
orig_argc = argc;
orig_argv = argv;
TimingLogger timings("patcher", false, false);
- InitLogging(argv);
-
// Skip over the command name.
argv++;
argc--;
#include "base/unix_file/fd_file.h"
#include "dex_file.h"
#include "jit/offline_profiling_info.h"
+#include "runtime.h"
#include "utils.h"
#include "zip_archive.h"
#include "profile_assistant.h"
original_argc = argc;
original_argv = argv;
- InitLogging(argv);
+ InitLogging(argv, Runtime::Aborter);
// Skip over the command name.
argv++;
#include <sstream>
#include "base/mutex.h"
-#include "runtime.h"
#include "thread-inl.h"
#include "utils.h"
// Headers for LogMessage::LogLine.
#ifdef ART_TARGET_ANDROID
#include <android/log.h>
-#include <android/set_abort_message.h>
#else
#include <sys/types.h>
#include <unistd.h>
: "art";
}
-NO_RETURN
-static void RuntimeAborter(const char* abort_message) {
-#ifdef __ANDROID__
- android_set_abort_message(abort_message);
-#else
- UNUSED(abort_message);
-#endif
- Runtime::Abort(abort_message);
-}
-
-void InitLogging(char* argv[]) {
+void InitLogging(char* argv[], AbortFunction& abort_function) {
if (gCmdLine.get() != nullptr) {
return;
}
#else
#define INIT_LOGGING_DEFAULT_LOGGER android::base::StderrLogger
#endif
- android::base::InitLogging(argv, INIT_LOGGING_DEFAULT_LOGGER, RuntimeAborter);
+ android::base::InitLogging(argv, INIT_LOGGING_DEFAULT_LOGGER,
+ std::move<AbortFunction>(abort_function));
#undef INIT_LOGGING_DEFAULT_LOGGER
}
using ::android::base::LogSeverity;
using ::android::base::ScopedLogSeverity;
+// Abort function.
+using AbortFunction = void(const char*);
+
// The members of this struct are the valid arguments to VLOG and VLOG_IS_ON in code,
// and the "-verbose:" command line argument.
struct LogVerbosity {
// The tag (or '*' for the global level) comes first, followed by a colon
// and a letter indicating the minimum priority level we're expected to log.
// This can be used to reveal or conceal logs with specific tags.
-extern void InitLogging(char* argv[]);
+extern void InitLogging(char* argv[], AbortFunction& default_aborter);
// Returns the command line used to invoke the current tool or null if InitLogging hasn't been
// performed.
// everything else. In case you want to see all messages, comment out the line.
setenv("ANDROID_LOG_TAGS", "*:e", 1);
- art::InitLogging(argv);
+ art::InitLogging(argv, art::Runtime::Aborter);
LOG(INFO) << "Running main() from common_runtime_test.cc...";
testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();
#include "verifier/method_verifier.h"
#include "well_known_classes.h"
+#ifdef ART_TARGET_ANDROID
+#include <android/set_abort_message.h>
+#endif
+
namespace art {
// If a signal isn't handled properly, enable a handler that attempts to dump the Java stack.
bool Runtime::ParseOptions(const RuntimeOptions& raw_options,
bool ignore_unrecognized,
RuntimeArgumentMap* runtime_options) {
- InitLogging(/* argv */ nullptr); // Calls Locks::Init() as a side effect.
+ InitLogging(/* argv */ nullptr, Aborter); // 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";
}
}
+NO_RETURN
+void Runtime::Aborter(const char* abort_message) {
+#ifdef __ANDROID__
+ android_set_abort_message(abort_message);
+#endif
+ Runtime::Abort(abort_message);
+}
+
} // namespace art
void AddSystemWeakHolder(gc::AbstractSystemWeakHolder* holder);
void RemoveSystemWeakHolder(gc::AbstractSystemWeakHolder* holder);
+ NO_RETURN
+ static void Aborter(const char* abort_message);
+
private:
static void InitPlatformSignalHandlers();