ʹÓà GDB µ÷ÊÔ Linux Èí¼þ
×÷Õߣºdio
email: hao@peng.com.cn
ÈÕÆÚ£º8/21/2001 1:00:47 PM
ÄÚÈÝ£º
±àÒë
ÔËÐÐ gdb
µ÷ÊԻỰʾÀý
ʹÓöϵã
¸ü¶à¶ÏµãºÍ¹Û²ìµã
Core Îļþ
¶ÑÕ»¸ú×Ù
Á¬½Óµ½ÆäËü½ø³Ì
ÆäËüС¼¼ÇÉ
½áÊøÓï
²Î¿¼×ÊÁÏ
¹ØÓÚ×÷Õß
GNU µ÷ÊÔÆ÷¼ò½é
×÷Õß:David Seager
Linux µÄ´ó²¿·ÖÌØÉ«Ô´×ÔÓÚ shell µÄ GNU µ÷ÊÔÆ÷£¬Ò²³Æ×÷ gdb¡£gdb ¿ÉÒÔÈÃÄú²é¿´³ÌÐòµÄÄÚ²¿½á¹¹¡¢´òÓ¡±äÁ¿Öµ¡¢ÉèÖöϵ㣬ÒÔ¼°µ¥²½µ÷ÊÔÔ´´úÂë¡£ËüÊǹ¦Äܼ«ÆäÇ¿´óµÄ¹¤¾ß£¬ÊÊÓÃÓÚÐÞ¸´³ÌÐò´úÂëÖеÄÎÊÌâ¡£ÔÚ±¾ÎÄÖУ¬ÎÒ½«³¢ÊÔ˵Ã÷ gdb Óжà°ô£¬¶àʵÓá£
±àÒë
¿ªÊ¼µ÷ÊÔ֮ǰ£¬±ØÐëÓóÌÐòÖеĵ÷ÊÔÐÅÏ¢±àÒëÒªµ÷ÊԵijÌÐò¡£ÕâÑù£¬gdb ²ÅÄܹ»µ÷ÊÔËùʹÓõıäÁ¿¡¢´úÂëÐкͺ¯Êý¡£Èç¹ûÒª½øÐбàÒ룬ÇëÔÚ gcc£¨»ò g++£©ÏÂʹÓöîÍâµÄ -g Ñ¡ÏîÀ´±àÒë³ÌÐò£º
gcc -g eg.c -o eg
ÔËÐÐ gdb
ÔÚ shell ÖУ¬¿ÉÒÔʹÓà gdb ÃüÁî²¢Ö¸¶¨³ÌÐòÃû×÷Ϊ²ÎÊýÀ´ÔËÐÐ gdb£¬ÀýÈç gdb eg£»»òÕßÔÚ gdb ÖУ¬¿ÉÒÔʹÓà file ÃüÁîÀ´×°ÈëÒªµ÷ÊԵijÌÐò£¬ÀýÈç file eg¡£ÕâÁ½ÖÖ·½Ê½¶¼¼ÙÉèÄúÊÇÔÚ°üº¬³ÌÐòµÄĿ¼ÖÐÖ´ÐÐÃüÁî¡£×°Èë³ÌÐòÖ®ºó£¬¿ÉÒÔÓà gdb ÃüÁî un À´Æô¶¯³ÌÐò¡£
µ÷ÊԻỰʾÀý
Èç¹ûÒ»ÇÐÕý³££¬³ÌÐò½«Ö´Ðе½½áÊø£¬´Ëʱ gdb ½«ÖØлñµÃ¿ØÖÆ¡£µ«Èç¹ûÓдíÎ󽫻áÔõôÑù£¿ÕâÖÖÇé¿öÏ£¬gdb »á»ñµÃ¿ØÖƲ¢ÖжϳÌÐò£¬´Ó¶ø¿ÉÒÔÈÃÄú¼ì²éËùÓÐÊÂÎïµÄ״̬£¬Èç¹ûÔËÆøºÃµÄ»°£¬¿ÉÒÔÕÒ³öÔÒò¡£ÎªÁËÒý·¢ÕâÖÖÇé¿ö£¬ÎÒÃǽ«Ê¹ÓÃÒ»¸öʾÀý³ÌÐò£º
´úÂëʾÀý eg1.c
#include
int wib(int no1, int no2)
{
int result, diff;
diff = no1 - no2;
result = no1 / diff;
return result;
}
int main(int argc, char *argv[])
{
int value, div, result, i, total;
value = 10;
div = 6;
total = 0;
for(i = 0; i < 10; i++)
{
result = wib(value, div);
total += result;
div++;
value--;
}
printf("%d wibed by %d equals %dn", value, div, total);
return 0;
}
Õâ¸ö³ÌÐò½«ÔËÐÐ 10 ´Î for Ñ»·£¬Ê¹Óà wib() º¯Êý¼ÆËã³öÀÛ»ýÖµ£¬×îºó´òÓ¡³ö½á¹û¡£
ÔÚÄúϲ»¶µÄÎı¾±à¼Æ÷ÖÐÊäÈëÕâ¸ö³ÌÐò£¨Òª±£³ÖÏàͬµÄÐоࣩ£¬±£´æΪ eg1.c£¬Ê¹Óà gcc -g eg1.c -o eg1 ½øÐбàÒ룬²¢Óà gdb eg1 Æô¶¯ gdb¡£Ê¹Óà un ÔËÐгÌÐò¿ÉÄÜ»á²úÉúÒÔÏÂÏûÏ¢£º
Program received signal SIGFPE, Arithmetic exception.
0x80483ea in wib (no1=8, no2=8) at eg1.c:7
7 result = no1 / diff;
(gdb)
g
Ïà¹ØÎĵµ£º
ºìÆì×ÀÃæLinux4.1Ï°²×°ºÍÅäÖÃJSP·þÎñÆ÷È«¹¥ÂÔ
ÕâÁ½ÌìÊÔ×ÅÔÚºìÆìLinux×ÀÃæ°æ4.1Ï°²×°WEB·þÎñÆ÷£¬Òѳɹ¦°²×°£¬ÏÖ°ÑÎҵݲװ¹ý³Ì½éÉÜÈçÏ£¬ÒÔ¸øÓÐÏàËÆÐèÇóµÄÍøÓѲο¼¡£
ÎҵݲװҪÇóÊÇÖ§³ÖJSP¡¢html¡¢htmÍøÒ³£¬ËùÒÔÑ¡ÓÃJDK1.5.0+Tomcat5.5.4+mySQL4.1.7£¬ÕâЩ¶¼Êǵ±Ç°¸÷Èí¼þ×îеÄÎȶ¨°æ±¾£¨·Ç²âÊ԰棩¡£ÔÝûÓа²×°Apacheº ......
¼¶±ð£º Öм¶
Éê Òã (shenyyi@cn.ibm.com), Èí¼þ¹¤³Ìʦ, IBM ÖйúÈí¼þ¿ª·¢ÖÐÐÄ
2008 Äê 5 ÔÂ 29 ÈÕ
ÏëÈýø³ÌÔڶϿªÁ¬½ÓºóÒÀÈ»±£³ÖÔËÐУ¿Èç¹û¸Ã½ø³ÌÒѾ¿ªÊ¼ÔËÐÐÁ˸ÃÈçºÎ²¹¾È£¿ Èç¹ûÓдóÁ¿ÕâÀàÐèÇóÈçºÎ¼ò»¯²Ù×÷£¿
ÎÒÃǾ³£»áÅöµ½ÕâÑùµÄÎÊÌ⣬Óà telnet/ssh µÇ¼ÁËÔ¶³ÌµÄ Linux ·þÎñÆ÷£¬ÔËÐÐÁËһЩºÄʱ½Ï³¤µÄÈÎÎñ£¬ ½á¹ûÈ´ ......
1. Linux ½Å±¾±àд»ù´¡
1.1 Óï·¨»ù±¾½éÉÜ
1.1.1 ¿ªÍ·
³ÌÐò±ØÐëÒÔÏÂÃæµÄÐпªÊ¼£¨±ØÐë·½ÔÚÎļþµÄµÚÒ»ÐУ©£º
#!/bin/sh
¡¡¡¡·ûºÅ#!ÓÃÀ´¸æËßϵͳËüºóÃæµÄ²ÎÊýÊÇÓÃÀ´Ö´ÐиÃÎļþµÄ³ÌÐò¡£ÔÚÕâ ¸öÀý×ÓÖÐÎÒÃÇʹÓÃ/bin/shÀ´Ö´ÐгÌÐò¡£
¡¡¡¡µ±±à¼ºÃ½Å±¾Ê±£¬Èç¹ûÒªÖ´Ðиýű¾£¬»¹±ØÐëʹÆä¿ÉÖ´ÐС£
¡¡¡¡ÒªÊ¹½Å±¾¿ÉÖ´ÐУº
±àÒ ......