These instructions don't work for me (dominicc); I think Type Profiler has rotted. See crbug.com/490464.
The C++ Object Type Identifier (a.k.a. Type Profiler) is another profiling feature to find “Which type is the object?". For example, it reports:
"An object at 0x37f3c88 is an instance of std::string."
RTTI is not enough to find a type of an object only from its address . You can try it with the following steps. See the Design Doc if interested.
How to Build with Type Profiler
- Edit .gclient to checkout the modified version of Clang.
"url" : "http://git.chromium.org/chromium/src.git",
- Build Chromium with additional build options. ("clang_type_profiler=1" is the required option.)
ninja -C out_type_profile/Debug -j 16 chrome
- Run the customized Chromium with Deep Memory Profiler as usual.
Run the dmprof script with a policy label "t0".
tools/deep_memory_profiler/dmprof csv -p t0 ~/profile/00-test.12345.0002.heap > ~/profile/00-test.12345.result.csv
- Run the customized Chromium with TCMalloc's heap-profiler and an environment variable "HEAP_PROFILE_TYPE_STATISTICS=1".
HEAPPROFILE=/tmp/prefix HEAP_PROFILE_TIME_INTERVAL=20 HEAP_PROFILE_TYPE_STATISTICS=1 out_type_profile/Debug/chrome --no-sandbox
- Type statistics "prefix.<pid>.????.type" is dumped with every heap profile dump. It is a classification of all malloc'ed objects by their types. For example, " 13: 520 @ N3WTF5MutexE" means that 13 objects of WTF::Mutex occupy 520 bytes.
3739: 841574 @ (no_typeinfo)
1: 16 @ N3WTF13WTFThreadDataE
1: 16 @ N3WTF14ThreadSpecificINS_13WTFThreadDataEE4DataE
13: 520 @ N3WTF5MutexE
Looking up from your code
Type Profiler just records mapping from object addresses to their types. You can utilize the mapping by yourself. To use it from your code,
- Include third_party/tcmalloc/chromium/src/gperftools/type_profiler_map.h, and
- Call LookupType() for object addresses.
- LookupType() returns const std::type_info& for the object.