I've been debugging my application which uses some crates. I can't get if it's possible to print a variable from a third party crate. I try to do this with command print extern libc::SIGUSR2 according that document. Unfortunately I get No symbol '::libc::SIGUSR2' in current context. Well does somebody know how to fix it?
No, I mean pub use libc; only, as extern crate is not needed.
Of course, you have to have libc added as a dependency first. If you've created your project before 2019, then you also need to add edition = "2018" to Cargo.toml.
I missed that change in Cargo.toml. Now I see it. Thank you so much! Very well, I decided to make an example which is easy to use for reproducing the issue.
Ok, looks like GDB doesn't show a constant (const statement). It shows variables and static variables but not constants. It's reasonable because they are not DIE (DWARF Information Entries). Does somebody know how to show a constant?
I don’t think constants show up in the binary at all as they are substituted directly where used during compilation. You should be able to assign the constant to a static variable in your code and print that.