Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: "Theodore A. Roth" <troth@openavr.org>
To: gdb-patches@sources.redhat.com
Subject: [commit] [avr] add extract_return_value method
Date: Tue, 17 Jun 2003 04:49:00 -0000	[thread overview]
Message-ID: <Pine.LNX.4.44.0306162143320.5352-200000@bozoland.mynet> (raw)

[-- Attachment #1: Type: TEXT/PLAIN, Size: 319 bytes --]

Hi,

Committed the attached.

This adds an extract_return_value method for the avr and get the 'call 
function()' command to handle return values.

Ted Roth

2003-06-16  Theodore A. Roth  <troth@openavr.org>

	* avr-tdep.c (avr_extract_return_value): New function.
	(avr_gdbarch_init): Set extract_return_value method.

[-- Attachment #2: Type: TEXT/PLAIN, Size: 1927 bytes --]

2003-06-16  Theodore A. Roth  <troth@openavr.org>

	* avr-tdep.c (avr_extract_return_value): New function.
	(avr_gdbarch_init): Set extract_return_value method.
 
Index: avr-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/avr-tdep.c,v
retrieving revision 1.59
diff -u -r1.59 avr-tdep.c
--- avr-tdep.c	16 Jun 2003 05:50:16 -0000	1.59
+++ avr-tdep.c	17 Jun 2003 04:41:20 -0000
@@ -1094,6 +1094,39 @@
     return avr_break_insn;
 }
 
+/* Given a return value in `regbuf' with a type `valtype', 
+   extract and copy its value into `valbuf'.
+
+   Return values are always passed via registers r25:r24:...  */
+
+static void
+avr_extract_return_value (struct type *type, struct regcache *regcache,
+                          void *valbuf)
+{
+  if (TYPE_LENGTH (type) == 1)
+    {
+      ULONGEST c;
+
+      /* For single byte return values, r25 is always cleared, so we can
+         ignore it.  */
+      regcache_cooked_read_unsigned (regcache, 24, &c);
+      store_unsigned_integer (valbuf, 1, c);
+    }
+  else
+    {
+      int i;
+      /* The MSB of the return value is always in r25, calculate which
+         register holds the LSB.  */
+      int lsb_reg = 25 - TYPE_LENGTH (type) + 1;
+
+      for (i=0; i< TYPE_LENGTH (type); i++)
+        {
+          regcache_cooked_read (regcache, lsb_reg + i,
+                                (bfd_byte *) valbuf + i);
+        }
+    }
+}
+
 /* Initialize the gdbarch structure for the AVR's. */
 
 static struct gdbarch *
@@ -1157,6 +1190,7 @@
   set_gdbarch_register_name (gdbarch, avr_register_name);
   set_gdbarch_register_type (gdbarch, avr_register_type);
 
+  set_gdbarch_extract_return_value (gdbarch, avr_extract_return_value);
   set_gdbarch_print_insn (gdbarch, print_insn_avr);
 
   set_gdbarch_call_dummy_address (gdbarch, avr_call_dummy_address);

                 reply	other threads:[~2003-06-17  4:49 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=Pine.LNX.4.44.0306162143320.5352-200000@bozoland.mynet \
    --to=troth@openavr.org \
    --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