MIPS Ptrace的疑问

113 views
Skip to first unread message

彭建章

unread,
Oct 24, 2009, 11:55:13 PM10/24/09
to hell...@googlegroups.com
大家好,在MIPS下用
ptrace(PTRACE_GETREGS,child,NULL,&regs) 我想要在break的时候读出EPC

 读出的寄存器的组织是怎么样的?
我在<linux/user.h>没有找到明确的结果。

谢谢大家

Hui Zhu

unread,
Oct 25, 2009, 4:45:12 AM10/25/09
to hell...@googlegroups.com
KERNEL比较明确

2009/10/25 彭建章 <pengji...@gmail.com>:

Amker.Cheng

unread,
Oct 25, 2009, 9:27:35 PM10/25/09
to hell...@googlegroups.com
>> 大家好,在MIPS下用
>> ptrace(PTRACE_GETREGS,child,NULL,&regs) 我想要在break的时候读出EPC
>>
>> 读出的寄存器的组织是怎么样的?
>> 我在<linux/user.h>没有找到明确的结果。
是不是在<asm/ptrace.h>中,里面有ptrace调用获取的寄存器结构的组织。

--
Best Regards.

Hui Zhu

unread,
Oct 25, 2009, 9:34:14 PM10/25/09
to hell...@googlegroups.com
/*
* This struct defines the way the registers are stored on the stack during a
* system call/exception. As usual the registers k0/k1 aren't being saved.
*/
struct pt_regs {
#ifdef CONFIG_32BIT
/* Pad bytes for argument save space on the stack. */
unsigned long pad0[6];
#endif

/* Saved main processor registers. */
unsigned long regs[32];

/* Saved special registers. */
unsigned long cp0_status;
unsigned long hi;
unsigned long lo;
#ifdef CONFIG_CPU_HAS_SMARTMIPS
unsigned long acx;
#endif
unsigned long cp0_badvaddr;
unsigned long cp0_cause;
unsigned long cp0_epc;
#ifdef CONFIG_MIPS_MT_SMTC
unsigned long cp0_tcstatus;
#endif /* CONFIG_MIPS_MT_SMTC */
} __attribute__ ((aligned (8)));

2009/10/26 Amker.Cheng <amker...@gmail.com>:

彭建章

unread,
Oct 25, 2009, 9:51:08 PM10/25/09
to hell...@googlegroups.com
/*
 * Read a general register set.  We always use the 64-bit format, even
 * for 32-bit kernels and for 32-bit processes on a 64-bit kernel.
 * Registers are sign extended to fill the available space.
 */
int ptrace_getregs(struct task_struct *child, __s64 __user *data)
{
        struct pt_regs *regs;
        int i;

        if (!access_ok(VERIFY_WRITE, data, 38 * 8))
                return -EIO;

        regs = task_pt_regs(child);

        for (i = 0; i < 32; i++)
                __put_user((long)regs->regs[i], data + i);
        __put_user((long)regs->lo, data + EF_LO - EF_R0);
        __put_user((long)regs->hi, data + EF_HI - EF_R0);
        __put_user((long)regs->cp0_epc, data + EF_CP0_EPC - EF_R0);
        __put_user((long)regs->cp0_badvaddr, data + EF_CP0_BADVADDR - EF_R0);
        __put_user((long)regs->cp0_status, data + EF_CP0_STATUS - EF_R0);
        __put_user((long)regs->cp0_cause, data + EF_CP0_CAUSE - EF_R0);

        return 0;
}



2009/10/26 Hui Zhu <teaw...@gmail.com>

彭建章

unread,
Oct 26, 2009, 6:19:33 AM10/26/09
to hell...@googlegroups.com
谢谢Hui Zhu, Amker. Cheng

2009/10/26 彭建章 <pengji...@gmail.com>
Reply all
Reply to author
Forward
0 new messages