This is the mail archive of the
gdb-patches@sources.redhat.com
mailing list for the GDB project.
Re: [patch/rfc] Deprecate FUNCTION_START_OFFSET
- From: Andrew Cagney <cagney at gnu dot org>
- To: gdb-patches at sources dot redhat dot com
- Date: Fri, 18 Jun 2004 17:37:09 -0400
- Subject: Re: [patch/rfc] Deprecate FUNCTION_START_OFFSET
- References: <40C88077.1020906@gnu.org>
Hello,
Ref: http://sources.redhat.com/ml/gdb-patches/2004-05/msg00098.html
Hello,
Looking over the Randolph's PA descriptor problem drew my attention to FUNCTION_START_OFFSET. The VAX uses this to ``adjust'' a function pointer so that it instead points to the function's code address (the first few bytes of a vax function are not executible and need to be skipped over).
Thing is, this conversion is exactly what CONVERT_FUNC_PTR_ADDR is for. Given a function pointer return the function's code address. Given this overlap, I think FUNCTION_START_OFFSET should be deprecated - it is redundant.
The only got-ya is with GDB's lack of dicipline when it comes to correctly differentiating between function pointers and code addresses. This is clearly illustrated by the current 64-bit GNU/Linux PPC code: for that OSABI, instead of having function pointers address the function's descriptor, GDB has function pointers addressing the function's code address - definitly wrong(1). Eliminating FUNCTION_START_OFFSET will result in other code being ``fixed''.
comments,
Andrew
(1) This is why function parameters don't work for that OSABI - GDB passes the incorrect value to push dummy call.
The attached deprecates FUNCTION_START_OFFSET.
I'll look to commit in a week,
(and a day) The attached is the final commit - I missed a few deprecates :-(
Andrew
2004-06-18 Andrew Cagney <cagney@gnu.org>
* gdbarch.sh (DEPRECATED_FUNCTION_START_OFFSET): Deprecated.
* gdbarch.h, gdbarch.c: Re-generate.
* ada-lang.c (ada_finish_decode_line_1): Update.
* infrun.c (handle_inferior_event): Update.
* infcall.c (find_function_addr): Update.
* linespec.c (minsym_found): Update.
* symtab.c (find_function_start_sal, skip_prologue_using_sal):
Update.
* blockframe.c (legacy_frameless_look_for_prologue): Update.
* cli/cli-cmds.c (disassemble_command): Update.
* vax-tdep.c (vax_gdbarch_init): Update.
Index: doc/ChangeLog
2004-06-18 Andrew Cagney <cagney@gnu.org>
* gdbint.texinfo (Target Architecture Definition): Deprecate
FUNCTION_START_OFFSET.
Index: ada-lang.c
===================================================================
RCS file: /cvs/src/src/gdb/ada-lang.c,v
retrieving revision 1.38
diff -p -u -r1.38 ada-lang.c
--- ada-lang.c 16 Jun 2004 08:18:05 -0000 1.38
+++ ada-lang.c 18 Jun 2004 21:16:05 -0000
@@ -5596,7 +5596,7 @@ ada_finish_decode_line_1 (char **spec, s
val.section = SYMBOL_BFD_SECTION (msymbol);
if (funfirstline)
{
- val.pc += FUNCTION_START_OFFSET;
+ val.pc += DEPRECATED_FUNCTION_START_OFFSET;
SKIP_PROLOGUE (val.pc);
}
selected.sals = (struct symtab_and_line *)
Index: arm-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/arm-tdep.c,v
retrieving revision 1.175
diff -p -u -r1.175 arm-tdep.c
--- arm-tdep.c 10 Jun 2004 13:22:05 -0000 1.175
+++ arm-tdep.c 18 Jun 2004 21:16:05 -0000
@@ -291,7 +291,7 @@ arm_frameless_function_invocation (struc
stmdb sp!, {}
sub sp, ip, #4. */
- func_start = (get_frame_func (fi) + FUNCTION_START_OFFSET);
+ func_start = (get_frame_func (fi) + DEPRECATED_FUNCTION_START_OFFSET);
after_prologue = SKIP_PROLOGUE (func_start);
/* There are some frameless functions whose first two instructions
Index: blockframe.c
===================================================================
RCS file: /cvs/src/src/gdb/blockframe.c,v
retrieving revision 1.102
diff -p -u -r1.102 blockframe.c
--- blockframe.c 11 Jun 2004 00:41:56 -0000 1.102
+++ blockframe.c 18 Jun 2004 21:16:05 -0000
@@ -147,7 +147,7 @@ legacy_frameless_look_for_prologue (stru
func_start = get_frame_func (frame);
if (func_start)
{
- func_start += FUNCTION_START_OFFSET;
+ func_start += DEPRECATED_FUNCTION_START_OFFSET;
/* NOTE: cagney/2004-02-09: Eliminated per-architecture
PROLOGUE_FRAMELESS_P call as architectures with custom
implementations had all been deleted. Eventually even this
Index: gdbarch.c
===================================================================
RCS file: /cvs/src/src/gdb/gdbarch.c,v
retrieving revision 1.296
diff -p -u -r1.296 gdbarch.c
--- gdbarch.c 13 Jun 2004 13:49:53 -0000 1.296
+++ gdbarch.c 18 Jun 2004 21:16:05 -0000
@@ -197,7 +197,7 @@ struct gdbarch
gdbarch_memory_insert_breakpoint_ftype *memory_insert_breakpoint;
gdbarch_memory_remove_breakpoint_ftype *memory_remove_breakpoint;
CORE_ADDR decr_pc_after_break;
- CORE_ADDR function_start_offset;
+ CORE_ADDR deprecated_function_start_offset;
gdbarch_remote_translate_xfer_address_ftype *remote_translate_xfer_address;
CORE_ADDR frame_args_skip;
gdbarch_deprecated_frameless_function_invocation_ftype *deprecated_frameless_function_invocation;
@@ -343,7 +343,7 @@ struct gdbarch startup_gdbarch =
0, /* memory_insert_breakpoint */
0, /* memory_remove_breakpoint */
0, /* decr_pc_after_break */
- 0, /* function_start_offset */
+ 0, /* deprecated_function_start_offset */
generic_remote_translate_xfer_address, /* remote_translate_xfer_address */
0, /* frame_args_skip */
0, /* deprecated_frameless_function_invocation */
@@ -621,7 +621,7 @@ verify_gdbarch (struct gdbarch *current_
/* Skip verify of memory_insert_breakpoint, invalid_p == 0 */
/* Skip verify of memory_remove_breakpoint, invalid_p == 0 */
/* Skip verify of decr_pc_after_break, invalid_p == 0 */
- /* Skip verify of function_start_offset, invalid_p == 0 */
+ /* Skip verify of deprecated_function_start_offset, invalid_p == 0 */
/* Skip verify of remote_translate_xfer_address, invalid_p == 0 */
/* Skip verify of frame_args_skip, invalid_p == 0 */
/* Skip verify of deprecated_frameless_function_invocation, has predicate */
@@ -1084,6 +1084,14 @@ gdbarch_dump (struct gdbarch *current_gd
(long) current_gdbarch->deprecated_frame_saved_pc
/*DEPRECATED_FRAME_SAVED_PC ()*/);
#endif
+#ifdef DEPRECATED_FUNCTION_START_OFFSET
+ fprintf_unfiltered (file,
+ "gdbarch_dump: DEPRECATED_FUNCTION_START_OFFSET # %s\n",
+ XSTRING (DEPRECATED_FUNCTION_START_OFFSET));
+ fprintf_unfiltered (file,
+ "gdbarch_dump: DEPRECATED_FUNCTION_START_OFFSET = %ld\n",
+ (long) DEPRECATED_FUNCTION_START_OFFSET);
+#endif
#ifdef DEPRECATED_GET_SAVED_REGISTER_P
fprintf_unfiltered (file,
"gdbarch_dump: %s # %s\n",
@@ -1526,14 +1534,6 @@ gdbarch_dump (struct gdbarch *current_gd
"gdbarch_dump: FRAME_RED_ZONE_SIZE = %d\n",
FRAME_RED_ZONE_SIZE);
#endif
-#ifdef FUNCTION_START_OFFSET
- fprintf_unfiltered (file,
- "gdbarch_dump: FUNCTION_START_OFFSET # %s\n",
- XSTRING (FUNCTION_START_OFFSET));
- fprintf_unfiltered (file,
- "gdbarch_dump: FUNCTION_START_OFFSET = %ld\n",
- (long) FUNCTION_START_OFFSET);
-#endif
#ifdef GET_LONGJMP_TARGET_P
fprintf_unfiltered (file,
"gdbarch_dump: %s # %s\n",
@@ -3760,20 +3760,20 @@ set_gdbarch_decr_pc_after_break (struct
}
CORE_ADDR
-gdbarch_function_start_offset (struct gdbarch *gdbarch)
+gdbarch_deprecated_function_start_offset (struct gdbarch *gdbarch)
{
gdb_assert (gdbarch != NULL);
- /* Skip verify of function_start_offset, invalid_p == 0 */
+ /* Skip verify of deprecated_function_start_offset, invalid_p == 0 */
if (gdbarch_debug >= 2)
- fprintf_unfiltered (gdb_stdlog, "gdbarch_function_start_offset called\n");
- return gdbarch->function_start_offset;
+ fprintf_unfiltered (gdb_stdlog, "gdbarch_deprecated_function_start_offset called\n");
+ return gdbarch->deprecated_function_start_offset;
}
void
-set_gdbarch_function_start_offset (struct gdbarch *gdbarch,
- CORE_ADDR function_start_offset)
+set_gdbarch_deprecated_function_start_offset (struct gdbarch *gdbarch,
+ CORE_ADDR deprecated_function_start_offset)
{
- gdbarch->function_start_offset = function_start_offset;
+ gdbarch->deprecated_function_start_offset = deprecated_function_start_offset;
}
void
Index: gdbarch.h
===================================================================
RCS file: /cvs/src/src/gdb/gdbarch.h,v
retrieving revision 1.260
diff -p -u -r1.260 gdbarch.h
--- gdbarch.h 13 Jun 2004 17:04:49 -0000 1.260
+++ gdbarch.h 18 Jun 2004 21:16:06 -0000
@@ -1312,13 +1312,21 @@ extern void set_gdbarch_decr_pc_after_br
#define DECR_PC_AFTER_BREAK (gdbarch_decr_pc_after_break (current_gdbarch))
#endif
-extern CORE_ADDR gdbarch_function_start_offset (struct gdbarch *gdbarch);
-extern void set_gdbarch_function_start_offset (struct gdbarch *gdbarch, CORE_ADDR function_start_offset);
-#if (GDB_MULTI_ARCH > GDB_MULTI_ARCH_PARTIAL) && defined (FUNCTION_START_OFFSET)
-#error "Non multi-arch definition of FUNCTION_START_OFFSET"
+/* A function can be addressed by either it's "pointer" (possibly a
+ descriptor address) or "entry point" (first executable instruction).
+ The method "convert_from_func_ptr_addr" converting the former to the
+ latter. DEPRECATED_FUNCTION_START_OFFSET is being used to implement
+ a simplified subset of that functionality - the function's address
+ corresponds to the "function pointer" and the function's start
+ corresponds to the "function entry point" - and hence is redundant. */
+
+extern CORE_ADDR gdbarch_deprecated_function_start_offset (struct gdbarch *gdbarch);
+extern void set_gdbarch_deprecated_function_start_offset (struct gdbarch *gdbarch, CORE_ADDR deprecated_function_start_offset);
+#if (GDB_MULTI_ARCH > GDB_MULTI_ARCH_PARTIAL) && defined (DEPRECATED_FUNCTION_START_OFFSET)
+#error "Non multi-arch definition of DEPRECATED_FUNCTION_START_OFFSET"
#endif
-#if !defined (FUNCTION_START_OFFSET)
-#define FUNCTION_START_OFFSET (gdbarch_function_start_offset (current_gdbarch))
+#if !defined (DEPRECATED_FUNCTION_START_OFFSET)
+#define DEPRECATED_FUNCTION_START_OFFSET (gdbarch_deprecated_function_start_offset (current_gdbarch))
#endif
typedef void (gdbarch_remote_translate_xfer_address_ftype) (struct gdbarch *gdbarch, struct regcache *regcache, CORE_ADDR gdb_addr, int gdb_len, CORE_ADDR *rem_addr, int *rem_len);
Index: gdbarch.sh
===================================================================
RCS file: /cvs/src/src/gdb/gdbarch.sh,v
retrieving revision 1.325
diff -p -u -r1.325 gdbarch.sh
--- gdbarch.sh 13 Jun 2004 17:04:49 -0000 1.325
+++ gdbarch.sh 18 Jun 2004 21:16:06 -0000
@@ -583,8 +583,17 @@ M:ADJUST_BREAKPOINT_ADDRESS:CORE_ADDR:ad
f:MEMORY_INSERT_BREAKPOINT:int:memory_insert_breakpoint:CORE_ADDR addr, char *contents_cache:addr, contents_cache::0:default_memory_insert_breakpoint::0
f:MEMORY_REMOVE_BREAKPOINT:int:memory_remove_breakpoint:CORE_ADDR addr, char *contents_cache:addr, contents_cache::0:default_memory_remove_breakpoint::0
v:DECR_PC_AFTER_BREAK:CORE_ADDR:decr_pc_after_break::::0:::0
-v:FUNCTION_START_OFFSET:CORE_ADDR:function_start_offset::::0:::0
-#
+
+# A function can be addressed by either it's "pointer" (possibly a
+# descriptor address) or "entry point" (first executable instruction).
+# The method "convert_from_func_ptr_addr" converting the former to the
+# latter. DEPRECATED_FUNCTION_START_OFFSET is being used to implement
+# a simplified subset of that functionality - the function's address
+# corresponds to the "function pointer" and the function's start
+# corresponds to the "function entry point" - and hence is redundant.
+
+v:DEPRECATED_FUNCTION_START_OFFSET:CORE_ADDR:deprecated_function_start_offset::::0:::0
+
m:REMOTE_TRANSLATE_XFER_ADDRESS:void:remote_translate_xfer_address:struct regcache *regcache, CORE_ADDR gdb_addr, int gdb_len, CORE_ADDR *rem_addr, int *rem_len:regcache, gdb_addr, gdb_len, rem_addr, rem_len:::generic_remote_translate_xfer_address::0
#
v:FRAME_ARGS_SKIP:CORE_ADDR:frame_args_skip::::0:::0
Index: infcall.c
===================================================================
RCS file: /cvs/src/src/gdb/infcall.c,v
retrieving revision 1.50
diff -p -u -r1.50 infcall.c
--- infcall.c 12 Jun 2004 18:02:29 -0000 1.50
+++ infcall.c 18 Jun 2004 21:16:06 -0000
@@ -207,7 +207,7 @@ find_function_addr (struct value *functi
if (retval_type != NULL)
*retval_type = value_type;
- return funaddr + FUNCTION_START_OFFSET;
+ return funaddr + DEPRECATED_FUNCTION_START_OFFSET;
}
/* Call breakpoint_auto_delete on the current contents of the bpstat
Index: infrun.c
===================================================================
RCS file: /cvs/src/src/gdb/infrun.c,v
retrieving revision 1.166
diff -p -u -r1.166 infrun.c
--- infrun.c 11 Jun 2004 23:39:51 -0000 1.166
+++ infrun.c 18 Jun 2004 21:16:06 -0000
@@ -1817,7 +1817,7 @@ handle_inferior_event (struct execution_
will both be 0 if it doesn't work. */
find_pc_partial_function (stop_pc, &ecs->stop_func_name,
&ecs->stop_func_start, &ecs->stop_func_end);
- ecs->stop_func_start += FUNCTION_START_OFFSET;
+ ecs->stop_func_start += DEPRECATED_FUNCTION_START_OFFSET;
ecs->another_trap = 0;
bpstat_clear (&stop_bpstat);
stop_step = 0;
Index: linespec.c
===================================================================
RCS file: /cvs/src/src/gdb/linespec.c,v
retrieving revision 1.56
diff -p -u -r1.56 linespec.c
--- linespec.c 11 Feb 2004 18:04:14 -0000 1.56
+++ linespec.c 18 Jun 2004 21:16:06 -0000
@@ -1842,7 +1842,7 @@ minsym_found (int funfirstline, struct m
values.sals[0].section = SYMBOL_BFD_SECTION (msymbol);
if (funfirstline)
{
- values.sals[0].pc += FUNCTION_START_OFFSET;
+ values.sals[0].pc += DEPRECATED_FUNCTION_START_OFFSET;
values.sals[0].pc = SKIP_PROLOGUE (values.sals[0].pc);
}
values.nelts = 1;
Index: symtab.c
===================================================================
RCS file: /cvs/src/src/gdb/symtab.c,v
retrieving revision 1.132
diff -p -u -r1.132 symtab.c
--- symtab.c 10 Jun 2004 20:05:44 -0000 1.132
+++ symtab.c 18 Jun 2004 21:16:06 -0000
@@ -2413,7 +2413,7 @@ find_function_start_sal (struct symbol *
!section_is_mapped (section))
pc = overlay_unmapped_address (pc, section);
- pc += FUNCTION_START_OFFSET;
+ pc += DEPRECATED_FUNCTION_START_OFFSET;
pc = SKIP_PROLOGUE (pc);
/* For overlays, map pc back into its mapped VMA range */
@@ -3985,7 +3985,7 @@ skip_prologue_using_sal (CORE_ADDR func_
/* Get an initial range for the function. */
find_pc_partial_function (func_addr, NULL, &start_pc, &end_pc);
- start_pc += FUNCTION_START_OFFSET;
+ start_pc += DEPRECATED_FUNCTION_START_OFFSET;
prologue_sal = find_pc_line (start_pc, 0);
if (prologue_sal.line != 0)
Index: vax-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/vax-tdep.c,v
retrieving revision 1.81
diff -p -u -r1.81 vax-tdep.c
--- vax-tdep.c 7 Jun 2004 02:02:55 -0000 1.81
+++ vax-tdep.c 18 Jun 2004 21:16:06 -0000
@@ -506,7 +506,7 @@ vax_gdbarch_init (struct gdbarch_info in
set_gdbarch_breakpoint_from_pc (gdbarch, vax_breakpoint_from_pc);
/* Misc info */
- set_gdbarch_function_start_offset (gdbarch, 2);
+ set_gdbarch_deprecated_function_start_offset (gdbarch, 2);
set_gdbarch_believe_pcc_promotion (gdbarch, 1);
set_gdbarch_print_insn (gdbarch, print_insn_vax);
Index: cli/cli-cmds.c
===================================================================
RCS file: /cvs/src/src/gdb/cli/cli-cmds.c,v
retrieving revision 1.43
diff -p -u -r1.43 cli-cmds.c
--- cli/cli-cmds.c 28 Feb 2004 18:04:37 -0000 1.43
+++ cli/cli-cmds.c 18 Jun 2004 21:16:07 -0000
@@ -858,7 +858,7 @@ disassemble_command (char *arg, int from
/* FIXME: cagney/2004-02-07: This should be an observer. */
low = tui_get_low_disassembly_address (low, pc);
#endif
- low += FUNCTION_START_OFFSET;
+ low += DEPRECATED_FUNCTION_START_OFFSET;
}
else if (!(space_index = (char *) strchr (arg, ' ')))
{
@@ -873,7 +873,7 @@ disassemble_command (char *arg, int from
/* FIXME: cagney/2004-02-07: This should be an observer. */
low = tui_get_low_disassembly_address (low, pc);
#endif
- low += FUNCTION_START_OFFSET;
+ low += DEPRECATED_FUNCTION_START_OFFSET;
}
else
{
Index: doc/gdbint.texinfo
===================================================================
RCS file: /cvs/src/src/gdb/doc/gdbint.texinfo,v
retrieving revision 1.209
diff -p -u -r1.209 gdbint.texinfo
--- doc/gdbint.texinfo 14 Jun 2004 22:26:34 -0000 1.209
+++ doc/gdbint.texinfo 18 Jun 2004 21:16:07 -0000
@@ -3260,20 +3260,20 @@ function end symbol is 0. For such targ
@code{FUNCTION_EPILOGUE_SIZE} to expand into the standard size of a
function's epilogue.
-@item FUNCTION_START_OFFSET
-@findex FUNCTION_START_OFFSET
+@item DEPRECATED_FUNCTION_START_OFFSET
+@findex DEPRECATED_FUNCTION_START_OFFSET
An integer, giving the offset in bytes from a function's address (as
used in the values of symbols, function pointers, etc.), and the
function's first genuine instruction.
This is zero on almost all machines: the function's address is usually
-the address of its first instruction. However, on the VAX, for example,
-each function starts with two bytes containing a bitmask indicating
-which registers to save upon entry to the function. The VAX @code{call}
-instructions check this value, and save the appropriate registers
-automatically. Thus, since the offset from the function's address to
-its first instruction is two bytes, @code{FUNCTION_START_OFFSET} would
-be 2 on the VAX.
+the address of its first instruction. However, on the VAX, for
+example, each function starts with two bytes containing a bitmask
+indicating which registers to save upon entry to the function. The
+VAX @code{call} instructions check this value, and save the
+appropriate registers automatically. Thus, since the offset from the
+function's address to its first instruction is two bytes,
+@code{DEPRECATED_FUNCTION_START_OFFSET} would be 2 on the VAX.
@item GCC_COMPILED_FLAG_SYMBOL
@itemx GCC2_COMPILED_FLAG_SYMBOL