How to use Valgrind on WP76 to investigate memory leaks

Thank you very much, I am now trying to use Valgrind in the NFS way.

Where should I download this, can you give me a link? Thank you

https://source.sierrawireless.com/resources/airprime/software/wp76xx/wp76xx-firmware-release-13,-d-,1-components/#sthash.YCBCjRWU.dpbs


Colleagues use Valgrind source code to cross compile.An error was reported when using the execution file. Have you ever encountered it? Thank you for answering.

I used the valgrind from yocto source, no problem is found

Ok, I ’m downloading, try it your way.

 tao@ubuntu:~/yocto$ make image_bin
    Makefile:57: "Legato: build disabled since '/home/tao/yocto/legato/' does not exist"
    "meta-swi/build.sh" -p poky/ -o meta-openembedded/ -l meta-swi -x "kernel" -j 9 -t 9          -a "LK_REPO="/home/tao/yocto/lk"" -m swi-mdm9x28 -P wp  -b build_bin -q
    Poky dir: /home/tao/yocto/poky
    OE meta: /home/tao/yocto/meta-openembedded
    SWI meta dir: /home/tao/yocto/meta-swi
    Linux repo dir: /home/tao/yocto/kernel
    Number of make threads 9
    Number of bitbake tasks 9
    Extra options added -  LK_REPO=/home/tao/yocto/lk
    SWI machine: swi-mdm9x28
    SWI product: wp
    Build dir: /home/tao/yocto/build_bin
    Enable Qualcomm Proprietary bin
    You had no conf/local.conf file. This configuration file has therefore been
    created for you with some default values. You may wish to edit it to, for
    example, select a different MACHINE (target hardware). See conf/local.conf
    for more information as common configuration options are commented.

    You had no conf/bblayers.conf file. This configuration file has therefore been
    created for you with some default values. To add additional metadata layers
    into your configuration please add entries to conf/bblayers.conf.

    The Yocto Project has extensive documentation about OE including a reference
    manual which can be found at:
        http://yoctoproject.org/documentation

    For more information about OpenEmbedded see their website:
        http://www.openembedded.org/


    ### Shell environment set up for builds. ###

    You can now run 'bitbake <target>'

    Common targets are:
        core-image-minimal
        core-image-sato
        meta-toolchain
        meta-ide-support

    You can also run generated qemu images with a command like 'runqemu qemux86'
    Error: bash is not set as default provider for /bin/sh
           build is not guaranteed to work, aborting
    make: *** [Makefile:255: image_bin] Error 1

My current environment is Ubuntu 18.04 with nothing installed and no compiler installed. I reported an error after executing "make image_bin", and my colleagues did not encounter this problem either. Do you know the reason?Thank you for your help.In addition, the downloaded compressed package is 8.9GB, but it is 5.5GB after unzipping. I don't know whether this is ok or not. There are no errors in the unzipping process.

How big is it in your coleague pc?
How about just type make?

tao@ubuntu:~/yocto$ make
Makefile:57: "Legato: build disabled since '/home/tao/yocto/legato/' does not exist"
"meta-swi/build.sh" -p poky/ -o meta-openembedded/ -l meta-swi -x "kernel" -j 9 -t 9          -a "LK_REPO="/home/tao/yocto/lk"" -m swi-mdm9x28 -P wp  -b build_bin -q
Poky dir: /home/tao/yocto/poky
OE meta: /home/tao/yocto/meta-openembedded
SWI meta dir: /home/tao/yocto/meta-swi
Linux repo dir: /home/tao/yocto/kernel
Number of make threads 9
Number of bitbake tasks 9
Extra options added -  LK_REPO=/home/tao/yocto/lk
SWI machine: swi-mdm9x28
SWI product: wp
Build dir: /home/tao/yocto/build_bin
Enable Qualcomm Proprietary bin

### Shell environment set up for builds. ###

You can now run 'bitbake <target>'

Common targets are:
    core-image-minimal
    core-image-sato
    meta-toolchain
    meta-ide-support

You can also run generated qemu images with a command like 'runqemu qemux86'
Error: bash is not set as default provider for /bin/sh
       build is not guaranteed to work, aborting
make: *** [Makefile:255: image_bin] Error 1

This is how much memory I’m using now, I don’t know about my colleagues.Is it because I’m out of memory?

