* [PATCH] Step over Objective-C dispatch function
@ 2003-01-03 3:35 Adam Fedor
2003-01-31 2:52 ` Michael Snyder
0 siblings, 1 reply; 8+ messages in thread
From: Adam Fedor @ 2003-01-03 3:35 UTC (permalink / raw)
To: GDB Patches
[-- Attachment #1: Type: text/plain, Size: 188 bytes --]
All Objective-C messages are called through the standard dispatch
function. This patch steps right into the method without the user having
to go through the dispatch function manually.
[-- Attachment #2: objc20.patch --]
[-- Type: text/plain, Size: 2301 bytes --]
2003-01-02 Adam Fedor <fedor@gnu.org>
* infrun.c (handle_inferior_event): Add test to step over
Objective-C dispatch function.
* Makefile.in (infrun.o): Add $(objc_lang_h)
Index: Makefile.in
===================================================================
RCS file: /cvs/src/src/gdb/Makefile.in,v
retrieving revision 1.302
diff -u -p -r1.302 Makefile.in
--- Makefile.in 2 Jan 2003 20:29:15 -0000 1.302
+++ Makefile.in 3 Jan 2003 03:24:54 -0000
@@ -1795,7 +1796,8 @@ infptrace.o: infptrace.c $(defs_h) $(fra
infrun.o: infrun.c $(defs_h) $(gdb_string_h) $(symtab_h) $(frame_h) \
$(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)
+ $(symfile_h) $(top_h) $(inf_loop_h) $(regcache_h) $(value_h) \
+ $(objc_lang_h)
inftarg.o: inftarg.c $(defs_h) $(frame_h) $(inferior_h) $(target_h) \
$(gdbcore_h) $(command_h) $(gdb_stat_h) $(gdb_wait_h)
infttrace.o: infttrace.c $(defs_h) $(frame_h) $(inferior_h) $(target_h) \
Index: infrun.c
===================================================================
RCS file: /cvs/src/src/gdb/infrun.c,v
retrieving revision 1.92
diff -u -p -r1.92 infrun.c
--- infrun.c 18 Dec 2002 18:03:42 -0000 1.92
+++ infrun.c 3 Jan 2003 03:20:06 -0000
@@ -42,6 +42,7 @@
#include "inf-loop.h"
#include "regcache.h"
#include "value.h"
+#include "objc-lang.h"
/* Prototypes for local functions */
@@ -1173,6 +1174,7 @@ void
handle_inferior_event (struct execution_control_state *ecs)
{
CORE_ADDR tmp;
+ CORE_ADDR new_stop;
int stepped_after_stopped_by_watchpoint;
int sw_single_step_trap_p = 0;
@@ -2428,6 +2430,22 @@ process_event_stop_test:
keep_going (ecs);
return;
}
+ }
+
+ /* Step over Objective-C dispatch function. */
+ if (tmp)
+ find_objc_msgcall (tmp, &new_stop);
+ else
+ find_objc_msgcall (stop_pc, &new_stop);
+
+ if (new_stop) /* step into a method call */
+ ecs->stop_func_start = new_stop;
+
+ if (new_stop)
+ {
+ tmp = SKIP_TRAMPOLINE_CODE (new_stop);
+ if (tmp != 0)
+ ecs->stop_func_start = tmp;
}
/* If we have line number information for the function we
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] Step over Objective-C dispatch function
2003-01-03 3:35 [PATCH] Step over Objective-C dispatch function Adam Fedor
@ 2003-01-31 2:52 ` Michael Snyder
2003-01-31 3:07 ` Andrew Cagney
0 siblings, 1 reply; 8+ messages in thread
From: Michael Snyder @ 2003-01-31 2:52 UTC (permalink / raw)
To: Adam Fedor; +Cc: GDB Patches
Adam Fedor wrote:
>
> All Objective-C messages are called through the standard dispatch
> function. This patch steps right into the method without the user having
> to go through the dispatch function manually.
Adam, can you explain / comment what you're doing a little more?
I *think* what you're doing is trying to follow thru the dispatcher
to the actual method -- but the only reason I can even guess that
is because I've worked on debugging objective-c.
>
> -------------------------------------------------------------------------------
> 2003-01-02 Adam Fedor <fedor@gnu.org>
>
> * infrun.c (handle_inferior_event): Add test to step over
> Objective-C dispatch function.
> * Makefile.in (infrun.o): Add $(objc_lang_h)
>
> Index: Makefile.in
> ===================================================================
> RCS file: /cvs/src/src/gdb/Makefile.in,v
> retrieving revision 1.302
> diff -u -p -r1.302 Makefile.in
> --- Makefile.in 2 Jan 2003 20:29:15 -0000 1.302
> +++ Makefile.in 3 Jan 2003 03:24:54 -0000
> @@ -1795,7 +1796,8 @@ infptrace.o: infptrace.c $(defs_h) $(fra
> infrun.o: infrun.c $(defs_h) $(gdb_string_h) $(symtab_h) $(frame_h) \
> $(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)
> + $(symfile_h) $(top_h) $(inf_loop_h) $(regcache_h) $(value_h) \
> + $(objc_lang_h)
> inftarg.o: inftarg.c $(defs_h) $(frame_h) $(inferior_h) $(target_h) \
> $(gdbcore_h) $(command_h) $(gdb_stat_h) $(gdb_wait_h)
> infttrace.o: infttrace.c $(defs_h) $(frame_h) $(inferior_h) $(target_h) \
> Index: infrun.c
> ===================================================================
> RCS file: /cvs/src/src/gdb/infrun.c,v
> retrieving revision 1.92
> diff -u -p -r1.92 infrun.c
> --- infrun.c 18 Dec 2002 18:03:42 -0000 1.92
> +++ infrun.c 3 Jan 2003 03:20:06 -0000
> @@ -42,6 +42,7 @@
> #include "inf-loop.h"
> #include "regcache.h"
> #include "value.h"
> +#include "objc-lang.h"
>
> /* Prototypes for local functions */
>
> @@ -1173,6 +1174,7 @@ void
> handle_inferior_event (struct execution_control_state *ecs)
> {
> CORE_ADDR tmp;
> + CORE_ADDR new_stop;
> int stepped_after_stopped_by_watchpoint;
> int sw_single_step_trap_p = 0;
>
> @@ -2428,6 +2430,22 @@ process_event_stop_test:
> keep_going (ecs);
> return;
> }
> + }
> +
> + /* Step over Objective-C dispatch function. */
> + if (tmp)
> + find_objc_msgcall (tmp, &new_stop);
> + else
> + find_objc_msgcall (stop_pc, &new_stop);
> +
> + if (new_stop) /* step into a method call */
> + ecs->stop_func_start = new_stop;
> +
> + if (new_stop)
> + {
> + tmp = SKIP_TRAMPOLINE_CODE (new_stop);
> + if (tmp != 0)
> + ecs->stop_func_start = tmp;
> }
>
> /* If we have line number information for the function we
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] Step over Objective-C dispatch function
2003-01-31 2:52 ` Michael Snyder
@ 2003-01-31 3:07 ` Andrew Cagney
2003-01-31 3:54 ` Adam Fedor
0 siblings, 1 reply; 8+ messages in thread
From: Andrew Cagney @ 2003-01-31 3:07 UTC (permalink / raw)
To: Adam Fedor; +Cc: Michael Snyder, GDB Patches
Just on the coding side (let michael handle the technical bit :-). That
file contains the nastiest code known to GDB so all possible effort
should be spent on ensuring that the new code is understandable.
> CORE_ADDR tmp;
Hmm, looks like the variable tmp needs a re-name, it's definitly no
longer tmp - it's carrying a meaningful value.
>> + CORE_ADDR new_stop;
this declaration should be moved as close as possible to its use (and
again given a descriptive name).
> + /* Step over Objective-C dispatch function. */
Following on from michael's comment, this needs a detailed description
of what is happening here.
Andrew
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] Step over Objective-C dispatch function
2003-01-31 3:07 ` Andrew Cagney
@ 2003-01-31 3:54 ` Adam Fedor
2003-03-20 21:08 ` Andrew Cagney
0 siblings, 1 reply; 8+ messages in thread
From: Adam Fedor @ 2003-01-31 3:54 UTC (permalink / raw)
To: Andrew Cagney; +Cc: Michael Snyder, GDB Patches
[-- Attachment #1: Type: text/plain, Size: 339 bytes --]
Andrew Cagney wrote:
>
> > + /* Step over Objective-C dispatch function. */
>
> Following on from michael's comment, this needs a detailed description
> of what is happening here.
>
I split this into separate patches (second patch to follow), although
perhaps that might be to trivial. Here's an update of the first patch:
[-- Attachment #2: objc20a.patch --]
[-- Type: text/plain, Size: 2643 bytes --]
2003-01-30 Adam Fedor <fedor@gnu.org>
* infrun.c (handle_inferior_event): Step through
Objective-C dispatch function to method function (if found).
* Makefile.in (infrun.o): Add $(objc_lang_h)
Index: Makefile.in
===================================================================
RCS file: /cvs/src/src/gdb/Makefile.in,v
retrieving revision 1.302
diff -u -p -r1.302 Makefile.in
--- Makefile.in 2 Jan 2003 20:29:15 -0000 1.302
+++ Makefile.in 3 Jan 2003 03:24:54 -0000
@@ -1795,7 +1796,8 @@ infptrace.o: infptrace.c $(defs_h) $(fra
infrun.o: infrun.c $(defs_h) $(gdb_string_h) $(symtab_h) $(frame_h) \
$(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)
+ $(symfile_h) $(top_h) $(inf_loop_h) $(regcache_h) $(value_h) \
+ $(objc_lang_h)
inftarg.o: inftarg.c $(defs_h) $(frame_h) $(inferior_h) $(target_h) \
$(gdbcore_h) $(command_h) $(gdb_stat_h) $(gdb_wait_h)
infttrace.o: infttrace.c $(defs_h) $(frame_h) $(inferior_h) $(target_h) \
Index: infrun.c
===================================================================
RCS file: /cvs/src/src/gdb/infrun.c,v
retrieving revision 1.95
diff -u -p -r1.95 infrun.c
--- infrun.c 19 Jan 2003 17:39:16 -0000 1.95
+++ infrun.c 31 Jan 2003 03:40:37 -0000
@@ -42,6 +42,7 @@
#include "inf-loop.h"
#include "regcache.h"
#include "value.h"
+#include "objc-lang.h"
/* Prototypes for local functions */
@@ -1172,7 +1173,7 @@ context_switch (struct execution_control
@@ -2430,6 +2431,32 @@ process_event_stop_test:
}
}
+ /* 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;
+ }
+ }
+
/* If we have line number information for the function we
are thinking of stepping into, step into it.
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] Step over Objective-C dispatch function
2003-01-31 3:54 ` Adam Fedor
@ 2003-03-20 21:08 ` Andrew Cagney
2003-03-25 15:56 ` Adam Fedor
0 siblings, 1 reply; 8+ messages in thread
From: Andrew Cagney @ 2003-03-20 21:08 UTC (permalink / raw)
To: Adam Fedor; +Cc: GDB Patches
> + /* 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.
Can you please do things as sketched out below.
- append to "language.h":struct language_defn the method:
/* If 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);
- add to "language.h" the global method:
CORE_ADDR skip_language_trampoline (CORE_ADDR pc);
the implementation iterates through all registered languages looking for
and calling any non-NULL struct language_defn.skip_trampoline()
functions. Returning the result from the first that returns non-zero,
or 0 if all `fail'.
- add to objc-lang.c, a language specific objc_skip_trampoline() that
implements the above
- just confirm that the objc_skip_trampoline() only does target side
accesses (memory/register read/write) after it's confirmed that there is
a valid objc symbol. No valid objc symbol, no target access.
- for infrun.c, before the existing SKIP_TRAMPOLINE() call, make a call
to skip_language_trampoline() and then, only if that `fails', try the
SKIP_TRAMPOLINE() method.
The intent of all this is to make it possible to at leat enable objc on
selective natives, and then over time make it more portable.
Andrew
(1) I noticed that the parameter extract methods assume host=target.
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] Step over Objective-C dispatch function
2003-03-20 21:08 ` Andrew Cagney
@ 2003-03-25 15:56 ` Adam Fedor
2003-03-25 16:25 ` Andrew Cagney
0 siblings, 1 reply; 8+ messages in thread
From: Adam Fedor @ 2003-03-25 15:56 UTC (permalink / raw)
To: Andrew Cagney; +Cc: GDB Patches
[-- 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 */
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] Step over Objective-C dispatch function
2003-03-25 15:56 ` Adam Fedor
@ 2003-03-25 16:25 ` Andrew Cagney
2003-03-25 16:41 ` Andrew Cagney
0 siblings, 1 reply; 8+ messages in thread
From: Andrew Cagney @ 2003-03-25 16:25 UTC (permalink / raw)
To: Adam Fedor; +Cc: GDB Patches
Minor tweaks:
> 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);
GNU puts a space between the function and its arguments vis:
skip_language_trampoline (stop_pc)
check the other code for this.
> + 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;
>
> +/* 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;
Return 0. Otherwize, the old SKIP_TRAMPOLINE_CODE() won't kick in.
> + /* 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);
> +
yep.
Otherwize approved.
Andrew
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] Step over Objective-C dispatch function
2003-03-25 16:25 ` Andrew Cagney
@ 2003-03-25 16:41 ` Andrew Cagney
0 siblings, 0 replies; 8+ messages in thread
From: Andrew Cagney @ 2003-03-25 16:41 UTC (permalink / raw)
To: Andrew Cagney; +Cc: Adam Fedor, GDB Patches
> +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;
>
> Return 0. Otherwize, the old SKIP_TRAMPOLINE_CODE() won't kick in.
Actually, never mind. Although:
CORE_ADDR real_pc = ...
if (real_pc)
return real_pc;
...
return 0;
might be easier to read.
Andrew
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2003-03-25 16:41 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-01-03 3:35 [PATCH] Step over Objective-C dispatch function 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
2003-03-25 16:25 ` Andrew Cagney
2003-03-25 16:41 ` Andrew Cagney
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox