mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-26 20:30:41 +00:00
Bug 1587721 - Memory statistics for crashes under macOS;r=gsvelto
Differential Revision: https://phabricator.services.mozilla.com/D55111 --HG-- extra : moz-landing-system : lando
This commit is contained in:
parent
0371facbd6
commit
43bf0f8688
@ -112,17 +112,26 @@ AvailablePageFile:
|
||||
|
||||
AvailablePhysicalMemory:
|
||||
description: >
|
||||
Windows-only, amount of free physical memory in bytes. This annotation
|
||||
is populated with the contents of the MEMORYSTATUSEX's structure
|
||||
Amount of free physical memory in bytes.
|
||||
- Under Windows, populated with the contents of the MEMORYSTATUSEX's structure
|
||||
ullAvailPhys field.
|
||||
- Under macOS, populated with vm_statistics64_data_t::free_count.
|
||||
- Not available under other platforms.
|
||||
type: string
|
||||
ping: true
|
||||
|
||||
AvailableSwapMemory:
|
||||
description: >
|
||||
macOS-only, amount of free swap space. Populated with the coontents of
|
||||
sysctl "vm.swapusage" :: xsu_avail.
|
||||
type: string
|
||||
ping: true
|
||||
|
||||
AvailableVirtualMemory:
|
||||
description: >
|
||||
Windows-only, amount of free virtual memory in bytes. This annotation is
|
||||
populated with the contents of the MEMORYSTATUSEX's structure
|
||||
ullAvailVirtual field.
|
||||
Windows-only, amount of free virtual memory in bytes. Populated with the contents
|
||||
of the MEMORYSTATUSEX's structure ullAvailVirtual field.
|
||||
For macOS, see AvailableSwapMemory, AvailablePhysicalMemory and PurgeablePhysicalMemory.
|
||||
type: string
|
||||
ping: true
|
||||
|
||||
@ -690,6 +699,14 @@ ProxyStreamValid:
|
||||
Set to "false" when encountering an invalid IPC proxy stream.
|
||||
type: string
|
||||
|
||||
PurgeablePhysicalMemory:
|
||||
description: >
|
||||
macOS only. Amount of physical memory currently allocated but which may
|
||||
be deallocated by the system in case of memory pressure. Populated from
|
||||
vm_statistics64_data_t::purgeable_count * vm_page_size.
|
||||
type: string
|
||||
ping: true
|
||||
|
||||
RDDProcessStatus:
|
||||
description: >
|
||||
Status of the RDD process, can be set to "Running" or "Destroyed"
|
||||
@ -826,23 +843,25 @@ ThreadIdNameMapping:
|
||||
|
||||
TotalPageFile:
|
||||
description: >
|
||||
Windows-only, maximum amount of memory that can be committed. This
|
||||
annotation is populated with the contents of the PERFORMANCE_INFORMATION's
|
||||
structure CommitLimit field.
|
||||
Maximum amount of memory that can be committed.
|
||||
- Under Windows, populated with the contents of the PERFORMANCE_INFORMATION's
|
||||
structure CommitLimit field.
|
||||
- Not available on other systems.
|
||||
type: string
|
||||
ping: true
|
||||
|
||||
TotalPhysicalMemory:
|
||||
description: >
|
||||
Windows-only, amount of physical memory in bytes. This annotation is
|
||||
populated with the contents of the MEMORYSTATUSEX's structure
|
||||
Amount of physical memory in bytes.
|
||||
- Under Windows, populated with the contents of the MEMORYSTATUSEX's structure
|
||||
ullTotalPhys field.
|
||||
- Under macOS, populated with sysctl "hw.memsize".
|
||||
type: string
|
||||
ping: true
|
||||
|
||||
TotalVirtualMemory:
|
||||
description: >
|
||||
Windows-only, size of the virtual address space. This annotation is
|
||||
Windows-only. Size of the virtual address space. This annotation is
|
||||
populated with the contents of the MEMORYSTATUSEX's structure
|
||||
ullTotalVirtual field.
|
||||
type: string
|
||||
|
@ -59,6 +59,8 @@
|
||||
# include <crt_externs.h>
|
||||
# include <fcntl.h>
|
||||
# include <mach/mach.h>
|
||||
# include <mach/vm_statistics.h>
|
||||
# include <sys/sysctl.h>
|
||||
# include <sys/types.h>
|
||||
# include <spawn.h>
|
||||
# include <unistd.h>
|
||||
@ -767,18 +769,23 @@ static void OpenAPIData(PlatformWriter& aWriter, const XP_CHAR* dump_path,
|
||||
aWriter.Open(extraDataPath);
|
||||
}
|
||||
|
||||
#ifdef XP_WIN
|
||||
#if defined(XP_WIN) || defined(XP_MACOSX)
|
||||
|
||||
static void WriteMemoryAnnotation(AnnotationWriter& aWriter,
|
||||
Annotation aAnnotation, uint64_t aValue) {
|
||||
// This function is used to write values of 64 bits, which can safely be
|
||||
// assumed to fit within 20 decimal digits, so we need neither allocation nor
|
||||
// overflow checking.
|
||||
char buffer[128];
|
||||
if (!_ui64toa_s(aValue, buffer, sizeof(buffer), 10)) {
|
||||
if (SprintfLiteral(buffer, "%llu", aValue) > 0) {
|
||||
aWriter.Write(aAnnotation, buffer);
|
||||
}
|
||||
}
|
||||
#endif // XP_WIN
|
||||
|
||||
static void WriteMemoryStatus(AnnotationWriter& aWriter) {
|
||||
#endif // XP_WIN || XP_MACOSX
|
||||
|
||||
#ifdef XP_WIN
|
||||
static void WriteMemoryStatus(AnnotationWriter& aWriter) {
|
||||
MEMORYSTATUSEX statex;
|
||||
statex.dwLength = sizeof(statex);
|
||||
if (GlobalMemoryStatusEx(&statex)) {
|
||||
@ -802,8 +809,63 @@ static void WriteMemoryStatus(AnnotationWriter& aWriter) {
|
||||
aWriter, Annotation::AvailablePageFile,
|
||||
(info.CommitLimit - info.CommitTotal) * info.PageSize);
|
||||
}
|
||||
#endif // XP_WIN
|
||||
}
|
||||
#elif XP_MACOSX
|
||||
// Extract the total physical memory of the system.
|
||||
static void WritePhysicalMemoryStatus(AnnotationWriter& aWriter) {
|
||||
uint64_t physicalMemoryByteSize = 0;
|
||||
const size_t NAME_LEN = 2;
|
||||
int name[NAME_LEN] = {/* Hardware */ CTL_HW,
|
||||
/* 64-bit physical memory size */ HW_MEMSIZE};
|
||||
size_t infoByteSize = sizeof(physicalMemoryByteSize);
|
||||
if (sysctl(name, NAME_LEN, &physicalMemoryByteSize, &infoByteSize,
|
||||
/* We do not replace data */ nullptr,
|
||||
/* We do not replace data */ 0) != -1) {
|
||||
WriteMemoryAnnotation(aWriter, Annotation::TotalPhysicalMemory,
|
||||
physicalMemoryByteSize);
|
||||
}
|
||||
}
|
||||
|
||||
// Extract available and purgeable physical memory.
|
||||
static void WriteAvailableMemoryStatus(AnnotationWriter& aWriter) {
|
||||
auto host = mach_host_self();
|
||||
vm_statistics64_data_t stats;
|
||||
unsigned int count = HOST_VM_INFO64_COUNT;
|
||||
if (host_statistics64(host, HOST_VM_INFO64, (host_info64_t)&stats, &count) ==
|
||||
KERN_SUCCESS) {
|
||||
WriteMemoryAnnotation(aWriter, Annotation::AvailablePhysicalMemory,
|
||||
stats.free_count * vm_page_size);
|
||||
WriteMemoryAnnotation(aWriter, Annotation::PurgeablePhysicalMemory,
|
||||
stats.purgeable_count * vm_page_size);
|
||||
}
|
||||
}
|
||||
|
||||
// Extract the status of the swap.
|
||||
static void WriteSwapFileStatus(AnnotationWriter& aWriter) {
|
||||
const size_t NAME_LEN = 2;
|
||||
int name[] = {/* Hardware */ CTL_VM,
|
||||
/* 64-bit physical memory size */ VM_SWAPUSAGE};
|
||||
struct xsw_usage swapUsage;
|
||||
size_t infoByteSize = sizeof(swapUsage);
|
||||
if (sysctl(name, NAME_LEN, &swapUsage, &infoByteSize,
|
||||
/* We do not replace data */ nullptr,
|
||||
/* We do not replace data */ 0) != -1) {
|
||||
WriteMemoryAnnotation(aWriter, Annotation::AvailableSwapMemory,
|
||||
swapUsage.xsu_avail);
|
||||
}
|
||||
}
|
||||
static void WriteMemoryStatus(AnnotationWriter& aWriter) {
|
||||
WritePhysicalMemoryStatus(aWriter);
|
||||
WriteAvailableMemoryStatus(aWriter);
|
||||
WriteSwapFileStatus(aWriter);
|
||||
}
|
||||
#else
|
||||
|
||||
static void WriteMemoryStatus(AnnotationWriter& aWriter) {
|
||||
// No memory data for other platforms yet.
|
||||
}
|
||||
|
||||
#endif // XP_WIN || XP_MACOSX || else
|
||||
|
||||
#if !defined(MOZ_WIDGET_ANDROID)
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user