Make sure you set from dash to bash on Ubuntu running ‘sudo dpkg-reconfigure dash’ (say no)

| gcc     -I. -I./lib -I../bison-3.0.4 -I../bison-3.0.4/lib -isystem/home/tao/yocto/build_bin/tmp/work/x86_64-linux/bison-native/3.0.4-r0/recipe-sysroot-native/usr/include  -isystem/home/tao/yocto/build_bin/tmp/work/x86_64-linux/bison-native/3.0.4-r0/recipe-sysroot-native/usr/include -O2 -pipe -c -o lib/fcntl.o ../bison-3.0.4/lib/fcntl.c
| gcc     -I. -I./lib -I../bison-3.0.4 -I../bison-3.0.4/lib -isystem/home/tao/yocto/build_bin/tmp/work/x86_64-linux/bison-native/3.0.4-r0/recipe-sysroot-native/usr/include  -isystem/home/tao/yocto/build_bin/tmp/work/x86_64-linux/bison-native/3.0.4-r0/recipe-sysroot-native/usr/include -O2 -pipe -c -o lib/fprintf.o ../bison-3.0.4/lib/fprintf.c
| gcc     -I. -I./lib -I../bison-3.0.4 -I../bison-3.0.4/lib -isystem/home/tao/yocto/build_bin/tmp/work/x86_64-linux/bison-native/3.0.4-r0/recipe-sysroot-native/usr/include  -isystem/home/tao/yocto/build_bin/tmp/work/x86_64-linux/bison-native/3.0.4-r0/recipe-sysroot-native/usr/include -O2 -pipe -c -o lib/fseterr.o ../bison-3.0.4/lib/fseterr.c
| ../bison-3.0.4/lib/fseterr.c: In function 'fseterr':
| ../bison-3.0.4/lib/fseterr.c:77:3: error: #error "Please port gnulib fseterr.c to your platform! Look at the definitions of ferror and clearerr on your system, then report this to bug-gnulib."
|    77 |  #error "Please port gnulib fseterr.c to your platform! Look at the definitions of ferror and clearerr on your system, then report this to bug-gnulib."
|       |   ^~~~~
| make[2]: *** [Makefile:3366: lib/fseterr.o] Error 1
| make[2]: Leaving directory '/home/tao/yocto/build_bin/tmp/work/x86_64-linux/bison-native/3.0.4-r0/build'
| ERROR: oe_runmake failed
| make[1]: *** [Makefile:4379: all-recursive] Error 1
| make[1]: Leaving directory '/home/tao/yocto/build_bin/tmp/work/x86_64-linux/bison-native/3.0.4-r0/build'
| make: *** [Makefile:2525: all] Error 2
| WARNING: /home/tao/yocto/build_bin/tmp/work/x86_64-linux/bison-native/3.0.4-r0/temp/run.do_compile.92708:1 exit 1 from 'exit 1'
| ERROR: Function failed: do_compile (log file is located at /home/tao/yocto/build_bin/tmp/work/x86_64-linux/bison-native/3.0.4-r0/temp/log.do_compile.92708)
ERROR: Task (virtual:native:/home/tao/yocto/poky/meta/recipes-devtools/bison/bison_3.0.4.bb:do_compile) failed with exit code '1'
NOTE: Tasks Summary: Attempted 117 tasks of which 0 didn't need to be rerun and 1 failed.

Summary: 1 task failed:
  virtual:native:/home/tao/yocto/poky/meta/recipes-devtools/bison/bison_3.0.4.bb:do_compile
Summary: There were 41 WARNING messages shown.
Summary: There were 2 ERROR messages shown, returning a non-zero exit code.
make: *** [Makefile:255: image_bin] Error 1
tao@ubuntu:~/yocto$ cat build_bin/tmp/work/x86_64-linux/bison-native/3.0.4-r0/temp/log.do_compile.92708
../bison-3.0.4/lib/fseterr.c: In function 'fseterr':
../bison-3.0.4/lib/fseterr.c:77:3: error: #error "Please port gnulib fseterr.c to your platform! Look at the definitions of ferror and clearerr on your system, then report this to bug-gnulib."
   77 |  #error "Please port gnulib fseterr.c to your platform! Look at the definitions of ferror and clearerr on your system, then report this to bug-gnulib."
      |   ^~~~~
make[2]: *** [Makefile:3366: lib/fseterr.o] Error 1
make[2]: Leaving directory '/home/tao/yocto/build_bin/tmp/work/x86_64-linux/bison-native/3.0.4-r0/build'
ERROR: oe_runmake failed
make[1]: *** [Makefile:4379: all-recursive] Error 1
make[1]: Leaving directory '/home/tao/yocto/build_bin/tmp/work/x86_64-linux/bison-native/3.0.4-r0/build'
make: *** [Makefile:2525: all] Error 2
WARNING: /home/tao/yocto/build_bin/tmp/work/x86_64-linux/bison-native/3.0.4-r0/temp/run.do_compile.92708:1 exit 1 from 'exit 1'
ERROR: Function failed: do_compile (log file is located at /home/tao/yocto/build_bin/tmp/work/x86_64-linux/bison-native/3.0.4-r0/temp/log.do_compile.92708)

A new error occurred during compilation.

You can try google the solution.

https://github.com/manuel-serrano/bigloo/issues/23

fhs@fhs-OptiPlex-990:~/Desktop/yocto$ cat /home/fhs/Desktop/yocto/build_bin/tmp/work/swi_mdm9x28_wp-poky-linux-gnueabi/mdm9x28-image-minimal/1.0-r0.0/temp/log.do_image_complete.20958
DEBUG: Executing python function sstate_task_prefunc
DEBUG: Python function sstate_task_prefunc finished
DEBUG: Executing python function extend_recipe_sysroot
NOTE: Direct dependencies are ['virtual:native:/home/fhs/Desktop/yocto/poky/meta/recipes-devtools/makedevs/makedevs_1.0.1.bb:do_populate_sysroot', 'virtual:native:/home/fhs/Desktop/yocto/poky/meta/recipes-devtools/mtd/mtd-utils_git.bb:do_populate_sysroot', 'virtual:native:/home/fhs/Desktop/yocto/poky/meta/recipes-extended/pbzip2/pbzip2_1.1.13.bb:do_populate_sysroot', 'virtual:native:/home/fhs/Desktop/yocto/poky/meta/recipes-core/update-rc.d/update-rc.d_0.7.bb:do_populate_sysroot', '/home/fhs/Desktop/yocto/poky/meta/recipes-core/glibc/ldconfig-native_2.12.1.bb:do_populate_sysroot', 'virtual:native:/home/fhs/Desktop/yocto/poky/meta/recipes-extended/pigz/pigz_2.4.bb:do_populate_sysroot', 'virtual:native:/home/fhs/Desktop/yocto/poky/meta/recipes-devtools/pseudo/pseudo_git.bb:do_populate_sysroot', '/home/fhs/Desktop/yocto/poky/meta/recipes-devtools/mklibs/mklibs-native_0.1.43.bb:do_populate_sysroot', 'virtual:native:/home/fhs/Desktop/yocto/meta-swi/common/recipes-security/ima-evm-utils/ima-evm-utils_1.1.bb:do_populate_sysroot', 'virtual:native:/home/fhs/Desktop/yocto/meta-swi/common/recipes-devtools/squashfs-tools/squashfs-tools_git.bb:do_populate_sysroot', 'virtual:native:/home/fhs/Desktop/yocto/poky/meta/recipes-devtools/opkg-utils/opkg-utils_0.3.6.bb:do_populate_sysroot', '/home/fhs/Desktop/yocto/poky/meta/recipes-kernel/kmod/depmodwrapper-cross_1.0.bb:do_populate_sysroot', '/home/fhs/Desktop/yocto/poky/meta/recipes-devtools/qemu/qemuwrapper-cross_1.0.bb:do_populate_sysroot', '/home/fhs/Desktop/yocto/meta-swi/meta-swi-mdm9xxx/recipes-bsp/lk/lk_1.3.0.bb:do_populate_sysroot', 'virtual:native:/home/fhs/Desktop/yocto/meta-swi/common/recipes-core/cwetool/cwetool_git.bb:do_populate_sysroot', 'virtual:native:/home/fhs/Desktop/yocto/meta-openembedded/meta-oe/recipes-crypto/cryptsetup/cryptsetup_1.7.4.bb:do_populate_sysroot', 'virtual:native:/home/fhs/Desktop/yocto/poky/meta/recipes-devtools/opkg/opkg_0.3.6.bb:do_populate_sysroot', 'virtual:native:/home/fhs/Desktop/yocto/poky/meta/recipes-extended/libarchive/libarchive_3.3.2.bb:do_populate_sysroot', 'virtual:native:/home/fhs/Desktop/yocto/poky/meta/recipes-devtools/prelink/prelink_git.bb:do_populate_sysroot']
NOTE: Installed into sysroot: []
NOTE: Skipping as already exists in sysroot: ['makedevs-native', 'mtd-utils-native', 'pbzip2-native', 'update-rc.d-native', 'ldconfig-native', 'pigz-native', 'pseudo-native', 'mklibs-native', 'ima-evm-utils-native', 'squashfs-tools-native', 'opkg-utils-native', 'depmodwrapper-cross', 'qemuwrapper-cross', 'lk', 'cwetool-native', 'cryptsetup-native', 'opkg-native', 'libarchive-native', 'prelink-native', 'xz-native', 'quilt-native', 'qemu-native', 'shadow-native', 'automake-native', 'lzo-native', 'pkgconfig-native', 'autoconf-native', 'zlib-native', 'util-linux-native', 'acl-native', 'gnu-config-native', 'libtool-native', 'e2fsprogs-native', 'bzip2-native', 'gettext-minimal-native', 'keyutils-native', 'attr-native', 'openssl-native', 'kmod-native', 'lz4-native', 'debianutils-native', 'gcc-runtime', 'glibc', 'libgcrypt-native', 'libdevmapper-native', 'popt-native', 'libsolv-native', 'elfutils-native', 'binutils-native', 'dtc-native', 'libsdl-native', 'glib-2.0-native', 'pixman-native', 'alsa-lib-native', 'texinfo-dummy-native', 'm4-native', 'ncurses-native', 'gtk-doc-native', 'python3-native', 'libgcc', 'linux-libc-headers', 'libcap-native', 'libgpg-error-native', 'autoconf-archive-native', 'rpm-native', 'ninja-native', 'cmake-native', 'expat-native', 'bison-native', 'flex-native', 'libxrandr-native', 'libxrender-native', 'libx11-native', 'libxext-native', 'libpcre-native', 'libffi-native', 'util-macros-native', 'libpng-native', 'readline-native', 'gdbm-native', 'sqlite3-native', 'gperf-native', 'db-native', 'nss-native', 'file-native', 'dbus-native', 're2c-native', 'curl-native', 'randrproto-native', 'renderproto-native', 'xproto-native', 'kbproto-native', 'xtrans-native', 'libxcb-native', 'inputproto-native', 'xextproto-native', 'nspr-native', 'xcb-proto-native', 'libpthread-stubs-native', 'libxau-native', 'libxdmcp-native']
DEBUG: Python function extend_recipe_sysroot finished
DEBUG: Executing python function do_image_complete
NOTE: Executing write_deploy_manifest ...
DEBUG: Executing python function write_deploy_manifest
DEBUG: Python function write_deploy_manifest finished
DEBUG: Python function do_image_complete finished
DEBUG: Executing shell function prepare_ubi
ubinize: error!: error in section "sysfs_volume": size of the image file "/home/fhs/Desktop/yocto/build_bin/tmp/work/swi_mdm9x28_wp-poky-linux-gnueabi/mdm9x28-image-minimal/1.0-r0.0/deploy-mdm9x28-image-minimal-image-complete/mdm9x28-image-minimal-swi-mdm9x28-wp-20200601023334.rootfs.2k.ubifs" is 75042816, which is larger than volume size 41943040
WARNING: /home/fhs/Desktop/yocto/build_bin/tmp/work/swi_mdm9x28_wp-poky-linux-gnueabi/mdm9x28-image-minimal/1.0-r0.0/temp/run.prepare_ubi.20958:1 exit 255 from '/home/fhs/Desktop/yocto/build_bin/tmp/work/swi_mdm9x28_wp-poky-linux-gnueabi/mdm9x28-image-minimal/1.0-r0.0/recipe-sysroot-native/usr/sbin/ubinize -o $ubi_path $ubinize_args $ubinize_cfg'
ERROR: Function failed: prepare_ubi (log file is located at /home/fhs/Desktop/yocto/build_bin/tmp/work/swi_mdm9x28_wp-poky-linux-gnueabi/mdm9x28-image-minimal/1.0-r0.0/temp/log.do_image_complete.20958)

Have you ever had this problem?

yes, as said above “there will be error to make the yocto.cwe as it is too big. Instead we need to transfer the binary to module’s RAM area”

root@swi-mdm9x28-wp:/tmp/valgrind# ls
callgrind_annotate  cg_diff             valgrind            vgdb
callgrind_control   cg_merge            valgrind-di-server
cg_annotate         ms_print            valgrind-listener
root@swi-mdm9x28-wp:/tmp/valgrind# ./valgrind ./aa 
valgrind: failed to start tool 'memcheck' for platform 'arm-linux': No such file or directory
root@swi-mdm9x28-wp:/tmp/valgrind# export VALGRIND_LIB=/tmp/valgrind
root@swi-mdm9x28-wp:/tmp/valgrind# ./valgrind ./aa 
==3054== Memcheck, a memory error detector
==3054== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al.
==3054== Using Valgrind-3.13.0 and LibVEX; rerun with -h for copyright info
==3054== Command: ./aa
==3054== 

valgrind:  Fatal error at startup: a function redirection
valgrind:  which is mandatory for this platform-tool combination
valgrind:  cannot be set up.  Details of the redirection are:
valgrind:  
valgrind:  A must-be-redirected function
valgrind:  whose name matches the pattern:      strcmp
valgrind:  in an object with soname matching:   ld-linux.so.3
valgrind:  was not found whilst processing
valgrind:  symbols from the object with soname: ld-linux.so.3
valgrind:  
valgrind:  Possible fixes: (1, short term): install glibc's debuginfo
valgrind:  package on this machine.  (2, longer term): ask the packagers
valgrind:  for your Linux distribution to please in future ship a non-
valgrind:  stripped ld.so (or whatever the dynamic linker .so is called)
valgrind:  that exports the above-named function using the standard
valgrind:  calling conventions for this platform.  The package you need
valgrind:  to install for fix (1) is called
valgrind:  
valgrind:    On Debian, Ubuntu:                 libc6-dbg
valgrind:    On SuSE, openSuSE, Fedora, RHEL:   glibc-debuginfo
valgrind:  
valgrind:  Note that if you are debugging a 32 bit process on a
valgrind:  64 bit system, you will need a corresponding 32 bit debuginfo
valgrind:  package (e.g. libc6-dbg:i386).
valgrind:  
valgrind:  Cannot continue -- exiting now.  Sorry.

