11.19Smgorny/* $NetBSD: ptrace.h,v 1.19 2020/10/15 17:37:36 mgorny Exp $ */ 21.1Sitojun 31.1Sitojun/* 41.1Sitojun * Copyright (c) 1993 Christopher G. Demetriou 51.1Sitojun * All rights reserved. 61.1Sitojun * 71.1Sitojun * Redistribution and use in source and binary forms, with or without 81.1Sitojun * modification, are permitted provided that the following conditions 91.1Sitojun * are met: 101.1Sitojun * 1. Redistributions of source code must retain the above copyright 111.1Sitojun * notice, this list of conditions and the following disclaimer. 121.1Sitojun * 2. Redistributions in binary form must reproduce the above copyright 131.1Sitojun * notice, this list of conditions and the following disclaimer in the 141.1Sitojun * documentation and/or other materials provided with the distribution. 151.1Sitojun * 3. All advertising materials mentioning features or use of this software 161.1Sitojun * must display the following acknowledgement: 171.1Sitojun * This product includes software developed by Christopher G. Demetriou. 181.1Sitojun * 4. The name of the author may not be used to endorse or promote products 191.1Sitojun * derived from this software without specific prior written permission 201.1Sitojun * 211.1Sitojun * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 221.1Sitojun * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 231.1Sitojun * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 241.1Sitojun * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 251.1Sitojun * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 261.1Sitojun * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 271.1Sitojun * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 281.1Sitojun * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 291.1Sitojun * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 301.1Sitojun * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 311.1Sitojun */ 321.1Sitojun 331.5Suwe#ifndef _SH3_PTRACE_H_ 341.5Suwe#define _SH3_PTRACE_H_ 351.5Suwe 361.1Sitojun/* 371.1Sitojun * sh3-dependent ptrace definitions 381.1Sitojun */ 391.2Smsaitoh 401.9Suwe#define PT_STEP (PT_FIRSTMACH + 0) 411.9Suwe 421.7Suwe/* old struct reg (now struct __reg40) that was missing r_gbr */ 431.7Suwe#define PT___GETREGS40 (PT_FIRSTMACH + 1) 441.7Suwe#define PT___SETREGS40 (PT_FIRSTMACH + 2) 451.7Suwe 461.7Suwe#define PT_GETREGS (PT_FIRSTMACH + 3) 471.7Suwe#define PT_SETREGS (PT_FIRSTMACH + 4) 481.1Sitojun 491.10Suwe#if 0 /* XXX: not yet, but reserve the numbers "leaked" to readelf(1). */ 501.10Suwe#define PT_GETFPREGS (PT_FIRSTMACH + 5) 511.10Suwe#define PT_SETFPREGS (PT_FIRSTMACH + 6) 521.10Suwe#endif 531.10Suwe 541.13Skamil#define PT_SETSTEP (PT_FIRSTMACH + 7) 551.13Skamil#define PT_CLEARSTEP (PT_FIRSTMACH + 8) 561.13Skamil 571.4Sskrll#define PT_MACHDEP_STRINGS \ 581.9Suwe "PT_STEP", \ 591.7Suwe "PT___GETREGS40", \ 601.7Suwe "PT___SETREGS40", \ 611.4Sskrll "PT_GETREGS", \ 621.13Skamil "PT_SETREGS", \ 631.13Skamil "PT_GETFPREGS", \ 641.13Skamil "PT_SETFPREGS", \ 651.13Skamil "PT_SETSTEP", \ 661.13Skamil "PT_CLEARSTEP" 671.5Suwe 681.11Schristos#include <machine/reg.h> 691.18Smrg#define PTRACE_REG_PC(r) (r)->r_spc 701.18Smrg#define PTRACE_REG_FP(r) (r)->r_r14 711.18Smrg#define PTRACE_REG_SET_PC(r, v) (r)->r_spc = (v) 721.18Smrg#define PTRACE_REG_SP(r) (r)->r_r15 731.18Smrg#define PTRACE_REG_INTV(r) (r)->r_r0 741.8Suwe 751.16Smaya#define PTRACE_ILLEGAL_ASM __asm __volatile ("0: bra 0b; bra 0b" : : : "memory") 761.16Smaya 771.14Skamil#define PTRACE_BREAKPOINT_TRAP 0xc3 781.12Schristos#define PTRACE_BREAKPOINT ((const uint8_t[]) { 0xc3, 0xc3 }) 791.14Skamil#define PTRACE_BREAKPOINT_ASM __asm __volatile("trapa %0" :: "i"(PTRACE_BREAKPOINT_TRAP)) 801.12Schristos#define PTRACE_BREAKPOINT_SIZE 2 811.12Schristos 821.8Suwe#ifdef _KERNEL 831.8Suwe#ifdef _KERNEL_OPT 841.8Suwe#include "opt_compat_netbsd.h" 851.8Suwe#endif 861.8Suwe 871.8Suwe#ifdef COMPAT_40 881.8Suwe 891.8Suwe#define __HAVE_PTRACE_MACHDEP 901.8Suwe 911.8Suwe#define PTRACE_MACHDEP_REQUEST_CASES \ 921.8Suwe case PT___GETREGS40: /* FALLTHROUGH */ \ 931.8Suwe case PT___SETREGS40: 941.8Suwe 951.8Suwe#endif /* COMPAT_40 */ 961.8Suwe 971.8Suwe#ifdef __HAVE_PTRACE_MACHDEP 981.19Smgornyint ptrace_machdep_dorequest(struct lwp *, struct lwp **, int, void *, int); 991.8Suwe#endif 1001.8Suwe 1011.17Skamil#define PTRACE_LWP_GETPRIVATE(l) (l)->l_md.md_regs->tf_gbr 1021.8Suwe#endif /* _KERNEL */ 1031.6Suwe#endif /* !_SH3_PTRACE_H_ */ 104