Skip to content

Conversation

AngheloAlf
Copy link
Contributor

@AngheloAlf AngheloAlf commented Sep 18, 2025

I tested it locally and works fine.

I'm unsure about a few things.

  • I only added this new demangler to mips and x86, should I add it to any other arch?
  • Should cpp_demangle be removed from mips? I don't know if there's any mips project that uses a new enough g++ compiler that uses the new mangling abi. Or maybe invert cwdemangle and cpp_demangle since it is more likely for cw to be used in mips than a new g++.

@tomsons26
Copy link
Contributor

I've seen old and new mangling formats in gcc built binaries for Windows and Mac so it's definitely not a old mips binary exclusive thing

@AngheloAlf
Copy link
Contributor Author

What arch is used for Mac? I assume Windows uses x86, but dunno what Mac uses. Maybe ppc?

@AngheloAlf AngheloAlf changed the title [MIPS] Use gnuv2_demangle for better demangling of old g++ compiled projects Use gnuv2_demangle for better demangling of old g++ compiled projects Sep 20, 2025
@benny-dreamly
Copy link

What arch is used for Mac? I assume Windows uses x86, but dunno what Mac uses. Maybe ppc?

Yes it is ppc/intel but most likely ppc

@AngheloAlf AngheloAlf changed the title Use gnuv2_demangle for better demangling of old g++ compiled projects Arch-independent demangling and add gnuv2_demangle for old g++ projects Sep 20, 2025
@AngheloAlf
Copy link
Contributor Author

I refactored the demangling code to be architecture-independent.

Now the user can manually select which demangler they prefer to use. objdiff will still try to guess demangling the symbols by default.

image

I also updated the "Tools" -> "Demangle..." pop-up to use the selected demangler instead of leaving it hardcoded to codewarrior.

Copy link
Owner

@encounter encounter left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Big improvement!

@@ -12,11 +13,12 @@ pub fn demangle_window(
show: &mut bool,
state: &mut DemangleViewState,
appearance: &Appearance,
demangler: Demangler,
) {
egui::Window::new("Demangle").open(show).show(ctx, |ui| {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we add the demangler option to this window as well?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As-in, keeping each option independent to each other?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Something like this?

image image

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great!

"name": "MSVC"
},
{
"value": "gnu_modern",
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we just call this itanium?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tbh I don't really know what's the best way to refer to this. I guess plain "itanium" should be fine

if name.starts_with('?') {
msvc_demangler::demangle(name, msvc_demangler::DemangleFlags::llvm()).ok()
} else {
name = name.trim_start_matches('.');
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's keep this . trimming logic

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From what I can see only ppc has this trimming logic.

Do you want to always trim . when the demangler is not msvc? Or should it be only be applied to specific demanglers (cpp_demangle, cwdemangle, etc) ?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can just add it for itanium/gnuv2

if name.starts_with('?') {
msvc_demangler::demangle(name, msvc_demangler::DemangleFlags::llvm()).ok()
} else {
name = name.trim_start_matches('.');
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can just add it for itanium/gnuv2

@@ -157,6 +157,7 @@ rlwinmdec = { version = "1.1", optional = true }

# mips
rabbitizer = { version = "2.0.0-alpha.4", default-features = false, features = ["all_extensions"], optional = true }
gnuv2_demangle ={ version = "0.1.0", optional = true }
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
gnuv2_demangle ={ version = "0.1.0", optional = true }
gnuv2_demangle = { version = "0.1.0", optional = true }

@@ -12,11 +13,12 @@ pub fn demangle_window(
show: &mut bool,
state: &mut DemangleViewState,
appearance: &Appearance,
demangler: Demangler,
) {
egui::Window::new("Demangle").open(show).show(ctx, |ui| {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great!

"name": "Itanium"
},
{
"value": "gnu_v2",
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thoughts on gnu_legacy? And "GNU g++ (Legacy)". I think it would make it more clear that this is the old version. Open to other ideas

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants