1/** \file 2 * \brief Memory server benchmark tracing 3 */ 4 5/* 6 * Copyright (c) 2010-2011, ETH Zurich. 7 * All rights reserved. 8 * 9 * This file is distributed under the terms in the attached LICENSE file. 10 * If you do not find this file, copies can be found by writing to: 11 * ETH Zurich D-INFK, Universitaetstrasse 6, CH-8092 Zurich. Attn: Systems Group. 12 */ 13 14//#include <string.h> 15#include <stdlib.h> 16#include <stdio.h> 17 18#include <barrelfish/barrelfish.h> 19#include <trace/trace.h> 20#include <trace_definitions/trace_defs.h> 21 22#include "memtest_trace.h" 23 24errval_t init_tracing(void) 25{ 26#ifdef CONFIG_TRACE 27 debug_printf("init tracing\n"); 28 29 trace_reset_all(); 30 31 // Tell the trace system when to start and stop. We can also 32 // provide an overriding maximum duration (in cycles) as the last parameter. 33 return trace_control(TRACE_EVENT(TRACE_SUBSYS_MEMTEST, 34 TRACE_EVENT_MEMTEST_START, 0), 35 TRACE_EVENT(TRACE_SUBSYS_MEMTEST, 36 TRACE_EVENT_MEMTEST_STOP, 0), 37 0); 38#else 39 debug_printf("Warning: tracing not enabled\n"); 40 return SYS_ERR_OK; 41#endif 42 43} 44 45void start_tracing(void) 46{ 47 // start the trace going by providing the start event 48 trace_event(TRACE_SUBSYS_MEMTEST, TRACE_EVENT_MEMTEST_START, 0); 49 debug_printf("tracing started\n"); 50} 51 52void stop_tracing(void) 53{ 54 // stop the trace by providing the stop event 55 trace_event(TRACE_SUBSYS_MEMTEST, TRACE_EVENT_MEMTEST_STOP, 0); 56 debug_printf("tracing stopped\n"); 57} 58 59#define TRACE_SIZE (4096*4096) 60static char *buf = NULL; 61 62void prepare_dump(void) 63{ 64 buf = malloc(TRACE_SIZE); 65 assert(buf != NULL); 66} 67 68void dump_trace(void) 69{ 70 // dump the trace on the output. We can copy and paste it 71 // to use in Aquarium. 72 if (buf == NULL) { 73 prepare_dump(); 74 } 75 size_t len = trace_dump(buf, TRACE_SIZE, NULL); 76 printf("%s\n", buf); 77 debug_printf("dump finished. len: %d\n", (int)len); 78 free(buf); 79} 80