Skip to content

Latest commit

 

History

History
80 lines (68 loc) · 2.27 KB

File metadata and controls

80 lines (68 loc) · 2.27 KB

GDB (GNU Debugger) is a powerful and widely used debugger for debugging programs on Unix-like systems, including Linux. It is a command-line tool that allows developers and reverse engineers to inspect and control the execution of programs, analyze their behavior, and identify and fix bugs. Here are some common uses of GDB:

  1. Launching a Program:

    gdb <executable>

    This command starts GDB with the specified executable.

  2. Setting Breakpoints:

    break <function>

    or

    break <line-number>

    This sets a breakpoint at a specific function or line number in the source code.

  3. Running the Program:

    run

    This command runs the program until a breakpoint or until it completes.

  4. Stepping Through Code:

    step

    This command executes the current line of code and stops at the first instruction of any called function.

    next

    This command executes the current line of code but does not step into any called functions.

  5. Continuing Execution:

    continue

    This command continues the execution until the next breakpoint or until the program completes.

  6. Inspecting Variables:

    print <variable>

    or

    p <variable>

    This command prints the current value of a variable.

  7. Backtrace:

    backtrace

    or

    bt

    This command shows the current call stack.

  8. Changing Values:

    set <variable> = <value>

    This command changes the value of a variable during program execution.

  9. Displaying Memory Content:

    x/<format> <address>

    This command displays the memory content at a specific address using a specified format.

  10. Detaching from a Running Process:

    detach

    This command detaches GDB from a running process, leaving the process running independently.

GDB is a powerful and flexible tool, and its capabilities extend beyond these basic commands. It's commonly used for both software development and reverse engineering tasks on Linux systems. Additionally, many integrated development environments (IDEs) provide GDB integration, offering a graphical interface for debugging.