This is great news Gabriele.

If I'd like to register an annotation only when we crash in a specific
scope (my use case is recording if a sanitized SQL query was running at
crash time), do you suggest I just set and unset the registered variable,
or is there also a way to unregister a variable?

Thank you,
Marco

On Mon, Mar 4, 2024 at 11:43 AM Gabriele Svelto <[email protected]> wrote:

> TL;DR crash annotations can be recorded so that their value is read and
> serialized only at crash-time, this means that even frequently updated
> ones have no performance cost at runtime.
>
> Longer version:
>
> Crash annotations have been historically recorded in C++ using the
> CrashReporter::AnnotateCrashReport() method. This would serialize the
> annotation value into a string and then store it in a table that would
> later be attached to a crash. A new way of recording crash annotations
> is now available via CrashReporter::RegisterAnnotation<TypeName>(). This
> method takes an address to the variable holding the annotation's value
> (which can be a boolean, integer, string, etc...) and records it among
> the annotations. At crash time we'll extract the values of the
> annotations from these addresses and serialize them into the crash
> report. This means that in the meantime you can update the value of the
> annotation at will without having to re-record it every time. The last
> value in memory will be picked up automatically if we crash.
>
> One advantage of this system is that you can now pick a variable that is
> updated very frequently, even thousands of times per second, and still
> be able to record it in a crash with no performance impact. You only
> have to ensure that the memory holding the value is alive when we crash,
> even though if it isn't the annotation will just be ignored.
>
> You can still record annotations the old way by using
> CrashReporter::RecordAnnotation<TypeName>(). This will make a copy of
> the value you passed in and keep it around with the other annotations.
>
> You can find more details in bug 1831092 [1].
>
>   Gabriele
>
> [1] Record all annotations using the new pull-based system and remove
> the annotation table
>      https://bugzilla.mozilla.org/show_bug.cgi?id=1831092
>
> --
> You received this message because you are subscribed to the Google Groups "
> [email protected]" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To view this discussion on the web visit
> https://groups.google.com/a/mozilla.org/d/msgid/dev-platform/83d422f9-369a-4233-a2b6-0f26c05e5a02%40mozilla.com
> .
>

-- 
You received this message because you are subscribed to the Google Groups 
"[email protected]" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/a/mozilla.org/d/msgid/dev-platform/CAPDqYT3kwMYVQaYxw0qBd_6aZCKbeQaiTSEbeb%3D6ATdCc2Zh%2BQ%40mail.gmail.com.

Reply via email to