diff options
| -rw-r--r-- | md/writeup/using_gdb.md | 65 | 
1 files changed, 58 insertions, 7 deletions
diff --git a/md/writeup/using_gdb.md b/md/writeup/using_gdb.md index ab27272..75e0bf3 100644 --- a/md/writeup/using_gdb.md +++ b/md/writeup/using_gdb.md @@ -1,5 +1,6 @@  title: Using GDB  keywords:gdb,debug,linux +  # Using GDB  GDB is gnu debugger that excists for years and it work on any linux/bsd @@ -20,24 +21,53 @@ more stuff will added  gdb [PROGRAM]  ``` + +Run program +  ```  (gdb) run [CMD LINE PARAMS TO PROGRAM]  ``` +Load ELD fileas with stuff and symbols + +```bash +load file.elf +file file.elf +``` + +### +  ## Setting breakpoints -Setting breakpoint on speific address +### Speific address  ```bash  (gdb) break *0x800000  ``` -on specific function +### Function  ```bash  (gdb) break _start  ``` +### Source line + +```bash +(gdb) break src/main.c:12 +``` + +###List breakpoints + +```bash +(gdb) info b +``` + +##Delete breakpoints +```bash +(gdb) clear src/main.c:12 +``` +  Here is more breakpoint types [Link1](http://ftp.gnu.org/old-gnu/Manuals/gdb/html_node/gdb_28.html) and [Link2](http://www.unknownroad.com/rtfm/gdbtut/gdbbreak.html)   ## Print registers @@ -62,29 +92,50 @@ print value in hex  ## Print memory -print one byte in specific adress +### Byte +print one byte from specific adress  ```bash  (gdb) x/u *0x808080  ``` -print array of 16 bytes in hex +### Array + +print 16 bytes in hex  ```bash -gdb) x/16xu *0xffffd310 +(gdb) x/16xu *0xffffd310  ``` +print from pointer value array -from register value +```bash +(gdb) print/x *array_var@123 +``` + +### Register value  ```bash  (gdb) x/4xb $ebp-0xc  ``` -## Print current position instruction +### Print current position instruction  ```bash  (gdb) x/i $pc  ``` +### Structure + +turn on more nicer structure otutput + +```bash +set print pretty on +``` + +```bash +(gdb) ptype SPI_HandleTypeDef +``` + +  ## Step  ```bash  | 
