[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Gdb] A problem when ptrace accessing a bad address
From: |
Chen Qi-A18263 |
Subject: |
[Gdb] A problem when ptrace accessing a bad address |
Date: |
Wed, 25 Feb 2004 15:15:27 +0800 |
Hi, guys:
Here I have encountered a problem when the ptrace function call trying
to accessing a bad address.
( This problem happed in the ColdFire uClinux )
Description:
When calling : ptrace(PT_READ_I, PID, Address ... ), and when the
Address is a an invalid address, the program will crashed on uClinux.
I have compared the same problem in x86 redhat linux8.0, and find that
when the ptrace trying to read an invalid memory address, it will not crash but
putting the following error message:
---------------------------------------------------------------------------
ptrace memory read failed: Input/output error
---------------------------------------------------------------------------
But In my uClinux for Coldfire, it just crash without any error message
( I think that maybe it's cause by the mmu-less feature on Coldfire. )
To avoid this problem, I have trying the following way, it they seems
not workable, wish you could give you some suggestions:
1. Normally, when the program attempting to access a bad address, the
system will raise SIGSEGV or SIGBUS signal, for example:
I can catch the signal and restore the context by :
--------------------------------------------------------------------
#include <setjmp.h>
#include <signal.h>
void SIGSEGV_Handler()
{
printf("SIGSEGV111 Id: %d is handled\n",SIGSEGV);
longjmp( gTrkExceptionJmpBuf, 1 );
}
jmp_buf gTrkExceptionJmpBuf;
int main()
{
if (setjmp( gTrkExceptionJmpBuf ) == 0)
{
int* pointer = 0xFF000000;
int value = *pointer; //can catch
SIGSEGV singal by this memory accessing
//ptrace(PT_READ_I, PID, pointer... ) //can't catch
ANY type singal by this memory accessing.
}
else
{
printf("Bad address access\n");
}
}
--------------------------------------------------------------------
But unfortuattly, when the ptrace accessing the bad address, I can't
catch ANY type of signal. Could someone tell me why? and how can I catch the
signal?
2. If the we can't catch the ptrace signal ( or it did not raise any
signal ), I am thinking of add a memory validate function before ptrace call,
the memory validate function can be implemented by the normal memory access
with setjmp and longjmp protect. But this way can't be use in my Coldfire board.
Because in ColdFire board, the address from 0xFFE00000 to 0xFFFFFFFF is
Flash rom address and we can accessing them, while the ptrace function can't
access it and it will crash too!
Thanks and Best Regards!
ChenQi(v)
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Gdb] A problem when ptrace accessing a bad address,
Chen Qi-A18263 <=