This is the mail archive of the systemtap@sourceware.org mailing list for the systemtap project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Queries on SystemTap - with focus on User Space debugging


Hi,
There was a typo error in the C code which i had posted in the
previous thread. I had missed out including the statement which causes
segmentation fault.
Below given is the corrected code.


 #include <stdlib.h>
 void segfault()
 {
 char* p = NULL;
   char ch = *p;
 }

 void myfunc()
 {
 segfault();
 }


 int main()
 {
 myfunc();
 return 0;
 }

On Mon, May 23, 2011 at 1:08 PM, Manjusha Ajay <manjusha.ajay@gmail.com> wrote:
> Hi Adrien,
> I tried using print_ubacktrace() in my test program, did not get the
> expected result.
>
> The systemtap script which I tried is as given below:
>
> probe process("test_segfault").syscall
> ?{
> ???????? pid = pid()
> ???????? if (pid == target())
> ???????? {
> ???????????????? if ($syscall == 11)
> ???????????????? {
> ???????????????? // ?Trying to stop the process to collect the
> required data when it receives?SIGSEGV
>
> ???????????????? stop_cmd = sprintf("kill -s STOP %d", pid)
> ???????????????? system(stop_cmd)
>
> ???????????????? print_ubacktrace()
>
> ???????????????? // Resume the process
>
> ???????????????? cont_cmd = sprintf ("kill -s CONT %d", pid)
> ???????????????? system(cont_cmd)
> ????????????????}
> ????????}
> ?}
>
>
> Output:
> 0x000000333be14037 ?// output of print_ubacktrace()
> sh: line 0: kill: (6343) - No such process
> sh: line 0: kill: (6343) - No such process
>
>
> Following is the test program which i wanted to monitor:
>
> #include <stdlib.h>
>
> void segfault()
> {
> char* p = NULL;
> }
>
> void myfunc()
> {
> segfault();
> }
>
>
> int main()
> {
> myfunc();
> return 0;
> }
>
>> gcc test.c -g? -o test_segfault
>
> What I expected was a traceback which points to the subroutine which
> results in a segmentation fault, including the chain of function calls
> leading to it - a stack trace similar to the out put of gdb?( my
> kernel supports Utrace ) .
>
> Also I ?wanted to invoke some bash commands other than pstack from a
> systemtap session. But as mentioned in my previous email, the bash
> commands invoked from within the systemtap session did not work as
> expected for me.
> It would be great if you could help me out with this and point out
> mistakes in my code if any.
>
> Thank You,
> Manjusha.
>
> From: Adrien Kunysz <adrien@kunysz.be>
> Date: Sun, May 22, 2011 at 5:00 AM
> Subject: Re: Queries on SystemTap - with focus on User Space debugging
> To: Manjusha Ajay <manjusha.ajay@gmail.com>
> Cc: "systemtap@sourceware.org" <systemtap@sourceware.org>
>
>
> On Sat, May 21, 2011 at 08:27:59PM +0530, Manjusha Ajay wrote:
>> - Can 'pstack' or any such tracing/profiling commands be invoked within a
>> SystemTap session which collects the corresponding user space data when
>> the process hits a particular probe.
>
> For this specific case you are probably better off using the
> print_ubacktrace() function.
>
>> For example, I tried the following script to collect stack trace of a
>> particular process.
>>
>> probe process("process_name").syscall
>> {
>> ? ? ? ? pid = pid()
>> ? ? ? ? if (pid == target())
>> ? ? ? ? {
>> ? ? ? ? ? ? ? ? if ($syscall == 11)
>> ? ? ? ? ? ? ? ? {
>> ? ? ? ? ? ? ? ? stop_cmd = sprintf("kill -s STOP %d", pid)
>> ? ? ? ? ? ? ? ? system(stop_cmd) ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? //
>> Trying to stop the process to collect the required data when it receives
>> SIGSEGV
>>
>> ? ? ? ? ? ? ? ? ? ? ? ? cms = sprintf("pstack %d", pid())
>> ? ? ? ? ? ? ? ? ? ? ? ? system(cmd)
>> ? ? ? ? ? ? ? ? ? ? ? ? }
>> ? ? ? ? ? ? ? ? ? ? ? ? cont_cmd = sprintf ("kill -s CONT %d", pid)
>> ? ? ? ? ? ? ? ? system(cont_cmd)
>> ? ? ? ? ? ? ?}
>> }
>>
>> Output:
>> Process 6343 not found ?// output of pstack
>> sh: line 0: kill: (6343) - No such process
>> sh: line 0: kill: (6343) - No such process
>>
>> Here bash commands executed through 'system' tapset are invoked after the
>> process is dead.
>>
>> My intent to get the userspace backtrace of any process which exits with a
>> segmentation fault. ?Is such a generic tracing method available in
>> systemtap?
>> Iam using Linux Red Hat release 5.4 ?and please comment on the backward
>> compatibility of the tool with Red Hat release 4.7.
>
> IIRC RHEL 4 doesn't have userland tracing. You can still put probes on
> system calls with "syscall.whatever" but I don't think you'll have
> ubacktrace().
>
> I can't comment properly on DTrace as I have no experience with it but
> from my understanding it's functionnaly equivalent to SystemTap
> although the internals are significantly different.
>


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]