[Techtalk] Re: [Techtalk]File Found ! Was:Icons for GNOME Applets Subsection

Val Henson val at nmt.edu
Fri Aug 9 16:55:08 EST 2002

On Fri, Aug 09, 2002 at 11:05:14AM +0800, Sujita Purushothaman wrote:
> Hi everyone,
>        I found the file I was looking for, it's the .directory file in
> the
> /usr/share/applets/My-Applet.
> I downloaded gnome-core and used gdb to run the GNOME Menu Editor
> and when I reached the function that ran when the save button was
> clicked, I printed out what I thought was relevant variables and
> found this file path. :-) Yay!

Spiffy!  I've never been able to get any useful information out of gdb
- I think my brain is just broken that way. :)

This reminded me of another one of my favorite tricks: strace.
"strace <program>" will print out all the system calls (with
arguments) that the program makes.  I usually use strace to find out
why a program is failing.  Usually the answer is some missing file or
something easily found by reading the output of strace.  For a very
silly example, here's an strace of the system calls of an attempt to
remove a non-existent file:

val at boardwalk<~>$ strace rm non-existent_file

[ lots and LOTS of output snipped]

lstat64(0xbffffc47, 0xbffff9cc)         = -1 ENOSYS (Function not implemented)
lstat("non-existent_file", 0xbffff94c)  = -1 ENOENT (No such file or directory)
write(2, "rm: ", 4rm: )                     = 4
write(2, "cannot remove `non-existent_file"..., 33cannot remove `non-existent_file') = 33
write(2, ": No such file or directory", 27: No such file or directory) = 27
write(2, "\n", 1
)                       = 1
_exit(1)                                = ?
val at boardwalk<~>$

Notice that lstat() returns "ENOENT (No such file or directory"?  Hey,
do you think that could be causing rm to fail? :) rm prints out the
error, but many programs just exit with any indication of why they

One annoying thing about strace is that you see all output twice -
look at this line:

write(2, "rm: ", 4rm: )                     = 4

The parts with "-" underneath them are strace's output, the parts with
"^" underneath them are the output of the actual write() call that
printed "rm: " to stderr.

Interesting, notice that "rm" is largefile aware?  It attempts to do
an lstat64() before it tries the lstat() call.  "man strace" will tell
you more fun stuff you can do with strace.


More information about the Techtalk mailing list