root@swi-mdm9x28-wp:/tmp/valgrind#
root@swi-mdm9x28-wp:~# legato version
19.02.0_4cb954265427b8c2c668a010ff5be274_modified
root@swi-mdm9x28-wp:~# cat /proc/version 
Linux version 3.18.131 (oe-user@oe-host) (gcc version 7.3.0 (GCC) ) #1 PREEMPT Mon Jul 8 12:20:50 UTC 2019
root@swi-mdm9x28-wp:~# uname -a
Linux swi-mdm9x28-wp 3.18.131 #1 PREEMPT Mon Jul 8 12:20:50 UTC 2019 armv7l GNU/Linux

Although the final compilation did not succeed, Valgrind has been compiled successfully.According to the way you gave it before, the wrong question is the same. I don’t know what kind of success environment you have.

seems it says it need this library:

./build_bin/tmp/work/armv7a-neon-poky-linux-gnueabi/valgrind/3.13.0-r0/recipe-sysroot/lib/ld-linux.so.3

root@swi-mdm9x28-wp:~/valgrind# ls
callgrind_annotate  ld-2.27.so          ms_print
callgrind_control   ld-linux.so.3       valgrind
cg_annotate         lib                 valgrind-di-server
cg_diff             libc.so.6           valgrind-listener
cg_merge            memcheck-arm-linux  vgdb
root@swi-mdm9x28-wp:~/valgrind# export LD_LIBRARY_PATH=" /home/root/valgrind/"

It has been put in and the path has been specified, but the error still exists.

you need to copy the new ld-linux.so.3 to /lib, however, this folder is read-only folder, so you need to do the following to overlay the folder:

mkdir /tmp/tmp_lib;mkdir /tmp/tmp_lib_wr;
cp -rf /lib /tmp/tmp_lib
mount -t overlay overlay /lib -o lowerdir=/lib,upperdir=/tmp/tmp_lib,workdir=/tmp/tmp_lib_wr;
cp ld-linux.so.3 /lib

Thank you very much, it is ready to use.