#gdb #mi #session #machine #interface #manager #parser

gdb_mi

gdb Machine Interface (MI) parser and session manager

4 releases

Uses old Rust 2015

0.1.3 Nov 7, 2017
0.1.2 Sep 15, 2017
0.1.1 Sep 14, 2017
0.1.0 Sep 14, 2017

#26 in #gdb

MIT license

24KB
625 lines

gdb_mi

A gdb Machine Interface (MI) output parser and session manager.

Example

extern crate gdb_mi;
use gdb_mi::*;

let mut session = SessionBuilder::new().finish().unwrap();
session.send("-file-exec-and-symbols tests/main\n").unwrap();
session.send("-break-insert main\n").unwrap();

// Skip first 3 outputs.
for _ in 0..3 {
    session.receive().unwrap();
}

let output = session.receive().unwrap();
// Output {
//     token: None,
//     record_type: Result,
//     output_type: Result,
//     result_class: Done,
//     value: Some(
//         Tuple(
//             {
//                 "bkpt": Tuple(
//                     {
//                         "thread-groups": List(
//                             [
//                                 Const(
//                                     "i1"
//                                 )
//                             ]
//                         ),
//                         "line": Const(
//                             "4"
//                         ),
//                         "disp": Const(
//                             "keep"
//                         ),
//                         "number": Const(
//                             "1"
//                         ),
//                         "file": Const(
//                             "tests/main.c"
//                         ),
//                         "original-location": Const(
//                             "main"
//                         ),
//                         "enabled": Const(
//                             "y"
//                         ),
//                         "addr": Const(
//                             "0x0000000100000f9d"
//                         ),
//                         "func": Const(
//                             "main"
//                         ),
//                         "fullname": Const(
//                             "$HOME/repo/gdb_mi/tests/main.c"
//                         ),
//                         "times": Const(
//                             "0"
//                         ),
//                         "type": Const(
//                             "breakpoint"
//                         )
//                     }
//                 )
//             }
//         )
//     )
// }

let json = serde_json::to_string(&output).unwrap();
// {"token":null,"record_type":"Result","output_type":"Result","result_class":"Done","value":{"bkpt":{"disp":"keep","file":"tests/main.c","number":"1","line":"4","times":"0","enabled":"y","thread-groups":["i1"],"fullname":"/Users/lijunfen/repo/LLDBNvim/gdb_mi/tests/main.c","func":"main","original-location":"main","type":"breakpoint","addr":"0x0000000100000f9d"}}}

Dependencies

~7–13MB
~176K SLoC