Minimal Stub for remote debugging - PowerPoint PPT Presentation

About This Presentation
Title:

Minimal Stub for remote debugging

Description:

Program resumed execution. Remote Serial Protocol. Request/Reply protocol. ASCII encoding ... Resume the debugged program and wait until it stop on a breakpoint, ... – PowerPoint PPT presentation

Number of Views:206
Avg rating:3.0/5.0
Slides: 16
Provided by: www1CsC
Category:

less

Transcript and Presenter's Notes

Title: Minimal Stub for remote debugging


1
Minimal Stub for remote debugging
  • Minheng Tan
  • Columbia University

2
My project - debugger stub
  • My GDBServer debugger stub.
  • Runs on Red Hat Linux, x86
  • Provides minimum command support(but facilitates
    all debugging requirements)
  • Speaks Remote Serial Protocol (RSP) over tcp/ip
  • Debugs most applications running Linux.

3
Debuggers
  • MSDev
  • Windbg
  • dbx
  • gdb

4
Remote Debugging
Chip
Machine A
Debugger
Program
Stub
5
Remote Debugging continued
Read register 3, Read memory at 0x338828, Write
CC at 0x380280, Continue program.
Machine A
Debugger
6
Remote Debugging continued
Register 3 is 0x75939ff3, Memory content at
0x338828 is 0x094833, Memory content
written, Program resumed execution.
Chip
Program
Stub
7
Remote Serial Protocol
  • Request/Reply protocol
  • ASCII encoding
  • Packet based.
  • Simple to parse, implement, extend.
  • Runs on almost all communication medium

8
RSP commands implemented
  • g read all register
  • G write all register
  • m read memory from a memory at specific
    address
  • M write data to memory at specific address
  • ? Get last signal(what happened to the
    program)

9
RSP commands implementscontinued
  • s step the program. Make the debugged
    program execute 1 instruction and relinquish
    control.
  • c continue the program. Resume the debugged
    program and wait until it stop on a breakpoint,
    bus error, access violation, etc

10
Implement read register
  • buf malloc (regset-gtsize)
  • res ptrace (PTRACE_GETREGS, childpid, 0, buf)

11
Implement write register
  • regset-gtfill_function (buf)
  • res ptrace (PTRACE_SETREGS, childpid, 0, (int)
    buf)

12
Implement read memory
  • i 0
  • while (startAddr lt endAddr)
  • bufferi ptrace(PTRACE_PEEKTEXT,
    childpid, startAddr, 0 )
  • startAddrsizeof(PTRACE_XFER_TYPE)

13
Implement write memory
  • i 0
  • while ( startAddr lt endAddr )
  • ptrace (PTRACE_POKETEXT, childpid, startAddr,
    bufferi)
  • StartAddrsizeof(PTRACE_XFER_TYPE)

14
Implement Step/Continue
  • ptrace (PTRACE_CONT, childpid, 1, 0)
  • ptrace (PTRACE_SINGLESTEP, childpid, 1, 0)

15
Summary
  • Minimum commands implemented
  • Packet based remote serial protocol.
  • Debugger uses the bare minimum stub to implement
    big things.
Write a Comment
User Comments (0)
About PowerShow.com