Ignore:
Timestamp:
Mar 18, 2006, 2:45:48 AM (19 years ago)
Author:
bird
Message:

#70: Demangle symbol names in debug info. (thanks to Yuri)

Location:
branches/libc-0.6/src/emx
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • branches/libc-0.6/src/emx/ChangeLog.LIBC

    r2649 r2650  
    22
    33TODO: open replace on RAMFS fails with error 32!
     4
     52006-03-17: knut st. osmundsen <bird-gccos2-spam@anduin.net>
     6    - emxomf:
     7        o #70: Demangle symbol names in debug info. (thanks to Yuri)
    48
    592006-03-14: knut st. osmundsen <bird-gccos2-spam@anduin.net>
  • branches/libc-0.6/src/emx/src/emxomf/emxomf.smak

    r1183 r2650  
    99.TCF    := $(CFLAGS.DEF.VERSION)
    1010.TDEP   := @O@libomflib$A
     11.TLDF   := -liberty
    1112include mkexe.smak
    1213
  • branches/libc-0.6/src/emx/src/emxomf/stabshll.c

    r1885 r2650  
    2020Boston, MA 02111-1307, USA.  */
    2121//#define HLL_DEBUG 1
     22
     23#define DEMANGLE_PROC_NAMES 1
    2224
    2325/*******************************************************************************
     
    3133#include <alloca.h>
    3234#include <ctype.h>
     35#ifdef DEMANGLE_PROC_NAMES
     36# include <demangle.h>
     37#endif
    3338#include "defs.h"
    3439#include "emxomf.h"
     
    22252230                  if (!parse_mangled_args ())
    22262231                    goto syntax;
    2227                   tf->mnglname = strpool_addn(str_pool, pszMangled, parse_ptr - pszMangled - 1); /* ASSUMES not extra spaces! */
     2232                  tf->mnglname = strpool_addn(str_pool, pszMangled, parse_ptr - pszMangled - 1); /* ASSUMES no extra spaces! */
    22282233                  tf->flags = parse_visibility () | MEMBER_FUNCTION;
    22292234                  switch (*parse_ptr)
     
    33153320  struct relocation_info r;
    33163321  const char *str, *p, *p2;
    3317   const char *name;
    3318   int n,                                /* size of name. */
    3319       ti,
    3320       ticlass;
     3322  const char *name, *mnglname;
     3323#ifdef DEMANGLE_PROC_NAMES
     3324  char *pszFree;
     3325#endif
     3326  size_t cchName, cchMnglName;
     3327  int ti, ticlass;
    33213328
    33223329  str = str_ptr + symbol->n_un.n_strx;
     
    33243331  if (p == NULL)
    33253332    abort ();
    3326   n = p - str;
    3327 
    3328   /** @todo name demangling */
    3329   name = strpool_addn (str_pool, str, n);
     3333  cchName = cchMnglName = p - str;
     3334  name = mnglname = strpool_addn (str_pool, str, cchMnglName);
    33303335  proc_start_addr = symbol->n_value;
     3336
     3337#ifdef DEMANGLE_PROC_NAMES
     3338  /* demangle the name */
     3339  pszFree = cplus_demangle (mnglname, DMGL_ANSI | DMGL_PARAMS);
     3340  if (!pszFree && (*mnglname == '_' || *mnglname == '*'))
     3341    pszFree = cplus_demangle (mnglname + 1, DMGL_ANSI | DMGL_PARAMS);
     3342  if (pszFree)
     3343    {
     3344      cchName = strlen (pszFree);
     3345      name = pszFree;
     3346    }
     3347  else if (*mnglname == '*')
     3348    {
     3349      cchName--;
     3350      name++;
     3351    }
     3352#endif
    33313353
    33323354  /* now let's see if there is a memfunc for this name. */
    33333355  for (t1 = type_head; t1; t1 = t1->next)
    33343356    if (    t1->tag == ty_memfunc
    3335         &&  t1->d.memfunc.mnglname == name)
     3357        &&  t1->d.memfunc.mnglname == mnglname)
    33363358      break;
    33373359
     
    33583380                       */
    33593381                      /** @todo: the string parsing still is a bit spooky. */
    3360                       for (p2 = p; (p2 = strstr (p2, name)) != NULL; p2 += n)
    3361                         if (p2[-1] == ':' && p2[n] == ';')
     3382                      for (p2 = p; (p2 = strstr (p2, mnglname)) != NULL; p2 += cchMnglName)
     3383                        if (p2[-1] == ':' && p2[cchMnglName] == ';')
    33623384                        {
    33633385                            int stab = atoi (&p[3]);
     
    33733395          if (ticlass < 0)
    33743396            {
    3375               warning (" Can't figure out which class method '%s' is a member of!", name);
     3397              warning (" Can't figure out which class method '%s' is a member of!", mnglname);
    33763398              ticlass = 0;
    33773399            }
     
    34113433      make_type (t2, &ti);
    34123434
    3413       sst_start (cplusplus_flag || n > 255 ? SST_CPPproc : SST_proc);
     3435      sst_start (cplusplus_flag || cchName > 255 ? SST_CPPproc : SST_proc);
    34143436      r.r_address = sst.size;
    34153437      buffer_dword (&sst, symbol->n_value); /* Segment offset */
     
    34213443      buffer_word (&sst, 0);        /* Class type (for member functions) */
    34223444      buffer_byte (&sst, 8);        /* 32-bit near */
    3423       if (cplusplus_flag || n > 255)
     3445      if (cplusplus_flag || cchName > 255)
    34243446        buffer_enc (&sst, name);    /* Proc name */
    34253447      else
     
    34343456  buffer_mem (&sst_reloc, &r, sizeof (r));
    34353457  set_hll_type (symbol - sym_ptr, ti);
     3458
     3459#ifdef DEMANGLE_PROC_NAMES
     3460  /* free the demangled name. */
     3461  free (pszFree);
     3462#endif
    34363463}
    34373464
Note: See TracChangeset for help on using the changeset viewer.