In the Linux environment, the compilation language programming is preliminary-use the gdb debugging program-general Linux technology-Linux programming and kernel information. The following is a detailed description. Debugging is an eternal topic in programming, unless your program has never been wrong. This article describes how to use gdb to debug assembler in Linux:
Gdb (GNU Debugger) is a powerful Debugger. Its GUI version is called Kdbg and runs in the KDE Desktop Environment. Many Linux releases contain gdb by default.
Example program:
-Start: The nop statement is added after the label to suspend the program in gdb.
CODE: # cpuid. s Sample program
. Section. data
Output: . Ascii "The processor Vendor ID is 'xxxxxxxxxxxx' \ n"
. Section. text . Globl _ start
_ Start:
Nop // pause the program in gdb Movl $0, % eax Cpuid Movl $ output, % edi Movl % ebx, 28 (% edi) Movl % edx, 32 (% edi) Movl % ecx, 36 (% edi) Movl $4, % eax Movl $1, % ebx Movl $ output, % ecx Movl $42, % edx Int $0x80 Movl $1, % eax Movl $0, % ebx Int $0x80 |