mirror of
https://github.com/dart-lang/sdk
synced 2024-09-16 01:30:32 +00:00
24683da915
Examples of the new line added to non-symbolic stack traces: os: linux arch: x64 comp: yes sim: no (Running on linux-x64c) os: macos arch: arm64 comp: no sim: yes (Running on mac-simarm64) This CL also abstracts out the separate hardcoded strings across the codebase for host and target OS and architecture into definitions in platform/globals.h to ensure that they stay in sync across different uses. TEST=vm/dart{,_2}/use_dwarf_stack_traces_flag Issue: https://github.com/flutter/flutter/pull/101586 Change-Id: Ifdfea5138dd1003f561da0174e89aebc165bf9b0 Cq-Include-Trybots: luci.dart.try:vm-kernel-precomp-dwarf-linux-product-x64-try,vm-kernel-precomp-linux-release-simarm-try,vm-kernel-precomp-linux-release-simarm64-try,vm-kernel-precomp-linux-release-simarm_x64-try,vm-kernel-precomp-linux-release-x64-try,vm-kernel-precomp-mac-product-x64-try,vm-kernel-precomp-nnbd-linux-release-x64-try,vm-kernel-precomp-nnbd-linux-release-simarm_x64-try,vm-kernel-precomp-win-release-x64-try,vm-kernel-precomp-nnbd-mac-release-arm64-try,vm-kernel-precomp-mac-release-simarm64-try,vm-ffi-android-release-arm-try,vm-ffi-android-release-arm64c-try Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/253283 Reviewed-by: Ryan Macnak <rmacnak@google.com> Commit-Queue: Tess Strickland <sstrickl@google.com> Reviewed-by: Daco Harkes <dacoharkes@google.com>
131 lines
4.6 KiB
C++
131 lines
4.6 KiB
C++
// Copyright (c) 2011, 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.
|
|
|
|
#ifndef RUNTIME_VM_OS_H_
|
|
#define RUNTIME_VM_OS_H_
|
|
|
|
#include "vm/globals.h"
|
|
|
|
// Forward declarations.
|
|
struct tm;
|
|
|
|
namespace dart {
|
|
|
|
// Forward declarations.
|
|
class Zone;
|
|
|
|
// Interface to the underlying OS platform.
|
|
class OS {
|
|
public:
|
|
// Returns the name of the given OS. For example "linux".
|
|
static const char* Name() { return kHostOperatingSystemName; }
|
|
|
|
// Returns the current process id.
|
|
static intptr_t ProcessId();
|
|
|
|
// Returns a time-zone name for the given instant.
|
|
// The name is provided by the underlying platform.
|
|
// The returned string may be Zone allocated.
|
|
static const char* GetTimeZoneName(int64_t seconds_since_epoch);
|
|
|
|
// Returns the difference in seconds between local time and UTC for the given
|
|
// instant.
|
|
// For example 3600 for CET, and 7200 for CEST.
|
|
static int GetTimeZoneOffsetInSeconds(int64_t seconds_since_epoch);
|
|
|
|
// Returns the current time in milliseconds measured
|
|
// from midnight January 1, 1970 UTC.
|
|
static int64_t GetCurrentTimeMillis();
|
|
|
|
// Returns the current time in microseconds measured
|
|
// from midnight January 1, 1970 UTC.
|
|
static int64_t GetCurrentTimeMicros();
|
|
|
|
// Returns the current time used by the tracing infrastructure.
|
|
static int64_t GetCurrentMonotonicMicros();
|
|
|
|
// Returns the raw clock value from the monotonic clock.
|
|
static int64_t GetCurrentMonotonicTicks();
|
|
|
|
// Returns the frequency of the monotonic clock.
|
|
static int64_t GetCurrentMonotonicFrequency();
|
|
|
|
// Returns the value of current thread's CPU usage clock in microseconds.
|
|
// NOTE: This clock will return different values depending on the calling
|
|
// thread. It is only expected to increase in value as the thread uses
|
|
// CPU time.
|
|
// NOTE: This function will return -1 on OSs that are not supported.
|
|
static int64_t GetCurrentThreadCPUMicros();
|
|
|
|
// If the tracing/timeline configuration on takes timestamps as input, returns
|
|
// the same value as |GetCurrentMonotonicMicros|. Otherwise, returns -1.
|
|
static int64_t GetCurrentMonotonicMicrosForTimeline();
|
|
// If the tracing/timeline configuration on the current OS supports thread
|
|
// timestamps, returns the same value as |GetCurrentThreadCPUMicros|.
|
|
// Otherwise, returns -1.
|
|
static int64_t GetCurrentThreadCPUMicrosForTimeline();
|
|
|
|
// Returns the activation frame alignment constraint or one if
|
|
// the platform doesn't care. Guaranteed to be a power of two.
|
|
static intptr_t ActivationFrameAlignment();
|
|
|
|
// Returns number of available processor cores.
|
|
static int NumberOfAvailableProcessors();
|
|
|
|
// Sleep the currently executing thread for millis ms.
|
|
static void Sleep(int64_t millis);
|
|
|
|
// Sleep the currently executing thread for micros microseconds.
|
|
static void SleepMicros(int64_t micros);
|
|
|
|
// Debug break.
|
|
static void DebugBreak();
|
|
|
|
// Returns the current program counter.
|
|
static uintptr_t GetProgramCounter();
|
|
|
|
// Print formatted output to stdout/stderr for debugging.
|
|
// Tracing and debugging prints from the VM should strongly prefer to use
|
|
// PrintErr to avoid interfering with the application's output, which may
|
|
// be parsed by another program.
|
|
static void Print(const char* format, ...) PRINTF_ATTRIBUTE(1, 2);
|
|
static void PrintErr(const char* format, ...) PRINTF_ATTRIBUTE(1, 2);
|
|
static void VFPrint(FILE* stream, const char* format, va_list args);
|
|
|
|
// Allocate a string and print formatted output into the buffer.
|
|
// Uses the zone for allocation if one if provided, and otherwise uses
|
|
// malloc.
|
|
static char* SCreate(Zone* zone, const char* format, ...)
|
|
PRINTF_ATTRIBUTE(2, 3);
|
|
static char* VSCreate(Zone* zone, const char* format, va_list args);
|
|
|
|
// Converts a C string which represents a valid dart integer into a 64 bit
|
|
// value.
|
|
// Returns false if it is unable to convert the string to a 64 bit value,
|
|
// the failure could be because of underflow/overflow or invalid characters.
|
|
// On success the function returns true and 'value' contains the converted
|
|
// value.
|
|
static bool StringToInt64(const char* str, int64_t* value);
|
|
|
|
// Register code observers relevant to this OS.
|
|
static void RegisterCodeObservers();
|
|
|
|
// Initialize the OS class.
|
|
static void Init();
|
|
|
|
// Cleanup the OS class.
|
|
static void Cleanup();
|
|
|
|
// Only implemented on Windows, prevents cleanup code from running.
|
|
static void PrepareToAbort();
|
|
|
|
DART_NORETURN static void Abort();
|
|
|
|
DART_NORETURN static void Exit(int code);
|
|
};
|
|
|
|
} // namespace dart
|
|
|
|
#endif // RUNTIME_VM_OS_H_
|