llvm/compiler-rt/lib/profile/GCDAProfiling.c

/*===- GCDAProfiling.c - Support library for GCDA file emission -----------===*\
|*
|* Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|* See https://llvm.org/LICENSE.txt for license information.
|* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|*
|*===----------------------------------------------------------------------===*|
|*
|* This file implements the call back routines for the gcov profiling
|* instrumentation pass. Link against this library when running code through
|* the -insert-gcov-profiling LLVM pass.
|*
|* We emit files in a corrupt version of GCOV's "gcda" file format. These files
|* are only close enough that LCOV will happily parse them. Anything that lcov
|* ignores is missing.
|*
|* TODO: gcov is multi-process safe by having each exit open the existing file
|* and append to it. We'd like to achieve that and be thread-safe too.
|*
\*===----------------------------------------------------------------------===*/

#if !defined(__Fuchsia__)

#include <errno.h>
#include <fcntl.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#if defined(_WIN32)
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include "WindowsMMap.h"
#else
#include <sys/file.h>
#include <sys/mman.h>
#include <sys/types.h>
#include <unistd.h>
#endif

#include "InstrProfiling.h"
#include "InstrProfilingUtil.h"

/* #define DEBUG_GCDAPROFILING */

enum {};

/*
 * --- GCOV file format I/O primitives ---
 */

/*
 * The current file name we're outputting. Used primarily for error logging.
 */
static char *filename =;

/*
 * The current file we're outputting.
 */
static FILE *output_file =;

/*
 * Buffer that we write things into.
 */
#define WRITE_BUFFER_SIZE
static unsigned char *write_buffer =;
static uint64_t cur_buffer_size =;
static uint64_t cur_pos =;
static uint64_t file_size =;
static int new_file =;
static int gcov_version;
#if defined(_WIN32)
static HANDLE mmap_handle = NULL;
#endif
static int fd =;

fn_ptr;

dynamic_object_id;
// The address of this variable identifies a given dynamic object.
static dynamic_object_id current_id;
#define CURRENT_ID

struct fn_node {};

struct fn_list {};

/*
 * A list of functions to write out the data, shared between all dynamic objects.
 */
struct fn_list writeout_fn_list;

/*
 *  A list of reset functions, shared between all dynamic objects.
 */
struct fn_list reset_fn_list;

static void fn_list_insert(struct fn_list* list, fn_ptr fn) {}

static void fn_list_remove(struct fn_list* list) {}

static void resize_write_buffer(uint64_t size) {}

static void write_bytes(const char *s, size_t len) {}

static void write_32bit_value(uint32_t i) {}

static void write_64bit_value(uint64_t i) {}

static uint32_t read_32bit_value(void) {}

static uint64_t read_64bit_value(void) {}

static char *mangle_filename(const char *orig_filename) {}

static int map_file(void) {}

static void unmap_file(void) {}

/*
 * --- LLVM line counter API ---
 */

/* A file in this case is a translation unit. Each .o file built with line
 * profiling enabled will emit to a different file. Only one file may be
 * started at a time.
 */
COMPILER_RT_VISIBILITY
void llvm_gcda_start_file(const char *orig_filename, uint32_t version,
                          uint32_t checksum) {}

COMPILER_RT_VISIBILITY
void llvm_gcda_emit_function(uint32_t ident, uint32_t func_checksum,
                             uint32_t cfg_checksum) {}

COMPILER_RT_VISIBILITY
void llvm_gcda_emit_arcs(uint32_t num_counters, uint64_t *counters) {}

COMPILER_RT_VISIBILITY
void llvm_gcda_summary_info(void) {}

COMPILER_RT_VISIBILITY
void llvm_gcda_end_file(void) {}

COMPILER_RT_VISIBILITY
void llvm_register_writeout_function(fn_ptr fn) {}

COMPILER_RT_VISIBILITY
void llvm_writeout_files(void) {}

#ifndef _WIN32
// __attribute__((destructor)) and destructors whose priorities are greater than
// 100 run before this function and can thus be tracked. The priority is
// compatible with GCC 7 onwards.
#if __GNUC__ >= 9
#pragma GCC diagnostic ignored "-Wprio-ctor-dtor"
#endif
__attribute__((destructor(100)))
#endif
static void llvm_writeout_and_clear(void) {}

COMPILER_RT_VISIBILITY
void llvm_register_reset_function(fn_ptr fn) {}

COMPILER_RT_VISIBILITY
void llvm_delete_reset_function_list(void) {}

COMPILER_RT_VISIBILITY
void llvm_reset_counters(void) {}

#if !defined(_WIN32)
COMPILER_RT_VISIBILITY
pid_t __gcov_fork() {}
#endif

COMPILER_RT_VISIBILITY
void llvm_gcov_init(fn_ptr wfn, fn_ptr rfn) {}

void __gcov_dump(void) {}

void __gcov_reset(void) {}

#endif