Skip to main content

Crate serde_gdbmi

Crate serde_gdbmi 

Source
Expand description

§Serde deserializer for the GDB Machine Interface (GDB/MI)

This crate implements a serde deserializer for GDB Machine Interface (GDB/MI) output. It allows you to easily parse GDB/MI output into Rust data structures using Serde’s powerful serialization framework.

This library does not specify the message types themselves, but rather just the deserialization logic. You can define your own Rust structs that match the structure of the GDB/MI output you expect to receive, and then use this crate to deserialize the GDB/MI output into those structs.

§Example

use serde::Deserialize;
use serde_gdbmi::{from_str, Response, ResponseBody};

#[derive(Debug, Deserialize)]
#[serde(rename_all = "kebab-case")]
struct GdbMiFrame {
    addr: String,
    func: String,
    arch: String,
}

#[derive(Debug, Deserialize)]
#[serde(rename_all = "kebab-case")]
enum GdbMiOutput {
    // variant names become class names from the GDB/MI output
    ThreadGroupAdded {
        id: String,
    },
    Stopped {
        reason: String,
        signal_name: Option<String>,
        signal_meaning: Option<String>,
        frame: Option<GdbMiFrame>,
        thread_id: Option<String>,
        stopped_threads: String
    }
}

let gdb_mi_output = r#"^thread-group-added,id="i1""#;
let response: Response<GdbMiOutput> = from_str(gdb_mi_output).unwrap();
println!("{:#?}", response);
/*
    Response {
        token: None,
        body: ResponseBody::Result(
            GdbMiOutput::ThreadGroupAdded {
                id: "i1",
            },
        ),
    }
*/

§License

Copyright © 2026 Josh Junon. Part of the Oro Operating System project. Released under the MIT license.

Modules§

de
lexer
Lexer implementation for MI messages.
parser

Macros§

Token
Resolves a literal punctuation token to its token type.

Structs§

Response
A full response body from the parser.

Enums§

Error
The error type returned by the various parts of the serde_gdbmi library.
ResponseBody
A response body, with the user-specific deserialized response type.
SimpleResponseBody
If the ResponseBody enum is too granular, you can ResponseBody::simple()-ify it, which results in either a SimpleResponseBody::Stream or SimpleResponseBody::Data variant.
SimpleResponseBodyRef
If the ResponseBody enum is too granular, you can ResponseBody::simple()-ify it, which results in either a SimpleResponseBody::Stream or SimpleResponseBody::Data variant.

Functions§

from_str
Returns a Response given a line string and a user-defined parsable MI type.