Giter Club home page Giter Club logo

riscv_gdbstub's Introduction

A GDBSTUB for RISC-V

Background

The term "gdbstub" refers generically to an artifact that mediates between GDB and a process or hardware CPU.

Typically GDB and gdbstub are in separate processes (possibly even on separate computers) connected via TCP, PTY, RS-232, or other communication medium. They interact using GDB's Remote Serial Protocol (RSP), which is a certain coding of ASCII text. RSP documentation can be found here

gdbstub, in turn, controls the DUT (process or hardware CPU).

A typical command flow is:

  • GDB gets a command (user input at GDB prompt, or from a GDB script)
  • GDB sends an RSP message (ASCII text) to gdbstub
  • gdbstub 'performs' the action on the DUT
  • gdbstub sends back an RSP response message (ASCII text) to GDB
  • GDB consumes the response (e.g., displays something at its console)

For RISC-V, gdbstub controls the DUT via a RISC-V Debug Module. Their interface is "DMI" (Debug Module Interface), a simple memory-like read/write interface. The spec for DMI and the Debug Module can be found here

This code

This code implements the major components of gdbstub for RISC-V. It is structured as a "front end" (gdbstub_fe) and a "back end" (gdbstub_be). The front end handles RSP communication with GDB, parsing ASCII commands from GDB and formatting ASCII responses for GDB. When gdbstub_fe has parsed a command from GDB (such as, "read GPR 13"), it invokes a corresponding function in the gdbstub_be, which performs the corresponding DMI interactions to execute that command; gdbstub_fe then responds to GDB.

To use this gdbstub in your environment, you need to:

  • Provide a main (see example main.c here) that sets up the communication mechanism to talk to GDB (e.g., TCP socket, PTY, RS-232, ...), and passes it in to gdbstub_fe as a standard file descriptor (gdbstub_fe uses standard read and write and poll calls on this).

  • Provide an implementation of dmi_read and dmi_write (in RVDM.c) that talks to the Debug Module in the DUT.


History

This code was written by Rishiyur Nikhil based on an original version of gdbstub at Bluespec, 'gdbstub.cc' written by Todd Snyder and/or Darius Rad circa 2014.

Compared to that version, this version:

  • Completely separates GDB-side communication from HW-side communication, into a front-end and back-end.

  • Abstracts out the choice of communication transport for talking with GDB. Here, it is passed in as an argument, a file descriptor, 'gdb_fd' which could be a PTY, TCP socket or something else.

  • Adds a lot of defensive error-checking on the communications with GDB, in case of flaky transports or bugs.

  • Suports both RV64 and RV32 (original only supported RV64) (this manifests itself in the ASCII formatting of GDB RSP messages for register reads and writes)

  • Fixes a number of bugs in the original.

  • Adds some capabilities such as direct ELF-file load

riscv_gdbstub's People

Contributors

bukinr avatar jrtc27 avatar rsnikhil avatar

Watchers

 avatar

Forkers

gameboo

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.