In The Debugging World: - Kiran Divekar

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 15

In The Debugging World

- Kiran Divekar

   
Agenda

● Hello world
● System calls ( strace )
● gdb internals
● gdb helpers
● Embedded debugging
● Kernel debugging

   
Hello World

● Hello world program


● Compiling
● Linking
● Debugging

   
How debugger works
JTAG
PORT
Host OS Target OS
JTAG SYSCALL
SYSCALL
Daemon

GDB
Gdbserver
Code
Daemon
Code Source

GCC
KGDB
KDB
Stub
How Debugger works

Compiler generates symbol information


Symbol address, data type, source path, function definition etc.
Monitor manages breakpoint setting, memory access and event
deliver.
A system call and a signal notification provided by OS.
A stub running under exception in OS
A daemon poll the hardware circuit port “JTAG”

   
How Debugger works

Debugger tracks the execution of the code


Run as the parent process of the code and talk to the system
call in local OS.
Talk to a local/remote daemon which talks to either a system call
in remote OS or a JTAG device.
Talk to a remote stub which takes over the OS when activated.
Run beneath the OS. Wake up and halt the OS when asked.

   
System call trace
gdb internals

One process reading memory belonging to other process: Is this


a security vulnerability?
Support needs to be provided by OS (Kernel)
System call ptrace ( sys/ptrace.h )
PTRACE_TRACEME, PTRACE_ATTACH
(one byte) INT 3 instruction

   
gdb commands

gdb prog or gdb prog <pid> or gdb prog core


Reading .gdbinit file, set output-radix 16
set args, dir
Save breakpoints and source <file>
Disassemble /m
stepi, nexti, disp/i $pc
Memory debugging x/nfu ( count, format, unit)

   
gdb commands

Info macros
Macro expand
Info signals
Handle singal SIGINT noignore
Thread i, thread apply all where
gdb macros

   
gdb commands

define connect
Target remote 192.168.1.13:4321
b panic
b sys_sync
end

   
Embedded Debugging

Embedded: concept of host and target


Using Serial port or Ethernet
Need to cross-compile gdb, gdbserver for target
Stripped target binaries

   
Embedded Debugging

To configure: -
./configure --host=arm-linux
--build = build machine
--target = compiling a cross compiler

make CC=<cross-compiler>

   
Kernel Debugging

Printk – same as printf


Kdgb- a gdb remote stub running under exception in Linux
kernel. It is used along with gdb to debug linux kernel.
(function) Tracers, Profilers
Linux Trace points
Lockups: spin locks, counters, lock validator
Example....

   
Thank You...

kirandivekar@gmail.com

   

You might also like