temp

Dependencies:   mbed SDFileSystem MS5607 ADXL345_I2C FATFileSystem

Committer:
IKobayashi
Date:
Mon Mar 16 23:37:42 2020 +0900
Revision:
0:c88c3b616c00
copy

Who changed what in which revision?

UserRevisionLine numberNew contents of line
IKobayashi 0:c88c3b616c00 1
IKobayashi 0:c88c3b616c00 2 /** \addtogroup platform */
IKobayashi 0:c88c3b616c00 3 /** @{*/
IKobayashi 0:c88c3b616c00 4 /* mbed Microcontroller Library
IKobayashi 0:c88c3b616c00 5 * Copyright (c) 2006-2016 ARM Limited
IKobayashi 0:c88c3b616c00 6 *
IKobayashi 0:c88c3b616c00 7 * Licensed under the Apache License, Version 2.0 (the "License");
IKobayashi 0:c88c3b616c00 8 * you may not use this file except in compliance with the License.
IKobayashi 0:c88c3b616c00 9 * You may obtain a copy of the License at
IKobayashi 0:c88c3b616c00 10 *
IKobayashi 0:c88c3b616c00 11 * http://www.apache.org/licenses/LICENSE-2.0
IKobayashi 0:c88c3b616c00 12 *
IKobayashi 0:c88c3b616c00 13 * Unless required by applicable law or agreed to in writing, software
IKobayashi 0:c88c3b616c00 14 * distributed under the License is distributed on an "AS IS" BASIS,
IKobayashi 0:c88c3b616c00 15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
IKobayashi 0:c88c3b616c00 16 * See the License for the specific language governing permissions and
IKobayashi 0:c88c3b616c00 17 * limitations under the License.
IKobayashi 0:c88c3b616c00 18 */
IKobayashi 0:c88c3b616c00 19
IKobayashi 0:c88c3b616c00 20 #ifndef __MBED_MEM_TRACE_H__
IKobayashi 0:c88c3b616c00 21 #define __MBED_MEM_TRACE_H__
IKobayashi 0:c88c3b616c00 22
IKobayashi 0:c88c3b616c00 23 #ifdef __cplusplus
IKobayashi 0:c88c3b616c00 24 extern "C" {
IKobayashi 0:c88c3b616c00 25 #endif
IKobayashi 0:c88c3b616c00 26
IKobayashi 0:c88c3b616c00 27 #include <stdint.h>
IKobayashi 0:c88c3b616c00 28 #include <stddef.h>
IKobayashi 0:c88c3b616c00 29
IKobayashi 0:c88c3b616c00 30 /* Operation types for tracer */
IKobayashi 0:c88c3b616c00 31 enum {
IKobayashi 0:c88c3b616c00 32 MBED_MEM_TRACE_MALLOC,
IKobayashi 0:c88c3b616c00 33 MBED_MEM_TRACE_REALLOC,
IKobayashi 0:c88c3b616c00 34 MBED_MEM_TRACE_CALLOC,
IKobayashi 0:c88c3b616c00 35 MBED_MEM_TRACE_FREE
IKobayashi 0:c88c3b616c00 36 };
IKobayashi 0:c88c3b616c00 37
IKobayashi 0:c88c3b616c00 38 /* Prefix for the output of the default tracer */
IKobayashi 0:c88c3b616c00 39 #define MBED_MEM_DEFAULT_TRACER_PREFIX "#"
IKobayashi 0:c88c3b616c00 40
IKobayashi 0:c88c3b616c00 41 /**
IKobayashi 0:c88c3b616c00 42 * Type of the callback used by the memory tracer. This callback is called when a memory
IKobayashi 0:c88c3b616c00 43 * allocation operation (malloc, realloc, calloc, free) is called and tracing is enabled
IKobayashi 0:c88c3b616c00 44 * for that memory allocation function.
IKobayashi 0:c88c3b616c00 45 *
IKobayashi 0:c88c3b616c00 46 * @param op the ID of the operation (MBED_MEM_TRACE_MALLOC, MBED_MEM_TRACE_REALLOC,
IKobayashi 0:c88c3b616c00 47 * MBED_MEM_TRACE_CALLOC or MBED_MEM_TRACE_FREE).
IKobayashi 0:c88c3b616c00 48 * @param res the result that the memory operation returned (NULL for 'free').
IKobayashi 0:c88c3b616c00 49 * @param caller the caller of the memory operation. Note that the value of 'caller' might be
IKobayashi 0:c88c3b616c00 50 * unreliable.
IKobayashi 0:c88c3b616c00 51 *
IKobayashi 0:c88c3b616c00 52 * The rest of the parameters passed 'mbed_mem_trace_cb_t' are the same as the memory operations
IKobayashi 0:c88c3b616c00 53 * that triggered its call (see 'man malloc' for details):
IKobayashi 0:c88c3b616c00 54 *
IKobayashi 0:c88c3b616c00 55 * - for malloc: cb(MBED_MEM_TRACE_MALLOC, res, caller, size).
IKobayashi 0:c88c3b616c00 56 * - for realloc: cb(MBED_MEM_TRACE_REALLOC, res, caller, ptr, size).
IKobayashi 0:c88c3b616c00 57 * - for calloc: cb(MBED_MEM_TRACE_CALLOC, res, caller, nmemb, size).
IKobayashi 0:c88c3b616c00 58 * - for free: cb(MBED_MEM_TRACE_FREE, NULL, caller, ptr).
IKobayashi 0:c88c3b616c00 59 */
IKobayashi 0:c88c3b616c00 60 typedef void (*mbed_mem_trace_cb_t)(uint8_t op, void *res, void* caller, ...);
IKobayashi 0:c88c3b616c00 61
IKobayashi 0:c88c3b616c00 62 /**
IKobayashi 0:c88c3b616c00 63 * Set the callback used by the memory tracer (use NULL for disable tracing).
IKobayashi 0:c88c3b616c00 64 *
IKobayashi 0:c88c3b616c00 65 * @param cb the callback to call on each memory operation.
IKobayashi 0:c88c3b616c00 66 */
IKobayashi 0:c88c3b616c00 67 void mbed_mem_trace_set_callback(mbed_mem_trace_cb_t cb);
IKobayashi 0:c88c3b616c00 68
IKobayashi 0:c88c3b616c00 69 /**
IKobayashi 0:c88c3b616c00 70 * Trace a call to 'malloc'.
IKobayashi 0:c88c3b616c00 71 * @param res the result of running 'malloc'.
IKobayashi 0:c88c3b616c00 72 * @param size the 'size' argument given to 'malloc'.
IKobayashi 0:c88c3b616c00 73 * @param caller the caller of the memory operation.
IKobayashi 0:c88c3b616c00 74 * @return 'res' (the first argument).
IKobayashi 0:c88c3b616c00 75 */
IKobayashi 0:c88c3b616c00 76 void *mbed_mem_trace_malloc(void *res, size_t size, void *caller);
IKobayashi 0:c88c3b616c00 77
IKobayashi 0:c88c3b616c00 78 /**
IKobayashi 0:c88c3b616c00 79 * Trace a call to 'realloc'.
IKobayashi 0:c88c3b616c00 80 * @param res the result of running 'realloc'.
IKobayashi 0:c88c3b616c00 81 * @param ptr the 'ptr' argument given to 'realloc'.
IKobayashi 0:c88c3b616c00 82 * @param size the 'size' argument given to 'realloc'.
IKobayashi 0:c88c3b616c00 83 *
IKobayashi 0:c88c3b616c00 84 * @return 'res' (the first argument).
IKobayashi 0:c88c3b616c00 85 */
IKobayashi 0:c88c3b616c00 86 void *mbed_mem_trace_realloc(void *res, void *ptr, size_t size, void *caller);
IKobayashi 0:c88c3b616c00 87
IKobayashi 0:c88c3b616c00 88 /**
IKobayashi 0:c88c3b616c00 89 * Trace a call to 'calloc'.
IKobayashi 0:c88c3b616c00 90 * @param res the result of running 'calloc'.
IKobayashi 0:c88c3b616c00 91 * @param nmemb the 'nmemb' argument given to 'calloc'.
IKobayashi 0:c88c3b616c00 92 * @param size the 'size' argument given to 'calloc'.
IKobayashi 0:c88c3b616c00 93 * @param caller the caller of the memory operation.
IKobayashi 0:c88c3b616c00 94 * @Return 'res' (the first argument).
IKobayashi 0:c88c3b616c00 95 */
IKobayashi 0:c88c3b616c00 96 void *mbed_mem_trace_calloc(void *res, size_t num, size_t size, void *caller);
IKobayashi 0:c88c3b616c00 97
IKobayashi 0:c88c3b616c00 98 /**
IKobayashi 0:c88c3b616c00 99 * Trace a call to 'free'.
IKobayashi 0:c88c3b616c00 100 * @param ptr the 'ptr' argument given to 'free'.
IKobayashi 0:c88c3b616c00 101 * @param caller the caller of the memory operation.
IKobayashi 0:c88c3b616c00 102 */
IKobayashi 0:c88c3b616c00 103 void mbed_mem_trace_free(void *ptr, void *caller);
IKobayashi 0:c88c3b616c00 104
IKobayashi 0:c88c3b616c00 105 /**
IKobayashi 0:c88c3b616c00 106 * Default memory trace callback. DO NOT CALL DIRECTLY. It is meant to be used
IKobayashi 0:c88c3b616c00 107 * as the second argument of 'mbed_mem_trace_setup'.
IKobayashi 0:c88c3b616c00 108 *
IKobayashi 0:c88c3b616c00 109 * The default callback outputs trace data using 'printf', in a format that's
IKobayashi 0:c88c3b616c00 110 * easily parsable by an external tool. For each memory operation, the callback
IKobayashi 0:c88c3b616c00 111 * outputs a line that begins with '#<op>:<0xresult>;<0xcaller>-':
IKobayashi 0:c88c3b616c00 112 *
IKobayashi 0:c88c3b616c00 113 * - 'op' identifies the memory operation ('m' for 'malloc', 'r' for 'realloc',
IKobayashi 0:c88c3b616c00 114 * 'c' for 'calloc' and 'f' for 'free').
IKobayashi 0:c88c3b616c00 115 * - 'result' (base 16) is the result of the memor operation. This is always NULL
IKobayashi 0:c88c3b616c00 116 * for 'free', since 'free' doesn't return anything.
IKobayashi 0:c88c3b616c00 117 * -'caller' (base 16) is the caller of the memory operation. Note that the value
IKobayashi 0:c88c3b616c00 118 * of 'caller' might be unreliable.
IKobayashi 0:c88c3b616c00 119 *
IKobayashi 0:c88c3b616c00 120 * The rest of the output depends on the operation being traced:
IKobayashi 0:c88c3b616c00 121 *
IKobayashi 0:c88c3b616c00 122 * - for 'malloc': 'size', where 'size' is the original argument to 'malloc'.
IKobayashi 0:c88c3b616c00 123 * - for 'realloc': '0xptr;size', where 'ptr' (base 16) and 'size' are the original arguments to 'realloc'.
IKobayashi 0:c88c3b616c00 124 * - for 'calloc': 'nmemb;size', where 'nmemb' and 'size' are the original arguments to 'calloc'.
IKobayashi 0:c88c3b616c00 125 * - for 'free': '0xptr', where 'ptr' (base 16) is the original argument to 'free'.
IKobayashi 0:c88c3b616c00 126 *
IKobayashi 0:c88c3b616c00 127 * Examples:
IKobayashi 0:c88c3b616c00 128 *
IKobayashi 0:c88c3b616c00 129 * - '#m:0x20003240;0x600d-50' encodes a 'malloc' that returned 0x20003240, was called
IKobayashi 0:c88c3b616c00 130 * by the instruction at 0x600D with a the 'size' argument equal to 50.
IKobayashi 0:c88c3b616c00 131 * - '#f:0x0;0x602f-0x20003240' encodes a 'free' that was called by the instruction at
IKobayashi 0:c88c3b616c00 132 * 0x602f with the 'ptr' argument equal to 0x20003240.
IKobayashi 0:c88c3b616c00 133 */
IKobayashi 0:c88c3b616c00 134 void mbed_mem_trace_default_callback(uint8_t op, void *res, void *caller, ...);
IKobayashi 0:c88c3b616c00 135
IKobayashi 0:c88c3b616c00 136 #ifdef __cplusplus
IKobayashi 0:c88c3b616c00 137 }
IKobayashi 0:c88c3b616c00 138 #endif
IKobayashi 0:c88c3b616c00 139
IKobayashi 0:c88c3b616c00 140 #endif// #ifndef __MBED_MEM_TRACE_H__
IKobayashi 0:c88c3b616c00 141
IKobayashi 0:c88c3b616c00 142
IKobayashi 0:c88c3b616c00 143 /** @}*/