GDB ʹÓ×—Linux C±à³Ì
¼òÊö
Ò» ÁÐÎļþÇåµ¥
¶þ£ºÖ´ÐгÌÐò
Èý£ºÏÔʾÊý¾Ý
ËÄ£º¶Ïµã(breakpoint)
Î壮¶ÏµãµÄ¹ÜÀí
Áù£®±äÁ¿µÄ¼ì²éºÍ¸³Öµ
Æß. µ¥²½Ö´ÐÐ
°Ë£®º¯ÊýµÄµ÷ÓÃ
¾Å£®»úÆ÷ÓïÑÔ¹¤¾ß
Ê®£®ÐźÅ
GDBµÄʹÓ÷½·¨
¼òÊö
Ò» ÁÐÎļþÇåµ¥
* List
(gdb) list line1,line2
¶þ£ºÖ´ÐгÌÐò
ÒªÏëÔËÐÐ×¼±¸µ÷ÊԵijÌÐò£¬¿ÉʹÓÃrunÃüÁÔÚËüºóÃæ¿ÉÒÔ¸úËæ·¢¸ø¸Ã³ÌÐòµÄÈκβÎÊý£¬°üÀ¨±ê×¼ÊäÈëºÍ±ê×¼Êä³ö˵Ã÷·û(<ºÍ> )ºÍÍâ¿ÇͨÅä·û£¨*¡¢£¿¡¢[¡¢]£©ÔÚÄÚ¡£Èç¹ûÄãʹÓò»´ø²ÎÊýµÄrunÃüÁgdb¾ÍÔÙ´ÎʹÓÃÄã¸øÓèÇ°Ò»ÌõrunÃüÁîµÄ²ÎÊý£¬ÕâÊǺÜÓÐÓõġ£ÀûÓÃset args ÃüÁî¾Í¿ÉÒÔÐ޸ķ¢Ë͸ø³ÌÐòµÄ²ÎÊý£¬¶øʹÓÃshow args ÃüÁî¾Í¿ÉÒԲ鿴Æäȱʡ²ÎÊýµÄÁÐ±í¡£
£¨gdb£©set args –b –x
(gdb) show args
backtraceÃüÁîΪ¶ÑÕ»ÌṩÏòºó¸ú×Ù¹¦ÄÜ¡£
Backtrace ÃüÁî²úÉúÒ»ÕÅÁÐ±í£¬°üº¬×Å´Ó×î½üµÄ¹ý³Ì¿ªÊ¼µÄËùÒÔÓÐЧ¹ý³ÌºÍµ÷ÓÃÕâЩ¹ý³ÌµÄ²ÎÊý¡£
Èý£ºÏÔʾÊý¾Ý
* ÀûÓÃprint ÃüÁî¿ÉÒÔ¼ì²é¸÷¸ö±äÁ¿µÄÖµ¡£
(gdb) print p (pΪ±äÁ¿Ãû)
print ÊÇgdbµÄÒ»¸ö¹¦ÄܺÜÇ¿µÄÃüÁÀûÓÃËü¿ÉÒÔÏÔʾ±»µ÷ÊÔµÄÓïÑÔÖÐÈκÎÓÐЧµÄ±í´ïʽ¡£±í´ïʽ³ýÁË°üº¬Äã³ÌÐòÖеıäÁ¿Í⣬»¹¿ÉÒÔ°üº¬ÒÔÏÂÄÚÈÝ£º
1. ¶Ô³ÌÐòÖк¯ÊýµÄµ÷ÓÃ
(gdb) print find_entry(1,0)
2. Êý¾Ý½á¹¹ºÍÆäËû¸´ÔÓ¶ÔÏó
(gdb) print *table_start
$8={e=reference=’\000’,location=0x0,next=0x0}
3. ÖµµÄÀúÊ·³É·Ö
(gdb)print $1 ($1ΪÀúÊ·¼Ç¼±äÁ¿,ÔÚÒÔºó¿ÉÒÔÖ±½ÓÒýÓà $1 µÄÖµ)
4. ÈËΪÊý×é
ÈËΪÊý×éÌṩÁËÒ»ÖÖÈ¥ÏÔʾ´æ´¢Æ÷¿é£¨Êý×é½Ú»ò¶¯Ì¬·ÖÅäµÄ´æ´¢Çø£©ÄÚÈݵķ½·¨¡£ÔçÆڵĵ÷ÊÔ³ÌÐòûÓкܺõķ½·¨½«ÈÎÒâµÄÖ¸Õë»»³ÉÒ»¸öÊý×é¡£¾ÍÏñ¶Ô´ý²ÎÊýÒ»Ñù£¬ÈÃÎÒÃDz鿴ÄÚ´æÖÐÔÚ±äÁ¿hºóÃæµÄ10¸öÕûÊý£¬Ò»¸ö¶¯Ì¬Êý×éµÄÓï·¨ÈçÏÂËùʾ£º
b
Ïà¹ØÎĵµ£º
extern "C"
¡¡¡¡extern "C" °üº¬Ë«Öغ¬Ò壬´Ó×ÖÃæÉϼ´¿ÉµÃµ½£ºÊ×ÏÈ£¬±»ËüÐÞÊεÄÄ¿±êÊÇ“extern”µÄ£»Æä´Î£¬±»ËüÐÞÊεÄÄ¿±êÊÇ“C”µÄ¡£ÈÃÎÒÃÇÀ´Ïêϸ½â¶ÁÕâÁ½Öغ¬Òå¡£
¡¡¡¡£¨1£© ±»extern "C"ÏÞ¶¨µÄº¯Êý»ò±äÁ¿ÊÇexternÀàÐ͵ģ»
¡¡¡¡externÊÇC/C++ÓïÑÔÖбíÃ÷º¯ÊýºÍÈ«¾Ö±äÁ¿×÷Ó÷¶Î§£¨¿É¼ûÐÔ£©µÄ¹Ø¼ü×Ö£ ......
¼ÆËãÏß³ÌÖ´ÐÐijÏîÈÎÎñÏûºÄµÄʱ¼äʱ£¬Ðí¶à¿ª·¢ÈËÔ±»áµ÷ÓÃGetTickCount/GetTickCount64±àдÈçϵĴúÂ룺
// Get the current time (start time)
ULONGLONG qwStartTime = GetTickCount64();
// Perform complex algorithm here
// Subtract start time from current time to get duration
ULONGLONG dwElapsedTime = Get ......
ÀýÒ»£º·¢ËÍ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 ......
°´: ¾¡¹ÜÎÒÃÇÒѾ²»Ï°¹ß¿´³¤Æª´óÂÛ, µ«ÎÒ»¹ÊÇҪ˵, ÕâÊÇһƪֵµÃÄã´ÓÍ·¶Áµ½Î²µÄ³¤ÆªÎÄÕÂ.
2005Äê9ÔÂ22ÈÕ£¬Ç廪ÔÚ¶Á²©Ê¿ÉúÍõÛóÔÚˮľÉçÇøBLOGÉÏ·¢±íÁË¡¶Ç廪ÃεķÛËé--д¸øÇ廪´óѧµÄÍËѧÉêÇë¡·Ã÷È·ÒªÇóÍËѧ, ÒýÆðÉç»á¸÷½ç¹ã·ºÕùÂÛ. Ëû´´×÷µÄ³¤ÆªÎÄÕ¡¶ÍêÈ«ÓÃLinux¹¤×÷¡·, ÑóÑóÁ½Íò¶à×Ö, ´Ó²»Í¬½Ç¶È¾Ó¸ßÁÙϵIJûÊöÁËËûÑÛÖÐL ......
1.Linux“Ï߳̔
½ø³ÌÓëÏß³ÌÖ®¼äÊÇÓÐÇø±ðµÄ£¬²»¹ýLinuxÄÚºËÖ»ÌṩÁËÇáÁ¿½ø³ÌµÄÖ§³Ö£¬Î´ÊµÏÖÏß³ÌÄ£ÐÍ¡£LinuxÊÇÒ»ÖÖ“¶à½ø³Ìµ¥Ï߳̔µÄ²Ù×÷ϵͳ¡£Linux±¾ÉíÖ»Óнø³ÌµÄ¸ÅÄ¶øÆäËùνµÄ“Ï߳̔±¾ÖÊÉÏÔÚÄÚºËÀïÈÔÈ»Êǽø³Ì¡£
´ó¼Ò ......