Template:ArticleBasedOnModel Template:ArticleMainWriter
Template:ArticleApprovedVersion
1. Article purpose[edit | edit source]
This article provides the basic information needed to start using the Linux application tool: valgrind[1].
2. Introduction[edit | edit source]
The following table provides a brief description of the tool, as well as its availability depending on the software packages:
Template:Y: this tool is either present (ready to use or to be activated), or can be integrated and activated on the software package.
Template:N: this tool is not present and cannot be integrated, or it is present but cannot be activated on the software package.
Tool | STM32MPU Embedded Software distribution | STM32MPU Embedded Software distribution for Android™ | ||||||
---|---|---|---|---|---|---|---|---|
Name | Category | Purpose | Starter Package | Developer Package | Distribution Package | Starter Package | Developer Package | Distribution Package |
valgrind | Monitoring tools | valgrind[1] is an instrumentation framework for building dynamic analysis tools. Some Valgrind tools can automatically detect many memory management and threading bugs, and profile your programs in detail. This is tool for Linux application analysis. |
Template:Y | Template:Y | Template:Y | Template:UnderConstruction |
3. Installing the trace and debug tool on your target board[edit | edit source]
3.1. Using the STM32MPU Embedded Software distribution[edit | edit source]
valgrind is installed by default and ready to be used with all STM32MPU Embedded Software Packages.
Template:Board$ which valgrind /usr/bin/valgrind
valgrind is integrated in weston image distribution through openembedded-core package: openembedded-core/meta/recipes-core/packagegroups/packagegroup-core-tools-profile.bb.
VALGRIND = "valgrind" ... RDEPENDS_${PN} = "\ ${PROFILETOOLS} \ ${LTTNGUST} \ ${LTTNGTOOLS} \ ${LTTNGMODULES} \ ${BABELTRACE} \ ${SYSTEMTAP} \ Template:Green \ "
3.2. Using the STM32MPU Embedded Software distribution for Android™[edit | edit source]
4. Getting started[edit | edit source]
Valgrind is designed to be as non-intrusive as possible. It works directly with existing executables/applications. It does not require to recompile, relink, or otherwise modify the program to be checked.
Here is a simple way to invoke valgrind:
Template:Board$ valgrind Template:Orange
valgrind can be started without [valgrind-options]. More options can be turned on afterward, according the proposals provided in valgrind first-pass result.
5. To go further[edit | edit source]
5.1. Example[edit | edit source]
- Example of program analysis without any issue detected:
Template:Board$ valgrind /usr/local/bin/fooProg ==351== Memcheck, a memory error detector ==351== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al. ==351== Using Valgrind-3.13.0 and LibVEX; rerun with -h for copyright info ==351== Command: /usr/local/bin/fooProg ==351== push_led application example started... Monitoring line 13 on /dev/gpiochip0 ^C...push_led application example exit. ==351== ==351== HEAP SUMMARY: ==351== in use at exit: Template:Green ==351== total heap usage: Template:Green 4,116 bytes allocated ==351== ==351== Template:Green ==351== ==351== For counts of detected and suppressed errors, rerun with: -v ==351== ERROR SUMMARY: Template:Green (suppressed: 6 from 3)
- Example of program analysis with memory leak issue detected (i.e. missing memory-freeing):
Template:Board$ valgrind /usr/local/bin/fooProg ==360== Memcheck, a memory error detector ==360== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al. ==360== Using Valgrind-3.13.0 and LibVEX; rerun with -h for copyright info ==360== Command: /usr/local/bin/fooProg ==360== push_led application example started... Monitoring line 13 on /dev/gpiochip0 ^C...push_led application example exit. ==360== ==360== HEAP SUMMARY: ==360== in use at exit: Template:Red ==360== total heap usage: Template:Red 4,116 bytes allocated ==360== ==360== LEAK SUMMARY: ==360== definitely lost: 0 bytes in 0 blocks ==360== indirectly lost: 0 bytes in 0 blocks ==360== possibly lost: 0 bytes in 0 blocks ==360== Template:Red ==360== suppressed: 0 bytes in 0 blocks ==360== Template:Orange ==360== ==360== For counts of detected and suppressed errors, rerun with: -v ==360== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 6 from 3)
The text highlighted in Template:Orange in the above valgrind report suggests to turn on more options in order to focus on the reported issue.
6. References[edit | edit source]
- Useful external links
Document link | Document Type | Description |
---|---|---|
Quick start | User guide | Official site |
Wikipedia | Wiki | Documentation from Wikipedia |