Giter VIP home page Giter VIP logo

gdb-cheat-sheet's Introduction

gdb-cheat-sheet

Various helpfull gdb commands.

Terminal Gui

I recommand using my own config file which integrates gdb-dashboard which is vastly superior to the default gdb -tui mode. Furthermore, I added autoload of the rust python pretty print module and add the rust stdlib if source is present (install via rustup component add rust-src).

RR

I recommand using rr since it allows for faster recording than native gdb (~2times slowdown vs ~50ktimes). This is especially usefull when you want to use reverse direction.

Debugging Rust

# setup breakpoint when panic is invoked
b rust_panic
b rust_begin_unwind
# alternative breakpoint for panic
b std::panicking::rust_panic_with_hook
# print value of element of vec (which is a Vec)
p vec.buf.ptr.pointer.__0[0]

Normal Commands

  • backtrace ('ba') full -- Complete backtrace with local variables
  • up, down, frame -- Move through frames
  • watch -- Suspend the process when a certain condition is met
  • set print pretty on -- Prints out prettily formatted C source code
  • set logging on -- Log debugging session to show to others for support
  • set print array on -- Pretty array printing
  • finish -- Continue till end of function
  • enable and disable -- Enable/disable breakpoints
  • tbreak -- Break once, and then remove the breakpoint
  • where -- Line number currently being executed
  • info locals -- View all local variables
  • info args -- View all function arguments
  • rbreak -- Break on function matching regular expression
  • print -- Print value of expression
  • whatis -- Print data type of expression
  • record -- Record a log of the process execution to replay it later
  • (more info)

Reversed Direction

  • talk on the subject
  • example with watchpoint
  • reverse-continue ('rc') -- Continue program being debugged but run it in reverse
  • reverse-finish -- Execute backward until just before the selected stack frame is called
  • reverse-next ('rn') -- Step program backward, proceeding through subroutine calls.
  • reverse-nexti ('rni') -- Step backward one instruction, but proceed through called subroutines.
  • reverse-step ('rs') -- Step program backward until it reaches the beginning of a previous source line
  • reverse-stepi -- Step backward exactly one instruction
  • set exec-direction (forward/reverse) -- Set direction of execution.
  • more info

Conversion

  • p/d 0x10 -- gives decimal equivalent of 0x10
  • p/t 0x10 -- binary equivalent of 0x10
  • p/x 256 -- hex equivalent of 256

gdb-cheat-sheet's People

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.