![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| High Level Programming Post questions about C, C++, Java, SQL, and other programming languages here. |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| tracing in linux | shary | Shell Programming and Scripting | 2 | 02-04-2007 07:05 AM |
| tracing | shary | Linux | 1 | 02-04-2007 03:33 AM |
| Tracing the GPU usage | solea | SUN Solaris | 0 | 07-31-2005 11:40 PM |
| [FreeBSD] ptrace( ) - Device busy | Driver | High Level Programming | 5 | 01-31-2003 07:34 AM |
| Tracing a terminal | alex blanco | UNIX for Advanced & Expert Users | 2 | 04-08-2002 03:24 PM |
|
|
Submit Tools | LinkBack | Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
Tracing self process using ptrace()
Kindly correct me if any of the foll is wrong:
I want to trace the current process from the C program itself which I think can be done using ptrace(PTRACE_ATTACH,getpid(),0,0); I would like to get control back after a segmentation fault, or arithmetric exception (i.e. all signals that end in a core dump). If I do something like this, it doesn't work : Code:
int status;
//other code
....
....
ptrace(PTRACE_ATTACH,getpid(),0,0);
int a=99,b=0,c;
c = a/b;
wait(&status);
if(WIFSIGNALED(status)) printf("Got control after exception");
Thank you, in advance. Last edited by vpraveen84; 06-02-2008 at 11:50 AM. |
| Forum Sponsor | ||
|
|
|
#2
|
|||
|
|||
|
A couple problems with this.
1. It can't be done if you service the segmentation violation properly as a fatal error. 2.If invalid memory has been accessed and overwritten causing the kernel to send sigsegv the program is in an unstable state and should exit. Further operations are no longer trustworthy as many critical memory locations may have been altered. |
|||
| Google The UNIX and Linux Forums |