42164cc140
This reverts commit aa9201b76b.
Reason for revert: blocks G3 roll (b/192627187)
Original change's description:
> [vm] Prefix HOST_OS_* and TARGET_OS_* with DART_
>
> TargetConditionals.h for XCode 13 defines several
> TARGET_OS_* preprocessor symbols that confuse the
> Dart build. There is probably a more targeted fix
> for this, but renaming the symbols that Dart uses
> will also prevent this problem if more symbols
> are added to the platform headers in the future.
>
> See: https://github.com/dart-lang/sdk/issues/46499
>
> TEST=It builds.
> Change-Id: I3b33a03b4a9a14b76d55fe12f8cdefec4b3c3664
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/205633
> Commit-Queue: Zach Anderson <zra@google.com>
> Reviewed-by: Siva Annamalai <asiva@google.com>
TBR=rmacnak@google.com,zra@google.com,asiva@google.com
Change-Id: Ib06ca418c7e9d3b4df62c72c033cd39f462f7667
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/205790
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Slava Egorov <vegorov@google.com>
70 lines
2.1 KiB
C++
70 lines
2.1 KiB
C++
// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
|
|
// for details. All rights reserved. Use of this source code is governed by a
|
|
// BSD-style license that can be found in the LICENSE file.
|
|
|
|
#include "platform/assert.h"
|
|
|
|
#include "include/dart_api.h"
|
|
#include "platform/globals.h"
|
|
#include "platform/syslog.h"
|
|
|
|
#if defined(HOST_OS_ANDROID)
|
|
extern "C" __attribute__((weak)) void android_set_abort_message(const char*);
|
|
#endif // defined(HOST_OS_ANDROID)
|
|
|
|
namespace dart {
|
|
|
|
bool Expect::failed_ = false;
|
|
|
|
void DynamicAssertionHelper::Print(const char* format,
|
|
va_list arguments,
|
|
bool will_abort /* = false */) {
|
|
// Take only the last 1KB of the file name if it is longer.
|
|
const intptr_t file_len = strlen(file_);
|
|
const intptr_t file_offset = (file_len > (1 * KB)) ? file_len - (1 * KB) : 0;
|
|
const char* file = file_ + file_offset;
|
|
|
|
// Print the file and line number into the buffer.
|
|
char buffer[4 * KB];
|
|
MSAN_UNPOISON(buffer, sizeof(buffer));
|
|
intptr_t file_and_line_length =
|
|
snprintf(buffer, sizeof(buffer), "%s: %d: error: ", file, line_);
|
|
|
|
// Print the error message into the buffer.
|
|
vsnprintf(buffer + file_and_line_length,
|
|
sizeof(buffer) - file_and_line_length, format, arguments);
|
|
|
|
// Print the buffer on stderr and/or syslog.
|
|
Syslog::PrintErr("%s\n", buffer);
|
|
#if defined(HOST_OS_ANDROID)
|
|
if (will_abort && (&android_set_abort_message != nullptr)) {
|
|
android_set_abort_message(buffer);
|
|
}
|
|
#endif // defined(HOST_OS_ANDROID)
|
|
}
|
|
|
|
void Assert::Fail(const char* format, ...) {
|
|
va_list arguments;
|
|
va_start(arguments, format);
|
|
Print(format, arguments, /*will_abort=*/true);
|
|
va_end(arguments);
|
|
|
|
// Abort right away.
|
|
Dart_DumpNativeStackTrace(NULL);
|
|
Dart_PrepareToAbort();
|
|
abort();
|
|
}
|
|
|
|
void Expect::Fail(const char* format, ...) {
|
|
va_list arguments;
|
|
va_start(arguments, format);
|
|
Print(format, arguments);
|
|
va_end(arguments);
|
|
|
|
// Wait until the program is exiting before producing a non-zero exit
|
|
// code through abort.
|
|
failed_ = true;
|
|
}
|
|
|
|
} // namespace dart
|