From d961fd91d0734564d6ee7fa3333098a1bb4a0d3a Mon Sep 17 00:00:00 2001 From: roytam1 Date: Wed, 27 Sep 2023 11:35:20 +0800 Subject: [PATCH] import changes from `dev' branch of rmottola/Arctic-Fox: - Bug 1144842 (part 1) - Don't use MOZ_PROFILING before all the places it can be set. r=glandium. (3c12a2e29a) - Bug 1144842 (part 2) - Make --enable-dmd imply --enable-profiling. r=glandium. (85c9ff5c32) - Bug 1144842 (part 3) - Remove --enable-dmd code from js/src/configure.in. r=glandium. (52cf663bc7) - Bug 1221846 - Get Task Tracer building on desktop r=cyu. (5d1a0fabe9) - Bug 1216681 - Add a fileid utility to extract the breakpad GUID from object files for identification in fix_stack_using_bpsyms. r=ted (e53eb5acc6) - Bug 1237156 - Only build the fileid utility when MOZ_CRASHREPORTER is set. r=ted.mielczarek (328a80ae18) - Bug 1239866 - Remove signaling standalone tests. r=bwc (b05b091059) --- configure.in | 65 ++++++++++--------- js/src/configure.in | 18 ----- media/webrtc/moz.build | 9 --- .../jsep_session_unittest_standalone.cpp | 7 -- .../mediaconduit_unittests_standalone.cpp | 5 -- .../mediapipeline_unittest_standalone.cpp | 7 -- .../signaling/test/standalone/moz.build | 63 ------------------ .../standalone/sdp_unittests_standalone.cpp | 7 -- .../signaling_unittests_standalone.cpp | 6 -- memory/replace/dmd/DMD.cpp | 7 +- testing/mochitest/Makefile.in | 1 + toolkit/toolkit.mozbuild | 7 +- tools/profiler/tasktracer/GeckoTaskTracer.cpp | 22 +++++-- .../profiler/tasktracer/GeckoTaskTracerImpl.h | 2 +- .../profiler/tasktracer/TracedTaskCommon.cpp | 4 +- tools/rb/fix_stack_using_bpsyms.py | 25 +++++-- xpcom/threads/TimerThread.cpp | 4 ++ 17 files changed, 88 insertions(+), 171 deletions(-) delete mode 100644 media/webrtc/signaling/test/standalone/jsep_session_unittest_standalone.cpp delete mode 100644 media/webrtc/signaling/test/standalone/mediaconduit_unittests_standalone.cpp delete mode 100644 media/webrtc/signaling/test/standalone/mediapipeline_unittest_standalone.cpp delete mode 100644 media/webrtc/signaling/test/standalone/moz.build delete mode 100644 media/webrtc/signaling/test/standalone/sdp_unittests_standalone.cpp delete mode 100644 media/webrtc/signaling/test/standalone/signaling_unittests_standalone.cpp diff --git a/configure.in b/configure.in index 1a5904bc89..3365d356aa 100644 --- a/configure.in +++ b/configure.in @@ -1696,15 +1696,6 @@ if test -n "$MOZ_USE_SYSTRACE"; then AC_DEFINE(MOZ_USE_SYSTRACE) fi -# For profiling builds keep the symbol information -if test "$MOZ_PROFILING" -a -z "$STRIP_FLAGS"; then - case "$OS_TARGET" in - Linux|DragonFly|FreeBSD|NetBSD|OpenBSD) - STRIP_FLAGS="--strip-debug" - ;; - esac -fi - dnl ======================================================== dnl = Use Valgrind dnl ======================================================== @@ -1768,6 +1759,38 @@ if test -n "$MOZ_VTUNE"; then AC_DEFINE(MOZ_VTUNE) fi +# For profiling builds keep the symbol information +if test "$MOZ_PROFILING" -a -z "$STRIP_FLAGS"; then + case "$OS_TARGET" in + Linux|DragonFly|FreeBSD|NetBSD|OpenBSD) + STRIP_FLAGS="--strip-debug" + ;; + esac +fi + +dnl ======================================================== +dnl = Enable DMD +dnl ======================================================== + +MOZ_ARG_ENABLE_BOOL(dmd, +[ --enable-dmd Enable DMD; also enables jemalloc, replace-malloc and profiling], + MOZ_DMD=1, + MOZ_DMD= ) + +if test "$MOZ_DMD"; then + AC_DEFINE(MOZ_DMD) + + if test "${CPU_ARCH}" = "arm"; then + CFLAGS="$CFLAGS -funwind-tables" + CXXFLAGS="$CXXFLAGS -funwind-tables" + fi + + MOZ_MEMORY=1 # DMD enables jemalloc + MOZ_REPLACE_MALLOC=1 # DMD enables replace-malloc + MOZ_PROFILING=1 # DMD enables profiling +fi +AC_SUBST(MOZ_DMD) + dnl ======================================================== dnl Profiling dnl ======================================================== @@ -6900,28 +6923,6 @@ if test -n "$MOZ_DEBUG"; then AC_DEFINE(MOZ_DUMP_PAINTING) fi -dnl ======================================================== -dnl = Enable DMD -dnl ======================================================== - -MOZ_ARG_ENABLE_BOOL(dmd, -[ --enable-dmd Enable DMD; also enables jemalloc and replace-malloc], - MOZ_DMD=1, - MOZ_DMD= ) - -if test "$MOZ_DMD"; then - AC_DEFINE(MOZ_DMD) - - if test "${CPU_ARCH}" = "arm"; then - CFLAGS="$CFLAGS -funwind-tables" - CXXFLAGS="$CXXFLAGS -funwind-tables" - fi - - MOZ_MEMORY=1 # DMD enables jemalloc - MOZ_REPLACE_MALLOC=1 # DMD enables replace-malloc -fi -AC_SUBST(MOZ_DMD) - dnl ======================================================== dnl = Enable jemalloc dnl ======================================================== @@ -7267,7 +7268,7 @@ MOZ_ARG_ENABLE_BOOL(tasktracer, [ --enable-tasktracer Set compile flags necessary for using TaskTracer], MOZ_TASK_TRACER=1, MOZ_TASK_TRACER= ) -if test "$MOZ_WIDGET_TOOLKIT" = "gonk" -a -n "$MOZ_TASK_TRACER"; then +if test -n "$MOZ_TASK_TRACER"; then AC_DEFINE(MOZ_TASK_TRACER) AC_SUBST(MOZ_TASK_TRACER) fi diff --git a/js/src/configure.in b/js/src/configure.in index 04f705aaab..cb14bdfcc1 100644 --- a/js/src/configure.in +++ b/js/src/configure.in @@ -2972,24 +2972,6 @@ elif test "$GNU_CC"; then fi fi -dnl ======================================================== -dnl = Enable DMD -dnl ======================================================== - -MOZ_ARG_ENABLE_BOOL(dmd, -[ --enable-dmd Enable DMD; also enables jemalloc and replace-malloc], - MOZ_DMD=1, - MOZ_DMD= ) - -if test "$MOZ_DMD"; then - AC_DEFINE(MOZ_DMD) - - if test "${CPU_ARCH}" = "arm"; then - CFLAGS="$CFLAGS -funwind-tables" - CXXFLAGS="$CXXFLAGS -funwind-tables" - fi -fi - dnl ======================================================== dnl = Enable jemalloc dnl ======================================================== diff --git a/media/webrtc/moz.build b/media/webrtc/moz.build index 7422e8da8c..4cfa9f0f9f 100644 --- a/media/webrtc/moz.build +++ b/media/webrtc/moz.build @@ -114,15 +114,6 @@ if CONFIG['MOZ_WIDGET_TOOLKIT'] != 'gonk': ) GYP_DIRS['signalingtest'].non_unified_sources += signaling_non_unified_sources - GYP_DIRS += ['signalingstandalone'] - GYP_DIRS['signalingstandalone'].input = 'signaling/signaling.gyp' - GYP_DIRS['signalingstandalone'].variables = gyp_vars.copy() - GYP_DIRS['signalingstandalone'].variables.update( - build_for_test=0, - build_for_standalone=1 - ) - GYP_DIRS['signalingstandalone'].non_unified_sources += signaling_non_unified_sources - if CONFIG['MOZ_X11']: CXXFLAGS += CONFIG['TK_CFLAGS'] diff --git a/media/webrtc/signaling/test/standalone/jsep_session_unittest_standalone.cpp b/media/webrtc/signaling/test/standalone/jsep_session_unittest_standalone.cpp deleted file mode 100644 index 4c18464512..0000000000 --- a/media/webrtc/signaling/test/standalone/jsep_session_unittest_standalone.cpp +++ /dev/null @@ -1,7 +0,0 @@ -/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* vim: set ts=2 et sw=2 tw=80: */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this file, - * You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#include "../jsep_session_unittest.cpp" diff --git a/media/webrtc/signaling/test/standalone/mediaconduit_unittests_standalone.cpp b/media/webrtc/signaling/test/standalone/mediaconduit_unittests_standalone.cpp deleted file mode 100644 index 051dfe76ed..0000000000 --- a/media/webrtc/signaling/test/standalone/mediaconduit_unittests_standalone.cpp +++ /dev/null @@ -1,5 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this file, - * You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#include "../mediaconduit_unittests.cpp" diff --git a/media/webrtc/signaling/test/standalone/mediapipeline_unittest_standalone.cpp b/media/webrtc/signaling/test/standalone/mediapipeline_unittest_standalone.cpp deleted file mode 100644 index a00703111b..0000000000 --- a/media/webrtc/signaling/test/standalone/mediapipeline_unittest_standalone.cpp +++ /dev/null @@ -1,7 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this file, - * You can obtain one at http://mozilla.org/MPL/2.0/. */ - -// Original author: ekr@rtfm.com - -#include "../mediapipeline_unittest.cpp" diff --git a/media/webrtc/signaling/test/standalone/moz.build b/media/webrtc/signaling/test/standalone/moz.build deleted file mode 100644 index 5bb7fe6e35..0000000000 --- a/media/webrtc/signaling/test/standalone/moz.build +++ /dev/null @@ -1,63 +0,0 @@ -# -*- Mode: python; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 40 -*- -# vim: set filetype=python: -# This Source Code Form is subject to the terms of the Mozilla Public -# License, v. 2.0. If a copy of the MPL was not distributed with this -# file, You can obtain one at http://mozilla.org/MPL/2.0/. - -# Standalone WebRTC does not link on Android. -# See Bug 1127510 - Standalone WebRTC unit tests fail to link on Android -if CONFIG['OS_TARGET'] != 'WINNT' and CONFIG['MOZ_WIDGET_TOOLKIT'] != 'gonk' and CONFIG['OS_TARGET'] != 'Android': - CppUnitTests([ - 'jsep_session_unittest_standalone', -# mediaconduit_unittests disabled for standalone build until GMP support added. -# See Bug 1121677 - Enable GMP for WebRTC standalone. -# 'mediaconduit_unittests_standalone', - 'mediapipeline_unittest_standalone', - 'sdp_unittests_standalone', - 'signaling_unittests_standalone', - ]) - -include('/ipc/chromium/chromium-config.mozbuild') -include('../common.build') - -for var in ('MOZILLA_INTERNAL_API', 'MOZILLA_XPCOMRT_API'): - DEFINES[var] = True - -if CONFIG['OS_TARGET'] == 'Linux': - USE_LIBS += [ - 'nspr', - ] - OS_LIBS += [ - '-lrt', - ] - -LOCAL_INCLUDES += [ - '..', - '/xpcom/libxpcomrt', -] - -USE_LIBS += [ - '/media/webrtc/signalingstandalone/signaling_ecc/ecc', - 'fallible', - 'js', # Turns out, binding implementations use JS, who knew. - 'media_standalone', - 'mfbt', - 'mozglue', - 'mtransport_standalone', - 'necko_standalone', - 'nspr', - 'nss', - 'unicharutil_standalone', - 'xpcomrt', -] - -if CONFIG['OS_TARGET'] == 'Android': - USE_LIBS += [ - 'freetype', - ] - -if CONFIG['OS_TARGET'] == 'OpenBSD': - OS_LIBS += ['sndio'] - - -USE_LIBS += ['mozglue'] diff --git a/media/webrtc/signaling/test/standalone/sdp_unittests_standalone.cpp b/media/webrtc/signaling/test/standalone/sdp_unittests_standalone.cpp deleted file mode 100644 index 122eb46b21..0000000000 --- a/media/webrtc/signaling/test/standalone/sdp_unittests_standalone.cpp +++ /dev/null @@ -1,7 +0,0 @@ -/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* vim: set ts=2 et sw=2 tw=80: */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this file, - * You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#include "../sdp_unittests.cpp" diff --git a/media/webrtc/signaling/test/standalone/signaling_unittests_standalone.cpp b/media/webrtc/signaling/test/standalone/signaling_unittests_standalone.cpp deleted file mode 100644 index 8a0524f3ef..0000000000 --- a/media/webrtc/signaling/test/standalone/signaling_unittests_standalone.cpp +++ /dev/null @@ -1,6 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this file, - * You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#define SIGNALING_UNITTEST_STANDALONE 1 -#include "../signaling_unittests.cpp" diff --git a/memory/replace/dmd/DMD.cpp b/memory/replace/dmd/DMD.cpp index f265769194..cfa77cc727 100644 --- a/memory/replace/dmd/DMD.cpp +++ b/memory/replace/dmd/DMD.cpp @@ -12,10 +12,11 @@ #include #include -#ifdef XP_WIN -#if defined(MOZ_OPTIMIZE) && !defined(MOZ_PROFILING) -#error "Optimized, DMD-enabled builds on Windows must be built with --enable-profiling" +#if !defined(MOZ_PROFILING) +#error "DMD requires MOZ_PROFILING" #endif + +#ifdef XP_WIN #include #include #else diff --git a/testing/mochitest/Makefile.in b/testing/mochitest/Makefile.in index 037b9bbb35..de93645be9 100644 --- a/testing/mochitest/Makefile.in +++ b/testing/mochitest/Makefile.in @@ -20,6 +20,7 @@ libs:: TEST_HARNESS_BINS := \ xpcshell$(BIN_SUFFIX) \ ssltunnel$(BIN_SUFFIX) \ + fileid$(BIN_SUFFIX) \ certutil$(BIN_SUFFIX) \ pk12util$(BIN_SUFFIX) \ BadCertServer$(BIN_SUFFIX) \ diff --git a/toolkit/toolkit.mozbuild b/toolkit/toolkit.mozbuild index 0a967441db..71e8058d3a 100644 --- a/toolkit/toolkit.mozbuild +++ b/toolkit/toolkit.mozbuild @@ -184,9 +184,12 @@ if CONFIG['ENABLE_TESTS']: '/testing/web-platform', ] - if CONFIG['MOZ_WEBRTC'] and CONFIG['MOZ_WIDGET_TOOLKIT'] != 'gonk': + # The file id utility requires breakpad libraries. + if CONFIG['MOZ_CRASHREPORTER']: + DIRS += ['/testing/tools/fileid'] + + if CONFIG['MOZ_WEBRTC'] and CONFIG['MOZ_WIDGET_TOOLKIT'] != 'gonk' and not CONFIG['MOZ_TASK_TRACER']: DIRS += [ '/media/webrtc/signaling/test', - '/media/webrtc/signaling/test/standalone', '/media/mtransport/test', ] diff --git a/tools/profiler/tasktracer/GeckoTaskTracer.cpp b/tools/profiler/tasktracer/GeckoTaskTracer.cpp index 3737c4db00..72ed2bdd5e 100644 --- a/tools/profiler/tasktracer/GeckoTaskTracer.cpp +++ b/tools/profiler/tasktracer/GeckoTaskTracer.cpp @@ -19,13 +19,25 @@ #include +// We need a definition of gettid(), but glibc doesn't provide a +// wrapper for it. #if defined(__GLIBC__) -// glibc doesn't implement gettid(2). +#include #include -static pid_t gettid() +static inline pid_t gettid() { return (pid_t) syscall(SYS_gettid); } +#elif defined(XP_MACOSX) +#include +#include +static inline pid_t gettid() +{ + return (pid_t) syscall(SYS_thread_selfid); +} +#elif defined(LINUX) +#include +pid_t gettid(); #endif // NS_ENSURE_TRUE_VOID() without the warning on the debug build. @@ -114,12 +126,12 @@ CreateSourceEvent(SourceEventType aType) info->mCurTraceSourceType = aType; info->mCurTaskId = newId; - int* namePtr; + uintptr_t* namePtr; #define SOURCE_EVENT_NAME(type) \ case SourceEventType::type: \ { \ static int CreateSourceEvent##type; \ - namePtr = &CreateSourceEvent##type; \ + namePtr = (uintptr_t*)&CreateSourceEvent##type; \ break; \ } @@ -367,7 +379,7 @@ LogEnd(uint64_t aTaskId, uint64_t aSourceEventId) } void -LogVirtualTablePtr(uint64_t aTaskId, uint64_t aSourceEventId, int* aVptr) +LogVirtualTablePtr(uint64_t aTaskId, uint64_t aSourceEventId, uintptr_t* aVptr) { TraceInfo* info = GetOrCreateTraceInfo(); ENSURE_TRUE_VOID(info); diff --git a/tools/profiler/tasktracer/GeckoTaskTracerImpl.h b/tools/profiler/tasktracer/GeckoTaskTracerImpl.h index 00e54b9769..5b748fb96b 100644 --- a/tools/profiler/tasktracer/GeckoTaskTracerImpl.h +++ b/tools/profiler/tasktracer/GeckoTaskTracerImpl.h @@ -94,7 +94,7 @@ void LogBegin(uint64_t aTaskId, uint64_t aSourceEventId); void LogEnd(uint64_t aTaskId, uint64_t aSourceEventId); -void LogVirtualTablePtr(uint64_t aTaskId, uint64_t aSourceEventId, int* aVptr); +void LogVirtualTablePtr(uint64_t aTaskId, uint64_t aSourceEventId, uintptr_t* aVptr); } // namespace mozilla } // namespace tasktracer diff --git a/tools/profiler/tasktracer/TracedTaskCommon.cpp b/tools/profiler/tasktracer/TracedTaskCommon.cpp index 9fc2f559a5..770eb202c9 100644 --- a/tools/profiler/tasktracer/TracedTaskCommon.cpp +++ b/tools/profiler/tasktracer/TracedTaskCommon.cpp @@ -95,7 +95,7 @@ TracedRunnable::TracedRunnable(already_AddRefed&& aOriginalObj) , mOriginalObj(Move(aOriginalObj)) { Init(); - LogVirtualTablePtr(mTaskId, mSourceEventId, *(int**)(aOriginalObj)); + LogVirtualTablePtr(mTaskId, mSourceEventId, reinterpret_cast(mOriginalObj.get())); } TracedRunnable::~TracedRunnable() @@ -122,7 +122,7 @@ TracedTask::TracedTask(Task* aOriginalObj) , mOriginalObj(aOriginalObj) { Init(); - LogVirtualTablePtr(mTaskId, mSourceEventId, *(int**)(aOriginalObj)); + LogVirtualTablePtr(mTaskId, mSourceEventId, reinterpret_cast(aOriginalObj)); } TracedTask::~TracedTask() diff --git a/tools/rb/fix_stack_using_bpsyms.py b/tools/rb/fix_stack_using_bpsyms.py index 83715095ef..ed89345d1b 100755 --- a/tools/rb/fix_stack_using_bpsyms.py +++ b/tools/rb/fix_stack_using_bpsyms.py @@ -13,8 +13,11 @@ from __future__ import with_statement import sys import os import re +import subprocess import bisect +here = os.path.dirname(__file__) + def prettyFileName(name): if name.startswith("../") or name.startswith("..\\"): # dom_quickstubs.cpp and many .h files show up with relative paths that are useless @@ -77,9 +80,21 @@ class SymbolFile: else: return "" -def guessSymbolFile(fn, symbolsDir): +def findIdForPath(path): + """Finds the breakpad id for the object file at the given path.""" + # We should always be packaged with a "fileid" executable. + fileid_exe = os.path.join(here, 'fileid') + if not os.path.isfile(fileid_exe): + raise Exception("Could not find fileid executable in %s" % here) + try: + return subprocess.check_output([fileid_exe, path]).rstrip() + except subprocess.CalledProcessError as e: + raise Exception("Error getting fileid for %s: %s" % + (path, e.output)) + +def guessSymbolFile(full_path, symbolsDir): """Guess a symbol file based on an object file's basename, ignoring the path and UUID.""" - fn = os.path.basename(fn) + fn = os.path.basename(full_path) d1 = os.path.join(symbolsDir, fn) if not os.path.exists(d1): fn = fn + ".pdb" @@ -90,10 +105,12 @@ def guessSymbolFile(fn, symbolsDir): if len(uuids) == 0: raise Exception("Missing symbol file for " + fn) if len(uuids) > 1: - raise Exception("Ambiguous symbol file for " + fn) + uuid = findIdForPath(full_path) + else: + uuid = uuids[0] if fn.endswith(".pdb"): fn = fn[:-4] - return os.path.join(d1, uuids[0], fn + ".sym") + return os.path.join(d1, uuid, fn + ".sym") parsedSymbolFiles = {} def getSymbolFile(file, symbolsDir): diff --git a/xpcom/threads/TimerThread.cpp b/xpcom/threads/TimerThread.cpp index 7e032607e7..7714262f61 100644 --- a/xpcom/threads/TimerThread.cpp +++ b/xpcom/threads/TimerThread.cpp @@ -21,6 +21,10 @@ #include using namespace mozilla; +#ifdef MOZ_TASK_TRACER +#include "GeckoTaskTracerImpl.h" +using namespace mozilla::tasktracer; +#endif NS_IMPL_ISUPPORTS(TimerThread, nsIRunnable, nsIObserver)