Welcome to Scribd, the world's digital library. Read, publish, and share books and documents. See more
Download
Standard view
Full view
of .
Look up keyword
Like this
1Activity
0 of .
Results for:
No results containing your search query
P. 1
Unix Debugging

Unix Debugging

Ratings: (0)|Views: 6|Likes:
Published by Kan15

More info:

Published by: Kan15 on Nov 19, 2010
Copyright:Attribution Non-commercial

Availability:

Read on Scribd mobile: iPhone, iPad and Android.
download as TXT, PDF, TXT or read online from Scribd
See more
See less

11/05/2013

pdf

text

original

 
C.1 System Call TracingMany versions of Unix provide a system call tracing facility. This can often provide a valuable debugging technique.Working at this level, we need to differentiate between a system call and a function. The former is an entry point into the kernel, and that is what we are ableto trace with the tools we will look at in this section. POSIX and most other standards use the term "function" to describe what appears to the user to be functions, even though on some implementations, they may be system calls. For example, on a Berkeley-derived kernel, socket is a system call even though it appearsto be a normal C function to the application programmer. But under SVR4, we willsee shortly that it is a library function in the sockets library that issues calls to putmsg and getmsg, these latter two being actual system calls.In this section, we will examine the system calls involved in running our daytime client. We showed this client in Figure 1.5.BSD Kernel SocketsWe start with FreeBSD, a Berkeley-derived kernel in which all the socket functions are system calls. The ktrace program is provided by FreeBSD to run a programand trace the system calls that are executed. This writes the trace informationto a file (whose default name is ktrace.out), which we print with kdump. We execute our sockets client asfreebsd % ktrace daytimetcpcli 192.168.42.2Tue Aug 19 23:35:10 2003We then execute kdump to output the trace information to standard output.3211 daytimetcpcli CALL socket(0x2,0x1,0)3211 daytimetcpcli RET socket 33211 daytimetcpcli CALL connect(0x3,0x7fdffffe820,0x10)3211 daytimetcpcli RET connect 03211 daytimetcpcli CALL read(0x3,0x7fdffffe830,0x1000)3211 daytimetcpcli GIO fd 3 read 26 bytes"Tue Aug 19 23:35:10 2003"3211 daytimetcpcli RET read 26/0x1a...3211 daytimetcpcli CALL write(0x1,0x204000,0x1a)3211 daytimetcpcli GIO fd 1 wrote 26 bytes"Tue Aug 19 23:35:10 2003/r"3211 daytimetcpcli RET write 26/0x1a3211 daytimetcpcli CALL read(0x3,0x7fdffffe830,0x1000)3211 daytimetcpcli GIO fd 3 read 0 bytes""3211 daytimetcpcli RET read 03211 daytimetcpcli CALL exit(0)

You're Reading a Free Preview

Download
scribd
/*********** DO NOT ALTER ANYTHING BELOW THIS LINE ! ************/ var s_code=s.t();if(s_code)document.write(s_code)//-->