This is the mail archive of the
gdb-patches@sources.redhat.com
mailing list for the GDB project.
[patch/rfc] Deprecate FUNCTION_START_OFFSET
- From: Andrew Cagney <cagney at gnu dot org>
- To: gdb-patches at sources dot redhat dot com
- Date: Thu, 10 Jun 2004 11:38:31 -0400
- Subject: [patch/rfc] Deprecate FUNCTION_START_OFFSET
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,
Andrew
2004-06-10 Andrew Cagney <cagney@gnu.org>
* gdbarch.sh (DEPRECATED_FUNCTION_START_OFFSET): Deprecated.
* gdbarch.h, gdbarch.c: Re-generate.
* 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: blockframe.c
===================================================================
RCS file: /cvs/src/src/gdb/blockframe.c,v
retrieving revision 1.101
diff -p -u -r1.101 blockframe.c
--- blockframe.c 10 Jun 2004 13:22:05 -0000 1.101
+++ blockframe.c 10 Jun 2004 15:28:15 -0000
@@ -167,7 +167,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.294
diff -p -u -r1.294 gdbarch.c
--- gdbarch.c 10 Jun 2004 13:22:05 -0000 1.294
+++ gdbarch.c 10 Jun 2004 15:28:15 -0000
@@ -200,7 +200,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;
@@ -349,7 +349,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 */
@@ -631,7 +631,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 */
@@ -1094,6 +1094,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",
@@ -1570,14 +1578,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",
@@ -3877,20 +3877,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.256
diff -p -u -r1.256 gdbarch.h
--- gdbarch.h 10 Jun 2004 13:22:06 -0000 1.256
+++ gdbarch.h 10 Jun 2004 15:28:15 -0000
@@ -1377,13 +1377,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.321
diff -p -u -r1.321 gdbarch.sh
--- gdbarch.sh 10 Jun 2004 13:22:06 -0000 1.321
+++ gdbarch.sh 10 Jun 2004 15:28:16 -0000
@@ -604,7 +604,16 @@ M:2:ADJUST_BREAKPOINT_ADDRESS:CORE_ADDR:
f:2:MEMORY_INSERT_BREAKPOINT:int:memory_insert_breakpoint:CORE_ADDR addr, char *contents_cache:addr, contents_cache::0:default_memory_insert_breakpoint::0
f:2:MEMORY_REMOVE_BREAKPOINT:int:memory_remove_breakpoint:CORE_ADDR addr, char *contents_cache:addr, contents_cache::0:default_memory_remove_breakpoint::0
v:2:DECR_PC_AFTER_BREAK:CORE_ADDR:decr_pc_after_break::::0:::0
-v:2: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:2: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
#
Index: infcall.c
===================================================================
RCS file: /cvs/src/src/gdb/infcall.c,v
retrieving revision 1.48
diff -p -u -r1.48 infcall.c
--- infcall.c 7 Jun 2004 02:02:50 -0000 1.48
+++ infcall.c 10 Jun 2004 15:28:16 -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.165
diff -p -u -r1.165 infrun.c
--- infrun.c 7 Jun 2004 02:19:07 -0000 1.165
+++ infrun.c 10 Jun 2004 15:28:16 -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 10 Jun 2004 15:28:16 -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.131
diff -p -u -r1.131 symtab.c
--- symtab.c 24 May 2004 16:11:17 -0000 1.131
+++ symtab.c 10 Jun 2004 15:28:18 -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 10 Jun 2004 15:28:18 -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 10 Jun 2004 15:28:18 -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
{