allow building GDB with Python support on MinGW
[deliverable/binutils-gdb.git] / binutils / prdbg.c
index 301c15284069eef5e76b46bd8599c31c994a4bae..78a8fc7511ffc9a971d7eb4191c8c363a5bef2c5 100644 (file)
@@ -1,6 +1,6 @@
 /* prdbg.c -- Print out generic debugging information.
-   Copyright 1995, 1996, 1999, 2002, 2003, 2004, 2006, 2007
-   Free Software Foundation, Inc.
+   Copyright 1995, 1996, 1999, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
+   2009  Free Software Foundation, Inc.
    Written by Ian Lance Taylor <ian@cygnus.com>.
    Tags style generation written by Salvador E. Tropea <set@computer.org>.
 
@@ -8,7 +8,7 @@
 
    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 2 of the License, or
+   the Free Software Foundation; either version 3 of the License, or
    (at your option) any later version.
 
    This program is distributed in the hope that it will be useful,
@@ -303,7 +303,7 @@ print_debugging_info (FILE *f, void *dhandle, bfd *abfd, asymbol **syms,
   info.filename = NULL;
   info.abfd = abfd;
   info.syms = syms;
-  info.demangler = demangler;
+  info.demangler = (char * (*)(struct bfd *, const char *, int)) demangler;
 
   if (as_tags)
     {
@@ -499,6 +499,26 @@ print_vma (bfd_vma vma, char *buf, bfd_boolean unsignedp, bfd_boolean hexp)
       else
        sprintf (buf, "%ld", (long) vma);
     }
+#if BFD_HOST_64BIT_LONG_LONG
+  else if (sizeof (vma) <= sizeof (unsigned long long))
+    {
+#ifndef __MSVCRT__
+      if (hexp)
+       sprintf (buf, "0x%llx", (unsigned long long) vma);
+      else if (unsignedp)
+       sprintf (buf, "%llu", (unsigned long long) vma);
+      else
+       sprintf (buf, "%lld", (long long) vma);
+#else
+      if (hexp)
+       sprintf (buf, "0x%I64x", (unsigned long long) vma);
+      else if (unsignedp)
+       sprintf (buf, "%I64u", (unsigned long long) vma);
+      else
+       sprintf (buf, "%I64d", (long long) vma);
+#endif
+    }
+#endif
   else
     {
       buf[0] = '0';
@@ -723,7 +743,7 @@ pr_function_type (void *p, int argcount, bfd_boolean varargs)
 
   /* Now the return type is on the top of the stack.  */
 
-  s = xmalloc (len);
+  s = (char *) xmalloc (len);
   LITSTRCPY (s, "(|) (");
 
   if (argcount < 0)
@@ -1297,7 +1317,7 @@ pr_class_static_member (void *p, const char *name, const char *physname,
 /* Add a base class to a class.  */
 
 static bfd_boolean
-pr_class_baseclass (void *p, bfd_vma bitpos, bfd_boolean virtual,
+pr_class_baseclass (void *p, bfd_vma bitpos, bfd_boolean is_virtual,
                    enum debug_visibility visibility)
 {
   struct pr_handle *info = (struct pr_handle *) p;
@@ -1323,7 +1343,7 @@ pr_class_baseclass (void *p, bfd_vma bitpos, bfd_boolean virtual,
   if (! push_type (info, t))
     return FALSE;
 
-  if (virtual)
+  if (is_virtual)
     {
       if (! prepend_type (info, "virtual "))
        return FALSE;
@@ -1927,15 +1947,13 @@ translate_addresses (bfd *abfd, char *addr_hex, FILE *f, asymbol **syms)
 /* Start a new compilation unit.  */
 
 static bfd_boolean
-tg_start_compilation_unit (void * p, const char *filename ATTRIBUTE_UNUSED)
+tg_start_compilation_unit (void * p, const char *fname ATTRIBUTE_UNUSED)
 {
   struct pr_handle *info = (struct pr_handle *) p;
 
-  fprintf (stderr, "New compilation unit: %s\n", filename);
-
   free (info->filename);
   /* Should it be relative? best way to do it here?.  */
-  info->filename = strdup (filename);
+  info->filename = strdup (fname);
 
   return TRUE;
 }
@@ -1943,13 +1961,13 @@ tg_start_compilation_unit (void * p, const char *filename ATTRIBUTE_UNUSED)
 /* Start a source file within a compilation unit.  */
 
 static bfd_boolean
-tg_start_source (void *p, const char *filename)
+tg_start_source (void *p, const char *fname)
 {
   struct pr_handle *info = (struct pr_handle *) p;
 
   free (info->filename);
   /* Should it be relative? best way to do it here?.  */
-  info->filename = strdup (filename);
+  info->filename = strdup (fname);
 
   return TRUE;
 }
@@ -2070,8 +2088,7 @@ tg_struct_field (void *p, const char *name, bfd_vma bitpos ATTRIBUTE_UNUSED,
 static bfd_boolean
 tg_end_struct_type (void *p ATTRIBUTE_UNUSED)
 {
-  struct pr_handle *info = (struct pr_handle *) p;
-  assert (info->stack != NULL);
+  assert (((struct pr_handle *) p)->stack != NULL);
 
   return TRUE;
 }
@@ -2152,7 +2169,7 @@ tg_class_static_member (void *p, const char *name,
 
   len_var = strlen (name);
   len_class = strlen (info->stack->next->type);
-  full_name = xmalloc (len_var + len_class + 3);
+  full_name = (char *) xmalloc (len_var + len_class + 3);
   if (! full_name)
     return FALSE;
   sprintf (full_name, "%s::%s", info->stack->next->type, name);
@@ -2183,7 +2200,7 @@ tg_class_static_member (void *p, const char *name,
 
 static bfd_boolean
 tg_class_baseclass (void *p, bfd_vma bitpos ATTRIBUTE_UNUSED,
-                   bfd_boolean virtual, enum debug_visibility visibility)
+                   bfd_boolean is_virtual, enum debug_visibility visibility)
 {
   struct pr_handle *info = (struct pr_handle *) p;
   char *t;
@@ -2203,7 +2220,7 @@ tg_class_baseclass (void *p, bfd_vma bitpos ATTRIBUTE_UNUSED,
   if (! push_type (info, t))
     return FALSE;
 
-  if (virtual)
+  if (is_virtual)
     {
       if (! prepend_type (info, "virtual "))
        return FALSE;
@@ -2525,25 +2542,18 @@ tg_variable (void *p, const char *name, enum debug_var_kind kind,
             bfd_vma val ATTRIBUTE_UNUSED)
 {
   struct pr_handle *info = (struct pr_handle *) p;
-  char *t;
-  const char *dname, *from_class;
+  char *t, *dname, *from_class;
 
   t = pop_type (info);
   if (t == NULL)
     return FALSE;
 
-  dname = name;
+  dname = NULL;
   if (info->demangler)
-    {
-      dname = info->demangler (info->abfd, name, DMGL_ANSI | DMGL_PARAMS);
-      if (strcmp (name, dname) == 0)
-       {
-         free ((char *) dname);
-         dname = name;
-       }
-    }
+    dname = info->demangler (info->abfd, name, DMGL_ANSI | DMGL_PARAMS);
 
-  if (dname != name)
+  from_class = NULL;
+  if (dname != NULL)
     {
       char *sep;
       sep = strstr (dname, "::");
@@ -2554,14 +2564,9 @@ tg_variable (void *p, const char *name, enum debug_var_kind kind,
          from_class = dname;
        }
       else
-       {
-         /* Obscure types as vts and type_info nodes.  */
-         name = dname;
-         from_class = NULL;
-       }
+       /* Obscure types as vts and type_info nodes.  */
+       name = dname;
     }
-  else
-    from_class = NULL;
 
   fprintf (info->f, "%s\t%s\t0;\"\tkind:v\ttype:%s", name, info->filename, t);
 
@@ -2579,10 +2584,10 @@ tg_variable (void *p, const char *name, enum debug_var_kind kind,
     }
 
   if (from_class)
-    {
-      fprintf (info->f, "\tclass:%s",from_class);
-      free ((char *) dname);
-    }
+    fprintf (info->f, "\tclass:%s", from_class);
+
+  if (dname)
+    free (dname);
 
   fprintf (info->f, "\n");
 
@@ -2597,28 +2602,22 @@ static bfd_boolean
 tg_start_function (void *p, const char *name, bfd_boolean global)
 {
   struct pr_handle *info = (struct pr_handle *) p;
-  const char *dname;
+  char *dname;
 
   if (! global)
     info->stack->flavor = "static";
   else
     info->stack->flavor = NULL;
 
-  dname = name;
+  dname = NULL;
   if (info->demangler)
-    {
-      dname = info->demangler (info->abfd, name, DMGL_ANSI | DMGL_PARAMS);
-      if (strcmp (name, dname) == 0)
-       {
-         free ((char *) dname);
-         dname = name;
-       }
-    }
+    dname = info->demangler (info->abfd, name, DMGL_ANSI | DMGL_PARAMS);
 
-  if (! substitute_type (info, dname))
+  if (! substitute_type (info, dname ? dname : name))
     return FALSE;
 
-  if (dname != name)
+  info->stack->method = NULL;
+  if (dname != NULL)
     {
       char *sep;
       sep = strstr (dname, "::");
@@ -2638,8 +2637,6 @@ tg_start_function (void *p, const char *name, bfd_boolean global)
        *sep = 0;
       /* Obscure functions as type_info function.  */
     }
-  else
-    info->stack->method = NULL;
 
   info->stack->parents = strdup (name);
 
@@ -2747,7 +2744,7 @@ tg_start_block (void *p, bfd_vma addr)
 /* Write out line number information.  */
 
 static bfd_boolean
-tg_lineno (void *p ATTRIBUTE_UNUSED, const char *filename ATTRIBUTE_UNUSED,
+tg_lineno (void *p ATTRIBUTE_UNUSED, const char *fname ATTRIBUTE_UNUSED,
           unsigned long lineno ATTRIBUTE_UNUSED,
           bfd_vma addr ATTRIBUTE_UNUSED)
 {
This page took 0.031644 seconds and 4 git commands to generate.