From fd13d079f2ace7b06620c3705018a3443c604225 Mon Sep 17 00:00:00 2001 From: Vedant Kumar Date: Wed, 8 Jun 2016 22:24:52 +0000 Subject: [PATCH] [docs] Coverage: Flesh out instructions for avoiding static initializeres git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@272214 91177308-0d34-0410-b5e6-96231b3b80d8 --- docs/SourceBasedCodeCoverage.rst | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/docs/SourceBasedCodeCoverage.rst b/docs/SourceBasedCodeCoverage.rst index 22420d97cd..4425bdeb02 100644 --- a/docs/SourceBasedCodeCoverage.rst +++ b/docs/SourceBasedCodeCoverage.rst @@ -192,14 +192,22 @@ By default the compiler runtime uses a static initializer to determine the profile output path and to register a writer function. To collect profiles without using static initializers, do this manually: -* Export a ``int __llvm_profile_runtime`` symbol. The linker won't pull in the - object file containing the profiling runtime's static initializer if this - symbol is defined. - -* Call ``__llvm_profile_initialize_file`` once. This parses - ``LLVM_PROFILE_FILE`` and sets the output path. - -* Call ``__llvm_profile_write_file`` to write out a profile. +* Export a ``int __llvm_profile_runtime`` symbol from each instrumented shared + library and executable. When the linker finds a definition of this symbol, it + knows to skip loading the object which contains the profiling runtime's + static initializer. + +* Forward-declare ``void __llvm_profile_initialize_file(void)`` and call it + once from each instrumented executable. This function parses + ``LLVM_PROFILE_FILE``, sets the output path, and truncates any existing files + at that path. To get the same behavior without truncating existing files, + pass a filename pattern string to ``void __llvm_profile_set_filename(char + *)``. These calls can be placed anywhere so long as they precede all calls + to ``__llvm_profile_write_file``. + +* Forward-declare ``int __llvm_profile_write_file(void)`` and call it to write + out a profile. Calling this function multiple times appends profile data to + an existing on-disk raw profile. Drawbacks and limitations ========================= -- 2.40.0