-
-
Notifications
You must be signed in to change notification settings - Fork 0
Labels
area:analyzerBinary analyzer functionalityBinary analyzer functionalitylang:rustRust implementationRust implementationneeds:testsNeeds test coverageNeeds test coveragestatus:backlogTask in backlogTask in backlogstory-points: 22 story points2 story pointstype:enhancementNew feature or requestNew feature or request
Milestone
Description
Summary
Implement Rust symbol demangling functionality to decode mangled Rust symbols into human-readable format. This enhancement will improve the analyzer's ability to process and display Rust binary symbols.
Background
Rust uses name mangling to encode additional information (such as type parameters, namespaces, and trait implementations) into symbol names. Mangled Rust symbols are difficult to read and understand without proper demangling. For example:
- Mangled:
_ZN3std2io5stdio6_print17h0123456789abcdefE - Demangled:
std::io::stdio::_print
Supporting Rust symbol demangling will enable StringyMcStringFace to:
- Display readable function and method names from Rust binaries
- Improve string classification accuracy for Rust-compiled artifacts
- Provide better analysis output for users working with Rust code
Proposed Solution
Implementation Steps
-
Add Dependencies
- Add
rustc-demanglecrate toCargo.toml - Version: Use latest stable (^0.1)
- Add
-
Create Symbol Processing Module
- Create new file:
src/classification/symbols.rs - Implement
demangle_rust_symbol()function - Handle both legacy and v0 Rust mangling schemes
- Return original string if demangling fails (graceful fallback)
- Create new file:
-
Integration Points
- Integrate symbol demangling into the string classification pipeline
- Apply demangling during binary analysis phase
- Ensure demangling is optional/configurable
-
Error Handling
- Handle invalid symbol formats gracefully
- Log demangling failures for debugging
- Maintain performance with large symbol tables
Code Structure
// src/classification/symbols.rs
use rustc_demangle::demangle;
pub fn demangle_rust_symbol(mangled: &str) -> String {
// Attempt to demangle, fallback to original on failure
demangle(mangled).to_string()
}
pub fn is_rust_symbol(symbol: &str) -> bool {
// Check if symbol matches Rust mangling pattern
symbol.starts_with("_ZN") || symbol.starts_with("_R")
}Testing Strategy
Implement comprehensive unit tests covering:
-
Valid Rust Symbols
- Standard function names
- Methods with type parameters
- Trait implementations
- Nested modules
-
Edge Cases
- Empty strings
- Non-Rust mangled symbols (C++, D, etc.)
- Partially mangled strings
- Very long symbol names
-
Performance Tests
- Benchmark demangling with large symbol tables
- Ensure acceptable performance overhead
Example Test Cases
#[test]
fn test_demangle_rust_symbol() {
assert_eq\!(
demangle_rust_symbol("_ZN3std2io5stdio6_print17h0123456789abcdefE"),
"std::io::stdio::_print"
);
}
#[test]
fn test_invalid_symbol_returns_original() {
let invalid = "not_a_mangled_symbol";
assert_eq\!(demangle_rust_symbol(invalid), invalid);
}Acceptance Criteria
-
rustc-demangledependency added to Cargo.toml -
src/classification/symbols.rsmodule created with demangling functionality - Unit tests achieve >90% code coverage
- All tests pass successfully
- Documentation added for public APIs
- Performance impact measured and acceptable (<5% overhead)
Requirements
Requirement ID: 4.1
Task ID
stringy-analyzer/symbol-processing
Related Work
- Consider future support for other languages (C++, D, Swift)
- Potential integration with existing classification rules
- May need configuration option to enable/disable demangling
Reactions are currently unavailable
Sub-issues
Metadata
Metadata
Assignees
Labels
area:analyzerBinary analyzer functionalityBinary analyzer functionalitylang:rustRust implementationRust implementationneeds:testsNeeds test coverageNeeds test coveragestatus:backlogTask in backlogTask in backlogstory-points: 22 story points2 story pointstype:enhancementNew feature or requestNew feature or request