LinuxÏÂcoreÎļþ
1.1 coreÎļþµÄ¼òµ¥½éÉÜ
ÔÚÒ»¸ö³ÌÐò±ÀÀ£Ê±£¬ËüÒ»°ã»áÔÚÖ¸¶¨Ä¿Â¼ÏÂÉú³ÉÒ»¸öcoreÎļþ¡£coreÎļþ½ö½öÊÇÒ»¸öÄÚ´æÓ³Ïó(ͬʱ¼ÓÉϵ÷ÊÔÐÅÏ¢)£¬Ö÷ÒªÊÇÓÃÀ´µ÷ÊԵġ£
1.2 ¿ªÆô»ò¹Ø±ÕcoreÎļþµÄÉú³É
ÓÃÒÔÏÂÃüÁîÀ´×èֹϵͳÉú³ÉcoreÎļþ:
ulimit -c 0
Ò²¿ÉÒÔÐÞ¸ÄϵͳÎļþÀ´µ÷ÕûcoreÑ¡Ïî
ÔÚ/etc/profileͨ³£»áÓÐÕâÑùÒ»¾ä»°À´½ûÖ¹²úÉúcoreÎļþ£¬Í¨³£ÕâÖÖÉèÖÃÊǺÏÀíµÄ:
# No core files by default
ulimit -S -c 0 > /dev/null 2>&1
ÏÂÃæµÄÃüÁî¿ÉÒÔ¼ì²éÉú³ÉcoreÎļþµÄÑ¡ÏîÊÇ·ñ´ò¿ª:
ulimit -c
Èç¹ûÏÔʾ0£¬ÔòΪ¹Ø±Õ
ulimit -c unlimitedÀ´ÈÃÌض¨µÄÓû§¿ÉÒÔ²úÉúcoreÎļþ£¬¶øulimit -c 1024ÔòÏÞÖƲúÉúµÄcoreÎļþµÄ´óС²»Äܳ¬¹ý1024 blcoks
ÔÚÓû§µÄ~/.bash_profileÀï¼ÓÉÏulimit -c unlimitedÀ´ÈÃÌض¨µÄÓû§¿ÉÒÔ²úÉúcoreÎļþ
1.3 ÉèÖÃCore DumpµÄºËÐÄת´¢ÎļþĿ¼ºÍÃüÃû¹æÔò
/proc/sys/kernel/core_uses_pid¿ÉÒÔ¿ØÖƲúÉúµÄcoreÎļþµÄÎļþÃûÖÐÊÇ·ñÌí¼Ópid×÷ΪÀ©Õ¹£¬Èç¹ûÌí¼ÓÔòÎļþÄÚÈÝΪ1£¬·ñÔòΪ0
/proc/sys/kernel/core_pattern¿ÉÒÔÉèÖøñʽ»¯µÄcoreÎļþ±£´æλÖûòÎļþÃû£¬±ÈÈçÔÀ´ÎļþÄÚÈÝÊÇcore-%e
¿ÉÒÔÕâÑùÐÞ¸Ä:
echo "/corefile/core-%e-%p-%t" > /proc/sys/kernel/core_pattern
½«»á¿ØÖÆËù²úÉúµÄcoreÎļþ»á´æ·Åµ½/corefileĿ¼Ï£¬²úÉúµÄÎļþÃûΪcore-ÃüÁîÃû-pid-ʱ¼ä´Á
ÒÔÏÂÊDzÎÊýÁбí:
%p - insert pid into filename Ìí¼Ópid
%u - insert current uid into filename Ìí¼Óµ±Ç°uid
%g - insert current gid into filename Ìí¼Óµ±Ç°gid
%s - insert signal that caused the coredump into the filename Ìí¼Óµ¼Ö²úÉúcoreµÄÐźÅ
%t - insert UNIX time that the coredump occurred into filename Ìí¼ÓcoreÎļþÉú³ÉʱµÄunixʱ¼ä
%h - insert hostname where the coredump happened into filename Ìí¼ÓÖ÷»úÃû
%e - insert coredumping executable name into filename Ìí¼ÓÃüÁîÃû
1.4 ʹÓÃcoreÎļþ
ÔÚcoreÎļþËùÔÚĿ¼Ï¼üÈë:
gdb -c core
Ëü»áÆô¶¯GNUµÄµ÷ÊÔÆ÷£¬À´µ÷ÊÔcoreÎļþ£¬²¢ÇÒ»áÏÔʾÉú³É´ËcoreÎļþµÄ³ÌÐòÃû£¬ÖÐÖ¹´Ë³ÌÐòµÄÐźŵȵÈ
ÈôÐèÒª½øÒ»²½²é¿´core dumpÎļþ½øÐÐÅÅ´í£¬ÐèÒª½øÒ»²½Á˽âgdbµÄÓ÷¨¡£
Ïà¹ØÎĵµ£º
ÀýÒ»£º·¢ËÍSignaling Packet£º
Signaling CommandÊÇ2¸öBluetoothʵÌåÖ®¼äµÄL2CAP²ãÃüÁî´«Êä¡£ËùÒÔµÃSignaling CommandʹÓÃCID 0x0001.
¶à¸öCommand¿ÉÒÔÔÚÒ»¸öC-frame£¨control frame£©Öз¢ËÍ¡£
Èç¹ûÒªÖ±½Ó·¢ËÍSignaling Command.ÐèÒª½¨Á¢SOCK_RAWÀàÐ͵ÄL2CAPÁ¬½ÓSocket¡£ÕâÑù²ÅÓлú»á×Ô¼ºÌî³äCommand Code£¬Identi ......
ÏÈд¼¸Ìõ£¬×Ô¼º³£Óõģ¬ÒÔºóÔÙ²¹³ä£º
1. ALT + '.'
Ç°Ò»ÌõÃüÁîµÄ×îºóÒ»¸ö²ÎÊý¡£
ÀýÈ磺
µÚÒ»ÌõÃüÁls /usr/loca/£»
µÚ¶þÌõÃüÁcd /usr/local;
µÚ¶þÌõÃüÁîµÄ/usr/local£¬Ö±½Óͨ¹ýALT+'.'¼´¿ÉÊäÈë¡£
2.CTRL+'r'
ÔÚhistoryÖÐÑ°ÕÒÃüÁî
3.TAB
²¹ÆëÎļþÃû»òĿ¼Ãû
4.$ find -name '*.[ch]' | xargs grep -E 'expr' ......
Linux 2.6 ×Ö·ûÉ豸Çý¶¯³ÌÐò
¡ð¡¢ËµÃ÷
±Ê¼ÇÊÊÓÃÓÚLinuxµÄ2.6.10ÒÔºóµÄÄںˡ£
±Ê¼ÇÒÔLinux
Device
Driver3ÌṩµÄscull³ÌÐò(scullĿ¼ÖеÄmain.cºÍscull.h)Ϊ¼Ç¼Ö÷Ïߣ¬²¢ÒÔ¸ÃÇý¶¯³ÌÐòÖеĸ÷ÖÖϵͳµ÷Óúͺ¯Êýµ÷ÓÃÁ÷³ÌΪ¼Ç
¼˳Ðò¡£±ÈÈ磬module_init( )ºÍmodule_exit(
)ΪÏà¶ÔÓ¦µÄÒ»¶Ôϵͳµ÷Óã¬Ò»°ãÊé¼®Öж¼»á·ÅÔÚÒ ......
Íز¨±ü³Ð²»¶Ï¿ªÍؽøÈ¡µÄ¾«Éñ£¬ÔÚ¼¼ÊõÑз¢ºÍÖ§³ÖÉϲ»¶ÏµÄͶÈëÈËÁ¦ÎïÁ¦£¬Á¦ÇóÔÚ²»¶Ï±ä»¯µÄÊг¡ÐèÇóÖУ¬´ïµ½100%µÄ¿Í»§ÂúÒâ¶È¡£ÔÚ¸Õ¸Õ̤Èë2010Ä꣬¸ù¾Ý¹ýÍùµÄÊг¡µ÷²é£¬½áºÏ¿Í»§µÄÐèÇóºÍ½¨Ò飬Íز¨ÓʼþϵͳÍƳöÁËLinux_°²ÌÚ°æ±¾£¬×÷ΪдºË͸ø¹ã´ó¿Í»§µÄµÚÒ»·ÝÀñÎï¡£
°²ÌÚ´¦ÀíÆ÷ÊÇ×î½üÊ®Äê²ÅÖð½¥·¢Õ¹ÆðÀ´µ ......
1.1.5 ShellÃüÁîºÍÁ÷³Ì¿ØÖÆ
ÔÚshell½Å±¾ÖпÉÒÔʹÓÃÈýÀàÃüÁ
1)Unix ÃüÁî:
ËäÈ»ÔÚshell½Å±¾ÖпÉÒÔʹÓÃÈÎÒâµÄunixÃüÁµ«ÊÇ»¹ÊÇÓÉһЩÏà¶Ô¸ü³£ÓõÄÃüÁî¡£ÕâЩÃüÁîͨ³£ÊÇÓÃÀ´½øÐÐÎļþºÍÎÄ×Ö²Ù×÷µÄ¡£
³£ÓÃÃüÁîÓï·¨¼°¹¦ÄÜ
echo "some text": ½«ÎÄ×ÖÄÚÈÝ´òÓ¡ÔÚÆÁÄ»ÉÏ
ls: ÎļþÁбí
wc –l filewc -w filewc -c fi ......