Write barman profile data in the memory buffer to custom storage

This topic describes how to interface, and instruct, barman to store capture data in a RAM buffer then write out the data to a storage of your choice.

Procedure

  1. Follow the steps in Configuring Barman to configure barman to use an on-target RAM buffer.

    As part of the integration process, you must initialize the barman agent with a user-provided memory buffer. Because you are providing the memory buffer, you can choose how to save its contents when the profiled code has finished running.

  2. After the sampling has stopped, store the contents of the memory buffer using your chosen mechanism. You can, for example, save to file or send over a network connection if your platform supports these options.

    The following example stops the sampling by calling barman_disable_sampling(), and stores the memory buffer contents to a file called barman.raw:

    /* Define the RAM buffer used to store the capture data.
     */
    #define SIZE  4096*4096
    bm_uint8 data[SIZE] __attribute__((aligned(8)));
    
    /* Application initializes Barman.
     */
    void my_app_profiling_setup_code()
    {
        barman_initialize(data, SIZE, "barman-example", &clock_info, 0);
        barman_enable_sampling();
    }
    
    /* Application provides a mechanism to stop profiling and save the buffer.
     */
    void my_app_profiling_tear_down_code()
    {
        barman_disable_sampling();
        /* This function uses the API that your embedded software or RTOS
         * provides to store the buffer contents to a file.
         */
        write_byte_buffer_to_file("barman.raw", data, SIZE);
    }