Tracing malloc, calloc, realloc, and free

Chris Johns chrisj at rtems.org
Thu Dec 18 04:36:02 UTC 2014


Hi,

I have just pushed some configuration files to rtems-tools.git so you 
can printk trace malloc, calloc, realloc, and free. We have been chasing 
down an allocation bug and I thought it would be interesting to see what 
happens with the RTEMS trace linker. The updated rtems-tools repo and 
this configuration file allow me to get a complete trace of all heap 
allocation calls (yawn, I have JFFS2 running).

To use this configuration you need to trace link your application. A 
command similar to this should work assume your tools are in the path 
and if not just use absolute paths:

  rtems-tld -vvv \
    -C malloc-free.ini \
    -B arm/xilinx_zynq_zc706 \
    -r /opt/rtems/4.11 \
    -l arm-rtems4.11-g++ -- \
    -qrtems \
    -B/opt/rtems/4.11/arm-rtems4.11/lib/ \
    -B/opt/rtems/4.11/arm-rtems4.11/xilinx_zynq_zc706/lib/ \
    --specs bsp_specs -march=armv7-a -mthumb -mfpu=neon \
    -mfloat-abi=hard -mtune=cortex-a9 -DIS_RTOS -g -O \
    main.o -o mainapp libsuff.a libmoresfuff.a libyeapokgotit.a \
    boost/lib/libboost_system.a boost/lib/libboost_date_time.a \
    boost/lib/libboost_regex.a

The parts of the command line after '--' is your normal linker command 
line. The example above links a C++ application which is the reason for 
the -l option.

Chris
-------------- next part --------------
;
; RTEMS Trace Linker C library Heap Configuration.
;
; We must provide a top level trace section.
;
[tracer]
;
; Name of the trace.
;
name = RTEMS Trace Linker Lib C Heap
;
; The BSP.
;
bsp = arm/xilinx_zynq_zc706
;
; Options can be defined here or on the command line.
;
options = all-funcs, verbose
;
; Functions to trace.
;
traces = malloc-free-trace
;
; Define the function sets. These are the function's that can be
; added to the trace lists.
;
functions = libc-heap
;
; Include RTEMS C Library Trace support.
;
include = libc-heap.ini, rtld-base.ini

;
; Malloc/free trace
;
[malloc-free-trace]
generator = printk-generator
traces = libc-heap-all


More information about the devel mailing list