* xtensa-modules.c: Remove comment indicating that this is a
[deliverable/binutils-gdb.git] / gdb / objc-lang.c
index 00a57dddae04eca8b5149836bddcc2813105cbcf..6fbbaa7fd2d8073c47b806096946ae63f1c62cfc 100644 (file)
@@ -1,6 +1,6 @@
 /* Objective-C language support routines for GDB, the GNU debugger.
 
-   Copyright 2002 Free Software Foundation, Inc.
+   Copyright 2002, 2003 Free Software Foundation, Inc.
 
    Contributed by Apple Computer, Inc.
    Written by Michael Snyder.
@@ -41,6 +41,7 @@
 #include "frame.h"
 #include "gdb_regex.h"
 #include "regcache.h"
+#include "block.h"
 
 #include <ctype.h>
 
@@ -236,7 +237,7 @@ value_nsstring (char *ptr, int len)
 /* Objective-C name demangling.  */
 
 char *
-objc_demangle (const char *mangled)
+objc_demangle (const char *mangled, int options)
 {
   char *demangled, *cp;
 
@@ -592,6 +593,35 @@ objc_create_fundamental_type (struct objfile *objfile, int typeid)
   return (type);
 }
 
+/* Determine if we are currently in the Objective-C dispatch function.
+   If so, get the address of the method function that the dispatcher
+   would call and use that as the function to step into instead. Also
+   skip over the trampoline for the function (if any).  This is better
+   for the user since they are only interested in stepping into the
+   method function anyway.  */
+static CORE_ADDR 
+objc_skip_trampoline (CORE_ADDR stop_pc)
+{
+  CORE_ADDR real_stop_pc;
+  CORE_ADDR method_stop_pc;
+  
+  real_stop_pc = SKIP_TRAMPOLINE_CODE (stop_pc);
+
+  if (real_stop_pc != 0)
+    find_objc_msgcall (real_stop_pc, &method_stop_pc);
+  else
+    find_objc_msgcall (stop_pc, &method_stop_pc);
+
+  if (method_stop_pc)
+    {
+      real_stop_pc = SKIP_TRAMPOLINE_CODE (method_stop_pc);
+      if (real_stop_pc == 0)
+       real_stop_pc = method_stop_pc;
+    }
+
+  return real_stop_pc;
+}
+
 
 /* Table mapping opcodes into strings for printing operators
    and precedences of the operators.  */
@@ -669,6 +699,8 @@ const struct language_defn objc_language_defn = {
   c_print_type,                        /* Print a type using appropriate syntax */
   c_val_print,                 /* Print a value using appropriate syntax */
   c_value_print,               /* Print a top-level value */
+  objc_skip_trampoline,        /* Language specific skip_trampoline */
+  objc_demangle,               /* Language specific symbol demangler */
   {"",     "",    "",  ""},    /* Binary format info */
   {"0%lo",  "0",   "o", ""},   /* Octal format info */
   {"%ld",   "",    "d", ""},   /* Decimal format info */
@@ -798,8 +830,8 @@ compare_selectors (const void *a, const void *b)
 {
   char *aname, *bname;
 
-  aname = SYMBOL_SOURCE_NAME (*(struct symbol **) a);
-  bname = SYMBOL_SOURCE_NAME (*(struct symbol **) b);
+  aname = SYMBOL_PRINT_NAME (*(struct symbol **) a);
+  bname = SYMBOL_PRINT_NAME (*(struct symbol **) b);
   if (aname == NULL || bname == NULL)
     error ("internal: compare_selectors(1)");
 
@@ -867,7 +899,7 @@ selectors_info (char *regexp, int from_tty)
       QUIT;
       name = SYMBOL_DEMANGLED_NAME (msymbol);
       if (name == NULL)
-       name = SYMBOL_NAME (msymbol);
+       name = DEPRECATED_SYMBOL_NAME (msymbol);
       if (name &&
         (name[0] == '-' || name[0] == '+') &&
          name[1] == '[')               /* Got a method name.  */
@@ -900,7 +932,7 @@ selectors_info (char *regexp, int from_tty)
          QUIT;
          name = SYMBOL_DEMANGLED_NAME (msymbol);
          if (name == NULL)
-           name = SYMBOL_NAME (msymbol);
+           name = DEPRECATED_SYMBOL_NAME (msymbol);
          if (name &&
             (name[0] == '-' || name[0] == '+') &&
              name[1] == '[')           /* Got a method name.  */
@@ -926,7 +958,7 @@ selectors_info (char *regexp, int from_tty)
          QUIT;
          name = SYMBOL_DEMANGLED_NAME (sym_arr[ix]);
          if (name == NULL)
-           name = SYMBOL_NAME (sym_arr[ix]);
+           name = DEPRECATED_SYMBOL_NAME (sym_arr[ix]);
          name = strchr (name, ' ') + 1;
          if (p[0] && specialcmp(name, p) == 0)
            continue;           /* Seen this one already (not unique).  */
@@ -956,8 +988,8 @@ compare_classes (const void *a, const void *b)
 {
   char *aname, *bname;
 
-  aname = SYMBOL_SOURCE_NAME (*(struct symbol **) a);
-  bname = SYMBOL_SOURCE_NAME (*(struct symbol **) b);
+  aname = SYMBOL_PRINT_NAME (*(struct symbol **) a);
+  bname = SYMBOL_PRINT_NAME (*(struct symbol **) b);
   if (aname == NULL || bname == NULL)
     error ("internal: compare_classes(1)");
 
@@ -1010,7 +1042,7 @@ classes_info (char *regexp, int from_tty)
       QUIT;
       name = SYMBOL_DEMANGLED_NAME (msymbol);
       if (name == NULL)
-       name = SYMBOL_NAME (msymbol);
+       name = DEPRECATED_SYMBOL_NAME (msymbol);
       if (name &&
         (name[0] == '-' || name[0] == '+') &&
          name[1] == '[')                       /* Got a method name.  */
@@ -1036,7 +1068,7 @@ classes_info (char *regexp, int from_tty)
          QUIT;
          name = SYMBOL_DEMANGLED_NAME (msymbol);
          if (name == NULL)
-           name = SYMBOL_NAME (msymbol);
+           name = DEPRECATED_SYMBOL_NAME (msymbol);
          if (name &&
             (name[0] == '-' || name[0] == '+') &&
              name[1] == '[')                   /* Got a method name.  */
@@ -1055,7 +1087,7 @@ classes_info (char *regexp, int from_tty)
          QUIT;
          name = SYMBOL_DEMANGLED_NAME (sym_arr[ix]);
          if (name == NULL)
-           name = SYMBOL_NAME (sym_arr[ix]);
+           name = DEPRECATED_SYMBOL_NAME (sym_arr[ix]);
          name += 2;
          if (p[0] && specialcmp(name, p) == 0)
            continue;   /* Seen this one already (not unique).  */
@@ -1272,7 +1304,7 @@ parse_method (char *method, char *type, char **class,
   return s2;
 }
 
-void
+static void
 find_methods (struct symtab *symtab, char type, 
              const char *class, const char *category, 
              const char *selector, struct symbol **syms, 
@@ -1318,7 +1350,7 @@ find_methods (struct symtab *symtab, char type,
 
       symname = SYMBOL_DEMANGLED_NAME (msymbol);
       if (symname == NULL)
-       symname = SYMBOL_NAME (msymbol);
+       symname = DEPRECATED_SYMBOL_NAME (msymbol);
       if (symname == NULL)
        continue;
 
@@ -1357,7 +1389,7 @@ find_methods (struct symtab *symtab, char type,
           const char *newsymname = SYMBOL_DEMANGLED_NAME (sym);
          
           if (newsymname == NULL)
-            newsymname = SYMBOL_NAME (sym);
+            newsymname = DEPRECATED_SYMBOL_NAME (sym);
           if (strcmp (symname, newsymname) == 0)
             {
               /* Found a high-level method sym: swap it into the
This page took 0.026023 seconds and 4 git commands to generate.