proc_regs.c (233402) | proc_regs.c (242723) |
---|---|
1/* 2 * Copyright (c) 2010 The FreeBSD Foundation 3 * All rights reserved. 4 * 5 * This software was developed by Rui Paulo under sponsorship from the 6 * FreeBSD Foundation. 7 * 8 * Redistribution and use in source and binary forms, with or without --- 14 unchanged lines hidden (view full) --- 23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27 * SUCH DAMAGE. 28 */ 29 30#include <sys/cdefs.h> | 1/* 2 * Copyright (c) 2010 The FreeBSD Foundation 3 * All rights reserved. 4 * 5 * This software was developed by Rui Paulo under sponsorship from the 6 * FreeBSD Foundation. 7 * 8 * Redistribution and use in source and binary forms, with or without --- 14 unchanged lines hidden (view full) --- 23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27 * SUCH DAMAGE. 28 */ 29 30#include <sys/cdefs.h> |
31__FBSDID("$FreeBSD: head/lib/libproc/proc_regs.c 233402 2012-03-23 23:07:02Z gonzo $"); | 31__FBSDID("$FreeBSD: head/lib/libproc/proc_regs.c 242723 2012-11-07 23:45:09Z jhibbits $"); |
32 33#include <sys/types.h> 34#include <sys/ptrace.h> 35 36#include <err.h> 37#include <stdio.h> 38#include <string.h> 39#include <errno.h> --- 15 unchanged lines hidden (view full) --- 55 switch (reg) { 56 case REG_PC: 57#if defined(__amd64__) 58 *regvalue = regs.r_rip; 59#elif defined(__i386__) 60 *regvalue = regs.r_eip; 61#elif defined(__mips__) 62 *regvalue = regs.r_regs[PC]; | 32 33#include <sys/types.h> 34#include <sys/ptrace.h> 35 36#include <err.h> 37#include <stdio.h> 38#include <string.h> 39#include <errno.h> --- 15 unchanged lines hidden (view full) --- 55 switch (reg) { 56 case REG_PC: 57#if defined(__amd64__) 58 *regvalue = regs.r_rip; 59#elif defined(__i386__) 60 *regvalue = regs.r_eip; 61#elif defined(__mips__) 62 *regvalue = regs.r_regs[PC]; |
63#elif defined(__powerpc__) 64 *regvalue = regs.pc; |
|
63#endif 64 break; 65 case REG_SP: 66#if defined(__amd64__) 67 *regvalue = regs.r_rsp; 68#elif defined(__i386__) 69 *regvalue = regs.r_esp; 70#elif defined(__mips__) 71 *regvalue = regs.r_regs[SP]; | 65#endif 66 break; 67 case REG_SP: 68#if defined(__amd64__) 69 *regvalue = regs.r_rsp; 70#elif defined(__i386__) 71 *regvalue = regs.r_esp; 72#elif defined(__mips__) 73 *regvalue = regs.r_regs[SP]; |
74#elif defined(__powerpc__) 75 *regvalue = regs.fixreg[1]; |
|
72#endif 73 break; 74 default: 75 warn("ERROR: no support for reg number %d", reg); 76 return (-1); 77 } 78 79 return (0); --- 14 unchanged lines hidden (view full) --- 94 switch (reg) { 95 case REG_PC: 96#if defined(__amd64__) 97 regs.r_rip = regvalue; 98#elif defined(__i386__) 99 regs.r_eip = regvalue; 100#elif defined(__mips__) 101 regs.r_regs[PC] = regvalue; | 76#endif 77 break; 78 default: 79 warn("ERROR: no support for reg number %d", reg); 80 return (-1); 81 } 82 83 return (0); --- 14 unchanged lines hidden (view full) --- 98 switch (reg) { 99 case REG_PC: 100#if defined(__amd64__) 101 regs.r_rip = regvalue; 102#elif defined(__i386__) 103 regs.r_eip = regvalue; 104#elif defined(__mips__) 105 regs.r_regs[PC] = regvalue; |
106#elif defined(__powerpc__) 107 regs.pc = regvalue; |
|
102#endif 103 break; 104 case REG_SP: 105#if defined(__amd64__) 106 regs.r_rsp = regvalue; 107#elif defined(__i386__) 108 regs.r_esp = regvalue; 109#elif defined(__mips__) 110 regs.r_regs[PC] = regvalue; | 108#endif 109 break; 110 case REG_SP: 111#if defined(__amd64__) 112 regs.r_rsp = regvalue; 113#elif defined(__i386__) 114 regs.r_esp = regvalue; 115#elif defined(__mips__) 116 regs.r_regs[PC] = regvalue; |
117#elif defined(__powerpc__) 118 regs.fixreg[1] = regvalue; |
|
111#endif 112 break; 113 default: 114 warn("ERROR: no support for reg number %d", reg); 115 return (-1); 116 } 117 if (ptrace(PT_SETREGS, proc_getpid(phdl), (caddr_t)®s, 0) < 0) 118 return (-1); 119 120 return (0); 121} | 119#endif 120 break; 121 default: 122 warn("ERROR: no support for reg number %d", reg); 123 return (-1); 124 } 125 if (ptrace(PT_SETREGS, proc_getpid(phdl), (caddr_t)®s, 0) < 0) 126 return (-1); 127 128 return (0); 129} |