nm : just lists symbols from obj file
================
-n sort symbols numerically by address
-D shows dynamic symbols only
Symbol type:
If lowercase, the symbol is local;
if uppercase, the symbol is global (external).
A - symbol's value is absolute, will not be changed by further linking.
B - symbol is in the uninitialized data section (known as BSS).
C - symbol is common. Common symbols are uninitialized data.
D - symbol is in the initialized data section.
N - symbol is a debugging symbol.
R - symbol is in a read only data section.
T - symbol is in the text(code) section.
U - symbol is undefined.
objdump : shows details of obj files
================
-d disassembly
-S mix source code when disassembles
-x display section/program headers
-r display relocation entries
-w more than 80 character wide display
readelf : displays information about contents of ELF format files
================
-a Equivalent to: -h -l -S -s -r -d -V -A -I
-e Equivalent to: -h -l -S
-h Display the ELF file header
-l Display the program headers
-S Display the section headers
-s Display the symbol table
--dyn-syms Display the dynamic symbol table
-r Display the relocations (if present)
-d Display the dynamic section (if present)
-W more than 80 character wide display
good examples:
================
# gcc -c -o test test.c
# readelf -esr test > a.txt
# gcc -g -c -o test test.c
# objdump -drS test > b.txt
PHP code cleaning tools.
PHP LOC statistics:
1. wget --no-check-certificate https://phar.phpunit.de/phploc.phar
2. /opt/lampp/bin/php phploc.phar --exclude="lib" --exclude="Resources" /mnt/data/MyWebProject/ > loc.txt
PHP Mess Detector:
1. Download http://static.phpmd.org/php/2.1.1/phpmd.phar
2. /opt/lampp/bin/php phpmd.phar /mnt/data/MyWebProject/ text codesize --exclude lib,Resources --reportfile code_complexity.txt
[output format: text; available mess detectors: cleancode, codesize, controversial, design, naming, unusedcode]
PHP Code Sniffer (Enforces a coding standard):
1. Download http://download.pear.php.net/package/PHP_CodeSniffer-2.0.0RC1.tgz
2. /opt/lampp/bin/php PHP_CodeSniffer-2.0.0RC1/scripts/phpcs --report-file=code_sniff.txt --standard=Generic --extensions=php --ignore=*/lib/*,*/Resources/* /mnt/data/MyWebProject/
PHP Dead Code Detector:
1. wget --no-check-certificate https://phar.phpunit.de/phpdcd.phar
2. /opt/lampp/bin/php phpdcd.phar --recursive --exclude="lib" --exclude="Resources" /mnt/data/MyWebProject/ > dead_code.txt
PHP Copy Paste Detector
1. wget --no-check-certificate https://phar.phpunit.de/phpcpd.phar
2. /opt/lampp/bin/php phpcpd.phar --exclude="lib" --exclude="Resources" /mnt/data/MyWebProject/ > copy_paste.txt
1. wget --no-check-certificate https://phar.phpunit.de/phploc.phar
2. /opt/lampp/bin/php phploc.phar --exclude="lib" --exclude="Resources" /mnt/data/MyWebProject/ > loc.txt
PHP Mess Detector:
1. Download http://static.phpmd.org/php/2.1.1/phpmd.phar
2. /opt/lampp/bin/php phpmd.phar /mnt/data/MyWebProject/ text codesize --exclude lib,Resources --reportfile code_complexity.txt
[output format: text; available mess detectors: cleancode, codesize, controversial, design, naming, unusedcode]
PHP Code Sniffer (Enforces a coding standard):
1. Download http://download.pear.php.net/package/PHP_CodeSniffer-2.0.0RC1.tgz
2. /opt/lampp/bin/php PHP_CodeSniffer-2.0.0RC1/scripts/phpcs --report-file=code_sniff.txt --standard=Generic --extensions=php --ignore=*/lib/*,*/Resources/* /mnt/data/MyWebProject/
PHP Dead Code Detector:
1. wget --no-check-certificate https://phar.phpunit.de/phpdcd.phar
2. /opt/lampp/bin/php phpdcd.phar --recursive --exclude="lib" --exclude="Resources" /mnt/data/MyWebProject/ > dead_code.txt
PHP Copy Paste Detector
1. wget --no-check-certificate https://phar.phpunit.de/phpcpd.phar
2. /opt/lampp/bin/php phpcpd.phar --exclude="lib" --exclude="Resources" /mnt/data/MyWebProject/ > copy_paste.txt
While searching files with find, exclude some directories
find . -type f -name '*.php' ! -path "./lib/*" ! -path "./Resources/*" -exec vim -s /root/vimscript.scr "{}" \;
To print colored text in linux terminal
echo "$(tput setaf 1) Hello $(tput setaf 2) World! $(tput sgr0)"
or
echo -e "\033[31m Hello \033[32m World! \033[0m"
Option -e means "enable interpretation of backslash escapes"
or
echo -e "\033[31m Hello \033[32m World! \033[0m"
Option -e means "enable interpretation of backslash escapes"
Subscribe to:
Posts (Atom)