binutils-20040312-1-modified/binutils/nm.c --- binutils-20040312-1/binutils/nm.c 2003-11-17 04:09:21.000000000 +0100 +++ binutils-20040312-1-modified/binutils/nm.c 2004-06-20 22:28:29.539843200 +0200 @@ -253,7 +253,7 @@ -C, --demangle[=STYLE] Decode low-level symbol names into user-level names\n\ The STYLE, if specified, can be `auto' (the default),\n\ `gnu', `lucid', `arm', `hp', `edg', `gnu-v3', `java'\n\ - or `gnat'\n\ + `gnat' or 'msvc'\n\ --no-demangle Do not demangle low-level symbol names\n\ -D, --dynamic Display dynamic symbols instead of normal symbols\n\ --defined-only Display only defined symbols\n\ diff -aurw binutils-20040312-1/include/demangle.h binutils-20040312-1-modified/include/demangle.h --- binutils-20040312-1/include/demangle.h 2004-02-05 01:51:42.000000000 +0100 +++ binutils-20040312-1-modified/include/demangle.h 2004-06-20 19:26:11.000000000 +0200 @@ -46,9 +46,10 @@ #define DMGL_EDG (1 << 13) #define DMGL_GNU_V3 (1 << 14) #define DMGL_GNAT (1 << 15) +#define DMGL_MSVC (1 << 16) /* If none of these are set, use 'current_demangling_style' as the default. */ -#define DMGL_STYLE_MASK (DMGL_AUTO|DMGL_GNU|DMGL_LUCID|DMGL_ARM|DMGL_HP|DMGL_EDG|DMGL_GNU_V3|DMGL_JAVA|DMGL_GNAT) +#define DMGL_STYLE_MASK (DMGL_AUTO|DMGL_GNU|DMGL_LUCID|DMGL_ARM|DMGL_HP|DMGL_EDG|DMGL_GNU_V3|DMGL_JAVA|DMGL_GNAT|DMGL_MSVC) /* Enumeration of possible demangling styles. @@ -70,7 +71,8 @@ edg_demangling = DMGL_EDG, gnu_v3_demangling = DMGL_GNU_V3, java_demangling = DMGL_JAVA, - gnat_demangling = DMGL_GNAT + gnat_demangling = DMGL_GNAT, + msvc_demangling = DMGL_MSVC } current_demangling_style; /* Define string names for the various demangling styles. */ @@ -85,6 +87,7 @@ #define GNU_V3_DEMANGLING_STYLE_STRING "gnu-v3" #define JAVA_DEMANGLING_STYLE_STRING "java" #define GNAT_DEMANGLING_STYLE_STRING "gnat" +#define MSVC_DEMANGLING_STYLE_STRING "msvc" /* Some macros to test what demangling style is active. */ @@ -98,6 +101,7 @@ #define GNU_V3_DEMANGLING (((int) CURRENT_DEMANGLING_STYLE) & DMGL_GNU_V3) #define JAVA_DEMANGLING (((int) CURRENT_DEMANGLING_STYLE) & DMGL_JAVA) #define GNAT_DEMANGLING (((int) CURRENT_DEMANGLING_STYLE) & DMGL_GNAT) +#define MSVC_DEMANGLING (((int) CURRENT_DEMANGLING_STYLE) & DMGL_MSVC) /* Provide information about the available demangle styles. This code is pulled from gdb into libiberty because it is useful to binutils also. */ diff -aurw binutils-20040312-1/libiberty/cplus-dem.c binutils-20040312-1-modified/libiberty/cplus-dem.c --- binutils-20040312-1/libiberty/cplus-dem.c 2004-02-05 01:52:07.000000000 +0100 +++ binutils-20040312-1-modified/libiberty/cplus-dem.c 2004-06-22 19:15:33.410699200 +0200 @@ -56,12 +56,18 @@ char * realloc (); #endif +#if defined(__CYGWIN__) +#include +#include "imagehlp.h" +#endif + #include #undef CURRENT_DEMANGLING_STYLE #define CURRENT_DEMANGLING_STYLE work->options #include "libiberty.h" +static char *msvc_demangle PARAMS ((const char *)); static char *ada_demangle PARAMS ((const char *, int)); #define min(X,Y) (((X) < (Y)) ? (X) : (Y)) @@ -309,6 +315,12 @@ } , { + MSVC_DEMANGLING_STYLE_STRING, + msvc_demangling, + "MSVC style demangling" + } + , + { NULL, unknown_demangling, NULL } }; @@ -933,6 +945,9 @@ if (GNAT_DEMANGLING) return ada_demangle(mangled,options); + if (MSVC_DEMANGLING) + return msvc_demangle(mangled); + ret = internal_cplus_demangle (work, mangled); squangle_mop_up (work); return (ret); @@ -1070,6 +1085,32 @@ return demangled; } +static char* +msvc_demangle (mangled) + const char *mangled; +{ + char *demangled; + int l; + char* prefix = "_imp_"; + const char* p; + char* q; + + l = 1000; + demangled = malloc(l); + p = mangled; + q = demangled; + if(!strncmp(mangled, prefix, strlen(prefix))) + { + sprintf(demangled, "%s ",prefix); + p = mangled + strlen(prefix); + q = demangled + strlen(demangled); + l -= strlen(demangled); + } + + UnDecorateSymbolName(p, q, l, UNDNAME_COMPLETE); + return demangled; +} + /* This function performs most of what cplus_demangle use to do, but to be able to demangle a name with a B, K or n code, we need to have a longer term memory of what types have been seen. The original