--- ./bfd/bfd.c_orig	2018-04-09 01:24:17 -0500
+++ ./bfd/bfd.c	2018-04-09 01:26:35 -0500
@@ -378,12 +378,15 @@
 #include "libecoff.h"
 #undef obj_symbols
 #include "elf-bfd.h"
-#include <aix-demangle.h>
 
 #ifndef EXIT_FAILURE
 #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;
 
 
@@ -1931,7 +1934,7 @@
       res = cplus_demangle (name, options);
     }
     else if( is_xlcpp_class) {
-      nm = demangle(name, &rest, RegularNames | ClassNames|SpecialNames|ParameterText|QualifierText); 
+	  nm = demangle(name, &rest, 0x1f); 
       res = text(nm);
     }
 
--- ./gdb/xcoffread.c_orig	2018-04-09 01:27:00 -0500
+++ ./gdb/xcoffread.c	2018-04-09 03:33:34 -0500
@@ -2338,6 +2338,11 @@
 
 			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
 			      (last_csect_name, last_csect_val,
@@ -2404,6 +2409,11 @@
 		  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
@@ -2441,11 +2451,15 @@
 		  case XMC_PR:
 		    /* A function entry point.  */
 
-		    if (first_fun_line_offset == 0 && symbol.n_numaux > 1)
-		      first_fun_line_offset =
+		    first_fun_line_offset =
 			main_aux[0].x_sym.x_fcnary.x_fcn.x_lnnoptr;
 			{
-			is_xlcpp_class = 1;
+		    if ((*namestring == '.') &&
+                           (strncmp (namestring, "._Z", 3)))
+                           is_xlcpp_class = 1;
+                        else if ((*namestring != '.') &&
+                           (strncmp (namestring, "_Z", 2)))
+                           is_xlcpp_class = 1;	
  			record_minimal_symbol
  			  (namestring, symbol.n_value,
  			   sclass == C_HIDEXT ? mst_file_text : mst_text,
@@ -2463,6 +2477,11 @@
 		       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
 		      (namestring, symbol.n_value,
@@ -2486,6 +2505,11 @@
 		       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
@@ -2504,6 +2528,11 @@
 		  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
@@ -2535,7 +2564,12 @@
 		/* If no misc. function recorded in the last seen csect, enter
 		   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 (last_csect_name, last_csect_val,
 				       mst_text, last_csect_sec, objfile);
@@ -2744,8 +2778,13 @@
 		if (gdbarch_static_transform_name_p (gdbarch))
 		  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,
@@ -2759,7 +2798,12 @@
 					    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,
@@ -2779,7 +2823,12 @@
 		    || (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,
@@ -2787,7 +2836,12 @@
 			is_xlcpp_class = 0;
 		    if (p[2] == 't')
 		      {
+				if ((*namestring == '.') &&
+                           (strncmp (namestring, "._Z", 3)))
 				is_xlcpp_class = 1;
+				else if ((*namestring != '.') &&
+                           (strncmp (namestring, "_Z", 2)))
+                           is_xlcpp_class = 1;
 			/* Also a typedef with the same name.  */
 			add_psymbol_to_list (namestring, p - namestring, 1,
 					     VAR_DOMAIN, LOC_TYPEDEF,
@@ -2864,7 +2918,12 @@
 			  ;
 			/* 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,
@@ -2884,7 +2943,12 @@
 
 	      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,
@@ -2905,7 +2969,12 @@
 		  }
 		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,
@@ -2938,7 +3007,12 @@
 
 		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,
--- ./gdb/stabsread.c_orig	2018-04-09 04:14:24 -0500
+++ ./gdb/stabsread.c	2018-04-09 04:15:20 -0500
@@ -4098,6 +4098,8 @@
   
   if (!is_xlC_class)
      return 0;
+  if ((TYPE_CODE (type) != TYPE_CODE_STRUCT) || (TYPE_CODE (type) != TYPE_CODE_UNION))
+      return 0;
   while (*pp != '\0' && (*pp != ':' && *pp != '('))
          (pp)++; 
   if (*pp == '(') {
--- ./gdb/psymtab.c_orig	2018-04-10 04:55:22 -0500
+++ ./gdb/psymtab.c	2018-04-10 04:56:17 -0500
@@ -391,9 +391,9 @@
 	/* Might want to error() here (in case symtab is corrupt and
 	   will cause a core dump), but maybe we can successfully
 	   continue, so let's not.  */
-	warning (_("\
+/*	warning (_("\
 (Internal error: pc %s in read in psymtab, but not in symtab.)\n"),
-		 paddress (get_objfile_arch (objfile), pc));
+		 paddress (get_objfile_arch (objfile), pc));*/
       psymtab_to_symtab (objfile, ps);
       return ps->compunit_symtab;
     }
