2

With idapython I would like to get demangled names with the name simplification (bottom of page) applied to them.

For example, the following function:

Python> ida_name.demangle_name(idc.get_func_name(0x123456), 0)

std::vector<std::__cxx11::basic_string<char,std::char_traits<char>,std::allocator<char>>,std::allocator<std::__cxx11::basic_string<char,std::char_traits<char>,std::allocator<char>>>>::vector(void)'

As you can see, the function name is very long with all the templates. IDA applies some rules from goodname.cfg to simplify this name. In its GUI the following is displayed:

std::vector<std::string>::vector(void)

Much better. Is there any way to achieve the same result in idapython? Other than copying and applying all the rules from goodname.cfg inside my script...

1
  • I don't think you can do much better than re-implementing IDA's filtering. Mangled symbol names as output by compilers always contain full specifications of the symbols, which ignore any typedef or using declarations that make them nice and compact in source code.
    – ynwarcs
    Commented Jul 16, 2023 at 15:37

1 Answer 1

5

idaapi.get_ea_name(ea, idaapi.GN_SHORT|idaapi.GN_DEMANGLED) seems to return the filtered demangled name.

1
  • Oh shit, you are a life saver. Thank you! edit: idaapi.get_long_name(ea) seems to work as well. guess I should have tried all the functions in the idaapi module. lesson learned, thanks
    – Blub
    Commented Jul 18, 2023 at 11:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.