rust-decimal
rust-decimal copied to clipboard
Printing decimals in GDB
I am currently debugging a project which uses this crate. Is it possible to print the decimal values in GDB?
Getting output like this is not really helpful:
rust_decimal::decimal::Decimal {flags: 1703936, hi: 369026481, lo: 1235921579, mid: 35
47879452}
I was thinking of looking at the implementation of to_string
, but could not find it.
Hmm, interesting. At the moment, we primarily implement the Display
trait however it wouldn't be too much of a lift to make it print better within GDB.
I may try to look at this one in the coming week.
This appears to be a limitation with the Rust pretty printers at present. Rust Decimal does implement to_string
implicitly via implementing the Display
trait - it also implements the Debug
trait.
There are discussions on the Rust source (e.g. #65564) which look like it may actually solve things going forward (i.e. by providing a trait to implement) however in the meantime it looks like we're limited to the pretty printers implemented at present.