• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* Fetch live process registers from TID.
2    This file is part of elfutils.
3 
4    This file is free software; you can redistribute it and/or modify
5    it under the terms of either
6 
7      * the GNU Lesser General Public License as published by the Free
8        Software Foundation; either version 3 of the License, or (at
9        your option) any later version
10 
11    or
12 
13      * the GNU General Public License as published by the Free
14        Software Foundation; either version 2 of the License, or (at
15        your option) any later version
16 
17    or both in parallel, as here.
18 
19    elfutils is distributed in the hope that it will be useful, but
20    WITHOUT ANY WARRANTY; without even the implied warranty of
21    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
22    General Public License for more details.
23 
24    You should have received copies of the GNU General Public License and
25    the GNU Lesser General Public License along with this program.  If
26    not, see <http://www.gnu.org/licenses/>.  */
27 
28 #ifdef HAVE_CONFIG_H
29 # include <config.h>
30 #endif
31 
32 #if defined __m68k__ && defined __linux__
33 # include <sys/types.h>
34 # include <sys/user.h>
35 # include <sys/ptrace.h>
36 #endif
37 
38 #define BACKEND m68k_
39 #include "libebl_CPU.h"
40 
41 bool
m68k_set_initial_registers_tid(pid_t tid,ebl_tid_registers_t * setfunc,void * arg)42 m68k_set_initial_registers_tid (pid_t tid __attribute__ ((unused)),
43 				ebl_tid_registers_t *setfunc __attribute__ ((unused)),
44 				void *arg __attribute__ ((unused)))
45 {
46 #if !defined __m68k__ || !defined __linux__
47   return false;
48 #else /* __m68k__ */
49   struct user_regs_struct user_regs;
50   if (ptrace (PTRACE_GETREGS, tid, NULL, &user_regs) != 0)
51     return false;
52 
53   Dwarf_Word dwarf_regs[16];
54   dwarf_regs[0] = user_regs.d0;
55   dwarf_regs[1] = user_regs.d1;
56   dwarf_regs[2] = user_regs.d2;
57   dwarf_regs[3] = user_regs.d3;
58   dwarf_regs[4] = user_regs.d4;
59   dwarf_regs[5] = user_regs.d5;
60   dwarf_regs[6] = user_regs.d6;
61   dwarf_regs[7] = user_regs.d7;
62   dwarf_regs[8] = user_regs.a0;
63   dwarf_regs[9] = user_regs.a1;
64   dwarf_regs[10] = user_regs.a2;
65   dwarf_regs[11] = user_regs.a3;
66   dwarf_regs[12] = user_regs.a4;
67   dwarf_regs[13] = user_regs.a5;
68   dwarf_regs[14] = user_regs.a6;
69   dwarf_regs[15] = user_regs.usp;
70 
71   /* D0..D7, A0..A7.  */
72   if (! setfunc (0, 16, dwarf_regs, arg))
73     return false;
74 
75   /* PC.  */
76   dwarf_regs[0] = user_regs.pc;
77   if (! setfunc (24, 1, dwarf_regs, arg))
78     return false;
79 
80   return true;
81 #endif /* __m68k__ */
82 }
83