ads1115 only
Fork of mbed by
platform/mbed_mem_trace.h@128:9bcdf88f62b0, 2016-10-27 (annotated)
- Committer:
- <>
- Date:
- Thu Oct 27 16:45:56 2016 +0100
- Revision:
- 128:9bcdf88f62b0
Release 128 of the mbed library
Ports for Upcoming Targets
Fixes and Changes
2966: Add kw24 support https://github.com/ARMmbed/mbed-os/pull/2966
3068: MultiTech mDot - clean up PeripheralPins.c and add new pin names https://github.com/ARMmbed/mbed-os/pull/3068
3089: Kinetis HAL: Remove clock initialization code from serial and ticker https://github.com/ARMmbed/mbed-os/pull/3089
2943: [NRF5] NVIC_SetVector functionality https://github.com/ARMmbed/mbed-os/pull/2943
2938: InterruptIn changes in NCS36510 HAL. https://github.com/ARMmbed/mbed-os/pull/2938
3108: Fix sleep function for NRF52. https://github.com/ARMmbed/mbed-os/pull/3108
3076: STM32F1: Correct timer master value reading https://github.com/ARMmbed/mbed-os/pull/3076
3085: Add LOWPOWERTIMER capability for NUCLEO_F303ZE https://github.com/ARMmbed/mbed-os/pull/3085
3046: [BEETLE] Update BLE stack on Beetle board https://github.com/ARMmbed/mbed-os/pull/3046
3122: [Silicon Labs] Update of Silicon Labs HAL https://github.com/ARMmbed/mbed-os/pull/3122
3022: OnSemi RAM usage fix https://github.com/ARMmbed/mbed-os/pull/3022
3121: STM32F3: Correct UART4 and UART5 defines when using DEVICE_SERIAL_ASYNCH https://github.com/ARMmbed/mbed-os/pull/3121
3142: Targets- NUMAKER_PFM_NUC47216 remove mbed 2 https://github.com/ARMmbed/mbed-os/pull/3142
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
<> | 128:9bcdf88f62b0 | 1 | |
<> | 128:9bcdf88f62b0 | 2 | /** \addtogroup platform */ |
<> | 128:9bcdf88f62b0 | 3 | /** @{*/ |
<> | 128:9bcdf88f62b0 | 4 | /* mbed Microcontroller Library |
<> | 128:9bcdf88f62b0 | 5 | * Copyright (c) 2006-2016 ARM Limited |
<> | 128:9bcdf88f62b0 | 6 | * |
<> | 128:9bcdf88f62b0 | 7 | * Licensed under the Apache License, Version 2.0 (the "License"); |
<> | 128:9bcdf88f62b0 | 8 | * you may not use this file except in compliance with the License. |
<> | 128:9bcdf88f62b0 | 9 | * You may obtain a copy of the License at |
<> | 128:9bcdf88f62b0 | 10 | * |
<> | 128:9bcdf88f62b0 | 11 | * http://www.apache.org/licenses/LICENSE-2.0 |
<> | 128:9bcdf88f62b0 | 12 | * |
<> | 128:9bcdf88f62b0 | 13 | * Unless required by applicable law or agreed to in writing, software |
<> | 128:9bcdf88f62b0 | 14 | * distributed under the License is distributed on an "AS IS" BASIS, |
<> | 128:9bcdf88f62b0 | 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
<> | 128:9bcdf88f62b0 | 16 | * See the License for the specific language governing permissions and |
<> | 128:9bcdf88f62b0 | 17 | * limitations under the License. |
<> | 128:9bcdf88f62b0 | 18 | */ |
<> | 128:9bcdf88f62b0 | 19 | |
<> | 128:9bcdf88f62b0 | 20 | #ifndef __MBED_MEM_TRACE_H__ |
<> | 128:9bcdf88f62b0 | 21 | #define __MBED_MEM_TRACE_H__ |
<> | 128:9bcdf88f62b0 | 22 | |
<> | 128:9bcdf88f62b0 | 23 | #ifdef __cplusplus |
<> | 128:9bcdf88f62b0 | 24 | extern "C" { |
<> | 128:9bcdf88f62b0 | 25 | #endif |
<> | 128:9bcdf88f62b0 | 26 | |
<> | 128:9bcdf88f62b0 | 27 | #include <stdint.h> |
<> | 128:9bcdf88f62b0 | 28 | #include <stddef.h> |
<> | 128:9bcdf88f62b0 | 29 | |
<> | 128:9bcdf88f62b0 | 30 | /* Operation types for tracer */ |
<> | 128:9bcdf88f62b0 | 31 | enum { |
<> | 128:9bcdf88f62b0 | 32 | MBED_MEM_TRACE_MALLOC, |
<> | 128:9bcdf88f62b0 | 33 | MBED_MEM_TRACE_REALLOC, |
<> | 128:9bcdf88f62b0 | 34 | MBED_MEM_TRACE_CALLOC, |
<> | 128:9bcdf88f62b0 | 35 | MBED_MEM_TRACE_FREE |
<> | 128:9bcdf88f62b0 | 36 | }; |
<> | 128:9bcdf88f62b0 | 37 | |
<> | 128:9bcdf88f62b0 | 38 | /* Prefix for the output of the default tracer */ |
<> | 128:9bcdf88f62b0 | 39 | #define MBED_MEM_DEFAULT_TRACER_PREFIX "#" |
<> | 128:9bcdf88f62b0 | 40 | |
<> | 128:9bcdf88f62b0 | 41 | /** |
<> | 128:9bcdf88f62b0 | 42 | * Type of the callback used by the memory tracer. This callback is called when a memory |
<> | 128:9bcdf88f62b0 | 43 | * allocation operation (malloc, realloc, calloc, free) is called and tracing is enabled |
<> | 128:9bcdf88f62b0 | 44 | * for that memory allocation function. |
<> | 128:9bcdf88f62b0 | 45 | * |
<> | 128:9bcdf88f62b0 | 46 | * @param op the ID of the operation (MBED_MEM_TRACE_MALLOC, MBED_MEM_TRACE_REALLOC, |
<> | 128:9bcdf88f62b0 | 47 | * MBED_MEM_TRACE_CALLOC or MBED_MEM_TRACE_FREE). |
<> | 128:9bcdf88f62b0 | 48 | * @param res the result that the memory operation returned (NULL for 'free'). |
<> | 128:9bcdf88f62b0 | 49 | * @param caller the caller of the memory operation. Note that the value of 'caller' might be |
<> | 128:9bcdf88f62b0 | 50 | * unreliable. |
<> | 128:9bcdf88f62b0 | 51 | * |
<> | 128:9bcdf88f62b0 | 52 | * The rest of the parameters passed 'mbed_mem_trace_cb_t' are the same as the memory operations |
<> | 128:9bcdf88f62b0 | 53 | * that triggered its call (see 'man malloc' for details): |
<> | 128:9bcdf88f62b0 | 54 | * |
<> | 128:9bcdf88f62b0 | 55 | * - for malloc: cb(MBED_MEM_TRACE_MALLOC, res, caller, size). |
<> | 128:9bcdf88f62b0 | 56 | * - for realloc: cb(MBED_MEM_TRACE_REALLOC, res, caller, ptr, size). |
<> | 128:9bcdf88f62b0 | 57 | * - for calloc: cb(MBED_MEM_TRACE_CALLOC, res, caller, nmemb, size). |
<> | 128:9bcdf88f62b0 | 58 | * - for free: cb(MBED_MEM_TRACE_FREE, NULL, caller, ptr). |
<> | 128:9bcdf88f62b0 | 59 | */ |
<> | 128:9bcdf88f62b0 | 60 | typedef void (*mbed_mem_trace_cb_t)(uint8_t op, void *res, void* caller, ...); |
<> | 128:9bcdf88f62b0 | 61 | |
<> | 128:9bcdf88f62b0 | 62 | /** |
<> | 128:9bcdf88f62b0 | 63 | * Set the callback used by the memory tracer (use NULL for disable tracing). |
<> | 128:9bcdf88f62b0 | 64 | * |
<> | 128:9bcdf88f62b0 | 65 | * @param cb the callback to call on each memory operation. |
<> | 128:9bcdf88f62b0 | 66 | */ |
<> | 128:9bcdf88f62b0 | 67 | void mbed_mem_trace_set_callback(mbed_mem_trace_cb_t cb); |
<> | 128:9bcdf88f62b0 | 68 | |
<> | 128:9bcdf88f62b0 | 69 | /** |
<> | 128:9bcdf88f62b0 | 70 | * Trace a call to 'malloc'. |
<> | 128:9bcdf88f62b0 | 71 | * @param res the result of running 'malloc'. |
<> | 128:9bcdf88f62b0 | 72 | * @param size the 'size' argument given to 'malloc'. |
<> | 128:9bcdf88f62b0 | 73 | * @param caller the caller of the memory operation. |
<> | 128:9bcdf88f62b0 | 74 | * @return 'res' (the first argument). |
<> | 128:9bcdf88f62b0 | 75 | */ |
<> | 128:9bcdf88f62b0 | 76 | void *mbed_mem_trace_malloc(void *res, size_t size, void *caller); |
<> | 128:9bcdf88f62b0 | 77 | |
<> | 128:9bcdf88f62b0 | 78 | /** |
<> | 128:9bcdf88f62b0 | 79 | * Trace a call to 'realloc'. |
<> | 128:9bcdf88f62b0 | 80 | * @param res the result of running 'realloc'. |
<> | 128:9bcdf88f62b0 | 81 | * @param ptr the 'ptr' argument given to 'realloc'. |
<> | 128:9bcdf88f62b0 | 82 | * @param size the 'size' argument given to 'realloc'. |
<> | 128:9bcdf88f62b0 | 83 | * |
<> | 128:9bcdf88f62b0 | 84 | * @return 'res' (the first argument). |
<> | 128:9bcdf88f62b0 | 85 | */ |
<> | 128:9bcdf88f62b0 | 86 | void *mbed_mem_trace_realloc(void *res, void *ptr, size_t size, void *caller); |
<> | 128:9bcdf88f62b0 | 87 | |
<> | 128:9bcdf88f62b0 | 88 | /** |
<> | 128:9bcdf88f62b0 | 89 | * Trace a call to 'calloc'. |
<> | 128:9bcdf88f62b0 | 90 | * @param res the result of running 'calloc'. |
<> | 128:9bcdf88f62b0 | 91 | * @param nmemb the 'nmemb' argument given to 'calloc'. |
<> | 128:9bcdf88f62b0 | 92 | * @param size the 'size' argument given to 'calloc'. |
<> | 128:9bcdf88f62b0 | 93 | * @param caller the caller of the memory operation. |
<> | 128:9bcdf88f62b0 | 94 | * @Return 'res' (the first argument). |
<> | 128:9bcdf88f62b0 | 95 | */ |
<> | 128:9bcdf88f62b0 | 96 | void *mbed_mem_trace_calloc(void *res, size_t num, size_t size, void *caller); |
<> | 128:9bcdf88f62b0 | 97 | |
<> | 128:9bcdf88f62b0 | 98 | /** |
<> | 128:9bcdf88f62b0 | 99 | * Trace a call to 'free'. |
<> | 128:9bcdf88f62b0 | 100 | * @param ptr the 'ptr' argument given to 'free'. |
<> | 128:9bcdf88f62b0 | 101 | * @param caller the caller of the memory operation. |
<> | 128:9bcdf88f62b0 | 102 | */ |
<> | 128:9bcdf88f62b0 | 103 | void mbed_mem_trace_free(void *ptr, void *caller); |
<> | 128:9bcdf88f62b0 | 104 | |
<> | 128:9bcdf88f62b0 | 105 | /** |
<> | 128:9bcdf88f62b0 | 106 | * Default memory trace callback. DO NOT CALL DIRECTLY. It is meant to be used |
<> | 128:9bcdf88f62b0 | 107 | * as the second argument of 'mbed_mem_trace_setup'. |
<> | 128:9bcdf88f62b0 | 108 | * |
<> | 128:9bcdf88f62b0 | 109 | * The default callback outputs trace data using 'printf', in a format that's |
<> | 128:9bcdf88f62b0 | 110 | * easily parsable by an external tool. For each memory operation, the callback |
<> | 128:9bcdf88f62b0 | 111 | * outputs a line that begins with '#<op>:<0xresult>;<0xcaller>-': |
<> | 128:9bcdf88f62b0 | 112 | * |
<> | 128:9bcdf88f62b0 | 113 | * - 'op' identifies the memory operation ('m' for 'malloc', 'r' for 'realloc', |
<> | 128:9bcdf88f62b0 | 114 | * 'c' for 'calloc' and 'f' for 'free'). |
<> | 128:9bcdf88f62b0 | 115 | * - 'result' (base 16) is the result of the memor operation. This is always NULL |
<> | 128:9bcdf88f62b0 | 116 | * for 'free', since 'free' doesn't return anything. |
<> | 128:9bcdf88f62b0 | 117 | * -'caller' (base 16) is the caller of the memory operation. Note that the value |
<> | 128:9bcdf88f62b0 | 118 | * of 'caller' might be unreliable. |
<> | 128:9bcdf88f62b0 | 119 | * |
<> | 128:9bcdf88f62b0 | 120 | * The rest of the output depends on the operation being traced: |
<> | 128:9bcdf88f62b0 | 121 | * |
<> | 128:9bcdf88f62b0 | 122 | * - for 'malloc': 'size', where 'size' is the original argument to 'malloc'. |
<> | 128:9bcdf88f62b0 | 123 | * - for 'realloc': '0xptr;size', where 'ptr' (base 16) and 'size' are the original arguments to 'realloc'. |
<> | 128:9bcdf88f62b0 | 124 | * - for 'calloc': 'nmemb;size', where 'nmemb' and 'size' are the original arguments to 'calloc'. |
<> | 128:9bcdf88f62b0 | 125 | * - for 'free': '0xptr', where 'ptr' (base 16) is the original argument to 'free'. |
<> | 128:9bcdf88f62b0 | 126 | * |
<> | 128:9bcdf88f62b0 | 127 | * Examples: |
<> | 128:9bcdf88f62b0 | 128 | * |
<> | 128:9bcdf88f62b0 | 129 | * - '#m:0x20003240;0x600d-50' encodes a 'malloc' that returned 0x20003240, was called |
<> | 128:9bcdf88f62b0 | 130 | * by the instruction at 0x600D with a the 'size' argument equal to 50. |
<> | 128:9bcdf88f62b0 | 131 | * - '#f:0x0;0x602f-0x20003240' encodes a 'free' that was called by the instruction at |
<> | 128:9bcdf88f62b0 | 132 | * 0x602f with the 'ptr' argument equal to 0x20003240. |
<> | 128:9bcdf88f62b0 | 133 | */ |
<> | 128:9bcdf88f62b0 | 134 | void mbed_mem_trace_default_callback(uint8_t op, void *res, void *caller, ...); |
<> | 128:9bcdf88f62b0 | 135 | |
<> | 128:9bcdf88f62b0 | 136 | #ifdef __cplusplus |
<> | 128:9bcdf88f62b0 | 137 | } |
<> | 128:9bcdf88f62b0 | 138 | #endif |
<> | 128:9bcdf88f62b0 | 139 | |
<> | 128:9bcdf88f62b0 | 140 | #endif// #ifndef __MBED_MEM_TRACE_H__ |
<> | 128:9bcdf88f62b0 | 141 | |
<> | 128:9bcdf88f62b0 | 142 | |
<> | 128:9bcdf88f62b0 | 143 | /** @}*/ |