Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Adam Fedor <fedor@doc.com>
To: GDB Patches <gdb-patches@sources.redhat.com>
Cc: Andrew Cagney <ac131313@redhat.com>,
	 Daniel Jacobowitz <drow@mvista.com>
Subject: Re: [RFA]: gdbarch FETCH_POINTER_ARGUMENT
Date: Fri, 30 May 2003 03:05:00 -0000	[thread overview]
Message-ID: <3ED6CA78.9010109@doc.com> (raw)
In-Reply-To: <3ECD2201.5040306@redhat.com>

[-- 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 

  reply	other threads:[~2003-05-30  3:05 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-05-19  3:12 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 [this message]
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

Reply instructions:

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

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

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

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

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

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

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