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: please help


On Sat, Oct 11, 2008 at 10:12 PM, siddharam suresh
<siddharam.s.t@gmail.com> wrote:
> i want visualize what all the stuffs happening inside the Linux kernel
> when this program is executed
>
>
> #include<stdio.h>
> void main()
> {
> printf("Test kernel");  <-- here i want know what are all the system
> calls and the kernel data structure kernel is used by the kernel. Is
> it possible to put break points here and can we see what are the
> things happening inside the kernel when printf is executed
>
> }
>
>
> is it possible to put break points in side the my program using the
> system tap i want to visualize what are system calls and kernel data
> structure used by particular statement.
>

How about trying UML?

http://user-mode-linux.sourceforge.net/hacking.html

After you have "b start_kernel", if u enter "n" all the way, basically
u will see all the functions (or sub-functions) called.

For example, mine it gives:

(gdb) b start_kernel
Breakpoint 1 at 0x80493c8: file
/sda2/linux-source-2.6.20-2.6.20/init/main.c, line 490.
(gdb) cont
The program is not being run.
(gdb) run
Starting program: /sda2/linux-source-2.6.20-2.6.20/uml/vmlinux
Checking that ptrace can change system call numbers...OK
Checking syscall emulation patch for ptrace...OK
Checking advanced syscall emulation patch for ptrace...OK
Checking for tmpfs mount on /dev/shm...OK
Checking PROT_EXEC mmap in /dev/shm/...OK
Checking for the skas3 patch in the host:
  - /proc/mm...not found
  - PTRACE_FAULTINFO...not found
  - PTRACE_LDT...not found
UML running in SKAS0 mode

Breakpoint 1, start_kernel () at
/sda2/linux-source-2.6.20-2.6.20/init/main.c:490
490             smp_setup_processor_id();
(gdb) n
499             local_irq_disable();
(gdb)
38              __asm__ __volatile__( LOCK_PREFIX
(gdb)
510             printk(KERN_NOTICE);
(gdb)
511             printk(linux_banner);
(gdb)
512             setup_arch(&command_line);
(gdb)
522             sched_init();
(gdb)
528             build_all_zonelists();
(gdb)
529             page_alloc_init();
(gdb)
530             printk(KERN_NOTICE "Kernel command line: %s\n",
saved_command_line);
(gdb)

531             parse_early_param();
(gdb)
532             parse_args("Booting kernel", command_line, __start___param,
(gdb)
535             if (!irqs_disabled()) {
(gdb)
540             sort_main_extable();
(gdb)
541             trap_init();

(gdb)
542             rcu_init();
(gdb)
543             init_IRQ();
(gdb)
544             pidhash_init();
(gdb)
545             init_timers();
(gdb)
546             hrtimers_init();
(gdb)
547             softirq_init();
(gdb)
548             timekeeping_init();
(gdb)
549             time_init();
(gdb)
550             profile_init();
(gdb)
551             if (!irqs_disabled())
(gdb)
554             local_irq_enable();
(gdb)
561             console_init();
(gdb)
562             if (panic_later)
(gdb)
582             vfs_caches_init_early();
(gdb)
584             mem_init();
(gdb)
start_idle_thread (stack=0x81dc000, switch_buf=0x81e147c) at
/sda2/linux-source-2.6.20-2.6.20/arch/um/os-Linux/skas/process.c:481
481             switch(n){
(gdb)
489                     (*cb_proc)(cb_arg);
(gdb)
490                     UML_LONGJMP(cb_back, 1);
(gdb)
initial_thread_cb_skas (proc=0x805739b <map_cb>, arg=0x0) at
/sda2/linux-source-2.6.20-2.6.20/arch/um/os-Linux/skas/process.c:515
515             unblock_signals();
(gdb)
520     }
(gdb)
517             cb_proc = NULL;
(gdb)
518             cb_arg = NULL;
(gdb)
519             cb_back = NULL;
(gdb)
520     }
(gdb)
initial_thread_cb (proc=0x805739b <map_cb>, arg=0x0) at
/sda2/linux-source-2.6.20-2.6.20/arch/um/kernel/process.c:188
188             kmalloc_ok = save_kmalloc_ok;
(gdb)
189     }
(gdb)
188             kmalloc_ok = save_kmalloc_ok;
(gdb)
189     }
(gdb)
mem_init () at /sda2/linux-source-2.6.20-2.6.20/arch/um/kernel/mem.c:77
77              free_bootmem(__pa(brk_end), uml_reserved - brk_end);


If u want u can zoom down to the specific functions and put a break
point there instead, and then print out any of the data u need, if the
symbols can be recognized in your vmlinux file (use the tab key in
gdb).

> as above stated test.c program i what see what is happening inside the
> kernel when printf("Test Kernel"); is executed .This because when the
> my program become large it will show so many information which may not
> be use full to me and very difficult to get the particular
> information.Is there any facilities like step in and step out in
> system tap
>
>
>
> thank you in advance
> waiting great response
>



-- 
Regards,
Peter Teoh


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