[26022] 2017-02-04_在Linux中如何使用gdb调试C程序

文档创建者:s7ckTeam
浏览次数:11
最后更新:2025-01-19
2017-02-04_在Linux中如何使用gdb调试C程序 - -   A n s h 1 3 % 4 1 % 8 8 %   L i n u x   使   g d b     C   z h b 1 2 7   L i n u x   2 0 1 7 - 0 2 - 0 4 G D B   -     b u g     G D B   / - G D B   - G D B   -   h t t p s : / / w w w . h o w t o f o r g e . c o m / t u t o r i a l / h o w - t o - d e b u g - c - p r o g r a m s - i n - l i n u x - u s i n g - g d b /     A n s h   z h b 1 2 7   b u g   b u g     b u g 便   C / C + +   使   F o r t r a n     M o d u l a - 2     -   G D B [ 1 ]   -     b u g     G D B   /   U b u n t u   1 4 . 0 4   L T S   C   使   s h e l l     b a s h 4 . 3 . 1 1 G D B     7 . 7 . 1 G D B  
G D B     G D B   使   G D B   使   g c c     C   使       g c c       [ 2 ]   G D B   使   D e b i a n     U b u n t u 使 [ 3 ] g c c       G D B   使   G D B     G D B     g d b   - g - g 1 .   s u d o   a p t - g e t   i n s t a l l   g d b - g 1 .   g d b   [ ] 1 .   r u n 1 .   r u n   [ ]
G D B   G D B     G D B   2 .   7 .   1 4 .                   1 .   # i n c l u d e   < s t d i o . h > 3 .   i n t   m a i n ( ) 4 .   { 5 .           i n t   o u t   =   0 ,   t o t   =   0 ,   c n t   =   0 ; 6 .           i n t   v a l [ ]   =   { 5 ,   5 4 ,   7 6 ,   9 1 ,   3 5 ,   2 7 ,   4 5 ,   1 5 ,   9 9 ,   0 } ; 8 .           w h i l e ( c n t   <   1 0 ) 9 .           { 1 0 .                   o u t   =   v a l [ c n t ] ; 1 1 .                   t o t   =   t o t   +   0 x f f f f f f f f / o u t ; 1 2 .                   c n t + + ; 1 3 .           } 1 5 .           p r i n t f ( " n   T o t a l   =   [ % d ] n " ,   t o t ) ; 1 6 .           r e t u r n   0 ; 1 7 .   } v a l o u t t o t 0 x f f f f f f f f / o u t t o t
  使       G D B         x     0     1 1             G D B   1 .   $   . / g d b - t e s t 2 .   F l o a t i n g   p o i n t   e x c e p t i o n   ( c o r e   d u m p e d ) - g 1 .   g c c   - g   - W a l l   g d b - t e s t . c   - o   g d b - t e s t 1 .   g d b   . / g d b - t e s t F l o a t i n g   p o i n t   e x c e p t i o n n   %   x 1 .   ( g d b ) & ; b r e a k   1 1 ( g d b ) b r e a k   1 1 r u n
G D B           使             B r e a k p o i n t   1 ,   m a i n   ( )   a t   g d b - t e s t . c : 1 1 1 1   t o t   =   t o t   +   0 x f f f f f f f f / o u t ; ( g d b ) o u t 1 .   ( g d b )   p r i n t   o u t 2 .   $ 1   =   5 3 .   ( g d b ) 5 c 1 .   c o u t 0 1 .   . . . 2 .   . . . 3 .   . . . 4 .   B r e a k p o i n t   1 ,   m a i n   ( )   a t   g d b - t e s t . c : 1 1 5 .   1 1   t o t   =   t o t   +   0 x f f f f f f f f / o u t ; 6 .   ( g d b )   p r i n t   o u t 7 .   $ 2   =   9 9 ( g d b )   c
1 0 .   使   G D B               1 1   2 .       2 .   8 .   ( g d b )   c 9 .   C o n t i n u i n g . 1 1 .   B r e a k p o i n t   1 ,   m a i n   ( )   a t   g d b - t e s t . c : 1 1 1 2 .   1 1   t o t   =   t o t   +   0 x f f f f f f f f / o u t ; 1 3 .   ( g d b )   p r i n t   o u t 1 4 .   $ 3   =   0 1 5 .   ( g d b ) s s t e p c 1 .   ( g d b )   s 3 .   P r o g r a m   r e c e i v e d   s i g n a l   S I G F P E ,   A r i t h m e t i c   e x c e p t i o n . 4 .   0 x 0 8 0 4 8 4 a a   i n   m a i n   ( )   a t   g d b - t e s t . c : 1 1 5 .   1 1   t o t   =   t o t   +   0 x f f f f f f f f / o u t ; s 1 .   ( g d b )   s 3 .   P r o g r a m   t e r m i n a t e d   w i t h   s i g n a l   S I G F P E ,   A r i t h m e t i c   e x c e p t i o n . 4 .   T h e   p r o g r a m   n o   l o n g e r   e x i s t s .
使   G D B   G D B   使   G D B   使 G D B   v i a :   h t t p s : / / w w w . h o w t o f o r g e . c o m / t u t o r i a l / h o w - t o - d e b u g - c - p r o g r a m s - i n - l i n u x - u s i n g - g d b / A n s h [ 4 ]   z h b 1 2 7   j a s m i n e p e n g   L C T T [ 5 ]   L i n u x   <     >   I D   [ 1 ] :   G D B   -   h t t p s : / / w w w . s o u r c e w a r e . o r g / g d b / [ 2 ] :     -   h t t p s : / / l i n u x . d i e . n e t / m a n / 1 / g c c [ 3 ] :     -   h t t p s : / / w w w . s o u r c e w a r e . o r g / g d b / d o w n l o a d / [ 4 ] :   A n s h   -   h t t p s : / / w w w . h o w t o f o r g e . c o m / t u t o r i a l / h o w - t o - d e b u g - c - p r o g r a m s - i n - l i n u x - u s i n g - g d b / [ 5 ] :   L C T T   -   h t t p s : / / g i t h u b . c o m / L C T T / T r a n s l a t e P r o j e c t
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则