a tool to count accesses to member variables in c++ programs

Overview

access_profiler

access_profiler is a heavy-weight class field access profiler, implemented as C++ library.

to use this profiler, include "access_profiler.hpp" and make the types you want to instrument derive from access_profiler::instrument_type< your-type > (i.e. you need to specify your type as the template argument).

in you Jamfile, add a dependency to the access_profiler library.

When you terminate your program, the access counters for your types fields will be printed to "access_profile.out" in current working directory. This file lists all instrumented types and the access counters for offsets into those types.

To combine this information with the debug information for more user-friendly output, use the struct_layout tool and use the profile as input.

Note

access_profiler is currently not compatible with std::make_shared or similar functions, since those won't invoke the new operator. To profile such types, convert them to regular std::shared_ptr constructor which still allocates the object with new.

output format

Each instrumented type has its fully qualified name printed on a single line preceded by a blank line (even the first type).

After each instrumented type follows a list of offsets into that type, colon, and the number of times that offset was accessed. The counter does not distinguish between reads and writes. These lines are indented by at least 3 spaces, but the offset is right adjusted and may contain some leading spaces too.

The general outline looks like this:

<blank line>
<fully qualified name of instrumented type>
   <offset>:<hit count>
   <offset>:<hit count>

example usage

#include "access_profiler.hpp"
#include <stdio.h>

struct test : access_profiler::instrument_type<test>
{
        test() : a(0), b(0) {}
        char array[50];
        int a;
        int b;
};

int main(int argc, char* argv[])
{
        test* t1 = new test;

        for (int i = 0; i < 10; ++i)
        {
                ++t1->a;
                t1->b += t1->a;
        }

        printf("%d\n", t1->b);

        delete t1;
}

example output

output from a debug build:

test
     52: 31
     56: 22

output from a release build:

test
     52: 1
You might also like...
Optimize small uxntal programs via brute-force

Uxnbruteforce A small C program to optimize little pieces of uxntal code. It is a work in progress, a little bit messy for the moment :) I had the ide

Grand Programs for every Data Structure including all their operations

Grand-Programs-UE20CS203 Grand Programs for every Data Structure including all their operations Some idioms that I use, so you won't get confused I pr

Clio is an embryonic experiment in UI for Common Lisp programs.

Clio Clio is an embryonic experiment in UI for Common Lisp programs. Building and running Clio Make sure you have the prerequisites: Visual Studio 201

Two programs to find the LCM of two positive integers.

LCM-finders LCM-finders? LCM-finders is the repo for my LCM finder projects. I made this program in two similar languages. 🛑 Note: Two languages mean

A collection of Simple C Programs.

C Practice A collection of Simple C Programs. NOTE: Work in progress! List of programs Basic Hello World Print an Integer Add Two Integers Find ASCII

Any one can add their programs here ,but program should not be repeated.
Any one can add their programs here ,but program should not be repeated.

Hactoberfest2021 To All the Beginners Guys Don't Forget to give star to this repo. Any one can add their programs here ,but program should not be repe

A virtual machine for executing programs written in Hack.

HHVM HHVM page | HHVM documentation | Hacklang page | General group | Dev group | Twitter HHVM is an open-source virtual machine designed for executin

Ios-malicious-bithunter - iOS Malicious Bit Hunter is a malicious plug-in detection engine for iOS applications. It can analyze the head of the macho file of the injected dylib dynamic library based on runtime. If you are interested in other programs of the author, please visit https://github.com/SecurityLife
Vaca - An experimental Win32 wrapper for C++ to develop GUI programs

Vaca Visual Application Components Abstraction Copyright (c) 2005-2012 David Capello All rights reserved. Vaca is a library to develop GUI application

Owner
Arvid Norberg
Arvid Norberg
défi pour maitrise bien les variables

challengeC Objectif Nous allons écrire des programmes C simples en utilisant les connaissances des types de données, des opérateurs, des fonctions pri

odin 5 Jul 30, 2022
Get_next_line is a project that taught me some new concepts like static variables file_desctiptors how they work

Get_next_line is a project that taught me some new concepts like static variables file_desctiptors how they work, how to create them, read and import data from them.

Ahmed El Mountassir 3 Aug 29, 2022
Just a basic mini library for parsing simple files that only have variables written and with Lua extension.

C++ Parser Lua file config Just a basic mini library for parsing simple files that only have variables written and with Lua extension. Note: At the mo

Marcos Oliveira 3 Dec 26, 2021
c++ program to solve up too 100 equations in 100 variables

linear-equation-solver c++ program to solve up too 100 equations in 100 variables PROGRAMMED BY : FAYSSAL & INASS REVONS COMMUNITY LICENSE & MIT THANK

Fayssal Chokri 2 Jul 2, 2022
collection of C/C++ programs that try to get compilers to exploit undefined behavior

------------------------------------------------------------------------------- UB Canaries: A collection of C/C++ programs that detect undefined beh

John Regehr 161 Nov 22, 2022
Backtrace support for Rust `no_std` and embedded programs.

mini-backtrace This crate provides backtrace support for no_std and embedded programs. This is done through by compiling LLVM's libunwind with certain

Amanieu d'Antras 27 Dec 18, 2022
Run Linux programs on DOS

A WSL alternative for users who prefer an MS-DOS environment. DOS Subsystem for Linux integrates a real Linux environment into MS-DOS systems, allowing users to make use of both DOS and Linux applications from the DOS command prompt.

Hailey Somerville 1.3k Dec 22, 2022
Create a Jupyter Kernel for 8085 Microprocessor assembly language that can interpret assembly-level programs right from the Jupyter notebook.

Create a Jupyter Kernel for 8085 Microprocessor assembly language that can interpret assembly-level programs right from the Jupyter notebook.

Sarita Singh 4 Oct 5, 2022
Several GX2 test programs to compare it with OpenGL. (With additional GLFW+OpenGL implementation provided)

GX2-Tests Provided are GX2 test programs and samples for comparison with OpenGL and with additional GLFW+OpenGL implementation for test on PC. These s

AboodXD 1 Nov 15, 2021