name-mangling

Can I ungarble GCC's RTTI names?

痞子三分冷 提交于 2019-12-01 04:42:18
Using gcc, when I ask for an object/variable's type using typeid, I get a different result from the type_info::name method from what I'd expect to get on Windows. I Googled around a bit, and found out that RTTI names are implementation-specific. Problem is, I want to get a type's name as it would be returned on Windows. Is there an easy way to do this? Gregory Pakosz If it's what you're asking, there is no compiler switch that would make gcc behave like msvc regarding the name returned by type_info::name() . However, in your code you can rely on the gcc specific __cxa_demangle function. There

Python “private” name mangling and instance vs class attributes

最后都变了- 提交于 2019-12-01 04:24:01
I was writing a decorator that needs to access private variables and found this discrepancy. Can anyone explain this? (Python 2.5) Naming mangling works as expected for attributes defined in the class: >>> class Tester(object): ... __foo = "hi" >>> t = Tester() >>> t._Tester__foo 'hi' Instance attributes do not work (and this is the way we are supposed to do it right?) >>> class Tester(object): ... def __init__(self): ... self.__foo = "hi" >>> t = Tester() >>> t._Tester__foo AttributeError: 'Tester' object has no attribute '_Tester__foo' P.S. Is "class attribute" the right word for these? They

g++: How to unmangle exported symbols

浪尽此生 提交于 2019-12-01 03:41:03
问题 I'm trying to compile a Java library that uses JNI. When I start the program, I see a crash with an UnsatisfiedLinkError, which says that a particular method could not be found in the DLL. On closer inspection, I found out that g++, which I use for compilation and linking, mangled my method names by adding suffixes such as "@8" or "@16" to the method names. Does anybody know the correct compiler options to disable the name mangling? Thanks in advance! EDIT : I'm using MinGW through Eclipse +

Python name mangling function

笑着哭i 提交于 2019-12-01 03:22:55
Is there a function in the Python standard library to reproduce Python's name mangling scheme with a "private" attribute name? It seems like there would be, but I can't find it for the life of me. I wrote this, but if there's a better way I'm all ears. def mangle_name (cls, attrname) : prefix = '_' + cls.__name__.lstrip('_') if not attrname.startswith('__') : attrname = '__' + attrname if not attrname.endswith('__') : return prefix + attrname else : return attrname class Foo : __some_such = 3 name = mangle_name(Foo, '__some_such') print name print hasattr(Foo(), name) It looks like the

Python “private” name mangling and instance vs class attributes

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-01 02:05:12
问题 I was writing a decorator that needs to access private variables and found this discrepancy. Can anyone explain this? (Python 2.5) Naming mangling works as expected for attributes defined in the class: >>> class Tester(object): ... __foo = "hi" >>> t = Tester() >>> t._Tester__foo 'hi' Instance attributes do not work (and this is the way we are supposed to do it right?) >>> class Tester(object): ... def __init__(self): ... self.__foo = "hi" >>> t = Tester() >>> t._Tester__foo AttributeError:

undecorate function names with visual studio sdk

不想你离开。 提交于 2019-12-01 00:15:34
To undecorate mangled C++ names that Visual Studio generates, you can use undname.exe . But what if you want to avoid the overhead of creating a full-blown process every time you need undecoration? Is there any equivalent functionality in the Visual Studio SDK (should be supported in VS2005)? You're looking for UnDecorateSymbolName function provided by dbghelp. 来源: https://stackoverflow.com/questions/1617204/undecorate-function-names-with-visual-studio-sdk

Python name mangling function

夙愿已清 提交于 2019-11-30 23:50:40
问题 Is there a function in the Python standard library to reproduce Python's name mangling scheme with a "private" attribute name? It seems like there would be, but I can't find it for the life of me. I wrote this, but if there's a better way I'm all ears. def mangle_name (cls, attrname) : prefix = '_' + cls.__name__.lstrip('_') if not attrname.startswith('__') : attrname = '__' + attrname if not attrname.endswith('__') : return prefix + attrname else : return attrname class Foo : __some_such = 3

View Compiler Mangled Names in C++

穿精又带淫゛_ 提交于 2019-11-30 20:00:55
How do I view the compiler-generated mangled names for overloaded functions in C++? I'm using VC9 but answers for other compilers are welcome too. Edit: I find all the answers useful here. Accepting the one I liked best. You could look in the map file. Assuming you have map file generation turned on. You can see the decorated function names by using Dependency Walker . Open any DLL\EXE in dependency walker and in right pane you can see a list of decorated function names. Since you also ask about other compilers. There is a tool called nm on the gnu toolchain. You will get it on linux and

undecorate function names with visual studio sdk

六眼飞鱼酱① 提交于 2019-11-30 18:59:23
问题 To undecorate mangled C++ names that Visual Studio generates, you can use undname.exe . But what if you want to avoid the overhead of creating a full-blown process every time you need undecoration? Is there any equivalent functionality in the Visual Studio SDK (should be supported in VS2005)? 回答1: You're looking for UnDecorateSymbolName function provided by dbghelp. 来源: https://stackoverflow.com/questions/1617204/undecorate-function-names-with-visual-studio-sdk

C++ name mangling by hand

 ̄綄美尐妖づ 提交于 2019-11-30 14:56:52
问题 I am writing a script for the IDA Pro disassembler in Python using the idapython plugin. Using this, I am able to fill in the gaps where IDA's auto-analysis falls short. One area that has me stumped is naming locations/functions with (for want of a better term) "pretty names". An example of what I mean is illustrated below: idapython and IDA Pro itself only allow me to enter basic C-ish function names. If I enter disallowed symbols (e.g. the scope resolution operator), they're replaced with