diff options
author | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2019-05-29 11:57:45 +0200 |
---|---|---|
committer | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2019-06-07 12:59:12 +0000 |
commit | 88465f872659641a3422fc6ce9d5beba0bd83251 (patch) | |
tree | 3d541b4155ad68386a046385226164c6369c833e | |
parent | 7762792a896e0cf8c92cff3078a02f80322b9703 (diff) | |
download | qtwebengine-chromium-88465f872659641a3422fc6ce9d5beba0bd83251.tar.gz |
Fix perfetto on MSVC
Change-Id: I9bad374117fceafdaa07326ad4468cda06184248
Reviewed-by: Michal Klocek <michal.klocek@qt.io>
4 files changed, 47 insertions, 10 deletions
diff --git a/chromium/third_party/perfetto/include/perfetto/base/logging.h b/chromium/third_party/perfetto/include/perfetto/base/logging.h index 35896ce75da..ede343d330d 100644 --- a/chromium/third_party/perfetto/include/perfetto/base/logging.h +++ b/chromium/third_party/perfetto/include/perfetto/base/logging.h @@ -84,7 +84,7 @@ enum LogLev { kLogDebug = 0, kLogInfo, kLogImportant, kLogError }; #define PERFETTO_XLOG_STDERR(level, fmt, ...) \ fprintf(stderr, "%-24.24s " fmt "\n", \ ::perfetto::base::Basename(__FILE__ "(" PERFETTO_LOG_LINE "):"), \ - ##__VA_ARGS__) + __VA_ARGS__) #else constexpr const char* kLogFmt[] = {"\x1b[2m", "\x1b[39m", "\x1b[32m\x1b[1m", "\x1b[31m"}; @@ -121,12 +121,39 @@ constexpr const char* kLogFmt[] = {"\x1b[2m", "\x1b[39m", "\x1b[32m\x1b[1m", #define PERFETTO_XLOG PERFETTO_XLOG_STDERR #endif -#define PERFETTO_IMMEDIATE_CRASH() \ - do { \ - __builtin_trap(); \ - __builtin_unreachable(); \ +#if PERFETTO_BUILDFLAG(PERFETTO_COMPILER_CLANG) || PERFETTO_BUILDFLAG(PERFETTO_COMPILER_GCC) +#define PERFETTO_TRAP_SEQUENCE() __builtin_trap() +#elif PERFETTO_BUILDFLAG(PERFETTO_COMPILER_MSVC) +#define PERFETTO_TRAP_SEQUENCE() __debugbreak() +#else +#error Port +#endif + +#if PERFETTO_BUILDFLAG(PERFETTO_COMPILER_CLANG) || PERFETTO_BUILDFLAG(PERFETTO_COMPILER_GCC) +#define PERFETTO_IMMEDIATE_CRASH() \ + do { \ + PERFETTO_TRAP_SEQUENCE(); \ + __builtin_unreachable(); \ + } while(false) +#else +// This is supporting non-chrome use of logging.h to build with MSVC. +#define PERFETTO_IMMEDIATE_CRASH() PERFETTO_TRAP_SEQUENCE() +#endif + +#if PERFETTO_BUILDFLAG(PERFETTO_COMPILER_MSVC) +#define CR_EXPAND_ARG(arg) arg +#define PERFETTO_LOG(fmt, ...) CR_EXPAND_ARG(PERFETTO_XLOG(kLogInfo, fmt, __VA_ARGS__)) +#define PERFETTO_ILOG(fmt, ...) CR_EXPAND_ARG(PERFETTO_XLOG(kLogImportant, fmt, __VA_ARGS__)) +#define PERFETTO_ELOG(fmt, ...) CR_EXPAND_ARG(PERFETTO_XLOG(kLogError, fmt, __VA_ARGS__)) +#define PERFETTO_FATAL(fmt, ...) \ + do { \ + CR_EXPAND_ARG(PERFETTO_ELOG(fmt, __VA_ARGS__)); \ + PERFETTO_IMMEDIATE_CRASH(); \ } while (0) +#define PERFETTO_PLOG(x, ...) \ + CR_EXPAND_ARG(PERFETTO_ELOG(x " (errno: %d, %s)", ##__VA_ARGS__, errno, strerror(errno))) +#else #define PERFETTO_LOG(fmt, ...) PERFETTO_XLOG(kLogInfo, fmt, ##__VA_ARGS__) #define PERFETTO_ILOG(fmt, ...) PERFETTO_XLOG(kLogImportant, fmt, ##__VA_ARGS__) #define PERFETTO_ELOG(fmt, ...) PERFETTO_XLOG(kLogError, fmt, ##__VA_ARGS__) @@ -138,7 +165,7 @@ constexpr const char* kLogFmt[] = {"\x1b[2m", "\x1b[39m", "\x1b[32m\x1b[1m", #define PERFETTO_PLOG(x, ...) \ PERFETTO_ELOG(x " (errno: %d, %s)", ##__VA_ARGS__, errno, strerror(errno)) - +#endif #if PERFETTO_DLOG_IS_ON() #define PERFETTO_DLOG(fmt, ...) PERFETTO_XLOG(kLogDebug, fmt, ##__VA_ARGS__) diff --git a/chromium/third_party/perfetto/include/perfetto/base/utils.h b/chromium/third_party/perfetto/include/perfetto/base/utils.h index aadbb702fdf..49ff3155d7d 100644 --- a/chromium/third_party/perfetto/include/perfetto/base/utils.h +++ b/chromium/third_party/perfetto/include/perfetto/base/utils.h @@ -27,16 +27,21 @@ #endif #define PERFETTO_EINTR(x) \ - ({ \ + ([&](){ \ decltype(x) eintr_wrapper_result; \ do { \ eintr_wrapper_result = (x); \ } while (eintr_wrapper_result == -1 && errno == EINTR); \ - eintr_wrapper_result; \ - }) + return eintr_wrapper_result; \ + }()) +#if PERFETTO_BUILDFLAG(PERFETTO_COMPILER_GCC) || PERFETTO_BUILDFLAG(PERFETTO_COMPILER_CLANG) #define PERFETTO_LIKELY(_x) __builtin_expect(!!(_x), 1) #define PERFETTO_UNLIKELY(_x) __builtin_expect(!!(_x), 0) +#else +#define PERFETTO_LIKELY(_x) (_x) +#define PERFETTO_UNLIKELY(_x) (_x) +#endif #if PERFETTO_BUILDFLAG(PERFETTO_OS_WIN) // TODO(brucedawson) - create a ::perfetto::base::IOSize to replace this. diff --git a/chromium/third_party/perfetto/src/protozero/protoc_plugin/protozero_generator.cc b/chromium/third_party/perfetto/src/protozero/protoc_plugin/protozero_generator.cc index 0ef0aff878f..bf9c631f76c 100644 --- a/chromium/third_party/perfetto/src/protozero/protoc_plugin/protozero_generator.cc +++ b/chromium/third_party/perfetto/src/protozero/protoc_plugin/protozero_generator.cc @@ -51,8 +51,13 @@ namespace { constexpr int kMaxDecoderFieldId = 999; void Assert(bool condition) { +#ifndef _MSC_VER if (!condition) __builtin_trap(); +#else + if (!condition) + __debugbreak(); +#endif } struct FileDescriptorComp { diff --git a/chromium/third_party/perfetto/src/tracing/core/tracing_service_impl.cc b/chromium/third_party/perfetto/src/tracing/core/tracing_service_impl.cc index c4c2612c344..558102689ba 100644 --- a/chromium/third_party/perfetto/src/tracing/core/tracing_service_impl.cc +++ b/chromium/third_party/perfetto/src/tracing/core/tracing_service_impl.cc @@ -1485,7 +1485,7 @@ void TracingServiceImpl::ReadBuffers(TracingSessionID tsid, int iov_batch_size = static_cast<int>(std::min(num_iovecs - i, kIOVMax)); ssize_t wr_size = PERFETTO_EINTR(writev(fd, &iovecs[i], iov_batch_size)); if (wr_size <= 0) { - PERFETTO_PLOG("writev() failed"); + PERFETTO_ELOG("writev() failed (errno: %d, %s)", errno, strerror(errno)); stop_writing_into_file = true; break; } |