|
发表于 2004-7-13 16:43:52
|
显示全部楼层
-------
上次好像有0D0A格式问题.
-------
附件是整个修改后的gdbserver,包括uclinux2.4.17kernel ptrace.c
本来修改比较少,不想把整个东西放上来.
不过,有些朋友要,还是不太方便,就放在这里了.
0)全部修改我已经传给chyyuu,不过目前只有本人的测试
1)gdbserver:
前面我写的就是对gdbserver本身的全部修改.
2)uclinux kernel2.4.17:
a.但是uclinux2.4.17 for at91(我测试的版本)缺省运行的flat程序是在USER26Mode下,
不是USER32Mode.这样,gdbserver/skyeye(client)的单步运行就会出问题.
我修改了arch/armnommu/kernel/ptrace.c,以支持这种情况.
b.uclinux的ptrace没有对内存读写做限制,很容易搞到进程外内存
//added by telpro
#define REG_SP 13
int in_arm26_mode(struct task_struct *child)
{
long psr;
psr = get_stack_long(child, REG_PSR) ;
return ((psr & 0x1f) <= 3);
}
#define FIXPC(child, x) \
do { \
if(in_arm26_mode(child)) x = x & 0x0ffffffc; \
}while(0)
//do as arch/armnommu/kernel/process.c
//a dirty version, FIXME...telpro
int is_addr_access( struct task_struct *child,
unsigned long addr )
{
unsigned long sp;
if ( addr >= child->mm->start_code &&
addr < child->mm->end_code )
return 1;
if ( addr >= child->mm->start_data &&
addr < child->mm->brk )
return 1;
sp = get_stack_long(child, REG_SP) ;
//actually <sp is r/w also.
if ( addr >= sp &&
addr < child->mm->start_stack )
return 1;
return 0;
}
int ptrace_set_bpt(struct task_struct *child)
{
struct pt_regs *regs;
unsigned long pc, insn;
int res;
regs = get_user_regs(child);
pc = instruction_pointer(regs);
//26bit , added by telpro
FIXPC(child, pc);
res = read_tsk_long(child, pc, &insn);
if (!res) {
struct debug_info *dbg = &child->thread.debug;
unsigned long alt;
dbg->nsaved = 0;
alt = get_branch_address(child, pc, insn);
if (alt) {
FIXPC(child, alt); //added by telpro
res = add_breakpoint_arm(child, dbg, alt);
}
.........
}
static int do_ptrace(int request, struct task_struct *child, long addr, long data)
中加入
case PTRACE_PEEKTEXT:
case PTRACE_PEEKDATA:
/*added by telpro*/
if (!is_addr_access(child, addr) ) {
ret = -EIO;
break;
}
ret = read_tsk_long(child, addr, &tmp);
....
case PTRACE_POKETEXT:
case PTRACE_POKEDATA:
/*added by telpro*/
if (!is_addr_access(child, addr) ) {
ret = -EIO;
break;
}
ret = write_tsk_long(child, addr, data);
break;
.......
case PTRACE_PEEKUSR:
ret = -EIO;
if ((addr & 3) || addr < 0 || addr >= sizeof(struct user))
break;
tmp = 0; /* Default return condition */
if (addr < sizeof(struct pt_regs)) {
tmp = get_stack_long(child, (int)addr >> 2);
//added by telpro, for at91
if(addr == 14*4 || addr == 15*4 ) {
FIXPC(child, tmp);
}
} else if (addr == 49*4) {
tmp = child->mm->start_code;
} else if (addr == 50*4) {
tmp = child->mm->start_data;
} else if (addr == 51*4) {
.....
3)已知问题
a.现在对USER26MOde的应用程序不是支持得很好,
r14,r15是按照USER32Mode显示的结果.
这是不对的.
完整的解决需要修改client端软件,也就是skyeye与gdbserver配合的部分.
不过,USER26总感觉是一种淘汰模式,xscale这些已经不支持它了.
因此,也不想花大力气去解决.
b.Thumb模式不支持 |
本帖子中包含更多资源
您需要 登录 才可以下载或查看,没有账号?注册
×
|