* libbfd.c (COERCE32): Cast through unsigned long and long to
[deliverable/binutils-gdb.git] / gdb / m68klinux-nat.c
CommitLineData
1994dc7c
EE
1/* Motorola m68k native support for Linux
2 Copyright (C) 1996,1998 Free Software Foundation, Inc.
3
4This file is part of GDB.
5
6This program is free software; you can redistribute it and/or modify
7it under the terms of the GNU General Public License as published by
8the Free Software Foundation; either version 2 of the License, or
9(at your option) any later version.
10
11This program is distributed in the hope that it will be useful,
12but WITHOUT ANY WARRANTY; without even the implied warranty of
13MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14GNU General Public License for more details.
15
16You should have received a copy of the GNU General Public License
17along with this program; if not, write to the Free Software
18Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
19
20#include "defs.h"
21#include "frame.h"
22#include "inferior.h"
23#include "language.h"
24#include "gdbcore.h"
25
26#ifdef USG
27#include <sys/types.h>
28#endif
29
30#include <sys/param.h>
31#include <sys/dir.h>
32#include <signal.h>
33#include <sys/user.h>
34#include <sys/ioctl.h>
35#include <fcntl.h>
36#include <sys/procfs.h>
37
38#include <sys/file.h>
39#include "gdb_stat.h"
40
41#include "floatformat.h"
42
43#include "target.h"
44
45\f
46/* This table must line up with REGISTER_NAMES in tm-m68k.h */
47static const int regmap[] =
48{
49 PT_D0, PT_D1, PT_D2, PT_D3, PT_D4, PT_D5, PT_D6, PT_D7,
50 PT_A0, PT_A1, PT_A2, PT_A3, PT_A4, PT_A5, PT_A6, PT_USP,
51 PT_SR, PT_PC,
52 /* PT_FP0, ..., PT_FP7 */
53 21, 24, 27, 30, 33, 36, 39, 42,
54 /* PT_FPCR, PT_FPSR, PT_FPIAR */
55 45, 46, 47
56};
57
58/* BLOCKEND is the value of u.u_ar0, and points to the place where GS
59 is stored. */
60
61int
62m68k_linux_register_u_addr (blockend, regnum)
63 int blockend;
64 int regnum;
65{
66 return (blockend + 4 * regmap[regnum]);
67}
68
69/* Given a pointer to a general register set in /proc format (gregset_t *),
70 unpack the register contents and supply them as gdb's idea of the current
71 register values. */
72
73#ifndef USE_PROC_FS
74
75void
76supply_gregset (gregsetp)
77 gregset_t *gregsetp;
78{
79 int regi;
80
81 for (regi = D0_REGNUM ; regi <= SP_REGNUM ; regi++)
82 supply_register (regi, (char *) (*gregsetp + regmap[regi]));
83 supply_register (PS_REGNUM, (char *) (*gregsetp + PT_SR));
84 supply_register (PC_REGNUM, (char *) (*gregsetp + PT_PC));
85}
86
87/* Given a pointer to a floating point register set in /proc format
88 (fpregset_t *), unpack the register contents and supply them as gdb's
89 idea of the current floating point register values. */
90
91void
92supply_fpregset (fpregsetp)
93 fpregset_t *fpregsetp;
94{
95 int regi;
96
97 for (regi = FP0_REGNUM ; regi < FPC_REGNUM ; regi++)
98 supply_register (regi, (char *) &fpregsetp->fpregs[(regi - FP0_REGNUM) * 3]);
99 supply_register (FPC_REGNUM, (char *) &fpregsetp->fpcntl[0]);
100 supply_register (FPS_REGNUM, (char *) &fpregsetp->fpcntl[1]);
101 supply_register (FPI_REGNUM, (char *) &fpregsetp->fpcntl[2]);
102}
103
104#endif
105
106\f
107int
108kernel_u_size ()
109{
110 return (sizeof (struct user));
111}
112\f
113/* Return non-zero if PC points into the signal trampoline. */
114
115int
116in_sigtramp (pc)
117 CORE_ADDR pc;
118{
119 CORE_ADDR sp;
120 char buf[TARGET_SHORT_BIT / TARGET_CHAR_BIT];
121 int insn;
122
123 sp = read_register (SP_REGNUM);
124 if (pc - 2 < sp)
125 return 0;
126
127 if (read_memory_nobpt (pc, buf, sizeof (buf)))
128 return 0;
129 insn = extract_unsigned_integer (buf, sizeof (buf));
130 if (insn == 0xdefc /* addaw #,sp */
131 || insn == 0x7077 /* moveq #119,d0 */
132 || insn == 0x4e40 /* trap #0 */
133 || insn == 0x203c /* movel #,d0 */)
134 return 1;
135
136 if (read_memory_nobpt (pc - 2, buf, sizeof (buf)))
137 return 0;
138 insn = extract_unsigned_integer (buf, sizeof (buf));
139 if (insn == 0xdefc /* addaw #,sp */
140 || insn == 0x7077 /* moveq #119,d0 */
141 || insn == 0x4e40 /* trap #0 */
142 || insn == 0x203c /* movel #,d0 */)
143 return 1;
144
145 return 0;
146}
This page took 0.027663 seconds and 4 git commands to generate.