1 / 15

Minimal Stub for remote debugging

Minimal Stub for remote debugging. Minheng Tan Columbia University. 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

Download Presentation

Minimal Stub for remote debugging

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  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 implements…continued • “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->size); • res = ptrace (PTRACE_GETREGS, childpid, 0, buf);

  11. Implement write register • regset->fill_function (buf); • res = ptrace (PTRACE_SETREGS, childpid, 0, (int) buf);

  12. Implement read memory • i = 0; • while (startAddr <= endAddr) { • buffer[i++] = ptrace(PTRACE_PEEKTEXT, childpid, startAddr, 0 ); • startAddr+=sizeof(PTRACE_XFER_TYPE); • }

  13. Implement write memory • i = 0; • while ( startAddr <= endAddr ) { • ptrace (PTRACE_POKETEXT, childpid, startAddr, buffer[i++]); • StartAddr+=sizeof(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.

More Related