Open Bug 1283337 Opened 8 years ago Updated 2 years ago

Make MOZ_COUNT_CTOR/DTOR track the type name with template argument available

Categories

(Core :: XPCOM, defect, P3)

defect

Tracking

()

People

(Reporter: xidorn, Unassigned)

Details

Attachments

(1 file, 1 obsolete file)

Currently, for example, if we leak a nsTArray<SomeType>, we only know that a nsTArray_base is leaked, but don't know what the "SomeType" is here. Not knowing that makes diagnosing this kind of leakage very difficult.

Simply using macro like what we are doing now wouldn't work because macros are expanded before instantiation.

Some options are:
1. try to use GCC/Clang's __PRETTY_FUNCTION__ and MSVC's __FUNCSIG__ macro, which are expanded after template instantiation, but we would need to parse the string for the typename.
2. enable RTTI for debug build and use typeid(T).name() to get the name.
Attached patch proof of concept for MSVC (obsolete) — Splinter Review
This is a proof of concept of including template arguments in leakcheck which works on MSVC. I wrote this for diagnosing bug 1283106.

Theoretically, something similiar can be done for GCC and Clang as well, I guess.

It may also be possible to make the type name be parsed at compile time rather than runtime, so that it wouldn't slow down tests, but I haven't figured out how.
Another option:
wait for compile time reflection: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2016/p0385r0
Attachment #8767027 - Attachment is obsolete: true
Comment on attachment 8767554 [details] [diff] [review]
proof of concept for MSVC

Review of attachment 8767554 [details] [diff] [review]:
-----------------------------------------------------------------

The RTTI approach strikes me as a better way to do things--more portable, more robust, more comprehensible, and probably more performant.
Priority: -- → P3

What about using https://github.com/adambadura/type_name as an existing wrapper for the PRETTY_FUNCTION based approach? I think RTTI without a wrapper doesn't yield portable results either, and there doesn't seem to have been progress on enabling RTTI in debug builds in the last years?

That's right, but I don't know if we need that to actually work on gcc builds? It needs to build somehow, of course.

Severity: normal → S3
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: