RudjiGames / MTuner

MTuner is a C/C++ memory profiler and memory leak finder for Windows, PlayStation 4 and 3, Android and other platforms
BSD 2-Clause "Simplified" License
2.63k stars 145 forks source link

[Feature request] Rust symbol demangling #105

Closed laundmo closed 9 months ago

laundmo commented 9 months ago

This is one of the few tools which works well for looking at them memory allocations of Rust programs on windows.

Would be be possible to build in symbol demangling for Rust (only necessary for release-optimised builds)? There is a C99 lib to demangle Rust symbols here: https://github.com/LykenSol/rust-demangle.c

Thank you for making this!

milostosic commented 9 months ago

Hey, I did a quick & dirty integration of rust-demangle.c to rdebug, but would need some test cases - if you're can provide me with some simple rust programs for testing I could likely add that quickly.

laundmo commented 9 months ago

Hey, I did a quick & dirty integration of rust-demangle.c to rdebug, but would need some test cases - if you're can provide me with some simple rust programs for testing I could likely add that quickly.

rust-demangling.zip

Here you go: This binary does nothing but constantly reallocate 8 bytes in a uncapped loop without command-line arguments, and if you pass the leak argument it leaks those 8 bytes (never frees them)

there is basically no functions here, but it should work to test demangling (it shows them mangled in my mtuner install)

Code ```rs use std::{env, hint::black_box}; fn main() { let args: Vec<_> = env::args().collect(); if args.len() > 1 && args[1].contains("leak") { loop { let big: Vec = vec![0; 8]; Box::new(black_box(big)).leak(); } } else { loop { let big: Vec = vec![0; 8]; let _ = black_box(big); } } } ```
milostosic commented 9 months ago

Thanks! Just published MTuner v4.7 which includes Rust demangler. Seems to work with your example.