rust-decimal icon indicating copy to clipboard operation
rust-decimal copied to clipboard

Printing decimals in GDB

Open philippludwig opened this issue 4 years ago • 2 comments

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.

philippludwig avatar Nov 05 '19 14:11 philippludwig

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.

paupino avatar Nov 23 '19 16:11 paupino

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.

paupino avatar Dec 14 '19 20:12 paupino