Linux valgrind ported to ARM-Linux
1. Cross-Compile
(1) Download and unzip Valgrind-3.11
(2) Modify the configuration
Change armv7*) to armv7*|arm*)
(3) Execute configure
./configure CC=arm-linux-gcc CPP=arm-linux-cpp CXX=arm-linux-g++ --host=arm-linux --prefix=/opt/valgrind/lib
Note: CC=arm-linux-gcc. The reason why I didn’t use an absolute path like some blogs say is because I have soft-linked arm-linux-gcc to the actual gcc.
(4)make
(5)make install
2. Porting to ARM Development Board
Note: After make install, the bin/ and lib/ directories generated by the compilation are stored in the /opt/valgrind/lib directory on the PC. Copy the bin/ and lib/ directories in this directory separately, and do not copy the share/ and include/ directories, because the files are a bit large, and the include/ and share/ directories are not used on the development board.
Create a "directory - /opt/valgrind/lib/valgrind/" on the ARM development board, and put the files (.so, .a, etc.) in the lib/directory just compiled above into the directory mentioned on the left (/opt/valgrind/lib/valgrind).
Note: The above step is very important. If you put it in the wrong place, when running the valgrind program, it will prompt "failed to start 'memcheck': No such file or directory".
3. Configuration and use on ARM
1. Error: When running "./valgrind ls", an error still occurred in "vgdb". The error prompt is:
[12:58:19]root@freescale ~/valgrind/valgrind/bin$ ./valgrind ls
[12:58:19]==5978== Memcheck, a memory error detector
[12:58:19]==5978== Copyright (C) 2002-2015, and GNU GPL'd, by Julian Seward et al.
[12:58:19]==5978== Using Valgrind-3.11.0 and LibVEX; rerun with -h for copyright info
[12:58:19]==5978== Command: ls
[12:58:19]==5978==
[12:58:20]==5978== error writing 36 bytes to shared mem /tmp/vgdb-pipe-shared-mem-vgdb-5978-by-root-on-???
A temporary solution was found on the webpage failure to run on armv6 following the armv6 legacy patches suggested by bug 276897, which is to temporarily disable "vgdb".
[12:54:55]root@freescale ~/valgrind/valgrind/bin$ ./valgrind --vgdb=no ls
[12:54:55]==5976== Memcheck, a memory error detector
[12:54:55]==5976== Copyright (C) 2002-2015, and GNU GPL'd, by Julian Seward et al.
[12:54:55]==5976== Using Valgrind-3.11.0 and LibVEX; rerun with -h for copyright info
[12:54:55]==5976== Command: ls
[12:54:55]==5976==
[12:54:56]ERROR: ld.so: object '/opt/valgrind/lib/valgrind/vgpreload_core-arm-linux.so' from LD_PRELOAD cannot be preloaded: ignored.
[12:54:56]ERROR: ld.so: object '/opt/valgrind/lib/valgrind/vgpreload_memcheck-arm-linux.so' from LD_PRELOAD cannot be preloaded: ignored.
[12:54:57]==5976== Conditional jump or move depends on uninitialised value(s)
[12:54:57]==5976== at 0x4909C98: index (in /lib/libc-2.11.1.so)
[12:54:57]==5976==
[12:54:58]==5976== Conditional jump or move depends on uninitialised value(s)
[12:54:58]==5976== at 0x4909D90: strcmp (in /lib/libc-2.11.1.so)
[12:54:58]==5976== by 0x4910377: strcoll_l (in /lib/libc-2.11.1.so)
[12:54:58]==5976==
[12:54:58]==5976== Conditional jump or move depends on uninitialised value(s)
[12:54:58]==5976== at 0x4909D98: strcmp (in /lib/libc-2.11.1.so)
[12:54:58]==5976== by 0x4910377: strcoll_l (in /lib/libc-2.11.1.so)
2. LD_PRELOAD error
[12:54:56]ERROR: ld.so: object '/opt/valgrind/lib/valgrind/vgpreload_core-arm-linux.so' from LD_PRELOAD cannot be preloaded: ignored.
After checking the above error, I found that: "/opt/valgrind/lib/valgrind" lacks some ".so/shared dynamic libraries". I recompiled "Valgrind" and used "arm-linux-strip" to simplify the files and copied them successfully. The program also ran smoothly.
4. Introduction to Valgrind
1. What is Valgrind?
2. What can Valgrind do?
(1)「badapp.c」
1 #include 2 3 void f(void) 4 { 5 int* x = malloc(10 * sizeof(int)); 6 x[10] = 0; // problem 1: heap block overrun 7 } // problem 2: memory leak -- x not freed 8 9 int main(void) 10 { 11 f(); 12 return 0; 13 } (2) [15:20:06] [15:20:06]==8399== Copyright (C) 2002-2015, and GNU GPL'd, by Julian Seward et al. [15:20:06]==8399== Using Valgrind-3.11.0 and LibVEX; rerun with -h for copyright info [15:20:06]==8399== Command: ./bad1pp1 [15:20:06]==8399== [15:20:07]connect fail. ip:10.167.13.207, strlen(ip):13. File:main.c, Line:696 [15:20:07]Internet Fail. File: main.c, Line: 2469 [15:20:08]==8399== Invalid write of size 4 [15:20:08]==8399== at 0x8414: f (badapp1.c:6) [15:20:08]==8399== by 0x842F: main (badapp1.c:11) [15:20:08]==8399== Address 0x496f050 is 0 bytes after a block of size 40 alloc'd [15:20:08]==8399== at 0x483481C: malloc (in /opt/valgrind/lib/valgrind/vgpreload_memcheck-arm-linux.so) [15:20:08]==8399== [15:20:08]==8399== [15:20:08]==8399== HEAP SUMMARY: [15:20:08]==8399== in use at exit: 40 bytes in 1 blocks [15:20:08]==8399== total heap usage: 1 allocs, 0 frees, 40 bytes allocated [15:20:08]==8399== [15:20:08]==8399== 40 bytes in 1 blocks are definitely lost in loss record 1 of 1 [15:20:08]==8399== at 0x483481C: malloc (in /opt/valgrind/lib/valgrind/vgpreload_memcheck-arm-linux.so) [15:20:08]==8399== [15:20:08]==8399== LEAK SUMMARY: [15:20:08]==8399== definitely lost: 40 bytes in 1 blocks [15:20:08]==8399== indirectly lost: 0 bytes in 0 blocks [15:20:08]==8399== possibly lost: 0 bytes in 0 blocks [15:20:08]==8399== still reachable: 0 bytes in 0 blocks [15:20:08]==8399== suppressed: 0 bytes in 0 blocks [15:20:08]==8399== [15:20:08]==8399== For counts of detected and suppressed errors, rerun with: -v [15:20:08]==8399== ERROR SUMMARY: 2 errors from 2 contexts (suppressed: 11 from 5) 3. How does Valgrind work? 4. Who developed Valgrind? Julian Seward, from Cambridge, UK. 5. The origin of the name Valgrind From Nordic mythology. Originally (before release) the project was named Heimdall, after the watchman of the Nordic gods. He could "see a hundred miles by day or night, hear the grass growing, see the wool growing on a sheep's back" (etc). This would have been a great name, but it was already taken by a security package "Heimdal". Keeping with the Nordic theme, Valgrind was chosen. Valgrind is the name of the main entrance to Valhalla (the Hall of the Chosen Slain in Asgard). Over this entrance there resides a wolf and over it there is the head of a boar and on it perches a huge eagle, whose eyes can see to the far regions of the nine worlds. Only those judged worthy by the guardians are allowed to pass through Valgrind. All others are refused entrance. It's not short for "value grinder", although that's not a bad guess.
Previous article:ARM series STM32F103RCT6 development
Next article:ARM S3C2410 Learning Notes
- Popular Resources
- Popular amplifiers
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- LED chemical incompatibility test to see which chemicals LEDs can be used with
- Application of ARM9 hardware coprocessor on WinCE embedded motherboard
- What are the key points for selecting rotor flowmeter?
- LM317 high power charger circuit
- A brief analysis of Embest's application and development of embedded medical devices
- Single-phase RC protection circuit
- stm32 PVD programmable voltage monitor
- Introduction and measurement of edge trigger and level trigger of 51 single chip microcomputer
- Improved design of Linux system software shell protection technology
- What to do if the ABB robot protection device stops
- Ranking of installed capacity of smart driving suppliers from January to September 2024: Rise of independent manufacturers and strong growth of LiDAR market
- Industry first! Xiaopeng announces P7 car chip crowdfunding is completed: upgraded to Snapdragon 8295, fluency doubled
- P22-009_Butterfly E3106 Cord Board Solution
- Keysight Technologies Helps Samsung Electronics Successfully Validate FiRa® 2.0 Safe Distance Measurement Test Case
- Innovation is not limited to Meizhi, Welling will appear at the 2024 China Home Appliance Technology Conference
- Innovation is not limited to Meizhi, Welling will appear at the 2024 China Home Appliance Technology Conference
- Huawei's Strategic Department Director Gai Gang: The cumulative installed base of open source Euler operating system exceeds 10 million sets
- Download from the Internet--ARM Getting Started Notes
- Learn ARM development(22)
- Learn ARM development(21)
- SHT31 Review Summary
- The differential voltage measured by the oscilloscope when the RS485 bus is idle is ±3.7V, and the periodic waveform with a frequency of 50hz
- What are the functions of magnetic beads and capacitors? How to choose the impedance of magnetic beads and the size of capacitors?
- Why would the filter added to the final stage cavity be burned?
- 【Beetle ESP32-C3】GNSS test
- Arteli AT32 uses GPIO to simulate HDMI CEC case
- Analyze the cause of tms320c6455 burning
- Beacon navigation sound positioning and recognition - microphone array
- How to make a boost circuit so that the output is equal to the input voltage?
- An experienced person explains Shannon's theorem, Nyquist's theorem, coding and modulation