Skip to main content
The Valgrind tool helps detect memory-related errors that are common in C and C++ programs. These errors can lead to crashes and unpredictable behavior, such as memory leaks and memory corruption. By default, the build includes the Valgrind tool.

Prerequisite

Set up SSH. For instructions, see Sign in using SSH.

Debug with Valgrind

  1. Push debug symbols to the device. For instructions, see Configure debug symbols.
  2. Run the following Valgrind command on the device:
    valgrind --tool=memcheck --leak-check=yes --show-reachable=yes --num-callers=20 --track-fds=yes /usr/bin/tqftpserv
    
    Sample output:
    ==622== Memcheck, a memory error detector
    ==622== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al.
    ==622== Command: /usr/bin/tqftpserv
    ==622==
    ^C==622==
    ==622== Process terminating with default action of signal 2 (SIGINT)
    ==622== at 0x498EF38: select (select.c:69)
    ==622== by 0x4013CB: ??? (in /usr/bin/tqftpserv)
    ==622== by 0x48DB1AF: (below main) (libc_start_call_main.h:58)
    ==622==
    ==622== FILE DESCRIPTORS: 4 open (3 std) at exit.
    ==622== Open pf-42 socket 3:
    ==622== at 0x49984CC: socket (syscall-template.S:120)
    ==622== by 0x4891293: qrtr_open (in /usr/lib/libqrtr.so.1.0)
    ==622== by 0x40129B: ??? (in /usr/bin/tqftpserv)
    ==622== by 0x48DB1AF: (below main) (libc_start_call_main.h:58)
    ==622==
    ==622==
    ==622== HEAP SUMMARY:
    ==622== in use at exit: 0 bytes in 0 blocks
    ==622== total heap usage: 0 allocs, 0 frees, 0 bytes allocated
    ==622==
    ==622== All heap blocks were freed -- no leaks are possible
    ==622==
    ==622== For lists of detected and suppressed errors, rerun with: -s
    ==622== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)
    ==622== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)
    
For more information, see Valgrind.