2000-04-05 Scott Bambrough <scottb@netwinder.org>
[platform/upstream/binutils.git] / gdb / arm-linux-tdep.c
1 /* GNU/Linux on ARM target support.
2    Copyright 1999, 2000 Free Software Foundation, Inc.
3
4    This file is part of GDB.
5
6    This program is free software; you can redistribute it and/or modify
7    it under the terms of the GNU General Public License as published by
8    the Free Software Foundation; either version 2 of the License, or
9    (at your option) any later version.
10
11    This program is distributed in the hope that it will be useful,
12    but WITHOUT ANY WARRANTY; without even the implied warranty of
13    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14    GNU General Public License for more details.
15
16    You should have received a copy of the GNU General Public License
17    along with this program; if not, write to the Free Software
18    Foundation, Inc., 59 Temple Place - Suite 330,
19    Boston, MA 02111-1307, USA.  */
20
21 #include "defs.h"
22 #include "target.h"
23 #include "value.h"
24 #include "gdbtypes.h"
25
26 #ifdef GET_LONGJMP_TARGET
27
28 /* Figure out where the longjmp will land.  We expect that we have
29    just entered longjmp and haven't yet altered r0, r1, so the
30    arguments are still in the registers.  (A1_REGNUM) points at the
31    jmp_buf structure from which we extract the pc (JB_PC) that we will
32    land at.  The pc is copied into ADDR.  This routine returns true on
33    success. */
34
35 #define LONGJMP_TARGET_SIZE     sizeof(int)
36 #define JB_ELEMENT_SIZE         sizeof(int)
37 #define JB_SL                   18
38 #define JB_FP                   19
39 #define JB_SP                   20
40 #define JB_PC                   21
41
42 int
43 arm_get_longjmp_target (CORE_ADDR * pc)
44 {
45   CORE_ADDR jb_addr;
46   char buf[LONGJMP_TARGET_SIZE];
47
48   jb_addr = read_register (A1_REGNUM);
49
50   if (target_read_memory (jb_addr + JB_PC * JB_ELEMENT_SIZE, buf,
51                           LONGJMP_TARGET_SIZE))
52     return 0;
53
54   *pc = extract_address (buf, LONGJMP_TARGET_SIZE);
55   return 1;
56 }
57
58 #endif /* GET_LONGJMP_TARGET */
59
60 /* Extract from an array REGBUF containing the (raw) register state
61    a function return value of type TYPE, and copy that, in virtual format,
62    into VALBUF.  */
63
64 void
65 arm_linux_extract_return_value (struct type *type,
66                                 char regbuf[REGISTER_BYTES],
67                                 char *valbuf)
68 {
69   /* ScottB: This needs to be looked at to handle the different
70      floating point emulators on ARM Linux.  Right now the code
71      assumes that fetch inferior registers does the right thing for
72      GDB.  I suspect this won't handle NWFPE registers correctly, nor
73      will the default ARM version (arm_extract_return_value()).  */
74
75   int regnum = (TYPE_CODE_FLT == TYPE_CODE (type)) ? F0_REGNUM : A1_REGNUM;
76   memcpy (valbuf, &regbuf[REGISTER_BYTE (regnum)], TYPE_LENGTH (type));
77 }
78
79 void
80 _initialize_arm_linux_tdep (void)
81 {
82 }