GDB (API)
|
00001 /* Native-dependent code for Solaris x86. 00002 00003 Copyright (C) 2004-2013 Free Software Foundation, Inc. 00004 00005 This file is part of GDB. 00006 00007 This program is free software; you can redistribute it and/or modify 00008 it under the terms of the GNU General Public License as published by 00009 the Free Software Foundation; either version 3 of the License, or 00010 (at your option) any later version. 00011 00012 This program is distributed in the hope that it will be useful, 00013 but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00015 GNU General Public License for more details. 00016 00017 You should have received a copy of the GNU General Public License 00018 along with this program. If not, see <http://www.gnu.org/licenses/>. */ 00019 00020 #include "defs.h" 00021 #include "regcache.h" 00022 00023 #include <sys/procfs.h> 00024 #include "gregset.h" 00025 #include "target.h" 00026 #include "procfs.h" 00027 00028 /* This file provids the (temporary) glue between the Solaris x86 00029 target dependent code and the machine independent SVR4 /proc 00030 support. */ 00031 00032 /* Solaris 10 (Solaris 2.10, SunOS 5.10) and up support two process 00033 data models, the traditional 32-bit data model (ILP32) and the 00034 64-bit data model (LP64). The format of /proc depends on the data 00035 model of the observer (the controlling process, GDB in our case). 00036 The Solaris header files conveniently define PR_MODEL_NATIVE to the 00037 data model of the controlling process. If its value is 00038 PR_MODEL_LP64, we know that GDB is being compiled as a 64-bit 00039 program. 00040 00041 Note that a 32-bit GDB won't be able to debug a 64-bit target 00042 process using /proc on Solaris. */ 00043 00044 #if defined (PR_MODEL_NATIVE) && (PR_MODEL_NATIVE == PR_MODEL_LP64) 00045 00046 #include "amd64-nat.h" 00047 #include "amd64-tdep.h" 00048 00049 /* Mapping between the general-purpose registers in gregset_t format 00050 and GDB's register cache layout. */ 00051 00052 /* From <sys/regset.h>. */ 00053 static int amd64_sol2_gregset64_reg_offset[] = { 00054 14 * 8, /* %rax */ 00055 11 * 8, /* %rbx */ 00056 13 * 8, /* %rcx */ 00057 12 * 8, /* %rdx */ 00058 9 * 8, /* %rsi */ 00059 8 * 8, /* %rdi */ 00060 10 * 8, /* %rbp */ 00061 20 * 8, /* %rsp */ 00062 7 * 8, /* %r8 ... */ 00063 6 * 8, 00064 5 * 8, 00065 4 * 8, 00066 3 * 8, 00067 2 * 8, 00068 1 * 8, 00069 0 * 8, /* ... %r15 */ 00070 17 * 8, /* %rip */ 00071 19 * 8, /* %eflags */ 00072 18 * 8, /* %cs */ 00073 21 * 8, /* %ss */ 00074 25 * 8, /* %ds */ 00075 24 * 8, /* %es */ 00076 22 * 8, /* %fs */ 00077 23 * 8 /* %gs */ 00078 }; 00079 00080 /* 32-bit registers are provided by Solaris in 64-bit format, so just 00081 give a subset of the list above. */ 00082 static int amd64_sol2_gregset32_reg_offset[] = { 00083 14 * 8, /* %eax */ 00084 13 * 8, /* %ecx */ 00085 12 * 8, /* %edx */ 00086 11 * 8, /* %ebx */ 00087 20 * 8, /* %esp */ 00088 10 * 8, /* %ebp */ 00089 9 * 8, /* %esi */ 00090 8 * 8, /* %edi */ 00091 17 * 8, /* %eip */ 00092 19 * 8, /* %eflags */ 00093 18 * 8, /* %cs */ 00094 21 * 8, /* %ss */ 00095 25 * 8, /* %ds */ 00096 24 * 8, /* %es */ 00097 22 * 8, /* %fs */ 00098 23 * 8 /* %gs */ 00099 }; 00100 00101 void 00102 supply_gregset (struct regcache *regcache, const prgregset_t *gregs) 00103 { 00104 amd64_supply_native_gregset (regcache, gregs, -1); 00105 } 00106 00107 void 00108 supply_fpregset (struct regcache *regcache, const prfpregset_t *fpregs) 00109 { 00110 amd64_supply_fxsave (regcache, -1, fpregs); 00111 } 00112 00113 void 00114 fill_gregset (const struct regcache *regcache, 00115 prgregset_t *gregs, int regnum) 00116 { 00117 amd64_collect_native_gregset (regcache, gregs, regnum); 00118 } 00119 00120 void 00121 fill_fpregset (const struct regcache *regcache, 00122 prfpregset_t *fpregs, int regnum) 00123 { 00124 amd64_collect_fxsave (regcache, regnum, fpregs); 00125 } 00126 00127 #else 00128 00129 /* For 32-bit Solaris x86, we use the Unix SVR4 code in i386v4-nat.c. */ 00130 00131 #endif 00132 00133 /* Provide a prototype to silence -Wmissing-prototypes. */ 00134 extern void _initialize_amd64_sol2_nat (void); 00135 00136 void 00137 _initialize_amd64_sol2_nat (void) 00138 { 00139 struct target_ops *t; 00140 00141 /* Fill in the generic procfs methods. */ 00142 t = procfs_target (); 00143 00144 #ifdef NEW_PROC_API /* Solaris 6 and above can do HW watchpoints. */ 00145 procfs_use_watchpoints (t); 00146 #endif 00147 00148 #if defined (PR_MODEL_NATIVE) && (PR_MODEL_NATIVE == PR_MODEL_LP64) 00149 amd64_native_gregset32_reg_offset = amd64_sol2_gregset32_reg_offset; 00150 amd64_native_gregset32_num_regs = 00151 ARRAY_SIZE (amd64_sol2_gregset32_reg_offset); 00152 amd64_native_gregset64_reg_offset = amd64_sol2_gregset64_reg_offset; 00153 amd64_native_gregset64_num_regs = 00154 ARRAY_SIZE (amd64_sol2_gregset64_reg_offset); 00155 #endif 00156 00157 add_target (t); 00158 }