Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Adam Fedor <fedor@doc.com>
To: Andrew Cagney <ac131313@redhat.com>
Cc: GDB Patches <gdb-patches@sources.redhat.com>
Subject: Re: [PATCH] Step over Objective-C dispatch function
Date: Tue, 25 Mar 2003 15:56:00 -0000	[thread overview]
Message-ID: <3E807C37.1040804@doc.com> (raw)
In-Reply-To: <3E7A2DCA.6050205@redhat.com>

[-- Attachment #1: Type: text/plain, Size: 1839 bytes --]



Andrew Cagney wrote:
>> +      /* 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.  */
>> +      {
>> +    CORE_ADDR method_stop_pc;
>> +   
>> +    if (real_stop_pc)
>> +      find_objc_msgcall (real_stop_pc, &method_stop_pc);
>> +    else
>> +      find_objc_msgcall (stop_pc, &method_stop_pc);
>> +   
>> +    if (method_stop_pc)
>> +      ecs->stop_func_start = method_stop_pc;
>> +   
>> +    if (method_stop_pc)
>> +      {
>> +        real_stop_pc = SKIP_TRAMPOLINE_CODE (method_stop_pc);
>> +        if (real_stop_pc != 0)
>> +          ecs->stop_func_start = real_stop_pc;
>> +      }
>> +      }
>> +
> 
> 
> Adam,
> 
> Seems you were waiting on me here :-(
> 
> I've looked at what the underlying code is trying to do and, 
> unfortunatly, the original objc-lang.c botched its portability(1), sigh! 
>  The file is currently native only so infrun.c can't directly refer to 
> objc-lang.c, and hence, will need to go via a dispatch table.  Going via 
> a dispatch table wouldn't hurt anyway.
> 

I think I understand this, but perhaps you can look at the patch and 
tell me if I'm way off.  After looking at this closer myself, I realized 
this is only relevant for the Apple Objective-C runtime (i.e. Darwin), 
not the GNU runtime. On GNU systems the dispatch function gets 
automatically skipped because it typically has no debugging information 
(Wouldn't this work also on the Apple runtime?). Perhaps that changes 
things a little.



[-- Attachment #2: skip_trampoline.patch --]
[-- Type: text/plain, Size: 14127 bytes --]

2003-03-24  Adam Fedor  <fedor@gnu.org>

	* Makefile.in (infrun.o): Add $(language_h)
	* infrun.c (handle_inferior_event): Use skip_language_trampoline
	for language specific trampolines.
	* language.h (struct language_defn): Add skip_trampoline.
	(skip_language_trampoline): Declare.
	* language.c (unk_lang_trampoline, skip_language_trampoline):
	New functions.
	(unknown_language_defn, auto_language_defn, local_language_defn):
	Add ukn_lang_trampoline.
	* ada-lang.c (ada_language_defn): Add NULL for language
	specific skip_trampoline.
	* c-lang.c, f-lang.c, jv-lang.c, m2-lang.c, p-lang.c,
	scm-lang.c: Likewise.
	* objc-lang.c (objc_skip_trampoline): New function.
	(objc_language_defn): Add objc_skip_trampoline.

Index: Makefile.in
===================================================================
RCS file: /cvs/src/src/gdb/Makefile.in,v
retrieving revision 1.350
diff -u -p -r1.350 Makefile.in
--- Makefile.in	25 Mar 2003 02:18:55 -0000	1.350
+++ Makefile.in	25 Mar 2003 04:11:36 -0000
@@ -1831,7 +1831,7 @@ infrun.o: infrun.c $(defs_h) $(gdb_strin
 	$(inferior_h) $(breakpoint_h) $(gdb_wait_h) $(gdbcore_h) $(gdbcmd_h) \
 	$(cli_script_h) $(target_h) $(gdbthread_h) $(annotate_h) \
 	$(symfile_h) $(top_h) $(inf_loop_h) $(regcache_h) $(value_h) \
-	$(observer_h)
+	$(observer_h) $(language_h)
 inftarg.o: inftarg.c $(defs_h) $(frame_h) $(inferior_h) $(target_h) \
 	$(gdbcore_h) $(command_h) $(gdb_stat_h) $(gdb_wait_h) $(inflow_h)
 infttrace.o: infttrace.c $(defs_h) $(frame_h) $(inferior_h) $(target_h) \
Index: ada-lang.c
===================================================================
RCS file: /cvs/src/src/gdb/ada-lang.c,v
retrieving revision 1.21
diff -u -p -r1.21 ada-lang.c
--- ada-lang.c	25 Feb 2003 21:36:15 -0000	1.21
+++ ada-lang.c	25 Mar 2003 04:11:54 -0000
@@ -8080,6 +8080,7 @@ const struct language_defn ada_language_
   ada_print_type,		/* Print a type using appropriate syntax */
   ada_val_print,		/* Print a value using appropriate syntax */
   ada_value_print,		/* Print a top-level value */
+  NULL,				/* Language specific skip_trampoline */
   {"", "", "", ""},		/* Binary format info */
 #if 0
   {"8#%lo#", "8#", "o", "#"},	/* Octal format info */
Index: c-lang.c
===================================================================
RCS file: /cvs/src/src/gdb/c-lang.c,v
retrieving revision 1.16
diff -u -p -r1.16 c-lang.c
--- c-lang.c	20 Sep 2002 17:37:11 -0000	1.16
+++ c-lang.c	25 Mar 2003 04:11:55 -0000
@@ -552,6 +552,7 @@ const struct language_defn c_language_de
   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 */
+  NULL,				/* Language specific skip_trampoline */
   {"", "", "", ""},		/* Binary format info */
   {"0%lo", "0", "o", ""},	/* Octal format info */
   {"%ld", "", "d", ""},		/* Decimal format info */
@@ -604,6 +605,7 @@ const struct language_defn cplus_languag
   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 */
+  NULL,				/* Language specific skip_trampoline */
   {"", "", "", ""},		/* Binary format info */
   {"0%lo", "0", "o", ""},	/* Octal format info */
   {"%ld", "", "d", ""},		/* Decimal format info */
@@ -633,6 +635,7 @@ const struct language_defn asm_language_
   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 */
+  NULL,				/* Language specific skip_trampoline */
   {"", "", "", ""},		/* Binary format info */
   {"0%lo", "0", "o", ""},	/* Octal format info */
   {"%ld", "", "d", ""},		/* Decimal format info */
Index: f-lang.c
===================================================================
RCS file: /cvs/src/src/gdb/f-lang.c,v
retrieving revision 1.11
diff -u -p -r1.11 f-lang.c
--- f-lang.c	27 Feb 2003 18:13:37 -0000	1.11
+++ f-lang.c	25 Mar 2003 04:11:55 -0000
@@ -472,6 +472,7 @@ const struct language_defn f_language_de
   f_print_type,			/* Print a type using appropriate syntax */
   f_val_print,			/* Print a value using appropriate syntax */
   c_value_print,		/* FIXME */
+  NULL,				/* Language specific skip_trampoline */
   {"", "", "", ""},		/* Binary format info */
   {"0%o", "0", "o", ""},	/* Octal format info */
   {"%d", "", "d", ""},		/* Decimal format info */
Index: infrun.c
===================================================================
RCS file: /cvs/src/src/gdb/infrun.c,v
retrieving revision 1.99
diff -u -p -r1.99 infrun.c
--- infrun.c	20 Mar 2003 22:52:53 -0000	1.99
+++ infrun.c	25 Mar 2003 04:12:09 -0000
@@ -43,6 +43,7 @@
 #include "regcache.h"
 #include "value.h"
 #include "observer.h"
+#include "language.h"
 
 /* Prototypes for local functions */
 
@@ -2386,7 +2387,9 @@ process_event_stop_test:
          function.  That's what tells us (a) whether we want to step
          into it at all, and (b) what prologue we want to run to
          the end of, if we do step into it.  */
-      real_stop_pc = SKIP_TRAMPOLINE_CODE (stop_pc);
+      real_stop_pc = skip_language_trampoline(stop_pc);
+      if (real_stop_pc == 0)
+	real_stop_pc = SKIP_TRAMPOLINE_CODE (stop_pc);
       if (real_stop_pc != 0)
 	ecs->stop_func_start = real_stop_pc;
 
Index: jv-lang.c
===================================================================
RCS file: /cvs/src/src/gdb/jv-lang.c,v
retrieving revision 1.15
diff -u -p -r1.15 jv-lang.c
--- jv-lang.c	25 Feb 2003 21:36:18 -0000	1.15
+++ jv-lang.c	25 Mar 2003 04:12:09 -0000
@@ -1054,6 +1054,7 @@ const struct language_defn java_language
   java_print_type,		/* Print a type using appropriate syntax */
   java_val_print,		/* Print a value using appropriate syntax */
   java_value_print,		/* Print a top-level value */
+  NULL,				/* Language specific skip_trampoline */
   {"", "", "", ""},		/* Binary format info */
   {"0%lo", "0", "o", ""},	/* Octal format info */
   {"%ld", "", "d", ""},		/* Decimal format info */
Index: language.c
===================================================================
RCS file: /cvs/src/src/gdb/language.c,v
retrieving revision 1.31
diff -u -p -r1.31 language.c
--- language.c	14 Jan 2003 00:49:04 -0000	1.31
+++ language.c	25 Mar 2003 04:12:12 -0000
@@ -100,6 +100,8 @@ static int unk_lang_val_print (struct ty
 
 static int unk_lang_value_print (struct value *, struct ui_file *, int, enum val_prettyprint);
 
+static CORE_ADDR unk_lang_trampoline (CORE_ADDR pc);
+
 /* Forward declaration */
 extern const struct language_defn unknown_language_defn;
 
@@ -1337,6 +1339,30 @@ add_language (const struct language_defn
   languages[languages_size++] = lang;
 }
 
+/* Iterate through all registered languages looking for and calling
+   any non-NULL struct language_defn.skip_trampoline() functions.
+   Return the result from the first that returns non-zero, or 0 if all
+   `fail'.  */
+CORE_ADDR 
+skip_language_trampoline (CORE_ADDR pc)
+{
+  int i;
+  CORE_ADDR real_pc = 0;
+
+  for (i = 0; i < languages_size; i++)
+    {
+      if (languages[i]->skip_trampoline)
+	{
+	  real_pc = (languages[i]->skip_trampoline)(pc);
+	  if (real_pc)
+	    break;
+	}
+    }
+
+  return real_pc;
+}
+
+
 /* Define the language that is no language.  */
 
 static int
@@ -1398,6 +1424,11 @@ unk_lang_value_print (struct value *val,
   error ("internal error - unimplemented function unk_lang_value_print called.");
 }
 
+static CORE_ADDR unk_lang_trampoline (CORE_ADDR pc)
+{
+  return 0;
+}
+
 static struct type **const (unknown_builtin_types[]) =
 {
   0
@@ -1425,6 +1456,7 @@ const struct language_defn unknown_langu
   unk_lang_print_type,		/* Print a type using appropriate syntax */
   unk_lang_val_print,		/* Print a value using appropriate syntax */
   unk_lang_value_print,		/* Print a top-level value */
+  unk_lang_trampoline,		/* Language specific skip_trampoline */
   {"", "", "", ""},		/* Binary format info */
   {"0%lo", "0", "o", ""},	/* Octal format info */
   {"%ld", "", "d", ""},		/* Decimal format info */
@@ -1455,6 +1487,7 @@ const struct language_defn auto_language
   unk_lang_print_type,		/* Print a type using appropriate syntax */
   unk_lang_val_print,		/* Print a value using appropriate syntax */
   unk_lang_value_print,		/* Print a top-level value */
+  unk_lang_trampoline,		/* Language specific skip_trampoline */
   {"", "", "", ""},		/* Binary format info */
   {"0%lo", "0", "o", ""},	/* Octal format info */
   {"%ld", "", "d", ""},		/* Decimal format info */
@@ -1484,6 +1517,7 @@ const struct language_defn local_languag
   unk_lang_print_type,		/* Print a type using appropriate syntax */
   unk_lang_val_print,		/* Print a value using appropriate syntax */
   unk_lang_value_print,		/* Print a top-level value */
+  unk_lang_trampoline,		/* Language specific skip_trampoline */
   {"", "", "", ""},		/* Binary format info */
   {"0%lo", "0", "o", ""},	/* Octal format info */
   {"%ld", "", "d", ""},		/* Decimal format info */
Index: language.h
===================================================================
RCS file: /cvs/src/src/gdb/language.h,v
retrieving revision 1.16
diff -u -p -r1.16 language.h
--- language.h	14 Jan 2003 00:49:04 -0000	1.16
+++ language.h	25 Mar 2003 04:12:15 -0000
@@ -203,6 +203,12 @@ struct language_defn
     int (*la_value_print) (struct value *, struct ui_file *,
 			   int, enum val_prettyprint);
 
+    /* PC is possibly an unknown languages trampoline.
+       If that PC falls in a trampoline belonging to this language,
+       return the address of the first pc in the real function, or 0
+       if it isn't a language tramp for this language.  */
+    CORE_ADDR (*skip_trampoline) (CORE_ADDR pc);
+
     /* Base 2 (binary) formats. */
 
     struct language_format_info la_binary_format;
@@ -464,5 +470,9 @@ extern char *language_str (enum language
 extern void add_language (const struct language_defn *);
 
 extern enum language get_frame_language (void);	/* In stack.c */
+
+/* Check for a language-specific trampoline. */
+
+extern CORE_ADDR skip_language_trampoline (CORE_ADDR pc);
 
 #endif /* defined (LANGUAGE_H) */
Index: m2-lang.c
===================================================================
RCS file: /cvs/src/src/gdb/m2-lang.c,v
retrieving revision 1.7
diff -u -p -r1.7 m2-lang.c
--- m2-lang.c	13 Feb 2002 18:49:30 -0000	1.7
+++ m2-lang.c	25 Mar 2003 04:12:16 -0000
@@ -426,6 +426,7 @@ const struct language_defn m2_language_d
   m2_print_type,		/* Print a type using appropriate syntax */
   m2_val_print,			/* Print a value using appropriate syntax */
   c_value_print,		/* Print a top-level value */
+  NULL,				/* Language specific skip_trampoline */
   {"", "", "", ""},		/* Binary format info */
   {"%loB", "", "o", "B"},	/* Octal format info */
   {"%ld", "", "d", ""},		/* Decimal format info */
Index: objc-lang.c
===================================================================
RCS file: /cvs/src/src/gdb/objc-lang.c,v
retrieving revision 1.13
diff -u -p -r1.13 objc-lang.c
--- objc-lang.c	25 Feb 2003 21:36:18 -0000	1.13
+++ objc-lang.c	25 Mar 2003 04:12:17 -0000
@@ -593,6 +593,35 @@ objc_create_fundamental_type (struct obj
   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.  */
@@ -670,6 +699,7 @@ const struct language_defn objc_language
   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 */
   {"",     "",    "",  ""},	/* Binary format info */
   {"0%lo",  "0",   "o", ""},	/* Octal format info */
   {"%ld",   "",    "d", ""},	/* Decimal format info */
Index: p-lang.c
===================================================================
RCS file: /cvs/src/src/gdb/p-lang.c,v
retrieving revision 1.9
diff -u -p -r1.9 p-lang.c
--- p-lang.c	27 Aug 2002 22:37:06 -0000	1.9
+++ p-lang.c	25 Mar 2003 04:12:24 -0000
@@ -461,6 +461,7 @@ const struct language_defn pascal_langua
   pascal_print_type,		/* Print a type using appropriate syntax */
   pascal_val_print,		/* Print a value using appropriate syntax */
   pascal_value_print,		/* Print a top-level value */
+  NULL,				/* Language specific skip_trampoline */
   {"", "%", "b", ""},		/* Binary format info */
   {"0%lo", "0", "o", ""},	/* Octal format info */
   {"%ld", "", "d", ""},		/* Decimal format info */
Index: scm-lang.c
===================================================================
RCS file: /cvs/src/src/gdb/scm-lang.c,v
retrieving revision 1.13
diff -u -p -r1.13 scm-lang.c
--- scm-lang.c	14 Jan 2003 00:49:04 -0000	1.13
+++ scm-lang.c	25 Mar 2003 04:12:26 -0000
@@ -250,6 +250,7 @@ const struct language_defn scm_language_
   c_print_type,			/* Print a type using appropriate syntax */
   scm_val_print,		/* Print a value using appropriate syntax */
   scm_value_print,		/* Print a top-level value */
+  NULL,				/* Language specific skip_trampoline */
   {"", "", "", ""},		/* Binary format info */
   {"#o%lo", "#o", "o", ""},	/* Octal format info */
   {"%ld", "", "d", ""},		/* Decimal format info */

  reply	other threads:[~2003-03-25 15:56 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-01-03  3:35 Adam Fedor
2003-01-31  2:52 ` Michael Snyder
2003-01-31  3:07   ` Andrew Cagney
2003-01-31  3:54     ` Adam Fedor
2003-03-20 21:08       ` Andrew Cagney
2003-03-25 15:56         ` Adam Fedor [this message]
2003-03-25 16:25           ` Andrew Cagney
2003-03-25 16:41             ` Andrew Cagney

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=3E807C37.1040804@doc.com \
    --to=fedor@doc.com \
    --cc=ac131313@redhat.com \
    --cc=gdb-patches@sources.redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox