In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-05 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
Editor to share with you how to debug GDB, I hope you will gain something after reading this article. Let's discuss it together.
First, the steps of compiling Linux program gcc:
The four main stages of the Gcc compilation process:
L pre-processing stage, complete the macro definition and include file expansion and other work; (.i)
L is optimized to varying degrees according to the compilation parameters and compiled into assembly code (.s.s)
L use the assembler to further generate the assembly code into the object code (.o)
Connect the generated object code to the system or user-provided library with a connector to generate an executable file
Format:
L gcc-E test.c// preprocessing stage
L Gcc-S test.c// compilation phase
L Gcc-c test.c// assembly phase
L Gcc-o test test.c// Link Pha
Second, Linux program gdb debugging steps:
Functions of Gdb:
L set breakpoint
L monitor the value of the program variable
Single-step execution of l program
L display and modify the value of a variable
L display, modify register
L check the stack of the program
L remote debugging
Gdb debugging process:
1. After preprocessing, the program enters the compilation phase, and first declares compilation:
2. Format: gcc-o test test.c-g
3. Enter the compilation: gdb test
4. Show the source programs that need to be compiled and debugged: l (list) / / list filename
5. Set breakpoint: B (break) line number
6. View the breakpoint set: info b
7. Run the debugger: run
8. Skip to the next breakpoint: C (continue)
9. If you run in a single step, use: n (next) / s (step into) to jump to the function body / / is different from: next executes the function body, while step does not execute the function body
10. Check the change of a variable during debugging: print I (set manually every time) / / display I (set it once until it is stopped with "undisplay variable label")
11. Exit the current debugging using the finish pop-out function
12. Clear breakpoint clear line number
13. Delete breakpoint information serial number / / Delete all breakpoints or set breakpoints to be deleted
14. Exit debugging Q
15. B num if iTunes 20 sets the trigger condition of the breakpoint
16. Condition num iTunes 50 changes the trigger conditions of the breakpoint
17. Source code view command in GDB
List / l line number or function name / / View the specified location code
List / / shows the source programs around the linenum line of the program
List / / shows the source program of the function named function
List / / displays the source program after the current line
List / / shows the source program of which function in which file
Eg: list src/fun1.c:fun1
List / / the source program around which line of which file
Eg:list src/fun1.c:1
After reading this article, I believe you have a certain understanding of "how to debug GDB". If you want to know more about it, you are welcome to follow the industry information channel. Thank you for reading!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.