Opened 18 years ago

Closed 18 years ago

Last modified 18 years ago

#70 closed defect (fixed)

Demangle function names for omf debug info

Reported by: Yuri Dario Owned by: bird
Priority: normal Milestone: libc-0.6.1
Component: emx Version: 0.6
Severity: normal Keywords:
Cc:

Description

This code is courtesy of froloff and slightly modified by me.

Index: emxomf.smak
===================================================================
--- emxomf.smak	(revision 2592)
+++ emxomf.smak	(working copy)
@@ -8,6 +8,7 @@
 .TSRC	:= $(addprefix src/emxomf/,emxomf.c stabshll.c grow.c)
 .TCF	:= $(CFLAGS.DEF.VERSION)
 .TDEP	:= @O@libomflib$A
+.TLDF	:= -liberty
 include mkexe.smak
 
 .TARGET	:= emxomfar.exe
Index: stabshll.c
===================================================================
--- stabshll.c	(revision 2592)
+++ stabshll.c	(working copy)
@@ -35,6 +35,7 @@
 #include "grow.h"
 #include "stabshll.h"
 
+#include <demangle.h>
 
 /*******************************************************************************
 *   Defined Constants And Macros                                               *
@@ -3325,8 +3326,18 @@
     abort ();
   n = p - str;
 
-  /** @todo name demangling */
-  name = strpool_addn (str_pool, str, n);
+  {
+     char mangled[1024];
+     char* demangled;
+     memcpy(mangled, str, n);
+     mangled[n]= '\0';
+     demangled = cplus_demangle (mangled, DMGL_ANSI | DMGL_PARAMS);
+     if (demangled != NULL)
+      name = strpool_addn (str_pool, demangled, strlen(demangled));
+    else
+      name = strpool_addn (str_pool, str, n);
+  }
+
   proc_start_addr = symbol->n_value;
 
   /* now let's see if there is a memfunc for this name. */

Change History (2)

comment:1 Changed 18 years ago by bird

Resolution: fixed
Status: newclosed

This isn't right, it breaks the for loop just below, which is looking for a C++ member function. I'll try get it right.

comment:2 Changed 18 years ago by bird

The patch was also leaking memory, doing an unnecessary copy and adding a potential buffer overrun. But, it's all fixed and committed. Only limited testing has been performed thus far. Will try with mozilla later.

Note: See TracTickets for help on using tickets.