Skip to content

Commit 7283827

Browse files
sjindel-googlecommit-bot@chromium.org
authored andcommitted
[vm/test] Show crash dump in builder logs for Android tests.
Previously we would not have any VM logs because they are were sent to the Android system logs, which are not captured by the bots. Also added a flag --android-log-to-stderr, which is useful for local testing and debugging. Change-Id: I1968b4c230d70b5546d2dd48e40fe3cfe5196def Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/112250 Commit-Queue: Samir Jindel <sjindel@google.com> Reviewed-by: Martin Kustermann <kustermann@google.com>
1 parent fa45f91 commit 7283827

File tree

2 files changed

+20
-4
lines changed

2 files changed

+20
-4
lines changed

pkg/test_runner/lib/src/process_queue.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -682,6 +682,7 @@ class CommandExecutorImpl implements CommandExecutor {
682682
[
683683
'export LD_LIBRARY_PATH=\$LD_LIBRARY_PATH:$deviceTestDir;'
684684
'$devicedir/dart_precompiled_runtime',
685+
'--android-log-to-stderr'
685686
]..addAll(arguments),
686687
timeout: timeoutDuration));
687688

@@ -741,6 +742,7 @@ class CommandExecutorImpl implements CommandExecutor {
741742
[
742743
'export LD_LIBRARY_PATH=\$LD_LIBRARY_PATH:$deviceTestDir;'
743744
'$devicedir/dart',
745+
'--android-log-to-stderr'
744746
]..addAll(arguments),
745747
timeout: timeoutDuration));
746748

runtime/vm/os_android.cc

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,12 @@
2525

2626
namespace dart {
2727

28+
DEFINE_FLAG(bool,
29+
android_log_to_stderr,
30+
false,
31+
"Send Dart VM logs to stdout and stderr instead of the Android "
32+
"system logs.");
33+
2834
// Android CodeObservers.
2935

3036
#ifndef PRODUCT
@@ -255,8 +261,12 @@ DART_NOINLINE uintptr_t OS::GetProgramCounter() {
255261
void OS::Print(const char* format, ...) {
256262
va_list args;
257263
va_start(args, format);
258-
// Forward to the Android log for remote access.
259-
__android_log_vprint(ANDROID_LOG_INFO, "DartVM", format, args);
264+
if (FLAG_android_log_to_stderr) {
265+
vfprintf(stderr, format, args);
266+
} else {
267+
// Forward to the Android log for remote access.
268+
__android_log_vprint(ANDROID_LOG_INFO, "DartVM", format, args);
269+
}
260270
va_end(args);
261271
}
262272

@@ -332,8 +342,12 @@ void OS::RegisterCodeObservers() {
332342
void OS::PrintErr(const char* format, ...) {
333343
va_list args;
334344
va_start(args, format);
335-
// Forward to the Android log for remote access.
336-
__android_log_vprint(ANDROID_LOG_ERROR, "DartVM", format, args);
345+
if (FLAG_android_log_to_stderr) {
346+
vfprintf(stderr, format, args);
347+
} else {
348+
// Forward to the Android log for remote access.
349+
__android_log_vprint(ANDROID_LOG_ERROR, "DartVM", format, args);
350+
}
337351
va_end(args);
338352
}
339353

0 commit comments

Comments
 (0)