Linux debugging and performance tunning
LTT Linux trace toolkits for Summery
Date; PS; Date
The time command can be used to measure the actual running time.
Gettimeofday return seconds and microseconds
Profile is used to view the time spent on subroutine or func.
Grof
Beforeprograms can be profiled using GPROF, they must be compiled with the-pg gcc option.
$ Gcc-PG-O sample1sample1. cThesample1 program prints the prime numbers up to 50,000. whe
execution time of the function itself and the execution time of the called function.Executes the compiled executable program, such as:./test.exe. This step runs the program slightly slower than when the normally compiled executable program runs. After the program runs, a file with the default file name of Gmon.out is generated under the path of the program, which is a data file that records the performance of the program, the call relationship, the number of calls, and so on.Use the
memory problems in the program, all memory reads and writes are detected, and all calls to malloc ()/free ()/new/delete are captured. Therefore, it can detect the following problems:1. Use of uninitialized memory;2. Read/write the memory block after release;3. Read/write memory blocks that exceed malloc allocations;4. Read/write inappropriate memory blocks in the stack;5. Memory leaks, pointers to a piece of memory are lost forever;6. Incorrect malloc/free or new/delete matching;The DST and src
GNU Assembler (gas)
The GNU assembler (known as gas) is the most popular assembler in the UNIX environment.
Unlike most other development packages, the GNU assembler is not published in a separate package. It is bundled with other development software in the GNU Binutils package. The following programs are included in the Binutils package:
Addr2line convert address to file name and line number
AR Create, modify, and expand file archives
As to assemble assembly language code into target code
C++
NavigatorVim (on the installation of Vim:MV ~/.vim ~/.vim.orig #保存原来的配置文件MV ~/.VIMRC ~/.vimrc.origgit clone git://github.com/humiaozuzu/dot-vimrc.git ~/.vim #下载新的配置Ln-s ~/.VIM/VIMRC ~/.VIMRC #创建软链接git clone https://github.com/gmarik/vundle.git ~/.vim/bundle/vundleAfter git completes, use vim to open any file and install it in command mode with the Bundleinstall command:: Bundleinstall)Code compilation:gcc/g++ (can be installed directly)Project construction: Software building SystemGNU make http
Developer options (useful when working on FFMPEG itself ):
--enable-gprof enable profiling with gprof [] --disable-opts disable compiler optimizations --enable-extra-warnings enable more compiler warnings --disable-strip disable stripping of executables and shared libraries
Note: object files are built at the place where configure is launched.
[Edit]
Precautions
[Edit]
Make w
program is part of the binutils package
F2c is a translation program from FORTRAN to C. Not part of GCC.
The Configuration tool used by gcov GPROF to determine which part of the program is the most time-consuming.
Gdb gnu Debugger, used to check the value and behavior of a program running
Gnats GNU debugging and Tracking System (gnu bug Tracking System ). An online system that tracks issues with GCC and other gnu software.
From: http://blogold.chinaunix.net/u3/104564/showart_2091186.html
1. Install the Cross Compiler1) the cross compiler uses the Eabi-compliant arm-none-linux-gnueabi-gcc-4.3.3 cross compiler provided by codesourcery ,:Http://www.codesourcery.com/sgpp/lite/arm/portal/package4571/public/arm-none-linux-gnueabi/arm-2009q1-203-arm-none-linux-gnueabi-i686-pc-linux-gnu.tar.bz22) decompress the package to the/opt/directory:# Tar jxvf arm-2009q1-203-arm-none-linux-gnueabi-i686-pc-linux-gnu.tar.bz2-C/opt/3)
.../binutils-multiarch_2.22-6ubuntu1_amd64.deb )...Adding 'diversion of/usr/bin/nm to/usr/bin/nm. Single by binutils-multiarch'Adding 'diversion of/usr/bin/objdump to/usr/bin/objdump. Single by binutils-multiarch'Adding 'diversion of/usr/bin/objcopy to/usr/bin/objcopy. Single by binutils-multiarch'Adding 'diversion of/usr/bin/strings to/usr/bin/strings. Single by binutils-multiarch'Adding 'diversion of/usr/bin/strip to/usr/bin/strip. Single by binutils-multiarch'Adding 'diversion of/usr/bin/size
;
Memory blocks in the stack that are not suitable for reading/writing;
Memory leakage: the pointer pointing to a piece of memory is always lost;
Incorrect malloc/free or new/delete match;
The dst and src pointers in the memcpy () related functions overlap.
2. Callgrind
It is similar to gprof, but it is more subtle in program running observation, which can provide us with more information. Unlike gprof, it
elf_i386: connect the target code to the elf_i386 format (that is, the code on the 32-bit platform)
-O: returns the target file.
1.3 debugger (gdb)
The main Commands are:
List: lists the specified functions or rows.
Break: sets a breakpoint.
Run: run
Next: next command
Step: Execute the next instruction in the program
1.4 Compiler (gcc)
Pure assembly does not require gcc. There are not many gcc parameters used, including the following:
-G: code in debugging mode
-O: followed by the target cod
/write memory blocks released;3. read/write memory blocks exceeding the memory allocated by malloc;4. memory blocks in the stack that are not suitable for reading/writing;5. Memory leakage. The pointer pointing to a piece of memory is always lost;6. Incorrect malloc/free or new/delete match;7. the DST and SRC pointers in the memcpy () related functions overlap.These problems are often the biggest headache for C/C ++ programmers. memcheck has helped a lot here.2. callgrindIt is similar to
occurs in such a program, you can use the debugger to locate the error step by step, and then find out the cause of the Error. However, this is troublesome. It is not desirable for the debugger to be a little useful. In this case, the strace command may be more convenient. It displays the execution process and results of calls/signals of various systems. For example, if a file opening error occurs, you can see at a glance that the cause of the error (errno) is known.
3. binutil
Binutil is a se
0000000000000000 rip limit 0000006a1425 RSP limit 47196f10 error 4[Guest @ host search_lau] $ addr2line 255.0000006a1425-e bin/is_searcher_server/Home/ascc_build1358835605903/b2b-isearch_cn/include/build/attributereader. h: 118
Ar-A utility for creating, modifying and extracting from archives.
C ++ filt-Filter to demangle encoded C ++ symbols.
(The C ++ polymorphism changes the functions and variables during compilation, causing inconvenience in reading. This command ca
problems:1. Use of uninitialized memory;2. Read/write the memory block after release;3. Read/write memory blocks that exceed malloc allocations;4. Read/write inappropriate memory blocks in the stack;5. Memory leaks, pointers to a piece of memory are lost forever;6. Incorrect malloc/free or new/delete matching;The DST and src pointers overlap in the 7,memcpy () correlation function.These problems are often the most vexing problem for C + + programmers, and Memcheck is very helpful here.2.Callgri
elapsed ( +- 3.831%)We can see the L1 cache are much more effective.To identify hot spots to concentrate on your can use:$ perf top-e l1-dcache-load-misses-e l1-dcache-loads perftop: 1923 irqs/sec kernel:0.0% exact: 0.0% [l1-dcache-load-misses ...--------------------------------------------------------------------------------- - weight samples pcnt funct DSO ___ _______ _____ _____ ______________________ 1.9 6184 98.8% func2/home/padraig/a.out 0.0 1.1% f
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.