mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-09-07 00:08:39 +09:00
Remove the Dark Matter Detector (DMD) Memeory debugger component.
This resolves #376.
This commit is contained in:
parent
4f9e1b3147
commit
92fbd042f5
55 changed files with 6 additions and 6544 deletions
|
|
@ -72,9 +72,6 @@
|
|||
#ifndef MOZ_STATIC_JS
|
||||
@BINPATH@/@DLL_PREFIX@mozjs@DLL_SUFFIX@
|
||||
#endif
|
||||
#ifdef MOZ_DMD
|
||||
@BINPATH@/@DLL_PREFIX@dmd@DLL_SUFFIX@
|
||||
#endif
|
||||
#ifndef MOZ_SYSTEM_NSPR
|
||||
#ifndef MOZ_FOLD_LIBS
|
||||
@BINPATH@/@DLL_PREFIX@nspr4@DLL_SUFFIX@
|
||||
|
|
|
|||
|
|
@ -69,9 +69,6 @@
|
|||
#ifndef MOZ_STATIC_JS
|
||||
@BINPATH@/@DLL_PREFIX@mozjs@DLL_SUFFIX@
|
||||
#endif
|
||||
#ifdef MOZ_DMD
|
||||
@BINPATH@/@DLL_PREFIX@dmd@DLL_SUFFIX@
|
||||
#endif
|
||||
#ifndef MOZ_SYSTEM_NSPR
|
||||
#ifndef MOZ_FOLD_LIBS
|
||||
@BINPATH@/@DLL_PREFIX@nspr4@DLL_SUFFIX@
|
||||
|
|
|
|||
|
|
@ -52,16 +52,13 @@ if CONFIG['MOZ_PHOENIX']:
|
|||
'compare-mozconfig/compare-mozconfigs-wrapper.py',
|
||||
]
|
||||
|
||||
if CONFIG['ENABLE_TESTS'] or CONFIG['MOZ_DMD']:
|
||||
if CONFIG['ENABLE_TESTS']:
|
||||
FINAL_TARGET_FILES += ['/tools/rb/fix_stack_using_bpsyms.py']
|
||||
if CONFIG['OS_ARCH'] == 'Darwin':
|
||||
FINAL_TARGET_FILES += ['/tools/rb/fix_macosx_stack.py']
|
||||
if CONFIG['OS_ARCH'] == 'Linux':
|
||||
FINAL_TARGET_FILES += ['/tools/rb/fix_linux_stack.py']
|
||||
|
||||
if CONFIG['MOZ_DMD']:
|
||||
FINAL_TARGET_FILES += ['/memory/replace/dmd/dmd.py']
|
||||
|
||||
# Put a useful .gdbinit in the bin directory, to be picked up automatically
|
||||
# by GDB when we debug executables there.
|
||||
FINAL_TARGET_FILES += ['/.gdbinit']
|
||||
|
|
|
|||
|
|
@ -173,17 +173,6 @@ OS_LDFLAGS += -DEBUG -OPT:REF
|
|||
endif
|
||||
endif
|
||||
|
||||
#
|
||||
# Handle DMD in optimized builds.
|
||||
#
|
||||
ifdef MOZ_DMD
|
||||
ifdef HAVE_64BIT_BUILD
|
||||
OS_LDFLAGS = -DEBUG -OPT:REF,ICF
|
||||
else
|
||||
OS_LDFLAGS = -DEBUG -OPT:REF
|
||||
endif
|
||||
endif # MOZ_DMD
|
||||
|
||||
endif # MOZ_DEBUG
|
||||
|
||||
endif # WINNT && !GNU_CC
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
|
|
@ -1,310 +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/. */
|
||||
|
||||
#ifndef DMD_h___
|
||||
#define DMD_h___
|
||||
|
||||
#include <string.h>
|
||||
#include <stdarg.h>
|
||||
|
||||
#include "mozilla/DebugOnly.h"
|
||||
#include "mozilla/Move.h"
|
||||
#include "mozilla/Types.h"
|
||||
#include "mozilla/UniquePtr.h"
|
||||
|
||||
#include "replace_malloc_bridge.h"
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
class JSONWriteFunc;
|
||||
|
||||
namespace dmd {
|
||||
|
||||
struct Sizes
|
||||
{
|
||||
size_t mStackTracesUsed;
|
||||
size_t mStackTracesUnused;
|
||||
size_t mStackTraceTable;
|
||||
size_t mLiveBlockTable;
|
||||
size_t mDeadBlockTable;
|
||||
|
||||
Sizes() { Clear(); }
|
||||
void Clear() { memset(this, 0, sizeof(Sizes)); }
|
||||
};
|
||||
|
||||
// See further below for a description of each method. The DMDFuncs class
|
||||
// should contain a virtual method for each of them (except IsRunning,
|
||||
// which can be inferred from the DMDFuncs singleton existing).
|
||||
struct DMDFuncs
|
||||
{
|
||||
virtual void Report(const void*);
|
||||
|
||||
virtual void ReportOnAlloc(const void*);
|
||||
|
||||
virtual void ClearReports();
|
||||
|
||||
virtual void Analyze(UniquePtr<JSONWriteFunc>);
|
||||
|
||||
virtual void SizeOf(Sizes*);
|
||||
|
||||
virtual void StatusMsg(const char*, va_list);
|
||||
|
||||
virtual void ResetEverything(const char*);
|
||||
|
||||
#ifndef REPLACE_MALLOC_IMPL
|
||||
// We deliberately don't use ReplaceMalloc::GetDMDFuncs here, because if we
|
||||
// did, the following would happen.
|
||||
// - The code footprint of each call to Get() larger as GetDMDFuncs ends
|
||||
// up inlined.
|
||||
// - When no replace-malloc library is loaded, the number of instructions
|
||||
// executed is equivalent, but don't necessarily fit in the same cache
|
||||
// line.
|
||||
// - When a non-DMD replace-malloc library is loaded, the overhead is
|
||||
// higher because there is first a check for the replace malloc bridge
|
||||
// and then for the DMDFuncs singleton.
|
||||
// Initializing the DMDFuncs singleton on the first access makes the
|
||||
// overhead even worse. Either Get() is inlined and massive, or it isn't
|
||||
// and a simple value check becomes a function call.
|
||||
static DMDFuncs* Get() { return sSingleton.Get(); }
|
||||
|
||||
private:
|
||||
// Wrapper class keeping a pointer to the DMD functions. It is statically
|
||||
// initialized because it needs to be set early enough.
|
||||
// Debug builds also check that it's never accessed before the static
|
||||
// initialization actually occured, which could be the case if some other
|
||||
// static initializer ended up calling into DMD.
|
||||
class Singleton
|
||||
{
|
||||
public:
|
||||
Singleton()
|
||||
: mValue(ReplaceMalloc::GetDMDFuncs())
|
||||
#ifdef DEBUG
|
||||
, mInitialized(true)
|
||||
#endif
|
||||
{}
|
||||
|
||||
DMDFuncs* Get()
|
||||
{
|
||||
MOZ_ASSERT(mInitialized);
|
||||
return mValue;
|
||||
}
|
||||
|
||||
private:
|
||||
DMDFuncs* mValue;
|
||||
#ifdef DEBUG
|
||||
bool mInitialized;
|
||||
#endif
|
||||
};
|
||||
|
||||
// This singleton pointer must be defined on the program side. In Gecko,
|
||||
// this is done in xpcom/base/nsMemoryInfoDumper.cpp.
|
||||
static /* DMDFuncs:: */Singleton sSingleton;
|
||||
#endif
|
||||
};
|
||||
|
||||
#ifndef REPLACE_MALLOC_IMPL
|
||||
// Mark a heap block as reported by a memory reporter.
|
||||
inline void
|
||||
Report(const void* aPtr)
|
||||
{
|
||||
DMDFuncs* funcs = DMDFuncs::Get();
|
||||
if (funcs) {
|
||||
funcs->Report(aPtr);
|
||||
}
|
||||
}
|
||||
|
||||
// Mark a heap block as reported immediately on allocation.
|
||||
inline void
|
||||
ReportOnAlloc(const void* aPtr)
|
||||
{
|
||||
DMDFuncs* funcs = DMDFuncs::Get();
|
||||
if (funcs) {
|
||||
funcs->ReportOnAlloc(aPtr);
|
||||
}
|
||||
}
|
||||
|
||||
// Clears existing reportedness data from any prior runs of the memory
|
||||
// reporters. The following sequence should be used.
|
||||
// - ClearReports()
|
||||
// - run the memory reporters
|
||||
// - Analyze()
|
||||
// This sequence avoids spurious twice-reported warnings.
|
||||
inline void
|
||||
ClearReports()
|
||||
{
|
||||
DMDFuncs* funcs = DMDFuncs::Get();
|
||||
if (funcs) {
|
||||
funcs->ClearReports();
|
||||
}
|
||||
}
|
||||
|
||||
// Determines which heap blocks have been reported, and dumps JSON output
|
||||
// (via |aWriter|) describing the heap.
|
||||
//
|
||||
// The following sample output contains comments that explain the format and
|
||||
// design choices. The output files can be quite large, so a number of
|
||||
// decisions were made to minimize size, such as using short property names and
|
||||
// omitting properties whenever possible.
|
||||
//
|
||||
// {
|
||||
// // The version number of the format, which will be incremented each time
|
||||
// // backwards-incompatible changes are made. A mandatory integer.
|
||||
// //
|
||||
// // Version history:
|
||||
// // - 1: Bug 1044709
|
||||
// // - 2: Bug 1094552
|
||||
// // - 3: Bug 1100851
|
||||
// // - 4: Bug 1121830
|
||||
// // - 5: Bug 1253512
|
||||
// "version": 5,
|
||||
//
|
||||
// // Information about how DMD was invoked. A mandatory object.
|
||||
// "invocation": {
|
||||
// // The contents of the $DMD environment variable. A string, or |null| if
|
||||
// // $DMD is undefined.
|
||||
// "dmdEnvVar": "--mode=dark-matter",
|
||||
//
|
||||
// // The profiling mode. A mandatory string taking one of the following
|
||||
// // values: "live", "dark-matter", "cumulative", "scan".
|
||||
// "mode": "dark-matter",
|
||||
// },
|
||||
//
|
||||
// // Details of all analyzed heap blocks. A mandatory array.
|
||||
// "blockList": [
|
||||
// // An example of a heap block.
|
||||
// {
|
||||
// // Requested size, in bytes. This is a mandatory integer.
|
||||
// "req": 3584,
|
||||
//
|
||||
// // Requested slop size, in bytes. This is mandatory if it is non-zero,
|
||||
// // but omitted otherwise.
|
||||
// "slop": 512,
|
||||
//
|
||||
// // The stack trace at which the block was allocated. An optional
|
||||
// // string that indexes into the "traceTable" object. If omitted, no
|
||||
// // allocation stack trace was recorded for the block.
|
||||
// "alloc": "A",
|
||||
//
|
||||
// // One or more stack traces at which this heap block was reported by a
|
||||
// // memory reporter. An optional array that will only be present in
|
||||
// // "dark-matter" mode. The elements are strings that index into
|
||||
// // the "traceTable" object.
|
||||
// "reps": ["B"]
|
||||
//
|
||||
// // The number of heap blocks with exactly the above properties. This
|
||||
// // is mandatory if it is greater than one, but omitted otherwise.
|
||||
// // (Blocks with identical properties don't have to be aggregated via
|
||||
// // this property, but it can greatly reduce output file size.)
|
||||
// "num": 5,
|
||||
//
|
||||
// // The address of the block. This is mandatory in "scan" mode, but
|
||||
// // omitted otherwise.
|
||||
// "addr": "4e4e4e4e",
|
||||
//
|
||||
// // The contents of the block, read one word at a time. This is
|
||||
// // mandatory in "scan" mode for blocks at least one word long, but
|
||||
// // omitted otherwise.
|
||||
// "contents": ["0", "6", "7f7f7f7f", "0"]
|
||||
// }
|
||||
// ],
|
||||
//
|
||||
// // The stack traces referenced by elements of the "blockList" array. This
|
||||
// // could be an array, but making it an object makes it easier to see
|
||||
// // which stacks correspond to which references in the "blockList" array.
|
||||
// "traceTable": {
|
||||
// // Each property corresponds to a stack trace mentioned in the "blocks"
|
||||
// // object. Each element is an index into the "frameTable" object.
|
||||
// "A": ["D", "E"],
|
||||
// "B": ["F", "G"]
|
||||
// },
|
||||
//
|
||||
// // The stack frames referenced by the "traceTable" object. The
|
||||
// // descriptions can be quite long, so they are stored separately from the
|
||||
// // "traceTable" object so that each one only has to be written once.
|
||||
// // This could also be an array, but again, making it an object makes it
|
||||
// // easier to see which frames correspond to which references in the
|
||||
// // "traceTable" object.
|
||||
// "frameTable": {
|
||||
// // Each property key is a frame key mentioned in the "traceTable" object.
|
||||
// // Each property value is a string containing a frame description. Each
|
||||
// // frame description must be in a format recognized by the stack-fixing
|
||||
// // scripts (e.g. fix_linux_stack.py), which require a frame number at
|
||||
// // the start. Because each stack frame description in this table can
|
||||
// // be shared between multiple stack traces, we use a dummy value of
|
||||
// // #00. The proper frame number can be reconstructed later by scripts
|
||||
// // that output stack traces in a conventional non-shared format.
|
||||
// "D": "#00: foo (Foo.cpp:123)",
|
||||
// "E": "#00: bar (Bar.cpp:234)",
|
||||
// "F": "#00: baz (Baz.cpp:345)",
|
||||
// "G": "#00: quux (Quux.cpp:456)"
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// Implementation note: normally, this function wouldn't be templated, but in
|
||||
// that case, the function is compiled, which makes the destructor for the
|
||||
// UniquePtr fire up, and that needs JSONWriteFunc to be fully defined. That,
|
||||
// in turn, requires to include JSONWriter.h, which includes
|
||||
// double-conversion.h, which ends up breaking various things built with
|
||||
// -Werror for various reasons.
|
||||
//
|
||||
template <typename JSONWriteFunc>
|
||||
inline void
|
||||
Analyze(UniquePtr<JSONWriteFunc> aWriteFunc)
|
||||
{
|
||||
DMDFuncs* funcs = DMDFuncs::Get();
|
||||
if (funcs) {
|
||||
funcs->Analyze(Move(aWriteFunc));
|
||||
}
|
||||
}
|
||||
|
||||
// Gets the size of various data structures. Used to implement a memory
|
||||
// reporter for DMD.
|
||||
inline void
|
||||
SizeOf(Sizes* aSizes)
|
||||
{
|
||||
DMDFuncs* funcs = DMDFuncs::Get();
|
||||
if (funcs) {
|
||||
funcs->SizeOf(aSizes);
|
||||
}
|
||||
}
|
||||
|
||||
// Prints a status message prefixed with "DMD[<pid>]". Use sparingly.
|
||||
inline void
|
||||
StatusMsg(const char* aFmt, ...)
|
||||
{
|
||||
DMDFuncs* funcs = DMDFuncs::Get();
|
||||
if (funcs) {
|
||||
va_list ap;
|
||||
va_start(ap, aFmt);
|
||||
funcs->StatusMsg(aFmt, ap);
|
||||
va_end(ap);
|
||||
}
|
||||
}
|
||||
|
||||
// Indicates whether or not DMD is running.
|
||||
inline bool
|
||||
IsRunning()
|
||||
{
|
||||
return !!DMDFuncs::Get();
|
||||
}
|
||||
|
||||
// Resets all DMD options and then sets new ones according to those specified
|
||||
// in |aOptions|. Also clears all recorded data about allocations. Only used
|
||||
// for testing purposes.
|
||||
inline void
|
||||
ResetEverything(const char* aOptions)
|
||||
{
|
||||
DMDFuncs* funcs = DMDFuncs::Get();
|
||||
if (funcs) {
|
||||
funcs->ResetEverything(aOptions);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
} // namespace dmd
|
||||
} // namespace mozilla
|
||||
|
||||
#endif /* DMD_h___ */
|
||||
|
|
@ -1,2 +0,0 @@
|
|||
This is DMD. See https://wiki.mozilla.org/Performance/MemShrink/DMD for
|
||||
details on how to use it.
|
||||
|
|
@ -1,261 +0,0 @@
|
|||
#!/usr/bin/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/.
|
||||
|
||||
# From a scan mode DMD log, extract some information about a
|
||||
# particular block, such as its allocation stack or which other blocks
|
||||
# contain pointers to it. This can be useful when investigating leaks
|
||||
# caused by unknown references to refcounted objects.
|
||||
|
||||
import json
|
||||
import gzip
|
||||
import sys
|
||||
import argparse
|
||||
import re
|
||||
|
||||
|
||||
# The DMD output version this script handles.
|
||||
outputVersion = 5
|
||||
|
||||
# If --ignore-alloc-fns is specified, stack frames containing functions that
|
||||
# match these strings will be removed from the *start* of stack traces. (Once
|
||||
# we hit a non-matching frame, any subsequent frames won't be removed even if
|
||||
# they do match.)
|
||||
allocatorFns = [
|
||||
'malloc (',
|
||||
'replace_malloc',
|
||||
'replace_calloc',
|
||||
'replace_realloc',
|
||||
'replace_memalign',
|
||||
'replace_posix_memalign',
|
||||
'malloc_zone_malloc',
|
||||
'moz_xmalloc',
|
||||
'moz_xcalloc',
|
||||
'moz_xrealloc',
|
||||
'operator new(',
|
||||
'operator new[](',
|
||||
'g_malloc',
|
||||
'g_slice_alloc',
|
||||
'callocCanGC',
|
||||
'reallocCanGC',
|
||||
'vpx_malloc',
|
||||
'vpx_calloc',
|
||||
'vpx_realloc',
|
||||
'vpx_memalign',
|
||||
'js_malloc',
|
||||
'js_calloc',
|
||||
'js_realloc',
|
||||
'pod_malloc',
|
||||
'pod_calloc',
|
||||
'pod_realloc',
|
||||
'nsTArrayInfallibleAllocator::Malloc',
|
||||
# This one necessary to fully filter some sequences of allocation functions
|
||||
# that happen in practice. Note that ??? entries that follow non-allocation
|
||||
# functions won't be stripped, as explained above.
|
||||
'???',
|
||||
]
|
||||
|
||||
####
|
||||
|
||||
# Command line arguments
|
||||
|
||||
def range_1_24(string):
|
||||
value = int(string)
|
||||
if value < 1 or value > 24:
|
||||
msg = '{:s} is not in the range 1..24'.format(string)
|
||||
raise argparse.ArgumentTypeError(msg)
|
||||
return value
|
||||
|
||||
parser = argparse.ArgumentParser(description='Analyze the heap graph to find out things about an object. \
|
||||
By default this prints out information about blocks that point to the given block.')
|
||||
|
||||
parser.add_argument('dmd_log_file_name',
|
||||
help='clamped DMD log file name')
|
||||
|
||||
parser.add_argument('block',
|
||||
help='address of the block of interest')
|
||||
|
||||
parser.add_argument('--info', dest='info', action='store_true',
|
||||
default=False,
|
||||
help='Print out information about the block.')
|
||||
|
||||
parser.add_argument('-sfl', '--max-stack-frame-length', type=int,
|
||||
default=150,
|
||||
help='Maximum number of characters to print from each stack frame')
|
||||
|
||||
parser.add_argument('-a', '--ignore-alloc-fns', action='store_true',
|
||||
help='ignore allocation functions at the start of traces')
|
||||
|
||||
parser.add_argument('-f', '--max-frames', type=range_1_24,
|
||||
help='maximum number of frames to consider in each trace')
|
||||
|
||||
parser.add_argument('-c', '--chain-reports', action='store_true',
|
||||
help='if only one block is found to hold onto the object, report the next one, too')
|
||||
|
||||
|
||||
####
|
||||
|
||||
|
||||
class BlockData:
|
||||
def __init__(self, json_block):
|
||||
self.addr = json_block['addr']
|
||||
|
||||
if 'contents' in json_block:
|
||||
contents = json_block['contents']
|
||||
else:
|
||||
contents = []
|
||||
self.contents = []
|
||||
for c in contents:
|
||||
self.contents.append(int(c, 16))
|
||||
|
||||
self.req_size = json_block['req']
|
||||
|
||||
self.alloc_stack = json_block['alloc']
|
||||
|
||||
|
||||
def print_trace_segment(args, stacks, block):
|
||||
(traceTable, frameTable) = stacks
|
||||
|
||||
for l in traceTable[block.alloc_stack]:
|
||||
# The 5: is to remove the bogus leading "#00: " from the stack frame.
|
||||
print ' ', frameTable[l][5:args.max_stack_frame_length]
|
||||
|
||||
|
||||
def show_referrers(args, blocks, stacks, block):
|
||||
visited = set([])
|
||||
|
||||
anyFound = False
|
||||
|
||||
while True:
|
||||
referrers = {}
|
||||
|
||||
for b, data in blocks.iteritems():
|
||||
which_edge = 0
|
||||
for e in data.contents:
|
||||
if e == block:
|
||||
# 8 is the number of bytes per word on a 64-bit system.
|
||||
# XXX This means that this output will be wrong for logs from 32-bit systems!
|
||||
referrers.setdefault(b, []).append(8 * which_edge)
|
||||
anyFound = True
|
||||
which_edge += 1
|
||||
|
||||
for r in referrers:
|
||||
sys.stdout.write('0x{} size = {} bytes'.format(blocks[r].addr, blocks[r].req_size))
|
||||
plural = 's' if len(referrers[r]) > 1 else ''
|
||||
sys.stdout.write(' at byte offset' + plural + ' ' + (', '.join(str(x) for x in referrers[r])))
|
||||
print
|
||||
print_trace_segment(args, stacks, blocks[r])
|
||||
print
|
||||
|
||||
if args.chain_reports:
|
||||
if len(referrers) == 0:
|
||||
sys.stdout.write('Found no more referrers.\n')
|
||||
break
|
||||
if len(referrers) > 1:
|
||||
sys.stdout.write('Found too many referrers.\n')
|
||||
break
|
||||
|
||||
sys.stdout.write('Chaining to next referrer.\n\n')
|
||||
for r in referrers:
|
||||
block = r
|
||||
if block in visited:
|
||||
sys.stdout.write('Found a loop.\n')
|
||||
break
|
||||
visited.add(block)
|
||||
else:
|
||||
break
|
||||
|
||||
if not anyFound:
|
||||
print 'No referrers found.'
|
||||
|
||||
|
||||
def show_block_info(args, blocks, stacks, block):
|
||||
b = blocks[block]
|
||||
sys.stdout.write('block: 0x{}\n'.format(b.addr))
|
||||
sys.stdout.write('requested size: {} bytes\n'.format(b.req_size))
|
||||
sys.stdout.write('\n')
|
||||
sys.stdout.write('block contents: ')
|
||||
for c in b.contents:
|
||||
v = '0' if c == 0 else blocks[c].addr
|
||||
sys.stdout.write('0x{} '.format(v))
|
||||
sys.stdout.write('\n\n')
|
||||
sys.stdout.write('allocation stack:\n')
|
||||
print_trace_segment(args, stacks, b)
|
||||
return
|
||||
|
||||
|
||||
def cleanupTraceTable(args, frameTable, traceTable):
|
||||
# Remove allocation functions at the start of traces.
|
||||
if args.ignore_alloc_fns:
|
||||
# Build a regexp that matches every function in allocatorFns.
|
||||
escapedAllocatorFns = map(re.escape, allocatorFns)
|
||||
fn_re = re.compile('|'.join(escapedAllocatorFns))
|
||||
|
||||
# Remove allocator fns from each stack trace.
|
||||
for traceKey, frameKeys in traceTable.items():
|
||||
numSkippedFrames = 0
|
||||
for frameKey in frameKeys:
|
||||
frameDesc = frameTable[frameKey]
|
||||
if re.search(fn_re, frameDesc):
|
||||
numSkippedFrames += 1
|
||||
else:
|
||||
break
|
||||
if numSkippedFrames > 0:
|
||||
traceTable[traceKey] = frameKeys[numSkippedFrames:]
|
||||
|
||||
# Trim the number of frames.
|
||||
for traceKey, frameKeys in traceTable.items():
|
||||
if len(frameKeys) > args.max_frames:
|
||||
traceTable[traceKey] = frameKeys[:args.max_frames]
|
||||
|
||||
|
||||
def loadGraph(options):
|
||||
# Handle gzipped input if necessary.
|
||||
isZipped = options.dmd_log_file_name.endswith('.gz')
|
||||
opener = gzip.open if isZipped else open
|
||||
|
||||
with opener(options.dmd_log_file_name, 'rb') as f:
|
||||
j = json.load(f)
|
||||
|
||||
if j['version'] != outputVersion:
|
||||
raise Exception("'version' property isn't '{:d}'".format(outputVersion))
|
||||
|
||||
invocation = j['invocation']
|
||||
|
||||
block_list = j['blockList']
|
||||
blocks = {}
|
||||
|
||||
for json_block in block_list:
|
||||
blocks[int(json_block['addr'], 16)] = BlockData(json_block)
|
||||
|
||||
traceTable = j['traceTable']
|
||||
frameTable = j['frameTable']
|
||||
|
||||
cleanupTraceTable(options, frameTable, traceTable)
|
||||
|
||||
return (blocks, (traceTable, frameTable))
|
||||
|
||||
|
||||
def analyzeLogs():
|
||||
options = parser.parse_args()
|
||||
|
||||
(blocks, stacks) = loadGraph(options)
|
||||
|
||||
block = int(options.block, 16)
|
||||
|
||||
if not block in blocks:
|
||||
print 'Object', block, 'not found in traces.'
|
||||
print 'It could still be the target of some nodes.'
|
||||
return
|
||||
|
||||
if options.info:
|
||||
show_block_info(options, blocks, stacks, block)
|
||||
return
|
||||
|
||||
show_referrers(options, blocks, stacks, block)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
analyzeLogs()
|
||||
|
|
@ -1,890 +0,0 @@
|
|||
#! /usr/bin/env 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/.
|
||||
|
||||
'''This script analyzes a JSON file emitted by DMD.'''
|
||||
|
||||
from __future__ import print_function, division
|
||||
|
||||
import argparse
|
||||
import collections
|
||||
import gzip
|
||||
import json
|
||||
import os
|
||||
import platform
|
||||
import re
|
||||
import shutil
|
||||
import sys
|
||||
import tempfile
|
||||
from bisect import bisect_right
|
||||
|
||||
# The DMD output version this script handles.
|
||||
outputVersion = 5
|
||||
|
||||
# If --ignore-alloc-fns is specified, stack frames containing functions that
|
||||
# match these strings will be removed from the *start* of stack traces. (Once
|
||||
# we hit a non-matching frame, any subsequent frames won't be removed even if
|
||||
# they do match.)
|
||||
allocatorFns = [
|
||||
# Matches malloc, replace_malloc, moz_xmalloc, vpx_malloc, js_malloc, pod_malloc, malloc_zone_*, g_malloc.
|
||||
'malloc',
|
||||
# Matches calloc, replace_calloc, moz_xcalloc, vpx_calloc, js_calloc, pod_calloc, malloc_zone_calloc, pod_callocCanGC.
|
||||
'calloc',
|
||||
# Matches realloc, replace_realloc, moz_xrealloc, vpx_realloc, js_realloc, pod_realloc, pod_reallocCanGC.
|
||||
'realloc',
|
||||
# Matches memalign, posix_memalign, replace_memalign, replace_posix_memalign, moz_xmemalign, moz_xposix_memalign, vpx_memalign, malloc_zone_memalign.
|
||||
'memalign',
|
||||
'operator new(',
|
||||
'operator new[](',
|
||||
'g_slice_alloc',
|
||||
# This one necessary to fully filter some sequences of allocation functions
|
||||
# that happen in practice. Note that ??? entries that follow non-allocation
|
||||
# functions won't be stripped, as explained above.
|
||||
'???',
|
||||
]
|
||||
|
||||
class Record(object):
|
||||
'''A record is an aggregation of heap blocks that have identical stack
|
||||
traces. It can also be used to represent the difference between two
|
||||
records.'''
|
||||
|
||||
def __init__(self):
|
||||
self.numBlocks = 0
|
||||
self.reqSize = 0
|
||||
self.slopSize = 0
|
||||
self.usableSize = 0
|
||||
self.allocatedAtDesc = None
|
||||
self.reportedAtDescs = []
|
||||
self.usableSizes = collections.defaultdict(int)
|
||||
|
||||
def isZero(self, args):
|
||||
return self.numBlocks == 0 and \
|
||||
self.reqSize == 0 and \
|
||||
self.slopSize == 0 and \
|
||||
self.usableSize == 0 and \
|
||||
len(self.usableSizes) == 0
|
||||
|
||||
def negate(self):
|
||||
self.numBlocks = -self.numBlocks
|
||||
self.reqSize = -self.reqSize
|
||||
self.slopSize = -self.slopSize
|
||||
self.usableSize = -self.usableSize
|
||||
|
||||
negatedUsableSizes = collections.defaultdict(int)
|
||||
for usableSize, count in self.usableSizes.items():
|
||||
negatedUsableSizes[-usableSize] = count
|
||||
self.usableSizes = negatedUsableSizes
|
||||
|
||||
def subtract(self, r):
|
||||
# We should only be calling this on records with matching stack traces.
|
||||
# Check this.
|
||||
assert self.allocatedAtDesc == r.allocatedAtDesc
|
||||
assert self.reportedAtDescs == r.reportedAtDescs
|
||||
|
||||
self.numBlocks -= r.numBlocks
|
||||
self.reqSize -= r.reqSize
|
||||
self.slopSize -= r.slopSize
|
||||
self.usableSize -= r.usableSize
|
||||
|
||||
usableSizes1 = self.usableSizes
|
||||
usableSizes2 = r.usableSizes
|
||||
usableSizes3 = collections.defaultdict(int)
|
||||
for usableSize in usableSizes1:
|
||||
counts1 = usableSizes1[usableSize]
|
||||
if usableSize in usableSizes2:
|
||||
counts2 = usableSizes2[usableSize]
|
||||
del usableSizes2[usableSize]
|
||||
counts3 = counts1 - counts2
|
||||
if counts3 != 0:
|
||||
if counts3 < 0:
|
||||
usableSize = -usableSize
|
||||
counts3 = -counts3
|
||||
usableSizes3[usableSize] = counts3
|
||||
else:
|
||||
usableSizes3[usableSize] = counts1
|
||||
|
||||
for usableSize in usableSizes2:
|
||||
usableSizes3[-usableSize] = usableSizes2[usableSize]
|
||||
|
||||
self.usableSizes = usableSizes3
|
||||
|
||||
@staticmethod
|
||||
def cmpByUsableSize(r1, r2):
|
||||
# Sort by usable size, then by req size.
|
||||
return cmp(abs(r1.usableSize), abs(r2.usableSize)) or \
|
||||
Record.cmpByReqSize(r1, r2)
|
||||
|
||||
@staticmethod
|
||||
def cmpByReqSize(r1, r2):
|
||||
# Sort by req size.
|
||||
return cmp(abs(r1.reqSize), abs(r2.reqSize))
|
||||
|
||||
@staticmethod
|
||||
def cmpBySlopSize(r1, r2):
|
||||
# Sort by slop size.
|
||||
return cmp(abs(r1.slopSize), abs(r2.slopSize))
|
||||
|
||||
@staticmethod
|
||||
def cmpByNumBlocks(r1, r2):
|
||||
# Sort by block counts, then by usable size.
|
||||
return cmp(abs(r1.numBlocks), abs(r2.numBlocks)) or \
|
||||
Record.cmpByUsableSize(r1, r2)
|
||||
|
||||
|
||||
sortByChoices = {
|
||||
'usable': Record.cmpByUsableSize, # the default
|
||||
'req': Record.cmpByReqSize,
|
||||
'slop': Record.cmpBySlopSize,
|
||||
'num-blocks': Record.cmpByNumBlocks,
|
||||
}
|
||||
|
||||
|
||||
def parseCommandLine():
|
||||
# 24 is the maximum number of frames that DMD will produce.
|
||||
def range_1_24(string):
|
||||
value = int(string)
|
||||
if value < 1 or value > 24:
|
||||
msg = '{:s} is not in the range 1..24'.format(string)
|
||||
raise argparse.ArgumentTypeError(msg)
|
||||
return value
|
||||
|
||||
description = '''
|
||||
Analyze heap data produced by DMD.
|
||||
If one file is specified, analyze it; if two files are specified, analyze the
|
||||
difference.
|
||||
Input files can be gzipped.
|
||||
Write to stdout unless -o/--output is specified.
|
||||
Stack traces are fixed to show function names, filenames and line numbers
|
||||
unless --no-fix-stacks is specified; stack fixing modifies the original file
|
||||
and may take some time. If specified, the BREAKPAD_SYMBOLS_PATH environment
|
||||
variable is used to find breakpad symbols for stack fixing.
|
||||
'''
|
||||
p = argparse.ArgumentParser(description=description)
|
||||
|
||||
p.add_argument('-o', '--output', type=argparse.FileType('w'),
|
||||
help='output file; stdout if unspecified')
|
||||
|
||||
p.add_argument('-f', '--max-frames', type=range_1_24,
|
||||
help='maximum number of frames to consider in each trace')
|
||||
|
||||
p.add_argument('-s', '--sort-by', choices=sortByChoices.keys(),
|
||||
default='usable',
|
||||
help='sort the records by a particular metric')
|
||||
|
||||
p.add_argument('-a', '--ignore-alloc-fns', action='store_true',
|
||||
help='ignore allocation functions at the start of traces')
|
||||
|
||||
p.add_argument('--no-fix-stacks', action='store_true',
|
||||
help='do not fix stacks')
|
||||
|
||||
p.add_argument('--clamp-contents', action='store_true',
|
||||
help='for a scan mode log, clamp addresses to the start of live blocks, or zero if not in one')
|
||||
|
||||
p.add_argument('--print-clamp-stats', action='store_true',
|
||||
help='print information about the results of pointer clamping; mostly useful for debugging clamping')
|
||||
|
||||
p.add_argument('--filter-stacks-for-testing', action='store_true',
|
||||
help='filter stack traces; only useful for testing purposes')
|
||||
|
||||
p.add_argument('input_file',
|
||||
help='a file produced by DMD')
|
||||
|
||||
p.add_argument('input_file2', nargs='?',
|
||||
help='a file produced by DMD; if present, it is diff\'d with input_file')
|
||||
|
||||
return p.parse_args(sys.argv[1:])
|
||||
|
||||
|
||||
# Fix stacks if necessary: first write the output to a tempfile, then replace
|
||||
# the original file with it.
|
||||
def fixStackTraces(inputFilename, isZipped, opener):
|
||||
# This append() call is needed to make the import statements work when this
|
||||
# script is installed as a symlink.
|
||||
sys.path.append(os.path.dirname(__file__))
|
||||
|
||||
bpsyms = os.environ.get('BREAKPAD_SYMBOLS_PATH', None)
|
||||
sysname = platform.system()
|
||||
if bpsyms and os.path.exists(bpsyms):
|
||||
import fix_stack_using_bpsyms as fixModule
|
||||
fix = lambda line: fixModule.fixSymbols(line, bpsyms)
|
||||
elif sysname == 'Linux':
|
||||
import fix_linux_stack as fixModule
|
||||
fix = lambda line: fixModule.fixSymbols(line)
|
||||
elif sysname == 'Darwin':
|
||||
import fix_macosx_stack as fixModule
|
||||
fix = lambda line: fixModule.fixSymbols(line)
|
||||
else:
|
||||
fix = None # there is no fix script for Windows
|
||||
|
||||
if fix:
|
||||
# Fix stacks, writing output to a temporary file, and then
|
||||
# overwrite the original file.
|
||||
tmpFile = tempfile.NamedTemporaryFile(delete=False)
|
||||
|
||||
# If the input is gzipped, then the output (written initially to
|
||||
# |tmpFile|) should be gzipped as well.
|
||||
#
|
||||
# And we want to set its pre-gzipped filename to '' rather than the
|
||||
# name of the temporary file, so that programs like the Unix 'file'
|
||||
# utility don't say that it was called 'tmp6ozTxE' (or something like
|
||||
# that) before it was zipped. So that explains the |filename=''|
|
||||
# parameter.
|
||||
#
|
||||
# But setting the filename like that clobbers |tmpFile.name|, so we
|
||||
# must get that now in order to move |tmpFile| at the end.
|
||||
tmpFilename = tmpFile.name
|
||||
if isZipped:
|
||||
tmpFile = gzip.GzipFile(filename='', fileobj=tmpFile)
|
||||
|
||||
with opener(inputFilename, 'rb') as inputFile:
|
||||
for line in inputFile:
|
||||
tmpFile.write(fix(line))
|
||||
|
||||
tmpFile.close()
|
||||
|
||||
shutil.move(tmpFilename, inputFilename)
|
||||
|
||||
|
||||
def getDigestFromFile(args, inputFile):
|
||||
# Handle gzipped input if necessary.
|
||||
isZipped = inputFile.endswith('.gz')
|
||||
opener = gzip.open if isZipped else open
|
||||
|
||||
# Fix stack traces unless otherwise instructed.
|
||||
if not args.no_fix_stacks:
|
||||
fixStackTraces(inputFile, isZipped, opener)
|
||||
|
||||
if args.clamp_contents:
|
||||
clampBlockList(args, inputFile, isZipped, opener)
|
||||
|
||||
with opener(inputFile, 'rb') as f:
|
||||
j = json.load(f)
|
||||
|
||||
if j['version'] != outputVersion:
|
||||
raise Exception("'version' property isn't '{:d}'".format(outputVersion))
|
||||
|
||||
# Extract the main parts of the JSON object.
|
||||
invocation = j['invocation']
|
||||
dmdEnvVar = invocation['dmdEnvVar']
|
||||
mode = invocation['mode']
|
||||
blockList = j['blockList']
|
||||
traceTable = j['traceTable']
|
||||
frameTable = j['frameTable']
|
||||
|
||||
# Insert the necessary entries for unrecorded stack traces. Note that 'ut'
|
||||
# and 'uf' will not overlap with any keys produced by DMD's
|
||||
# ToIdStringConverter::Base32() function.
|
||||
unrecordedTraceID = 'ut'
|
||||
unrecordedFrameID = 'uf'
|
||||
traceTable[unrecordedTraceID] = [unrecordedFrameID]
|
||||
frameTable[unrecordedFrameID] = \
|
||||
'#00: (no stack trace recorded due to --stacks=partial)'
|
||||
|
||||
# For the purposes of this script, 'scan' behaves like 'live'.
|
||||
if mode == 'scan':
|
||||
mode = 'live'
|
||||
|
||||
if not mode in ['live', 'dark-matter', 'cumulative']:
|
||||
raise Exception("bad 'mode' property: '{:s}'".format(mode))
|
||||
|
||||
# Remove allocation functions at the start of traces.
|
||||
if args.ignore_alloc_fns:
|
||||
# Build a regexp that matches every function in allocatorFns.
|
||||
escapedAllocatorFns = map(re.escape, allocatorFns)
|
||||
fn_re = re.compile('|'.join(escapedAllocatorFns))
|
||||
|
||||
# Remove allocator fns from each stack trace.
|
||||
for traceKey, frameKeys in traceTable.items():
|
||||
numSkippedFrames = 0
|
||||
for frameKey in frameKeys:
|
||||
frameDesc = frameTable[frameKey]
|
||||
if re.search(fn_re, frameDesc):
|
||||
numSkippedFrames += 1
|
||||
else:
|
||||
break
|
||||
if numSkippedFrames > 0:
|
||||
traceTable[traceKey] = frameKeys[numSkippedFrames:]
|
||||
|
||||
# Trim the number of frames.
|
||||
for traceKey, frameKeys in traceTable.items():
|
||||
if len(frameKeys) > args.max_frames:
|
||||
traceTable[traceKey] = frameKeys[:args.max_frames]
|
||||
|
||||
def buildTraceDescription(traceTable, frameTable, traceKey):
|
||||
frameKeys = traceTable[traceKey]
|
||||
fmt = ' #{:02d}{:}'
|
||||
|
||||
if args.filter_stacks_for_testing:
|
||||
# When running SmokeDMD.cpp, every stack trace should contain at
|
||||
# least one frame that contains 'DMD.cpp', from either |DMD.cpp| or
|
||||
# |SmokeDMD.cpp|. (Or 'dmd.cpp' on Windows.) If we see such a
|
||||
# frame, we replace the entire stack trace with a single,
|
||||
# predictable frame. There is too much variation in the stack
|
||||
# traces across different machines and platforms to do more precise
|
||||
# matching, but this level of matching will result in failure if
|
||||
# stack fixing fails completely.
|
||||
for frameKey in frameKeys:
|
||||
frameDesc = frameTable[frameKey]
|
||||
if 'DMD.cpp' in frameDesc or 'dmd.cpp' in frameDesc:
|
||||
return [fmt.format(1, ': ... DMD.cpp ...')]
|
||||
|
||||
# The frame number is always '#00' (see DMD.h for why), so we have to
|
||||
# replace that with the correct frame number.
|
||||
desc = []
|
||||
for n, frameKey in enumerate(traceTable[traceKey], start=1):
|
||||
desc.append(fmt.format(n, frameTable[frameKey][3:]))
|
||||
return desc
|
||||
|
||||
# Aggregate blocks into records. All sufficiently similar blocks go into a
|
||||
# single record.
|
||||
|
||||
if mode in ['live', 'cumulative']:
|
||||
liveOrCumulativeRecords = collections.defaultdict(Record)
|
||||
elif mode == 'dark-matter':
|
||||
unreportedRecords = collections.defaultdict(Record)
|
||||
onceReportedRecords = collections.defaultdict(Record)
|
||||
twiceReportedRecords = collections.defaultdict(Record)
|
||||
|
||||
heapUsableSize = 0
|
||||
heapBlocks = 0
|
||||
|
||||
recordKeyPartCache = {}
|
||||
|
||||
for block in blockList:
|
||||
# For each block we compute a |recordKey|, and all blocks with the same
|
||||
# |recordKey| are aggregated into a single record. The |recordKey| is
|
||||
# derived from the block's 'alloc' and 'reps' (if present) stack
|
||||
# traces.
|
||||
#
|
||||
# We use frame descriptions (e.g. "#00: foo (X.cpp:99)") when comparing
|
||||
# traces for equality. We can't use trace keys or frame keys because
|
||||
# they're not comparable across different DMD runs (which is relevant
|
||||
# when doing diffs).
|
||||
#
|
||||
# Using frame descriptions also fits in with the stack trimming done
|
||||
# for --max-frames, which requires that stack traces with common
|
||||
# beginnings but different endings to be considered equivalent. E.g. if
|
||||
# we have distinct traces T1:[A:D1,B:D2,C:D3] and T2:[X:D1,Y:D2,Z:D4]
|
||||
# and we trim the final frame of each they should be considered
|
||||
# equivalent because the untrimmed frame descriptions (D1 and D2)
|
||||
# match.
|
||||
#
|
||||
# Having said all that, during a single invocation of dmd.py on a
|
||||
# single DMD file, for a single frameKey value the record key will
|
||||
# always be the same, and we might encounter it 1000s of times. So we
|
||||
# cache prior results for speed.
|
||||
def makeRecordKeyPart(traceKey):
|
||||
if traceKey in recordKeyPartCache:
|
||||
return recordKeyPartCache[traceKey]
|
||||
|
||||
recordKeyPart = str(map(lambda frameKey: frameTable[frameKey],
|
||||
traceTable[traceKey]))
|
||||
recordKeyPartCache[traceKey] = recordKeyPart
|
||||
return recordKeyPart
|
||||
|
||||
allocatedAtTraceKey = block.get('alloc', unrecordedTraceID)
|
||||
if mode in ['live', 'cumulative']:
|
||||
recordKey = makeRecordKeyPart(allocatedAtTraceKey)
|
||||
records = liveOrCumulativeRecords
|
||||
elif mode == 'dark-matter':
|
||||
recordKey = makeRecordKeyPart(allocatedAtTraceKey)
|
||||
if 'reps' in block:
|
||||
reportedAtTraceKeys = block['reps']
|
||||
for reportedAtTraceKey in reportedAtTraceKeys:
|
||||
recordKey += makeRecordKeyPart(reportedAtTraceKey)
|
||||
if len(reportedAtTraceKeys) == 1:
|
||||
records = onceReportedRecords
|
||||
else:
|
||||
records = twiceReportedRecords
|
||||
else:
|
||||
records = unreportedRecords
|
||||
|
||||
record = records[recordKey]
|
||||
|
||||
if 'req' not in block:
|
||||
raise Exception("'req' property missing in block'")
|
||||
|
||||
reqSize = block['req']
|
||||
slopSize = block.get('slop', 0)
|
||||
|
||||
if 'num' in block:
|
||||
num = block['num']
|
||||
else:
|
||||
num = 1
|
||||
|
||||
usableSize = reqSize + slopSize
|
||||
heapUsableSize += num * usableSize
|
||||
heapBlocks += num
|
||||
|
||||
record.numBlocks += num
|
||||
record.reqSize += num * reqSize
|
||||
record.slopSize += num * slopSize
|
||||
record.usableSize += num * usableSize
|
||||
if record.allocatedAtDesc == None:
|
||||
record.allocatedAtDesc = \
|
||||
buildTraceDescription(traceTable, frameTable,
|
||||
allocatedAtTraceKey)
|
||||
|
||||
if mode in ['live', 'cumulative']:
|
||||
pass
|
||||
elif mode == 'dark-matter':
|
||||
if 'reps' in block and record.reportedAtDescs == []:
|
||||
f = lambda k: buildTraceDescription(traceTable, frameTable, k)
|
||||
record.reportedAtDescs = map(f, reportedAtTraceKeys)
|
||||
record.usableSizes[usableSize] += num
|
||||
|
||||
# All the processed data for a single DMD file is called a "digest".
|
||||
digest = {}
|
||||
digest['dmdEnvVar'] = dmdEnvVar
|
||||
digest['mode'] = mode
|
||||
digest['heapUsableSize'] = heapUsableSize
|
||||
digest['heapBlocks'] = heapBlocks
|
||||
if mode in ['live', 'cumulative']:
|
||||
digest['liveOrCumulativeRecords'] = liveOrCumulativeRecords
|
||||
elif mode == 'dark-matter':
|
||||
digest['unreportedRecords'] = unreportedRecords
|
||||
digest['onceReportedRecords'] = onceReportedRecords
|
||||
digest['twiceReportedRecords'] = twiceReportedRecords
|
||||
return digest
|
||||
|
||||
|
||||
def diffRecords(args, records1, records2):
|
||||
records3 = {}
|
||||
|
||||
# Process records1.
|
||||
for k in records1:
|
||||
r1 = records1[k]
|
||||
if k in records2:
|
||||
# This record is present in both records1 and records2.
|
||||
r2 = records2[k]
|
||||
del records2[k]
|
||||
r2.subtract(r1)
|
||||
if not r2.isZero(args):
|
||||
records3[k] = r2
|
||||
else:
|
||||
# This record is present only in records1.
|
||||
r1.negate()
|
||||
records3[k] = r1
|
||||
|
||||
for k in records2:
|
||||
# This record is present only in records2.
|
||||
records3[k] = records2[k]
|
||||
|
||||
return records3
|
||||
|
||||
|
||||
def diffDigests(args, d1, d2):
|
||||
if (d1['mode'] != d2['mode']):
|
||||
raise Exception("the input files have different 'mode' properties")
|
||||
|
||||
d3 = {}
|
||||
d3['dmdEnvVar'] = (d1['dmdEnvVar'], d2['dmdEnvVar'])
|
||||
d3['mode'] = d1['mode']
|
||||
d3['heapUsableSize'] = d2['heapUsableSize'] - d1['heapUsableSize']
|
||||
d3['heapBlocks'] = d2['heapBlocks'] - d1['heapBlocks']
|
||||
if d1['mode'] in ['live', 'cumulative']:
|
||||
d3['liveOrCumulativeRecords'] = \
|
||||
diffRecords(args, d1['liveOrCumulativeRecords'],
|
||||
d2['liveOrCumulativeRecords'])
|
||||
elif d1['mode'] == 'dark-matter':
|
||||
d3['unreportedRecords'] = diffRecords(args, d1['unreportedRecords'],
|
||||
d2['unreportedRecords'])
|
||||
d3['onceReportedRecords'] = diffRecords(args, d1['onceReportedRecords'],
|
||||
d2['onceReportedRecords'])
|
||||
d3['twiceReportedRecords'] = diffRecords(args, d1['twiceReportedRecords'],
|
||||
d2['twiceReportedRecords'])
|
||||
return d3
|
||||
|
||||
|
||||
def printDigest(args, digest):
|
||||
dmdEnvVar = digest['dmdEnvVar']
|
||||
mode = digest['mode']
|
||||
heapUsableSize = digest['heapUsableSize']
|
||||
heapBlocks = digest['heapBlocks']
|
||||
if mode in ['live', 'cumulative']:
|
||||
liveOrCumulativeRecords = digest['liveOrCumulativeRecords']
|
||||
elif mode == 'dark-matter':
|
||||
unreportedRecords = digest['unreportedRecords']
|
||||
onceReportedRecords = digest['onceReportedRecords']
|
||||
twiceReportedRecords = digest['twiceReportedRecords']
|
||||
|
||||
separator = '#' + '-' * 65 + '\n'
|
||||
|
||||
def number(n):
|
||||
'''Format a number with comma as a separator.'''
|
||||
return '{:,d}'.format(n)
|
||||
|
||||
def perc(m, n):
|
||||
return 0 if n == 0 else (100 * m / n)
|
||||
|
||||
def plural(n):
|
||||
return '' if n == 1 else 's'
|
||||
|
||||
# Prints to stdout, or to file if -o/--output was specified.
|
||||
def out(*arguments, **kwargs):
|
||||
print(*arguments, file=args.output, **kwargs)
|
||||
|
||||
def printStack(traceDesc):
|
||||
for frameDesc in traceDesc:
|
||||
out(frameDesc)
|
||||
|
||||
def printRecords(recordKind, records, heapUsableSize):
|
||||
RecordKind = recordKind.capitalize()
|
||||
out(separator)
|
||||
numRecords = len(records)
|
||||
cmpRecords = sortByChoices[args.sort_by]
|
||||
sortedRecords = sorted(records.values(), cmp=cmpRecords, reverse=True)
|
||||
kindBlocks = 0
|
||||
kindUsableSize = 0
|
||||
maxRecord = 1000
|
||||
|
||||
# First iteration: get totals, etc.
|
||||
for record in sortedRecords:
|
||||
kindBlocks += record.numBlocks
|
||||
kindUsableSize += record.usableSize
|
||||
|
||||
# Second iteration: print.
|
||||
if numRecords == 0:
|
||||
out('# no {:} heap blocks\n'.format(recordKind))
|
||||
|
||||
kindCumulativeUsableSize = 0
|
||||
for i, record in enumerate(sortedRecords, start=1):
|
||||
# Stop printing at the |maxRecord|th record.
|
||||
if i == maxRecord:
|
||||
out('# {:}: stopping after {:,d} heap block records\n'.
|
||||
format(RecordKind, i))
|
||||
break
|
||||
|
||||
kindCumulativeUsableSize += record.usableSize
|
||||
|
||||
out(RecordKind + ' {')
|
||||
out(' {:} block{:} in heap block record {:,d} of {:,d}'.
|
||||
format(number(record.numBlocks),
|
||||
plural(record.numBlocks), i, numRecords))
|
||||
out(' {:} bytes ({:} requested / {:} slop)'.
|
||||
format(number(record.usableSize),
|
||||
number(record.reqSize),
|
||||
number(record.slopSize)))
|
||||
|
||||
abscmp = lambda (usableSize1, _1), (usableSize2, _2): \
|
||||
cmp(abs(usableSize1), abs(usableSize2))
|
||||
usableSizes = sorted(record.usableSizes.items(), cmp=abscmp,
|
||||
reverse=True)
|
||||
|
||||
hasSingleBlock = len(usableSizes) == 1 and usableSizes[0][1] == 1
|
||||
|
||||
if not hasSingleBlock:
|
||||
out(' Individual block sizes: ', end='')
|
||||
if len(usableSizes) == 0:
|
||||
out('(no change)', end='')
|
||||
else:
|
||||
isFirst = True
|
||||
for usableSize, count in usableSizes:
|
||||
if not isFirst:
|
||||
out('; ', end='')
|
||||
out('{:}'.format(number(usableSize)), end='')
|
||||
if count > 1:
|
||||
out(' x {:,d}'.format(count), end='')
|
||||
isFirst = False
|
||||
out()
|
||||
|
||||
out(' {:4.2f}% of the heap ({:4.2f}% cumulative)'.
|
||||
format(perc(record.usableSize, heapUsableSize),
|
||||
perc(kindCumulativeUsableSize, heapUsableSize)))
|
||||
if mode in ['live', 'cumulative']:
|
||||
pass
|
||||
elif mode == 'dark-matter':
|
||||
out(' {:4.2f}% of {:} ({:4.2f}% cumulative)'.
|
||||
format(perc(record.usableSize, kindUsableSize),
|
||||
recordKind,
|
||||
perc(kindCumulativeUsableSize, kindUsableSize)))
|
||||
out(' Allocated at {')
|
||||
printStack(record.allocatedAtDesc)
|
||||
out(' }')
|
||||
if mode in ['live', 'cumulative']:
|
||||
pass
|
||||
elif mode == 'dark-matter':
|
||||
for n, reportedAtDesc in enumerate(record.reportedAtDescs):
|
||||
again = 'again ' if n > 0 else ''
|
||||
out(' Reported {:}at {{'.format(again))
|
||||
printStack(reportedAtDesc)
|
||||
out(' }')
|
||||
out('}\n')
|
||||
|
||||
return (kindUsableSize, kindBlocks)
|
||||
|
||||
|
||||
def printInvocation(n, dmdEnvVar, mode):
|
||||
out('Invocation{:} {{'.format(n))
|
||||
if dmdEnvVar == None:
|
||||
out(' $DMD is undefined')
|
||||
else:
|
||||
out(' $DMD = \'' + dmdEnvVar + '\'')
|
||||
out(' Mode = \'' + mode + '\'')
|
||||
out('}\n')
|
||||
|
||||
# Print command line. Strip dirs so the output is deterministic, which is
|
||||
# needed for testing.
|
||||
out(separator, end='')
|
||||
out('# ' + ' '.join(map(os.path.basename, sys.argv)) + '\n')
|
||||
|
||||
# Print invocation(s).
|
||||
if type(dmdEnvVar) is not tuple:
|
||||
printInvocation('', dmdEnvVar, mode)
|
||||
else:
|
||||
printInvocation(' 1', dmdEnvVar[0], mode)
|
||||
printInvocation(' 2', dmdEnvVar[1], mode)
|
||||
|
||||
# Print records.
|
||||
if mode in ['live', 'cumulative']:
|
||||
liveOrCumulativeUsableSize, liveOrCumulativeBlocks = \
|
||||
printRecords(mode, liveOrCumulativeRecords, heapUsableSize)
|
||||
elif mode == 'dark-matter':
|
||||
twiceReportedUsableSize, twiceReportedBlocks = \
|
||||
printRecords('twice-reported', twiceReportedRecords, heapUsableSize)
|
||||
|
||||
unreportedUsableSize, unreportedBlocks = \
|
||||
printRecords('unreported', unreportedRecords, heapUsableSize)
|
||||
|
||||
onceReportedUsableSize, onceReportedBlocks = \
|
||||
printRecords('once-reported', onceReportedRecords, heapUsableSize)
|
||||
|
||||
# Print summary.
|
||||
out(separator)
|
||||
out('Summary {')
|
||||
if mode in ['live', 'cumulative']:
|
||||
out(' Total: {:} bytes in {:} blocks'.
|
||||
format(number(liveOrCumulativeUsableSize),
|
||||
number(liveOrCumulativeBlocks)))
|
||||
elif mode == 'dark-matter':
|
||||
fmt = ' {:15} {:>12} bytes ({:6.2f}%) in {:>7} blocks ({:6.2f}%)'
|
||||
out(fmt.
|
||||
format('Total:',
|
||||
number(heapUsableSize),
|
||||
100,
|
||||
number(heapBlocks),
|
||||
100))
|
||||
out(fmt.
|
||||
format('Unreported:',
|
||||
number(unreportedUsableSize),
|
||||
perc(unreportedUsableSize, heapUsableSize),
|
||||
number(unreportedBlocks),
|
||||
perc(unreportedBlocks, heapBlocks)))
|
||||
out(fmt.
|
||||
format('Once-reported:',
|
||||
number(onceReportedUsableSize),
|
||||
perc(onceReportedUsableSize, heapUsableSize),
|
||||
number(onceReportedBlocks),
|
||||
perc(onceReportedBlocks, heapBlocks)))
|
||||
out(fmt.
|
||||
format('Twice-reported:',
|
||||
number(twiceReportedUsableSize),
|
||||
perc(twiceReportedUsableSize, heapUsableSize),
|
||||
number(twiceReportedBlocks),
|
||||
perc(twiceReportedBlocks, heapBlocks)))
|
||||
out('}\n')
|
||||
|
||||
|
||||
#############################
|
||||
# Pretty printer for DMD JSON
|
||||
#############################
|
||||
|
||||
def prettyPrintDmdJson(out, j):
|
||||
out.write('{\n')
|
||||
|
||||
out.write(' "version": {0},\n'.format(j['version']))
|
||||
out.write(' "invocation": ')
|
||||
json.dump(j['invocation'], out, sort_keys=True)
|
||||
out.write(',\n')
|
||||
|
||||
out.write(' "blockList": [')
|
||||
first = True
|
||||
for b in j['blockList']:
|
||||
out.write('' if first else ',')
|
||||
out.write('\n ')
|
||||
json.dump(b, out, sort_keys=True)
|
||||
first = False
|
||||
out.write('\n ],\n')
|
||||
|
||||
out.write(' "traceTable": {')
|
||||
first = True
|
||||
for k, l in j['traceTable'].iteritems():
|
||||
out.write('' if first else ',')
|
||||
out.write('\n "{0}": {1}'.format(k, json.dumps(l)))
|
||||
first = False
|
||||
out.write('\n },\n')
|
||||
|
||||
out.write(' "frameTable": {')
|
||||
first = True
|
||||
for k, v in j['frameTable'].iteritems():
|
||||
out.write('' if first else ',')
|
||||
out.write('\n "{0}": {1}'.format(k, json.dumps(v)))
|
||||
first = False
|
||||
out.write('\n }\n')
|
||||
|
||||
out.write('}\n')
|
||||
|
||||
|
||||
##################################################################
|
||||
# Code for clamping addresses using conservative pointer analysis.
|
||||
##################################################################
|
||||
|
||||
# Start is the address of the first byte of the block, while end is
|
||||
# the address of the first byte after the final byte in the block.
|
||||
class AddrRange:
|
||||
def __init__(self, block, length):
|
||||
self.block = block
|
||||
self.start = int(block, 16)
|
||||
self.length = length
|
||||
self.end = self.start + self.length
|
||||
|
||||
assert self.start > 0
|
||||
assert length >= 0
|
||||
|
||||
|
||||
class ClampStats:
|
||||
def __init__(self):
|
||||
# Number of pointers already pointing to the start of a block.
|
||||
self.startBlockPtr = 0
|
||||
|
||||
# Number of pointers pointing to the middle of a block. These
|
||||
# are clamped to the start of the block they point into.
|
||||
self.midBlockPtr = 0
|
||||
|
||||
# Number of null pointers.
|
||||
self.nullPtr = 0
|
||||
|
||||
# Number of non-null pointers that didn't point into the middle
|
||||
# of any blocks. These are clamped to null.
|
||||
self.nonNullNonBlockPtr = 0
|
||||
|
||||
|
||||
def clampedBlockAddr(self, sameAddress):
|
||||
if sameAddress:
|
||||
self.startBlockPtr += 1
|
||||
else:
|
||||
self.midBlockPtr += 1
|
||||
|
||||
def nullAddr(self):
|
||||
self.nullPtr += 1
|
||||
|
||||
def clampedNonBlockAddr(self):
|
||||
self.nonNullNonBlockPtr += 1
|
||||
|
||||
def log(self):
|
||||
sys.stderr.write('Results:\n')
|
||||
sys.stderr.write(' Number of pointers already pointing to start of blocks: ' + str(self.startBlockPtr) + '\n')
|
||||
sys.stderr.write(' Number of pointers clamped to start of blocks: ' + str(self.midBlockPtr) + '\n')
|
||||
sys.stderr.write(' Number of non-null pointers not pointing into blocks clamped to null: ' + str(self.nonNullNonBlockPtr) + '\n')
|
||||
sys.stderr.write(' Number of null pointers: ' + str(self.nullPtr) + '\n')
|
||||
|
||||
|
||||
# Search the block ranges array for a block that address points into.
|
||||
# The search is carried out in an array of starting addresses for each blocks
|
||||
# because it is faster.
|
||||
def clampAddress(blockRanges, blockStarts, clampStats, address):
|
||||
i = bisect_right(blockStarts, address)
|
||||
|
||||
# Any addresses completely out of the range should have been eliminated already.
|
||||
assert i > 0
|
||||
r = blockRanges[i - 1]
|
||||
assert r.start <= address
|
||||
|
||||
if address >= r.end:
|
||||
assert address < blockRanges[i].start
|
||||
clampStats.clampedNonBlockAddr()
|
||||
return '0'
|
||||
|
||||
clampStats.clampedBlockAddr(r.start == address)
|
||||
return r.block
|
||||
|
||||
|
||||
def clampBlockList(args, inputFileName, isZipped, opener):
|
||||
# XXX This isn't very efficient because we end up reading and writing
|
||||
# the file multiple times.
|
||||
with opener(inputFileName, 'rb') as f:
|
||||
j = json.load(f)
|
||||
|
||||
if j['version'] != outputVersion:
|
||||
raise Exception("'version' property isn't '{:d}'".format(outputVersion))
|
||||
|
||||
# Check that the invocation is reasonable for contents clamping.
|
||||
invocation = j['invocation']
|
||||
if invocation['mode'] != 'scan':
|
||||
raise Exception("Log was taken in mode " + invocation['mode'] + " not scan")
|
||||
|
||||
sys.stderr.write('Creating block range list.\n')
|
||||
blockList = j['blockList']
|
||||
blockRanges = []
|
||||
for block in blockList:
|
||||
blockRanges.append(AddrRange(block['addr'], block['req']))
|
||||
blockRanges.sort(key=lambda r: r.start)
|
||||
|
||||
# Make sure there are no overlapping blocks.
|
||||
prevRange = blockRanges[0]
|
||||
for currRange in blockRanges[1:]:
|
||||
assert prevRange.end <= currRange.start
|
||||
prevRange = currRange
|
||||
|
||||
sys.stderr.write('Clamping block contents.\n')
|
||||
clampStats = ClampStats()
|
||||
firstAddr = blockRanges[0].start
|
||||
lastAddr = blockRanges[-1].end
|
||||
|
||||
blockStarts = []
|
||||
for r in blockRanges:
|
||||
blockStarts.append(r.start)
|
||||
|
||||
for block in blockList:
|
||||
# Small blocks don't have any contents.
|
||||
if not 'contents' in block:
|
||||
continue
|
||||
|
||||
cont = block['contents']
|
||||
for i in range(len(cont)):
|
||||
address = int(cont[i], 16)
|
||||
|
||||
if address == 0:
|
||||
clampStats.nullAddr()
|
||||
continue
|
||||
|
||||
# If the address is before the first block or after the last
|
||||
# block then it can't be within a block.
|
||||
if address < firstAddr or address >= lastAddr:
|
||||
clampStats.clampedNonBlockAddr()
|
||||
cont[i] = '0'
|
||||
continue
|
||||
|
||||
cont[i] = clampAddress(blockRanges, blockStarts, clampStats, address)
|
||||
|
||||
# Remove any trailing nulls.
|
||||
while len(cont) and cont[-1] == '0':
|
||||
cont.pop()
|
||||
|
||||
if args.print_clamp_stats:
|
||||
clampStats.log()
|
||||
|
||||
sys.stderr.write('Saving file.\n')
|
||||
tmpFile = tempfile.NamedTemporaryFile(delete=False)
|
||||
tmpFilename = tmpFile.name
|
||||
if isZipped:
|
||||
tmpFile = gzip.GzipFile(filename='', fileobj=tmpFile)
|
||||
prettyPrintDmdJson(tmpFile, j)
|
||||
tmpFile.close()
|
||||
shutil.move(tmpFilename, inputFileName)
|
||||
|
||||
|
||||
def main():
|
||||
args = parseCommandLine()
|
||||
digest = getDigestFromFile(args, args.input_file)
|
||||
if args.input_file2:
|
||||
digest2 = getDigestFromFile(args, args.input_file2)
|
||||
digest = diffDigests(args, digest, digest2)
|
||||
printDigest(args, digest)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
|
||||
|
|
@ -1,39 +0,0 @@
|
|||
# -*- Mode: python; 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/.
|
||||
|
||||
EXPORTS += [
|
||||
'DMD.h',
|
||||
]
|
||||
|
||||
SOURCES += [
|
||||
'../../../mfbt/HashFunctions.cpp',
|
||||
'../../../mfbt/JSONWriter.cpp',
|
||||
'../../../mfbt/Poison.cpp',
|
||||
'../../../mozglue/misc/StackWalk.cpp',
|
||||
'DMD.cpp',
|
||||
]
|
||||
|
||||
SOURCES += [
|
||||
'../../../nsprpub/lib/libc/src/strcpy.c',
|
||||
]
|
||||
|
||||
SharedLibrary('dmd')
|
||||
|
||||
DEFINES['MOZ_NO_MOZALLOC'] = True
|
||||
DEFINES['IMPL_MFBT'] = True
|
||||
DEFINES['XPCOM_GLUE'] = True
|
||||
|
||||
if CONFIG['MOZ_OPTIMIZE']:
|
||||
DEFINES['MOZ_OPTIMIZE'] = True
|
||||
|
||||
DISABLE_STL_WRAPPING = True
|
||||
|
||||
if CONFIG['OS_ARCH'] == 'WINNT':
|
||||
OS_LIBS += [
|
||||
'dbghelp',
|
||||
]
|
||||
|
||||
TEST_DIRS += ['test']
|
||||
|
|
@ -1,379 +0,0 @@
|
|||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim: set ts=8 sts=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/. */
|
||||
|
||||
// This program is used by the DMD xpcshell test. It is run under DMD and
|
||||
// produces some output. The xpcshell test then post-processes and checks this
|
||||
// output.
|
||||
//
|
||||
// Note that this file does not have "Test" or "test" in its name, because that
|
||||
// will cause the build system to not record breakpad symbols for it, which
|
||||
// will stop the post-processing (which includes stack fixing) from working
|
||||
// correctly.
|
||||
|
||||
#include <errno.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "mozilla/Assertions.h"
|
||||
#include "mozilla/JSONWriter.h"
|
||||
#include "mozilla/UniquePtr.h"
|
||||
#include "DMD.h"
|
||||
|
||||
using mozilla::JSONWriter;
|
||||
using mozilla::MakeUnique;
|
||||
using namespace mozilla::dmd;
|
||||
|
||||
DMDFuncs::Singleton DMDFuncs::sSingleton;
|
||||
|
||||
class FpWriteFunc : public mozilla::JSONWriteFunc
|
||||
{
|
||||
public:
|
||||
explicit FpWriteFunc(const char* aFilename)
|
||||
{
|
||||
mFp = fopen(aFilename, "w");
|
||||
if (!mFp) {
|
||||
fprintf(stderr, "SmokeDMD: can't create %s file: %s\n",
|
||||
aFilename, strerror(errno));
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
~FpWriteFunc() { fclose(mFp); }
|
||||
|
||||
void Write(const char* aStr) { fputs(aStr, mFp); }
|
||||
|
||||
private:
|
||||
FILE* mFp;
|
||||
};
|
||||
|
||||
// This stops otherwise-unused variables from being optimized away.
|
||||
static void
|
||||
UseItOrLoseIt(void* aPtr, int aSeven)
|
||||
{
|
||||
char buf[64];
|
||||
int n = sprintf(buf, "%p\n", aPtr);
|
||||
if (n == 20 + aSeven) {
|
||||
fprintf(stderr, "well, that is surprising");
|
||||
}
|
||||
}
|
||||
|
||||
// This function checks that heap blocks that have the same stack trace but
|
||||
// different (or no) reporters get aggregated separately.
|
||||
void Foo(int aSeven)
|
||||
{
|
||||
char* a[6];
|
||||
for (int i = 0; i < aSeven - 1; i++) {
|
||||
a[i] = (char*) malloc(128 - 16*i);
|
||||
}
|
||||
|
||||
// Oddly, some versions of clang will cause identical stack traces to be
|
||||
// generated for adjacent calls to Report(), which breaks the test. Inserting
|
||||
// the UseItOrLoseIt() calls in between is enough to prevent this.
|
||||
|
||||
Report(a[2]); // reported
|
||||
|
||||
UseItOrLoseIt(a[2], aSeven);
|
||||
|
||||
for (int i = 0; i < aSeven - 5; i++) {
|
||||
Report(a[i]); // reported
|
||||
}
|
||||
|
||||
UseItOrLoseIt(a[2], aSeven);
|
||||
|
||||
Report(a[3]); // reported
|
||||
|
||||
// a[4], a[5] unreported
|
||||
}
|
||||
|
||||
void
|
||||
TestEmpty(const char* aTestName, const char* aMode)
|
||||
{
|
||||
char filename[128];
|
||||
sprintf(filename, "complete-%s-%s.json", aTestName, aMode);
|
||||
auto f = MakeUnique<FpWriteFunc>(filename);
|
||||
|
||||
char options[128];
|
||||
sprintf(options, "--mode=%s --stacks=full", aMode);
|
||||
ResetEverything(options);
|
||||
|
||||
// Zero for everything.
|
||||
Analyze(Move(f));
|
||||
}
|
||||
|
||||
void
|
||||
TestFull(const char* aTestName, int aNum, const char* aMode, int aSeven)
|
||||
{
|
||||
char filename[128];
|
||||
sprintf(filename, "complete-%s%d-%s.json", aTestName, aNum, aMode);
|
||||
auto f = MakeUnique<FpWriteFunc>(filename);
|
||||
|
||||
// The --show-dump-stats=yes is there just to give that option some basic
|
||||
// testing, e.g. ensure it doesn't crash. It's hard to test much beyond that.
|
||||
char options[128];
|
||||
sprintf(options, "--mode=%s --stacks=full --show-dump-stats=yes", aMode);
|
||||
ResetEverything(options);
|
||||
|
||||
// Analyze 1: 1 freed, 9 out of 10 unreported.
|
||||
// Analyze 2: still present and unreported.
|
||||
int i;
|
||||
char* a = nullptr;
|
||||
for (i = 0; i < aSeven + 3; i++) {
|
||||
a = (char*) malloc(100);
|
||||
UseItOrLoseIt(a, aSeven);
|
||||
}
|
||||
free(a);
|
||||
|
||||
// A no-op.
|
||||
free(nullptr);
|
||||
|
||||
// Note: 16 bytes is the smallest requested size that gives consistent
|
||||
// behaviour across all platforms with jemalloc.
|
||||
// Analyze 1: reported.
|
||||
// Analyze 2: thrice-reported.
|
||||
char* a2 = (char*) malloc(16);
|
||||
Report(a2);
|
||||
|
||||
// Analyze 1: reported.
|
||||
// Analyze 2: reportedness carries over, due to ReportOnAlloc.
|
||||
char* b = (char*) malloc(10);
|
||||
ReportOnAlloc(b);
|
||||
|
||||
// ReportOnAlloc, then freed.
|
||||
// Analyze 1: freed, irrelevant.
|
||||
// Analyze 2: freed, irrelevant.
|
||||
char* b2 = (char*) malloc(16);
|
||||
ReportOnAlloc(b2);
|
||||
free(b2);
|
||||
|
||||
// Analyze 1: reported 4 times.
|
||||
// Analyze 2: freed, irrelevant.
|
||||
char* c = (char*) calloc(10, 3);
|
||||
Report(c);
|
||||
for (int i = 0; i < aSeven - 4; i++) {
|
||||
Report(c);
|
||||
}
|
||||
|
||||
// Analyze 1: ignored.
|
||||
// Analyze 2: irrelevant.
|
||||
Report((void*)(intptr_t)i);
|
||||
|
||||
// jemalloc rounds this up to 8192.
|
||||
// Analyze 1: reported.
|
||||
// Analyze 2: freed.
|
||||
char* e = (char*) malloc(4096);
|
||||
e = (char*) realloc(e, 7169);
|
||||
Report(e);
|
||||
|
||||
// First realloc is like malloc; second realloc is shrinking.
|
||||
// Analyze 1: reported.
|
||||
// Analyze 2: re-reported.
|
||||
char* e2 = (char*) realloc(nullptr, 1024);
|
||||
e2 = (char*) realloc(e2, 512);
|
||||
Report(e2);
|
||||
|
||||
// First realloc is like malloc; second realloc creates a min-sized block.
|
||||
// XXX: on Windows, second realloc frees the block.
|
||||
// Analyze 1: reported.
|
||||
// Analyze 2: freed, irrelevant.
|
||||
char* e3 = (char*) realloc(nullptr, 1023);
|
||||
//e3 = (char*) realloc(e3, 0);
|
||||
MOZ_ASSERT(e3);
|
||||
Report(e3);
|
||||
|
||||
// Analyze 1: freed, irrelevant.
|
||||
// Analyze 2: freed, irrelevant.
|
||||
char* f1 = (char*) malloc(64);
|
||||
free(f1);
|
||||
|
||||
// Analyze 1: ignored.
|
||||
// Analyze 2: irrelevant.
|
||||
Report((void*)(intptr_t)0x0);
|
||||
|
||||
// Analyze 1: mixture of reported and unreported.
|
||||
// Analyze 2: all unreported.
|
||||
Foo(aSeven);
|
||||
|
||||
// Analyze 1: twice-reported.
|
||||
// Analyze 2: twice-reported.
|
||||
char* g1 = (char*) malloc(77);
|
||||
ReportOnAlloc(g1);
|
||||
ReportOnAlloc(g1);
|
||||
|
||||
// Analyze 1: mixture of reported and unreported.
|
||||
// Analyze 2: all unreported.
|
||||
// Nb: this Foo() call is deliberately not adjacent to the previous one. See
|
||||
// the comment about adjacent calls in Foo() for more details.
|
||||
Foo(aSeven);
|
||||
|
||||
// Analyze 1: twice-reported.
|
||||
// Analyze 2: once-reported.
|
||||
char* g2 = (char*) malloc(78);
|
||||
Report(g2);
|
||||
ReportOnAlloc(g2);
|
||||
|
||||
// Analyze 1: twice-reported.
|
||||
// Analyze 2: once-reported.
|
||||
char* g3 = (char*) malloc(79);
|
||||
ReportOnAlloc(g3);
|
||||
Report(g3);
|
||||
|
||||
// All the odd-ball ones.
|
||||
// Analyze 1: all unreported.
|
||||
// Analyze 2: all freed, irrelevant.
|
||||
// XXX: no memalign on Mac
|
||||
//void* w = memalign(64, 65); // rounds up to 128
|
||||
//UseItOrLoseIt(w, aSeven);
|
||||
|
||||
// XXX: posix_memalign doesn't work on B2G
|
||||
//void* x;
|
||||
//posix_memalign(&y, 128, 129); // rounds up to 256
|
||||
//UseItOrLoseIt(x, aSeven);
|
||||
|
||||
// XXX: valloc doesn't work on Windows.
|
||||
//void* y = valloc(1); // rounds up to 4096
|
||||
//UseItOrLoseIt(y, aSeven);
|
||||
|
||||
// XXX: C11 only
|
||||
//void* z = aligned_alloc(64, 256);
|
||||
//UseItOrLoseIt(z, aSeven);
|
||||
|
||||
if (aNum == 1) {
|
||||
// Analyze 1.
|
||||
Analyze(Move(f));
|
||||
}
|
||||
|
||||
ClearReports();
|
||||
|
||||
//---------
|
||||
|
||||
Report(a2);
|
||||
Report(a2);
|
||||
free(c);
|
||||
free(e);
|
||||
Report(e2);
|
||||
free(e3);
|
||||
//free(w);
|
||||
//free(x);
|
||||
//free(y);
|
||||
//free(z);
|
||||
|
||||
// Do some allocations that will only show up in cumulative mode.
|
||||
for (int i = 0; i < 100; i++) {
|
||||
free(malloc(128));
|
||||
}
|
||||
|
||||
if (aNum == 2) {
|
||||
// Analyze 2.
|
||||
Analyze(Move(f));
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
TestPartial(const char* aTestName, const char* aMode, int aSeven)
|
||||
{
|
||||
char filename[128];
|
||||
sprintf(filename, "complete-%s-%s.json", aTestName, aMode);
|
||||
auto f = MakeUnique<FpWriteFunc>(filename);
|
||||
|
||||
char options[128];
|
||||
sprintf(options, "--mode=%s", aMode);
|
||||
ResetEverything(options);
|
||||
|
||||
int kTenThousand = aSeven + 9993;
|
||||
char* s;
|
||||
|
||||
// The output of this function is deterministic but it relies on the
|
||||
// probability and seeds given to the FastBernoulliTrial instance in
|
||||
// ResetBernoulli(). If they change, the output will change too.
|
||||
|
||||
// Expected fraction with stacks: (1 - (1 - 0.003) ** 16) = 0.0469.
|
||||
// So we expect about 0.0469 * 10000 == 469.
|
||||
// We actually get 511.
|
||||
for (int i = 0; i < kTenThousand; i++) {
|
||||
s = (char*) malloc(16);
|
||||
UseItOrLoseIt(s, aSeven);
|
||||
}
|
||||
|
||||
// Expected fraction with stacks: (1 - (1 - 0.003) ** 128) = 0.3193.
|
||||
// So we expect about 0.3193 * 10000 == 3193.
|
||||
// We actually get 3136.
|
||||
for (int i = 0; i < kTenThousand; i++) {
|
||||
s = (char*) malloc(128);
|
||||
UseItOrLoseIt(s, aSeven);
|
||||
}
|
||||
|
||||
// Expected fraction with stacks: (1 - (1 - 0.003) ** 1024) = 0.9539.
|
||||
// So we expect about 0.9539 * 10000 == 9539.
|
||||
// We actually get 9531.
|
||||
for (int i = 0; i < kTenThousand; i++) {
|
||||
s = (char*) malloc(1024);
|
||||
UseItOrLoseIt(s, aSeven);
|
||||
}
|
||||
|
||||
Analyze(Move(f));
|
||||
}
|
||||
|
||||
void
|
||||
TestScan(int aSeven)
|
||||
{
|
||||
auto f = MakeUnique<FpWriteFunc>("basic-scan.json");
|
||||
|
||||
ResetEverything("--mode=scan");
|
||||
|
||||
uintptr_t* p = (uintptr_t*) malloc(6 * sizeof(uintptr_t*));
|
||||
UseItOrLoseIt(p, aSeven);
|
||||
|
||||
// Hard-coded values checked by scan-test.py
|
||||
p[0] = 0x123; // outside a block, small value
|
||||
p[1] = 0x0; // null
|
||||
p[2] = (uintptr_t)((uint8_t*)p - 1); // pointer outside a block, but nearby
|
||||
p[3] = (uintptr_t)p; // pointer to start of a block
|
||||
p[4] = (uintptr_t)((uint8_t*)p + 1); // pointer into a block
|
||||
p[5] = 0x0; // trailing null
|
||||
|
||||
Analyze(Move(f));
|
||||
}
|
||||
|
||||
void
|
||||
RunTests()
|
||||
{
|
||||
// This test relies on the compiler not doing various optimizations, such as
|
||||
// eliding unused malloc() calls or unrolling loops with fixed iteration
|
||||
// counts. So we compile it with -O0 (or equivalent), which probably prevents
|
||||
// that. We also use the following variable for various loop iteration
|
||||
// counts, just in case compilers might unroll very small loops even with
|
||||
// -O0.
|
||||
int seven = 7;
|
||||
|
||||
// Make sure that DMD is actually running; it is initialized on the first
|
||||
// allocation.
|
||||
int *x = (int*)malloc(100);
|
||||
UseItOrLoseIt(x, seven);
|
||||
MOZ_RELEASE_ASSERT(IsRunning());
|
||||
|
||||
// Please keep this in sync with run_test in test_dmd.js.
|
||||
|
||||
TestEmpty("empty", "live");
|
||||
TestEmpty("empty", "dark-matter");
|
||||
TestEmpty("empty", "cumulative");
|
||||
|
||||
TestFull("full", 1, "live", seven);
|
||||
TestFull("full", 1, "dark-matter", seven);
|
||||
|
||||
TestFull("full", 2, "dark-matter", seven);
|
||||
TestFull("full", 2, "cumulative", seven);
|
||||
|
||||
TestPartial("partial", "live", seven);
|
||||
|
||||
TestScan(seven);
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
RunTests();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -1,25 +0,0 @@
|
|||
#-----------------------------------------------------------------
|
||||
# dmd.py --filter-stacks-for-testing -o basic-scan-32-actual.txt --clamp-contents basic-scan.json
|
||||
|
||||
Invocation {
|
||||
$DMD = '--mode=scan'
|
||||
Mode = 'live'
|
||||
}
|
||||
|
||||
#-----------------------------------------------------------------
|
||||
|
||||
Live {
|
||||
1 block in heap block record 1 of 1
|
||||
32 bytes (24 requested / 8 slop)
|
||||
100.00% of the heap (100.00% cumulative)
|
||||
Allocated at {
|
||||
#01: ... DMD.cpp ...
|
||||
}
|
||||
}
|
||||
|
||||
#-----------------------------------------------------------------
|
||||
|
||||
Summary {
|
||||
Total: 32 bytes in 1 blocks
|
||||
}
|
||||
|
||||
|
|
@ -1,25 +0,0 @@
|
|||
#-----------------------------------------------------------------
|
||||
# dmd.py --filter-stacks-for-testing -o basic-scan-64-actual.txt --clamp-contents basic-scan.json
|
||||
|
||||
Invocation {
|
||||
$DMD = '--mode=scan'
|
||||
Mode = 'live'
|
||||
}
|
||||
|
||||
#-----------------------------------------------------------------
|
||||
|
||||
Live {
|
||||
1 block in heap block record 1 of 1
|
||||
48 bytes (48 requested / 0 slop)
|
||||
100.00% of the heap (100.00% cumulative)
|
||||
Allocated at {
|
||||
#01: ... DMD.cpp ...
|
||||
}
|
||||
}
|
||||
|
||||
#-----------------------------------------------------------------
|
||||
|
||||
Summary {
|
||||
Total: 48 bytes in 1 blocks
|
||||
}
|
||||
|
||||
|
|
@ -1,18 +0,0 @@
|
|||
#-----------------------------------------------------------------
|
||||
# dmd.py --filter-stacks-for-testing -o complete-empty-cumulative-actual.txt complete-empty-cumulative.json
|
||||
|
||||
Invocation {
|
||||
$DMD = '--mode=cumulative --stacks=full'
|
||||
Mode = 'cumulative'
|
||||
}
|
||||
|
||||
#-----------------------------------------------------------------
|
||||
|
||||
# no cumulative heap blocks
|
||||
|
||||
#-----------------------------------------------------------------
|
||||
|
||||
Summary {
|
||||
Total: 0 bytes in 0 blocks
|
||||
}
|
||||
|
||||
|
|
@ -1,29 +0,0 @@
|
|||
#-----------------------------------------------------------------
|
||||
# dmd.py --filter-stacks-for-testing -o complete-empty-dark-matter-actual.txt complete-empty-dark-matter.json
|
||||
|
||||
Invocation {
|
||||
$DMD = '--mode=dark-matter --stacks=full'
|
||||
Mode = 'dark-matter'
|
||||
}
|
||||
|
||||
#-----------------------------------------------------------------
|
||||
|
||||
# no twice-reported heap blocks
|
||||
|
||||
#-----------------------------------------------------------------
|
||||
|
||||
# no unreported heap blocks
|
||||
|
||||
#-----------------------------------------------------------------
|
||||
|
||||
# no once-reported heap blocks
|
||||
|
||||
#-----------------------------------------------------------------
|
||||
|
||||
Summary {
|
||||
Total: 0 bytes (100.00%) in 0 blocks (100.00%)
|
||||
Unreported: 0 bytes ( 0.00%) in 0 blocks ( 0.00%)
|
||||
Once-reported: 0 bytes ( 0.00%) in 0 blocks ( 0.00%)
|
||||
Twice-reported: 0 bytes ( 0.00%) in 0 blocks ( 0.00%)
|
||||
}
|
||||
|
||||
|
|
@ -1,18 +0,0 @@
|
|||
#-----------------------------------------------------------------
|
||||
# dmd.py --filter-stacks-for-testing -o complete-empty-live-actual.txt complete-empty-live.json
|
||||
|
||||
Invocation {
|
||||
$DMD = '--mode=live --stacks=full'
|
||||
Mode = 'live'
|
||||
}
|
||||
|
||||
#-----------------------------------------------------------------
|
||||
|
||||
# no live heap blocks
|
||||
|
||||
#-----------------------------------------------------------------
|
||||
|
||||
Summary {
|
||||
Total: 0 bytes in 0 blocks
|
||||
}
|
||||
|
||||
|
|
@ -1,265 +0,0 @@
|
|||
#-----------------------------------------------------------------
|
||||
# dmd.py --filter-stacks-for-testing -o complete-full1-dark-matter-actual.txt complete-full1-dark-matter.json
|
||||
|
||||
Invocation {
|
||||
$DMD = '--mode=dark-matter --stacks=full --show-dump-stats=yes'
|
||||
Mode = 'dark-matter'
|
||||
}
|
||||
|
||||
#-----------------------------------------------------------------
|
||||
|
||||
Twice-reported {
|
||||
1 block in heap block record 1 of 4
|
||||
80 bytes (79 requested / 1 slop)
|
||||
0.66% of the heap (0.66% cumulative)
|
||||
29.41% of twice-reported (29.41% cumulative)
|
||||
Allocated at {
|
||||
#01: ... DMD.cpp ...
|
||||
}
|
||||
Reported at {
|
||||
#01: ... DMD.cpp ...
|
||||
}
|
||||
Reported again at {
|
||||
#01: ... DMD.cpp ...
|
||||
}
|
||||
}
|
||||
|
||||
Twice-reported {
|
||||
1 block in heap block record 2 of 4
|
||||
80 bytes (78 requested / 2 slop)
|
||||
0.66% of the heap (1.32% cumulative)
|
||||
29.41% of twice-reported (58.82% cumulative)
|
||||
Allocated at {
|
||||
#01: ... DMD.cpp ...
|
||||
}
|
||||
Reported at {
|
||||
#01: ... DMD.cpp ...
|
||||
}
|
||||
Reported again at {
|
||||
#01: ... DMD.cpp ...
|
||||
}
|
||||
}
|
||||
|
||||
Twice-reported {
|
||||
1 block in heap block record 3 of 4
|
||||
80 bytes (77 requested / 3 slop)
|
||||
0.66% of the heap (1.98% cumulative)
|
||||
29.41% of twice-reported (88.24% cumulative)
|
||||
Allocated at {
|
||||
#01: ... DMD.cpp ...
|
||||
}
|
||||
Reported at {
|
||||
#01: ... DMD.cpp ...
|
||||
}
|
||||
Reported again at {
|
||||
#01: ... DMD.cpp ...
|
||||
}
|
||||
}
|
||||
|
||||
Twice-reported {
|
||||
1 block in heap block record 4 of 4
|
||||
32 bytes (30 requested / 2 slop)
|
||||
0.26% of the heap (2.25% cumulative)
|
||||
11.76% of twice-reported (100.00% cumulative)
|
||||
Allocated at {
|
||||
#01: ... DMD.cpp ...
|
||||
}
|
||||
Reported at {
|
||||
#01: ... DMD.cpp ...
|
||||
}
|
||||
Reported again at {
|
||||
#01: ... DMD.cpp ...
|
||||
}
|
||||
}
|
||||
|
||||
#-----------------------------------------------------------------
|
||||
|
||||
Unreported {
|
||||
9 blocks in heap block record 1 of 3
|
||||
1,008 bytes (900 requested / 108 slop)
|
||||
Individual block sizes: 112 x 9
|
||||
8.33% of the heap (8.33% cumulative)
|
||||
81.82% of unreported (81.82% cumulative)
|
||||
Allocated at {
|
||||
#01: ... DMD.cpp ...
|
||||
}
|
||||
}
|
||||
|
||||
Unreported {
|
||||
2 blocks in heap block record 2 of 3
|
||||
112 bytes (112 requested / 0 slop)
|
||||
Individual block sizes: 64; 48
|
||||
0.93% of the heap (9.26% cumulative)
|
||||
9.09% of unreported (90.91% cumulative)
|
||||
Allocated at {
|
||||
#01: ... DMD.cpp ...
|
||||
}
|
||||
}
|
||||
|
||||
Unreported {
|
||||
2 blocks in heap block record 3 of 3
|
||||
112 bytes (112 requested / 0 slop)
|
||||
Individual block sizes: 64; 48
|
||||
0.93% of the heap (10.19% cumulative)
|
||||
9.09% of unreported (100.00% cumulative)
|
||||
Allocated at {
|
||||
#01: ... DMD.cpp ...
|
||||
}
|
||||
}
|
||||
|
||||
#-----------------------------------------------------------------
|
||||
|
||||
Once-reported {
|
||||
1 block in heap block record 1 of 11
|
||||
8,192 bytes (7,169 requested / 1,023 slop)
|
||||
67.72% of the heap (67.72% cumulative)
|
||||
77.34% of once-reported (77.34% cumulative)
|
||||
Allocated at {
|
||||
#01: ... DMD.cpp ...
|
||||
}
|
||||
Reported at {
|
||||
#01: ... DMD.cpp ...
|
||||
}
|
||||
}
|
||||
|
||||
Once-reported {
|
||||
1 block in heap block record 2 of 11
|
||||
1,024 bytes (1,023 requested / 1 slop)
|
||||
8.47% of the heap (76.19% cumulative)
|
||||
9.67% of once-reported (87.01% cumulative)
|
||||
Allocated at {
|
||||
#01: ... DMD.cpp ...
|
||||
}
|
||||
Reported at {
|
||||
#01: ... DMD.cpp ...
|
||||
}
|
||||
}
|
||||
|
||||
Once-reported {
|
||||
1 block in heap block record 3 of 11
|
||||
512 bytes (512 requested / 0 slop)
|
||||
4.23% of the heap (80.42% cumulative)
|
||||
4.83% of once-reported (91.84% cumulative)
|
||||
Allocated at {
|
||||
#01: ... DMD.cpp ...
|
||||
}
|
||||
Reported at {
|
||||
#01: ... DMD.cpp ...
|
||||
}
|
||||
}
|
||||
|
||||
Once-reported {
|
||||
2 blocks in heap block record 4 of 11
|
||||
240 bytes (240 requested / 0 slop)
|
||||
Individual block sizes: 128; 112
|
||||
1.98% of the heap (82.41% cumulative)
|
||||
2.27% of once-reported (94.11% cumulative)
|
||||
Allocated at {
|
||||
#01: ... DMD.cpp ...
|
||||
}
|
||||
Reported at {
|
||||
#01: ... DMD.cpp ...
|
||||
}
|
||||
}
|
||||
|
||||
Once-reported {
|
||||
2 blocks in heap block record 5 of 11
|
||||
240 bytes (240 requested / 0 slop)
|
||||
Individual block sizes: 128; 112
|
||||
1.98% of the heap (84.39% cumulative)
|
||||
2.27% of once-reported (96.37% cumulative)
|
||||
Allocated at {
|
||||
#01: ... DMD.cpp ...
|
||||
}
|
||||
Reported at {
|
||||
#01: ... DMD.cpp ...
|
||||
}
|
||||
}
|
||||
|
||||
Once-reported {
|
||||
1 block in heap block record 6 of 11
|
||||
96 bytes (96 requested / 0 slop)
|
||||
0.79% of the heap (85.19% cumulative)
|
||||
0.91% of once-reported (97.28% cumulative)
|
||||
Allocated at {
|
||||
#01: ... DMD.cpp ...
|
||||
}
|
||||
Reported at {
|
||||
#01: ... DMD.cpp ...
|
||||
}
|
||||
}
|
||||
|
||||
Once-reported {
|
||||
1 block in heap block record 7 of 11
|
||||
96 bytes (96 requested / 0 slop)
|
||||
0.79% of the heap (85.98% cumulative)
|
||||
0.91% of once-reported (98.19% cumulative)
|
||||
Allocated at {
|
||||
#01: ... DMD.cpp ...
|
||||
}
|
||||
Reported at {
|
||||
#01: ... DMD.cpp ...
|
||||
}
|
||||
}
|
||||
|
||||
Once-reported {
|
||||
1 block in heap block record 8 of 11
|
||||
80 bytes (80 requested / 0 slop)
|
||||
0.66% of the heap (86.64% cumulative)
|
||||
0.76% of once-reported (98.94% cumulative)
|
||||
Allocated at {
|
||||
#01: ... DMD.cpp ...
|
||||
}
|
||||
Reported at {
|
||||
#01: ... DMD.cpp ...
|
||||
}
|
||||
}
|
||||
|
||||
Once-reported {
|
||||
1 block in heap block record 9 of 11
|
||||
80 bytes (80 requested / 0 slop)
|
||||
0.66% of the heap (87.30% cumulative)
|
||||
0.76% of once-reported (99.70% cumulative)
|
||||
Allocated at {
|
||||
#01: ... DMD.cpp ...
|
||||
}
|
||||
Reported at {
|
||||
#01: ... DMD.cpp ...
|
||||
}
|
||||
}
|
||||
|
||||
Once-reported {
|
||||
1 block in heap block record 10 of 11
|
||||
16 bytes (16 requested / 0 slop)
|
||||
0.13% of the heap (87.43% cumulative)
|
||||
0.15% of once-reported (99.85% cumulative)
|
||||
Allocated at {
|
||||
#01: ... DMD.cpp ...
|
||||
}
|
||||
Reported at {
|
||||
#01: ... DMD.cpp ...
|
||||
}
|
||||
}
|
||||
|
||||
Once-reported {
|
||||
1 block in heap block record 11 of 11
|
||||
16 bytes (10 requested / 6 slop)
|
||||
0.13% of the heap (87.57% cumulative)
|
||||
0.15% of once-reported (100.00% cumulative)
|
||||
Allocated at {
|
||||
#01: ... DMD.cpp ...
|
||||
}
|
||||
Reported at {
|
||||
#01: ... DMD.cpp ...
|
||||
}
|
||||
}
|
||||
|
||||
#-----------------------------------------------------------------
|
||||
|
||||
Summary {
|
||||
Total: 12,096 bytes (100.00%) in 30 blocks (100.00%)
|
||||
Unreported: 1,232 bytes ( 10.19%) in 13 blocks ( 43.33%)
|
||||
Once-reported: 10,592 bytes ( 87.57%) in 13 blocks ( 43.33%)
|
||||
Twice-reported: 272 bytes ( 2.25%) in 4 blocks ( 13.33%)
|
||||
}
|
||||
|
||||
|
|
@ -1,127 +0,0 @@
|
|||
#-----------------------------------------------------------------
|
||||
# dmd.py --filter-stacks-for-testing -o complete-full1-live-actual.txt complete-full1-live.json
|
||||
|
||||
Invocation {
|
||||
$DMD = '--mode=live --stacks=full --show-dump-stats=yes'
|
||||
Mode = 'live'
|
||||
}
|
||||
|
||||
#-----------------------------------------------------------------
|
||||
|
||||
Live {
|
||||
1 block in heap block record 1 of 12
|
||||
8,192 bytes (7,169 requested / 1,023 slop)
|
||||
67.72% of the heap (67.72% cumulative)
|
||||
Allocated at {
|
||||
#01: ... DMD.cpp ...
|
||||
}
|
||||
}
|
||||
|
||||
Live {
|
||||
1 block in heap block record 2 of 12
|
||||
1,024 bytes (1,023 requested / 1 slop)
|
||||
8.47% of the heap (76.19% cumulative)
|
||||
Allocated at {
|
||||
#01: ... DMD.cpp ...
|
||||
}
|
||||
}
|
||||
|
||||
Live {
|
||||
9 blocks in heap block record 3 of 12
|
||||
1,008 bytes (900 requested / 108 slop)
|
||||
Individual block sizes: 112 x 9
|
||||
8.33% of the heap (84.52% cumulative)
|
||||
Allocated at {
|
||||
#01: ... DMD.cpp ...
|
||||
}
|
||||
}
|
||||
|
||||
Live {
|
||||
6 blocks in heap block record 4 of 12
|
||||
528 bytes (528 requested / 0 slop)
|
||||
Individual block sizes: 128; 112; 96; 80; 64; 48
|
||||
4.37% of the heap (88.89% cumulative)
|
||||
Allocated at {
|
||||
#01: ... DMD.cpp ...
|
||||
}
|
||||
}
|
||||
|
||||
Live {
|
||||
6 blocks in heap block record 5 of 12
|
||||
528 bytes (528 requested / 0 slop)
|
||||
Individual block sizes: 128; 112; 96; 80; 64; 48
|
||||
4.37% of the heap (93.25% cumulative)
|
||||
Allocated at {
|
||||
#01: ... DMD.cpp ...
|
||||
}
|
||||
}
|
||||
|
||||
Live {
|
||||
1 block in heap block record 6 of 12
|
||||
512 bytes (512 requested / 0 slop)
|
||||
4.23% of the heap (97.49% cumulative)
|
||||
Allocated at {
|
||||
#01: ... DMD.cpp ...
|
||||
}
|
||||
}
|
||||
|
||||
Live {
|
||||
1 block in heap block record 7 of 12
|
||||
80 bytes (79 requested / 1 slop)
|
||||
0.66% of the heap (98.15% cumulative)
|
||||
Allocated at {
|
||||
#01: ... DMD.cpp ...
|
||||
}
|
||||
}
|
||||
|
||||
Live {
|
||||
1 block in heap block record 8 of 12
|
||||
80 bytes (78 requested / 2 slop)
|
||||
0.66% of the heap (98.81% cumulative)
|
||||
Allocated at {
|
||||
#01: ... DMD.cpp ...
|
||||
}
|
||||
}
|
||||
|
||||
Live {
|
||||
1 block in heap block record 9 of 12
|
||||
80 bytes (77 requested / 3 slop)
|
||||
0.66% of the heap (99.47% cumulative)
|
||||
Allocated at {
|
||||
#01: ... DMD.cpp ...
|
||||
}
|
||||
}
|
||||
|
||||
Live {
|
||||
1 block in heap block record 10 of 12
|
||||
32 bytes (30 requested / 2 slop)
|
||||
0.26% of the heap (99.74% cumulative)
|
||||
Allocated at {
|
||||
#01: ... DMD.cpp ...
|
||||
}
|
||||
}
|
||||
|
||||
Live {
|
||||
1 block in heap block record 11 of 12
|
||||
16 bytes (16 requested / 0 slop)
|
||||
0.13% of the heap (99.87% cumulative)
|
||||
Allocated at {
|
||||
#01: ... DMD.cpp ...
|
||||
}
|
||||
}
|
||||
|
||||
Live {
|
||||
1 block in heap block record 12 of 12
|
||||
16 bytes (10 requested / 6 slop)
|
||||
0.13% of the heap (100.00% cumulative)
|
||||
Allocated at {
|
||||
#01: ... DMD.cpp ...
|
||||
}
|
||||
}
|
||||
|
||||
#-----------------------------------------------------------------
|
||||
|
||||
Summary {
|
||||
Total: 12,096 bytes in 30 blocks
|
||||
}
|
||||
|
||||
|
|
@ -1,173 +0,0 @@
|
|||
#-----------------------------------------------------------------
|
||||
# dmd.py --filter-stacks-for-testing -o complete-full2-cumulative-actual.txt complete-full2-cumulative.json
|
||||
|
||||
Invocation {
|
||||
$DMD = '--mode=cumulative --stacks=full --show-dump-stats=yes'
|
||||
Mode = 'cumulative'
|
||||
}
|
||||
|
||||
#-----------------------------------------------------------------
|
||||
|
||||
Cumulative {
|
||||
100 blocks in heap block record 1 of 17
|
||||
12,800 bytes (12,800 requested / 0 slop)
|
||||
Individual block sizes: 128 x 100
|
||||
42.37% of the heap (42.37% cumulative)
|
||||
Allocated at {
|
||||
#01: ... DMD.cpp ...
|
||||
}
|
||||
}
|
||||
|
||||
Cumulative {
|
||||
1 block in heap block record 2 of 17
|
||||
8,192 bytes (7,169 requested / 1,023 slop)
|
||||
27.12% of the heap (69.49% cumulative)
|
||||
Allocated at {
|
||||
#01: ... DMD.cpp ...
|
||||
}
|
||||
}
|
||||
|
||||
Cumulative {
|
||||
1 block in heap block record 3 of 17
|
||||
4,096 bytes (4,096 requested / 0 slop)
|
||||
13.56% of the heap (83.05% cumulative)
|
||||
Allocated at {
|
||||
#01: ... DMD.cpp ...
|
||||
}
|
||||
}
|
||||
|
||||
Cumulative {
|
||||
10 blocks in heap block record 4 of 17
|
||||
1,120 bytes (1,000 requested / 120 slop)
|
||||
Individual block sizes: 112 x 10
|
||||
3.71% of the heap (86.76% cumulative)
|
||||
Allocated at {
|
||||
#01: ... DMD.cpp ...
|
||||
}
|
||||
}
|
||||
|
||||
Cumulative {
|
||||
1 block in heap block record 5 of 17
|
||||
1,024 bytes (1,024 requested / 0 slop)
|
||||
3.39% of the heap (90.15% cumulative)
|
||||
Allocated at {
|
||||
#01: ... DMD.cpp ...
|
||||
}
|
||||
}
|
||||
|
||||
Cumulative {
|
||||
1 block in heap block record 6 of 17
|
||||
1,024 bytes (1,023 requested / 1 slop)
|
||||
3.39% of the heap (93.54% cumulative)
|
||||
Allocated at {
|
||||
#01: ... DMD.cpp ...
|
||||
}
|
||||
}
|
||||
|
||||
Cumulative {
|
||||
6 blocks in heap block record 7 of 17
|
||||
528 bytes (528 requested / 0 slop)
|
||||
Individual block sizes: 128; 112; 96; 80; 64; 48
|
||||
1.75% of the heap (95.29% cumulative)
|
||||
Allocated at {
|
||||
#01: ... DMD.cpp ...
|
||||
}
|
||||
}
|
||||
|
||||
Cumulative {
|
||||
6 blocks in heap block record 8 of 17
|
||||
528 bytes (528 requested / 0 slop)
|
||||
Individual block sizes: 128; 112; 96; 80; 64; 48
|
||||
1.75% of the heap (97.03% cumulative)
|
||||
Allocated at {
|
||||
#01: ... DMD.cpp ...
|
||||
}
|
||||
}
|
||||
|
||||
Cumulative {
|
||||
1 block in heap block record 9 of 17
|
||||
512 bytes (512 requested / 0 slop)
|
||||
1.69% of the heap (98.73% cumulative)
|
||||
Allocated at {
|
||||
#01: ... DMD.cpp ...
|
||||
}
|
||||
}
|
||||
|
||||
Cumulative {
|
||||
1 block in heap block record 10 of 17
|
||||
80 bytes (79 requested / 1 slop)
|
||||
0.26% of the heap (98.99% cumulative)
|
||||
Allocated at {
|
||||
#01: ... DMD.cpp ...
|
||||
}
|
||||
}
|
||||
|
||||
Cumulative {
|
||||
1 block in heap block record 11 of 17
|
||||
80 bytes (78 requested / 2 slop)
|
||||
0.26% of the heap (99.26% cumulative)
|
||||
Allocated at {
|
||||
#01: ... DMD.cpp ...
|
||||
}
|
||||
}
|
||||
|
||||
Cumulative {
|
||||
1 block in heap block record 12 of 17
|
||||
80 bytes (77 requested / 3 slop)
|
||||
0.26% of the heap (99.52% cumulative)
|
||||
Allocated at {
|
||||
#01: ... DMD.cpp ...
|
||||
}
|
||||
}
|
||||
|
||||
Cumulative {
|
||||
1 block in heap block record 13 of 17
|
||||
64 bytes (64 requested / 0 slop)
|
||||
0.21% of the heap (99.74% cumulative)
|
||||
Allocated at {
|
||||
#01: ... DMD.cpp ...
|
||||
}
|
||||
}
|
||||
|
||||
Cumulative {
|
||||
1 block in heap block record 14 of 17
|
||||
32 bytes (30 requested / 2 slop)
|
||||
0.11% of the heap (99.84% cumulative)
|
||||
Allocated at {
|
||||
#01: ... DMD.cpp ...
|
||||
}
|
||||
}
|
||||
|
||||
Cumulative {
|
||||
1 block in heap block record 15 of 17
|
||||
16 bytes (16 requested / 0 slop)
|
||||
0.05% of the heap (99.89% cumulative)
|
||||
Allocated at {
|
||||
#01: ... DMD.cpp ...
|
||||
}
|
||||
}
|
||||
|
||||
Cumulative {
|
||||
1 block in heap block record 16 of 17
|
||||
16 bytes (16 requested / 0 slop)
|
||||
0.05% of the heap (99.95% cumulative)
|
||||
Allocated at {
|
||||
#01: ... DMD.cpp ...
|
||||
}
|
||||
}
|
||||
|
||||
Cumulative {
|
||||
1 block in heap block record 17 of 17
|
||||
16 bytes (10 requested / 6 slop)
|
||||
0.05% of the heap (100.00% cumulative)
|
||||
Allocated at {
|
||||
#01: ... DMD.cpp ...
|
||||
}
|
||||
}
|
||||
|
||||
#-----------------------------------------------------------------
|
||||
|
||||
Summary {
|
||||
Total: 30,208 bytes in 135 blocks
|
||||
}
|
||||
|
||||
|
|
@ -1,140 +0,0 @@
|
|||
#-----------------------------------------------------------------
|
||||
# dmd.py --filter-stacks-for-testing -o complete-full2-dark-matter-actual.txt complete-full2-dark-matter.json
|
||||
|
||||
Invocation {
|
||||
$DMD = '--mode=dark-matter --stacks=full --show-dump-stats=yes'
|
||||
Mode = 'dark-matter'
|
||||
}
|
||||
|
||||
#-----------------------------------------------------------------
|
||||
|
||||
Twice-reported {
|
||||
1 block in heap block record 1 of 2
|
||||
80 bytes (77 requested / 3 slop)
|
||||
2.81% of the heap (2.81% cumulative)
|
||||
83.33% of twice-reported (83.33% cumulative)
|
||||
Allocated at {
|
||||
#01: ... DMD.cpp ...
|
||||
}
|
||||
Reported at {
|
||||
#01: ... DMD.cpp ...
|
||||
}
|
||||
Reported again at {
|
||||
#01: ... DMD.cpp ...
|
||||
}
|
||||
}
|
||||
|
||||
Twice-reported {
|
||||
1 block in heap block record 2 of 2
|
||||
16 bytes (16 requested / 0 slop)
|
||||
0.56% of the heap (3.37% cumulative)
|
||||
16.67% of twice-reported (100.00% cumulative)
|
||||
Allocated at {
|
||||
#01: ... DMD.cpp ...
|
||||
}
|
||||
Reported at {
|
||||
#01: ... DMD.cpp ...
|
||||
}
|
||||
Reported again at {
|
||||
#01: ... DMD.cpp ...
|
||||
}
|
||||
}
|
||||
|
||||
#-----------------------------------------------------------------
|
||||
|
||||
Unreported {
|
||||
9 blocks in heap block record 1 of 3
|
||||
1,008 bytes (900 requested / 108 slop)
|
||||
Individual block sizes: 112 x 9
|
||||
35.39% of the heap (35.39% cumulative)
|
||||
48.84% of unreported (48.84% cumulative)
|
||||
Allocated at {
|
||||
#01: ... DMD.cpp ...
|
||||
}
|
||||
}
|
||||
|
||||
Unreported {
|
||||
6 blocks in heap block record 2 of 3
|
||||
528 bytes (528 requested / 0 slop)
|
||||
Individual block sizes: 128; 112; 96; 80; 64; 48
|
||||
18.54% of the heap (53.93% cumulative)
|
||||
25.58% of unreported (74.42% cumulative)
|
||||
Allocated at {
|
||||
#01: ... DMD.cpp ...
|
||||
}
|
||||
}
|
||||
|
||||
Unreported {
|
||||
6 blocks in heap block record 3 of 3
|
||||
528 bytes (528 requested / 0 slop)
|
||||
Individual block sizes: 128; 112; 96; 80; 64; 48
|
||||
18.54% of the heap (72.47% cumulative)
|
||||
25.58% of unreported (100.00% cumulative)
|
||||
Allocated at {
|
||||
#01: ... DMD.cpp ...
|
||||
}
|
||||
}
|
||||
|
||||
#-----------------------------------------------------------------
|
||||
|
||||
Once-reported {
|
||||
1 block in heap block record 1 of 4
|
||||
512 bytes (512 requested / 0 slop)
|
||||
17.98% of the heap (17.98% cumulative)
|
||||
74.42% of once-reported (74.42% cumulative)
|
||||
Allocated at {
|
||||
#01: ... DMD.cpp ...
|
||||
}
|
||||
Reported at {
|
||||
#01: ... DMD.cpp ...
|
||||
}
|
||||
}
|
||||
|
||||
Once-reported {
|
||||
1 block in heap block record 2 of 4
|
||||
80 bytes (79 requested / 1 slop)
|
||||
2.81% of the heap (20.79% cumulative)
|
||||
11.63% of once-reported (86.05% cumulative)
|
||||
Allocated at {
|
||||
#01: ... DMD.cpp ...
|
||||
}
|
||||
Reported at {
|
||||
#01: ... DMD.cpp ...
|
||||
}
|
||||
}
|
||||
|
||||
Once-reported {
|
||||
1 block in heap block record 3 of 4
|
||||
80 bytes (78 requested / 2 slop)
|
||||
2.81% of the heap (23.60% cumulative)
|
||||
11.63% of once-reported (97.67% cumulative)
|
||||
Allocated at {
|
||||
#01: ... DMD.cpp ...
|
||||
}
|
||||
Reported at {
|
||||
#01: ... DMD.cpp ...
|
||||
}
|
||||
}
|
||||
|
||||
Once-reported {
|
||||
1 block in heap block record 4 of 4
|
||||
16 bytes (10 requested / 6 slop)
|
||||
0.56% of the heap (24.16% cumulative)
|
||||
2.33% of once-reported (100.00% cumulative)
|
||||
Allocated at {
|
||||
#01: ... DMD.cpp ...
|
||||
}
|
||||
Reported at {
|
||||
#01: ... DMD.cpp ...
|
||||
}
|
||||
}
|
||||
|
||||
#-----------------------------------------------------------------
|
||||
|
||||
Summary {
|
||||
Total: 2,848 bytes (100.00%) in 27 blocks (100.00%)
|
||||
Unreported: 2,064 bytes ( 72.47%) in 21 blocks ( 77.78%)
|
||||
Once-reported: 688 bytes ( 24.16%) in 4 blocks ( 14.81%)
|
||||
Twice-reported: 96 bytes ( 3.37%) in 2 blocks ( 7.41%)
|
||||
}
|
||||
|
||||
|
|
@ -1,56 +0,0 @@
|
|||
#-----------------------------------------------------------------
|
||||
# dmd.py --filter-stacks-for-testing -o complete-partial-live-actual.txt complete-partial-live.json
|
||||
|
||||
Invocation {
|
||||
$DMD = '--mode=live'
|
||||
Mode = 'live'
|
||||
}
|
||||
|
||||
#-----------------------------------------------------------------
|
||||
|
||||
Live {
|
||||
9,531 blocks in heap block record 1 of 4
|
||||
9,759,744 bytes (9,759,744 requested / 0 slop)
|
||||
Individual block sizes: 1,024 x 9,531
|
||||
83.56% of the heap (83.56% cumulative)
|
||||
Allocated at {
|
||||
#01: ... DMD.cpp ...
|
||||
}
|
||||
}
|
||||
|
||||
Live {
|
||||
16,822 blocks in heap block record 2 of 4
|
||||
1,510,672 bytes (1,510,672 requested / 0 slop)
|
||||
Individual block sizes: 1,024 x 469; 128 x 6,864; 16 x 9,489
|
||||
12.93% of the heap (96.49% cumulative)
|
||||
Allocated at {
|
||||
#01: (no stack trace recorded due to --stacks=partial)
|
||||
}
|
||||
}
|
||||
|
||||
Live {
|
||||
3,136 blocks in heap block record 3 of 4
|
||||
401,408 bytes (401,408 requested / 0 slop)
|
||||
Individual block sizes: 128 x 3,136
|
||||
3.44% of the heap (99.93% cumulative)
|
||||
Allocated at {
|
||||
#01: ... DMD.cpp ...
|
||||
}
|
||||
}
|
||||
|
||||
Live {
|
||||
511 blocks in heap block record 4 of 4
|
||||
8,176 bytes (8,176 requested / 0 slop)
|
||||
Individual block sizes: 16 x 511
|
||||
0.07% of the heap (100.00% cumulative)
|
||||
Allocated at {
|
||||
#01: ... DMD.cpp ...
|
||||
}
|
||||
}
|
||||
|
||||
#-----------------------------------------------------------------
|
||||
|
||||
Summary {
|
||||
Total: 11,680,000 bytes in 30,000 blocks
|
||||
}
|
||||
|
||||
|
|
@ -1,26 +0,0 @@
|
|||
# -*- Mode: python; 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/.
|
||||
|
||||
GeckoSimplePrograms([
|
||||
'SmokeDMD',
|
||||
], linkage=None)
|
||||
|
||||
# See the comment at the top of SmokeDMD.cpp:RunTests().
|
||||
if CONFIG['OS_ARCH'] == 'WINNT':
|
||||
CXXFLAGS += ['-Og-']
|
||||
else:
|
||||
CXXFLAGS += ['-O0']
|
||||
|
||||
DEFINES['MOZ_NO_MOZALLOC'] = True
|
||||
|
||||
DISABLE_STL_WRAPPING = True
|
||||
|
||||
XPCSHELL_TESTS_MANIFESTS += [
|
||||
'xpcshell.ini',
|
||||
]
|
||||
|
||||
if CONFIG['GNU_CXX']:
|
||||
CXXFLAGS += ['-Wno-error=shadow']
|
||||
|
|
@ -1,83 +0,0 @@
|
|||
#! /usr/bin/env 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/.
|
||||
|
||||
'''Testing for the JSON file emitted by DMD heap scan mode when running SmokeDMD.'''
|
||||
|
||||
from __future__ import print_function, division
|
||||
|
||||
import argparse
|
||||
import gzip
|
||||
import json
|
||||
import sys
|
||||
|
||||
# The DMD output version this script handles.
|
||||
outputVersion = 5
|
||||
|
||||
|
||||
def parseCommandLine():
|
||||
description = '''
|
||||
Ensure that DMD heap scan mode creates the correct output when run with SmokeDMD.
|
||||
This is only for testing. Input files can be gzipped.
|
||||
'''
|
||||
p = argparse.ArgumentParser(description=description)
|
||||
|
||||
p.add_argument('--clamp-contents', action='store_true',
|
||||
help='expect that the contents of the JSON input file have had their addresses clamped')
|
||||
|
||||
p.add_argument('input_file',
|
||||
help='a file produced by DMD')
|
||||
|
||||
return p.parse_args(sys.argv[1:])
|
||||
|
||||
|
||||
def checkScanContents(contents, expected):
|
||||
if len(contents) != len(expected):
|
||||
raise Exception("Expected " + str(len(expected)) + " things in contents but found " + str(len(contents)))
|
||||
|
||||
for i in range(len(expected)):
|
||||
if contents[i] != expected[i]:
|
||||
raise Exception("Expected to find " + expected[i] + " at offset " + str(i) + " but found " + contents[i])
|
||||
|
||||
|
||||
def main():
|
||||
args = parseCommandLine()
|
||||
|
||||
# Handle gzipped input if necessary.
|
||||
isZipped = args.input_file.endswith('.gz')
|
||||
opener = gzip.open if isZipped else open
|
||||
|
||||
with opener(args.input_file, 'rb') as f:
|
||||
j = json.load(f)
|
||||
|
||||
if j['version'] != outputVersion:
|
||||
raise Exception("'version' property isn't '{:d}'".format(outputVersion))
|
||||
|
||||
invocation = j['invocation']
|
||||
|
||||
mode = invocation['mode']
|
||||
if mode != 'scan':
|
||||
raise Exception("bad 'mode' property: '{:s}'".format(mode))
|
||||
|
||||
blockList = j['blockList']
|
||||
|
||||
if len(blockList) != 1:
|
||||
raise Exception("Expected only one block")
|
||||
|
||||
b = blockList[0]
|
||||
|
||||
# The expected values are based on hard-coded values in SmokeDMD.cpp.
|
||||
if args.clamp_contents:
|
||||
expected = ['0', '0', '0', b['addr'], b['addr']]
|
||||
else:
|
||||
addr = int(b['addr'], 16)
|
||||
expected = ['123', '0', str(format(addr - 1, 'x')), b['addr'],
|
||||
str(format(addr + 1, 'x')), '0']
|
||||
|
||||
checkScanContents(b['contents'], expected)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
|
|
@ -1,127 +0,0 @@
|
|||
#-----------------------------------------------------------------
|
||||
# dmd.py --filter-stacks-for-testing -o script-diff-dark-matter-actual.txt script-diff-dark-matter1.json script-diff-dark-matter2.json
|
||||
|
||||
Invocation 1 {
|
||||
$DMD = '--mode=dark-matter'
|
||||
Mode = 'dark-matter'
|
||||
}
|
||||
|
||||
Invocation 2 {
|
||||
$DMD is undefined
|
||||
Mode = 'dark-matter'
|
||||
}
|
||||
|
||||
#-----------------------------------------------------------------
|
||||
|
||||
Twice-reported {
|
||||
-1 blocks in heap block record 1 of 1
|
||||
-1,088 bytes (-1,064 requested / -24 slop)
|
||||
Individual block sizes: -1,024; -127; 63
|
||||
15.46% of the heap (15.46% cumulative)
|
||||
100.00% of twice-reported (100.00% cumulative)
|
||||
Allocated at {
|
||||
#01: F (F.cpp:99)
|
||||
}
|
||||
Reported at {
|
||||
#01: R1 (R1.cpp:99)
|
||||
}
|
||||
Reported again at {
|
||||
#01: R2 (R2.cpp:99)
|
||||
}
|
||||
}
|
||||
|
||||
#-----------------------------------------------------------------
|
||||
|
||||
Unreported {
|
||||
4 blocks in heap block record 1 of 5
|
||||
16,384 bytes (16,384 requested / 0 slop)
|
||||
Individual block sizes: 4,096 x 4
|
||||
-232.76% of the heap (-232.76% cumulative)
|
||||
371.01% of unreported (371.01% cumulative)
|
||||
Allocated at {
|
||||
#01: E (E.cpp:99)
|
||||
}
|
||||
}
|
||||
|
||||
Unreported {
|
||||
7 blocks in heap block record 2 of 5
|
||||
-11,968 bytes (-12,016 requested / 48 slop)
|
||||
Individual block sizes: -15,360; 2,048; 512 x 2; 128; -127; 64 x 4; 63
|
||||
170.02% of the heap (-62.74% cumulative)
|
||||
-271.01% of unreported (100.00% cumulative)
|
||||
Allocated at {
|
||||
#01: F (F.cpp:99)
|
||||
}
|
||||
}
|
||||
|
||||
Unreported {
|
||||
0 blocks in heap block record 3 of 5
|
||||
0 bytes (-384 requested / 384 slop)
|
||||
Individual block sizes: (no change)
|
||||
-0.00% of the heap (-62.74% cumulative)
|
||||
0.00% of unreported (100.00% cumulative)
|
||||
Allocated at {
|
||||
#01: C (C.cpp:99)
|
||||
}
|
||||
}
|
||||
|
||||
Unreported {
|
||||
-2 blocks in heap block record 4 of 5
|
||||
0 bytes (0 requested / 0 slop)
|
||||
Individual block sizes: 8,192 x 2; -4,096 x 4
|
||||
-0.00% of the heap (-62.74% cumulative)
|
||||
0.00% of unreported (100.00% cumulative)
|
||||
Allocated at {
|
||||
#01: B (B.cpp:99)
|
||||
}
|
||||
}
|
||||
|
||||
Unreported {
|
||||
0 blocks in heap block record 5 of 5
|
||||
0 bytes (0 requested / 0 slop)
|
||||
Individual block sizes: 20,480; -16,384; -8,192; 4,096
|
||||
-0.00% of the heap (-62.74% cumulative)
|
||||
0.00% of unreported (100.00% cumulative)
|
||||
Allocated at {
|
||||
#01: (no stack trace recorded due to --stacks=partial)
|
||||
}
|
||||
}
|
||||
|
||||
#-----------------------------------------------------------------
|
||||
|
||||
Once-reported {
|
||||
-3 blocks in heap block record 1 of 2
|
||||
-10,240 bytes (-10,192 requested / -48 slop)
|
||||
Individual block sizes: -4,096 x 2; -2,048
|
||||
145.48% of the heap (145.48% cumulative)
|
||||
98.77% of once-reported (98.77% cumulative)
|
||||
Allocated at {
|
||||
#01: D (D.cpp:99)
|
||||
}
|
||||
Reported at {
|
||||
#01: R1 (R1.cpp:99)
|
||||
}
|
||||
}
|
||||
|
||||
Once-reported {
|
||||
-1 blocks in heap block record 2 of 2
|
||||
-127 bytes (-151 requested / 24 slop)
|
||||
1.80% of the heap (147.28% cumulative)
|
||||
1.23% of once-reported (100.00% cumulative)
|
||||
Allocated at {
|
||||
#01: F (F.cpp:99)
|
||||
}
|
||||
Reported at {
|
||||
#01: R1 (R1.cpp:99)
|
||||
}
|
||||
}
|
||||
|
||||
#-----------------------------------------------------------------
|
||||
|
||||
Summary {
|
||||
Total: -7,039 bytes (100.00%) in 4 blocks (100.00%)
|
||||
Unreported: 4,416 bytes (-62.74%) in 9 blocks (225.00%)
|
||||
Once-reported: -10,367 bytes (147.28%) in -4 blocks (-100.00%)
|
||||
Twice-reported: -1,088 bytes ( 15.46%) in -1 blocks (-25.00%)
|
||||
}
|
||||
|
||||
|
|
@ -1,51 +0,0 @@
|
|||
{
|
||||
"version": 5,
|
||||
"invocation": {
|
||||
"dmdEnvVar": "--mode=dark-matter",
|
||||
"mode": "dark-matter"
|
||||
},
|
||||
"blockList": [
|
||||
{"req": 4096, "alloc": "A", "num": 4},
|
||||
|
||||
{"req": 4096, "alloc": "B", "num": 3},
|
||||
{"req": 4096, "alloc": "B"},
|
||||
|
||||
{"req": 4096, "alloc": "C", "num": 2},
|
||||
{"req": 4096, "alloc": "C", "num": 2},
|
||||
|
||||
{"req": 4096, "alloc": "D", "reps": ["R1"], "num": 2},
|
||||
{"req": 2000, "slop": 48, "alloc": "D", "reps": ["R1"]},
|
||||
|
||||
{"req": 15360, "alloc": "F"},
|
||||
{"req": 512, "alloc": "F", "num": 2},
|
||||
{"req": 127, "alloc": "F"},
|
||||
{"req": 1024, "alloc": "F", "reps": ["R1"]},
|
||||
{"req": 127, "alloc": "F", "reps": ["R1"]},
|
||||
{"req": 1000, "slop": 24, "alloc": "F", "reps": ["R1", "R2"]},
|
||||
{"req": 127, "alloc": "F", "reps": ["R1", "R2"]},
|
||||
|
||||
{"req": 4096 },
|
||||
{"req": 8192 },
|
||||
{"req": 16384 }
|
||||
],
|
||||
"traceTable": {
|
||||
"A": ["AA"],
|
||||
"B": ["BB"],
|
||||
"C": ["CC"],
|
||||
"D": ["DD"],
|
||||
"E": ["EE"],
|
||||
"F": ["FF"],
|
||||
"R1": ["RR1"],
|
||||
"R2": ["RR2"]
|
||||
},
|
||||
"frameTable": {
|
||||
"AA": "#00: A (A.cpp:99)",
|
||||
"BB": "#00: B (B.cpp:99)",
|
||||
"CC": "#00: C (C.cpp:99)",
|
||||
"DD": "#00: D (D.cpp:99)",
|
||||
"EE": "#00: E (E.cpp:99)",
|
||||
"FF": "#00: F (F.cpp:99)",
|
||||
"RR1": "#00: R1 (R1.cpp:99)",
|
||||
"RR2": "#00: R2 (R2.cpp:99)"
|
||||
}
|
||||
}
|
||||
|
|
@ -1,51 +0,0 @@
|
|||
{
|
||||
"version": 5,
|
||||
"invocation": {
|
||||
"dmdEnvVar": null,
|
||||
"mode": "dark-matter"
|
||||
},
|
||||
"blockList": [
|
||||
{"req": 4096, "alloc": "A", "num": 4},
|
||||
|
||||
{"req": 8192, "alloc": "B"},
|
||||
{"req": 8192, "alloc": "B"},
|
||||
|
||||
{"req": 4000, "slop": 96, "alloc": "C", "num": 4},
|
||||
|
||||
{"req": 4096, "alloc": "E", "num": 4},
|
||||
|
||||
{"req": 2000, "slop": 48, "alloc": "F"},
|
||||
{"req": 1000, "slop": 24, "alloc": "F", "reps": ["R1"]},
|
||||
{"req": 512, "alloc": "F"},
|
||||
{"req": 512, "alloc": "F"},
|
||||
{"req": 512, "alloc": "F"},
|
||||
{"req": 512, "alloc": "F"},
|
||||
{"req": 128, "alloc": "F"},
|
||||
{"req": 63, "alloc": "F", "reps": ["R1", "R2"]},
|
||||
{"req": 64, "alloc": "F", "num": 4},
|
||||
{"req": 63, "alloc": "F"},
|
||||
|
||||
{"req": 4096, "num": 2 },
|
||||
{"req": 20480 }
|
||||
],
|
||||
"traceTable": {
|
||||
"A": ["AA"],
|
||||
"B": ["BB"],
|
||||
"C": ["CC"],
|
||||
"D": ["DD"],
|
||||
"E": ["EE"],
|
||||
"F": ["FF"],
|
||||
"R1": ["RR1"],
|
||||
"R2": ["RR2"]
|
||||
},
|
||||
"frameTable": {
|
||||
"AA": "#00: A (A.cpp:99)",
|
||||
"BB": "#00: B (B.cpp:99)",
|
||||
"CC": "#00: C (C.cpp:99)",
|
||||
"DD": "#00: D (D.cpp:99)",
|
||||
"EE": "#00: E (E.cpp:99)",
|
||||
"FF": "#00: F (F.cpp:99)",
|
||||
"RR1": "#00: R1 (R1.cpp:99)",
|
||||
"RR2": "#00: R2 (R2.cpp:99)"
|
||||
}
|
||||
}
|
||||
|
|
@ -1,81 +0,0 @@
|
|||
#-----------------------------------------------------------------
|
||||
# dmd.py --filter-stacks-for-testing -o script-diff-live-actual.txt script-diff-live1.json script-diff-live2.json
|
||||
|
||||
Invocation 1 {
|
||||
$DMD = '--mode=live'
|
||||
Mode = 'live'
|
||||
}
|
||||
|
||||
Invocation 2 {
|
||||
$DMD = '--mode=live --stacks=partial'
|
||||
Mode = 'live'
|
||||
}
|
||||
|
||||
#-----------------------------------------------------------------
|
||||
|
||||
Live {
|
||||
4 blocks in heap block record 1 of 6
|
||||
16,384 bytes (16,384 requested / 0 slop)
|
||||
Individual block sizes: 4,096 x 4
|
||||
-232.76% of the heap (-232.76% cumulative)
|
||||
Allocated at {
|
||||
#01: E (E.cpp:99)
|
||||
}
|
||||
}
|
||||
|
||||
Live {
|
||||
5 blocks in heap block record 2 of 6
|
||||
-13,183 bytes (-13,231 requested / 48 slop)
|
||||
Individual block sizes: -15,360; 2,048; -1,024; 512 x 2; 128; -127 x 3; 64 x 4; 63 x 2
|
||||
187.29% of the heap (-45.48% cumulative)
|
||||
Allocated at {
|
||||
#01: F (F.cpp:99)
|
||||
}
|
||||
}
|
||||
|
||||
Live {
|
||||
-3 blocks in heap block record 3 of 6
|
||||
-10,240 bytes (-10,192 requested / -48 slop)
|
||||
Individual block sizes: -4,096 x 2; -2,048
|
||||
145.48% of the heap (100.00% cumulative)
|
||||
Allocated at {
|
||||
#01: D (D.cpp:99)
|
||||
}
|
||||
}
|
||||
|
||||
Live {
|
||||
0 blocks in heap block record 4 of 6
|
||||
0 bytes (-384 requested / 384 slop)
|
||||
Individual block sizes: (no change)
|
||||
-0.00% of the heap (100.00% cumulative)
|
||||
Allocated at {
|
||||
#01: C (C.cpp:99)
|
||||
}
|
||||
}
|
||||
|
||||
Live {
|
||||
0 blocks in heap block record 5 of 6
|
||||
0 bytes (0 requested / 0 slop)
|
||||
Individual block sizes: 20,480; -16,384; -8,192; 4,096
|
||||
-0.00% of the heap (100.00% cumulative)
|
||||
Allocated at {
|
||||
#01: (no stack trace recorded due to --stacks=partial)
|
||||
}
|
||||
}
|
||||
|
||||
Live {
|
||||
-2 blocks in heap block record 6 of 6
|
||||
0 bytes (0 requested / 0 slop)
|
||||
Individual block sizes: 8,192 x 2; -4,096 x 4
|
||||
-0.00% of the heap (100.00% cumulative)
|
||||
Allocated at {
|
||||
#01: B (B.cpp:99)
|
||||
}
|
||||
}
|
||||
|
||||
#-----------------------------------------------------------------
|
||||
|
||||
Summary {
|
||||
Total: -7,039 bytes in 4 blocks
|
||||
}
|
||||
|
||||
|
|
@ -1,51 +0,0 @@
|
|||
{
|
||||
"version": 5,
|
||||
"invocation": {
|
||||
"dmdEnvVar": "--mode=live",
|
||||
"mode": "live"
|
||||
},
|
||||
"blockList": [
|
||||
{"req": 4096, "alloc": "A", "num": 4},
|
||||
|
||||
{"req": 4096, "alloc": "B", "num": 4},
|
||||
|
||||
{"req": 4096, "alloc": "C", "num": 4},
|
||||
|
||||
{"req": 4096, "alloc": "D"},
|
||||
{"req": 4096, "alloc": "D"},
|
||||
{"req": 2000, "slop": 48, "alloc": "D"},
|
||||
|
||||
{"req": 15360, "alloc": "F"},
|
||||
{"req": 512, "alloc": "F"},
|
||||
{"req": 512, "alloc": "F"},
|
||||
{"req": 127, "alloc": "F"},
|
||||
{"req": 1024, "alloc": "F"},
|
||||
{"req": 127, "alloc": "F"},
|
||||
{"req": 1000, "slop": 24, "alloc": "F"},
|
||||
{"req": 127, "alloc": "F"},
|
||||
|
||||
{"req": 4096 },
|
||||
{"req": 8192 },
|
||||
{"req": 16384 }
|
||||
],
|
||||
"traceTable": {
|
||||
"A": ["AA"],
|
||||
"B": ["BB"],
|
||||
"C": ["CC"],
|
||||
"D": ["DD"],
|
||||
"E": ["EE"],
|
||||
"F": ["FF"],
|
||||
"R1": ["RR1"],
|
||||
"R2": ["RR2"]
|
||||
},
|
||||
"frameTable": {
|
||||
"AA": "#00: A (A.cpp:99)",
|
||||
"BB": "#00: B (B.cpp:99)",
|
||||
"CC": "#00: C (C.cpp:99)",
|
||||
"DD": "#00: D (D.cpp:99)",
|
||||
"EE": "#00: E (E.cpp:99)",
|
||||
"FF": "#00: F (F.cpp:99)",
|
||||
"RR1": "#00: R1 (R1.cpp:99)",
|
||||
"RR2": "#00: R2 (R2.cpp:99)"
|
||||
}
|
||||
}
|
||||
|
|
@ -1,53 +0,0 @@
|
|||
{
|
||||
"version": 5,
|
||||
"invocation": {
|
||||
"dmdEnvVar": "--mode=live --stacks=partial",
|
||||
"mode": "live"
|
||||
},
|
||||
"blockList": [
|
||||
{"req": 4096, "alloc": "A", "num": 3},
|
||||
{"req": 4096, "alloc": "A"},
|
||||
|
||||
{"req": 8192, "alloc": "B"},
|
||||
{"req": 8192, "alloc": "B"},
|
||||
|
||||
{"req": 4000, "slop": 96, "alloc": "C", "num": 4},
|
||||
|
||||
{"req": 4096, "alloc": "E"},
|
||||
{"req": 4096, "alloc": "E"},
|
||||
{"req": 4096, "alloc": "E"},
|
||||
{"req": 4096, "alloc": "E"},
|
||||
|
||||
{"req": 2000, "slop": 48, "alloc": "F"},
|
||||
{"req": 1000, "slop": 24, "alloc": "F"},
|
||||
{"req": 512, "alloc": "F", "num": 4},
|
||||
{"req": 128, "alloc": "F"},
|
||||
{"req": 63, "alloc": "F"},
|
||||
{"req": 64, "alloc": "F", "num": 4},
|
||||
{"req": 63, "alloc": "F"},
|
||||
|
||||
{"req": 4096 },
|
||||
{"req": 4096 },
|
||||
{"req": 20480 }
|
||||
],
|
||||
"traceTable": {
|
||||
"A": ["AA"],
|
||||
"B": ["BB"],
|
||||
"C": ["CC"],
|
||||
"D": ["DD"],
|
||||
"E": ["EE"],
|
||||
"F": ["FF"],
|
||||
"R1": ["RR1"],
|
||||
"R2": ["RR2"]
|
||||
},
|
||||
"frameTable": {
|
||||
"AA": "#00: A (A.cpp:99)",
|
||||
"BB": "#00: B (B.cpp:99)",
|
||||
"CC": "#00: C (C.cpp:99)",
|
||||
"DD": "#00: D (D.cpp:99)",
|
||||
"EE": "#00: E (E.cpp:99)",
|
||||
"FF": "#00: F (F.cpp:99)",
|
||||
"RR1": "#00: R1 (R1.cpp:99)",
|
||||
"RR2": "#00: R2 (R2.cpp:99)"
|
||||
}
|
||||
}
|
||||
|
|
@ -1,72 +0,0 @@
|
|||
#-----------------------------------------------------------------
|
||||
# dmd.py --filter-stacks-for-testing -o script-ignore-alloc-fns-actual.txt --ignore-alloc-fns script-ignore-alloc-fns.json
|
||||
|
||||
Invocation {
|
||||
$DMD is undefined
|
||||
Mode = 'dark-matter'
|
||||
}
|
||||
|
||||
#-----------------------------------------------------------------
|
||||
|
||||
# no twice-reported heap blocks
|
||||
|
||||
#-----------------------------------------------------------------
|
||||
|
||||
Unreported {
|
||||
1 block in heap block record 1 of 4
|
||||
1,048,576 bytes (1,048,576 requested / 0 slop)
|
||||
93.22% of the heap (93.22% cumulative)
|
||||
93.22% of unreported (93.22% cumulative)
|
||||
Allocated at {
|
||||
#01: A (A.cpp:99)
|
||||
}
|
||||
}
|
||||
|
||||
Unreported {
|
||||
1 block in heap block record 2 of 4
|
||||
65,536 bytes (65,536 requested / 0 slop)
|
||||
5.83% of the heap (99.05% cumulative)
|
||||
5.83% of unreported (99.05% cumulative)
|
||||
Allocated at {
|
||||
#01: js::jit::JitRuntime::initialize(JSContext*) (Ion.cpp:301)
|
||||
}
|
||||
}
|
||||
|
||||
Unreported {
|
||||
1 block in heap block record 3 of 4
|
||||
8,192 bytes (8,000 requested / 192 slop)
|
||||
0.73% of the heap (99.78% cumulative)
|
||||
0.73% of unreported (99.78% cumulative)
|
||||
Allocated at {
|
||||
#01: mozilla::Vector::growStorageBy(unsigned long) (Vector.h:802)
|
||||
#02: D (D.cpp:99)
|
||||
}
|
||||
}
|
||||
|
||||
Unreported {
|
||||
1 block in heap block record 4 of 4
|
||||
2,500 bytes (2,500 requested / 0 slop)
|
||||
0.22% of the heap (100.00% cumulative)
|
||||
0.22% of unreported (100.00% cumulative)
|
||||
Allocated at {
|
||||
#01: g_type_create_instance (/usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0)
|
||||
#02: not_an_alloc_function_so_alloc_functions_below_here_will_not_be_stripped (blah)
|
||||
#03: replace_posix_memalign (replace_malloc.h:120)
|
||||
#04: ??? (/lib/x86_64-linux-gnu/libglib-2.0.so.0)
|
||||
#05: another_non_alloc_function (blah)
|
||||
}
|
||||
}
|
||||
|
||||
#-----------------------------------------------------------------
|
||||
|
||||
# no once-reported heap blocks
|
||||
|
||||
#-----------------------------------------------------------------
|
||||
|
||||
Summary {
|
||||
Total: 1,124,804 bytes (100.00%) in 4 blocks (100.00%)
|
||||
Unreported: 1,124,804 bytes (100.00%) in 4 blocks (100.00%)
|
||||
Once-reported: 0 bytes ( 0.00%) in 0 blocks ( 0.00%)
|
||||
Twice-reported: 0 bytes ( 0.00%) in 0 blocks ( 0.00%)
|
||||
}
|
||||
|
||||
|
|
@ -1,46 +0,0 @@
|
|||
{
|
||||
"version": 5,
|
||||
"invocation": {
|
||||
"dmdEnvVar": null,
|
||||
"mode": "dark-matter"
|
||||
},
|
||||
"blockList": [
|
||||
{"req": 1048576, "alloc": "A"},
|
||||
{"req": 65536, "alloc": "B"},
|
||||
{"req": 8000, "slop": 192, "alloc": "C"},
|
||||
{"req": 2500, "alloc": "D"}
|
||||
],
|
||||
"traceTable": {
|
||||
"A": ["AA", "AB", "AC", "AD"],
|
||||
"B": ["BA", "BB", "BC"],
|
||||
"C": ["CA", "CB", "CC", "CD"],
|
||||
"D": ["DA", "DB", "DD", "DD", "DE", "DF", "DG", "DH", "DI", "DJ"]
|
||||
},
|
||||
"frameTable": {
|
||||
"AA": "#00: replace_malloc (DMD.cpp:1106)",
|
||||
"AB": "#00: moz_xmalloc (mozalloc.cpp:68)",
|
||||
"AC": "#00: operator new(unsigned long) (mozalloc.h:208)",
|
||||
"AD": "#00: A (A.cpp:99)",
|
||||
|
||||
"BA": "#00: replace_calloc (DMD.cpp:1125)",
|
||||
"BB": "#00: js_calloc(unsigned long) (Utility.h:107)",
|
||||
"BC": "#06: js::jit::JitRuntime::initialize(JSContext*) (Ion.cpp:301)",
|
||||
|
||||
"CA": "#00: replace_realloc (DMD.cpp:1153)",
|
||||
"CB": "#00: bool* mozilla::MallocAllocPolicy::pod_realloc<bool>(bool*, unsigned long, unsigned long) (AllocPolicy.h:74)",
|
||||
"CC": "#00: mozilla::Vector::growStorageBy(unsigned long) (Vector.h:802)",
|
||||
"CD": "#00: D (D.cpp:99)",
|
||||
|
||||
"DA": "#00: replace_memalign (DMD.cpp:1181)",
|
||||
"DB": "#00: replace_posix_memalign (replace_malloc.h:120)",
|
||||
"DC": "#00: ??? (/lib/x86_64-linux-gnu/libglib-2.0.so.0)",
|
||||
"DD": "#00: g_slice_alloc (/lib/x86_64-linux-gnu/libglib-2.0.so.0)",
|
||||
"DE": "#00: g_slice_alloc0 (/lib/x86_64-linux-gnu/libglib-2.0.so.0)",
|
||||
"DF": "#00: g_type_create_instance (/usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0)",
|
||||
"DG": "#00: not_an_alloc_function_so_alloc_functions_below_here_will_not_be_stripped (blah)",
|
||||
"DH": "#00: replace_posix_memalign (replace_malloc.h:120)",
|
||||
"DI": "#00: ??? (/lib/x86_64-linux-gnu/libglib-2.0.so.0)",
|
||||
"DJ": "#00: another_non_alloc_function (blah)"
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1,26 +0,0 @@
|
|||
#-----------------------------------------------------------------
|
||||
# dmd.py --filter-stacks-for-testing -o script-max-frames-1-actual.txt --max-frames=1 script-max-frames.json
|
||||
|
||||
Invocation {
|
||||
$DMD = '--mode=live --stacks=full'
|
||||
Mode = 'live'
|
||||
}
|
||||
|
||||
#-----------------------------------------------------------------
|
||||
|
||||
Live {
|
||||
4 blocks in heap block record 1 of 1
|
||||
4,416 bytes (4,404 requested / 12 slop)
|
||||
Individual block sizes: 4,096; 128; 112; 80
|
||||
100.00% of the heap (100.00% cumulative)
|
||||
Allocated at {
|
||||
#01: E (E.cpp:99)
|
||||
}
|
||||
}
|
||||
|
||||
#-----------------------------------------------------------------
|
||||
|
||||
Summary {
|
||||
Total: 4,416 bytes in 4 blocks
|
||||
}
|
||||
|
||||
|
|
@ -1,48 +0,0 @@
|
|||
#-----------------------------------------------------------------
|
||||
# dmd.py --filter-stacks-for-testing -o script-max-frames-3-actual.txt --max-frames=3 --no-fix-stacks script-max-frames.json
|
||||
|
||||
Invocation {
|
||||
$DMD = '--mode=live --stacks=full'
|
||||
Mode = 'live'
|
||||
}
|
||||
|
||||
#-----------------------------------------------------------------
|
||||
|
||||
Live {
|
||||
2 blocks in heap block record 1 of 3
|
||||
4,224 bytes (4,224 requested / 0 slop)
|
||||
Individual block sizes: 4,096; 128
|
||||
95.65% of the heap (95.65% cumulative)
|
||||
Allocated at {
|
||||
#01: E (E.cpp:99)
|
||||
#02: F (F.cpp:99)
|
||||
#03: G (G.cpp:99)
|
||||
}
|
||||
}
|
||||
|
||||
Live {
|
||||
1 block in heap block record 2 of 3
|
||||
112 bytes (100 requested / 12 slop)
|
||||
2.54% of the heap (98.19% cumulative)
|
||||
Allocated at {
|
||||
#01: E (E.cpp:99)
|
||||
#02: X (X.cpp:99)
|
||||
#03: Y (Y.cpp:99)
|
||||
}
|
||||
}
|
||||
|
||||
Live {
|
||||
1 block in heap block record 3 of 3
|
||||
80 bytes (80 requested / 0 slop)
|
||||
1.81% of the heap (100.00% cumulative)
|
||||
Allocated at {
|
||||
#01: E (E.cpp:99)
|
||||
}
|
||||
}
|
||||
|
||||
#-----------------------------------------------------------------
|
||||
|
||||
Summary {
|
||||
Total: 4,416 bytes in 4 blocks
|
||||
}
|
||||
|
||||
|
|
@ -1,69 +0,0 @@
|
|||
#-----------------------------------------------------------------
|
||||
# dmd.py --filter-stacks-for-testing -o script-max-frames-8-actual.txt --max-frames=8 script-max-frames.json
|
||||
|
||||
Invocation {
|
||||
$DMD = '--mode=live --stacks=full'
|
||||
Mode = 'live'
|
||||
}
|
||||
|
||||
#-----------------------------------------------------------------
|
||||
|
||||
Live {
|
||||
1 block in heap block record 1 of 4
|
||||
4,096 bytes (4,096 requested / 0 slop)
|
||||
92.75% of the heap (92.75% cumulative)
|
||||
Allocated at {
|
||||
#01: E (E.cpp:99)
|
||||
#02: F (F.cpp:99)
|
||||
#03: G (G.cpp:99)
|
||||
#04: H (H.cpp:99)
|
||||
#05: I (I.cpp:99)
|
||||
#06: J (J.cpp:99)
|
||||
#07: K (K.cpp:99)
|
||||
#08: L (L.cpp:99)
|
||||
}
|
||||
}
|
||||
|
||||
Live {
|
||||
1 block in heap block record 2 of 4
|
||||
128 bytes (128 requested / 0 slop)
|
||||
2.90% of the heap (95.65% cumulative)
|
||||
Allocated at {
|
||||
#01: E (E.cpp:99)
|
||||
#02: F (F.cpp:99)
|
||||
#03: G (G.cpp:99)
|
||||
#04: R (R.cpp:99)
|
||||
#05: S (S.cpp:99)
|
||||
#06: T (T.cpp:99)
|
||||
#07: U (U.cpp:99)
|
||||
#08: V (V.cpp:99)
|
||||
}
|
||||
}
|
||||
|
||||
Live {
|
||||
1 block in heap block record 3 of 4
|
||||
112 bytes (100 requested / 12 slop)
|
||||
2.54% of the heap (98.19% cumulative)
|
||||
Allocated at {
|
||||
#01: E (E.cpp:99)
|
||||
#02: X (X.cpp:99)
|
||||
#03: Y (Y.cpp:99)
|
||||
#04: Z (Z.cpp:99)
|
||||
}
|
||||
}
|
||||
|
||||
Live {
|
||||
1 block in heap block record 4 of 4
|
||||
80 bytes (80 requested / 0 slop)
|
||||
1.81% of the heap (100.00% cumulative)
|
||||
Allocated at {
|
||||
#01: E (E.cpp:99)
|
||||
}
|
||||
}
|
||||
|
||||
#-----------------------------------------------------------------
|
||||
|
||||
Summary {
|
||||
Total: 4,416 bytes in 4 blocks
|
||||
}
|
||||
|
||||
|
|
@ -1,43 +0,0 @@
|
|||
{
|
||||
"version": 5,
|
||||
"invocation": {
|
||||
"dmdEnvVar": "--mode=live --stacks=full",
|
||||
"mode": "live"
|
||||
},
|
||||
"blockList": [
|
||||
{"req": 4096, "alloc": "A"},
|
||||
{"req": 128, "alloc": "B"},
|
||||
{"req": 100, "slop":12, "alloc": "C"},
|
||||
{"req": 80, "alloc": "D"}
|
||||
],
|
||||
"traceTable": {
|
||||
"A": ["E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P"],
|
||||
"B": ["E", "F", "G", "R", "S", "T", "U", "V"],
|
||||
"C": ["E", "X", "Y", "Z"],
|
||||
"D": ["E"]
|
||||
},
|
||||
"frameTable": {
|
||||
"E": "#00: E (E.cpp:99)",
|
||||
"F": "#00: F (F.cpp:99)",
|
||||
"G": "#00: G (G.cpp:99)",
|
||||
"H": "#00: H (H.cpp:99)",
|
||||
"I": "#00: I (I.cpp:99)",
|
||||
"J": "#00: J (J.cpp:99)",
|
||||
"K": "#00: K (K.cpp:99)",
|
||||
"L": "#00: L (L.cpp:99)",
|
||||
"M": "#00: M (M.cpp:99)",
|
||||
"N": "#00: N (N.cpp:99)",
|
||||
"O": "#00: O (O.cpp:99)",
|
||||
"P": "#00: P (P.cpp:99)",
|
||||
"Q": "#00: Q (Q.cpp:99)",
|
||||
"R": "#00: R (R.cpp:99)",
|
||||
"S": "#00: S (S.cpp:99)",
|
||||
"T": "#00: T (T.cpp:99)",
|
||||
"U": "#00: U (U.cpp:99)",
|
||||
"V": "#00: V (V.cpp:99)",
|
||||
"W": "#00: W (W.cpp:99)",
|
||||
"X": "#00: X (X.cpp:99)",
|
||||
"Y": "#00: Y (Y.cpp:99)",
|
||||
"Z": "#00: Z (Z.cpp:99)"
|
||||
}
|
||||
}
|
||||
|
|
@ -1,46 +0,0 @@
|
|||
#-----------------------------------------------------------------
|
||||
# dmd.py --filter-stacks-for-testing -o script-sort-by-num-blocks-actual.txt --sort-by=num-blocks script-sort-by.json.gz
|
||||
|
||||
Invocation {
|
||||
$DMD = '--mode=live'
|
||||
Mode = 'live'
|
||||
}
|
||||
|
||||
#-----------------------------------------------------------------
|
||||
|
||||
Live {
|
||||
8 blocks in heap block record 1 of 3
|
||||
16,384 bytes (8,200 requested / 8,184 slop)
|
||||
Individual block sizes: 2,048 x 8
|
||||
33.32% of the heap (33.32% cumulative)
|
||||
Allocated at {
|
||||
#01: C (C.cpp:99)
|
||||
}
|
||||
}
|
||||
|
||||
Live {
|
||||
5 blocks in heap block record 2 of 3
|
||||
16,400 bytes (12,016 requested / 4,384 slop)
|
||||
Individual block sizes: 4,096 x 4; 16
|
||||
33.35% of the heap (66.67% cumulative)
|
||||
Allocated at {
|
||||
#01: B (B.cpp:99)
|
||||
}
|
||||
}
|
||||
|
||||
Live {
|
||||
5 blocks in heap block record 3 of 3
|
||||
16,392 bytes (16,392 requested / 0 slop)
|
||||
Individual block sizes: 4,096 x 4; 8
|
||||
33.33% of the heap (100.00% cumulative)
|
||||
Allocated at {
|
||||
#01: A (A.cpp:99)
|
||||
}
|
||||
}
|
||||
|
||||
#-----------------------------------------------------------------
|
||||
|
||||
Summary {
|
||||
Total: 49,176 bytes in 18 blocks
|
||||
}
|
||||
|
||||
|
|
@ -1,46 +0,0 @@
|
|||
#-----------------------------------------------------------------
|
||||
# dmd.py --filter-stacks-for-testing -o script-sort-by-req-actual.txt --sort-by=req --no-fix-stacks script-sort-by.json.gz
|
||||
|
||||
Invocation {
|
||||
$DMD = '--mode=live'
|
||||
Mode = 'live'
|
||||
}
|
||||
|
||||
#-----------------------------------------------------------------
|
||||
|
||||
Live {
|
||||
5 blocks in heap block record 1 of 3
|
||||
16,392 bytes (16,392 requested / 0 slop)
|
||||
Individual block sizes: 4,096 x 4; 8
|
||||
33.33% of the heap (33.33% cumulative)
|
||||
Allocated at {
|
||||
#01: A (A.cpp:99)
|
||||
}
|
||||
}
|
||||
|
||||
Live {
|
||||
5 blocks in heap block record 2 of 3
|
||||
16,400 bytes (12,016 requested / 4,384 slop)
|
||||
Individual block sizes: 4,096 x 4; 16
|
||||
33.35% of the heap (66.68% cumulative)
|
||||
Allocated at {
|
||||
#01: B (B.cpp:99)
|
||||
}
|
||||
}
|
||||
|
||||
Live {
|
||||
8 blocks in heap block record 3 of 3
|
||||
16,384 bytes (8,200 requested / 8,184 slop)
|
||||
Individual block sizes: 2,048 x 8
|
||||
33.32% of the heap (100.00% cumulative)
|
||||
Allocated at {
|
||||
#01: C (C.cpp:99)
|
||||
}
|
||||
}
|
||||
|
||||
#-----------------------------------------------------------------
|
||||
|
||||
Summary {
|
||||
Total: 49,176 bytes in 18 blocks
|
||||
}
|
||||
|
||||
|
|
@ -1,46 +0,0 @@
|
|||
#-----------------------------------------------------------------
|
||||
# dmd.py --filter-stacks-for-testing -o script-sort-by-slop-actual.txt --sort-by=slop script-sort-by.json.gz
|
||||
|
||||
Invocation {
|
||||
$DMD = '--mode=live'
|
||||
Mode = 'live'
|
||||
}
|
||||
|
||||
#-----------------------------------------------------------------
|
||||
|
||||
Live {
|
||||
8 blocks in heap block record 1 of 3
|
||||
16,384 bytes (8,200 requested / 8,184 slop)
|
||||
Individual block sizes: 2,048 x 8
|
||||
33.32% of the heap (33.32% cumulative)
|
||||
Allocated at {
|
||||
#01: C (C.cpp:99)
|
||||
}
|
||||
}
|
||||
|
||||
Live {
|
||||
5 blocks in heap block record 2 of 3
|
||||
16,400 bytes (12,016 requested / 4,384 slop)
|
||||
Individual block sizes: 4,096 x 4; 16
|
||||
33.35% of the heap (66.67% cumulative)
|
||||
Allocated at {
|
||||
#01: B (B.cpp:99)
|
||||
}
|
||||
}
|
||||
|
||||
Live {
|
||||
5 blocks in heap block record 3 of 3
|
||||
16,392 bytes (16,392 requested / 0 slop)
|
||||
Individual block sizes: 4,096 x 4; 8
|
||||
33.33% of the heap (100.00% cumulative)
|
||||
Allocated at {
|
||||
#01: A (A.cpp:99)
|
||||
}
|
||||
}
|
||||
|
||||
#-----------------------------------------------------------------
|
||||
|
||||
Summary {
|
||||
Total: 49,176 bytes in 18 blocks
|
||||
}
|
||||
|
||||
|
|
@ -1,46 +0,0 @@
|
|||
#-----------------------------------------------------------------
|
||||
# dmd.py --filter-stacks-for-testing -o script-sort-by-usable-actual.txt --sort-by=usable script-sort-by.json.gz
|
||||
|
||||
Invocation {
|
||||
$DMD = '--mode=live'
|
||||
Mode = 'live'
|
||||
}
|
||||
|
||||
#-----------------------------------------------------------------
|
||||
|
||||
Live {
|
||||
5 blocks in heap block record 1 of 3
|
||||
16,400 bytes (12,016 requested / 4,384 slop)
|
||||
Individual block sizes: 4,096 x 4; 16
|
||||
33.35% of the heap (33.35% cumulative)
|
||||
Allocated at {
|
||||
#01: B (B.cpp:99)
|
||||
}
|
||||
}
|
||||
|
||||
Live {
|
||||
5 blocks in heap block record 2 of 3
|
||||
16,392 bytes (16,392 requested / 0 slop)
|
||||
Individual block sizes: 4,096 x 4; 8
|
||||
33.33% of the heap (66.68% cumulative)
|
||||
Allocated at {
|
||||
#01: A (A.cpp:99)
|
||||
}
|
||||
}
|
||||
|
||||
Live {
|
||||
8 blocks in heap block record 3 of 3
|
||||
16,384 bytes (8,200 requested / 8,184 slop)
|
||||
Individual block sizes: 2,048 x 8
|
||||
33.32% of the heap (100.00% cumulative)
|
||||
Allocated at {
|
||||
#01: C (C.cpp:99)
|
||||
}
|
||||
}
|
||||
|
||||
#-----------------------------------------------------------------
|
||||
|
||||
Summary {
|
||||
Total: 49,176 bytes in 18 blocks
|
||||
}
|
||||
|
||||
Binary file not shown.
|
|
@ -1,226 +0,0 @@
|
|||
/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*-*/
|
||||
/* vim: set ts=8 sts=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/. */
|
||||
|
||||
"use strict";
|
||||
|
||||
var {classes: Cc, interfaces: Ci, utils: Cu} = Components
|
||||
|
||||
Cu.import("resource://gre/modules/FileUtils.jsm");
|
||||
|
||||
// The xpcshell test harness sets PYTHON so we can read it here.
|
||||
var gEnv = Cc["@mozilla.org/process/environment;1"]
|
||||
.getService(Ci.nsIEnvironment);
|
||||
var gPythonName = gEnv.get("PYTHON");
|
||||
|
||||
// If we're testing locally, the executable file is in "CurProcD". Otherwise,
|
||||
// it is in another location that we have to find.
|
||||
function getExecutable(aFilename) {
|
||||
let file = FileUtils.getFile("CurProcD", [aFilename]);
|
||||
if (!file.exists()) {
|
||||
file = FileUtils.getFile("CurWorkD", []);
|
||||
while (file.path.includes("xpcshell")) {
|
||||
file = file.parent;
|
||||
}
|
||||
file.append("bin");
|
||||
file.append(aFilename);
|
||||
}
|
||||
return file;
|
||||
}
|
||||
|
||||
var gIsWindows = Cc["@mozilla.org/xre/app-info;1"]
|
||||
.getService(Ci.nsIXULRuntime).OS === "WINNT";
|
||||
var gDmdTestFile = getExecutable("SmokeDMD" + (gIsWindows ? ".exe" : ""));
|
||||
|
||||
var gDmdScriptFile = getExecutable("dmd.py");
|
||||
|
||||
var gScanTestFile = FileUtils.getFile("CurWorkD", ["scan-test.py"]);
|
||||
|
||||
function readFile(aFile) {
|
||||
let fstream = Cc["@mozilla.org/network/file-input-stream;1"]
|
||||
.createInstance(Ci.nsIFileInputStream);
|
||||
let cstream = Cc["@mozilla.org/intl/converter-input-stream;1"]
|
||||
.createInstance(Ci.nsIConverterInputStream);
|
||||
fstream.init(aFile, -1, 0, 0);
|
||||
cstream.init(fstream, "UTF-8", 0, 0);
|
||||
|
||||
let data = "";
|
||||
let str = {};
|
||||
let read = 0;
|
||||
do {
|
||||
// Read as much as we can and put it in str.value.
|
||||
read = cstream.readString(0xffffffff, str);
|
||||
data += str.value;
|
||||
} while (read != 0);
|
||||
|
||||
cstream.close(); // this closes fstream
|
||||
return data.replace(/\r/g, ""); // normalize line endings
|
||||
}
|
||||
|
||||
function runProcess(aExeFile, aArgs) {
|
||||
let process = Cc["@mozilla.org/process/util;1"]
|
||||
.createInstance(Components.interfaces.nsIProcess);
|
||||
process.init(aExeFile);
|
||||
process.run(/* blocking = */true, aArgs, aArgs.length);
|
||||
return process.exitValue;
|
||||
}
|
||||
|
||||
function test(aPrefix, aArgs) {
|
||||
// DMD writes the JSON files to CurWorkD, so we do likewise here with
|
||||
// |actualFile| for consistency. It is removed once we've finished.
|
||||
let expectedFile = FileUtils.getFile("CurWorkD", [aPrefix + "-expected.txt"]);
|
||||
let actualFile = FileUtils.getFile("CurWorkD", [aPrefix + "-actual.txt"]);
|
||||
|
||||
// Run dmd.py on the JSON file, producing |actualFile|.
|
||||
|
||||
let args = [
|
||||
gDmdScriptFile.path,
|
||||
"--filter-stacks-for-testing",
|
||||
"-o", actualFile.path
|
||||
].concat(aArgs);
|
||||
|
||||
runProcess(new FileUtils.File(gPythonName), args);
|
||||
|
||||
// Compare |expectedFile| with |actualFile|. We produce nice diffs with
|
||||
// /usr/bin/diff on systems that have it (Mac and Linux). Otherwise (Windows)
|
||||
// we do a string compare of the file contents and then print them both if
|
||||
// they don't match.
|
||||
|
||||
let success;
|
||||
try {
|
||||
let rv = runProcess(new FileUtils.File("/usr/bin/diff"),
|
||||
["-u", expectedFile.path, actualFile.path]);
|
||||
success = rv == 0;
|
||||
|
||||
} catch (e) {
|
||||
let expectedData = readFile(expectedFile);
|
||||
let actualData = readFile(actualFile);
|
||||
success = expectedData === actualData;
|
||||
if (!success) {
|
||||
expectedData = expectedData.split("\n");
|
||||
actualData = actualData.split("\n");
|
||||
for (let i = 0; i < expectedData.length; i++) {
|
||||
print("EXPECTED:" + expectedData[i]);
|
||||
}
|
||||
for (let i = 0; i < actualData.length; i++) {
|
||||
print(" ACTUAL:" + actualData[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ok(success, aPrefix);
|
||||
|
||||
actualFile.remove(true);
|
||||
}
|
||||
|
||||
// Run scan-test.py on the JSON file and see if it succeeds.
|
||||
function scanTest(aJsonFilePath, aExtraArgs) {
|
||||
let args = [
|
||||
gScanTestFile.path,
|
||||
aJsonFilePath,
|
||||
].concat(aExtraArgs);
|
||||
|
||||
return runProcess(new FileUtils.File(gPythonName), args) == 0;
|
||||
}
|
||||
|
||||
function run_test() {
|
||||
let jsonFile, jsonFile2;
|
||||
|
||||
// These tests do complete end-to-end testing of DMD, i.e. both the C++ code
|
||||
// that generates the JSON output, and the script that post-processes that
|
||||
// output.
|
||||
//
|
||||
// Run these synchronously, because test() updates the complete*.json files
|
||||
// in-place (to fix stacks) when it runs dmd.py, and that's not safe to do
|
||||
// asynchronously.
|
||||
|
||||
gEnv.set(gEnv.get("DMD_PRELOAD_VAR"), gEnv.get("DMD_PRELOAD_VALUE"));
|
||||
|
||||
runProcess(gDmdTestFile, []);
|
||||
|
||||
function test2(aTestName, aMode) {
|
||||
let name = "complete-" + aTestName + "-" + aMode;
|
||||
jsonFile = FileUtils.getFile("CurWorkD", [name + ".json"]);
|
||||
test(name, [jsonFile.path]);
|
||||
jsonFile.remove(true);
|
||||
}
|
||||
|
||||
// Please keep this in sync with RunTests() in SmokeDMD.cpp.
|
||||
|
||||
test2("empty", "live");
|
||||
test2("empty", "dark-matter");
|
||||
test2("empty", "cumulative");
|
||||
|
||||
test2("full1", "live");
|
||||
test2("full1", "dark-matter");
|
||||
|
||||
test2("full2", "dark-matter");
|
||||
test2("full2", "cumulative");
|
||||
|
||||
test2("partial", "live");
|
||||
|
||||
// Heap scan testing.
|
||||
jsonFile = FileUtils.getFile("CurWorkD", ["basic-scan.json"]);
|
||||
ok(scanTest(jsonFile.path), "Basic scan test");
|
||||
|
||||
let is64Bit = Components.classes["@mozilla.org/xre/app-info;1"]
|
||||
.getService(Components.interfaces.nsIXULRuntime).is64Bit;
|
||||
let basicScanFileName = "basic-scan-" + (is64Bit ? "64" : "32");
|
||||
test(basicScanFileName, ["--clamp-contents", jsonFile.path]);
|
||||
ok(scanTest(jsonFile.path, ["--clamp-contents"]), "Scan with address clamping");
|
||||
|
||||
// Run the generic test a second time to ensure that the first time produced
|
||||
// valid JSON output. "--clamp-contents" is passed in so we don't have to have
|
||||
// more variants of the files.
|
||||
test(basicScanFileName, ["--clamp-contents", jsonFile.path]);
|
||||
jsonFile.remove(true);
|
||||
|
||||
// These tests only test the post-processing script. They use hand-written
|
||||
// JSON files as input. Ideally the JSON files would contain comments
|
||||
// explaining how they work, but JSON doesn't allow comments, so I've put
|
||||
// explanations here.
|
||||
|
||||
// This just tests that stack traces of various lengths are truncated
|
||||
// appropriately. The number of records in the output is different for each
|
||||
// of the tested values.
|
||||
jsonFile = FileUtils.getFile("CurWorkD", ["script-max-frames.json"]);
|
||||
test("script-max-frames-8",
|
||||
["--max-frames=8", jsonFile.path]);
|
||||
test("script-max-frames-3",
|
||||
["--max-frames=3", "--no-fix-stacks", jsonFile.path]);
|
||||
test("script-max-frames-1",
|
||||
["--max-frames=1", jsonFile.path]);
|
||||
|
||||
// This file has three records that are shown in a different order for each
|
||||
// of the different sort values. It also tests the handling of gzipped JSON
|
||||
// files.
|
||||
jsonFile = FileUtils.getFile("CurWorkD", ["script-sort-by.json.gz"]);
|
||||
test("script-sort-by-usable",
|
||||
["--sort-by=usable", jsonFile.path]);
|
||||
test("script-sort-by-req",
|
||||
["--sort-by=req", "--no-fix-stacks", jsonFile.path]);
|
||||
test("script-sort-by-slop",
|
||||
["--sort-by=slop", jsonFile.path]);
|
||||
test("script-sort-by-num-blocks",
|
||||
["--sort-by=num-blocks", jsonFile.path]);
|
||||
|
||||
// This file has several real stack traces taken from Firefox execution, each
|
||||
// of which tests a different allocator function (or functions).
|
||||
jsonFile = FileUtils.getFile("CurWorkD", ["script-ignore-alloc-fns.json"]);
|
||||
test("script-ignore-alloc-fns",
|
||||
["--ignore-alloc-fns", jsonFile.path]);
|
||||
|
||||
// This tests "live"-mode diffs.
|
||||
jsonFile = FileUtils.getFile("CurWorkD", ["script-diff-live1.json"]);
|
||||
jsonFile2 = FileUtils.getFile("CurWorkD", ["script-diff-live2.json"]);
|
||||
test("script-diff-live",
|
||||
[jsonFile.path, jsonFile2.path]);
|
||||
|
||||
// This tests "dark-matter"-mode diffs.
|
||||
jsonFile = FileUtils.getFile("CurWorkD", ["script-diff-dark-matter1.json"]);
|
||||
jsonFile2 = FileUtils.getFile("CurWorkD", ["script-diff-dark-matter2.json"]);
|
||||
test("script-diff-dark-matter",
|
||||
[jsonFile.path, jsonFile2.path]);
|
||||
}
|
||||
|
|
@ -1,35 +0,0 @@
|
|||
[DEFAULT]
|
||||
support-files =
|
||||
basic-scan-32-expected.txt
|
||||
basic-scan-64-expected.txt
|
||||
complete-empty-live-expected.txt
|
||||
complete-empty-dark-matter-expected.txt
|
||||
complete-empty-cumulative-expected.txt
|
||||
complete-full1-live-expected.txt
|
||||
complete-full1-dark-matter-expected.txt
|
||||
complete-full2-dark-matter-expected.txt
|
||||
complete-full2-cumulative-expected.txt
|
||||
complete-partial-live-expected.txt
|
||||
scan-test.py
|
||||
script-max-frames.json
|
||||
script-max-frames-8-expected.txt
|
||||
script-max-frames-3-expected.txt
|
||||
script-max-frames-1-expected.txt
|
||||
script-sort-by.json.gz
|
||||
script-sort-by-usable-expected.txt
|
||||
script-sort-by-req-expected.txt
|
||||
script-sort-by-slop-expected.txt
|
||||
script-sort-by-num-blocks-expected.txt
|
||||
script-ignore-alloc-fns.json
|
||||
script-ignore-alloc-fns-expected.txt
|
||||
script-diff-live1.json
|
||||
script-diff-live2.json
|
||||
script-diff-live-expected.txt
|
||||
script-diff-dark-matter1.json
|
||||
script-diff-dark-matter2.json
|
||||
script-diff-dark-matter-expected.txt
|
||||
|
||||
# Bug 1077230 explains why this test is disabled on Mac 10.6.
|
||||
[test_dmd.js]
|
||||
dmd = true
|
||||
skip-if = !(os=='linux' || os=='win' || (os=='mac' && os_version!='10.6'))
|
||||
|
|
@ -12,5 +12,3 @@ DIRS += [
|
|||
if CONFIG['MOZ_REPLACE_MALLOC_LINKAGE'] == 'dummy library':
|
||||
DIRS += ['dummy']
|
||||
|
||||
if CONFIG['MOZ_DMD']:
|
||||
DIRS += ['dmd']
|
||||
|
|
|
|||
|
|
@ -29,9 +29,6 @@
|
|||
#ifndef MOZ_STATIC_JS
|
||||
@BINPATH@/@DLL_PREFIX@mozjs@DLL_SUFFIX@
|
||||
#endif
|
||||
#ifdef MOZ_DMD
|
||||
@BINPATH@/@DLL_PREFIX@dmd@DLL_SUFFIX@
|
||||
#endif
|
||||
#ifndef MOZ_FOLD_LIBS
|
||||
@BINPATH@/@DLL_PREFIX@plc4@DLL_SUFFIX@
|
||||
@BINPATH@/@DLL_PREFIX@plds4@DLL_SUFFIX@
|
||||
|
|
|
|||
|
|
@ -719,17 +719,6 @@ if test "$MOZ_PROFILING" -a -z "$STRIP_FLAGS"; then
|
|||
esac
|
||||
fi
|
||||
|
||||
dnl ========================================================
|
||||
dnl = Enable DMD
|
||||
dnl ========================================================
|
||||
|
||||
if test "$MOZ_DMD"; then
|
||||
if test "${CPU_ARCH}" = "arm"; then
|
||||
CFLAGS="$CFLAGS -funwind-tables"
|
||||
CXXFLAGS="$CXXFLAGS -funwind-tables"
|
||||
fi
|
||||
fi
|
||||
|
||||
dnl ========================================================
|
||||
dnl System overrides of the defaults for host
|
||||
dnl ========================================================
|
||||
|
|
@ -4558,7 +4547,7 @@ fi
|
|||
|
||||
# Demangle only for debug or DMD builds
|
||||
MOZ_DEMANGLE_SYMBOLS=
|
||||
if test "$HAVE_DEMANGLE" && test "$MOZ_DEBUG" -o "$MOZ_DMD"; then
|
||||
if test "$HAVE_DEMANGLE" && test "$MOZ_DEBUG"; then
|
||||
MOZ_DEMANGLE_SYMBOLS=1
|
||||
AC_DEFINE(MOZ_DEMANGLE_SYMBOLS)
|
||||
fi
|
||||
|
|
@ -5153,7 +5142,7 @@ fi
|
|||
|
||||
|
||||
dnl ========================================================
|
||||
if test "$MOZ_DEBUG" -o "$MOZ_DMD"; then
|
||||
if test "$MOZ_DEBUG"; then
|
||||
MOZ_COMPONENTS_VERSION_SCRIPT_LDFLAGS=
|
||||
fi
|
||||
|
||||
|
|
|
|||
|
|
@ -36,9 +36,6 @@
|
|||
|
||||
#ifdef MOZ_STORAGE_MEMORY
|
||||
# include "mozmemory.h"
|
||||
# ifdef MOZ_DMD
|
||||
# include "DMD.h"
|
||||
# endif
|
||||
#endif
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
|
@ -59,10 +56,6 @@ namespace storage {
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
//// Memory Reporting
|
||||
|
||||
#ifdef MOZ_DMD
|
||||
static mozilla::Atomic<size_t> gSqliteMemoryUsed;
|
||||
#endif
|
||||
|
||||
static int64_t
|
||||
StorageSQLiteDistinguishedAmount()
|
||||
{
|
||||
|
|
@ -165,13 +158,6 @@ Service::CollectReports(nsIHandleReportCallback *aHandleReport,
|
|||
NS_LITERAL_CSTRING("schema"), schemaDesc,
|
||||
SQLITE_DBSTATUS_SCHEMA_USED, &totalConnSize);
|
||||
}
|
||||
|
||||
#ifdef MOZ_DMD
|
||||
if (::sqlite3_memory_used() != int64_t(gSqliteMemoryUsed)) {
|
||||
NS_WARNING("memory consumption reported by SQLite doesn't match "
|
||||
"our measurements");
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
int64_t other = ::sqlite3_memory_used() - totalConnSize;
|
||||
|
|
@ -410,58 +396,20 @@ namespace {
|
|||
// from the standard ones -- they use int instead of size_t. But we don't need
|
||||
// a wrapper for free.
|
||||
|
||||
#ifdef MOZ_DMD
|
||||
|
||||
// sqlite does its own memory accounting, and we use its numbers in our memory
|
||||
// reporters. But we don't want sqlite's heap blocks to show up in DMD's
|
||||
// output as unreported, so we mark them as reported when they're allocated and
|
||||
// mark them as unreported when they are freed.
|
||||
//
|
||||
// In other words, we are marking all sqlite heap blocks as reported even
|
||||
// though we're not reporting them ourselves. Instead we're trusting that
|
||||
// sqlite is fully and correctly accounting for all of its heap blocks via its
|
||||
// own memory accounting. Well, we don't have to trust it entirely, because
|
||||
// it's easy to keep track (while doing this DMD-specific marking) of exactly
|
||||
// how much memory SQLite is using. And we can compare that against what
|
||||
// SQLite reports it is using.
|
||||
|
||||
MOZ_DEFINE_MALLOC_SIZE_OF_ON_ALLOC(SqliteMallocSizeOfOnAlloc)
|
||||
MOZ_DEFINE_MALLOC_SIZE_OF_ON_FREE(SqliteMallocSizeOfOnFree)
|
||||
|
||||
#endif
|
||||
|
||||
static void *sqliteMemMalloc(int n)
|
||||
{
|
||||
void* p = ::malloc(n);
|
||||
#ifdef MOZ_DMD
|
||||
gSqliteMemoryUsed += SqliteMallocSizeOfOnAlloc(p);
|
||||
#endif
|
||||
return p;
|
||||
}
|
||||
|
||||
static void sqliteMemFree(void *p)
|
||||
{
|
||||
#ifdef MOZ_DMD
|
||||
gSqliteMemoryUsed -= SqliteMallocSizeOfOnFree(p);
|
||||
#endif
|
||||
::free(p);
|
||||
}
|
||||
|
||||
static void *sqliteMemRealloc(void *p, int n)
|
||||
{
|
||||
#ifdef MOZ_DMD
|
||||
gSqliteMemoryUsed -= SqliteMallocSizeOfOnFree(p);
|
||||
void *pnew = ::realloc(p, n);
|
||||
if (pnew) {
|
||||
gSqliteMemoryUsed += SqliteMallocSizeOfOnAlloc(pnew);
|
||||
} else {
|
||||
// realloc failed; undo the SqliteMallocSizeOfOnFree from above
|
||||
gSqliteMemoryUsed += SqliteMallocSizeOfOnAlloc(p);
|
||||
}
|
||||
return pnew;
|
||||
#else
|
||||
return ::realloc(p, n);
|
||||
#endif
|
||||
}
|
||||
|
||||
static int sqliteMemSize(void *p)
|
||||
|
|
|
|||
|
|
@ -367,22 +367,6 @@ function onLoad()
|
|||
appendButton(row4, GCAndCCAllLogDesc,
|
||||
saveGCLogAndVerboseCCLog, "Save verbose", 'saveLogsVerbose');
|
||||
|
||||
// Three cases here:
|
||||
// - DMD is disabled (i.e. not built): don't show the button.
|
||||
// - DMD is enabled but is not running: show the button, but disable it.
|
||||
// - DMD is enabled and is running: show the button and enable it.
|
||||
if (gMgr.isDMDEnabled) {
|
||||
let row5 = appendElement(ops, "div", "opsRow");
|
||||
|
||||
appendElementWithText(row5, "div", "opsRowLabel", "Save DMD output");
|
||||
let enableButtons = gMgr.isDMDRunning;
|
||||
|
||||
let dmdButton =
|
||||
appendButton(row5, enableButtons ? DMDEnabledDesc : DMDDisabledDesc,
|
||||
doDMD, "Save");
|
||||
dmdButton.disabled = !enableButtons;
|
||||
}
|
||||
|
||||
// Generate the main div, where content ("section" divs) will go. It's
|
||||
// hidden at first.
|
||||
|
||||
|
|
|
|||
|
|
@ -52,22 +52,6 @@ set_config('MOZ_ENABLE_PROFILER_SPS', sps_profiler_define)
|
|||
set_define('MOZ_ENABLE_PROFILER_SPS', sps_profiler_define)
|
||||
|
||||
|
||||
option('--enable-dmd', env='MOZ_DMD',
|
||||
help='Enable Dark Matter Detector (heap profiler). '
|
||||
'Also enables jemalloc, replace-malloc and profiling')
|
||||
|
||||
@depends('--enable-dmd')
|
||||
def dmd(value):
|
||||
if value:
|
||||
return True
|
||||
|
||||
set_config('MOZ_DMD', dmd)
|
||||
set_define('MOZ_DMD', dmd)
|
||||
add_old_configure_assignment('MOZ_DMD', dmd)
|
||||
imply_option('--enable-profiling', dmd)
|
||||
imply_option('--enable-jemalloc', dmd)
|
||||
imply_option('--enable-replace-malloc', dmd)
|
||||
|
||||
# JACK cubeb backend
|
||||
# ==============================================================
|
||||
option('--enable-jack', env='MOZ_JACK',
|
||||
|
|
|
|||
|
|
@ -349,10 +349,6 @@ ifndef MOZ_PKG_MANIFEST
|
|||
NO_PKG_FILES += ssltunnel*
|
||||
endif
|
||||
|
||||
ifdef MOZ_DMD
|
||||
NO_PKG_FILES += SmokeDMD
|
||||
endif
|
||||
|
||||
DEFINES += -DDLL_PREFIX=$(DLL_PREFIX) -DDLL_SUFFIX=$(DLL_SUFFIX) -DBIN_SUFFIX=$(BIN_SUFFIX)
|
||||
|
||||
ifeq (cocoa,$(MOZ_WIDGET_TOOLKIT))
|
||||
|
|
|
|||
|
|
@ -404,13 +404,6 @@ interface nsIMemoryReporterManager : nsISupports
|
|||
*/
|
||||
[infallible] readonly attribute boolean hasMozMallocUsableSize;
|
||||
|
||||
/*
|
||||
* These attributes indicate DMD's status. "Enabled" means enabled at
|
||||
* build-time.
|
||||
*/
|
||||
[infallible] readonly attribute boolean isDMDEnabled;
|
||||
[infallible] readonly attribute boolean isDMDRunning;
|
||||
|
||||
/*
|
||||
* Run a series of GC/CC's in an attempt to minimize the application's memory
|
||||
* usage. When we're finished, we invoke the given runnable if it's not
|
||||
|
|
@ -519,23 +512,9 @@ nsresult RegisterNonJSSizeOfTab(NonJSSizeOfTabFn aSizeOfTabFn);
|
|||
|
||||
}
|
||||
|
||||
#if defined(MOZ_DMD)
|
||||
#if !defined(MOZ_MEMORY)
|
||||
#error "MOZ_DMD requires MOZ_MEMORY"
|
||||
#endif
|
||||
|
||||
#include "DMD.h"
|
||||
|
||||
#define MOZ_REPORT(ptr) mozilla::dmd::Report(ptr)
|
||||
#define MOZ_REPORT_ON_ALLOC(ptr) mozilla::dmd::ReportOnAlloc(ptr)
|
||||
|
||||
#else
|
||||
|
||||
#define MOZ_REPORT(ptr)
|
||||
#define MOZ_REPORT_ON_ALLOC(ptr)
|
||||
|
||||
#endif // defined(MOZ_DMD)
|
||||
|
||||
// Functions generated via this macro should be used by all traversal-based
|
||||
// memory reporters. Such functions return |moz_malloc_size_of(ptr)|; this
|
||||
// will always be zero on some obscure platforms.
|
||||
|
|
|
|||
|
|
@ -766,65 +766,3 @@ nsMemoryInfoDumper::DumpMemoryInfoToTempDir(const nsAString& aIdentifier,
|
|||
aAnonymize, aMinimizeMemoryUsage, identifier);
|
||||
}
|
||||
|
||||
#ifdef MOZ_DMD
|
||||
dmd::DMDFuncs::Singleton dmd::DMDFuncs::sSingleton;
|
||||
|
||||
nsresult
|
||||
nsMemoryInfoDumper::OpenDMDFile(const nsAString& aIdentifier, int aPid,
|
||||
FILE** aOutFile)
|
||||
{
|
||||
if (!dmd::IsRunning()) {
|
||||
*aOutFile = nullptr;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// Create a filename like dmd-<identifier>-<pid>.json.gz, which will be used
|
||||
// if DMD is enabled.
|
||||
nsCString dmdFilename;
|
||||
MakeFilename("dmd", aIdentifier, aPid, "json.gz", dmdFilename);
|
||||
|
||||
// Open a new DMD file named |dmdFilename| in NS_OS_TEMP_DIR for writing,
|
||||
// and dump DMD output to it. This must occur after the memory reporters
|
||||
// have been run (above), but before the memory-reports file has been
|
||||
// renamed (so scripts can detect the DMD file, if present).
|
||||
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsIFile> dmdFile;
|
||||
rv = nsDumpUtils::OpenTempFile(dmdFilename,
|
||||
getter_AddRefs(dmdFile),
|
||||
NS_LITERAL_CSTRING("memory-reports"));
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return rv;
|
||||
}
|
||||
rv = dmdFile->OpenANSIFileDesc("wb", aOutFile);
|
||||
NS_WARNING_ASSERTION(NS_SUCCEEDED(rv), "OpenANSIFileDesc failed");
|
||||
|
||||
// Print the path, because on some platforms (e.g. Mac) it's not obvious.
|
||||
nsCString path;
|
||||
rv = dmdFile->GetNativePath(path);
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return rv;
|
||||
}
|
||||
dmd::StatusMsg("opened %s for writing\n", path.get());
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsMemoryInfoDumper::DumpDMDToFile(FILE* aFile)
|
||||
{
|
||||
RefPtr<nsGZFileWriter> gzWriter = new nsGZFileWriter();
|
||||
nsresult rv = gzWriter->InitANSIFileDesc(aFile);
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
// Dump DMD's memory reports analysis to the file.
|
||||
dmd::Analyze(MakeUnique<GZWriterWrapper>(gzWriter));
|
||||
|
||||
rv = gzWriter->Finish();
|
||||
NS_WARNING_ASSERTION(NS_SUCCEEDED(rv), "Finish failed");
|
||||
return rv;
|
||||
}
|
||||
#endif // MOZ_DMD
|
||||
|
||||
|
|
|
|||
|
|
@ -28,15 +28,6 @@ public:
|
|||
nsMemoryInfoDumper();
|
||||
|
||||
static void Initialize();
|
||||
|
||||
#ifdef MOZ_DMD
|
||||
// Open an appropriately named file for a DMD report. If DMD is
|
||||
// disabled, return a null FILE* instead.
|
||||
static nsresult OpenDMDFile(const nsAString& aIdentifier, int aPid,
|
||||
FILE** aOutFile);
|
||||
// Write a DMD report to the given file and close it.
|
||||
static nsresult DumpDMDToFile(FILE* aFile);
|
||||
#endif
|
||||
};
|
||||
|
||||
#define NS_MEMORY_INFO_DUMPER_CID \
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@
|
|||
#include "nsIObserverService.h"
|
||||
#include "nsIGlobalObject.h"
|
||||
#include "nsIXPConnect.h"
|
||||
#if defined(XP_UNIX) || defined(MOZ_DMD)
|
||||
#if defined(XP_UNIX)
|
||||
#include "nsMemoryInfoDumper.h"
|
||||
#endif
|
||||
#include "mozilla/Attributes.h"
|
||||
|
|
@ -1425,62 +1425,6 @@ NS_IMPL_ISUPPORTS(DeadlockDetectorReporter, nsIMemoryReporter)
|
|||
|
||||
#endif
|
||||
|
||||
#ifdef MOZ_DMD
|
||||
|
||||
namespace mozilla {
|
||||
namespace dmd {
|
||||
|
||||
class DMDReporter final : public nsIMemoryReporter
|
||||
{
|
||||
public:
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
NS_IMETHOD CollectReports(nsIHandleReportCallback* aHandleReport,
|
||||
nsISupports* aData, bool aAnonymize) override
|
||||
{
|
||||
dmd::Sizes sizes;
|
||||
dmd::SizeOf(&sizes);
|
||||
|
||||
MOZ_COLLECT_REPORT(
|
||||
"explicit/dmd/stack-traces/used", KIND_HEAP, UNITS_BYTES,
|
||||
sizes.mStackTracesUsed,
|
||||
"Memory used by stack traces which correspond to at least "
|
||||
"one heap block DMD is tracking.");
|
||||
|
||||
MOZ_COLLECT_REPORT(
|
||||
"explicit/dmd/stack-traces/unused", KIND_HEAP, UNITS_BYTES,
|
||||
sizes.mStackTracesUnused,
|
||||
"Memory used by stack traces which don't correspond to any heap "
|
||||
"blocks DMD is currently tracking.");
|
||||
|
||||
MOZ_COLLECT_REPORT(
|
||||
"explicit/dmd/stack-traces/table", KIND_HEAP, UNITS_BYTES,
|
||||
sizes.mStackTraceTable,
|
||||
"Memory used by DMD's stack trace table.");
|
||||
|
||||
MOZ_COLLECT_REPORT(
|
||||
"explicit/dmd/live-block-table", KIND_HEAP, UNITS_BYTES,
|
||||
sizes.mLiveBlockTable,
|
||||
"Memory used by DMD's live block table.");
|
||||
|
||||
MOZ_COLLECT_REPORT(
|
||||
"explicit/dmd/dead-block-list", KIND_HEAP, UNITS_BYTES,
|
||||
sizes.mDeadBlockTable,
|
||||
"Memory used by DMD's dead block list.");
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
private:
|
||||
~DMDReporter() {}
|
||||
};
|
||||
NS_IMPL_ISUPPORTS(DMDReporter, nsIMemoryReporter)
|
||||
|
||||
} // namespace dmd
|
||||
} // namespace mozilla
|
||||
|
||||
#endif // MOZ_DMD
|
||||
|
||||
/**
|
||||
** nsMemoryReporterManager implementation
|
||||
**/
|
||||
|
|
@ -1560,10 +1504,6 @@ nsMemoryReporterManager::Init()
|
|||
RegisterStrongReporter(new DeadlockDetectorReporter());
|
||||
#endif
|
||||
|
||||
#ifdef MOZ_DMD
|
||||
RegisterStrongReporter(new mozilla::dmd::DMDReporter());
|
||||
#endif
|
||||
|
||||
#ifdef XP_WIN
|
||||
RegisterStrongReporter(new WindowsAddressSpaceReporter());
|
||||
#endif
|
||||
|
|
@ -1679,22 +1619,9 @@ nsMemoryReporterManager::StartGettingReports()
|
|||
PendingProcessesState* s = mPendingProcessesState;
|
||||
nsresult rv;
|
||||
|
||||
// Get reports for this process.
|
||||
FILE* parentDMDFile = nullptr;
|
||||
#ifdef MOZ_DMD
|
||||
if (!s->mDMDDumpIdent.IsEmpty()) {
|
||||
rv = nsMemoryInfoDumper::OpenDMDFile(s->mDMDDumpIdent, getpid(),
|
||||
&parentDMDFile);
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
// Proceed with the memory report as if DMD were disabled.
|
||||
parentDMDFile = nullptr;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
// This is async.
|
||||
GetReportsForThisProcessExtended(s->mHandleReport, s->mHandleReportData,
|
||||
s->mAnonymize, parentDMDFile,
|
||||
s->mAnonymize, nullptr,
|
||||
s->mFinishReporting, s->mFinishReportingData);
|
||||
|
||||
nsTArray<ContentParent*> childWeakRefs;
|
||||
|
|
@ -1775,16 +1702,6 @@ nsMemoryReporterManager::GetReportsForThisProcessExtended(
|
|||
return NS_ERROR_IN_PROGRESS;
|
||||
}
|
||||
|
||||
#ifdef MOZ_DMD
|
||||
if (aDMDFile) {
|
||||
// Clear DMD's reportedness state before running the memory
|
||||
// reporters, to avoid spurious twice-reported warnings.
|
||||
dmd::ClearReports();
|
||||
}
|
||||
#else
|
||||
MOZ_ASSERT(!aDMDFile);
|
||||
#endif
|
||||
|
||||
mPendingReportersState = new PendingReportersState(
|
||||
aFinishReporting, aFinishReportingData, aDMDFile);
|
||||
|
||||
|
|
@ -1810,11 +1727,6 @@ NS_IMETHODIMP
|
|||
nsMemoryReporterManager::EndReport()
|
||||
{
|
||||
if (--mPendingReportersState->mReportsPending == 0) {
|
||||
#ifdef MOZ_DMD
|
||||
if (mPendingReportersState->mDMDFile) {
|
||||
nsMemoryInfoDumper::DumpDMDToFile(mPendingReportersState->mDMDFile);
|
||||
}
|
||||
#endif
|
||||
if (mPendingProcessesState) {
|
||||
// This is the parent process.
|
||||
EndProcessReport(mPendingProcessesState->mGeneration, true);
|
||||
|
|
@ -1902,24 +1814,8 @@ nsMemoryReporterManager::StartChildReport(mozilla::dom::ContentParent* aChild,
|
|||
return false;
|
||||
}
|
||||
|
||||
mozilla::dom::MaybeFileDesc dmdFileDesc = void_t();
|
||||
#ifdef MOZ_DMD
|
||||
if (!aState->mDMDDumpIdent.IsEmpty()) {
|
||||
FILE *dmdFile = nullptr;
|
||||
nsresult rv = nsMemoryInfoDumper::OpenDMDFile(aState->mDMDDumpIdent,
|
||||
aChild->Pid(), &dmdFile);
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
// Proceed with the memory report as if DMD were disabled.
|
||||
dmdFile = nullptr;
|
||||
}
|
||||
if (dmdFile) {
|
||||
dmdFileDesc = mozilla::ipc::FILEToFileDescriptor(dmdFile);
|
||||
fclose(dmdFile);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
return aChild->SendPMemoryReportRequestConstructor(
|
||||
aState->mGeneration, aState->mAnonymize, aState->mMinimize, dmdFileDesc);
|
||||
aState->mGeneration, aState->mAnonymize, aState->mMinimize, void_t());
|
||||
}
|
||||
|
||||
void
|
||||
|
|
@ -2452,28 +2348,6 @@ nsMemoryReporterManager::GetHasMozMallocUsableSize(bool* aHas)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsMemoryReporterManager::GetIsDMDEnabled(bool* aIsEnabled)
|
||||
{
|
||||
#ifdef MOZ_DMD
|
||||
*aIsEnabled = true;
|
||||
#else
|
||||
*aIsEnabled = false;
|
||||
#endif
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsMemoryReporterManager::GetIsDMDRunning(bool* aIsRunning)
|
||||
{
|
||||
#ifdef MOZ_DMD
|
||||
*aIsRunning = dmd::IsRunning();
|
||||
#else
|
||||
*aIsRunning = false;
|
||||
#endif
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
namespace {
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -42,11 +42,6 @@
|
|||
#include <dlfcn.h>
|
||||
#endif
|
||||
|
||||
#ifdef MOZ_DMD
|
||||
#include "base/process_util.h"
|
||||
#include "nsMemoryInfoDumper.h"
|
||||
#endif
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "plhash.h"
|
||||
|
|
@ -936,39 +931,6 @@ NS_LogTerm()
|
|||
mozilla::LogTerm();
|
||||
}
|
||||
|
||||
#ifdef MOZ_DMD
|
||||
// If MOZ_DMD_SHUTDOWN_LOG is set, dump a DMD report to a file.
|
||||
// The value of this environment variable is used as the prefix
|
||||
// of the file name, so you probably want something like "/tmp/".
|
||||
// By default, this is run in all processes, but you can record a
|
||||
// log only for a specific process type by setting MOZ_DMD_LOG_PROCESS
|
||||
// to the process type you want to log, such as "default" or "tab".
|
||||
// This method can't use the higher level XPCOM file utilities
|
||||
// because it is run very late in shutdown to avoid recording
|
||||
// information about refcount logging entries.
|
||||
static void
|
||||
LogDMDFile()
|
||||
{
|
||||
const char* dmdFilePrefix = PR_GetEnv("MOZ_DMD_SHUTDOWN_LOG");
|
||||
if (!dmdFilePrefix) {
|
||||
return;
|
||||
}
|
||||
|
||||
const char* logProcessEnv = PR_GetEnv("MOZ_DMD_LOG_PROCESS");
|
||||
if (logProcessEnv && !!strcmp(logProcessEnv, XRE_ChildProcessTypeToString(XRE_GetProcessType()))) {
|
||||
return;
|
||||
}
|
||||
|
||||
nsPrintfCString fileName("%sdmd-%d.log.gz", dmdFilePrefix, base::GetCurrentProcId());
|
||||
FILE* logFile = fopen(fileName.get(), "w");
|
||||
if (NS_WARN_IF(!logFile)) {
|
||||
return;
|
||||
}
|
||||
|
||||
nsMemoryInfoDumper::DumpDMDToFile(logFile);
|
||||
}
|
||||
#endif // MOZ_DMD
|
||||
|
||||
namespace mozilla {
|
||||
void
|
||||
LogTerm()
|
||||
|
|
@ -1000,10 +962,6 @@ LogTerm()
|
|||
nsTraceRefcnt::Shutdown();
|
||||
nsTraceRefcnt::SetActivityIsLegal(false);
|
||||
gActivityTLS = BAD_TLS_INDEX;
|
||||
|
||||
#ifdef MOZ_DMD
|
||||
LogDMDFile();
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -4,9 +4,6 @@
|
|||
* 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/. */
|
||||
|
||||
// Avoid DMD-specific parts of MOZ_DEFINE_MALLOC_SIZE_OF
|
||||
#undef MOZ_DMD
|
||||
|
||||
#include "nsIMemoryReporter.h"
|
||||
#include "mozilla/Mutex.h"
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue