gprofng: use xmalloc/xrealloc/xcalloc/xstrdup/xstrndup from libiberty

	PR gprofng/32241
	* src/Makefile.am (CSOURCES): Remove dbe_memmgr.c
	* src/Makefile.in: Regenerate.
	* src/dbe_memmgr.c: Remove.
	* src/gprofng.cc (main): Call xmalloc_set_program_name.
	* src/gp-archive.cc (main): Likewise.
	* src/gp-collect-app.cc (main): Likewise.
	* src/gp-display-src.cc (main): Likewise.
	* src/gp-display-text.cc (main): Likewise.
	* src/Application.cc: Use xmalloc, xrealloc, xcalloc, xstrdup,
	xstrndup instead of malloc, realloc, calloc, strdup, strndup.
	* src/BaseMetric.cc: Likewise.
	* src/CallStack.cc: Likewise.
	* src/ClassFile.cc: Likewise.
	* src/Data_window.cc: Likewise.
	* src/Dbe.cc: Likewise.
	* src/DbeJarFile.cc: Likewise.
	* src/DbeSession.cc: Likewise.
	* src/DbeView.cc: Likewise.
	* src/DerivedMetrics.cc: Likewise.
	* src/DwarfLib.cc: Likewise.
	* src/Elf.cc: Likewise.
	* src/Emsg.cc: Likewise.
	* src/Experiment.cc: Likewise.
	* src/Function.cc: Likewise.
	* src/Module.cc: Likewise.
	* src/Print.cc: Likewise.
	* src/QLParser.yy: Likewise.
	* src/SAXParserFactory.cc: Likewise.
	* src/Settings.cc: Likewise.
	* src/SourceFile.cc: Likewise.
	* src/StringBuilder.cc: Likewise.
	* src/StringMap.h: Likewise.
	* src/Table.cc: Likewise.
	* src/checks.cc: Likewise.
	* src/collctrl.cc: Likewise.
	* src/comp_com.c: Likewise.
	* src/count.cc: Likewise.
	* src/envsets.cc: Likewise.
	* src/gp-archive.cc: Likewise.
	* src/gp-display-src.cc: Likewise.
	* src/gp-display-text.cc: Likewise.
	* src/gprofng.cc: Likewise.
	* src/ipc.cc: Likewise.
	* src/ipcio.cc: Likewise.
	* src/vec.h: Likewise.
	* src/util.cc: Likewise.
	(get_prog_name): Remove.
	* src/util.h: Likewise.
	* src/dbe_hwc.h (malloc, realloc, calloc, strdup): Define.
diff --git a/gprofng/src/Application.cc b/gprofng/src/Application.cc
index 98caeba..ee461b3 100644
--- a/gprofng/src/Application.cc
+++ b/gprofng/src/Application.cc
@@ -112,7 +112,7 @@
 	      path = s + 1;
 	    }
     }
-  return strdup (_name);
+  return xstrdup (_name);
 }
 
 // Set the directory where all binaries are found
diff --git a/gprofng/src/BaseMetric.cc b/gprofng/src/BaseMetric.cc
index ae0ee32..b7475e2 100644
--- a/gprofng/src/BaseMetric.cc
+++ b/gprofng/src/BaseMetric.cc
@@ -238,7 +238,7 @@
     default_visbits[ii] = m.default_visbits[ii];
   if (m.cond_spec)
     {
-      cond_spec = strdup (m.cond_spec);
+      cond_spec = xstrdup (m.cond_spec);
       cond = m.cond->copy ();
     }
   else
@@ -248,7 +248,7 @@
     }
   if (m.val_spec)
     {
-      val_spec = strdup (m.val_spec);
+      val_spec = xstrdup (m.val_spec);
       val = m.val->copy ();
     }
   else
@@ -258,7 +258,7 @@
     }
   if (m.expr_spec)
     {
-      expr_spec = strdup (m.expr_spec);
+      expr_spec = xstrdup (m.expr_spec);
       expr = m.expr->copy ();
     }
   else
diff --git a/gprofng/src/CallStack.cc b/gprofng/src/CallStack.cc
index 5bfafb7..15594a2 100644
--- a/gprofng/src/CallStack.cc
+++ b/gprofng/src/CallStack.cc
@@ -89,7 +89,7 @@
   if (old_cnt + 1 >= limit)
     {
       int new_limit = (limit == 0) ? DELTA : limit * 2;
-      CallStackNode **new_data = (CallStackNode **) malloc (new_limit * sizeof (CallStackNode *));
+      CallStackNode **new_data = (CallStackNode **) xmalloc (new_limit * sizeof (CallStackNode *));
       for (int i = 0; i < ind; i++)
 	new_data[i] = old_data[i];
       new_data[ind] = item;
@@ -204,12 +204,12 @@
       nchunks++;
 
       // Reallocate Node chunk array
-      chunks = (CallStackNode **) malloc (nchunks * sizeof (CallStackNode *));
+      chunks = (CallStackNode **) xmalloc (nchunks * sizeof (CallStackNode *));
       for (int i = 0; i < nchunks - 1; i++)
 	chunks[i] = old_chunks[i];
       free (old_chunks);
       // Allocate new chunk for nodes.
-      chunks[nchunks - 1] = (CallStackNode *) malloc (CHUNKSZ * sizeof (CallStackNode));
+      chunks[nchunks - 1] = (CallStackNode *) xmalloc (CHUNKSZ * sizeof (CallStackNode));
     }
   nodes++;
   CallStackNode *node = get_node (nodes - 1);
diff --git a/gprofng/src/ClassFile.cc b/gprofng/src/ClassFile.cc
index 37dd0ff..51bb0c2 100644
--- a/gprofng/src/ClassFile.cc
+++ b/gprofng/src/ClassFile.cc
@@ -957,7 +957,7 @@
       return NULL;
     }
   u2 len = input->readUnsignedShort ();
-  strings[index] = (char *) malloc (len + 1);
+  strings[index] = (char *) xmalloc (len + 1);
   input->copy_bytes (strings[index], len);
   return strings[index];
 }
@@ -1014,7 +1014,7 @@
       return;
     }
   cf_bufsz = stat_buf.st_size;
-  cf_buf = (unsigned char *) malloc (cf_bufsz);
+  cf_buf = (unsigned char *) xmalloc (cf_bufsz);
   if (cf_bufsz != read_from_file (fd, cf_buf, cf_bufsz))
     {
       free (cf_buf);
@@ -1409,7 +1409,7 @@
       class_filename = dbe_strdup (bcpool->getString (classNameInd));
       if (class_filename)
 	{
-	  class_name = strdup (class_filename);
+	  class_name = xstrdup (class_filename);
 	  convertName (class_name);
 	}
 
@@ -1527,7 +1527,7 @@
   if (class_filename)
     {
       if (strcmp (class_filename, get_name ()) != 0)
-	set_name (strdup (class_filename));
+	set_name (xstrdup (class_filename));
       if (source_name)
 	{
 	  char *bname = strrchr (class_filename, '/');
@@ -1535,13 +1535,13 @@
 	    fnm = dbe_sprintf (NTXT ("%.*s/%s"), (int) (bname - class_filename),
 			       class_filename, source_name);
 	  else
-	    fnm = strdup (source_name);
+	    fnm = xstrdup (source_name);
 	}
       else
 	fnm = get_java_file_name (class_filename, false);
     }
   else if (source_name)
-    fnm = strdup (source_name);
+    fnm = xstrdup (source_name);
   if (fnm)
     {
       set_file_name (fnm);
@@ -1631,7 +1631,7 @@
       if (tmp)
 	len = tmp - clname;
     }
-  char *clpath = (char *) malloc (len + 10);
+  char *clpath = (char *) xmalloc (len + 10);
   for (size_t i = 0; i < len; i++)
     clpath[i] = (clname[i] == '.') ? '/' : clname[i];
   snprintf (clpath + len, 10, classSuffix ? NTXT (".class") : NTXT (".java"));
diff --git a/gprofng/src/Data_window.cc b/gprofng/src/Data_window.cc
index da142f0..be08559 100644
--- a/gprofng/src/Data_window.cc
+++ b/gprofng/src/Data_window.cc
@@ -149,7 +149,7 @@
 	    { // Need to realloc 'base'
 	      free (base);
 	      basesize = wsize;
-	      base = (void *) malloc (basesize);
+	      base = (void *) xmalloc (basesize);
 	      Dprintf (DEBUG_DATA_WINDOW,
 		       NTXT ("Data_window:bind:%d realloc basesize=%llx woffset=%lld \n"),
 		       (int) __LINE__, (long long) basesize, (long long) woffset);
@@ -188,7 +188,7 @@
     return NULL;
   if (datap == NULL && !mmap_on_file)
     // Can be remmaped or reallocated. Need to make a copy
-    datap = (void *) malloc (size);
+    datap = (void *) xmalloc (size);
   if (datap)
     {
       memcpy (datap, buf, (size_t) size);
diff --git a/gprofng/src/Dbe.cc b/gprofng/src/Dbe.cc
index 09b7f94..c46313a 100644
--- a/gprofng/src/Dbe.cc
+++ b/gprofng/src/Dbe.cc
@@ -353,7 +353,7 @@
 {
   Vector<char*> *result = new Vector<char*>(2);
   int limit = 1024 * 1024; // Temporary limit: 1 MB
-  char * contents = (char *) malloc (limit);
+  char * contents = (char *) xmalloc (limit);
   StringBuilder sb;
   if (NULL == contents)
     {
@@ -4960,7 +4960,7 @@
 	      //	it needs to be
 	      // first, scan all the lines, to get the maximum line number
 	      bufsz = 1024;
-	      buf = (char *) malloc (bufsz);
+	      buf = (char *) xmalloc (bufsz);
 	      int max_lineno = 0;
 	      int hidx;
 	      Hist_data::HistItem *hitem;
@@ -5047,7 +5047,7 @@
 			      // Reallocate the buffer
 			      size_t curlen = d - buf;
 			      bufsz += 1024;
-			      char *buf_new = (char *) malloc (bufsz);
+			      char *buf_new = (char *) xmalloc (bufsz);
 			      strncpy (buf_new, buf, curlen);
 			      buf_new[curlen] = '\0';
 			      free (buf);
@@ -5243,7 +5243,7 @@
 	    //	it needs to be
 	    // first, scan all the lines, to get the maximum line number
 	    bufsz = 1024;
-	    buf = (char *) malloc (bufsz);
+	    buf = (char *) xmalloc (bufsz);
 	    int max_lineno = 0;
 	    int hidx;
 	    Hist_data::HistItem *hitem;
@@ -5334,7 +5334,7 @@
 			    // Reallocate the buffer
 			    size_t curlen = d - buf;
 			    bufsz += 1024;
-			    char *buf_new = (char *) malloc (bufsz);
+			    char *buf_new = (char *) xmalloc (bufsz);
 			    strncpy (buf_new, buf, curlen);
 			    buf_new[curlen] = '\0';
 			    free (buf);
@@ -6089,7 +6089,7 @@
     return NULL;
 
   // Get statistics data
-  data = (Stats_data **) malloc ((size + 1) * sizeof (Stats_data *));
+  data = (Stats_data **) xmalloc ((size + 1) * sizeof (Stats_data *));
   data[0] = new Stats_data ();
   for (index = 1; index <= size; index++)
     {
@@ -7006,8 +7006,8 @@
       if (map != NULL)
 	{
 	  int nmetrics = mvec->size ();
-	  double *evalues = (double *) malloc (nmetrics * sizeof (double));
-	  double *ivalues = (double *) malloc (nmetrics * sizeof (double));
+	  double *evalues = (double *) xmalloc (nmetrics * sizeof (double));
+	  double *ivalues = (double *) xmalloc (nmetrics * sizeof (double));
 	  for (index2 = 0; index2 < nmetrics; index2++)
 	    {
 	      evalues[index2] = excl_list->fetch (index2);
@@ -7090,8 +7090,8 @@
   Vector<char*> *name = new Vector<char*>(1); // Internal name
   if (NULL != defctrs)
     {
-      i18n->store (0, strdup (defctrs));
-      name->store (0, strdup (NTXT ("default")));
+      i18n->store (0, xstrdup (defctrs));
+      name->store (0, xstrdup (NTXT ("default")));
     }
   list->store (0, i18n);
   list->store (1, name);
@@ -8692,8 +8692,8 @@
       int data_id = dataDscr->getId ();
       int aux_prop_id = (data_id == DATA_HWC) ? PROP_HWCTAG : PROP_NONE;
       dataId->append (data_id);
-      dataName->append (strdup (dataDscr->getName ()));
-      dataUName->append (strdup (dataDscr->getUName ()));
+      dataName->append (xstrdup (dataDscr->getName ()));
+      dataUName->append (xstrdup (dataDscr->getUName ()));
       auxProp->append (aux_prop_id);
     }
   delete ddscr;
@@ -9921,8 +9921,8 @@
   if (dbeline != NULL)
     snprintf (lineno, sizeof (lineno), NTXT ("%d"), dbeline->lineno);
   Vector<char*> *res = new Vector<char*>(2);
-  res->store (0, strdup (fname));
-  res->store (1, strdup (lineno));
+  res->store (0, xstrdup (fname));
+  res->store (1, xstrdup (lineno));
   return res;
 }
 
diff --git a/gprofng/src/DbeJarFile.cc b/gprofng/src/DbeJarFile.cc
index fe3427f..b2bb355 100644
--- a/gprofng/src/DbeJarFile.cc
+++ b/gprofng/src/DbeJarFile.cc
@@ -123,7 +123,7 @@
 
 DbeJarFile::DbeJarFile (const char *jarName)
 {
-  name = strdup (jarName);
+  name = xstrdup (jarName);
   fnames = NULL;
   dwin = new Data_window (name);
   get_entries ();
@@ -211,7 +211,7 @@
       char *nm = (char *) dwin->bind (offset + 46, name_len);
       if (nm)
 	{
-	  ze->name = (char *) malloc (name_len + 1);
+	  ze->name = (char *) xmalloc (name_len + 1);
 	  strncpy (ze->name, nm, name_len);
 	  ze->name[name_len] = 0;
 	}
@@ -320,7 +320,7 @@
   strm.avail_in = ze->csize;
   strm.next_in = b;
   int retval = ze->size;
-  unsigned char *buf = (unsigned char *) malloc (ze->size);
+  unsigned char *buf = (unsigned char *) xmalloc (ze->size);
   for (;;)
     {
       strm.next_out = buf;
diff --git a/gprofng/src/DbeSession.cc b/gprofng/src/DbeSession.cc
index 3649357..2a8a6f2 100644
--- a/gprofng/src/DbeSession.cc
+++ b/gprofng/src/DbeSession.cc
@@ -1245,7 +1245,7 @@
     {
       if (t_exp_list[j] == NULL) continue;
       Experiment *dexp = t_exp_list[j];
-      exp_ctx *new_ctx = (exp_ctx*) malloc (sizeof (exp_ctx));
+      exp_ctx *new_ctx = (exp_ctx*) xmalloc (sizeof (exp_ctx));
       new_ctx->path = NULL;
       new_ctx->exp = dexp;
       new_ctx->ds = this;
diff --git a/gprofng/src/DbeView.cc b/gprofng/src/DbeView.cc
index 6b0c3a4..872ebcd 100644
--- a/gprofng/src/DbeView.cc
+++ b/gprofng/src/DbeView.cc
@@ -552,7 +552,7 @@
 
       // set the defaults
       if (settings->str_dmetrics == NULL)
-	settings->str_dmetrics = strdup (Command::DEFAULT_METRICS);
+	settings->str_dmetrics = xstrdup (Command::DEFAULT_METRICS);
       char *status = setMetrics (settings->str_dmetrics, true);
       if (status != NULL)
 	{
@@ -1122,7 +1122,7 @@
   if ((sort_list == NULL) || (strcmp (sort_list, Command::DEFAULT_CMD) == 0))
     {
       if (settings->str_dsort == NULL)
-	settings->str_dsort = strdup (Command::DEFAULT_METRICS);
+	settings->str_dsort = xstrdup (Command::DEFAULT_METRICS);
       sort_list = settings->get_default_sort ();
     }
   mlist = get_metric_list (mtype);
diff --git a/gprofng/src/DerivedMetrics.cc b/gprofng/src/DerivedMetrics.cc
index ee14ea0..14026d6 100644
--- a/gprofng/src/DerivedMetrics.cc
+++ b/gprofng/src/DerivedMetrics.cc
@@ -119,7 +119,7 @@
   int nmetrics = mitems->size ();
 
   // allocate arrays for the mapping between derived metrics and requested values
-  int *map = (int *) malloc (ndm * sizeof (int));
+  int *map = (int *) xmalloc (ndm * sizeof (int));
 
   // map derived metrics to requested metrics    // EUGENE explain this more clearly
   //   0  means not mapped
@@ -194,7 +194,7 @@
   int n = items->size ();
 
   // zero out a vector representing definitions
-  int *vec = (int *) malloc (n * sizeof (int));
+  int *vec = (int *) xmalloc (n * sizeof (int));
   for (int i = 0; i < n; i++)
     vec[i] = 0;
   fill_dependencies (def, vec);
diff --git a/gprofng/src/DwarfLib.cc b/gprofng/src/DwarfLib.cc
index a150c76..3872cc2 100644
--- a/gprofng/src/DwarfLib.cc
+++ b/gprofng/src/DwarfLib.cc
@@ -1523,7 +1523,7 @@
 	   (long long) debug_lineSec->offset, efmt_cnt);
   if (efmt_cnt == 0)
     return NULL;
-  t_entry_fmt *efmt = (t_entry_fmt *) malloc (sizeof (t_entry_fmt) * efmt_cnt);
+  t_entry_fmt *efmt = (t_entry_fmt *) xmalloc (sizeof (t_entry_fmt) * efmt_cnt);
   for (int i = 0; i < efmt_cnt; i++)
     {
       efmt[i].type_code = debug_lineSec->GetULEB128 ();
@@ -2350,8 +2350,8 @@
   if (isGNU && (inlinedSubrCnt > 0))
     {
       Function *func = NULL;
-      mod->inlinedSubr = (InlinedSubr *) malloc (inlinedSubrCnt
-						 * sizeof (InlinedSubr));
+      mod->inlinedSubr = (InlinedSubr *) xmalloc (inlinedSubrCnt
+						  * sizeof (InlinedSubr));
       for (long i = 0; i < inlinedSubrCnt; i++)
 	{
 	  DwrInlinedSubr *inlinedSubr = dwrInlinedSubrs->get (i);
diff --git a/gprofng/src/Elf.cc b/gprofng/src/Elf.cc
index 45f8893..7c71561 100644
--- a/gprofng/src/Elf.cc
+++ b/gprofng/src/Elf.cc
@@ -405,7 +405,7 @@
 {
   if (data == NULL)
     {
-      data = (Elf_Data **) malloc (ehdrp->e_shnum * sizeof (Elf_Data *));
+      data = (Elf_Data **) xmalloc (ehdrp->e_shnum * sizeof (Elf_Data *));
       for (int i = 0; i < (int) ehdrp->e_shnum; i++)
 	data[i] = NULL;
     }
@@ -744,7 +744,7 @@
 	bfd_symcnt = bfd_get_symtab_upper_bound (abfd);
       if (bfd_symcnt > 0)
 	{
-	  bfd_sym = (asymbol **) malloc (bfd_symcnt);
+	  bfd_sym = (asymbol **) xmalloc (bfd_symcnt);
 	  bfd_symcnt = bfd_canonicalize_symtab (abfd, bfd_sym);
 	  if (bfd_symcnt < 0)
 	    {
@@ -761,7 +761,7 @@
       bfd_dynsymcnt = bfd_get_dynamic_symtab_upper_bound (abfd);
       if (bfd_dynsymcnt > 0)
 	{
-	  bfd_dynsym = (asymbol **) malloc (bfd_dynsymcnt);
+	  bfd_dynsym = (asymbol **) xmalloc (bfd_dynsymcnt);
 	  bfd_dynsymcnt = bfd_canonicalize_dynamic_symtab (abfd, bfd_dynsym);
 	  if (bfd_dynsymcnt < 0)
 	    {
diff --git a/gprofng/src/Emsg.cc b/gprofng/src/Emsg.cc
index 0162059..eada9ae 100644
--- a/gprofng/src/Emsg.cc
+++ b/gprofng/src/Emsg.cc
@@ -39,7 +39,7 @@
   warn = w;
   flavor = 0;
   par = NULL;
-  text = strdup (i18n_text);
+  text = xstrdup (i18n_text);
   next = NULL;
 }
 
@@ -436,7 +436,7 @@
 {
   first = NULL;
   last = NULL;
-  qname = strdup (_qname);
+  qname = xstrdup (_qname);
 }
 
 Emsgqueue::~Emsgqueue ()
@@ -584,7 +584,7 @@
   else
     {
       va_start (vp, fmt);
-      char *buf = (char *) malloc (buf_size);
+      char *buf = (char *) xmalloc (buf_size);
       vsnprintf (buf, buf_size, fmt, vp);
       va_end (vp);
       msg = new Emsg (w, buf);
diff --git a/gprofng/src/Experiment.cc b/gprofng/src/Experiment.cc
index 3e1e1a7..3c63f9f 100644
--- a/gprofng/src/Experiment.cc
+++ b/gprofng/src/Experiment.cc
@@ -252,9 +252,7 @@
   if (bufsz == 0)
     {
       bufsz = 1024;
-      buffer = (char *) malloc (bufsz);
-      if (buffer == NULL)
-	return NULL;
+      buffer = (char *) xmalloc (bufsz);
       buffer[bufsz - 1] = (char) 1; // sentinel
     }
   char *res = ::fgets (buffer, bufsz, fh);
@@ -263,9 +261,7 @@
   while (buffer[bufsz - 1] == (char) 0)
     {
       int newsz = bufsz + 1024;
-      char *newbuf = (char *) malloc (newsz);
-      if (newbuf == NULL)
-	return NULL;
+      char *newbuf = (char *) xmalloc (newsz);
       memcpy (newbuf, buffer, bufsz);
       free (buffer);
       buffer = newbuf;
@@ -451,19 +447,19 @@
       if (str != NULL)
 	{
 	  found = 1;
-	  exp->coll_params.start_delay = strdup (str);
+	  exp->coll_params.start_delay = xstrdup (str);
 	}
       str = attrs->getValue (SP_JCMD_TERMINATE);
       if (str != NULL)
 	{
 	  found = 1;
-	  exp->coll_params.terminate = strdup (str);
+	  exp->coll_params.terminate = xstrdup (str);
 	}
       str = attrs->getValue (SP_JCMD_PAUSE_SIG);
       if (str != NULL)
 	{
 	  found = 1;
-	  exp->coll_params.pause_sig = strdup (str);
+	  exp->coll_params.pause_sig = xstrdup (str);
 	}
       str = attrs->getValue (SP_JCMD_SAMPLE_PERIOD);
       if (str != NULL)
@@ -491,7 +487,7 @@
       if (str != NULL)
 	{
 	  found = 1;
-	  exp->coll_params.linetrace = strdup (str);
+	  exp->coll_params.linetrace = xstrdup (str);
 	}
 
       str = attrs->getValue (SP_JCMD_COLLENV);
@@ -524,11 +520,11 @@
       pushElem (EL_SYSTEM);
       const char *str = attrs->getValue (NTXT ("hostname"));
       if (str != NULL)
-	exp->hostname = strdup (str);
+	exp->hostname = xstrdup (str);
       str = attrs->getValue (NTXT ("os"));
       if (str != NULL)
 	{
-	  exp->os_version = strdup (str);
+	  exp->os_version = xstrdup (str);
 	  /* For Linux experiments expect sparse thread ID's */
 	  if (strncmp (str, NTXT ("SunOS"), 5) != 0)
 	    exp->sparse_threads = true;
@@ -547,7 +543,7 @@
 	    exp->platform = Sparc;
 	  exp->need_swap_endian = (DbeSession::platform == Sparc) ?
 		  (exp->platform != Sparc) : (exp->platform == Sparc);
-	  exp->architecture = strdup (str);
+	  exp->architecture = xstrdup (str);
 	}
       str = attrs->getValue (NTXT ("pagesz"));
       if (str != NULL)
@@ -624,7 +620,7 @@
 	exp->sid = atoi (str);
       str = attrs->getValue (NTXT ("cwd"));
       if (str != NULL)
-	exp->ucwd = strdup (str);
+	exp->ucwd = xstrdup (str);
       str = attrs->getValue (NTXT ("pagesz"));
       if (str != NULL)
 	exp->page_size = atoi (str);
@@ -1061,7 +1057,7 @@
 	  exp->has_java = true;
 	  str = attrs->getValue (NTXT ("jversion"));
 	  if (str != NULL)
-	    exp->jversion = strdup (str);
+	    exp->jversion = xstrdup (str);
 	}
       else if (strcmp (str, NTXT ("datarace")) == 0)
 	{
@@ -1148,7 +1144,7 @@
 		{
 		  fldDscr->vtype = TYPE_DATE;
 		  const char *fmt = attrs->getValue (NTXT ("format"));
-		  fldDscr->format = strdup (fmt ? fmt : "");
+		  fldDscr->format = xstrdup (fmt ? fmt : "");
 		}
 	    }
 	  propDscr->vtype = fldDscr->vtype;
@@ -1173,7 +1169,7 @@
 
 	  str = attrs->getValue (NTXT ("uname"));
 	  if (str)
-	    propDscr->uname = strdup (PTXT ((char*) str));
+	    propDscr->uname = xstrdup (PTXT ((char*) str));
 	  str = attrs->getValue (NTXT ("noshow"));
 	  if (str && atoi (str) != 0)
 	    propDscr->flags |= PRFLAG_NOSHOW;
@@ -4589,7 +4585,7 @@
 		else
 		  {
 		    // bug 6909545: garbage in 64-bit JAVA_INFO
-		    char *nstack = (char*) malloc (stack_size);
+		    char *nstack = (char*) xmalloc (stack_size);
 		    char *dst = nstack;
 		    char *srcmax = stack + stack_size - sizeof (uint64_t);
 		    for (char *src = stack; src <= srcmax;)
@@ -5845,7 +5841,7 @@
       DbeFile *df = archiveMap->get (aname);
       free (aname);
       if (df)
-	return strdup (df->get_location ());
+	return xstrdup (df->get_location ());
       return NULL;
     }
   if (founder_exp)
@@ -6591,12 +6587,7 @@
 	  fprintf (stderr, GTXT ("gp-archive: Fatal error: pathconf(\".\", _PC_PATH_MAX) failed\n"));
 	  return 1;
 	}
-      char *buf = (char *) malloc ((size_t) size);
-      if (buf == NULL)
-	{
-	  fprintf (stderr, GTXT ("gp-archive: Fatal error: unable to allocate memory\n"));
-	  return 1;
-	}
+      char *buf = (char *) xmalloc ((size_t) size);
       char *ptr = getcwd (buf, (size_t) size);
       if (ptr == NULL)
 	{
diff --git a/gprofng/src/Function.cc b/gprofng/src/Function.cc
index 1d8ae45..dd9a2c7 100644
--- a/gprofng/src/Function.cc
+++ b/gprofng/src/Function.cc
@@ -129,14 +129,14 @@
   bool soname_fmt = Histable::soname_fmt (nfmt);
   int fname_fmt = Histable::fname_fmt (nfmt);
   if (fname_fmt == Histable::MANGLED)
-    name_buf = strdup (mangled_name);
+    name_buf = xstrdup (mangled_name);
   else
     {
       if (module && module->is_fortran ()
 	  && (streq (name, "MAIN") || streq (name, "MAIN_")))
-	name_buf = strdup (match_name);
+	name_buf = xstrdup (match_name);
       else
-	name_buf = strdup (name);
+	name_buf = xstrdup (name);
 
       if (fname_fmt == Histable::SHORT)
 	{
diff --git a/gprofng/src/Makefile.am b/gprofng/src/Makefile.am
index fb4b8a0..4179507 100644
--- a/gprofng/src/Makefile.am
+++ b/gprofng/src/Makefile.am
@@ -92,7 +92,6 @@
 	dbe_hwcdrv.c \
 	dbe_hwcfuncs.c \
 	dbe_hwctable.c \
-	dbe_memmgr.c \
 	gethrtime.c \
 	$(NULL)
 
diff --git a/gprofng/src/Makefile.in b/gprofng/src/Makefile.in
index cef4b27..4c25d01 100644
--- a/gprofng/src/Makefile.in
+++ b/gprofng/src/Makefile.in
@@ -178,7 +178,7 @@
 	QLParser.tab.lo dbe_collctrl.lo i18n.lo parse.lo UserLabel.lo \
 	util.lo Dbe.lo
 am__objects_2 = dbe_hwcdrv.lo dbe_hwcfuncs.lo dbe_hwctable.lo \
-	dbe_memmgr.lo gethrtime.lo
+	gethrtime.lo
 am_libgprofng_la_OBJECTS = $(am__objects_1) $(am__objects_2)
 libgprofng_la_OBJECTS = $(am_libgprofng_la_OBJECTS)
 AM_V_lt = $(am__v_lt_@AM_V@)
@@ -519,7 +519,6 @@
 	dbe_hwcdrv.c \
 	dbe_hwcfuncs.c \
 	dbe_hwctable.c \
-	dbe_memmgr.c \
 	gethrtime.c \
 	$(NULL)
 
@@ -786,7 +785,6 @@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dbe_hwcdrv.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dbe_hwcfuncs.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dbe_hwctable.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dbe_memmgr.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/envsets.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gethrtime.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gp-archive.Po@am__quote@
diff --git a/gprofng/src/Module.cc b/gprofng/src/Module.cc
index d5255dc..064581c 100644
--- a/gprofng/src/Module.cc
+++ b/gprofng/src/Module.cc
@@ -368,7 +368,7 @@
   if (!strncmp (hdr.ar_name, NTXT ("//"), 2))
     {
       longnames_size = get_ar_size (hdr.ar_size, sizeof (hdr.ar_size));
-      longnames = (char *) malloc (longnames_size + 1);
+      longnames = (char *) xmalloc (longnames_size + 1);
       int64_t cnt = read_from_file (ar, longnames, longnames_size);
       if (cnt != (int64_t) longnames_size)
 	{
@@ -519,8 +519,8 @@
       char *path = loadobject->dbeFile->get_location ();
       if (path)
 	{
-	  disPath = strdup (path);
-	  disName = strdup (path);
+	  disPath = xstrdup (path);
+	  disName = xstrdup (path);
 	  disMTime = loadobject->dbeFile->sbuf.st_mtime;
 	}
 
@@ -535,7 +535,7 @@
 	  size_t last = strlen (base) - 1;
 	  base[last] = '\0';
 	  stabsTmp = dbeSession->get_tmp_file_name (base, false);
-	  dbeSession->tmp_files->append (strdup (stabsTmp));
+	  dbeSession->tmp_files->append (xstrdup (stabsTmp));
 
 	  DbeFile *dbf = dbeSession->getDbeFile (namebuf,
 					DbeFile::F_DOT_A_LIB | DbeFile::F_FILE);
@@ -553,8 +553,8 @@
 	      dbeFile->check_access (stabsTmp); // init 'sbuf'
 	      dbeFile->sbuf.st_mtime = 0; // Don't check timestamps
 	      dbeFile->container = dbf;
-	      stabsPath = strdup (stabsTmp);
-	      stabsName = strdup (path);
+	      stabsPath = xstrdup (stabsTmp);
+	      stabsName = xstrdup (path);
 	      stabsMTime = dbeFile->sbuf.st_mtime;
 	    }
 	  else
@@ -573,8 +573,8 @@
 	  path = dbeFile->get_location ();
 	  if (path != NULL)
 	    {
-	      stabsPath = strdup (path);
-	      stabsName = strdup (path);
+	      stabsPath = xstrdup (path);
+	      stabsName = xstrdup (path);
 	      stabsMTime = hasDwarf ? 0 : dbeFile->sbuf.st_mtime;
 	    }
 	}
@@ -585,14 +585,14 @@
 	{
 	  if (disPath == NULL)
 	    return false;
-	  stabsPath = strdup (disPath);
-	  stabsName = strdup (disName);
+	  stabsPath = xstrdup (disPath);
+	  stabsName = xstrdup (disName);
 	  stabsMTime = disMTime;
 	}
       else if (disPath == NULL)
 	{
-	  disPath = strdup (stabsPath);
-	  disName = strdup (stabsName);
+	  disPath = xstrdup (stabsPath);
+	  disName = xstrdup (stabsName);
 	  disMTime = stabsMTime;
 	}
     }
@@ -1278,7 +1278,7 @@
     {
       Hist_data::HistItem *item = src_items->new_hist_item (NULL, AT_EMPTY,
 							    empty);
-      item->value[name_idx].l = strdup (NTXT (""));
+      item->value[name_idx].l = xstrdup (NTXT (""));
       data_items->append_hist_item (item);
       item = src_items->new_hist_item (NULL, AT_COM, empty);
       item->value[name_idx].l = dbe_sprintf (GTXT ("Compile flags: %s"),
diff --git a/gprofng/src/Print.cc b/gprofng/src/Print.cc
index 32a5178..76d9fbd 100644
--- a/gprofng/src/Print.cc
+++ b/gprofng/src/Print.cc
@@ -60,7 +60,7 @@
   if (params->dest == DEST_PRINTER)
     {
       tmp_file = dbeSession->get_tmp_file_name (NTXT ("print"), false);
-      dbeSession->tmp_files->append (strdup (tmp_file));
+      dbeSession->tmp_files->append (xstrdup (tmp_file));
       out_file = fopen (tmp_file, NTXT ("w"));
     }
   else if (params->dest == DEST_OPEN_FILE)
@@ -128,7 +128,7 @@
   if (f == NULL)
     return dbe_sprintf (GTXT ("Error: cannot open temporary file: %s\n"),
 			tmp_file);
-  char *report = (char *) malloc (max);
+  char *report = (char *) xmalloc (max);
   if (report)
     {
       if (1 != fread (report, max - 1, 1, f))
@@ -2382,7 +2382,7 @@
 	ncols++;
       if (ncols == 0)
 	continue;
-      char *name = strdup (mitem->get_name ());
+      char *name = xstrdup (mitem->get_name ());
       char *name2 = split_metric_name (name);
       const char *style = index == metrics_list->get_sort_ref_index () ? "G" : "";
 
@@ -2608,7 +2608,7 @@
       if (!(mitem->is_visible () || mitem->is_tvisible ()
 	    || mitem->is_pvisible ()))
 	continue;
-      char *name = strdup (mitem->get_name ());
+      char *name = xstrdup (mitem->get_name ());
       char *name2 = split_metric_name (name);
 
       if (mitem->is_tvisible ())
diff --git a/gprofng/src/QLParser.yy b/gprofng/src/QLParser.yy
index c0d7329..1b09980 100644
--- a/gprofng/src/QLParser.yy
+++ b/gprofng/src/QLParser.yy
@@ -26,11 +26,13 @@
 %language "C++"
 
 %code top {
+#include "config.h"
 #include <stdio.h>
 #include <string.h>
 #include <string>
 }
 %code requires {
+#include "libiberty.h"
 #include "QLParser.h"
 #include "DbeSession.h"
 #include "Expression.h"
@@ -274,7 +276,7 @@
       case '"':
 	{
 	  int  maxsz = 16;
-	  char *str = (char *) malloc (maxsz);
+	  char *str = (char *) xmalloc (maxsz);
 	  char *ptr = str;
 
 	  for (;;)
@@ -301,7 +303,7 @@
 		    {
 		      size_t len = ptr - str;
 		      maxsz = maxsz > 8192 ? maxsz + 8192 : maxsz * 2;
-		      char *new_s = (char *) realloc (str, maxsz);
+		      char *new_s = (char *) xrealloc (str, maxsz);
 		      str = new_s;
 		      ptr = str + len;
 		    }
diff --git a/gprofng/src/SAXParserFactory.cc b/gprofng/src/SAXParserFactory.cc
index 1099ca3..eedda26 100644
--- a/gprofng/src/SAXParserFactory.cc
+++ b/gprofng/src/SAXParserFactory.cc
@@ -112,15 +112,15 @@
  */
 SAXException::SAXException ()
 {
-  message = strdup ("null");
+  message = xstrdup ("null");
 }
 
 SAXException::SAXException (const char *_message)
 {
   if (_message == NULL)
-    message = strdup ("null");
+    message = xstrdup ("null");
   else
-    message = strdup (_message);
+    message = xstrdup (_message);
 }
 
 SAXException::~SAXException ()
@@ -197,7 +197,7 @@
 {
   dh = NULL;
   bufsz = 0x2000;
-  buffer = (char*) malloc (bufsz);
+  buffer = (char*) xmalloc (bufsz);
   cntsz = 0;
   idx = 0;
   line = 1;
@@ -214,7 +214,7 @@
 {
   dh = NULL;
   bufsz = 8192;
-  buffer = (char*) realloc (buffer, bufsz);
+  buffer = (char*) xrealloc (buffer, bufsz);
   cntsz = 0;
   idx = 0;
   line = 1;
@@ -244,7 +244,7 @@
 	{
 	  int oldbufsz = bufsz;
 	  bufsz = bufsz >= 0x100000 ? bufsz + 0x100000 : bufsz * 2;
-	  buffer = (char*) realloc (buffer, bufsz);
+	  buffer = (char*) xrealloc (buffer, bufsz);
 	  rem = bufsz - oldbufsz;
 	}
     }
diff --git a/gprofng/src/Settings.cc b/gprofng/src/Settings.cc
index 6d1d357..1af0a23 100644
--- a/gprofng/src/Settings.cc
+++ b/gprofng/src/Settings.cc
@@ -1346,13 +1346,13 @@
   if (_rdtMode == true)
     {
       if (str_rtabs == NULL)
-	str_rtabs = strdup ("header");
+	str_rtabs = xstrdup ("header");
       cmd = str_rtabs;
     }
   else
     {
       if (str_tabs == NULL)
-	str_tabs = strdup ("header");
+	str_tabs = xstrdup ("header");
       cmd = str_tabs;
     }
   if (strcmp (cmd, NTXT ("none")) == 0)
diff --git a/gprofng/src/SourceFile.cc b/gprofng/src/SourceFile.cc
index b9f4f13..ac14935 100644
--- a/gprofng/src/SourceFile.cc
+++ b/gprofng/src/SourceFile.cc
@@ -101,7 +101,7 @@
       status = OS_NOSRC;
       return false;
     }
-  char *srcMap = (char *) malloc (srcLen + 1);
+  char *srcMap = (char *) xmalloc (srcLen + 1);
   int64_t sz = read_from_file (fd, srcMap, srcLen);
   if (sz != (int64_t) srcLen)
     append_msg (CMSG_ERROR, GTXT ("%s: Can read only %lld bytes instead %lld"),
diff --git a/gprofng/src/StringBuilder.cc b/gprofng/src/StringBuilder.cc
index 9901b62..c89afd7 100644
--- a/gprofng/src/StringBuilder.cc
+++ b/gprofng/src/StringBuilder.cc
@@ -26,6 +26,7 @@
 #include <stdarg.h>
 #include <unistd.h>
 
+#include "libiberty.h"
 #include "gp-defs.h"
 #include "StringBuilder.h"
 #include "i18n.h"
@@ -34,7 +35,7 @@
 {
   count = 0;
   maxCapacity = 16;
-  value = (char *) malloc (maxCapacity);
+  value = (char *) xmalloc (maxCapacity);
   memset (value, 0, maxCapacity);
 }
 
@@ -42,7 +43,7 @@
 {
   count = 0;
   maxCapacity = capacity;
-  value = (char *) malloc (maxCapacity);
+  value = (char *) xmalloc (maxCapacity);
   memset (value, 0, maxCapacity);
 }
 
@@ -66,7 +67,7 @@
     newCapacity = MAXINT;
   else if (minimumCapacity > newCapacity)
     newCapacity = minimumCapacity;
-  char *newValue = (char *) malloc (newCapacity);
+  char *newValue = (char *) xmalloc (newCapacity);
   maxCapacity = newCapacity;
   memcpy (newValue, value, count);
   memset (newValue + count, 0, maxCapacity - count);
@@ -79,7 +80,7 @@
 {
   if (count < maxCapacity)
     {
-      char *newValue = (char *) malloc (count);
+      char *newValue = (char *) xmalloc (count);
       maxCapacity = count;
       memcpy (newValue, value, count);
       free (value);
@@ -425,7 +426,7 @@
 char *
 StringBuilder::toString ()
 {
-  char *str = (char *) malloc (count + 1);
+  char *str = (char *) xmalloc (count + 1);
   memcpy (str, value, count);
   str[count] = '\0';
   return str;
diff --git a/gprofng/src/StringMap.h b/gprofng/src/StringMap.h
index db949ad..d4702d3 100644
--- a/gprofng/src/StringMap.h
+++ b/gprofng/src/StringMap.h
@@ -154,7 +154,7 @@
       chunks[nchunks - 1] = new Entry[CHUNK_SIZE];
     }
   entry = &chunks[entries / CHUNK_SIZE][entries % CHUNK_SIZE];
-  entry->key = strdup (key);
+  entry->key = xstrdup (key);
   entry->val = val;
   index->insert (lo, entry);
   hashTable[idx] = entry;
diff --git a/gprofng/src/Table.cc b/gprofng/src/Table.cc
index 5e8883e..4ec0a76 100644
--- a/gprofng/src/Table.cc
+++ b/gprofng/src/Table.cc
@@ -85,7 +85,7 @@
 PropDescr::PropDescr (int _propID, const char *_name)
 {
   propID = _propID;
-  name = strdup (_name ? _name : NTXT (""));
+  name = xstrdup (_name ? _name : NTXT (""));
   uname = NULL;
   vtype = TYPE_NONE;
   flags = 0;
@@ -116,10 +116,10 @@
     return;
   if (stateNames == NULL)
     stateNames = new Vector<char*>;
-  stateNames->store (value, strdup (stname));
+  stateNames->store (value, xstrdup (stname));
   if (stateUNames == NULL)
     stateUNames = new Vector<char*>;
-  stateUNames->store (value, strdup (stuname));
+  stateUNames->store (value, xstrdup (stuname));
 }
 
 char *
@@ -145,7 +145,7 @@
 FieldDescr::FieldDescr (int _propID, const char *_name)
 {
   propID = _propID;
-  name = _name ? strdup (_name) : NULL;
+  name = _name ? xstrdup (_name) : NULL;
   offset = 0;
   vtype = TYPE_NONE;
   format = NULL;
@@ -820,7 +820,7 @@
   virtual char *
   fetchString (long i)
   {
-    return strdup (data->fetch (i));
+    return xstrdup (data->fetch (i));
   }
 
   virtual double
@@ -1008,8 +1008,8 @@
 {
   isMaster = true;
   id = _id;
-  name = _name ? strdup (_name) : strdup (NTXT (""));
-  uname = _uname ? strdup (_uname) : strdup (NTXT (""));
+  name = _name ? xstrdup (_name) : xstrdup (NTXT (""));
+  uname = _uname ? xstrdup (_uname) : xstrdup (NTXT (""));
   flags = _flags;
 
   // master data, shared with reference copies:
@@ -1029,8 +1029,8 @@
 {
   isMaster = false;
   id = _id;
-  name = _name ? strdup (_name) : strdup (NTXT (""));
-  uname = _uname ? strdup (_uname) : strdup (NTXT (""));
+  name = _name ? xstrdup (_name) : xstrdup (NTXT (""));
+  uname = _uname ? xstrdup (_uname) : xstrdup (NTXT (""));
   flags = dDscr->flags;
 
   // references point to master DataDescriptor
diff --git a/gprofng/src/checks.cc b/gprofng/src/checks.cc
index 4fe850d..f6d9b0e 100644
--- a/gprofng/src/checks.cc
+++ b/gprofng/src/checks.cc
@@ -51,7 +51,7 @@
     {
     case EXEC_OK:
       njargs = cc->get_java_arg_cnt ();
-      arglist = (char **) calloc (nargs + 5 + njargs, sizeof (char *));
+      arglist = (char **) xcalloc (nargs + 5 + njargs, sizeof (char *));
       jargs = cc->get_java_args ();
 
       // store the first argument -- target name
@@ -96,7 +96,7 @@
 	  exit (1);
 	}
       njargs = cc->get_java_arg_cnt ();
-      arglist = (char **) calloc (nargs + 5 + njargs, sizeof (char *));
+      arglist = (char **) xcalloc (nargs + 5 + njargs, sizeof (char *));
       jargs = cc->get_java_args ();
 
       a = find_java ();
@@ -140,7 +140,7 @@
 	}
       jargs = cc->get_java_args ();
       njargs = cc->get_java_arg_cnt ();
-      arglist = (char **) calloc (nargs + 4 + njargs, sizeof (char *));
+      arglist = (char **) xcalloc (nargs + 4 + njargs, sizeof (char *));
 
       a = find_java ();
       if (a == NULL)
@@ -377,7 +377,7 @@
     case EXEC_OPEN_FAIL:
       return dbe_sprintf (GTXT ("Can't open target executable `%s'\n"), target_name);
     case EXEC_ELF_LIB:
-      return strdup (GTXT ("Internal error: Not a working version of ELF library\n"));
+      return xstrdup (GTXT ("Internal error: Not a working version of ELF library\n"));
     case EXEC_ELF_HEADER:
       return dbe_sprintf (GTXT ("Target `%s' is not a valid ELF executable\n"), target_name);
     case EXEC_ELF_ARCH:
@@ -450,11 +450,11 @@
   switch (rv)
     {
     case EXEC_OK:
-      java_path = strdup (buf);
+      java_path = xstrdup (buf);
       if (verbose == 1)
 	dbe_write (2, GTXT ("Path to `%s' (set from %s) used for Java profiling\n"),
 		   java_path, java_how);
-      return ( strdup (buf));
+      return xstrdup (buf);
     default:
       dbe_write (2, GTXT ("Path to `%s' (set from %s) does not point to a JVM executable\n"),
 		 buf, java_how);
diff --git a/gprofng/src/collctrl.cc b/gprofng/src/collctrl.cc
index 2fa9a88..3dae531 100644
--- a/gprofng/src/collctrl.cc
+++ b/gprofng/src/collctrl.cc
@@ -64,7 +64,7 @@
 	  {
 	    if (s[i] != '\n' && s[i] != ' ' && s[i] != '\t')
 	      {
-		*to = strndup (s, i + 1);
+		*to = xstrndup (s, i + 1);
 		return;
 	      }
 	  }
@@ -131,7 +131,7 @@
     }
   if (cpu_info.cpu_vendorstr == NULL)
 #if defined(__aarch64__)
-    cpu_info.cpu_vendorstr = strdup (AARCH64_VENDORSTR_ARM);
+    cpu_info.cpu_vendorstr = xstrdup (AARCH64_VENDORSTR_ARM);
 #else
     cpu_info.cpu_vendorstr = GTXT ("Unknown processor");
 #endif
@@ -149,11 +149,11 @@
 
   /* set this host's parameters */
   gethostname (hostname, 1023);
-  node_name = strdup (hostname);
+  node_name = xstrdup (hostname);
   char *p = strchr (node_name, (int) '.');
   if (p != NULL)
     *p = 0;
-  default_stem = strdup ("test");
+  default_stem = xstrdup ("test");
 
   cpu_info_t *cpu_p = read_cpuinfo ();
   ncpus = cpu_p->cpu_cnt;
@@ -186,7 +186,7 @@
   follow_spec_usr = NULL;
   follow_spec_cmp = NULL;
   prof_idle = 1;
-  archive_mode = strdup ("on");
+  archive_mode = xstrdup ("on");
   pauseresume_sig = 0;
   sample_sig = 0;
   uinterrupt = 0;
@@ -201,7 +201,7 @@
   base_name = NULL;
   udir_name = NULL;
   store_dir = NULL;
-  prev_store_dir = strdup ("");
+  prev_store_dir = xstrdup ("");
   store_ptr = NULL;
   expt_group = NULL;
   target_name = NULL;
@@ -256,8 +256,8 @@
   interactive = cc->interactive;
   defHWC = cc->defHWC;
   kernelHWC = cc->kernelHWC;
-  node_name = strdup (cc->node_name);
-  default_stem = strdup (cc->default_stem);
+  node_name = xstrdup (cc->node_name);
+  default_stem = xstrdup (cc->default_stem);
   ncpus = cc->ncpus;
   cpu_clk_freq = cc->cpu_clk_freq;
   npages = cc->npages;
@@ -272,15 +272,15 @@
   follow_default = cc->follow_default;
   if (cc->follow_spec_usr)
     {
-      follow_spec_usr = strdup (cc->follow_spec_usr);
-      follow_spec_cmp = strdup (cc->follow_spec_cmp);
+      follow_spec_usr = xstrdup (cc->follow_spec_usr);
+      follow_spec_cmp = xstrdup (cc->follow_spec_cmp);
     }
   else
     {
       follow_spec_usr = NULL;
       follow_spec_cmp = NULL;
     }
-  archive_mode = strdup (cc->archive_mode);
+  archive_mode = xstrdup (cc->archive_mode);
   pauseresume_sig = cc->pauseresume_sig;
   sample_sig = cc->sample_sig;
   time_run = cc->time_run;
@@ -295,12 +295,12 @@
   hwcprof_default = cc->hwcprof_default;
   hwcprof_enabled_cnt = cc->hwcprof_enabled_cnt;
   if (cc->hwc_string != NULL)
-    hwc_string = strdup (cc->hwc_string);
+    hwc_string = xstrdup (cc->hwc_string);
   else
     hwc_string = NULL;
   for (int i = 0; i < hwcprof_enabled_cnt; i++)
     hwcentry_dup (&hwctr[i], &(cc->hwctr[i]));
-  project_home = cc->project_home ? strdup (cc->project_home) : NULL;
+  project_home = cc->project_home ? xstrdup (cc->project_home) : NULL;
   synctrace_enabled = cc->synctrace_enabled;
   synctrace_thresh = cc->synctrace_thresh;
   synctrace_scope = cc->synctrace_scope;
@@ -324,16 +324,16 @@
   // these represent user settings
   expt_group = NULL;
   if (cc->expt_group != NULL)
-    expt_group = strdup (cc->expt_group);
+    expt_group = xstrdup (cc->expt_group);
   uexpt_name = NULL;
   if (cc->uexpt_name != NULL)
-    uexpt_name = strdup (cc->uexpt_name);
+    uexpt_name = xstrdup (cc->uexpt_name);
   udir_name = NULL;
   if (cc->udir_name != NULL)
-    udir_name = strdup (cc->udir_name);
+    udir_name = xstrdup (cc->udir_name);
 
   /* clear the string pointers */
-  prev_store_dir = strdup ("");
+  prev_store_dir = xstrdup ("");
   store_ptr = NULL;
   target_name = NULL;
   data_desc = NULL;
@@ -408,11 +408,11 @@
 Coll_Ctrl::enable_expt ()
 {
   if (opened == 1)
-    return strdup (GTXT ("Experiment is active; command ignored.\n"));
+    return xstrdup (GTXT ("Experiment is active; command ignored.\n"));
   if (cpu_clk_freq == 0)
-    return strdup (GTXT ("Can not determine CPU clock frequency.\n"));
+    return xstrdup (GTXT ("Can not determine CPU clock frequency.\n"));
   if (sys_resolution == 0)
-    return strdup (GTXT ("System clock profile resolution can not be determined.\n"));
+    return xstrdup (GTXT ("System clock profile resolution can not be determined.\n"));
   enabled = 1;
   return NULL;
 }
@@ -450,14 +450,14 @@
 {
   /* check for Java arguments, but not Java profiling */
   if (java_args != NULL && java_mode == 0)
-    return strdup (GTXT ("Java arguments can not be set if Java profiling is not enabled.\n"));
+    return xstrdup (GTXT ("Java arguments can not be set if Java profiling is not enabled.\n"));
 
   /* if count data, no other data is allowed */
   if (count_enabled != 0
       && ((clkprof_default != 1 && clkprof_enabled != 0)
 	  || hwcprof_enabled_cnt != 0 || synctrace_enabled != 0
 	  || heaptrace_mode != NULL || iotrace_enabled != 0))
-    return strdup (GTXT ("Count data cannot be collected along with any other data.\n"));
+    return xstrdup (GTXT ("Count data cannot be collected along with any other data.\n"));
 
   /* if count data, various other options are not allowed */
   if (count_enabled != 0
@@ -466,10 +466,10 @@
 	  || (follow_mode != 0 && follow_default != 1)
 	  || pauseresume_sig != 0 || sample_sig != 0
 	  || (sample_default != 1 && sample_period != 0) || time_run != 0))
-    return strdup (GTXT ("Count data cannot be collected with any of -F -S -y -l -j -J -x -t .\n"));
+    return xstrdup (GTXT ("Count data cannot be collected with any of -F -S -y -l -j -J -x -t .\n"));
   /* if not count data, I and N options are not allowed */
   if (count_enabled == 0 && (Iflag != 0 || Nflag != 0))
-    return strdup (GTXT ("-I or -N can only be specified with count data.\n"));
+    return xstrdup (GTXT ("-I or -N can only be specified with count data.\n"));
   return NULL;
 }
 
@@ -483,12 +483,12 @@
     return ret;
   /* check for heaptrace and java -- warn that it covers native allocations only */
   if (heaptrace_mode != NULL && java_mode == 1 && java_default == 0)
-    *warn = strdup (GTXT ("Note: Heap profiling will only trace native allocations, not Java allocations.\n"));
+    *warn = xstrdup (GTXT ("Note: Heap profiling will only trace native allocations, not Java allocations.\n"));
 
   /* if no profiling data selected, warn the user */
   if (clkprof_enabled == 0 && hwcprof_enabled_cnt == 0 && synctrace_enabled == 0
       && heaptrace_mode == NULL && iotrace_enabled == 0 && count_enabled == 0)
-    *warn = strdup (GTXT ("Warning: No function level data requested; only statistics will be collected.\n\n"));
+    *warn = xstrdup (GTXT ("Warning: No function level data requested; only statistics will be collected.\n\n"));
   build_data_desc ();
 
   /* verify that the directory exists */
@@ -677,22 +677,20 @@
 Coll_Ctrl::get_collect_args ()
 {
   char **p;
-  char **argv = (char **) calloc (MAX_COLLECT_ARGS, sizeof (char *));
-  if (argv == NULL) // poor way of dealing with calloc failure
-    abort ();
+  char **argv = (char **) xcalloc (MAX_COLLECT_ARGS, sizeof (char *));
   p = argv;
-  *p++ = strdup ("collect");
+  *p++ = xstrdup ("collect");
   if (debug_mode == 1)
-    *p++ = strdup ("-x");
+    *p++ = xstrdup ("-x");
   if (clkprof_enabled != 0)
     {
-      *p++ = strdup ("-p");
+      *p++ = xstrdup ("-p");
       *p++ = dbe_sprintf ("%du", clkprof_timer);
     }
   if (hwcprof_enabled_cnt > 0)
     {
       StringBuilder sb;
-      *p++ = strdup ("-h");
+      *p++ = xstrdup ("-h");
       for (int ii = 0; ii < hwcprof_enabled_cnt; ii++)
 	{
 	  char*rateString = hwc_rate_string (&hwctr[ii], 1); //"1" is for temporary goldfile compatibility. TBR YXXX!!
@@ -711,90 +709,90 @@
     }
   if (heaptrace_mode != NULL)
     {
-      *p++ = strdup ("-H");
-      *p++ = strdup (heaptrace_mode);
+      *p++ = xstrdup ("-H");
+      *p++ = xstrdup (heaptrace_mode);
     }
   if (iotrace_enabled != 0)
     {
-      *p++ = strdup ("-i");
-      *p++ = strdup ("on");
+      *p++ = xstrdup ("-i");
+      *p++ = xstrdup ("on");
     }
   if (synctrace_enabled != 0)
     {
-      *p++ = strdup ("-s");
+      *p++ = xstrdup ("-s");
       if (synctrace_thresh < 0)
-	*p++ = strdup ("calibrate");
+	*p++ = xstrdup ("calibrate");
       else if (synctrace_thresh == 0)
-	*p++ = strdup ("all");
+	*p++ = xstrdup ("all");
       else
 	*p++ = dbe_sprintf ("%d", synctrace_thresh);
       *p++ = dbe_sprintf (",%d", synctrace_scope);
     }
   if (follow_mode != 0)
     {
-      *p++ = strdup ("-F");
+      *p++ = xstrdup ("-F");
       char * fs = get_follow_usr_spec ();
       if (fs)
-	*p++ = strdup (fs);
+	*p++ = xstrdup (fs);
       else
 	{
 	  switch (get_follow_mode ())
 	    {
 	    case FOLLOW_ON:
-	      *p++ = strdup ("on");
+	      *p++ = xstrdup ("on");
 	      break;
 	    case FOLLOW_ALL:
-	      *p++ = strdup ("all");
+	      *p++ = xstrdup ("all");
 	      break;
 	    case FOLLOW_NONE:
 	    default:
-	      *p++ = strdup ("off");
+	      *p++ = xstrdup ("off");
 	      break;
 	    }
 	}
     }
-  *p++ = strdup ("-a");
-  *p++ = strdup (get_archive_mode ());
+  *p++ = xstrdup ("-a");
+  *p++ = xstrdup (get_archive_mode ());
   if (java_mode != 0)
     {
-      *p++ = strdup ("-j");
-      *p++ = strdup ("on");
+      *p++ = xstrdup ("-j");
+      *p++ = xstrdup ("on");
     }
   if (pauseresume_sig != 0)
     {
-      *p++ = strdup ("-y");
+      *p++ = xstrdup ("-y");
       *p++ = dbe_sprintf ("%d%s", pauseresume_sig,
 			  (pauseresume_pause == 0 ? ",r" : ""));
     }
   if (sample_sig != 0)
     {
-      *p++ = strdup ("-l");
+      *p++ = xstrdup ("-l");
       *p++ = dbe_sprintf ("%d", sample_sig);
     }
   if (sample_period != 0)
     {
-      *p++ = strdup ("-S");
+      *p++ = xstrdup ("-S");
       *p++ = dbe_sprintf ("%d", sample_period);
     }
   if (size_limit != 0)
     {
-      *p++ = strdup ("-L");
+      *p++ = xstrdup ("-L");
       *p++ = dbe_sprintf ("%d", size_limit);
     }
   if (expt_group != NULL)
     {
-      *p++ = strdup ("-g");
-      *p++ = strdup (expt_group);
+      *p++ = xstrdup ("-g");
+      *p++ = xstrdup (expt_group);
     }
   if (udir_name != 0)
     {
-      *p++ = strdup ("-d");
-      *p++ = strdup (udir_name);
+      *p++ = xstrdup ("-d");
+      *p++ = xstrdup (udir_name);
     }
   if (expt_name != 0)
     {
-      *p++ = strdup ("-o");
-      *p++ = strdup (expt_name);
+      *p++ = xstrdup ("-o");
+      *p++ = xstrdup (expt_name);
     }
   if (p - argv >= MAX_COLLECT_ARGS) // argument list too small -- fatal error
     abort ();
@@ -852,10 +850,10 @@
   int prevclkprof_default;
   *warn = NULL;
   if (opened == 1)
-    return strdup (GTXT ("Experiment is active; command ignored.\n"));
+    return xstrdup (GTXT ("Experiment is active; command ignored.\n"));
   /* if the first character is a +, warn user that it is no longer supported */
   if (string[0] == '+')
-    return strdup (GTXT ("Warning: clock-based memoryspace and dataspace profiling is no longer supported\n"));
+    return xstrdup (GTXT ("Warning: clock-based memoryspace and dataspace profiling is no longer supported\n"));
   if (strcmp (string, "off") == 0)
     {
       clkprof_enabled = 0;
@@ -946,7 +944,7 @@
 Coll_Ctrl::set_synctrace (const char *string)
 {
   if (opened == 1)
-    return strdup (GTXT ("Experiment is active; command ignored.\n"));
+    return xstrdup (GTXT ("Experiment is active; command ignored.\n"));
   char *comma_p = NULL;
   if (string == NULL)
     {
@@ -962,7 +960,7 @@
 	}
       return NULL;
     }
-  char *val = strdup (string);
+  char *val = xstrdup (string);
   /* see if there's a comma in the string */
   char *next = strchr (val, (int) ',');
   if (next != NULL)
@@ -1042,14 +1040,14 @@
 Coll_Ctrl::set_heaptrace (const char *string)
 {
   if (opened == 1)
-    return strdup (GTXT ("Experiment is active; command ignored.\n"));
+    return xstrdup (GTXT ("Experiment is active; command ignored.\n"));
   free(heaptrace_mode);
   heaptrace_mode = NULL;  // Same as "off"
   if (string != NULL && strcmp (string, "off") == 0)
     return NULL;
 
   if (string == NULL || strlen (string) == 0 || strcmp (string, "on") == 0)
-    heaptrace_mode = strdup ("on");
+    heaptrace_mode = xstrdup ("on");
   else if (isdigit (*string))
     {
       char *s;
@@ -1064,7 +1062,7 @@
       if (*s != 0)
 	return dbe_sprintf (
 	       GTXT ("Incorrect range in heap trace parameter '%s'\n"), string);
-      heaptrace_mode = strdup (string);
+      heaptrace_mode = xstrdup (string);
     }
   else
     return dbe_sprintf (GTXT ("Unrecognized heap tracing parameter `%s'\n"),
@@ -1083,7 +1081,7 @@
 Coll_Ctrl::set_iotrace (const char *string)
 {
   if (opened == 1)
-    return strdup (GTXT ("Experiment is active; command ignored.\n"));
+    return xstrdup (GTXT ("Experiment is active; command ignored.\n"));
   if (string == NULL || strlen (string) == 0 || strcmp (string, "on") == 0)
     {
       iotrace_enabled = 1;
@@ -1108,7 +1106,7 @@
 {
   int ret = -1;
   if (opened == 1)
-    return strdup (GTXT ("Experiment is active; command ignored.\n"));
+    return xstrdup (GTXT ("Experiment is active; command ignored.\n"));
   if (string == NULL || strlen (string) == 0 || strcmp (string, "off") == 0)
     {
       count_enabled = 0;
@@ -1161,9 +1159,9 @@
 Coll_Ctrl::set_time_run (const char *valarg)
 {
   if (opened == 1)
-    return strdup (GTXT ("Experiment is active; command ignored.\n"));
+    return xstrdup (GTXT ("Experiment is active; command ignored.\n"));
   if (valarg == NULL) /* invalid setting */
-    return strdup (GTXT ("time parameter can not be NULL\n"));
+    return xstrdup (GTXT ("time parameter can not be NULL\n"));
   /* the string should be a number >= 0 */
   int prev_start_delay = start_delay;
   int prev_time_run = time_run;
@@ -1233,9 +1231,9 @@
 Coll_Ctrl::set_attach_pid (char *valarg)
 {
   if (opened == 1)
-    return strdup (GTXT ("Experiment is active; command ignored.\n"));
+    return xstrdup (GTXT ("Experiment is active; command ignored.\n"));
   if (valarg == NULL)
-    return strdup (GTXT ("Specified PID can not be NULL\n"));
+    return xstrdup (GTXT ("Specified PID can not be NULL\n"));
 
   /* the string should be a number corresponding to an active process' pid */
   char *endchar = NULL;
@@ -1269,19 +1267,19 @@
 {
   *hnew = *_hwc;
   if (_hwc->name != NULL)
-    hnew->name = strdup (_hwc->name);
+    hnew->name = xstrdup (_hwc->name);
   else
     hnew->name = NULL;
   if (_hwc->int_name != NULL)
-    hnew->int_name = strdup (_hwc->int_name);
+    hnew->int_name = xstrdup (_hwc->int_name);
   else
     hnew->int_name = NULL;
   if (_hwc->metric != NULL)
-    hnew->metric = strdup (_hwc->metric);
+    hnew->metric = xstrdup (_hwc->metric);
   else
     hnew->metric = NULL;
   if (_hwc->short_desc != NULL)
-    hnew->short_desc = strdup (_hwc->short_desc);
+    hnew->short_desc = xstrdup (_hwc->short_desc);
   else
     hnew->short_desc = NULL;
 }
@@ -1378,7 +1376,7 @@
   char *emsg;
   char *wmsg;
   if (opened == 1)
-    return strdup (GTXT ("Experiment is active; command ignored.\n"));
+    return xstrdup (GTXT ("Experiment is active; command ignored.\n"));
   if (hwcprof_default == 0)
     {
       /* Copy the counters already defined */
@@ -1472,14 +1470,12 @@
     }
   /* allocate return string */
   int retsize = 2 * len + 10;
-  char *ret = (char *) malloc (retsize);
-  if (ret == NULL)
-    return strdup (GTXT ("internal error formating HW counter set; malloc failed\n"));
+  char *ret = (char *) xmalloc (retsize);
   *ret = 0;
   char *retp = ret;
   char *stringp = def_string;
   int first = 1;
-  char *hwc_defaultx = strdup (def_string);
+  char *hwc_defaultx = xstrdup (def_string);
 
   /* now massage the string in order to insert resolution for each counter */
   for (;;)
@@ -1608,7 +1604,7 @@
 {
   int val;
   if (opened == 1)
-    return strdup (GTXT ("Experiment is active; command ignored.\n"));
+    return xstrdup (GTXT ("Experiment is active; command ignored.\n"));
   if (string == NULL || strcmp (string, "on") == 0)
     val = 1;
   else if (strcmp (string, "off") == 0)
@@ -1638,7 +1634,7 @@
 Coll_Ctrl::set_size_limit (const char *string)
 {
   if (opened == 1)
-    return strdup (GTXT ("Experiment is active; command ignored.\n"));
+    return xstrdup (GTXT ("Experiment is active; command ignored.\n"));
   if (string == NULL || strlen (string) == 0
       || strcmp (string, "unlimited") == 0 || strcmp (string, "none") == 0)
     {
@@ -1776,7 +1772,7 @@
 	  if (uinterrupt == 1)
 	    {
 	      close (groupfd);
-	      return strdup (GTXT ("user interrupt\n"));
+	      return xstrdup (GTXT ("user interrupt\n"));
 	    }
 	  // it's opened, now lock it
 	  if (fcntl (groupfd, F_SETLK, &flockbuf) != -1)
@@ -1820,7 +1816,7 @@
 	      // can't get the lock, close the file and try again
 	      close (groupfd);
 	      if (uinterrupt == 1)
-		return strdup (GTXT ("user interrupt\n"));
+		return xstrdup (GTXT ("user interrupt\n"));
 	      if (tries == 11900)
 		return dbe_sprintf (GTXT ("Timed out: waiting for group file %s\n"), group_file);
 #if 0
@@ -1883,7 +1879,7 @@
   struct stat statbuf;
   *warn = NULL;
   if (opened == 1)
-    return strdup (GTXT ("Experiment is active; command ignored.\n"));
+    return xstrdup (GTXT ("Experiment is active; command ignored.\n"));
   if (stat (dir, &statbuf) != 0)
     return dbe_sprintf (GTXT ("Can't set directory `%s': %s\n"),
 			dir, strerror (errno));
@@ -1891,7 +1887,7 @@
     return dbe_sprintf (GTXT ("Can't set directory `%s': %s\n"),
 			dir, strerror (ENOTDIR));
   free (udir_name);
-  udir_name = strdup (dir);
+  udir_name = xstrdup (dir);
 
   // Process new setting
   *warn = preprocess_names ();
@@ -1922,14 +1918,14 @@
   free (target_name);
   target_name = NULL;
   if (targetname != NULL)
-    target_name = strdup (targetname);
+    target_name = xstrdup (targetname);
   return 0;
 }
 
 void
 Coll_Ctrl::set_default_stem (const char* stem)
 {
-  default_stem = strdup (stem);
+  default_stem = xstrdup (stem);
   preprocess_names ();
   (void) update_expt_name (false, false); // no warnings
 }
@@ -1944,7 +1940,7 @@
       uexpt_name = NULL;
       return NULL;
     }
-  char *exptname = canonical_path (strdup (ename));
+  char *exptname = canonical_path (xstrdup (ename));
   size_t i = strlen (exptname);
   if (i < 4 || strcmp (&exptname[i - 3], ".er") != 0)
     {
@@ -1980,7 +1976,7 @@
 Coll_Ctrl::set_group (char *groupname)
 {
   if (opened == 1)
-    return strdup (GTXT ("Experiment is active; command ignored.\n"));
+    return xstrdup (GTXT ("Experiment is active; command ignored.\n"));
   if (expt_group != NULL)
     {
       free (expt_group);
@@ -1996,7 +1992,7 @@
   int i = (int) strlen (groupname);
   if (i < 5 || strcmp (&groupname[i - 4], ".erg") != 0)
     return dbe_sprintf (GTXT ("Experiment group name `%s'must end in `.erg'\n"), groupname);
-  expt_group = strdup (groupname);
+  expt_group = xstrdup (groupname);
   preprocess_names ();
   (void) update_expt_name (true, false);
   return NULL;
@@ -2007,7 +2003,7 @@
 {
   struct stat statbuf;
   if (opened == 1)
-    return strdup (GTXT ("Experiment is active; command ignored.\n"));
+    return xstrdup (GTXT ("Experiment is active; command ignored.\n"));
   if (string == NULL || strlen (string) == 0 || strcmp (string, "on") == 0)
     {
 #if defined(GPROFNG_JAVA_PROFILING)
@@ -2024,7 +2020,7 @@
 	}
       return NULL;
 #else
-      return strdup (GTXT ("gprofng was built without support for profiling Java applications\n"));
+      return xstrdup (GTXT ("gprofng was built without support for profiling Java applications\n"));
 #endif
     }
   if (strcmp (string, "off") == 0)
@@ -2071,9 +2067,9 @@
 Coll_Ctrl::set_java_path (const char *string)
 {
   if (opened == 1)
-    return strdup (GTXT ("Experiment is active; command ignored.\n"));
+    return xstrdup (GTXT ("Experiment is active; command ignored.\n"));
   free (java_path);
-  java_path = strdup (string);
+  java_path = xstrdup (string);
   return NULL;
 }
 
@@ -2082,12 +2078,12 @@
 {
   char *next;
   if (opened == 1)
-    return strdup (GTXT ("Experiment is active; command ignored.\n"));
+    return xstrdup (GTXT ("Experiment is active; command ignored.\n"));
   char *prev_java_args = java_args;
   if (string == NULL || strlen (string) == 0)
-    java_args = strdup ("");
+    java_args = xstrdup ("");
   else
-    java_args = strdup (string);
+    java_args = xstrdup (string);
   // now count the number of Java arguments
   for (next = java_args; *next; next++)
     {
@@ -2116,7 +2112,7 @@
 Coll_Ctrl::set_follow_mode (const char *string)
 {
   if (opened == 1)
-    return strdup (GTXT ("Experiment is active; command ignored.\n"));
+    return xstrdup (GTXT ("Experiment is active; command ignored.\n"));
   free (follow_spec_usr);
   free (follow_spec_cmp);
   follow_spec_usr = NULL;
@@ -2143,18 +2139,13 @@
       int ercode;
       const char *userspec = &string[1];
       size_t newstrlen = strlen (userspec) + 3;
-      char * str = (char *) malloc (newstrlen);
-      if (str)
-	{
-	  snprintf (str, newstrlen, "^%s$", userspec);
-	  assert (strlen (str) == newstrlen - 1);
-	  ercode = regcomp (&regex_desc, str, REG_EXTENDED | REG_NOSUB | REG_NEWLINE);
-	}
-      else
-	ercode = 1;
+      char * str = (char *) xmalloc (newstrlen);
+      snprintf (str, newstrlen, "^%s$", userspec);
+      assert (strlen (str) == newstrlen - 1);
+      ercode = regcomp (&regex_desc, str, REG_EXTENDED | REG_NOSUB | REG_NEWLINE);
       if (!ercode)
 	{
-	  follow_spec_usr = strdup (string);
+	  follow_spec_usr = xstrdup (string);
 	  /* Ideally, follow_spec_cmp = [serialized regex_desc], */
 	  /* so that libcollector wouldn't have to recompile it. */
 	  /* For now, just copy the regular expression into follow_spec_cmp */
@@ -2173,7 +2164,7 @@
 Coll_Ctrl::set_prof_idle (const char *string)
 {
   if (opened == 1)
-    return strdup (GTXT ("Experiment is active; command ignored.\n"));
+    return xstrdup (GTXT ("Experiment is active; command ignored.\n"));
   if (string == NULL || strlen (string) == 0 || strcmp (string, "on") == 0)
     {
       prof_idle = 1;
@@ -2191,7 +2182,7 @@
 Coll_Ctrl::set_archive_mode (const char *string)
 {
   if (opened == 1)
-    return strdup (GTXT ("Experiment is active; command ignored.\n"));
+    return xstrdup (GTXT ("Experiment is active; command ignored.\n"));
   if (string == NULL || strlen (string) == 0)
     string = "on";
   if (strcasecmp (string, "on") == 0 || strcasecmp (string, "off") == 0
@@ -2201,7 +2192,7 @@
       || strcasecmp (string, "all") == 0)
     {
       free (archive_mode);
-      archive_mode = strdup (string);
+      archive_mode = xstrdup (string);
       return NULL;
     }
   return dbe_sprintf (GTXT ("Unrecognized archive-mode parameter `%s'\n"), string);
@@ -2212,7 +2203,7 @@
 {
   const char *buf;
   if (opened == 1)
-    return strdup (GTXT ("Experiment is active; command ignored.\n"));
+    return xstrdup (GTXT ("Experiment is active; command ignored.\n"));
   if (value == 0)
     {
       sample_sig = 0;
@@ -2241,9 +2232,7 @@
   if (strncmp (string, "SIG", 3) != 0)
     {
       // no: add it
-      signame_alloc = (char *) malloc (strlen (string) + 3 + 1);
-      if (signame_alloc == NULL)
-	return -1;
+      signame_alloc = (char *) xmalloc (strlen (string) + 3 + 1);
       strcpy (signame_alloc, "SIG");
       strcpy (&signame_alloc[3], string);
       signame = signame_alloc;
@@ -2266,7 +2255,7 @@
 Coll_Ctrl::set_pauseresume_signal (int value, int resume)
 {
   if (opened == 1)
-    return strdup (GTXT ("Experiment is active; command ignored.\n"));
+    return xstrdup (GTXT ("Experiment is active; command ignored.\n"));
   if (value == 0)
     {
       pauseresume_sig = 0;
@@ -2299,7 +2288,7 @@
 Coll_Ctrl::set_debug_mode (int value)
 {
   if (opened == 1)
-    return strdup (GTXT ("Experiment is active; command ignored.\n"));
+    return xstrdup (GTXT ("Experiment is active; command ignored.\n"));
   debug_mode = value;
   return NULL;
 }
@@ -2373,7 +2362,7 @@
     }
   expno = 1;
   if (uexpt_name != NULL)
-    expt_name = strdup (uexpt_name);
+    expt_name = xstrdup (uexpt_name);
   else
     {
       // no user name -- pick a default
@@ -2382,12 +2371,12 @@
       char *stembase;
       if (expt_group == NULL)
 	{
-	  stem = strdup (default_stem);
+	  stem = xstrdup (default_stem);
 	  stembase = stem;
 	}
       else
 	{
-	  stem = strdup (expt_group);
+	  stem = xstrdup (expt_group);
 	  stem[strlen (stem) - 4] = 0;
 	  stembase = stem;
 	  // now remove any leading directory
@@ -2401,7 +2390,7 @@
 	  if (strlen (stembase) == 0)
 	    {
 	      free (stem);
-	      stem = strdup (default_stem);
+	      stem = xstrdup (default_stem);
 	      stembase = stem;
 	    }
 	}
@@ -2417,35 +2406,35 @@
   char *s = strrchr (expt_name, '/');
   if (s == NULL)
     {
-      expt_dir = strdup (".");
-      base_name = strdup (expt_name);
+      expt_dir = xstrdup (".");
+      base_name = xstrdup (expt_name);
     }
   else
     {
       expt_dir = dbe_strndup (expt_name, s - expt_name);
-      base_name = strdup (s + 1);
+      base_name = xstrdup (s + 1);
     }
 
   if (expt_dir[0] == '/')
-    store_dir = strdup (expt_dir);
+    store_dir = xstrdup (expt_dir);
   else if ((udir_name == NULL) || (udir_name[0] == 0))
     {
       if (expt_dir[0] == 0)
-	store_dir = strdup (".");
+	store_dir = xstrdup (".");
       else
-	store_dir = strdup (expt_dir);
+	store_dir = xstrdup (expt_dir);
     }
   else
     {
       /* udir_name is a non-empty string */
       if (expt_dir[0] == 0)
-	store_dir = strdup (udir_name);
+	store_dir = xstrdup (udir_name);
       else
 	store_dir = dbe_sprintf ("%s/%s", udir_name, expt_dir);
     }
   free (store_ptr);
   if (strcmp (store_dir, ".") == 0)
-    store_ptr = strdup (base_name);
+    store_ptr = xstrdup (base_name);
   else
     store_ptr = dbe_sprintf ("%s/%s", store_dir, base_name);
 
@@ -2453,7 +2442,7 @@
   if (strcmp (store_dir, prev_store_dir) != 0)
     {
       free (prev_store_dir);
-      prev_store_dir = strdup (store_dir);
+      prev_store_dir = xstrdup (store_dir);
       const char *fstype = get_fstype (store_dir);
       if (interactive && enabled && (fstype != NULL) && (nofswarn == 0))
 	sb.appendf (GTXT ("Experiment directory is set to a file system of type \"%s\",\n"
@@ -2513,7 +2502,7 @@
     return NULL;
 
   // save the name for a changed message
-  char *oldbase = strdup (base_name);
+  char *oldbase = xstrdup (base_name);
 
   // the name is of the from prefix.nnn.er; extract the value of nnn
   int version = atoi (&base_name[pcount + 1]);
@@ -2568,17 +2557,17 @@
   else
     free (oldbase);
   free (base_name);
-  base_name = strdup (newbase);
+  base_name = xstrdup (newbase);
 
   // now, reset expt_name to reflect new setting
   free (expt_name);
   if (expt_dir[0] == 0)
-    expt_name = strdup (base_name);
+    expt_name = xstrdup (base_name);
   else
     expt_name = dbe_sprintf ("%s/%s", expt_dir, base_name);
   free (store_ptr);
   if (strcmp (store_dir, ".") == 0)
-    store_ptr = strdup (base_name);
+    store_ptr = xstrdup (base_name);
   else
     store_ptr = dbe_sprintf ("%s/%s", store_dir, base_name);
   closedir (dir);
@@ -2712,7 +2701,7 @@
   char *str_signal = NULL;
   const char *buf = strsignal (signal);
   if (buf != NULL)
-    str_signal = strdup (buf);
+    str_signal = xstrdup (buf);
   return str_signal;
 }
 
@@ -2729,7 +2718,7 @@
     {
       if ((size_limit > 0))
 	return dbe_sprintf ("%d", size_limit);
-      return strdup (ipc_str_unlimited);
+      return xstrdup (ipc_str_unlimited);
     }
   if (!strncmp (control, ipc_str_time_limit, len))
     {
@@ -2743,67 +2732,67 @@
 	    }
 	  return dbe_sprintf ("0s-%ds", time_run);
 	}
-      return strdup (ipc_str_unlimited);
+      return xstrdup (ipc_str_unlimited);
     }
   if (strncmp (control, ipc_str_arch_exp, len) == 0)
-    return strdup (get_archive_mode ());
+    return xstrdup (get_archive_mode ());
   if (!strncmp (control, ipc_str_descendant, len))
     {
       switch (get_follow_mode ())
 	{
 	case FOLLOW_ON:
-	  return strdup (ipc_str_on);
+	  return xstrdup (ipc_str_on);
 	case FOLLOW_ALL:
-	  return strdup (ipc_str_on);
+	  return xstrdup (ipc_str_on);
 	case FOLLOW_NONE:
 	default:
-	  return strdup (ipc_str_off);
+	  return xstrdup (ipc_str_off);
 	}
     }
   if (!strncmp (control, ipc_str_prof_idle, len))
     {
       if (prof_idle == 0)
-	return strdup (ipc_str_off);
-      return strdup (ipc_str_on);
+	return xstrdup (ipc_str_off);
+      return xstrdup (ipc_str_on);
     }
   if (!strncmp (control, ipc_str_clkprof, len))
     {
       if (clkprof_default == 1 && clkprof_enabled == 1) // Default value
-	return strdup (ipc_str_empty);
+	return xstrdup (ipc_str_empty);
       if (clkprof_enabled == 0)
-	return strdup (ipc_str_off);
+	return xstrdup (ipc_str_off);
       if ((clkprof_timer > 0))
 	return dbe_sprintf ("%d", clkprof_timer / 1000);
-      return strdup (ipc_str_internal_error);
+      return xstrdup (ipc_str_internal_error);
     }
   if (!strncmp (control, ipc_str_hwcprof, len))
     {
       if (hwcprof_enabled_cnt == 0)
-	return strdup (ipc_str_off);
+	return xstrdup (ipc_str_off);
       if (hwc_string != NULL)
 	return dbe_sprintf ("on\n%s", hwc_string);
-      return strdup (ipc_str_on); // XXX need more details?
+      return xstrdup (ipc_str_on); // XXX need more details?
     }
   if (!strncmp (control, ipc_str_javaprof, len))
     {
       if (java_mode == 0)
-	return strdup (ipc_str_off);
-      return strdup (ipc_str_on);
+	return xstrdup (ipc_str_off);
+      return xstrdup (ipc_str_on);
     }
   if (!strncmp (control, ipc_str_sample, len))
     {
       if (sample_default == 1 && sample_period == 1) // Default value
-	return strdup (ipc_str_empty);
+	return xstrdup (ipc_str_empty);
       if (sample_period == 0)
-	return strdup (ipc_str_off);
+	return xstrdup (ipc_str_off);
       if (sample_period > 0)
 	return dbe_sprintf ("%d", sample_period);
-      return strdup (ipc_str_internal_error);
+      return xstrdup (ipc_str_internal_error);
     }
   if (!strncmp (control, ipc_str_sample_sig, len))
     {
       if (sample_sig == 0)
-	return strdup (ipc_str_off);
+	return xstrdup (ipc_str_off);
       char *str_signal = find_signal_name (sample_sig);
       if (str_signal != NULL)
 	return str_signal;
@@ -2812,7 +2801,7 @@
   if (!strncmp (control, ipc_str_pause_resume_sig, len))
     {
       if (pauseresume_sig == 0)
-	return strdup (ipc_str_off);
+	return xstrdup (ipc_str_off);
       char *str_signal = find_signal_name (pauseresume_sig);
       if (str_signal != NULL)
 	return str_signal;
@@ -2821,34 +2810,34 @@
   if (!strncmp (control, ipc_str_synctrace, len))
     {
       if (synctrace_enabled == 0)
-	return strdup (ipc_str_off);
+	return xstrdup (ipc_str_off);
       if (synctrace_thresh < 0)
-	return strdup ("on\nthreshold: calibrate");
+	return xstrdup ("on\nthreshold: calibrate");
       if (synctrace_thresh == 0)
-	return strdup ("on\nthreshold: all");
+	return xstrdup ("on\nthreshold: all");
       return dbe_sprintf ("on\nthreshold: %d", synctrace_thresh);
     }
   if (!strncmp (control, ipc_str_heaptrace, len))
     {
       if (heaptrace_mode == NULL)
-	return strdup (ipc_str_off);
-      return strdup (ipc_str_on);
+	return xstrdup (ipc_str_off);
+      return xstrdup (ipc_str_on);
     }
   if (!strncmp (control, ipc_str_iotrace, len))
     {
       if (iotrace_enabled == 0)
-	return strdup (ipc_str_off);
-      return strdup (ipc_str_on);
+	return xstrdup (ipc_str_off);
+      return xstrdup (ipc_str_on);
     }
   if (!strncmp (control, ipc_str_count, len))
     {
       if (count_enabled == 0)
-	return strdup (ipc_str_off);
+	return xstrdup (ipc_str_off);
       if (count_enabled < 0)
-	return strdup ("on\nstatic");
-      return strdup (ipc_str_on);
+	return xstrdup ("on\nstatic");
+      return xstrdup (ipc_str_on);
     }
-  return strdup (ipc_str_unknown_control);
+  return xstrdup (ipc_str_unknown_control);
 }
 
 /**
@@ -2914,7 +2903,7 @@
     return set_sample_signal (find_sig (value));
   if (!strncmp (control, ipc_str_pause_resume_sig, len))
     {
-      char *str_signal = strdup (value);
+      char *str_signal = xstrdup (value);
       char *str_state = strchr (str_signal, (int) '\n');
       if (str_state != NULL)
 	{
@@ -2936,7 +2925,7 @@
     return set_iotrace (value);
   if (!strncmp (control, ipc_str_count, len))
     return set_count (value);
-  return strdup (ipc_str_unknown_control);
+  return xstrdup (ipc_str_unknown_control);
 }
 
 /**
@@ -2957,7 +2946,7 @@
     }
   if (!strncmp (control, ipc_str_arch_exp, len))
     {
-      archive_mode = strdup ("on");
+      archive_mode = xstrdup ("on");
       return NULL;
     }
   if (!strncmp (control, ipc_str_descendant, len))
@@ -3031,12 +3020,12 @@
       Nflag = 0;
       return NULL;
     }
-  return strdup (ipc_str_unknown_control);
+  return xstrdup (ipc_str_unknown_control);
 }
 
 void
 Coll_Ctrl::set_project_home (char *s)
 {
   if (s)
-    project_home = strdup (s);
+    project_home = xstrdup (s);
 }
diff --git a/gprofng/src/comp_com.c b/gprofng/src/comp_com.c
index 79d14eb..636bcf3 100644
--- a/gprofng/src/comp_com.c
+++ b/gprofng/src/comp_com.c
@@ -25,6 +25,7 @@
 #include <values.h>
 #include <assert.h>
 
+#include "libiberty.h"
 #include "comp_com.h"
 
 /*
@@ -839,9 +840,7 @@
     return;
   done = 1;
   size = ccm_vis_index ((COMPMSG_ID) (CCMV_BASIC << 8));
-  ccm_attrs = (Ccm_Attr_t *) calloc (size, sizeof (Ccm_Attr_t));
-  if (ccm_attrs == NULL)
-    exit (1);
+  ccm_attrs = (Ccm_Attr_t *) xcalloc (size, sizeof (Ccm_Attr_t));
   vindex = ccm_vis_index (CCM_MODDATE);
   ccm_attrs[vindex].vis = CCMV_VER | CCMV_BASIC | CCMV_UNIMPL;
   ccm_attrs[vindex].name = "CCM_MODDATE";
diff --git a/gprofng/src/count.cc b/gprofng/src/count.cc
index 41fa092..42f990e 100644
--- a/gprofng/src/count.cc
+++ b/gprofng/src/count.cc
@@ -33,6 +33,7 @@
 #include <collctrl.h>
 #include <StringBuilder.h>
 #include "collect.h"
+#include "libiberty.h"
 
 /* get_count_data -- format exec of bit to do the real work */
 void
@@ -44,7 +45,7 @@
 
   // reserve space for original args, plus 30 arguments to bit
   nargs = origargc + 30;
-  char **narglist = (char **) calloc (nargs, sizeof (char *));
+  char **narglist = (char **) xcalloc (nargs, sizeof (char *));
   arglist = narglist;
 
   // construct the command for bit
@@ -57,7 +58,7 @@
       if (stat (command, &statbuf) == -1)
 	{
 	  // if bit command does not exist there
-	  char *first_look = strdup (command);
+	  char *first_look = xstrdup (command);
 	  snprintf (command, sizeof (command), NTXT ("%s"), run_dir);
 	  s = strstr (command, NTXT ("/bin"));
 	  snprintf (s, sizeof (command) - (s - command), NTXT ("/prod/bin/bit"));
@@ -69,7 +70,7 @@
 	    }
 	  free (first_look);
 	}
-      *arglist++ = strdup (command);
+      *arglist++ = xstrdup (command);
     }
   else
     {
diff --git a/gprofng/src/dbe_hwc.h b/gprofng/src/dbe_hwc.h
index 951ebaf..c303ac8 100644
--- a/gprofng/src/dbe_hwc.h
+++ b/gprofng/src/dbe_hwc.h
@@ -24,8 +24,14 @@
 #include <stdio.h>
 #include <stdarg.h>
 
+#include "libiberty.h"
 #include "i18n.h"
 
+#define malloc(s) xmalloc (s)
+#define realloc(p, s) xrealloc (p, s)
+#define calloc(n, s) xcalloc (n, s)
+#define strdup(s) xstrdup (s)
+
 #define HWC_TRACELEVEL -1
 #if HWC_TRACELEVEL < 0
 #define TprintfT(x1,...)
diff --git a/gprofng/src/dbe_memmgr.c b/gprofng/src/dbe_memmgr.c
deleted file mode 100644
index 8c451cf..0000000
--- a/gprofng/src/dbe_memmgr.c
+++ /dev/null
@@ -1,118 +0,0 @@
-/* Copyright (C) 2021-2024 Free Software Foundation, Inc.
-   Contributed by Oracle.
-
-   This file is part of GNU Binutils.
-
-   This program is free software; you can redistribute it and/or modify
-   it under the terms of the GNU General Public License as published by
-   the Free Software Foundation; either version 3, or (at your option)
-   any later version.
-
-   This program is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-   GNU General Public License for more details.
-
-   You should have received a copy of the GNU General Public License
-   along with this program; if not, write to the Free Software
-   Foundation, 51 Franklin Street - Fifth Floor, Boston,
-   MA 02110-1301, USA.  */
-
-#include "config.h"
-#include <dlfcn.h>
-#include "util.h"
-
-#define CHECK_OUT_OF_MEM(ptr, size) if (ptr == NULL) err_out_of_memory(size)
-
-/* Report Out of Memory error and exit */
-static void
-err_out_of_memory (unsigned nbytes)
-{
-  char *nm = get_prog_name (1);
-  if (nm)
-    fprintf (stderr, GTXT ("%s: Error: Memory capacity exceeded.\n"), nm);
-  else
-    fprintf (stderr, GTXT ("Error: Memory capacity exceeded.\n"));
-  fprintf (stderr, GTXT ("  Requested %u bytes.\n"), nbytes);
-  exit (16);
-}
-
-#define CALL_REAL(x) (__real_##x)
-#define NULL_PTR(x) ( __real_##x == NULL )
-
-static void *(*__real_malloc)(size_t) = NULL;
-static void (*__real_free)(void *) = NULL;
-static void *(*__real_realloc)(void *, size_t) = NULL;
-static void *(*__real_calloc)(size_t, size_t) = NULL;
-static char *(*__real_strdup)(const char*) = NULL;
-static volatile int in_init = 0;
-
-static int
-init_heap_intf ()
-{
-  in_init = 1;
-  __real_malloc = (void*(*)(size_t))dlsym (RTLD_NEXT, "malloc");
-  __real_free = (void(*)(void *))dlsym (RTLD_NEXT, "free");
-  __real_realloc = (void*(*)(void *, size_t))dlsym (RTLD_NEXT, "realloc");
-  __real_calloc = (void*(*)(size_t, size_t))dlsym (RTLD_NEXT, "calloc");
-  __real_strdup = (char*(*)(const char*))dlsym (RTLD_NEXT, "strdup");
-  in_init = 0;
-  return 0;
-}
-
-/* --------------------------------------------------------------------------- */
-/* libc's memory management functions substitutions */
-
-/* Allocate memory and make sure we got some */
-void *
-malloc (size_t size)
-{
-  if (NULL_PTR (malloc))
-    init_heap_intf ();
-  void *ptr = CALL_REAL (malloc)(size);
-  CHECK_OUT_OF_MEM (ptr, size);
-  return ptr;
-}
-
-
-/* Implement a workaround for a libdl recursion problem */
-void *
-calloc (size_t nelem, size_t size)
-{
-  if (NULL_PTR (calloc))
-    {
-      /* If a program is linked with libpthread then the following
-       * calling sequence occurs:
-       * init_heap_intf -> dlsym -> calloc -> malloc -> init_heap_intf
-       * We break some performance improvement in libdl by returning
-       * NULL but preserve functionality.
-       */
-      if (in_init)
-	return NULL;
-      init_heap_intf ();
-    }
-  return CALL_REAL (calloc)(nelem, size);
-}
-
-/* Free the storage associated with data */
-void
-free (void *ptr)
-{
-  if (ptr == NULL)
-    return;
-  if (NULL_PTR (free))
-    init_heap_intf ();
-  CALL_REAL (free)(ptr);
-  return;
-}
-
-/* Reallocate buffer */
-void *
-realloc (void *ptr, size_t size)
-{
-  if (NULL_PTR (realloc))
-    init_heap_intf ();
-  ptr = CALL_REAL (realloc)(ptr, size);
-  CHECK_OUT_OF_MEM (ptr, size);
-  return ptr;
-}
diff --git a/gprofng/src/envsets.cc b/gprofng/src/envsets.cc
index 70510fb..b7d3d9d 100644
--- a/gprofng/src/envsets.cc
+++ b/gprofng/src/envsets.cc
@@ -136,7 +136,7 @@
 collect::putenv_libcollector_ld_misc ()
 {
 #if 0 // XXX 1 turns on LD_DEBUG
-  putenv (strdup ("LD_DEBUG=audit,bindings,detail"));
+  putenv (xstrdup ("LD_DEBUG=audit,bindings,detail"));
 #endif
   // workaround to have the dynamic linker use absolute names
   if (add_env (dbe_strdup ("LD_ORIGIN=yes")))
@@ -156,7 +156,7 @@
   if (ev)
     { /* GPROFNG_PRELOAD_LIBDIRS is used only in the gprofng testing.
        * Use these directories first.  */
-      ev = strdup (ev);
+      ev = xstrdup (ev);
       for (char *s = ev; s;)
 	{
 	  char *s1 = strchr (s, ':');
@@ -246,7 +246,7 @@
     {
       char *old_sp = sp_preload_list[ii];
       if (old_sp == NULL)
-	sp_preload_list[ii] = strdup (lib);
+	sp_preload_list[ii] = xstrdup (lib);
       else
 	{
 	  sp_preload_list[ii] = dbe_sprintf ("%s %s", old_sp, lib);
diff --git a/gprofng/src/gp-archive.cc b/gprofng/src/gp-archive.cc
index ff6816d..00a4450 100644
--- a/gprofng/src/gp-archive.cc
+++ b/gprofng/src/gp-archive.cc
@@ -528,7 +528,7 @@
 	  if (dseen)
 	    fprintf (stderr, GTXT ("Warning: option -d was specified several times. Last value is used.\n"));
 	  free (common_archive_dir);
-	  common_archive_dir = strdup (optarg);
+	  common_archive_dir = xstrdup (optarg);
 	  dseen = 1;
 	  break;
 	case 'q':
@@ -546,7 +546,7 @@
 	  if (rseen)
 	    fprintf (stderr, GTXT ("Warning: option -r was specified several times. Last value is used.\n"));
 	  free (common_archive_dir);
-	  common_archive_dir = strdup (optarg);
+	  common_archive_dir = xstrdup (optarg);
 	  use_relative_path = 1;
 	  rseen = 1;
 	  break;
@@ -667,7 +667,7 @@
     }
   if (opts->size () > 0)
     {
-      char **arr = (char **) malloc (sizeof (char *) *opts->size ());
+      char **arr = (char **) xmalloc (sizeof (char *) *opts->size ());
       for (long i = 0; i < opts->size (); i++)
 	arr[i] = opts->get (i);
       if (-1 == check_args (opts->size (), arr))
@@ -697,5 +697,6 @@
 int
 main (int argc, char *argv[])
 {
+  xmalloc_set_program_name (argv[0]);
   return catch_out_of_memory (real_main, argc, argv);
 }
diff --git a/gprofng/src/gp-collect-app.cc b/gprofng/src/gp-collect-app.cc
index c80c1b0..4bf9f07 100644
--- a/gprofng/src/gp-collect-app.cc
+++ b/gprofng/src/gp-collect-app.cc
@@ -63,6 +63,7 @@
 int
 main (int argc, char *argv[])
 {
+  xmalloc_set_program_name (argv[0]);
   // disable any alarm that might be pending
   int r = alarm (0);
   if (r != 0)
diff --git a/gprofng/src/gp-display-src.cc b/gprofng/src/gp-display-src.cc
index 24af375..5d885b5 100644
--- a/gprofng/src/gp-display-src.cc
+++ b/gprofng/src/gp-display-src.cc
@@ -89,6 +89,7 @@
 int
 main (int argc, char *argv[])
 {
+  xmalloc_set_program_name (argv[0]);
   return catch_out_of_memory (real_main, argc, argv);
 }
 
@@ -216,7 +217,7 @@
       else if ((fname = strstr (cmd, "~")) != NULL && home != NULL)
 	cmdpath = dbe_sprintf ("/home/%s", fname + 1);
       else
-	cmdpath = strdup (cmd);
+	cmdpath = xstrdup (cmd);
       new_file = fopen (cmdpath, "w");
       if (new_file == NULL)
 	{
@@ -666,7 +667,7 @@
   Vector<Histable*> *module_lst;
 
   // Construct the Segment structure
-  char *path = strdup (exe);
+  char *path = xstrdup (exe);
   lo = dbeSession->createLoadObject (path);
   if (NULL == lo->dbeFile->find_file (lo->dbeFile->get_name ()))
     {
diff --git a/gprofng/src/gp-display-text.cc b/gprofng/src/gp-display-text.cc
index 3d7774a..ad60e76 100644
--- a/gprofng/src/gp-display-text.cc
+++ b/gprofng/src/gp-display-text.cc
@@ -112,6 +112,7 @@
 int
 main (int argc, char *argv[])
 {
+  xmalloc_set_program_name (argv[0]);
   er_print *erprint;
   int ind = 1;
   if (argc > ind && *argv[ind] == '-')
@@ -533,7 +534,7 @@
   if (!got_err)
     { // good coverage string
       free (cov_string);
-      cov_string = strdup (names);
+      cov_string = xstrdup (names);
     }
   else
     { // bad, restore original coverage
@@ -1662,9 +1663,9 @@
   for (index = 0; index < size; index++)
     {
       lists[0][index] = dbe_sprintf (NTXT ("%d"), index + 1);
-      lists[1][index] = strdup (dbev->get_exp_enable (index) ? GTXT ("yes") : GTXT ("no"));
+      lists[1][index] = xstrdup (dbev->get_exp_enable (index) ? GTXT ("yes") : GTXT ("no"));
       lists[2][index] = dbe_sprintf (NTXT ("%d"), dbeSession->get_exp (index)->getPID ());
-      lists[3][index] = strdup (dbeSession->get_exp (index)->get_expt_name ());
+      lists[3][index] = xstrdup (dbeSession->get_exp (index)->get_expt_name ());
     }
   disp_list (4, size, align, header, lists);
   for (int i = 0; i < 4; i++)
@@ -1834,9 +1835,9 @@
 	  continue;
       }
     bool expand = dbev->get_lo_expand (lo->seg_idx);
-    lists[0][new_index] = strdup (expand ? GTXT ("yes") : GTXT ("no"));
+    lists[0][new_index] = xstrdup (expand ? GTXT ("yes") : GTXT ("no"));
     lists[1][new_index] = dbe_sprintf (NTXT ("%lld"), (ll_t) lo->get_size ());
-    lists[2][new_index] = strdup (lo->get_pathname ());
+    lists[2][new_index] = xstrdup (lo->get_pathname ());
     new_index++;
   }
 
@@ -1903,7 +1904,7 @@
 	continue;
       lists[0][new_index] = dbe_sprintf (NTXT ("%d"), index + 1);
       pattern = dbev->get_exp_enable (index) ? select->get_pattern () : NULL;
-      lists[1][new_index] = strdup (pattern && *pattern ? pattern : GTXT ("none"));
+      lists[1][new_index] = xstrdup (pattern && *pattern ? pattern : GTXT ("none"));
       lists[2][new_index] = dbe_sprintf (NTXT ("%lld"), (ll_t) select->nelem ());
       lists[3][new_index] = select->get_status ();
       new_index++;
@@ -2822,7 +2823,7 @@
       else if ((fname = strstr (cmd, NTXT ("~"))) != NULL && home != NULL)
 	path = dbe_sprintf (NTXT ("/home/%s"), fname + 1);
       else
-	path = strdup (cmd);
+	path = xstrdup (cmd);
       new_file = fopen (path, append ? NTXT ("a") : NTXT ("w"));
       if (new_file == NULL)
 	{
diff --git a/gprofng/src/gprofng.cc b/gprofng/src/gprofng.cc
index a59fdb2..385b097 100644
--- a/gprofng/src/gprofng.cc
+++ b/gprofng/src/gprofng.cc
@@ -49,6 +49,7 @@
 int
 main (int argc, char *argv[])
 {
+  xmalloc_set_program_name (argv[0]);
   Gprofng *gprofng = new Gprofng (argc, argv);
   gprofng->start();
   delete gprofng;
@@ -228,7 +229,7 @@
 
   const char *aname = app_names[first].app_name;
 
-  char **arr = (char **) malloc ((argc + 5) * sizeof (char *));
+  char **arr = (char **) xmalloc ((argc + 5) * sizeof (char *));
   char *pname = get_name ();
   char *exe_name = dbe_sprintf ("%.*s%s",
 			(int) (get_basename (pname) - pname), pname, aname);
diff --git a/gprofng/src/ipc.cc b/gprofng/src/ipc.cc
index d5f3771..3e706db 100644
--- a/gprofng/src/ipc.cc
+++ b/gprofng/src/ipc.cc
@@ -28,6 +28,7 @@
 #include <sys/wait.h>   // wait
 #include <locale.h>
 
+#include "libiberty.h"
 #include "DbeApplication.h"
 #include "Histable.h"
 #include "ipcio.h"
@@ -2686,7 +2687,7 @@
   if (er_print_catch_crash)
     {
       /* reserve memory for fatal error processing */
-      fatalErrorDynamicMemory = (char *) malloc (4 * 1024 * 1024); // reserve 4 MB
+      fatalErrorDynamicMemory = (char *) xmalloc (4 * 1024 * 1024); // reserve 4 MB
       /* install a handler for SIGABRT */
       ipc_request_trace (TRACE_LVL_1, "Installing SIGABRT handler to send message to analyzer\n");
       sigemptyset (&act.sa_mask);
diff --git a/gprofng/src/ipcio.cc b/gprofng/src/ipcio.cc
index 29d699d..8ff16d5 100644
--- a/gprofng/src/ipcio.cc
+++ b/gprofng/src/ipcio.cc
@@ -63,7 +63,7 @@
   channelID = chID;
   status = INITIALIZED;
   idx = 0;
-  buf = (char *) malloc (size);
+  buf = (char *) xmalloc (size);
   cancelImmediate = false;
 }
 
@@ -149,7 +149,7 @@
       ipc_trace ("  readSVal: <NULL>\n");
       return NULL;
     }
-  char *str = (char *) malloc (len + 1);
+  char *str = (char *) xmalloc (len + 1);
   char *s = str;
   *s = (char) 0;
   while (len--)
diff --git a/gprofng/src/util.cc b/gprofng/src/util.cc
index 228140b..e491999 100644
--- a/gprofng/src/util.cc
+++ b/gprofng/src/util.cc
@@ -35,7 +35,7 @@
 #include "dbe_structs.h"
 #include "StringBuilder.h"
 #include "StringMap.h"      // For directory names
-#include "Application.h"    // Only for get_prog_name
+#include "Application.h"
 #include "vec.h"
 
 void
@@ -340,7 +340,7 @@
 {
   // get an input line, no size limit
   int line_sz = 128; // starting size
-  char *line = (char *) malloc (line_sz);
+  char *line = (char *) xmalloc (line_sz);
 
   // read as much of the line as will fit in memory
   line[0] = 0;
@@ -353,7 +353,7 @@
 	  if (len == 0 || line[len - 1] == '\n')
 	    break;
 	  // increase the buffer
-	  char *lineNew = (char *) malloc (2 * line_sz);
+	  char *lineNew = (char *) xmalloc (2 * line_sz);
 	  strncpy (lineNew, line, line_sz);
 	  lineNew[line_sz] = '\0';
 	  free (line);
@@ -531,7 +531,7 @@
   int ch = '`';
   if (in_str == NULL)
     return NULL;
-  char *copy = strdup (in_str);
+  char *copy = xstrdup (in_str);
   char *p = strchr (copy, ch);
   if (p != NULL)
     {
@@ -556,7 +556,7 @@
 	  return NULL;
 	}
       free (*fcontext);
-      *fcontext = strdup (p);
+      *fcontext = xstrdup (p);
     }
   return copy;
 }
@@ -778,24 +778,11 @@
 }
 
 char *
-get_prog_name (int basename)
-{
-  char *nm = NULL;
-  if (theApplication)
-    {
-      nm = theApplication->get_name ();
-      if (nm && basename)
-	nm = get_basename (nm);
-    }
-  return nm;
-}
-
-char *
 dbe_strndup (const char *str, size_t len)
 {
   if (str == NULL)
     return NULL;
-  char *s = (char *) malloc (len + 1);
+  char *s = (char *) xmalloc (len + 1);
   strncpy (s, str, len);
   s[len] = '\0';
   return s;
@@ -815,11 +802,11 @@
     {
       if (buf_size <= 1)
 	buffer[0] = 0;
-      return strdup (buffer);
+      return xstrdup (buffer);
     }
 
   va_start (vp, fmt);
-  char *buf = (char *) malloc (buf_size);
+  char *buf = (char *) xmalloc (buf_size);
   vsnprintf (buf, buf_size, fmt, vp);
   va_end (vp);
   return buf;
@@ -843,7 +830,7 @@
     }
 
   va_start (vp, fmt);
-  char *buf = (char *) malloc (buf_size);
+  char *buf = (char *) xmalloc (buf_size);
   vsnprintf (buf, buf_size, fmt, vp);
   va_end (vp);
   ssize_t val = write (f, buf, strlen (buf));
@@ -1064,35 +1051,32 @@
       if (theApplication->get_number_of_worker_threads () > 0)
 	{
 	  struct worker_thread_info *wt_info;
-	  wt_info = (worker_thread_info *) calloc (1, sizeof (worker_thread_info));
-	  if (wt_info != NULL)
+	  wt_info = (worker_thread_info *) xcalloc (1, sizeof (worker_thread_info));
+	  int res = dbe_dispatch_on_thread (path, wt_info);
+	  if (THREAD_FINISHED == res)
 	    {
-	      int res = dbe_dispatch_on_thread (path, wt_info);
-	      if (THREAD_FINISHED == res)
+	      int st = wt_info->result;
+	      extract_and_save_dirname (path, st);
+	      if (st == 0 && file_only)
+		if (S_ISREG ((wt_info->statbuf).st_mode) == 0)
+		  st = -1; // It is not a regular file
+	      if (sbuf != NULL)
+		*sbuf = wt_info->statbuf;
+	      free (wt_info);
+	      return st;
+	    }
+	  else
+	    {
+	      if (THREAD_CANCEL == res)
 		{
-		  int st = wt_info->result;
-		  extract_and_save_dirname (path, st);
-		  if (st == 0 && file_only)
-		    if (S_ISREG ((wt_info->statbuf).st_mode) == 0)
-		      st = -1; // It is not a regular file
-		  if (sbuf != NULL)
-		    *sbuf = wt_info->statbuf;
-		  free (wt_info);
-		  return st;
+		  // Worker thread hung. Cannot free wt_info.
+		  // Allocated memory will be freed by worker thread.
+		  // save directory
+		  extract_and_save_dirname (path, 1);
+		  return 1; // stat64 failed
 		}
-	      else
-		{
-		  if (THREAD_CANCEL == res)
-		    {
-		      // Worker thread hung. Cannot free wt_info.
-		      // Allocated memory will be freed by worker thread.
-		      // save directory
-		      extract_and_save_dirname (path, 1);
-		      return 1; // stat64 failed
-		    }
-		  else  // THREAD_NOT_CREATED - continue on current thread
-		    free (wt_info);
-		}
+	      else  // THREAD_NOT_CREATED - continue on current thread
+		free (wt_info);
 	    }
 	}
     }
diff --git a/gprofng/src/util.h b/gprofng/src/util.h
index cbbc2f7..ca2480b 100644
--- a/gprofng/src/util.h
+++ b/gprofng/src/util.h
@@ -27,6 +27,7 @@
 #include <sys/stat.h>
 #include <stdint.h>
 
+#include "libiberty.h"
 #include "gp-defs.h"
 #include "gp-time.h"
 #include "i18n.h"
@@ -105,7 +106,7 @@
 inline char *
 dbe_strdup (const char *str)
 {
-  return str ? strdup (str) : NULL;
+  return str ? xstrdup (str) : NULL;
 }
 
 inline long
@@ -170,7 +171,6 @@
   char *canonical_path (char *path);
   char *get_relative_path (char *name);
   char *get_relative_link (const char *path_to, const char *path_from);
-  char *get_prog_name (int basename);
   char *dbe_strndup (const char *str, size_t len);
   int dbe_stat (const char *path, dbe_stat_t *sbuf);
   int dbe_stat_file (const char *path, dbe_stat_t *sbuf);
diff --git a/gprofng/src/vec.h b/gprofng/src/vec.h
index 7d5be1f..4ee4642 100644
--- a/gprofng/src/vec.h
+++ b/gprofng/src/vec.h
@@ -25,6 +25,7 @@
 #include <inttypes.h>
 #include <string.h>
 #include <stdlib.h>
+#include "libiberty.h"
 
 // This package implements a vector of items.
 
@@ -222,7 +223,7 @@
 {
   count = 0;
   limit = sz > 0 ? sz : KILOCHUNK; // was 0;
-  data = limit ? (ITEM *) malloc (sizeof (ITEM) * limit) : NULL;
+  data = limit ? (ITEM *) xmalloc (sizeof (ITEM) * limit) : NULL;
   sorted = false;
 }
 
@@ -241,7 +242,7 @@
       else
 	limit = limit * 2;
     }
-  data = (ITEM *) realloc (data, limit * sizeof (ITEM));
+  data = (ITEM *) xrealloc (data, limit * sizeof (ITEM));
 }
 
 template <typename ITEM> void
@@ -269,7 +270,7 @@
   vector = new Vector<ITEM>;
   vector->count = count;
   vector->limit = limit;
-  vector->data = (ITEM *) malloc (sizeof (ITEM) * limit);
+  vector->data = (ITEM *) xmalloc (sizeof (ITEM) * limit);
   (void) memcpy ((char *) vector->data, (char *) data, sizeof (ITEM) * count);
   return vector;
 }