Enable the _ERROR6_
macro in the application source file linux_test_application.c
and disable _ERROR3_
and _ERROR5_
as shown below.
//#define _ERROR3_
//#define _ERROR5_
#define _ERROR6_
The goal of dynamic memory allocation debugging is to understand memory management.
Under
FLOW
, highlight thelinux_test_app
, and Build.Under
FLOW
, highlight thelinux_test_app
, and Debug to launch a Launch Configuration.Select, the Target Connection; either
physical_zcu102
, orqemu_zcu102
and the Work Directory to /home/petalinux`
The code stops at the program entry.
Use debugging techniques such as the Variables view, step over, breakpoints, and so on to identify the incorrect memory assignment.
Place a breakpoint at the following lines.
*ptr = i + 1; ptr++;
Click Resume and let the tool stop at the breakpoint.
Open Variables view to check the ptr value. Observe that a value is not correctly assigned to a pointer.
Comment out the following code lines:
#ifdef _ERROR6_ ................ ................ ................ //ptr = i + 1; //ptr++; ................
Uncomment the following line of code to make the appropriate pointer assignment.
#ifdef _ERROR6_ ................ ................ ................ ................ ptr[i] = i + 1; ................
Rebuild the application.
Relaunch the
Launch Configuration
Observe the output.