Skip to content

matolks/gdb-debugging-extensions

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 

Repository files navigation

GDB Debugging Extensions

Custom GDB commands for memory editing and inspection, linked list traversal, and allocation tracking

How To Use

gdb ./program
source gdbextension-gdb.gdb
run

Replace ./program with the executable you want to debug

Both files must be in the same directory:

  • gdbextension-gdb.gdb
  • gdbextension-gdb.py

Go To Location

Go to a location (line number, function name, address, or file:line pair) within your program

Command

go2 <LOCATION>

Examples

go2 88
go2 main
go2 program.c:88
go2 *0x555555555439

Set Memory

Write SIZE bytes of VALUE into memory starting at DESTINATION

Command

memset <DESTINATION> <VALUE> <SIZE>

Examples

memset memset_buf 0x41 16
memset memset_buf 65 16
memset &memset_buf[4] 0xff 8

Move Memory

Copy SIZE bytes from SOURCE to DESTINATION

Command

memmove <DESTINATION> <SOURCE> <SIZE>

Examples

memmove dst_buf src_buf 32
memmove &buf[4] &buf[0] 16
memmove buf+8 buf 12

Print Linked List

Print a linked list starting from HEAD. Assumes each node has the structure:

   int val;
   node_t *next;

Command

linked_list_print <HEAD>

Examples

linked_list_print head
linked_list_print list_head
linked_list_print node

Search Memory

Searches a memory range for every occurrence of a byte pattern

Command

memsearch <SEARCH> <SEARCH_SIZE> <PATTERN> <PATTERN_SIZE>

Examples

memsearch search_buf 64 pattern_buf 4
memsearch buf 100 &target 1
memsearch buf 256 pattern 8

Hexdump

Prints memory as hex bytes and printable ASCII characters

Command

hexdump [MEMORY] [LINES] [BYTES_PER_LINE]

Examples

hexdump buf
hexdump buf 10
hexdump buf 10 8
hexdump

Malloc Tracker

Initializes allocation tracking by installing wrapper breakpoints and prints all currently tracked dynamic allocations

Command

malloc_track_init
malloc_track_list

Example

source gdbextension-gdb.gdb
break main
run
malloc_track_init
continue
malloc_track_list

About

Custom GDB commands for memory editing and inspection, linked list traversal, and allocation tracking

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors