As shown in RED, are the steps needed to analyze the bootup activities of Linux Kernel surrounding sys_socket() APIs.

(but systemtap is but better, next post - esp for a RUNNING native OS).

(gdb) break sys_socket
Breakpoint 1 at 0x8145132: file /hdc1/download/2.6/linux-2.6-
latest/net/socket.c, line 1219.
(gdb) run ubda=/hdc2/download1/qimage/root_fs_val mem=128M
Starting program: /hdc1/download/2.6/linux-2.6-latest/uml/linux ubda=/hdc2/download1/qimage/root_fs_val mem=128M
Locating the bottom of the address space ... 0x0
Locating the top of the address space ... 0xc0000000
Core dump limits :
       soft - NONE
       hard - NONE
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...nothing mounted on /dev/shm
Checking PROT_EXEC mmap in /tmp/...OK
Checking for the skas3 patch in the host:
 - /proc/mm...not found: No such file or directory
 - PTRACE_FAULTINFO...not found
 - PTRACE_LDT...not found
UML running in SKAS0 mode
Linux version 2.6.28-rc3-00054-g75fa677 ([EMAIL PROTECTED]) (gcc version 4.1.2 20061115 (prerelease) (SUSE Linux)) #1 Thu Nov 6 22:57:34 SGT 2008
Built 1 zonelists in Zone order, mobility grouping on.  Total pages: 32512
Kernel command line: ubda=/hdc2/download1/qimage/root_fs_val mem=128M root=98:0
PID hash table entries: 512 (order: 9, 2048 bytes)
Dentry cache hash table entries: 16384 (order: 4, 65536 bytes)
Inode-cache hash table entries: 8192 (order: 3, 32768 bytes)
Memory: 126732k available
Calibrating delay loop... 2627.99 BogoMIPS (lpj=13139968)
Mount-cache hash table entries: 512
Checking for host processor cmov support...Yes
Checking that host ptys support output SIGIO...Yes
Checking that host ptys support SIGIO on close...No, enabling workaround
net_namespace: 288 bytes
Using 2.6 host AIO
NET: Registered protocol family 16
NET: Registered protocol family 2
IP route cache hash table entries: 1024 (order: 0, 4096 bytes)
TCP established hash table entries: 4096 (order: 3, 32768 bytes)
TCP bind hash table entries: 4096 (order: 2, 16384 bytes)
TCP: Hash tables configured (established 4096 bind 4096)
TCP reno registered
NET: Registered protocol family 1
Checking host MADV_REMOVE support...<3>MADV_REMOVE failed, err = -38
Can't release memory to the host - memory hotplug won't be supported
mconsole (version 2) initialized on /root/.uml/7uDazb/mconsole
Host TLS support detected
Detected host type: i386 (GDT indexes 6 to 9)
VFS: Disk quotas dquot_6.5.1
Dquot-cache hash table entries: 1024 (order 0, 4096 bytes)
msgmni has been set to 247
io scheduler noop registered
io scheduler anticipatory registered (default)
io scheduler deadline registered
io scheduler cfq registered
TCP cubic registered
NET: Registered protocol family 17
Initialized stdio console driver
Console initialized on /dev/tty0
console [tty0] enabled
Initializing software serial port version 1
console [mc-1] enabled
ubda: unknown partition table
VFS: Mounted root (ext2 filesystem) readonly.
INIT: version 2.84 booting

Breakpoint 1, sys_socket (family=1, type=1, protocol=0) at /hdc1/download/2.6/linux-2.6-latest/net/socket.c:1219
1219    {
(gdb) bt
#0  sys_socket (family=1, type=1, protocol=0) at /hdc1/download/2.6/linux-2.6-latest/net/socket.c:1219
#1  0x081451d8 in sys_socketcall (call=1, args=0xbff3ae24) at /hdc1/download/2.6/linux-2.6-latest/net/socket.c:2134
#2  0x08059b30 in handle_syscall (r=0xf9ace2c) at /hdc1/download/2.6/linux-2.6-latest/arch/um/kernel/skas/syscall.c:35
#3  0x080674a7 in userspace (regs=0xf9ace2c) at /hdc1/download/2.6/linux-2.6-latest/arch/um/os-Linux/skas/process.c:201
#4  0x08057696 in fork_handler () at /hdc1/download/2.6/linux-2.6-latest/arch/um/kernel/process.c:179
#5  0x00000000 in ?? ()
(gdb) cont
Continuing.
/etc/rc.d/rc.S: Testing filesystem status: Read-only file system
Checking root filesystem:
fsck 1.27 (8-Mar-2002)

Breakpoint 1, sys_socket (family=1, type=1, protocol=0) at /hdc1/download/2.6/linux-2.6-latest/net/socket.c:1219
1219    {
(gdb) bt
#0  sys_socket (family=1, type=1, protocol=0) at /hdc1/download/2.6/linux-2.6-latest/net/socket.c:1219
#1  0x081451d8 in sys_socketcall (call=1, args=0xbfc83684) at /hdc1/download/2.6/linux-2.6-latest/net/socket.c:2134
#2  0x08059b30 in handle_syscall (r=0xf9a1a2c) at /hdc1/download/2.6/linux-2.6-latest/arch/um/kernel/skas/syscall.c:35
#3  0x080674a7 in userspace (regs=0xf9a1a2c) at /hdc1/download/2.6/linux-2.6-latest/arch/um/os-Linux/skas/process.c:201
#4  0x08057696 in fork_handler () at /hdc1/download/2.6/linux-2.6-latest/arch/um/kernel/process.c:179
#5  0x00000000 in ?? ()
(gdb) cont
Continuing.
/dev/ubd/0: clean, 14573/51584 files, 50296/205824 blocks
Remounting root device with read-write enabled.
/dev/ubd/0 on / type ext2 (rw)
Checking non-root filesystems:
fsck 1.27 (8-Mar-2002)
none on /dev/pts type devpts (rw,gid=5,mode=620)
none on /proc type proc (rw)
Using /etc/random-seed to initialize /dev/urandom.

Breakpoint 1, sys_socket (family=1, type=2, protocol=0) at /hdc1/download/2.6/linux-2.6-latest/net/socket.c:1219
1219    {
(gdb) bt
#0  sys_socket (family=1, type=2, protocol=0) at /hdc1/download/2.6/linux-2.6-latest/net/socket.c:1219
#1  0x081451d8 in sys_socketcall (call=1, args=0xbfff8184) at /hdc1/download/2.6/linux-2.6-latest/net/socket.c:2134
#2  0x08059b30 in handle_syscall (r=0xf85ae2c) at /hdc1/download/2.6/linux-2.6-latest/arch/um/kernel/skas/syscall.c:35
#3  0x080674a7 in userspace (regs=0xf85ae2c) at /hdc1/download/2.6/linux-2.6-latest/arch/um/os-Linux/skas/process.c:201
#4  0x08057637 in new_thread_handler () at /hdc1/download/2.6/linux-2.6-latest/arch/um/kernel/process.c:155
#5  0x00000000 in ?? ()
(gdb) cont
Continuing.
INIT: Entering runlevel: 3

Breakpoint 1, sys_socket (family=1, type=1, protocol=0) at /hdc1/download/2.6/linux-2.6-latest/net/socket.c:1219
1219    {
(gdb) bt
#0  sys_socket (family=1, type=1, protocol=0) at /hdc1/download/2.6/linux-2.6-latest/net/socket.c:1219
#1  0x081451d8 in sys_socketcall (call=1, args=0xbff9b9d4) at /hdc1/download/2.6/linux-2.6-latest/net/socket.c:2134
#2  0x08059b30 in handle_syscall (r=0xf995e2c) at /hdc1/download/2.6/linux-2.6-latest/arch/um/kernel/skas/syscall.c:35
#3  0x080674a7 in userspace (regs=0xf995e2c) at /hdc1/download/2.6/linux-2.6-latest/arch/um/os-Linux/skas/process.c:201
#4  0x08057696 in fork_handler () at /hdc1/download/2.6/linux-2.6-latest/arch/um/kernel/process.c:179
#5  0x00000000 in ?? ()
(gdb) cont
Continuing.
Going multiuser...
[9;15]
Breakpoint 1, sys_socket (family=1, type=2, protocol=0) at /hdc1/download/2.6/linux-2.6-latest/net/socket.c:1219
1219    {
(gdb) bt
#0  sys_socket (family=1, type=2, protocol=0) at /hdc1/download/2.6/linux-2.6-latest/net/socket.c:1219
#1  0x081451d8 in sys_socketcall (call=1, args=0xbfbe9024) at /hdc1/download/2.6/linux-2.6-latest/net/socket.c:2134
#2  0x08059b30 in handle_syscall (r=0xf9a162c) at /hdc1/download/2.6/linux-2.6-latest/arch/um/kernel/skas/syscall.c:35
#3  0x080674a7 in userspace (regs=0xf9a162c) at /hdc1/download/2.6/linux-2.6-latest/arch/um/os-Linux/skas/process.c:201
#4  0x08057696 in fork_handler () at /hdc1/download/2.6/linux-2.6-latest/arch/um/kernel/process.c:179
#5  0x002f0000 in ?? ()
(gdb) cont
Continuing.

Breakpoint 1, sys_socket (family=2, type=2, protocol=0) at /hdc1/download/2.6/linux-2.6-latest/net/socket.c:1219
1219    {
(gdb) cont
Continuing.

Breakpoint 1, sys_socket (family=2, type=2, protocol=0) at /hdc1/download/2.6/linux-2.6-latest/net/socket.c:1219
1219    {
(gdb) bt
#0  sys_socket (family=2, type=2, protocol=0) at /hdc1/download/2.6/linux-2.6-latest/net/socket.c:1219
#1  0x081451d8 in sys_socketcall (call=1, args=0xbf968b04) at /hdc1/download/2.6/linux-2.6-latest/net/socket.c:2134
#2  0x08059b30 in handle_syscall (r=0xf99522c) at /hdc1/download/2.6/linux-2.6-latest/arch/um/kernel/skas/syscall.c:35
#3  0x080674a7 in userspace (regs=0xf99522c) at /hdc1/download/2.6/linux-2.6-latest/arch/um/os-Linux/skas/process.c:201
#4  0x08057696 in fork_handler () at /hdc1/download/2.6/linux-2.6-latest/arch/um/kernel/process.c:179
#5  0x00000000 in ?? ()
(gdb) cont
Continuing.
Mounting remote (NFS) file systems:  /sbin/mount -a -t nfs
Mounting remote (SMB) file systems:  /sbin/mount -a -t smbfs
Starting sysklogd daemons:   /usr/sbin/syslogd
Breakpoint 1, sys_socket (family=1, type=1, protocol=0) at /hdc1/download/2.6/linux-2.6-latest/net/socket.c:1219
1219    {
(gdb) bt
#0  sys_socket (family=1, type=1, protocol=0) at /hdc1/download/2.6/linux-2.6-latest/net/socket.c:1219
#1  0x081451d8 in sys_socketcall (call=1, args=0xbff62664) at /hdc1/download/2.6/linux-2.6-latest/net/socket.c:2134
#2  0x08059b30 in handle_syscall (r=0xf990a2c) at /hdc1/download/2.6/linux-2.6-latest/arch/um/kernel/skas/syscall.c:35
#3  0x080674a7 in userspace (regs=0xf990a2c) at /hdc1/download/2.6/linux-2.6-latest/arch/um/os-Linux/skas/process.c:201
#4  0x08057696 in fork_handler () at /hdc1/download/2.6/linux-2.6-latest/arch/um/kernel/process.c:179
#5  0x00000000 in ?? ()
(gdb) cont
Continuing.

Breakpoint 1, sys_socket (family=1, type=2, protocol=0) at /hdc1/download/2.6/linux-2.6-latest/net/socket.c:1219
1219    {
(gdb) bt
#0  sys_socket (family=1, type=2, protocol=0) at /hdc1/download/2.6/linux-2.6-latest/net/socket.c:1219
#1  0x081451d8 in sys_socketcall (call=1, args=0xbff60314) at /hdc1/download/2.6/linux-2.6-latest/net/socket.c:2134
#2  0x08059b30 in handle_syscall (r=0xf990a2c) at /hdc1/download/2.6/linux-2.6-latest/arch/um/kernel/skas/syscall.c:35
#3  0x080674a7 in userspace (regs=0xf990a2c) at /hdc1/download/2.6/linux-2.6-latest/arch/um/os-Linux/skas/process.c:201
#4  0x08057696 in fork_handler () at /hdc1/download/2.6/linux-2.6-latest/arch/um/kernel/process.c:179
#5  0x00000000 in ?? ()
(gdb) cont
Continuing.
/usr/sbin/klogd -c 3 -x

Breakpoint 1, sys_socket (family=1, type=2, protocol=0) at /hdc1/download/2.6/linux-2.6-latest/net/socket.c:1219
1219    {
(gdb) bt
#0  sys_socket (family=1, type=2, protocol=0) at /hdc1/download/2.6/linux-2.6-latest/net/socket.c:1219
#1  0x081451d8 in sys_socketcall (call=1, args=0xbf9969f4) at /hdc1/download/2.6/linux-2.6-latest/net/socket.c:2134
#2  0x08059b30 in handle_syscall (r=0xf99022c) at /hdc1/download/2.6/linux-2.6-latest/arch/um/kernel/skas/syscall.c:35
#3  0x080674a7 in userspace (regs=0xf99022c) at /hdc1/download/2.6/linux-2.6-latest/arch/um/os-Linux/skas/process.c:201
#4  0x08057696 in fork_handler () at /hdc1/download/2.6/linux-2.6-latest/arch/um/kernel/process.c:179
#5  0x00000000 in ?? ()
(gdb) cont
Continuing.
Activating IPv4 packet forwarding.
Starting Internet super-server daemon:  /usr/sbin/inetd===============>notice the starting of daemon etc...

and entering "cont" a few times:

(gdb)
Continuing.


Welcome to Linux 2.6.28-rc3-00054-g75fa677 (tty0)

darkstar login: root

Breakpoint 1, sys_socket (family=1, type=1, protocol=0) at /hdc1/download/2.6/linux-2.6-latest/net/socket.c:1219
1219    {
(gdb) cont
Continuing.

Breakpoint 1, sys_socket (family=1, type=1, protocol=0) at /hdc1/download/2.6/linux-2.6-latest/net/socket.c:1219
1219    {
(gdb)
Continuing.
Linux 2.6.28-rc3-00054-g75fa677.
Last login: Thu Nov 13 05:13:04 +0000 2008 on tty0.
You have mail.

Breakpoint 1, sys_socket (family=1, type=2, protocol=0) at /hdc1/download/2.6/linux-2.6-latest/net/socket.c:1219
1219    {
(gdb)
Continuing.

Breakpoint 1, sys_socket (family=1, type=1, protocol=0) at /hdc1/download/2.6/linux-2.6-latest/net/socket.c:1219
1219    {
(gdb)
Continuing.
[EMAIL PROTECTED]:~# df
Filesystem           1k-blocks      Used Available Use% Mounted on
/dev/ubd/0              199309     43793    145225  24% /
[EMAIL PROTECTED]:~# ping www.yahoo.com======>enter ping at command line.

And below onwards trace the path the kernel takes for processing the above command:

Breakpoint 1, sys_socket (family=2, type=3, protocol=1) at /hdc1/download/2.6/linux-2.6-latest/net/socket.c:1219
1219    {
(gdb) bt
#0  sys_socket (family=2, type=3, protocol=1) at /hdc1/download/2.6/linux-2.6-latest/net/socket.c:1219
#1  0x081451d8 in sys_socketcall (call=1, args=0xbf9623e4) at /hdc1/download/2.6/linux-2.6-latest/net/socket.c:2134
#2  0x08059b30 in handle_syscall (r=0xf990e2c) at /hdc1/download/2.6/linux-2.6-latest/arch/um/kernel/skas/syscall.c:35
#3  0x080674a7 in userspace (regs=0xf990e2c) at /hdc1/download/2.6/linux-2.6-latest/arch/um/os-Linux/skas/process.c:201
#4  0x08057696 in fork_handler () at /hdc1/download/2.6/linux-2.6-latest/arch/um/kernel/process.c:179
#5  0x00000000 in ?? ()
(gdb) cont
Continuing.

Breakpoint 1, sys_socket (family=1, type=1, protocol=0) at /hdc1/download/2.6/linux-2.6-latest/net/socket.c:1219
1219    {
(gdb) bt
#0  sys_socket (family=1, type=1, protocol=0) at /hdc1/download/2.6/linux-2.6-latest/net/socket.c:1219
#1  0x081451d8 in sys_socketcall (call=1, args=0xbf9621d4) at /hdc1/download/2.6/linux-2.6-latest/net/socket.c:2134
#2  0x08059b30 in handle_syscall (r=0xf990e2c) at /hdc1/download/2.6/linux-2.6-latest/arch/um/kernel/skas/syscall.c:35
#3  0x080674a7 in userspace (regs=0xf990e2c) at /hdc1/download/2.6/linux-2.6-latest/arch/um/os-Linux/skas/process.c:201
#4  0x08057696 in fork_handler () at /hdc1/download/2.6/linux-2.6-latest/arch/um/kernel/process.c:179
#5  0x00000000 in ?? ()
(gdb) cont
Continuing.

Breakpoint 1, sys_socket (family=2, type=2, protocol=0) at /hdc1/download/2.6/linux-2.6-latest/net/socket.c:1219
1219    {
(gdb) bt
#0  sys_socket (family=2, type=2, protocol=0) at /hdc1/download/2.6/linux-2.6-latest/net/socket.c:1219
#1  0x081451d8 in sys_socketcall (call=1, args=0xbf960c54) at /hdc1/download/2.6/linux-2.6-latest/net/socket.c:2134
#2  0x08059b30 in handle_syscall (r=0xf990e2c) at /hdc1/download/2.6/linux-2.6-latest/arch/um/kernel/skas/syscall.c:35
#3  0x080674a7 in userspace (regs=0xf990e2c) at /hdc1/download/2.6/linux-2.6-latest/arch/um/os-Linux/skas/process.c:201
#4  0x08057696 in fork_handler () at /hdc1/download/2.6/linux-2.6-latest/arch/um/kernel/process.c:179
#5  0x00000000 in ?? ()
(gdb) cont
Continuing.

Breakpoint 1, sys_socket (family=2, type=2, protocol=0) at /hdc1/download/2.6/linux-2.6-latest/net/socket.c:1219
1219    {
(gdb) bt
#0  sys_socket (family=2, type=2, protocol=0) at /hdc1/download/2.6/linux-2.6-latest/net/socket.c:1219
#1  0x081451d8 in sys_socketcall (call=1, args=0xbf960c54) at /hdc1/download/2.6/linux-2.6-latest/net/socket.c:2134
#2  0x08059b30 in handle_syscall (r=0xf990e2c) at /hdc1/download/2.6/linux-2.6-latest/arch/um/kernel/skas/syscall.c:35
#3  0x080674a7 in userspace (regs=0xf990e2c) at /hdc1/download/2.6/linux-2.6-latest/arch/um/os-Linux/skas/process.c:201
#4  0x08057696 in fork_handler () at /hdc1/download/2.6/linux-2.6-latest/arch/um/kernel/process.c:179
#5  0x00000000 in ?? ()
(gdb) cont
Continuing.

Breakpoint 1, sys_socket (family=2, type=2, protocol=0) at /hdc1/download/2.6/linux-2.6-latest/net/socket.c:1219
1219    {
(gdb) bt
#0  sys_socket (family=2, type=2, protocol=0) at /hdc1/download/2.6/linux-2.6-latest/net/socket.c:1219
#1  0x081451d8 in sys_socketcall (call=1, args=0xbf960c54) at /hdc1/download/2.6/linux-2.6-latest/net/socket.c:2134
#2  0x08059b30 in handle_syscall (r=0xf990e2c) at /hdc1/download/2.6/linux-2.6-latest/arch/um/kernel/skas/syscall.c:35
#3  0x080674a7 in userspace (regs=0xf990e2c) at /hdc1/download/2.6/linux-2.6-latest/arch/um/os-Linux/skas/process.c:201
#4  0x08057696 in fork_handler () at /hdc1/download/2.6/linux-2.6-latest/arch/um/kernel/process.c:179
#5  0x00000000 in ?? ()
(gdb) cont
Continuing.

Breakpoint 1, sys_socket (family=2, type=2, protocol=0) at /hdc1/download/2.6/linux-2.6-latest/net/socket.c:1219
1219    {
(gdb) bt
#0  sys_socket (family=2, type=2, protocol=0) at /hdc1/download/2.6/linux-2.6-latest/net/socket.c:1219
#1  0x081451d8 in sys_socketcall (call=1, args=0xbf960c54) at /hdc1/download/2.6/linux-2.6-latest/net/socket.c:2134
#2  0x08059b30 in handle_syscall (r=0xf990e2c) at /hdc1/download/2.6/linux-2.6-latest/arch/um/kernel/skas/syscall.c:35
#3  0x080674a7 in userspace (regs=0xf990e2c) at /hdc1/download/2.6/linux-2.6-latest/arch/um/os-Linux/skas/process.c:201
#4  0x08057696 in fork_handler () at /hdc1/download/2.6/linux-2.6-latest/arch/um/kernel/process.c:179
#5  0x00000000 in ?? ()
(gdb) cont
Continuing.
ping: unknown host www.yahoo.com
[EMAIL PROTECTED]:~#

From the stack trace, you can trace through the caller and path of processing on the kernel side.

Have fun!!!!!



--
Regards,
Peter Teoh

Reply via email to