--- ./gdb/f-valprint.c_orig	2018-01-11 01:25:09 -0600
+++ ./gdb/f-valprint.c	2018-01-11 01:21:57 -0600
@@ -317,7 +317,7 @@
 
 	  if (options->symbol_print)
 	    want_space = print_address_demangle (options, gdbarch, addr,
-						 stream, demangle);
+						 stream, gdb1_demangle);
 	  else if (options->addressprint && options->format != 's')
 	    {
 	      fputs_filtered (paddress (gdbarch, addr), stream);
--- ./gdb/gdb-demangle.h_orig	2018-01-11 01:25:27 -0600
+++ ./gdb/gdb-demangle.h	2018-01-11 01:21:57 -0600
@@ -21,7 +21,7 @@
 
 /* Nonzero means that encoded C++/ObjC names should be printed out in their
    C++/ObjC form rather than raw.  */
-extern int demangle;
+extern int gdb1_demangle;
 
 /* Nonzero means that encoded C++/ObjC names should be printed out in their
    C++/ObjC form even in assembler language displays.  If this is set, but
--- ./gdb/gnu-v3-abi.c_orig	2018-01-11 01:25:43 -0600
+++ ./gdb/gnu-v3-abi.c	2018-01-11 01:21:57 -0600
@@ -641,7 +641,7 @@
       struct value_print_options opts;
 
       get_user_print_options (&opts);
-      print_address_demangle (&opts, gdbarch, ptr_value, stream, demangle);
+      print_address_demangle (&opts, gdbarch, ptr_value, stream, gdb1_demangle);
     }
 
   if (adjustment)
--- ./gdb/p-valprint.c_orig	2018-01-11 01:26:16 -0600
+++ ./gdb/p-valprint.c	2018-01-11 01:21:57 -0600
@@ -156,7 +156,7 @@
 	  /* Extract the address, assume that it is unsigned.  */
 	  addr = extract_unsigned_integer (valaddr + embedded_offset,
 					   TYPE_LENGTH (type), byte_order);
-	  print_address_demangle (options, gdbarch, addr, stream, demangle);
+	  print_address_demangle (options, gdbarch, addr, stream, gdb1_demangle);
 	  break;
 	}
       check_typedef (TYPE_TARGET_TYPE (type));
@@ -168,7 +168,7 @@
       if (TYPE_CODE (elttype) == TYPE_CODE_FUNC)
 	{
 	  /* Try to print what function it points to.  */
-	  print_address_demangle (options, gdbarch, addr, stream, demangle);
+	  print_address_demangle (options, gdbarch, addr, stream, gdb1_demangle);
 	  return;
 	}
 
@@ -312,7 +312,7 @@
 				       TYPE_LENGTH (TYPE_FIELD_TYPE (type,
 								     VTBL_FNADDR_OFFSET)),
 				       byte_order),
-	     stream, demangle);
+	     stream, gdb1_demangle);
 	}
       else
 	{
--- ./gdb/utils.c_orig	2018-01-11 01:28:03 -0600
+++ ./gdb/utils.c	2018-01-11 01:21:57 -0600
@@ -2472,7 +2472,7 @@
   if (name != NULL)
     {
       /* If user wants to see raw output, no problem.  */
-      if (!demangle)
+      if (!gdb1_demangle)
 	{
 	  fputs_filtered (name, stream);
 	}
--- ./gdb/demangle.c_orig	2018-01-11 01:28:22 -0600
+++ ./gdb/demangle.c	2018-01-11 01:21:57 -0600
@@ -46,7 +46,7 @@
 static void demangle_command (char *, int);
 
 /* See documentation in gdb-demangle.h.  */
-int demangle = 1;
+int gdb1_demangle = 1;
 
 static void
 show_demangle (struct ui_file *file, int from_tty,
@@ -253,7 +253,7 @@
 	current_demangling_style_string = demangling_style_names[i];
     }
 
-  add_setshow_boolean_cmd ("demangle", class_support, &demangle, _("\
+  add_setshow_boolean_cmd ("demangle", class_support, &gdb1_demangle, _("\
 Set demangling of encoded C++/ObjC names when displaying symbols."), _("\
 Show demangling of encoded C++/ObjC names when displaying symbols."), NULL,
 			   NULL,
--- ./bfd/bfd.c_orig	2018-01-11 01:28:37 -0600
+++ ./bfd/bfd.c	2018-01-11 01:30:14 -0600
@@ -342,6 +342,11 @@
 #define EXIT_FAILURE 1
 #endif
 
+typedef struct Name *Name;
+Name *demangle(/* char *name, char **rest, unsigned long options */);
+char *text(/* Name * */);
+is_xlcpp_class = 0;
+
 
 /* provide storage for subsystem, stack and heap data which may have been
    passed in on the command line.  Ld puts this data into a bfd_link_info
@@ -1851,6 +1856,8 @@
   const char *pre, *suf;
   size_t pre_len;
   bfd_boolean skip_lead;
+  char *rest;
+  Name *nm;
 
   skip_lead = (abfd != NULL
 	       && *name != '\0'
@@ -1880,7 +1887,14 @@
       name = alloc;
     }
 
-  res = cplus_demangle (name, options);
+    if (!is_xlcpp_class) {
+      res = cplus_demangle (name, options);
+    }
+    else if( is_xlcpp_class) {
+      nm = demangle(name, &rest, 0x1f); 
+      res = text(nm);
+    }
+
 
   if (alloc != NULL)
     free (alloc);
--- ./bfd/bfd-in2.h_orig	2018-01-12 03:30:17 -0600
+++ ./bfd/bfd-in2.h	2018-01-12 03:06:35 -0600
@@ -203,6 +203,8 @@
 
 typedef unsigned int flagword;	/* 32 bits of flags */
 typedef unsigned char bfd_byte;
+
+extern int is_xlcpp_class;
 
 /* File formats.  */
 
--- ./gdb/breakpoint.c_orig	2018-08-26 13:54:34 +0000
+++ ./gdb/breakpoint.c	2018-08-26 13:54:51 +0000
@@ -5924,7 +5924,7 @@
       string_file stb;
 
       print_address_symbolic (loc->gdbarch, loc->address, &stb,
-			      demangle, "");
+			      gdb1_demangle, "");
       uiout->field_stream ("at", stb);
     }
   else
--- ./gdb/c-valprint.c_orig	2018-08-26 13:55:34 +0000
+++ ./gdb/c-valprint.c	2018-08-26 13:55:58 +0000
@@ -155,7 +155,7 @@
 
   if (options->symbol_print)
     want_space = print_address_demangle (options, gdbarch, address, stream,
-					 demangle);
+					 gdb1_demangle);
   else if (options->addressprint)
     {
       fputs_filtered (paddress (gdbarch, address), stream);
--- ./gdb/tui/tui-stack.c_orig	2018-08-26 14:05:04 +0000
+++ ./gdb/tui/tui-stack.c	2018-08-26 14:05:35 +0000
@@ -216,7 +216,7 @@
   string_file stream;
 
   print_address_symbolic (get_frame_arch (fi), get_frame_pc (fi),
-			  &stream, demangle, "");
+			  &stream, gdb1_demangle, "");
 
   /* Use simple heuristics to isolate the function name.  The symbol
      can be demangled and we can have function parameters.  Remove
--- ./gdb/valprint.c_orig	2018-08-26 14:05:55 +0000
+++ ./gdb/valprint.c	2018-08-26 14:06:29 +0000
@@ -398,7 +398,7 @@
     }
 
   if (options->symbol_print)
-    print_address_demangle (options, gdbarch, address, stream, demangle);
+    print_address_demangle (options, gdbarch, address, stream, gdb1_demangle);
   else if (options->addressprint)
     fputs_filtered (paddress (gdbarch, address), stream);
 }
@@ -719,7 +719,7 @@
       type_print (type, "", stream, -1);
       fprintf_filtered (stream, "} ");
       /* Try to print what function it points to, and its address.  */
-      print_address_demangle (options, gdbarch, address, stream, demangle);
+      print_address_demangle (options, gdbarch, address, stream, gdb1_demangle);
     }
 }
 
@@ -1898,7 +1898,7 @@
       fputs_filtered (paddress (gdbarch, address), stream);
       fputs_filtered (": ", stream);
     }
-  print_address_demangle (options, gdbarch, func_addr, stream, demangle);
+  print_address_demangle (options, gdbarch, func_addr, stream, gdb1_demangle);
 }
 
 
--- ./gdb/symtab.h_orig	2018-08-27 03:40:42 +0000
+++ ./gdb/symtab.h	2018-08-27 03:39:31 +0000
@@ -540,8 +540,8 @@
    e.g., struct symbol or struct minimal_symbol.  */
 
 #define SYMBOL_PRINT_NAME(symbol)					\
-  (demangle ? SYMBOL_NATURAL_NAME (symbol) : SYMBOL_LINKAGE_NAME (symbol))
-extern int demangle;
+  (gdb1_demangle ? SYMBOL_NATURAL_NAME (symbol) : SYMBOL_LINKAGE_NAME (symbol))
+extern int gdb1_demangle;
 
 /* Macro that returns the name to be used when sorting and searching symbols.
    In C++, we search for the demangled form of a name,
@@ -706,7 +706,7 @@
   (symbol_natural_name (&(symbol)->mginfo))
 #define MSYMBOL_LINKAGE_NAME(symbol)	(symbol)->mginfo.name
 #define MSYMBOL_PRINT_NAME(symbol)					\
-  (demangle ? MSYMBOL_NATURAL_NAME (symbol) : MSYMBOL_LINKAGE_NAME (symbol))
+  (gdb1_demangle ? MSYMBOL_NATURAL_NAME (symbol) : MSYMBOL_LINKAGE_NAME (symbol))
 #define MSYMBOL_DEMANGLED_NAME(symbol) \
   (symbol_demangled_name (&(symbol)->mginfo))
 #define MSYMBOL_SET_LANGUAGE(symbol,language,obstack)	\
--- ./gdb/xcoffread.c_orig	2018-08-27 04:37:01 +0000
+++ ./gdb/xcoffread.c	2018-08-27 04:51:26 +0000
@@ -2340,10 +2340,17 @@
 
 			if (!misc_func_recorded)
 			  {
+                            if ((*last_csect_name == '.') &&
+                               (strncmp (last_csect_name, "._Z", 3)))
+                              is_xlcpp_class = 1;                  
+                            else if ((*last_csect_name != '.') &&
+                               (strncmp (last_csect_name, "_Z", 2)))
+                              is_xlcpp_class = 1;
 			    record_minimal_symbol
 			      (reader, last_csect_name, last_csect_val,
 			       mst_text, last_csect_sec, objfile);
 			    misc_func_recorded = 1;
+                            is_xlcpp_class = 0;
 			  }
 
 			if (pst != NULL)
@@ -2404,11 +2411,18 @@
 		  case XMC_TD:
 		    /* Data variables are recorded in the minimal symbol
 		       table, except for section symbols.  */
+                    if ((*namestring == '.') &&
+                       (strncmp (namestring, "._Z", 3)))
+                       is_xlcpp_class = 1;                  
+                    else if ((*namestring != '.') &&
+                      (strncmp (namestring, "_Z", 2)))
+                       is_xlcpp_class = 1;
 		    if (*namestring != '.')
 		      record_minimal_symbol
 			(reader, namestring, symbol.n_value,
 			 sclass == C_HIDEXT ? mst_file_data : mst_data,
 			 symbol.n_scnum, objfile);
+                    is_xlcpp_class = 0;
 		    break;
 
 		  case XMC_TC0:
@@ -2443,11 +2457,18 @@
 		      first_fun_line_offset =
 			main_aux[0].x_sym.x_fcnary.x_fcn.x_lnnoptr;
 
+                        if ((*namestring == '.') &&
+                           (strncmp (namestring, "._Z", 3)))
+                           is_xlcpp_class = 1;                  
+                        else if ((*namestring != '.') &&
+                           (strncmp (namestring, "_Z", 2)))
+                           is_xlcpp_class = 1;
 		    record_minimal_symbol
 		      (reader, namestring, symbol.n_value,
 		       sclass == C_HIDEXT ? mst_file_text : mst_text,
 		       symbol.n_scnum, objfile);
 		    misc_func_recorded = 1;
+                        is_xlcpp_class = 0;
 		    break;
 
 		  case XMC_GL:
@@ -2458,10 +2479,17 @@
 		       mst_solib_trampoline symbol.  When we lookup mst
 		       symbols, we will choose mst_text over
 		       mst_solib_trampoline.  */
+                    if ((*namestring == '.') &&
+                       (strncmp (namestring, "._Z", 3)))
+                       is_xlcpp_class = 1;                  
+                    else if ((*namestring != '.') &&
+                       (strncmp (namestring, "_Z", 2)))
+                       is_xlcpp_class = 1;
 		    record_minimal_symbol
 		      (reader, namestring, symbol.n_value,
 		       mst_solib_trampoline, symbol.n_scnum, objfile);
 		    misc_func_recorded = 1;
+                    is_xlcpp_class = 0;
 		    break;
 
 		  case XMC_DS:
@@ -2479,11 +2507,18 @@
 		       still need to record them.  This will
 		       typically be XMC_RW; I suspect XMC_RO and
 		       XMC_BS might be possible too.  */
+                    if ((*namestring == '.') &&
+                       (strncmp (namestring, "._Z", 3)))
+                       is_xlcpp_class = 1;                  
+                    else if ((*namestring != '.') &&
+                       (strncmp (namestring, "_Z", 2)))
+                       is_xlcpp_class = 1;
 		    if (*namestring != '.')
 		      record_minimal_symbol
 			(reader, namestring, symbol.n_value,
 			 sclass == C_HIDEXT ? mst_file_data : mst_data,
 			 symbol.n_scnum, objfile);
+                    is_xlcpp_class = 0;
 		    break;
 		  }
 		break;
@@ -2495,11 +2530,18 @@
 		  case XMC_BS:
 		    /* Common variables are recorded in the minimal symbol
 		       table, except for section symbols.  */
+                    if ((*namestring == '.') &&
+                       (strncmp (namestring, "._Z", 3)))
+                       is_xlcpp_class = 1;                  
+                    else if ((*namestring != '.') &&
+                       (strncmp (namestring, "_Z", 2)))
+                       is_xlcpp_class = 1;
 		    if (*namestring != '.')
 		      record_minimal_symbol
 			(reader, namestring, symbol.n_value,
 			 sclass == C_HIDEXT ? mst_file_bss : mst_bss,
 			 symbol.n_scnum, objfile);
+                    is_xlcpp_class = 0;
 		    break;
 		  }
 		break;
@@ -2525,9 +2567,16 @@
 		   it as a function.  This will take care of functions like
 		   strcmp() compiled by xlc.  */
 
+                if ((*last_csect_name == '.') &&
+                   (strncmp (last_csect_name, "._Z", 3)))
+                   is_xlcpp_class = 1;                  
+                else if ((*last_csect_name != '.') &&
+                   (strncmp (last_csect_name, "_Z", 2)))
+                   is_xlcpp_class = 1;
 		record_minimal_symbol (reader, last_csect_name, last_csect_val,
 				       mst_text, last_csect_sec, objfile);
 		misc_func_recorded = 1;
+                is_xlcpp_class = 0;
 	      }
 
 	    if (pst)
@@ -2732,11 +2781,18 @@
 		  namestring = gdbarch_static_transform_name
 				 (gdbarch, namestring);
 
+                if ((*namestring == '.') &&
+                   (strncmp (namestring, "._Z", 3)))
+                   is_xlcpp_class = 1;                  
+                else if ((*namestring != '.') &&
+                   (strncmp (namestring, "_Z", 2)))
+                   is_xlcpp_class = 1;
 		add_psymbol_to_list (namestring, p - namestring, 1,
 				     VAR_DOMAIN, LOC_STATIC,
 				     &objfile->static_psymbols,
 				     symbol.n_value,
 				     psymtab_language, objfile);
+                is_xlcpp_class = 0;
 		continue;
 
 	      case 'G':
@@ -2744,11 +2800,18 @@
 					    SECT_OFF_DATA (objfile));
 		/* The addresses in these entries are reported to be
 		   wrong.  See the code that reads 'G's for symtabs.  */
+                if ((*namestring == '.') &&
+                   (strncmp (namestring, "._Z", 3)))
+                   is_xlcpp_class = 1;                  
+                else if ((*namestring != '.') &&
+                   (strncmp (namestring, "_Z", 2)))
+                   is_xlcpp_class = 1;
 		add_psymbol_to_list (namestring, p - namestring, 1,
 				     VAR_DOMAIN, LOC_STATIC,
 				     &objfile->global_psymbols,
 				     symbol.n_value,
 				     psymtab_language, objfile);
+                is_xlcpp_class = 0;
 		continue;
 
 	      case 'T':
@@ -2762,17 +2825,31 @@
 		    || (p == namestring + 1
 			&& namestring[0] != ' '))
 		  {
+                    if ((*namestring == '.') &&
+                       (strncmp (namestring, "._Z", 3)))
+                       is_xlcpp_class = 1;                  
+                    else if ((*namestring != '.') &&
+                       (strncmp (namestring, "_Z", 2)))
+                       is_xlcpp_class = 1;
 		    add_psymbol_to_list (namestring, p - namestring, 1,
 					 STRUCT_DOMAIN, LOC_TYPEDEF,
 					 &objfile->static_psymbols,
 					 0, psymtab_language, objfile);
+                    is_xlcpp_class = 0;
 		    if (p[2] == 't')
 		      {
 			/* Also a typedef with the same name.  */
+                         if ((*namestring == '.') &&
+                            (strncmp (namestring, "._Z", 3)))
+                            is_xlcpp_class = 1;                  
+                         else if ((*namestring != '.') &&
+                            (strncmp (namestring, "_Z", 2)))
+                            is_xlcpp_class = 1;
 			add_psymbol_to_list (namestring, p - namestring, 1,
 					     VAR_DOMAIN, LOC_TYPEDEF,
 					     &objfile->static_psymbols,
 					     0, psymtab_language, objfile);
+                        is_xlcpp_class = 0;
 			p += 1;
 		      }
 		  }
@@ -2843,10 +2920,17 @@
 			  ;
 			/* Note that the value doesn't matter for
 			   enum constants in psymtabs, just in symtabs.  */
+                        if ((*p == '.') &&
+                           (strncmp (p, "._Z", 3)))
+                          is_xlcpp_class = 1;                  
+                        else if ((*p != '.') &&
+                           (strncmp (p, "_Z", 2)))
+                          is_xlcpp_class = 1;
 			add_psymbol_to_list (p, q - p, 1,
 					     VAR_DOMAIN, LOC_CONST,
 					     &objfile->static_psymbols,
 					     0, psymtab_language, objfile);
+                        is_xlcpp_class = 0;
 			/* Point past the name.  */
 			p = q;
 			/* Skip over the value.  */
@@ -2861,10 +2945,17 @@
 
 	      case 'c':
 		/* Constant, e.g. from "const" in Pascal.  */
+                if ((*namestring == '.') &&
+                   (strncmp (namestring, "._Z", 3)))
+                   is_xlcpp_class = 1;                  
+                else if ((*namestring != '.') &&
+                   (strncmp (namestring, "_Z", 2)))
+                   is_xlcpp_class = 1;
 		add_psymbol_to_list (namestring, p - namestring, 1,
 				     VAR_DOMAIN, LOC_CONST,
 				     &objfile->static_psymbols,
 				     0, psymtab_language, objfile);
+                is_xlcpp_class = 0;
 		continue;
 
 	      case 'f':
@@ -2880,11 +2971,18 @@
 		  }
 		symbol.n_value += ANOFFSET (objfile->section_offsets,
 					    SECT_OFF_TEXT (objfile));
+                if ((*namestring == '.') &&
+                   (strncmp (namestring, "._Z", 3)))
+                   is_xlcpp_class = 1;                  
+                else if ((*namestring != '.') &&
+                   (strncmp (namestring, "_Z", 2)))
+                   is_xlcpp_class = 1;
 		add_psymbol_to_list (namestring, p - namestring, 1,
 				     VAR_DOMAIN, LOC_BLOCK,
 				     &objfile->static_psymbols,
 				     symbol.n_value,
 				     psymtab_language, objfile);
+                is_xlcpp_class = 0;
 		continue;
 
 		/* Global functions were ignored here, but now they
@@ -2911,11 +3009,18 @@
 
 		symbol.n_value += ANOFFSET (objfile->section_offsets,
 					    SECT_OFF_TEXT (objfile));
+                if ((*namestring == '.') &&
+                   (strncmp (namestring, "._Z", 3)))
+                   is_xlcpp_class = 1;                  
+                else if ((*namestring != '.') &&
+                   (strncmp (namestring, "_Z", 2)))
+                   is_xlcpp_class = 1;
 		add_psymbol_to_list (namestring, p - namestring, 1,
 				     VAR_DOMAIN, LOC_BLOCK,
 				     &objfile->global_psymbols,
 				     symbol.n_value,
 				     psymtab_language, objfile);
+                 is_xlcpp_class = 0;
 		continue;
 
 		/* Two things show up here (hopefully); static symbols of
--- ./gdb/stabsread.c_orig	2018-09-26 03:00:05 +0000
+++ ./gdb/stabsread.c	2018-09-26 03:01:29 +0000
@@ -2597,8 +2597,15 @@
       (*pp)++;
 	  STABS_CONTINUE (pp, objfile);
       
+      if ((*sublist->fn_field.physname == '.') &&
+         (strncmp (sublist->fn_field.physname, "._Z", 3)))
+         is_xlcpp_class = 1;                  
+      else if ((*sublist->fn_field.physname != '.') &&
+         (strncmp (sublist->fn_field.physname, "_Z", 2)))
+         is_xlcpp_class = 1; 
 	  char *new_method_name =
       stabs_method_name_from_physname (sublist->fn_field.physname);
+       is_xlcpp_class = 0;
 
       if (new_method_name != NULL
          && strcmp (new_method_name,
@@ -3072,8 +3079,15 @@
 		 - in -gstabs instead of -gstabs+
 		 - or for static methods, which are output as a function type
 		   instead of a method type.  */
+              if ((*sublist->fn_field.physname == '.') &&
+                 (strncmp (sublist->fn_field.physname, "._Z", 3)))
+                 is_xlcpp_class = 1;                  
+              else if ((*sublist->fn_field.physname != '.') &&
+                 (strncmp (sublist->fn_field.physname, "_Z", 2)))
+                 is_xlcpp_class = 1; 
 	      char *new_method_name =
 		stabs_method_name_from_physname (sublist->fn_field.physname);
+                is_xlcpp_class = 0;
 
 	      if (new_method_name != NULL
 		  && strcmp (new_method_name,
