Lcd companion boards support (VKLCD50RTA & VKLCD70RT)
Embed:
(wiki syntax)
Show/hide line numbers
mbed_mem_trace.h
00001 /* mbed Microcontroller Library 00002 * Copyright (c) 2006-2016 ARM Limited 00003 * 00004 * Licensed under the Apache License, Version 2.0 (the "License"); 00005 * you may not use this file except in compliance with the License. 00006 * You may obtain a copy of the License at 00007 * 00008 * http://www.apache.org/licenses/LICENSE-2.0 00009 * 00010 * Unless required by applicable law or agreed to in writing, software 00011 * distributed under the License is distributed on an "AS IS" BASIS, 00012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00013 * See the License for the specific language governing permissions and 00014 * limitations under the License. 00015 */ 00016 00017 #ifndef __MBED_MEM_TRACE_H__ 00018 #define __MBED_MEM_TRACE_H__ 00019 00020 #ifdef __cplusplus 00021 extern "C" { 00022 #endif 00023 00024 #include <stdint.h> 00025 #include <stddef.h> 00026 00027 /* Operation types for tracer */ 00028 enum { 00029 MBED_MEM_TRACE_MALLOC, 00030 MBED_MEM_TRACE_REALLOC, 00031 MBED_MEM_TRACE_CALLOC, 00032 MBED_MEM_TRACE_FREE 00033 }; 00034 00035 /* Prefix for the output of the default tracer */ 00036 #define MBED_MEM_DEFAULT_TRACER_PREFIX "#" 00037 00038 /** 00039 * Type of the callback used by the memory tracer. This callback is called when a memory 00040 * allocation operation (malloc, realloc, calloc, free) is called and tracing is enabled 00041 * for that memory allocation function. 00042 * 00043 * @param op the ID of the operation (MBED_MEM_TRACE_MALLOC, MBED_MEM_TRACE_REALLOC, 00044 * MBED_MEM_TRACE_CALLOC or MBED_MEM_TRACE_FREE). 00045 * @param res the result that the memory operation returned (NULL for 'free'). 00046 * @param caller the caller of the memory operation. Note that the value of 'caller' might be 00047 * unreliable. 00048 * 00049 * The rest of the parameters passed 'mbed_mem_trace_cb_t' are the same as the memory operations 00050 * that triggered its call (see 'man malloc' for details): 00051 * 00052 * - for malloc: cb(MBED_MEM_TRACE_MALLOC, res, caller, size). 00053 * - for realloc: cb(MBED_MEM_TRACE_REALLOC, res, caller, ptr, size). 00054 * - for calloc: cb(MBED_MEM_TRACE_CALLOC, res, caller, nmemb, size). 00055 * - for free: cb(MBED_MEM_TRACE_FREE, NULL, caller, ptr). 00056 */ 00057 typedef void (*mbed_mem_trace_cb_t)(uint8_t op, void *res, void* caller, ...); 00058 00059 /** 00060 * Set the callback used by the memory tracer (use NULL for disable tracing). 00061 * 00062 * @param cb the callback to call on each memory operation. 00063 */ 00064 void mbed_mem_trace_set_callback(mbed_mem_trace_cb_t cb); 00065 00066 /** 00067 * Trace a call to 'malloc'. 00068 * @param res the result of running 'malloc'. 00069 * @param size the 'size' argument given to 'malloc'. 00070 * @param caller the caller of the memory operation. 00071 * @return 'res' (the first argument). 00072 */ 00073 void *mbed_mem_trace_malloc(void *res, size_t size, void *caller); 00074 00075 /** 00076 * Trace a call to 'realloc'. 00077 * @param res the result of running 'realloc'. 00078 * @param ptr the 'ptr' argument given to 'realloc'. 00079 * @param size the 'size' argument given to 'realloc'. 00080 * 00081 * @return 'res' (the first argument). 00082 */ 00083 void *mbed_mem_trace_realloc(void *res, void *ptr, size_t size, void *caller); 00084 00085 /** 00086 * Trace a call to 'calloc'. 00087 * @param res the result of running 'calloc'. 00088 * @param nmemb the 'nmemb' argument given to 'calloc'. 00089 * @param size the 'size' argument given to 'calloc'. 00090 * @param caller the caller of the memory operation. 00091 * @Return 'res' (the first argument). 00092 */ 00093 void *mbed_mem_trace_calloc(void *res, size_t num, size_t size, void *caller); 00094 00095 /** 00096 * Trace a call to 'free'. 00097 * @param ptr the 'ptr' argument given to 'free'. 00098 * @param caller the caller of the memory operation. 00099 */ 00100 void mbed_mem_trace_free(void *ptr, void *caller); 00101 00102 /** 00103 * Default memory trace callback. DO NOT CALL DIRECTLY. It is meant to be used 00104 * as the second argument of 'mbed_mem_trace_setup'. 00105 * 00106 * The default callback outputs trace data using 'printf', in a format that's 00107 * easily parsable by an external tool. For each memory operation, the callback 00108 * outputs a line that begins with '#<op>:<0xresult>;<0xcaller>-': 00109 * 00110 * - 'op' identifies the memory operation ('m' for 'malloc', 'r' for 'realloc', 00111 * 'c' for 'calloc' and 'f' for 'free'). 00112 * - 'result' (base 16) is the result of the memor operation. This is always NULL 00113 * for 'free', since 'free' doesn't return anything. 00114 * -'caller' (base 16) is the caller of the memory operation. Note that the value 00115 * of 'caller' might be unreliable. 00116 * 00117 * The rest of the output depends on the operation being traced: 00118 * 00119 * - for 'malloc': 'size', where 'size' is the original argument to 'malloc'. 00120 * - for 'realloc': '0xptr;size', where 'ptr' (base 16) and 'size' are the original arguments to 'realloc'. 00121 * - for 'calloc': 'nmemb;size', where 'nmemb' and 'size' are the original arguments to 'calloc'. 00122 * - for 'free': '0xptr', where 'ptr' (base 16) is the original argument to 'free'. 00123 * 00124 * Examples: 00125 * 00126 * - '#m:0x20003240;0x600d-50' encodes a 'malloc' that returned 0x20003240, was called 00127 * by the instruction at 0x600D with a the 'size' argument equal to 50. 00128 * - '#f:0x0;0x602f-0x20003240' encodes a 'free' that was called by the instruction at 00129 * 0x602f with the 'ptr' argument equal to 0x20003240. 00130 */ 00131 void mbed_mem_trace_default_callback(uint8_t op, void *res, void *caller, ...); 00132 00133 #ifdef __cplusplus 00134 } 00135 #endif 00136 00137 #endif// #ifndef __MBED_MEM_TRACE_H__ 00138 00139
Generated on Tue Jul 12 2022 14:32:43 by 1.7.2