Contents

GDB Cheat Sheet

Configuration

  • Save history
1
set history save on

Print

history command

1
C-r (reverse-i-search)`':

address

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
  x/nfu addr

  n: How many units to print (default 1).

  f: Format character (like print)
      o - octal
      x - hexadecimal
      d - decimal
      u - unsigned decimal
      t - binary
      f - floating point
      a - address
      c - char
      s - string
      i - instruction

      u: Unit.
      b: Byte,
      h: Half-word (two bytes)
      w: Word (four bytes)
      g: Giant word (eight bytes))

print hex

1
p/x variable

show all functions

1
info functions [regexp]

show address info

1
info symbol addr

Kernel Debugging

1
2
3
4
5
6
7
8
9
(gdb) apropos lx
function lx_current -- Return current task
function lx_module -- Find module by name and return the module variable
function lx_per_cpu -- Return per-cpu variable
function lx_task_by_pid -- Find Linux task by PID and return the task_struct variable
function lx_thread_info -- Calculate Linux thread_info from task variable
lx-dmesg -- Print Linux kernel log buffer
lx-lsmod -- List currently loaded modules
lx-symbols -- (Re-)load symbols of Linux kernel and currently loaded modules

V8

compile

args

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
# Build arguments go here.
# See "gn args <out_dir> --list" for available build arguments.
is_component_build = true
is_debug = true
symbol_level = 2
target_cpu = "x64"
use_goma = false
v8_enable_backtrace = true
v8_enable_fast_mksnapshot = true
v8_enable_slow_dchecks = true
v8_optimized_debug = false
v8_expose_symbols = true
v8_symbol_level = 2
cppgc_enable_object_names = true
v8_enable_disassembler = true
v8_enable_gdbjit = true

command

1
2
3
gn args out/Debug
#----- add args -----#
gn gen out/Debug

debug

gdbinit

v8/tools/gdbinit

functions
job
1
2
Print a v8 JavaScript object
Usage: job tagged_ptr
jh
1
2
Print content of a v8::internal::Handle
Usage: jh internal_handle
jlh
1
2
print-v8-local, jl, jlh
Print content of v8::Local handle.
jco
1
2
Print a v8 Code object from an internal code address
Usage: jco pc
jtt
1
2
Print the complete transition tree of the given v8 Map.
Usage: jtt tagged_ptr
jst
1
2
Print the current JavaScript stack trace
Usage: jst
jss
1
2
Skip the jitted stack on x64 to where we entered JS last.
Usage: jss
bta
1
2
Print stack trace with assertion scopes
Usage: bta
heap_find
1
2
Find the location of a given address in V8 pages.
Usage: heap_find address
cpcp
1
2
Prints compressed pointer (raw value) after decompression.
Usage: cpcp compressed_pointer
cpm
1
2
Prints member, compressed or not.
Usage: cpm member

js debug commands