[profiler] Rework GC roots reporting. (#6144)
commitd7ac79ccc0edc7de26f319447935f179f893bff6
authorAlex Rønne Petersen <alex@alexrp.com>
Thu, 7 Dec 2017 15:47:18 +0000 (7 16:47 +0100)
committerLudovic Henry <luhenry@microsoft.com>
Thu, 7 Dec 2017 15:47:18 +0000 (7 10:47 -0500)
tree61e6d8e4120ee0db20ba3b174ff4b368695394a6
parent4d5d54f7a8c02c3d91c74bca46c5bacb8d1a073d
[profiler] Rework GC roots reporting. (#6144)

This change re-implement GC roots reporting in a way that allows users to correctly track the source of a GC root.

The new design is based on emitting GC root information upfront and only report addresses during heap dumps.

When a GC root is registered we emit an event that is an address range, the root kind, a key and a text description.

A decoder can use this information to match a reported root address with all registration addresses to figure out what they mean.

A GC Root key is used to further its meaning. For example, if kind is thread, key is a tid, if kind is static variables, key is the vtable pointer and so on.

The build of the change is introducing this key argument across all root registration code and rework our root reporting code to encode their addresses.

Some roots use pseudo-addresses when they are not registrable. This is the case of thread stacks/registers and the finalizer queue.

Finally, root reporting was changed to happen only once per collection and at the end, leading to correct and useful data being produced.
48 files changed:
mcs/class/Mono.Profiler.Log/Makefile
mcs/class/Mono.Profiler.Log/Mono.Profiler.Log/LogEnums.cs
mcs/class/Mono.Profiler.Log/Mono.Profiler.Log/LogEventVisitor.cs
mcs/class/Mono.Profiler.Log/Mono.Profiler.Log/LogEvents.cs
mcs/class/Mono.Profiler.Log/Mono.Profiler.Log/LogProcessor.cs
mcs/class/Mono.Profiler.Log/Mono.Profiler.Log/LogStreamHeader.cs
mono/metadata/boehm-gc.c
mono/metadata/custom-attrs.c
mono/metadata/domain.c
mono/metadata/dynamic-image.c
mono/metadata/gc-internals.h
mono/metadata/handle.c
mono/metadata/handle.h
mono/metadata/marshal.c
mono/metadata/mono-conc-hash.c
mono/metadata/mono-conc-hash.h
mono/metadata/mono-gc.h
mono/metadata/mono-hash.c
mono/metadata/mono-hash.h
mono/metadata/mono-ptr-array.h
mono/metadata/null-gc-handles.c
mono/metadata/null-gc.c
mono/metadata/object.c
mono/metadata/object.h
mono/metadata/profiler-events.h
mono/metadata/profiler-private.h
mono/metadata/profiler.c
mono/metadata/profiler.h
mono/metadata/reflection-cache.h
mono/metadata/reflection.c
mono/metadata/sgen-client-mono.h
mono/metadata/sgen-mono.c
mono/metadata/sre-save.c
mono/metadata/threadpool-io.c
mono/metadata/threadpool.c
mono/metadata/threads.c
mono/mini/debugger-agent.c
mono/mini/tasklets.c
mono/profiler/log.c
mono/profiler/log.h
mono/profiler/mprof-report.c
mono/sgen/sgen-client.h
mono/sgen/sgen-descriptor.h
mono/sgen/sgen-gc.c
mono/sgen/sgen-gc.h
mono/sgen/sgen-gchandles.c
mono/sgen/sgen-marksweep.c
mono/sgen/sgen-pinning.c