* [RFA]: gdbarch FETCH_POINTER_ARGUMENT
@ 2003-05-19 3:12 Adam Fedor
2003-05-20 20:07 ` Andrew Cagney
0 siblings, 1 reply; 11+ messages in thread
From: Adam Fedor @ 2003-05-19 3:12 UTC (permalink / raw)
To: GDB Patches; +Cc: Daniel Jacobowitz
[-- Attachment #1: Type: text/plain, Size: 208 bytes --]
This patch added some arch-specific macros that aid in getting function
forwarding information, namely a macro to get the arguments in a
function. Hopefully someone can figure out a good way to test it...
[-- Attachment #2: gdbarch.patch --]
[-- Type: text/plain, Size: 17929 bytes --]
2003-05-18 Adam Fedor <fedor@gnu.org>
* gdbarch.sh (function_list): Add FETCH_POINTER_ARGUMENT,
CONVERT_FUNCTION_POINTER.
* gdbarch.[ch]: Regenerate.
* arch-utils.c (default_convert_function_pointer): New function.
* arch-utils.h (default_convert_function_pointer): Add definition.
* hppa-tdep.c (hppa_fetch_pointer_argument,
hppa_convert_function_pointer): New functions.
(hppa_gdbarch_init): Set them in the gdbarch vector.
* i386-tdep.c (i386_fetch_pointer_argument): New
(i386_gdbarch_init): Set it into gdbarch.
* rs6000-tdep.c (rs6000_fetch_pointer_argument): New.
(rs6000_gdbarch_init): Set it in gdbarch.
* sparc-tdep.c (sparc_fetch_pointer_argument): New
(sparc_gdbarch_init): Set it in gdbarch.
* objc-lang.c (FETCH_ARGUMENT, CONVERT_FUNCPTRE): Remove.
(read_objc_method, resolve_msgsend, resolve_msgsend_stret,
resolve_msgsend_super, resolve_msgsend_super_stret): Rename macros
to FETCH_POINTER_ARGUMENT, CONVERT_FUNCTION_POINTER.
Index: arch-utils.c
===================================================================
RCS file: /cvs/src/src/gdb/arch-utils.c,v
retrieving revision 1.83
diff -u -p -r1.83 arch-utils.c
--- arch-utils.c 15 May 2003 22:58:36 -0000 1.83
+++ arch-utils.c 19 May 2003 02:28:33 -0000
@@ -362,6 +362,12 @@ default_coff_make_msymbol_special (int v
return;
}
+CORE_ADDR
+default_convert_function_pointer (CORE_ADDR pc)
+{
+ return pc;
+}
+
int
cannot_register_not (int regnum)
{
Index: arch-utils.h
===================================================================
RCS file: /cvs/src/src/gdb/arch-utils.h,v
retrieving revision 1.46
diff -u -p -r1.46 arch-utils.h
--- arch-utils.h 15 May 2003 22:58:36 -0000 1.46
+++ arch-utils.h 19 May 2003 02:28:33 -0000
@@ -130,6 +130,9 @@ void default_elf_make_msymbol_special (a
void default_coff_make_msymbol_special (int val, struct minimal_symbol *msym);
+/* Default convert_function_pointer */
+CORE_ADDR default_convert_function_pointer (CORE_ADDR pc);
+
/* Version of cannot_fetch_register() / cannot_store_register() that
always fails. */
Index: gdbarch.c
===================================================================
RCS file: /cvs/src/src/gdb/gdbarch.c,v
retrieving revision 1.216
diff -u -p -r1.216 gdbarch.c
--- gdbarch.c 17 May 2003 05:59:58 -0000 1.216
+++ gdbarch.c 19 May 2003 02:28:52 -0000
@@ -280,6 +280,8 @@ struct gdbarch
gdbarch_address_class_type_flags_to_name_ftype *address_class_type_flags_to_name;
gdbarch_address_class_name_to_type_flags_ftype *address_class_name_to_type_flags;
gdbarch_register_reggroup_p_ftype *register_reggroup_p;
+ gdbarch_fetch_pointer_argument_ftype *fetch_pointer_argument;
+ gdbarch_convert_function_pointer_ftype *convert_function_pointer;
};
@@ -446,6 +448,8 @@ struct gdbarch startup_gdbarch =
0,
0,
default_register_reggroup_p,
+ 0,
+ 0,
/* startup_gdbarch() */
};
@@ -564,6 +568,7 @@ gdbarch_alloc (const struct gdbarch_info
current_gdbarch->coff_make_msymbol_special = default_coff_make_msymbol_special;
current_gdbarch->name_of_malloc = "malloc";
current_gdbarch->register_reggroup_p = default_register_reggroup_p;
+ current_gdbarch->convert_function_pointer = default_convert_function_pointer;
/* gdbarch_alloc() */
return current_gdbarch;
@@ -762,6 +767,9 @@ verify_gdbarch (struct gdbarch *gdbarch)
/* Skip verify of address_class_type_flags_to_name, has predicate */
/* Skip verify of address_class_name_to_type_flags, has predicate */
/* Skip verify of register_reggroup_p, invalid_p == 0 */
+ if ((GDB_MULTI_ARCH > GDB_MULTI_ARCH_PARTIAL)
+ && (gdbarch->convert_function_pointer == default_convert_function_pointer))
+ fprintf_unfiltered (log, "\n\tconvert_function_pointer");
buf = ui_file_xstrdup (log, &dummy);
make_cleanup (xfree, buf);
if (strlen (buf) > 0)
@@ -984,6 +992,17 @@ gdbarch_dump (struct gdbarch *gdbarch, s
(long) current_gdbarch->convert_from_func_ptr_addr
/*CONVERT_FROM_FUNC_PTR_ADDR ()*/);
#endif
+#ifdef CONVERT_FUNCTION_POINTER
+ fprintf_unfiltered (file,
+ "gdbarch_dump: %s # %s\n",
+ "CONVERT_FUNCTION_POINTER(pc)",
+ XSTRING (CONVERT_FUNCTION_POINTER (pc)));
+ if (GDB_MULTI_ARCH)
+ fprintf_unfiltered (file,
+ "gdbarch_dump: CONVERT_FUNCTION_POINTER = <0x%08lx>\n",
+ (long) current_gdbarch->convert_function_pointer
+ /*CONVERT_FUNCTION_POINTER ()*/);
+#endif
#ifdef CONVERT_REGISTER_P
fprintf_unfiltered (file,
"gdbarch_dump: %s # %s\n",
@@ -1693,6 +1712,17 @@ gdbarch_dump (struct gdbarch *gdbarch, s
(long) current_gdbarch->extract_struct_value_address
/*EXTRACT_STRUCT_VALUE_ADDRESS ()*/);
#endif
+#ifdef FETCH_POINTER_ARGUMENT
+ fprintf_unfiltered (file,
+ "gdbarch_dump: %s # %s\n",
+ "FETCH_POINTER_ARGUMENT(i)",
+ XSTRING (FETCH_POINTER_ARGUMENT (i)));
+ if (GDB_MULTI_ARCH)
+ fprintf_unfiltered (file,
+ "gdbarch_dump: FETCH_POINTER_ARGUMENT = <0x%08lx>\n",
+ (long) current_gdbarch->fetch_pointer_argument
+ /*FETCH_POINTER_ARGUMENT ()*/);
+#endif
#ifdef FP0_REGNUM
fprintf_unfiltered (file,
"gdbarch_dump: FP0_REGNUM # %s\n",
@@ -5689,6 +5719,44 @@ set_gdbarch_register_reggroup_p (struct
gdbarch_register_reggroup_p_ftype register_reggroup_p)
{
gdbarch->register_reggroup_p = register_reggroup_p;
+}
+
+unsigned long
+gdbarch_fetch_pointer_argument (struct gdbarch *gdbarch, int i)
+{
+ gdb_assert (gdbarch != NULL);
+ if (gdbarch->fetch_pointer_argument == 0)
+ internal_error (__FILE__, __LINE__,
+ "gdbarch: gdbarch_fetch_pointer_argument invalid");
+ if (gdbarch_debug >= 2)
+ fprintf_unfiltered (gdb_stdlog, "gdbarch_fetch_pointer_argument called\n");
+ return gdbarch->fetch_pointer_argument (i);
+}
+
+void
+set_gdbarch_fetch_pointer_argument (struct gdbarch *gdbarch,
+ gdbarch_fetch_pointer_argument_ftype fetch_pointer_argument)
+{
+ gdbarch->fetch_pointer_argument = fetch_pointer_argument;
+}
+
+CORE_ADDR
+gdbarch_convert_function_pointer (struct gdbarch *gdbarch, CORE_ADDR pc)
+{
+ gdb_assert (gdbarch != NULL);
+ if (gdbarch->convert_function_pointer == 0)
+ internal_error (__FILE__, __LINE__,
+ "gdbarch: gdbarch_convert_function_pointer invalid");
+ if (gdbarch_debug >= 2)
+ fprintf_unfiltered (gdb_stdlog, "gdbarch_convert_function_pointer called\n");
+ return gdbarch->convert_function_pointer (pc);
+}
+
+void
+set_gdbarch_convert_function_pointer (struct gdbarch *gdbarch,
+ gdbarch_convert_function_pointer_ftype convert_function_pointer)
+{
+ gdbarch->convert_function_pointer = convert_function_pointer;
}
Index: gdbarch.h
===================================================================
RCS file: /cvs/src/src/gdb/gdbarch.h,v
retrieving revision 1.185
diff -u -p -r1.185 gdbarch.h
--- gdbarch.h 17 May 2003 05:59:58 -0000 1.185
+++ gdbarch.h 19 May 2003 02:28:57 -0000
@@ -3184,6 +3184,34 @@ typedef int (gdbarch_register_reggroup_p
extern int gdbarch_register_reggroup_p (struct gdbarch *gdbarch, int regnum, struct reggroup *reggroup);
extern void set_gdbarch_register_reggroup_p (struct gdbarch *gdbarch, gdbarch_register_reggroup_p_ftype *register_reggroup_p);
+/* Fetch the pointer to the ith function argument. */
+
+typedef unsigned long (gdbarch_fetch_pointer_argument_ftype) (int i);
+extern unsigned long gdbarch_fetch_pointer_argument (struct gdbarch *gdbarch, int i);
+extern void set_gdbarch_fetch_pointer_argument (struct gdbarch *gdbarch, gdbarch_fetch_pointer_argument_ftype *fetch_pointer_argument);
+#if (GDB_MULTI_ARCH > GDB_MULTI_ARCH_PARTIAL) && defined (FETCH_POINTER_ARGUMENT)
+#error "Non multi-arch definition of FETCH_POINTER_ARGUMENT"
+#endif
+#if GDB_MULTI_ARCH
+#if (GDB_MULTI_ARCH > GDB_MULTI_ARCH_PARTIAL) || !defined (FETCH_POINTER_ARGUMENT)
+#define FETCH_POINTER_ARGUMENT(i) (gdbarch_fetch_pointer_argument (current_gdbarch, i))
+#endif
+#endif
+
+/* Get the real address of the function. */
+
+typedef CORE_ADDR (gdbarch_convert_function_pointer_ftype) (CORE_ADDR pc);
+extern CORE_ADDR gdbarch_convert_function_pointer (struct gdbarch *gdbarch, CORE_ADDR pc);
+extern void set_gdbarch_convert_function_pointer (struct gdbarch *gdbarch, gdbarch_convert_function_pointer_ftype *convert_function_pointer);
+#if (GDB_MULTI_ARCH > GDB_MULTI_ARCH_PARTIAL) && defined (CONVERT_FUNCTION_POINTER)
+#error "Non multi-arch definition of CONVERT_FUNCTION_POINTER"
+#endif
+#if GDB_MULTI_ARCH
+#if (GDB_MULTI_ARCH > GDB_MULTI_ARCH_PARTIAL) || !defined (CONVERT_FUNCTION_POINTER)
+#define CONVERT_FUNCTION_POINTER(pc) (gdbarch_convert_function_pointer (current_gdbarch, pc))
+#endif
+#endif
+
extern struct gdbarch_tdep *gdbarch_tdep (struct gdbarch *gdbarch);
Index: gdbarch.sh
===================================================================
RCS file: /cvs/src/src/gdb/gdbarch.sh,v
retrieving revision 1.237
diff -u -p -r1.237 gdbarch.sh
--- gdbarch.sh 17 May 2003 05:59:58 -0000 1.237
+++ gdbarch.sh 19 May 2003 02:28:58 -0000
@@ -716,6 +716,10 @@ M:2:ADDRESS_CLASS_TYPE_FLAGS_TO_NAME:con
M:2:ADDRESS_CLASS_NAME_TO_TYPE_FLAGS:int:address_class_name_to_type_flags:const char *name, int *type_flags_ptr:name, type_flags_ptr
# Is a register in a group
m:::int:register_reggroup_p:int regnum, struct reggroup *reggroup:regnum, reggroup:::default_register_reggroup_p::0
+# Fetch the pointer to the ith function argument.
+f::FETCH_POINTER_ARGUMENT:unsigned long:fetch_pointer_argument:int i:i:::::::::
+# Get the real address of the function.
+f::CONVERT_FUNCTION_POINTER:CORE_ADDR:convert_function_pointer:CORE_ADDR pc:pc:::default_convert_function_pointer::::::
EOF
}
Index: hppa-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/hppa-tdep.c,v
retrieving revision 1.78
diff -u -p -r1.78 hppa-tdep.c
--- hppa-tdep.c 17 May 2003 05:59:58 -0000 1.78
+++ hppa-tdep.c 19 May 2003 02:29:02 -0000
@@ -4962,6 +4962,22 @@ hppa_smash_text_address (CORE_ADDR addr)
return (addr &= ~0x3);
}
+/* Get the ith function argument for the current function. */
+unsigned long
+hppa_fetch_pointer_argument (int i)
+{
+ return read_register (R0_REGNUM + 26 - i);
+}
+
+CORE_ADDR
+hppa_convert_function_pointer (CORE_ADDR pc)
+{
+ if (pc & 0x2)
+ pc = (CORE_ADDR) read_memory_integer (pc & ~0x3, 4);
+
+ return pc;
+}
+
static struct gdbarch *
hppa_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
{
@@ -5040,6 +5056,9 @@ hppa_gdbarch_init (struct gdbarch_info i
set_gdbarch_write_pc (gdbarch, hppa_target_write_pc);
set_gdbarch_deprecated_target_read_fp (gdbarch, hppa_target_read_fp);
+ /* Helpers for function argument information. */
+ set_gdbarch_fetch_pointer_argument (gdbarch, hppa_fetch_pointer_argument);
+ set_gdbarch_convert_function_pointer (gdbarch, hppa_convert_function_pointer);
return gdbarch;
}
Index: i386-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/i386-tdep.c,v
retrieving revision 1.144
diff -u -p -r1.144 i386-tdep.c
--- i386-tdep.c 17 May 2003 05:59:58 -0000 1.144
+++ i386-tdep.c 19 May 2003 02:29:07 -0000
@@ -1420,6 +1420,14 @@ i386_register_reggroup_p (struct gdbarch
return default_register_reggroup_p (gdbarch, regnum, group);
}
+/* Get the ith function argument for the current function. */
+unsigned long
+i386_fetch_pointer_argument (int i)
+{
+ CORE_ADDR stack = read_register (SP_REGNUM);
+ return read_memory_unsigned_integer (stack + (4 * (i + 1)), 4);
+}
+
\f
static struct gdbarch *
i386_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
@@ -1551,6 +1559,9 @@ i386_gdbarch_init (struct gdbarch_info i
/* Add the i386 register groups. */
i386_add_reggroups (gdbarch);
set_gdbarch_register_reggroup_p (gdbarch, i386_register_reggroup_p);
+
+ /* Helper for function argument information. */
+ set_gdbarch_fetch_pointer_argument (gdbarch, i386_fetch_pointer_argument);
/* Should be using push_dummy_call. */
set_gdbarch_deprecated_dummy_write_sp (gdbarch, generic_target_write_sp);
Index: objc-lang.c
===================================================================
RCS file: /cvs/src/src/gdb/objc-lang.c,v
retrieving revision 1.22
diff -u -p -r1.22 objc-lang.c
--- objc-lang.c 15 May 2003 22:18:42 -0000 1.22
+++ objc-lang.c 19 May 2003 02:29:08 -0000
@@ -1752,60 +1752,6 @@ _initialize_objc_language (void)
add_com_alias ("po", "print-object", class_vars, 1);
}
-#if 1
-/* Disable these functions until we put them in the gdbarch vector. */
-static unsigned long FETCH_ARGUMENT (int i)
-{
- internal_error (__FILE__, __LINE__, "FETCH_ARGUMENT not implemented");
- return 0;
-}
-static CORE_ADDR CONVERT_FUNCPTR (CORE_ADDR pc)
-{
- internal_error (__FILE__, __LINE__, "CONVERT_FUNCPTR not implemented");
- return pc;
-}
-#else
-#if defined (__powerpc__) || defined (__ppc__)
-static unsigned long FETCH_ARGUMENT (int i)
-{
- return read_register (3 + i);
-}
-#elif defined (__i386__)
-static unsigned long FETCH_ARGUMENT (int i)
-{
- CORE_ADDR stack = read_register (SP_REGNUM);
- return read_memory_unsigned_integer (stack + (4 * (i + 1)), 4);
-}
-#elif defined (__sparc__)
-static unsigned long FETCH_ARGUMENT (int i)
-{
- return read_register (O0_REGNUM + i);
-}
-#elif defined (__hppa__) || defined (__hppa)
-static unsigned long FETCH_ARGUMENT (int i)
-{
- return read_register (R0_REGNUM + 26 - i);
-}
-#else
-#error unknown architecture
-#endif
-
-#if defined (__hppa__) || defined (__hppa)
-static CORE_ADDR CONVERT_FUNCPTR (CORE_ADDR pc)
-{
- if (pc & 0x2)
- pc = (CORE_ADDR) read_memory_integer (pc & ~0x3, 4);
-
- return pc;
-}
-#else
-static CORE_ADDR CONVERT_FUNCPTR (CORE_ADDR pc)
-{
- return pc;
-}
-#endif
-#endif
-
static void
read_objc_method (CORE_ADDR addr, struct objc_method *method)
{
@@ -1894,7 +1840,7 @@ find_implementation_from_class (CORE_ADD
#endif
if (meth_str.name == sel)
- return CONVERT_FUNCPTR (meth_str.imp);
+ return CONVERT_FUNCTION_POINTER (meth_str.imp);
}
mlistnum++;
}
@@ -1925,8 +1871,8 @@ resolve_msgsend (CORE_ADDR pc, CORE_ADDR
CORE_ADDR sel;
CORE_ADDR res;
- object = FETCH_ARGUMENT (0);
- sel = FETCH_ARGUMENT (1);
+ object = FETCH_POINTER_ARGUMENT (0);
+ sel = FETCH_POINTER_ARGUMENT (1);
res = find_implementation (object, sel);
if (new_pc != 0)
@@ -1943,8 +1889,8 @@ resolve_msgsend_stret (CORE_ADDR pc, COR
CORE_ADDR sel;
CORE_ADDR res;
- object = FETCH_ARGUMENT (1);
- sel = FETCH_ARGUMENT (2);
+ object = FETCH_POINTER_ARGUMENT (1);
+ sel = FETCH_POINTER_ARGUMENT (2);
res = find_implementation (object, sel);
if (new_pc != 0)
@@ -1963,8 +1909,8 @@ resolve_msgsend_super (CORE_ADDR pc, COR
CORE_ADDR sel;
CORE_ADDR res;
- super = FETCH_ARGUMENT (0);
- sel = FETCH_ARGUMENT (1);
+ super = FETCH_POINTER_ARGUMENT (0);
+ sel = FETCH_POINTER_ARGUMENT (1);
read_objc_super (super, &sstr);
if (sstr.class == 0)
@@ -1987,8 +1933,8 @@ resolve_msgsend_super_stret (CORE_ADDR p
CORE_ADDR sel;
CORE_ADDR res;
- super = FETCH_ARGUMENT (1);
- sel = FETCH_ARGUMENT (2);
+ super = FETCH_POINTER_ARGUMENT (1);
+ sel = FETCH_POINTER_ARGUMENT (2);
read_objc_super (super, &sstr);
if (sstr.class == 0)
Index: rs6000-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/rs6000-tdep.c,v
retrieving revision 1.134
diff -u -p -r1.134 rs6000-tdep.c
--- rs6000-tdep.c 17 May 2003 05:59:58 -0000 1.134
+++ rs6000-tdep.c 19 May 2003 02:29:10 -0000
@@ -230,6 +230,13 @@ rs6000_saved_pc_after_call (struct frame
return read_register (gdbarch_tdep (current_gdbarch)->ppc_lr_regnum);
}
+/* Get the ith function argument for the current function. */
+unsigned long
+rs6000_fetch_pointer_argument (int i)
+{
+ return read_register (3 + i);
+}
+
/* Calculate the destination of a branch/jump. Return -1 if not a branch. */
static CORE_ADDR
@@ -2957,6 +2964,9 @@ rs6000_gdbarch_init (struct gdbarch_info
set_gdbarch_frame_args_address (gdbarch, rs6000_frame_args_address);
set_gdbarch_frame_locals_address (gdbarch, rs6000_frame_args_address);
set_gdbarch_deprecated_saved_pc_after_call (gdbarch, rs6000_saved_pc_after_call);
+
+ /* Helpers for function argument information. */
+ set_gdbarch_fetch_pointer_argument (gdbarch, rs6000_fetch_pointer_argument);
/* We can't tell how many args there are
now that the C compiler delays popping them. */
Index: sparc-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/sparc-tdep.c,v
retrieving revision 1.101
diff -u -p -r1.101 sparc-tdep.c
--- sparc-tdep.c 17 May 2003 05:59:59 -0000 1.101
+++ sparc-tdep.c 19 May 2003 02:29:11 -0000
@@ -3092,6 +3092,13 @@ sparc_return_value_on_stack (struct type
return 0;
}
+/* Get the ith function argument for the current function. */
+unsigned long
+sparc_fetch_pointer_argument (int i)
+{
+ return read_register (O0_REGNUM + i);
+}
+
/*
* Gdbarch "constructor" function.
*/
@@ -3201,6 +3208,9 @@ sparc_gdbarch_init (struct gdbarch_info
set_gdbarch_sp_regnum (gdbarch, SPARC_SP_REGNUM);
set_gdbarch_deprecated_use_generic_dummy_frames (gdbarch, 0);
set_gdbarch_write_pc (gdbarch, generic_target_write_pc);
+
+ /* Helper for function argument information. */
+ set_gdbarch_fetch_pointer_argument (gdbarch, sparc_fetch_pointer_argument);
/*
* Settings that depend only on 32/64 bit word size
^ permalink raw reply [flat|nested] 11+ messages in thread* Re: [RFA]: gdbarch FETCH_POINTER_ARGUMENT
2003-05-19 3:12 [RFA]: gdbarch FETCH_POINTER_ARGUMENT Adam Fedor
@ 2003-05-20 20:07 ` Andrew Cagney
2003-05-20 20:17 ` Daniel Jacobowitz
2003-05-22 19:16 ` Andrew Cagney
0 siblings, 2 replies; 11+ messages in thread
From: Andrew Cagney @ 2003-05-20 20:07 UTC (permalink / raw)
To: Adam Fedor; +Cc: GDB Patches, Daniel Jacobowitz
Adam,
I need to think about FETCH_POINTER_ARGUMENT. It needs additional
parameters - something to that lets it fetch registers or memory, and
something identifying the type of pointer.
As for convert function pointer, I think, at this stage, it would be
better to simply eliminate the only call:
@@ -1894,7 +1840,7 @@ find_implementation_from_class (CORE_ADD
#endif
if (meth_str.name == sel)
- return CONVERT_FUNCPTR (meth_str.imp);
+ return CONVERT_FUNCTION_POINTER (meth_str.imp);
}
mlistnum++;
}
replacing it with the code from the default case (do nothing), and a
comment mentioning that HP was doing a pointer dereference here. I think
it is better to leave this one to someone that can both demonstrate the
need for the tweek, and that some other existing method/code isn't
sufficient (I think I've seen this before).
Andrew
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [RFA]: gdbarch FETCH_POINTER_ARGUMENT
2003-05-20 20:07 ` Andrew Cagney
@ 2003-05-20 20:17 ` Daniel Jacobowitz
2003-05-20 20:28 ` Andrew Cagney
2003-05-22 19:16 ` Andrew Cagney
1 sibling, 1 reply; 11+ messages in thread
From: Daniel Jacobowitz @ 2003-05-20 20:17 UTC (permalink / raw)
To: Andrew Cagney; +Cc: Adam Fedor, GDB Patches
On Tue, May 20, 2003 at 04:07:13PM -0400, Andrew Cagney wrote:
> Adam,
>
> I need to think about FETCH_POINTER_ARGUMENT. It needs additional
> parameters - something to that lets it fetch registers or memory, and
> something identifying the type of pointer.
I'm curious. Would you mind expanding on that? My vision of
FETCH_POINTER_ARGUMENT was:
For a normal function on this architecture whose first N arguments
are all pointers (or passed like pointers, etc.) fetch the value of
the Nth argument.
So I don't see how it would need a param specifying registers or
memory.
Hmm, maybe a regcache argument though.
--
Daniel Jacobowitz
MontaVista Software Debian GNU/Linux Developer
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [RFA]: gdbarch FETCH_POINTER_ARGUMENT
2003-05-20 20:17 ` Daniel Jacobowitz
@ 2003-05-20 20:28 ` Andrew Cagney
0 siblings, 0 replies; 11+ messages in thread
From: Andrew Cagney @ 2003-05-20 20:28 UTC (permalink / raw)
To: Daniel Jacobowitz; +Cc: Adam Fedor, GDB Patches
> On Tue, May 20, 2003 at 04:07:13PM -0400, Andrew Cagney wrote:
>
>> Adam,
>>
>> I need to think about FETCH_POINTER_ARGUMENT. It needs additional
>> parameters - something to that lets it fetch registers or memory, and
>> something identifying the type of pointer.
>
>
> I'm curious. Would you mind expanding on that? My vision of
> FETCH_POINTER_ARGUMENT was:
> For a normal function on this architecture whose first N arguments
> are all pointers (or passed like pointers, etc.) fetch the value of
> the Nth argument.
> So I don't see how it would need a param specifying registers or
> memory.
``lets it fetch registers or memory'', not ``specify registers or memory''.
> Hmm, maybe a regcache argument though.
Something. Like I said, I need to think about it.
Andrew
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [RFA]: gdbarch FETCH_POINTER_ARGUMENT
2003-05-20 20:07 ` Andrew Cagney
2003-05-20 20:17 ` Daniel Jacobowitz
@ 2003-05-22 19:16 ` Andrew Cagney
2003-05-30 3:05 ` Adam Fedor
1 sibling, 1 reply; 11+ messages in thread
From: Andrew Cagney @ 2003-05-22 19:16 UTC (permalink / raw)
To: Andrew Cagney; +Cc: Adam Fedor, GDB Patches, Daniel Jacobowitz
Adam,
I think the FETCH_POINTER_ARGUMENT method should have the signature:
(CORE_ADDR) (struct frame_info *frame, int argi, struct type *type)
the call would then look like:
addr = gdbarch_fetch_pointer_argument (current_gdbarch,
get_current_frame (), argi, builtin_type_void_func_ptr);
See: cooked regcache -> frame
http://sources.redhat.com/ml/gdb/2003-05/msg00287.html
for the rationale,
Andrew
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [RFA]: gdbarch FETCH_POINTER_ARGUMENT
2003-05-22 19:16 ` Andrew Cagney
@ 2003-05-30 3:05 ` Adam Fedor
2003-05-30 19:26 ` Andrew Cagney
0 siblings, 1 reply; 11+ messages in thread
From: Adam Fedor @ 2003-05-30 3:05 UTC (permalink / raw)
To: GDB Patches; +Cc: Andrew Cagney, Daniel Jacobowitz
[-- Attachment #1: Type: text/plain, Size: 773 bytes --]
Andrew Cagney wrote:
> Adam,
>
> I think the FETCH_POINTER_ARGUMENT method should have the signature:
>
> (CORE_ADDR) (struct frame_info *frame, int argi, struct type *type)
>
> the call would then look like:
>
> addr = gdbarch_fetch_pointer_argument (current_gdbarch,
> get_current_frame (), argi, builtin_type_void_func_ptr);
>
> See: cooked regcache -> frame
> http://sources.redhat.com/ml/gdb/2003-05/msg00287.html
>
> for the rationale,
>
> Andrew
>
Here's an updated patch. The more I looked at the "struct type *type"
argument, the less I understood about how it should be used. I assume it
would only be used, so far, on i386, but I'm easily confused by stacks
and registers (and how things are stored there), so any pointers would
be appreciated.
[-- Attachment #2: newgdbarch.patch --]
[-- Type: text/plain, Size: 10300 bytes --]
2003-05-18 Adam Fedor <fedor@gnu.org>
* gdbarch.sh (function_list): Add FETCH_POINTER_ARGUMENT.
* gdbarch.[ch]: Regenerate.
* hppa-tdep.c (hppa_fetch_pointer_argument): New function.
(hppa_gdbarch_init): Set it in the gdbarch vector.
* i386-tdep.c (i386_fetch_pointer_argument): New
(i386_gdbarch_init): Set it into gdbarch.
* rs6000-tdep.c (rs6000_fetch_pointer_argument): New.
(rs6000_gdbarch_init): Set it in gdbarch.
* sparc-tdep.c (sparc_fetch_pointer_argument): New
(sparc_gdbarch_init): Set it in gdbarch.
Index: gdbarch.c
===================================================================
RCS file: /cvs/src/src/gdb/gdbarch.c,v
retrieving revision 1.216
diff -u -p -r1.216 gdbarch.c
--- gdbarch.c 17 May 2003 05:59:58 -0000 1.216
+++ gdbarch.c 30 May 2003 02:59:43 -0000
@@ -280,6 +280,7 @@ struct gdbarch
gdbarch_address_class_type_flags_to_name_ftype *address_class_type_flags_to_name;
gdbarch_address_class_name_to_type_flags_ftype *address_class_name_to_type_flags;
gdbarch_register_reggroup_p_ftype *register_reggroup_p;
+ gdbarch_fetch_pointer_argument_ftype *fetch_pointer_argument;
};
@@ -446,6 +447,7 @@ struct gdbarch startup_gdbarch =
0,
0,
default_register_reggroup_p,
+ 0,
/* startup_gdbarch() */
};
@@ -1693,6 +1695,17 @@ gdbarch_dump (struct gdbarch *gdbarch, s
(long) current_gdbarch->extract_struct_value_address
/*EXTRACT_STRUCT_VALUE_ADDRESS ()*/);
#endif
+#ifdef FETCH_POINTER_ARGUMENT
+ fprintf_unfiltered (file,
+ "gdbarch_dump: %s # %s\n",
+ "FETCH_POINTER_ARGUMENT(frame, argi, type)",
+ XSTRING (FETCH_POINTER_ARGUMENT (frame, argi, type)));
+ if (GDB_MULTI_ARCH)
+ fprintf_unfiltered (file,
+ "gdbarch_dump: FETCH_POINTER_ARGUMENT = <0x%08lx>\n",
+ (long) current_gdbarch->fetch_pointer_argument
+ /*FETCH_POINTER_ARGUMENT ()*/);
+#endif
#ifdef FP0_REGNUM
fprintf_unfiltered (file,
"gdbarch_dump: FP0_REGNUM # %s\n",
@@ -5689,6 +5702,25 @@ set_gdbarch_register_reggroup_p (struct
gdbarch_register_reggroup_p_ftype register_reggroup_p)
{
gdbarch->register_reggroup_p = register_reggroup_p;
+}
+
+CORE_ADDR
+gdbarch_fetch_pointer_argument (struct gdbarch *gdbarch, struct frame_info *frame, int argi, struct type *type)
+{
+ gdb_assert (gdbarch != NULL);
+ if (gdbarch->fetch_pointer_argument == 0)
+ internal_error (__FILE__, __LINE__,
+ "gdbarch: gdbarch_fetch_pointer_argument invalid");
+ if (gdbarch_debug >= 2)
+ fprintf_unfiltered (gdb_stdlog, "gdbarch_fetch_pointer_argument called\n");
+ return gdbarch->fetch_pointer_argument (frame, argi, type);
+}
+
+void
+set_gdbarch_fetch_pointer_argument (struct gdbarch *gdbarch,
+ gdbarch_fetch_pointer_argument_ftype fetch_pointer_argument)
+{
+ gdbarch->fetch_pointer_argument = fetch_pointer_argument;
}
Index: gdbarch.h
===================================================================
RCS file: /cvs/src/src/gdb/gdbarch.h,v
retrieving revision 1.185
diff -u -p -r1.185 gdbarch.h
--- gdbarch.h 17 May 2003 05:59:58 -0000 1.185
+++ gdbarch.h 30 May 2003 02:59:44 -0000
@@ -3184,6 +3184,20 @@ typedef int (gdbarch_register_reggroup_p
extern int gdbarch_register_reggroup_p (struct gdbarch *gdbarch, int regnum, struct reggroup *reggroup);
extern void set_gdbarch_register_reggroup_p (struct gdbarch *gdbarch, gdbarch_register_reggroup_p_ftype *register_reggroup_p);
+/* Fetch the pointer to the ith function argument. */
+
+typedef CORE_ADDR (gdbarch_fetch_pointer_argument_ftype) (struct frame_info *frame, int argi, struct type *type);
+extern CORE_ADDR gdbarch_fetch_pointer_argument (struct gdbarch *gdbarch, struct frame_info *frame, int argi, struct type *type);
+extern void set_gdbarch_fetch_pointer_argument (struct gdbarch *gdbarch, gdbarch_fetch_pointer_argument_ftype *fetch_pointer_argument);
+#if (GDB_MULTI_ARCH > GDB_MULTI_ARCH_PARTIAL) && defined (FETCH_POINTER_ARGUMENT)
+#error "Non multi-arch definition of FETCH_POINTER_ARGUMENT"
+#endif
+#if GDB_MULTI_ARCH
+#if (GDB_MULTI_ARCH > GDB_MULTI_ARCH_PARTIAL) || !defined (FETCH_POINTER_ARGUMENT)
+#define FETCH_POINTER_ARGUMENT(frame, argi, type) (gdbarch_fetch_pointer_argument (current_gdbarch, frame, argi, type))
+#endif
+#endif
+
extern struct gdbarch_tdep *gdbarch_tdep (struct gdbarch *gdbarch);
Index: gdbarch.sh
===================================================================
RCS file: /cvs/src/src/gdb/gdbarch.sh,v
retrieving revision 1.237
diff -u -p -r1.237 gdbarch.sh
--- gdbarch.sh 17 May 2003 05:59:58 -0000 1.237
+++ gdbarch.sh 30 May 2003 02:59:45 -0000
@@ -716,6 +716,8 @@ M:2:ADDRESS_CLASS_TYPE_FLAGS_TO_NAME:con
M:2:ADDRESS_CLASS_NAME_TO_TYPE_FLAGS:int:address_class_name_to_type_flags:const char *name, int *type_flags_ptr:name, type_flags_ptr
# Is a register in a group
m:::int:register_reggroup_p:int regnum, struct reggroup *reggroup:regnum, reggroup:::default_register_reggroup_p::0
+# Fetch the pointer to the ith function argument.
+f::FETCH_POINTER_ARGUMENT:CORE_ADDR:fetch_pointer_argument:struct frame_info *frame, int argi, struct type *type:frame, argi, type:::::::::
EOF
}
Index: hppa-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/hppa-tdep.c,v
retrieving revision 1.79
diff -u -p -r1.79 hppa-tdep.c
--- hppa-tdep.c 22 May 2003 02:04:05 -0000 1.79
+++ hppa-tdep.c 30 May 2003 02:59:48 -0000
@@ -4993,6 +4993,16 @@ hppa_smash_text_address (CORE_ADDR addr)
return (addr &= ~0x3);
}
+/* Get the ith function argument for the current function. */
+CORE_ADDR
+hppa_fetch_pointer_argument (struct frame_info *frame, int argi,
+ struct type *type)
+{
+ CORE_ADDR addr;
+ frame_read_register (frame, R0_REGNUM + 26 - argi, &addr);
+ return addr;
+}
+
static struct gdbarch *
hppa_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
{
@@ -5070,6 +5080,9 @@ hppa_gdbarch_init (struct gdbarch_info i
set_gdbarch_read_pc (gdbarch, hppa_target_read_pc);
set_gdbarch_write_pc (gdbarch, hppa_target_write_pc);
set_gdbarch_deprecated_target_read_fp (gdbarch, hppa_target_read_fp);
+
+ /* Helper for function argument information. */
+ set_gdbarch_fetch_pointer_argument (gdbarch, hppa_fetch_pointer_argument);
return gdbarch;
}
Index: i386-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/i386-tdep.c,v
retrieving revision 1.144
diff -u -p -r1.144 i386-tdep.c
--- i386-tdep.c 17 May 2003 05:59:58 -0000 1.144
+++ i386-tdep.c 30 May 2003 02:59:48 -0000
@@ -1420,6 +1420,16 @@ i386_register_reggroup_p (struct gdbarch
return default_register_reggroup_p (gdbarch, regnum, group);
}
+/* Get the ith function argument for the current function. */
+CORE_ADDR
+i386_fetch_pointer_argument (struct frame_info *frame, int argi,
+ struct type *type)
+{
+ CORE_ADDR stack;
+ frame_read_register (frame, SP_REGNUM, &stack);
+ return read_memory_unsigned_integer (stack + (4 * (argi + 1)), 4);
+}
+
\f
static struct gdbarch *
i386_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
@@ -1551,6 +1561,9 @@ i386_gdbarch_init (struct gdbarch_info i
/* Add the i386 register groups. */
i386_add_reggroups (gdbarch);
set_gdbarch_register_reggroup_p (gdbarch, i386_register_reggroup_p);
+
+ /* Helper for function argument information. */
+ set_gdbarch_fetch_pointer_argument (gdbarch, i386_fetch_pointer_argument);
/* Should be using push_dummy_call. */
set_gdbarch_deprecated_dummy_write_sp (gdbarch, generic_target_write_sp);
Index: rs6000-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/rs6000-tdep.c,v
retrieving revision 1.135
diff -u -p -r1.135 rs6000-tdep.c
--- rs6000-tdep.c 29 May 2003 19:47:14 -0000 1.135
+++ rs6000-tdep.c 30 May 2003 02:59:56 -0000
@@ -230,6 +230,16 @@ rs6000_saved_pc_after_call (struct frame
return read_register (gdbarch_tdep (current_gdbarch)->ppc_lr_regnum);
}
+/* Get the ith function argument for the current function. */
+CORE_ADDR
+rs6000_fetch_pointer_argument (struct frame_info *frame, int argi,
+ struct type *type)
+{
+ CORE_ADDR addr;
+ frame_read_register (frame, 3 + argi, &addr);
+ return addr;
+}
+
/* Calculate the destination of a branch/jump. Return -1 if not a branch. */
static CORE_ADDR
@@ -2990,6 +3000,9 @@ rs6000_gdbarch_init (struct gdbarch_info
set_gdbarch_frame_args_address (gdbarch, rs6000_frame_args_address);
set_gdbarch_frame_locals_address (gdbarch, rs6000_frame_args_address);
set_gdbarch_deprecated_saved_pc_after_call (gdbarch, rs6000_saved_pc_after_call);
+
+ /* Helpers for function argument information. */
+ set_gdbarch_fetch_pointer_argument (gdbarch, rs6000_fetch_pointer_argument);
/* We can't tell how many args there are
now that the C compiler delays popping them. */
Index: sparc-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/sparc-tdep.c,v
retrieving revision 1.103
diff -u -p -r1.103 sparc-tdep.c
--- sparc-tdep.c 25 May 2003 15:47:26 -0000 1.103
+++ sparc-tdep.c 30 May 2003 03:00:00 -0000
@@ -3243,6 +3243,15 @@ sparc_return_value_on_stack (struct type
return 0;
}
+/* Get the ith function argument for the current function. */
+CORE_ADDR
+sparc_fetch_pointer_argument (struct frame_info *frame, int argi, struct type *type)
+{
+ CORE_ADDR addr;
+ frame_read_register (frame, O0_REGNUM + argi, &addr);
+ return addr;
+}
+
/*
* Gdbarch "constructor" function.
*/
@@ -3353,6 +3362,9 @@ sparc_gdbarch_init (struct gdbarch_info
set_gdbarch_sp_regnum (gdbarch, SPARC_SP_REGNUM);
set_gdbarch_deprecated_use_generic_dummy_frames (gdbarch, 0);
set_gdbarch_write_pc (gdbarch, generic_target_write_pc);
+
+ /* Helper for function argument information. */
+ set_gdbarch_fetch_pointer_argument (gdbarch, sparc_fetch_pointer_argument);
/*
* Settings that depend only on 32/64 bit word size
^ permalink raw reply [flat|nested] 11+ messages in thread* Re: [RFA]: gdbarch FETCH_POINTER_ARGUMENT
2003-05-30 3:05 ` Adam Fedor
@ 2003-05-30 19:26 ` Andrew Cagney
2003-05-30 20:19 ` Daniel Jacobowitz
2003-06-01 4:02 ` Adam Fedor
0 siblings, 2 replies; 11+ messages in thread
From: Andrew Cagney @ 2003-05-30 19:26 UTC (permalink / raw)
To: Adam Fedor; +Cc: GDB Patches, Daniel Jacobowitz
> Here's an updated patch. The more I looked at the "struct type *type" argument, the less I understood about how it should be used. I assume it would only be used, so far, on i386, but I'm easily confused by stacks and registers (and how things are stored there), so any pointers would be appreciated.
The patch is almost fine. Change it to `F' instead of `f' - so that a
predicate is also available.
For some background, see: Pointers Are Not Always Addresses
http://sources.redhat.com/gdb/current/onlinedocs/gdbint_9.html#SEC71
The d10v is an example.
Andrew
> 2003-05-18 Adam Fedor <fedor@gnu.org>
>
> * gdbarch.sh (function_list): Add FETCH_POINTER_ARGUMENT.
> * gdbarch.[ch]: Regenerate.
> * hppa-tdep.c (hppa_fetch_pointer_argument): New function.
> (hppa_gdbarch_init): Set it in the gdbarch vector.
> * i386-tdep.c (i386_fetch_pointer_argument): New
> (i386_gdbarch_init): Set it into gdbarch.
> * rs6000-tdep.c (rs6000_fetch_pointer_argument): New.
> (rs6000_gdbarch_init): Set it in gdbarch.
> * sparc-tdep.c (sparc_fetch_pointer_argument): New
> (sparc_gdbarch_init): Set it in gdbarch.
>
> Index: gdbarch.c
> ===================================================================
> RCS file: /cvs/src/src/gdb/gdbarch.c,v
> retrieving revision 1.216
> diff -u -p -r1.216 gdbarch.c
> --- gdbarch.c 17 May 2003 05:59:58 -0000 1.216
> +++ gdbarch.c 30 May 2003 02:59:43 -0000
> @@ -280,6 +280,7 @@ struct gdbarch
> gdbarch_address_class_type_flags_to_name_ftype *address_class_type_flags_to_name;
> gdbarch_address_class_name_to_type_flags_ftype *address_class_name_to_type_flags;
> gdbarch_register_reggroup_p_ftype *register_reggroup_p;
> + gdbarch_fetch_pointer_argument_ftype *fetch_pointer_argument;
> };
>
>
> @@ -446,6 +447,7 @@ struct gdbarch startup_gdbarch =
> 0,
> 0,
> default_register_reggroup_p,
> + 0,
> /* startup_gdbarch() */
> };
>
> @@ -1693,6 +1695,17 @@ gdbarch_dump (struct gdbarch *gdbarch, s
> (long) current_gdbarch->extract_struct_value_address
> /*EXTRACT_STRUCT_VALUE_ADDRESS ()*/);
> #endif
> +#ifdef FETCH_POINTER_ARGUMENT
> + fprintf_unfiltered (file,
> + "gdbarch_dump: %s # %s\n",
> + "FETCH_POINTER_ARGUMENT(frame, argi, type)",
> + XSTRING (FETCH_POINTER_ARGUMENT (frame, argi, type)));
> + if (GDB_MULTI_ARCH)
> + fprintf_unfiltered (file,
> + "gdbarch_dump: FETCH_POINTER_ARGUMENT = <0x%08lx>\n",
> + (long) current_gdbarch->fetch_pointer_argument
> + /*FETCH_POINTER_ARGUMENT ()*/);
> +#endif
> #ifdef FP0_REGNUM
> fprintf_unfiltered (file,
> "gdbarch_dump: FP0_REGNUM # %s\n",
> @@ -5689,6 +5702,25 @@ set_gdbarch_register_reggroup_p (struct
> gdbarch_register_reggroup_p_ftype register_reggroup_p)
> {
> gdbarch->register_reggroup_p = register_reggroup_p;
> +}
> +
> +CORE_ADDR
> +gdbarch_fetch_pointer_argument (struct gdbarch *gdbarch, struct frame_info *frame, int argi, struct type *type)
> +{
> + gdb_assert (gdbarch != NULL);
> + if (gdbarch->fetch_pointer_argument == 0)
> + internal_error (__FILE__, __LINE__,
> + "gdbarch: gdbarch_fetch_pointer_argument invalid");
> + if (gdbarch_debug >= 2)
> + fprintf_unfiltered (gdb_stdlog, "gdbarch_fetch_pointer_argument called\n");
> + return gdbarch->fetch_pointer_argument (frame, argi, type);
> +}
> +
> +void
> +set_gdbarch_fetch_pointer_argument (struct gdbarch *gdbarch,
> + gdbarch_fetch_pointer_argument_ftype fetch_pointer_argument)
> +{
> + gdbarch->fetch_pointer_argument = fetch_pointer_argument;
> }
>
>
> Index: gdbarch.h
> ===================================================================
> RCS file: /cvs/src/src/gdb/gdbarch.h,v
> retrieving revision 1.185
> diff -u -p -r1.185 gdbarch.h
> --- gdbarch.h 17 May 2003 05:59:58 -0000 1.185
> +++ gdbarch.h 30 May 2003 02:59:44 -0000
> @@ -3184,6 +3184,20 @@ typedef int (gdbarch_register_reggroup_p
> extern int gdbarch_register_reggroup_p (struct gdbarch *gdbarch, int regnum, struct reggroup *reggroup);
> extern void set_gdbarch_register_reggroup_p (struct gdbarch *gdbarch, gdbarch_register_reggroup_p_ftype *register_reggroup_p);
>
> +/* Fetch the pointer to the ith function argument. */
> +
> +typedef CORE_ADDR (gdbarch_fetch_pointer_argument_ftype) (struct frame_info *frame, int argi, struct type *type);
> +extern CORE_ADDR gdbarch_fetch_pointer_argument (struct gdbarch *gdbarch, struct frame_info *frame, int argi, struct type *type);
> +extern void set_gdbarch_fetch_pointer_argument (struct gdbarch *gdbarch, gdbarch_fetch_pointer_argument_ftype *fetch_pointer_argument);
> +#if (GDB_MULTI_ARCH > GDB_MULTI_ARCH_PARTIAL) && defined (FETCH_POINTER_ARGUMENT)
> +#error "Non multi-arch definition of FETCH_POINTER_ARGUMENT"
> +#endif
> +#if GDB_MULTI_ARCH
> +#if (GDB_MULTI_ARCH > GDB_MULTI_ARCH_PARTIAL) || !defined (FETCH_POINTER_ARGUMENT)
> +#define FETCH_POINTER_ARGUMENT(frame, argi, type) (gdbarch_fetch_pointer_argument (current_gdbarch, frame, argi, type))
> +#endif
> +#endif
> +
> extern struct gdbarch_tdep *gdbarch_tdep (struct gdbarch *gdbarch);
>
>
> Index: gdbarch.sh
> ===================================================================
> RCS file: /cvs/src/src/gdb/gdbarch.sh,v
> retrieving revision 1.237
> diff -u -p -r1.237 gdbarch.sh
> --- gdbarch.sh 17 May 2003 05:59:58 -0000 1.237
> +++ gdbarch.sh 30 May 2003 02:59:45 -0000
> @@ -716,6 +716,8 @@ M:2:ADDRESS_CLASS_TYPE_FLAGS_TO_NAME:con
> M:2:ADDRESS_CLASS_NAME_TO_TYPE_FLAGS:int:address_class_name_to_type_flags:const char *name, int *type_flags_ptr:name, type_flags_ptr
> # Is a register in a group
> m:::int:register_reggroup_p:int regnum, struct reggroup *reggroup:regnum, reggroup:::default_register_reggroup_p::0
> +# Fetch the pointer to the ith function argument.
> +f::FETCH_POINTER_ARGUMENT:CORE_ADDR:fetch_pointer_argument:struct frame_info *frame, int argi, struct type *type:frame, argi, type:::::::::
> EOF
> }
>
> Index: hppa-tdep.c
> ===================================================================
> RCS file: /cvs/src/src/gdb/hppa-tdep.c,v
> retrieving revision 1.79
> diff -u -p -r1.79 hppa-tdep.c
> --- hppa-tdep.c 22 May 2003 02:04:05 -0000 1.79
> +++ hppa-tdep.c 30 May 2003 02:59:48 -0000
> @@ -4993,6 +4993,16 @@ hppa_smash_text_address (CORE_ADDR addr)
> return (addr &= ~0x3);
> }
>
> +/* Get the ith function argument for the current function. */
> +CORE_ADDR
> +hppa_fetch_pointer_argument (struct frame_info *frame, int argi,
> + struct type *type)
> +{
> + CORE_ADDR addr;
> + frame_read_register (frame, R0_REGNUM + 26 - argi, &addr);
> + return addr;
> +}
> +
> static struct gdbarch *
> hppa_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
> {
> @@ -5070,6 +5080,9 @@ hppa_gdbarch_init (struct gdbarch_info i
> set_gdbarch_read_pc (gdbarch, hppa_target_read_pc);
> set_gdbarch_write_pc (gdbarch, hppa_target_write_pc);
> set_gdbarch_deprecated_target_read_fp (gdbarch, hppa_target_read_fp);
> +
> + /* Helper for function argument information. */
> + set_gdbarch_fetch_pointer_argument (gdbarch, hppa_fetch_pointer_argument);
>
> return gdbarch;
> }
> Index: i386-tdep.c
> ===================================================================
> RCS file: /cvs/src/src/gdb/i386-tdep.c,v
> retrieving revision 1.144
> diff -u -p -r1.144 i386-tdep.c
> --- i386-tdep.c 17 May 2003 05:59:58 -0000 1.144
> +++ i386-tdep.c 30 May 2003 02:59:48 -0000
> @@ -1420,6 +1420,16 @@ i386_register_reggroup_p (struct gdbarch
> return default_register_reggroup_p (gdbarch, regnum, group);
> }
>
> +/* Get the ith function argument for the current function. */
> +CORE_ADDR
> +i386_fetch_pointer_argument (struct frame_info *frame, int argi,
> + struct type *type)
> +{
> + CORE_ADDR stack;
> + frame_read_register (frame, SP_REGNUM, &stack);
> + return read_memory_unsigned_integer (stack + (4 * (argi + 1)), 4);
> +}
> +
> \f
> static struct gdbarch *
> i386_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
> @@ -1551,6 +1561,9 @@ i386_gdbarch_init (struct gdbarch_info i
> /* Add the i386 register groups. */
> i386_add_reggroups (gdbarch);
> set_gdbarch_register_reggroup_p (gdbarch, i386_register_reggroup_p);
> +
> + /* Helper for function argument information. */
> + set_gdbarch_fetch_pointer_argument (gdbarch, i386_fetch_pointer_argument);
>
> /* Should be using push_dummy_call. */
> set_gdbarch_deprecated_dummy_write_sp (gdbarch, generic_target_write_sp);
> Index: rs6000-tdep.c
> ===================================================================
> RCS file: /cvs/src/src/gdb/rs6000-tdep.c,v
> retrieving revision 1.135
> diff -u -p -r1.135 rs6000-tdep.c
> --- rs6000-tdep.c 29 May 2003 19:47:14 -0000 1.135
> +++ rs6000-tdep.c 30 May 2003 02:59:56 -0000
> @@ -230,6 +230,16 @@ rs6000_saved_pc_after_call (struct frame
> return read_register (gdbarch_tdep (current_gdbarch)->ppc_lr_regnum);
> }
>
> +/* Get the ith function argument for the current function. */
> +CORE_ADDR
> +rs6000_fetch_pointer_argument (struct frame_info *frame, int argi,
> + struct type *type)
> +{
> + CORE_ADDR addr;
> + frame_read_register (frame, 3 + argi, &addr);
> + return addr;
> +}
> +
> /* Calculate the destination of a branch/jump. Return -1 if not a branch. */
>
> static CORE_ADDR
> @@ -2990,6 +3000,9 @@ rs6000_gdbarch_init (struct gdbarch_info
> set_gdbarch_frame_args_address (gdbarch, rs6000_frame_args_address);
> set_gdbarch_frame_locals_address (gdbarch, rs6000_frame_args_address);
> set_gdbarch_deprecated_saved_pc_after_call (gdbarch, rs6000_saved_pc_after_call);
> +
> + /* Helpers for function argument information. */
> + set_gdbarch_fetch_pointer_argument (gdbarch, rs6000_fetch_pointer_argument);
>
> /* We can't tell how many args there are
> now that the C compiler delays popping them. */
> Index: sparc-tdep.c
> ===================================================================
> RCS file: /cvs/src/src/gdb/sparc-tdep.c,v
> retrieving revision 1.103
> diff -u -p -r1.103 sparc-tdep.c
> --- sparc-tdep.c 25 May 2003 15:47:26 -0000 1.103
> +++ sparc-tdep.c 30 May 2003 03:00:00 -0000
> @@ -3243,6 +3243,15 @@ sparc_return_value_on_stack (struct type
> return 0;
> }
>
> +/* Get the ith function argument for the current function. */
> +CORE_ADDR
> +sparc_fetch_pointer_argument (struct frame_info *frame, int argi, struct type *type)
> +{
> + CORE_ADDR addr;
> + frame_read_register (frame, O0_REGNUM + argi, &addr);
> + return addr;
> +}
> +
> /*
> * Gdbarch "constructor" function.
> */
> @@ -3353,6 +3362,9 @@ sparc_gdbarch_init (struct gdbarch_info
> set_gdbarch_sp_regnum (gdbarch, SPARC_SP_REGNUM);
> set_gdbarch_deprecated_use_generic_dummy_frames (gdbarch, 0);
> set_gdbarch_write_pc (gdbarch, generic_target_write_pc);
> +
> + /* Helper for function argument information. */
> + set_gdbarch_fetch_pointer_argument (gdbarch, sparc_fetch_pointer_argument);
>
> /*
> * Settings that depend only on 32/64 bit word size
^ permalink raw reply [flat|nested] 11+ messages in thread* Re: [RFA]: gdbarch FETCH_POINTER_ARGUMENT
2003-05-30 19:26 ` Andrew Cagney
@ 2003-05-30 20:19 ` Daniel Jacobowitz
2003-05-30 21:33 ` Andrew Cagney
2003-06-01 4:02 ` Adam Fedor
1 sibling, 1 reply; 11+ messages in thread
From: Daniel Jacobowitz @ 2003-05-30 20:19 UTC (permalink / raw)
To: Andrew Cagney; +Cc: Adam Fedor, GDB Patches
On Fri, May 30, 2003 at 03:26:28PM -0400, Andrew Cagney wrote:
>
> >Here's an updated patch. The more I looked at the "struct type *type"
> >argument, the less I understood about how it should be used. I assume it
> >would only be used, so far, on i386, but I'm easily confused by stacks and
> >registers (and how things are stored there), so any pointers would be
> >appreciated.
>
> The patch is almost fine. Change it to `F' instead of `f' - so that a
> predicate is also available.
>
> For some background, see: Pointers Are Not Always Addresses
> http://sources.redhat.com/gdb/current/onlinedocs/gdbint_9.html#SEC71
>
> The d10v is an example.
Shouldn't TYPE be used? I guess I'm not understanding why you wanted
it to be there...
>
> Andrew
>
> >2003-05-18 Adam Fedor <fedor@gnu.org>
> >
> > * gdbarch.sh (function_list): Add FETCH_POINTER_ARGUMENT.
> > * gdbarch.[ch]: Regenerate.
> > * hppa-tdep.c (hppa_fetch_pointer_argument): New function.
> > (hppa_gdbarch_init): Set it in the gdbarch vector.
> > * i386-tdep.c (i386_fetch_pointer_argument): New
> > (i386_gdbarch_init): Set it into gdbarch.
> > * rs6000-tdep.c (rs6000_fetch_pointer_argument): New.
> > (rs6000_gdbarch_init): Set it in gdbarch.
> > * sparc-tdep.c (sparc_fetch_pointer_argument): New
> > (sparc_gdbarch_init): Set it in gdbarch.
> >
> >Index: gdbarch.c
> >===================================================================
> >RCS file: /cvs/src/src/gdb/gdbarch.c,v
> >retrieving revision 1.216
> >diff -u -p -r1.216 gdbarch.c
> >--- gdbarch.c 17 May 2003 05:59:58 -0000 1.216
> >+++ gdbarch.c 30 May 2003 02:59:43 -0000
> >@@ -280,6 +280,7 @@ struct gdbarch
> > gdbarch_address_class_type_flags_to_name_ftype
> > *address_class_type_flags_to_name;
> > gdbarch_address_class_name_to_type_flags_ftype
> > *address_class_name_to_type_flags;
> > gdbarch_register_reggroup_p_ftype *register_reggroup_p;
> >+ gdbarch_fetch_pointer_argument_ftype *fetch_pointer_argument;
> > };
> >
> >
> >@@ -446,6 +447,7 @@ struct gdbarch startup_gdbarch =
> > 0,
> > 0,
> > default_register_reggroup_p,
> >+ 0,
> > /* startup_gdbarch() */
> > };
> >
> >@@ -1693,6 +1695,17 @@ gdbarch_dump (struct gdbarch *gdbarch, s
> > (long)
> > current_gdbarch->extract_struct_value_address
> > /*EXTRACT_STRUCT_VALUE_ADDRESS ()*/);
> > #endif
> >+#ifdef FETCH_POINTER_ARGUMENT
> >+ fprintf_unfiltered (file,
> >+ "gdbarch_dump: %s # %s\n",
> >+ "FETCH_POINTER_ARGUMENT(frame, argi, type)",
> >+ XSTRING (FETCH_POINTER_ARGUMENT (frame, argi,
> >type)));
> >+ if (GDB_MULTI_ARCH)
> >+ fprintf_unfiltered (file,
> >+ "gdbarch_dump: FETCH_POINTER_ARGUMENT =
> ><0x%08lx>\n",
> >+ (long) current_gdbarch->fetch_pointer_argument
> >+ /*FETCH_POINTER_ARGUMENT ()*/);
> >+#endif
> > #ifdef FP0_REGNUM
> > fprintf_unfiltered (file,
> > "gdbarch_dump: FP0_REGNUM # %s\n",
> >@@ -5689,6 +5702,25 @@ set_gdbarch_register_reggroup_p (struct
> > gdbarch_register_reggroup_p_ftype
> > register_reggroup_p)
> > {
> > gdbarch->register_reggroup_p = register_reggroup_p;
> >+}
> >+
> >+CORE_ADDR
> >+gdbarch_fetch_pointer_argument (struct gdbarch *gdbarch, struct
> >frame_info *frame, int argi, struct type *type)
> >+{
> >+ gdb_assert (gdbarch != NULL);
> >+ if (gdbarch->fetch_pointer_argument == 0)
> >+ internal_error (__FILE__, __LINE__,
> >+ "gdbarch: gdbarch_fetch_pointer_argument invalid");
> >+ if (gdbarch_debug >= 2)
> >+ fprintf_unfiltered (gdb_stdlog, "gdbarch_fetch_pointer_argument
> >called\n");
> >+ return gdbarch->fetch_pointer_argument (frame, argi, type);
> >+}
> >+
> >+void
> >+set_gdbarch_fetch_pointer_argument (struct gdbarch *gdbarch,
> >+ gdbarch_fetch_pointer_argument_ftype
> >fetch_pointer_argument)
> >+{
> >+ gdbarch->fetch_pointer_argument = fetch_pointer_argument;
> > }
> >
> >
> >Index: gdbarch.h
> >===================================================================
> >RCS file: /cvs/src/src/gdb/gdbarch.h,v
> >retrieving revision 1.185
> >diff -u -p -r1.185 gdbarch.h
> >--- gdbarch.h 17 May 2003 05:59:58 -0000 1.185
> >+++ gdbarch.h 30 May 2003 02:59:44 -0000
> >@@ -3184,6 +3184,20 @@ typedef int (gdbarch_register_reggroup_p
> > extern int gdbarch_register_reggroup_p (struct gdbarch *gdbarch, int
> > regnum, struct reggroup *reggroup);
> > extern void set_gdbarch_register_reggroup_p (struct gdbarch *gdbarch,
> > gdbarch_register_reggroup_p_ftype *register_reggroup_p);
> >
> >+/* Fetch the pointer to the ith function argument. */
> >+
> >+typedef CORE_ADDR (gdbarch_fetch_pointer_argument_ftype) (struct
> >frame_info *frame, int argi, struct type *type);
> >+extern CORE_ADDR gdbarch_fetch_pointer_argument (struct gdbarch *gdbarch,
> >struct frame_info *frame, int argi, struct type *type);
> >+extern void set_gdbarch_fetch_pointer_argument (struct gdbarch *gdbarch,
> >gdbarch_fetch_pointer_argument_ftype *fetch_pointer_argument);
> >+#if (GDB_MULTI_ARCH > GDB_MULTI_ARCH_PARTIAL) && defined
> >(FETCH_POINTER_ARGUMENT)
> >+#error "Non multi-arch definition of FETCH_POINTER_ARGUMENT"
> >+#endif
> >+#if GDB_MULTI_ARCH
> >+#if (GDB_MULTI_ARCH > GDB_MULTI_ARCH_PARTIAL) || !defined
> >(FETCH_POINTER_ARGUMENT)
> >+#define FETCH_POINTER_ARGUMENT(frame, argi, type)
> >(gdbarch_fetch_pointer_argument (current_gdbarch, frame, argi, type))
> >+#endif
> >+#endif
> >+
> > extern struct gdbarch_tdep *gdbarch_tdep (struct gdbarch *gdbarch);
> >
> >
> >Index: gdbarch.sh
> >===================================================================
> >RCS file: /cvs/src/src/gdb/gdbarch.sh,v
> >retrieving revision 1.237
> >diff -u -p -r1.237 gdbarch.sh
> >--- gdbarch.sh 17 May 2003 05:59:58 -0000 1.237
> >+++ gdbarch.sh 30 May 2003 02:59:45 -0000
> >@@ -716,6 +716,8 @@ M:2:ADDRESS_CLASS_TYPE_FLAGS_TO_NAME:con
> > M:2:ADDRESS_CLASS_NAME_TO_TYPE_FLAGS:int:address_class_name_to_type_flags:const char *name, int *type_flags_ptr:name, type_flags_ptr
> > # Is a register in a group
> > m:::int:register_reggroup_p:int regnum, struct reggroup *reggroup:regnum,
> > reggroup:::default_register_reggroup_p::0
> >+# Fetch the pointer to the ith function argument.
> >+f::FETCH_POINTER_ARGUMENT:CORE_ADDR:fetch_pointer_argument:struct
> >frame_info *frame, int argi, struct type *type:frame, argi, type:::::::::
> > EOF
> > }
> >
> >Index: hppa-tdep.c
> >===================================================================
> >RCS file: /cvs/src/src/gdb/hppa-tdep.c,v
> >retrieving revision 1.79
> >diff -u -p -r1.79 hppa-tdep.c
> >--- hppa-tdep.c 22 May 2003 02:04:05 -0000 1.79
> >+++ hppa-tdep.c 30 May 2003 02:59:48 -0000
> >@@ -4993,6 +4993,16 @@ hppa_smash_text_address (CORE_ADDR addr)
> > return (addr &= ~0x3);
> > }
> >
> >+/* Get the ith function argument for the current function. */
> >+CORE_ADDR
> >+hppa_fetch_pointer_argument (struct frame_info *frame, int argi,
> >+ struct type *type)
> >+{
> >+ CORE_ADDR addr;
> >+ frame_read_register (frame, R0_REGNUM + 26 - argi, &addr);
> >+ return addr;
> >+}
> >+
> > static struct gdbarch *
> > hppa_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
> > {
> >@@ -5070,6 +5080,9 @@ hppa_gdbarch_init (struct gdbarch_info i
> > set_gdbarch_read_pc (gdbarch, hppa_target_read_pc);
> > set_gdbarch_write_pc (gdbarch, hppa_target_write_pc);
> > set_gdbarch_deprecated_target_read_fp (gdbarch, hppa_target_read_fp);
> >+
> >+ /* Helper for function argument information. */
> >+ set_gdbarch_fetch_pointer_argument (gdbarch,
> >hppa_fetch_pointer_argument);
> >
> > return gdbarch;
> > }
> >Index: i386-tdep.c
> >===================================================================
> >RCS file: /cvs/src/src/gdb/i386-tdep.c,v
> >retrieving revision 1.144
> >diff -u -p -r1.144 i386-tdep.c
> >--- i386-tdep.c 17 May 2003 05:59:58 -0000 1.144
> >+++ i386-tdep.c 30 May 2003 02:59:48 -0000
> >@@ -1420,6 +1420,16 @@ i386_register_reggroup_p (struct gdbarch
> > return default_register_reggroup_p (gdbarch, regnum, group);
> > }
> >
> >+/* Get the ith function argument for the current function. */
> >+CORE_ADDR
> >+i386_fetch_pointer_argument (struct frame_info *frame, int argi,
> >+ struct type *type)
> >+{
> >+ CORE_ADDR stack;
> >+ frame_read_register (frame, SP_REGNUM, &stack);
> >+ return read_memory_unsigned_integer (stack + (4 * (argi + 1)), 4);
> >+}
> >+
> >
> > static struct gdbarch *
> > i386_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
> >@@ -1551,6 +1561,9 @@ i386_gdbarch_init (struct gdbarch_info i
> > /* Add the i386 register groups. */
> > i386_add_reggroups (gdbarch);
> > set_gdbarch_register_reggroup_p (gdbarch, i386_register_reggroup_p);
> >+
> >+ /* Helper for function argument information. */
> >+ set_gdbarch_fetch_pointer_argument (gdbarch,
> >i386_fetch_pointer_argument);
> >
> > /* Should be using push_dummy_call. */
> > set_gdbarch_deprecated_dummy_write_sp (gdbarch,
> > generic_target_write_sp);
> >Index: rs6000-tdep.c
> >===================================================================
> >RCS file: /cvs/src/src/gdb/rs6000-tdep.c,v
> >retrieving revision 1.135
> >diff -u -p -r1.135 rs6000-tdep.c
> >--- rs6000-tdep.c 29 May 2003 19:47:14 -0000 1.135
> >+++ rs6000-tdep.c 30 May 2003 02:59:56 -0000
> >@@ -230,6 +230,16 @@ rs6000_saved_pc_after_call (struct frame
> > return read_register (gdbarch_tdep (current_gdbarch)->ppc_lr_regnum);
> > }
> >
> >+/* Get the ith function argument for the current function. */
> >+CORE_ADDR
> >+rs6000_fetch_pointer_argument (struct frame_info *frame, int argi,
> >+ struct type *type)
> >+{
> >+ CORE_ADDR addr;
> >+ frame_read_register (frame, 3 + argi, &addr);
> >+ return addr;
> >+}
> >+
> > /* Calculate the destination of a branch/jump. Return -1 if not a
> > branch. */
> >
> > static CORE_ADDR
> >@@ -2990,6 +3000,9 @@ rs6000_gdbarch_init (struct gdbarch_info
> > set_gdbarch_frame_args_address (gdbarch, rs6000_frame_args_address);
> > set_gdbarch_frame_locals_address (gdbarch, rs6000_frame_args_address);
> > set_gdbarch_deprecated_saved_pc_after_call (gdbarch,
> > rs6000_saved_pc_after_call);
> >+
> >+ /* Helpers for function argument information. */
> >+ set_gdbarch_fetch_pointer_argument (gdbarch,
> >rs6000_fetch_pointer_argument);
> >
> > /* We can't tell how many args there are
> > now that the C compiler delays popping them. */
> >Index: sparc-tdep.c
> >===================================================================
> >RCS file: /cvs/src/src/gdb/sparc-tdep.c,v
> >retrieving revision 1.103
> >diff -u -p -r1.103 sparc-tdep.c
> >--- sparc-tdep.c 25 May 2003 15:47:26 -0000 1.103
> >+++ sparc-tdep.c 30 May 2003 03:00:00 -0000
> >@@ -3243,6 +3243,15 @@ sparc_return_value_on_stack (struct type
> > return 0;
> > }
> >
> >+/* Get the ith function argument for the current function. */
> >+CORE_ADDR
> >+sparc_fetch_pointer_argument (struct frame_info *frame, int argi, struct
> >type *type)
> >+{
> >+ CORE_ADDR addr;
> >+ frame_read_register (frame, O0_REGNUM + argi, &addr);
> >+ return addr;
> >+}
> >+
> > /*
> > * Gdbarch "constructor" function.
> > */
> >@@ -3353,6 +3362,9 @@ sparc_gdbarch_init (struct gdbarch_info
> > set_gdbarch_sp_regnum (gdbarch, SPARC_SP_REGNUM);
> > set_gdbarch_deprecated_use_generic_dummy_frames (gdbarch, 0);
> > set_gdbarch_write_pc (gdbarch, generic_target_write_pc);
> >+
> >+ /* Helper for function argument information. */
> >+ set_gdbarch_fetch_pointer_argument (gdbarch,
> >sparc_fetch_pointer_argument);
> >
> > /*
> > * Settings that depend only on 32/64 bit word size
>
>
>
--
Daniel Jacobowitz
MontaVista Software Debian GNU/Linux Developer
^ permalink raw reply [flat|nested] 11+ messages in thread* Re: [RFA]: gdbarch FETCH_POINTER_ARGUMENT
2003-05-30 20:19 ` Daniel Jacobowitz
@ 2003-05-30 21:33 ` Andrew Cagney
0 siblings, 0 replies; 11+ messages in thread
From: Andrew Cagney @ 2003-05-30 21:33 UTC (permalink / raw)
To: Daniel Jacobowitz; +Cc: Adam Fedor, GDB Patches
> On Fri, May 30, 2003 at 03:26:28PM -0400, Andrew Cagney wrote:
>
>>
>
>> >Here's an updated patch. The more I looked at the "struct type *type"
>> >argument, the less I understood about how it should be used. I assume it
>> >would only be used, so far, on i386, but I'm easily confused by stacks and
>> >registers (and how things are stored there), so any pointers would be
>> >appreciated.
>
>>
>> The patch is almost fine. Change it to `F' instead of `f' - so that a
>> predicate is also available.
>>
>> For some background, see: Pointers Are Not Always Addresses
>> http://sources.redhat.com/gdb/current/onlinedocs/gdbint_9.html#SEC71
>>
>> The d10v is an example.
>
>
> Shouldn't TYPE be used? I guess I'm not understanding why you wanted
> it to be there...
Strictly speaking POINTER_TO_ADDRESS should be used. The only targets
that absolutly need this though are the d10v and avr (which weren't
modified).
Andrew
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [RFA]: gdbarch FETCH_POINTER_ARGUMENT
2003-05-30 19:26 ` Andrew Cagney
2003-05-30 20:19 ` Daniel Jacobowitz
@ 2003-06-01 4:02 ` Adam Fedor
2003-06-01 22:55 ` Andrew Cagney
1 sibling, 1 reply; 11+ messages in thread
From: Adam Fedor @ 2003-06-01 4:02 UTC (permalink / raw)
To: GDB Patches; +Cc: Andrew Cagney, Daniel Jacobowitz
[-- Attachment #1: Type: text/plain, Size: 485 bytes --]
Andrew Cagney wrote:
>
>> Here's an updated patch. The more I looked at the "struct type *type"
>> argument, the less I understood about how it should be used. I assume
>> it would only be used, so far, on i386, but I'm easily confused by
>> stacks and registers (and how things are stored there), so any
>> pointers would be appreciated.
>
>
> The patch is almost fine. Change it to `F' instead of `f' - so that a
> predicate is also available.
>
OK, I made this change.
[-- Attachment #2: newgdbarch.patch --]
[-- Type: text/plain, Size: 12288 bytes --]
2003-05-18 Adam Fedor <fedor@gnu.org>
* gdbarch.sh (function_list): Add FETCH_POINTER_ARGUMENT.
* gdbarch.[ch]: Regenerate.
* hppa-tdep.c (hppa_fetch_pointer_argument): New function.
(hppa_gdbarch_init): Set it in the gdbarch vector.
* i386-tdep.c (i386_fetch_pointer_argument): New
(i386_gdbarch_init): Set it into gdbarch.
* rs6000-tdep.c (rs6000_fetch_pointer_argument): New.
(rs6000_gdbarch_init): Set it in gdbarch.
* sparc-tdep.c (sparc_fetch_pointer_argument): New
(sparc_gdbarch_init): Set it in gdbarch.
Index: gdbarch.c
===================================================================
RCS file: /cvs/src/src/gdb/gdbarch.c,v
retrieving revision 1.216
diff -u -p -r1.216 gdbarch.c
--- gdbarch.c 17 May 2003 05:59:58 -0000 1.216
+++ gdbarch.c 1 Jun 2003 03:55:39 -0000
@@ -280,6 +280,7 @@ struct gdbarch
gdbarch_address_class_type_flags_to_name_ftype *address_class_type_flags_to_name;
gdbarch_address_class_name_to_type_flags_ftype *address_class_name_to_type_flags;
gdbarch_register_reggroup_p_ftype *register_reggroup_p;
+ gdbarch_fetch_pointer_argument_ftype *fetch_pointer_argument;
};
@@ -446,6 +447,7 @@ struct gdbarch startup_gdbarch =
0,
0,
default_register_reggroup_p,
+ 0,
/* startup_gdbarch() */
};
@@ -762,6 +764,7 @@ verify_gdbarch (struct gdbarch *gdbarch)
/* Skip verify of address_class_type_flags_to_name, has predicate */
/* Skip verify of address_class_name_to_type_flags, has predicate */
/* Skip verify of register_reggroup_p, invalid_p == 0 */
+ /* Skip verify of fetch_pointer_argument, has predicate */
buf = ui_file_xstrdup (log, &dummy);
make_cleanup (xfree, buf);
if (strlen (buf) > 0)
@@ -1693,6 +1696,26 @@ gdbarch_dump (struct gdbarch *gdbarch, s
(long) current_gdbarch->extract_struct_value_address
/*EXTRACT_STRUCT_VALUE_ADDRESS ()*/);
#endif
+#ifdef FETCH_POINTER_ARGUMENT_P
+ fprintf_unfiltered (file,
+ "gdbarch_dump: %s # %s\n",
+ "FETCH_POINTER_ARGUMENT_P()",
+ XSTRING (FETCH_POINTER_ARGUMENT_P ()));
+ fprintf_unfiltered (file,
+ "gdbarch_dump: FETCH_POINTER_ARGUMENT_P() = %d\n",
+ FETCH_POINTER_ARGUMENT_P ());
+#endif
+#ifdef FETCH_POINTER_ARGUMENT
+ fprintf_unfiltered (file,
+ "gdbarch_dump: %s # %s\n",
+ "FETCH_POINTER_ARGUMENT(frame, argi, type)",
+ XSTRING (FETCH_POINTER_ARGUMENT (frame, argi, type)));
+ if (GDB_MULTI_ARCH)
+ fprintf_unfiltered (file,
+ "gdbarch_dump: FETCH_POINTER_ARGUMENT = <0x%08lx>\n",
+ (long) current_gdbarch->fetch_pointer_argument
+ /*FETCH_POINTER_ARGUMENT ()*/);
+#endif
#ifdef FP0_REGNUM
fprintf_unfiltered (file,
"gdbarch_dump: FP0_REGNUM # %s\n",
@@ -5689,6 +5712,32 @@ set_gdbarch_register_reggroup_p (struct
gdbarch_register_reggroup_p_ftype register_reggroup_p)
{
gdbarch->register_reggroup_p = register_reggroup_p;
+}
+
+int
+gdbarch_fetch_pointer_argument_p (struct gdbarch *gdbarch)
+{
+ gdb_assert (gdbarch != NULL);
+ return gdbarch->fetch_pointer_argument != 0;
+}
+
+CORE_ADDR
+gdbarch_fetch_pointer_argument (struct gdbarch *gdbarch, struct frame_info *frame, int argi, struct type *type)
+{
+ gdb_assert (gdbarch != NULL);
+ if (gdbarch->fetch_pointer_argument == 0)
+ internal_error (__FILE__, __LINE__,
+ "gdbarch: gdbarch_fetch_pointer_argument invalid");
+ if (gdbarch_debug >= 2)
+ fprintf_unfiltered (gdb_stdlog, "gdbarch_fetch_pointer_argument called\n");
+ return gdbarch->fetch_pointer_argument (frame, argi, type);
+}
+
+void
+set_gdbarch_fetch_pointer_argument (struct gdbarch *gdbarch,
+ gdbarch_fetch_pointer_argument_ftype fetch_pointer_argument)
+{
+ gdbarch->fetch_pointer_argument = fetch_pointer_argument;
}
Index: gdbarch.h
===================================================================
RCS file: /cvs/src/src/gdb/gdbarch.h,v
retrieving revision 1.185
diff -u -p -r1.185 gdbarch.h
--- gdbarch.h 17 May 2003 05:59:58 -0000 1.185
+++ gdbarch.h 1 Jun 2003 03:55:42 -0000
@@ -3184,6 +3184,45 @@ typedef int (gdbarch_register_reggroup_p
extern int gdbarch_register_reggroup_p (struct gdbarch *gdbarch, int regnum, struct reggroup *reggroup);
extern void set_gdbarch_register_reggroup_p (struct gdbarch *gdbarch, gdbarch_register_reggroup_p_ftype *register_reggroup_p);
+/* Fetch the pointer to the ith function argument. */
+
+#if defined (FETCH_POINTER_ARGUMENT)
+/* Legacy for systems yet to multi-arch FETCH_POINTER_ARGUMENT */
+#if !defined (FETCH_POINTER_ARGUMENT_P)
+#define FETCH_POINTER_ARGUMENT_P() (1)
+#endif
+#endif
+
+/* Default predicate for non- multi-arch targets. */
+#if (!GDB_MULTI_ARCH) && !defined (FETCH_POINTER_ARGUMENT_P)
+#define FETCH_POINTER_ARGUMENT_P() (0)
+#endif
+
+extern int gdbarch_fetch_pointer_argument_p (struct gdbarch *gdbarch);
+#if (GDB_MULTI_ARCH > GDB_MULTI_ARCH_PARTIAL) && defined (FETCH_POINTER_ARGUMENT_P)
+#error "Non multi-arch definition of FETCH_POINTER_ARGUMENT"
+#endif
+#if (GDB_MULTI_ARCH > GDB_MULTI_ARCH_PARTIAL) || !defined (FETCH_POINTER_ARGUMENT_P)
+#define FETCH_POINTER_ARGUMENT_P() (gdbarch_fetch_pointer_argument_p (current_gdbarch))
+#endif
+
+/* Default (function) for non- multi-arch platforms. */
+#if (!GDB_MULTI_ARCH) && !defined (FETCH_POINTER_ARGUMENT)
+#define FETCH_POINTER_ARGUMENT(frame, argi, type) (internal_error (__FILE__, __LINE__, "FETCH_POINTER_ARGUMENT"), 0)
+#endif
+
+typedef CORE_ADDR (gdbarch_fetch_pointer_argument_ftype) (struct frame_info *frame, int argi, struct type *type);
+extern CORE_ADDR gdbarch_fetch_pointer_argument (struct gdbarch *gdbarch, struct frame_info *frame, int argi, struct type *type);
+extern void set_gdbarch_fetch_pointer_argument (struct gdbarch *gdbarch, gdbarch_fetch_pointer_argument_ftype *fetch_pointer_argument);
+#if (GDB_MULTI_ARCH > GDB_MULTI_ARCH_PARTIAL) && defined (FETCH_POINTER_ARGUMENT)
+#error "Non multi-arch definition of FETCH_POINTER_ARGUMENT"
+#endif
+#if GDB_MULTI_ARCH
+#if (GDB_MULTI_ARCH > GDB_MULTI_ARCH_PARTIAL) || !defined (FETCH_POINTER_ARGUMENT)
+#define FETCH_POINTER_ARGUMENT(frame, argi, type) (gdbarch_fetch_pointer_argument (current_gdbarch, frame, argi, type))
+#endif
+#endif
+
extern struct gdbarch_tdep *gdbarch_tdep (struct gdbarch *gdbarch);
Index: gdbarch.sh
===================================================================
RCS file: /cvs/src/src/gdb/gdbarch.sh,v
retrieving revision 1.237
diff -u -p -r1.237 gdbarch.sh
--- gdbarch.sh 17 May 2003 05:59:58 -0000 1.237
+++ gdbarch.sh 1 Jun 2003 03:55:45 -0000
@@ -716,6 +716,8 @@ M:2:ADDRESS_CLASS_TYPE_FLAGS_TO_NAME:con
M:2:ADDRESS_CLASS_NAME_TO_TYPE_FLAGS:int:address_class_name_to_type_flags:const char *name, int *type_flags_ptr:name, type_flags_ptr
# Is a register in a group
m:::int:register_reggroup_p:int regnum, struct reggroup *reggroup:regnum, reggroup:::default_register_reggroup_p::0
+# Fetch the pointer to the ith function argument.
+F::FETCH_POINTER_ARGUMENT:CORE_ADDR:fetch_pointer_argument:struct frame_info *frame, int argi, struct type *type:frame, argi, type:::::::::
EOF
}
Index: hppa-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/hppa-tdep.c,v
retrieving revision 1.79
diff -u -p -r1.79 hppa-tdep.c
--- hppa-tdep.c 22 May 2003 02:04:05 -0000 1.79
+++ hppa-tdep.c 1 Jun 2003 03:55:54 -0000
@@ -4993,6 +4993,16 @@ hppa_smash_text_address (CORE_ADDR addr)
return (addr &= ~0x3);
}
+/* Get the ith function argument for the current function. */
+CORE_ADDR
+hppa_fetch_pointer_argument (struct frame_info *frame, int argi,
+ struct type *type)
+{
+ CORE_ADDR addr;
+ frame_read_register (frame, R0_REGNUM + 26 - argi, &addr);
+ return addr;
+}
+
static struct gdbarch *
hppa_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
{
@@ -5070,6 +5080,9 @@ hppa_gdbarch_init (struct gdbarch_info i
set_gdbarch_read_pc (gdbarch, hppa_target_read_pc);
set_gdbarch_write_pc (gdbarch, hppa_target_write_pc);
set_gdbarch_deprecated_target_read_fp (gdbarch, hppa_target_read_fp);
+
+ /* Helper for function argument information. */
+ set_gdbarch_fetch_pointer_argument (gdbarch, hppa_fetch_pointer_argument);
return gdbarch;
}
Index: i386-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/i386-tdep.c,v
retrieving revision 1.144
diff -u -p -r1.144 i386-tdep.c
--- i386-tdep.c 17 May 2003 05:59:58 -0000 1.144
+++ i386-tdep.c 1 Jun 2003 03:55:55 -0000
@@ -1420,6 +1420,16 @@ i386_register_reggroup_p (struct gdbarch
return default_register_reggroup_p (gdbarch, regnum, group);
}
+/* Get the ith function argument for the current function. */
+CORE_ADDR
+i386_fetch_pointer_argument (struct frame_info *frame, int argi,
+ struct type *type)
+{
+ CORE_ADDR stack;
+ frame_read_register (frame, SP_REGNUM, &stack);
+ return read_memory_unsigned_integer (stack + (4 * (argi + 1)), 4);
+}
+
\f
static struct gdbarch *
i386_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
@@ -1551,6 +1561,9 @@ i386_gdbarch_init (struct gdbarch_info i
/* Add the i386 register groups. */
i386_add_reggroups (gdbarch);
set_gdbarch_register_reggroup_p (gdbarch, i386_register_reggroup_p);
+
+ /* Helper for function argument information. */
+ set_gdbarch_fetch_pointer_argument (gdbarch, i386_fetch_pointer_argument);
/* Should be using push_dummy_call. */
set_gdbarch_deprecated_dummy_write_sp (gdbarch, generic_target_write_sp);
Index: rs6000-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/rs6000-tdep.c,v
retrieving revision 1.135
diff -u -p -r1.135 rs6000-tdep.c
--- rs6000-tdep.c 29 May 2003 19:47:14 -0000 1.135
+++ rs6000-tdep.c 1 Jun 2003 03:55:59 -0000
@@ -230,6 +230,16 @@ rs6000_saved_pc_after_call (struct frame
return read_register (gdbarch_tdep (current_gdbarch)->ppc_lr_regnum);
}
+/* Get the ith function argument for the current function. */
+CORE_ADDR
+rs6000_fetch_pointer_argument (struct frame_info *frame, int argi,
+ struct type *type)
+{
+ CORE_ADDR addr;
+ frame_read_register (frame, 3 + argi, &addr);
+ return addr;
+}
+
/* Calculate the destination of a branch/jump. Return -1 if not a branch. */
static CORE_ADDR
@@ -2990,6 +3000,9 @@ rs6000_gdbarch_init (struct gdbarch_info
set_gdbarch_frame_args_address (gdbarch, rs6000_frame_args_address);
set_gdbarch_frame_locals_address (gdbarch, rs6000_frame_args_address);
set_gdbarch_deprecated_saved_pc_after_call (gdbarch, rs6000_saved_pc_after_call);
+
+ /* Helpers for function argument information. */
+ set_gdbarch_fetch_pointer_argument (gdbarch, rs6000_fetch_pointer_argument);
/* We can't tell how many args there are
now that the C compiler delays popping them. */
Index: sparc-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/sparc-tdep.c,v
retrieving revision 1.103
diff -u -p -r1.103 sparc-tdep.c
--- sparc-tdep.c 25 May 2003 15:47:26 -0000 1.103
+++ sparc-tdep.c 1 Jun 2003 03:56:07 -0000
@@ -3243,6 +3243,15 @@ sparc_return_value_on_stack (struct type
return 0;
}
+/* Get the ith function argument for the current function. */
+CORE_ADDR
+sparc_fetch_pointer_argument (struct frame_info *frame, int argi, struct type *type)
+{
+ CORE_ADDR addr;
+ frame_read_register (frame, O0_REGNUM + argi, &addr);
+ return addr;
+}
+
/*
* Gdbarch "constructor" function.
*/
@@ -3353,6 +3362,9 @@ sparc_gdbarch_init (struct gdbarch_info
set_gdbarch_sp_regnum (gdbarch, SPARC_SP_REGNUM);
set_gdbarch_deprecated_use_generic_dummy_frames (gdbarch, 0);
set_gdbarch_write_pc (gdbarch, generic_target_write_pc);
+
+ /* Helper for function argument information. */
+ set_gdbarch_fetch_pointer_argument (gdbarch, sparc_fetch_pointer_argument);
/*
* Settings that depend only on 32/64 bit word size
^ permalink raw reply [flat|nested] 11+ messages in thread* Re: [RFA]: gdbarch FETCH_POINTER_ARGUMENT
2003-06-01 4:02 ` Adam Fedor
@ 2003-06-01 22:55 ` Andrew Cagney
0 siblings, 0 replies; 11+ messages in thread
From: Andrew Cagney @ 2003-06-01 22:55 UTC (permalink / raw)
To: Adam Fedor; +Cc: GDB Patches, Daniel Jacobowitz
> Andrew Cagney wrote:
>
> Here's an updated patch. The more I looked at the "struct type *type" argument, the less I understood about how it should be used. I assume it would only be used, so far, on i386, but I'm easily confused by stacks and registers (and how things are stored there), so any pointers would be appreciated.
>
>
> The patch is almost fine. Change it to `F' instead of `f' - so that a predicate is also available.
>
>
> OK, I made this change.
>
>
>
> 2003-05-18 Adam Fedor <fedor@gnu.org>
>
> * gdbarch.sh (function_list): Add FETCH_POINTER_ARGUMENT.
> * gdbarch.[ch]: Regenerate.
> * hppa-tdep.c (hppa_fetch_pointer_argument): New function.
> (hppa_gdbarch_init): Set it in the gdbarch vector.
> * i386-tdep.c (i386_fetch_pointer_argument): New
> (i386_gdbarch_init): Set it into gdbarch.
> * rs6000-tdep.c (rs6000_fetch_pointer_argument): New.
> (rs6000_gdbarch_init): Set it in gdbarch.
> * sparc-tdep.c (sparc_fetch_pointer_argument): New
> (sparc_gdbarch_init): Set it in gdbarch.
>
Ok! Be sure to re-run gdbarch.sh before committing - I made a change
that will affect the generate gdbarch.[hc] files.
Andrew
^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2003-06-01 22:55 UTC | newest]
Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-05-19 3:12 [RFA]: gdbarch FETCH_POINTER_ARGUMENT Adam Fedor
2003-05-20 20:07 ` Andrew Cagney
2003-05-20 20:17 ` Daniel Jacobowitz
2003-05-20 20:28 ` Andrew Cagney
2003-05-22 19:16 ` Andrew Cagney
2003-05-30 3:05 ` Adam Fedor
2003-05-30 19:26 ` Andrew Cagney
2003-05-30 20:19 ` Daniel Jacobowitz
2003-05-30 21:33 ` Andrew Cagney
2003-06-01 4:02 ` Adam Fedor
2003-06-01 22:55 ` Andrew Cagney
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox