HP-UX HB v13.00 Ch-11 - Software Development

HP-UX Handbook Rev 13.00 Page 60 (of 101)
Chapter 11 Software Development
October 29, 2013
For example if core files should be stored in a separate file system that provides sufficient disk
space, and their names should contain program name and PID of the aborted process, the
following command can be used (as root):
# coreadm e global g /core files/core.%f.%p
tusc
While a debugger is helpful to analyze what happens inside a running program, it often is
interesting to see how a program interacts with the kernel. Every process does this via system
calls. System calls are necessary for reading and writing files, communicating with other
processes or over the network, allocating memory etc.
tusc is the tool to trace system calls on HP-UX. It is not installed with HP-UX, and it is not a
supported product. It can be obtained HP internally (including a manpage) from the KTOOLS
website [8] or from the HP-UX Archiving_&_porting center [10].
System calls are defined within the kernel sources. They are identical for all processes. That’s
why no source code or debug information of a program is required to trace its system calls.
In the execution example we have already traced the HelloWorld program. Similar to a
debugger, a program can either be run completely under tusc by specifying the program name,
or you can attach to an already running process by specifying the process ID:
tusc [ options ] program | PID
There are various options available to collect additional information like process and thread ID's,
timestamps, or to redirect output into a file rather than stdout, etc. To see all available
parameters, start tusc without any options.
tusc prints one line for each system call. The line contains at least the name, arguments and
return value of the system call. tusc tries to interpret the arguments as far as it knows about
them. To get info about what the system call does you could look up the manpage of the system
call name. Note that the manpages are not for the system calls but for libc functions which are
wrappers for the system calls with the same name. So the arguments and the return code of the
system call might not match the things described in the manpage. Fortunately, for most system
calls they do match.
open("/tmp/xyz", O_RDWR, 04344) ................ = 3
write(3, "H e l l o W o r l d ! \n", 13) ..... = 13