> It shouldn't be gigabytes -- you want to strace only special events like
> open and read, and you want to attach to the process only before running
> the script (run under -X) -- so you should have just a few lines!!!
>
> % strace -p PID -e trace=open,read
I was talking about ltrace, not strace, when I said it would take gigs.
And even then, I was wrong -- it was only about 50mb. (And that didn't
take into account specifiying which events to trace on.)
Anyhow... here are the results...
Test program: /web/ShadNet/sys/cvs/webdocs/foo.mp (no, it's
not the same as the one before... I tried an IO::Dir object
this time, but it makes an underlying call to Perl's 'opendir',
so it's equivalent to what I had before)
---------------------------------------------------------------
#!/usr/bin/perl -w
use strict;
use IO::Dir;
my $dir = new IO::Dir "/web/ShadNet/sys/cvs/webdocs";
print "Content-type: text/plain\n\n";
if ( defined($dir)) {
while (defined($_ = $dir->read)) {
print "[$_]\n";
}
}
undef $dir;
exit 0;
---------------------------------------------------------------
This works from the command line but not from Apache::Registry.
strace of seemingly-relevant bits via command line:
(this works)
---------------------------------------------------------------
munmap(0x40017000, 4096) = 0
rt_sigprocmask(SIG_BLOCK, NULL, [], 8) = 0
open("/dev/null", O_RDONLY|O_NONBLOCK|0x10000) = -1 ENOTDIR (Not a directory)
open("/web/ShadNet/sys/cvs/webdocs", O_RDONLY|O_NONBLOCK|0x10000) = 4
fstat(4, {st_mode=S_IFDIR|0755, st_size=1024, ...}) = 0
fcntl(4, F_SETFD, FD_CLOEXEC) = 0
brk(0x81ca000) = 0x81ca000
fstat(1, {st_mode=S_IFCHR|0620, st_rdev=makedev(136, 7), ...}) = 0
old_mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) =
0x40017000
ioctl(1, TCGETS, {B38400 opost isig icanon echo ...}) = 0
write(1, "Content-type: text/plain\n", 25) = 25
write(1, "\n", 1) = 1
getdents(4, /* 43 entries */, 3391) = 936
write(1, "[.]\n", 4) = 4
write(1, "[..]\n", 5) = 5
write(1, "[CVS]\n", 6) = 6
write(1, "[accountclaim]\n", 15) = 15
write(1, "[AppletTag.pm]\n", 15) = 15
write(1, "[admin-login.mp]\n", 17) = 17
write(1, "[bugs.mp]\n", 10) = 10
write(1, "[bugs.mp.save]\n", 15) = 15
write(1, "[finger.mp]\n", 12) = 12
write(1, "[index.mp]\n", 11) = 11
write(1, "[login.mp]\n", 11) = 11
write(1, "[logout.html]\n", 14) = 14
write(1, "[logout.mp]\n", 12) = 12
write(1, "[menu.mp]\n", 10) = 10
write(1, "[motd.mp]\n", 10) = 10
write(1, "[msie.mp]\n", 10) = 10
write(1, "[newshad.mp]\n", 13) = 13
write(1, "[nph-changegroup.mp]\n", 21) = 21
write(1, "[nph-changelanguage.mp]\n", 24) = 24
write(1, "[nph-validate.mp]\n", 18) = 18
write(1, "[other.mp]\n", 11) = 11
write(1, "[page.mp]\n", 10) = 10
write(1, "[parsechangelog.mp]\n", 20) = 20
write(1, "[poll.mp]\n", 10) = 10
write(1, "[shadfont.css]\n", 15) = 15
write(1, "[shadnet.css]\n", 14) = 14
write(1, "[shownews.mp]\n", 14) = 14
write(1, "[admin]\n", 8) = 8
write(1, "[alumni]\n", 9) = 9
write(1, "[common]\n", 9) = 9
write(1, "[developers]\n", 13) = 13
write(1, "[development]\n", 14) = 14
write(1, "[online]\n", 9) = 9
write(1, "[partner]\n", 10) = 10
write(1, "[password]\n", 11) = 11
write(1, "[polls]\n", 8) = 8
write(1, "[static]\n", 9) = 9
write(1, "[util]\n", 7) = 7
write(1, "[classes]\n", 10) = 10
write(1, "[test-opendir.mp]\n", 18) = 18
write(1, "[test-opendir.mp~]\n", 19) = 19
write(1, "[foo.mp]\n", 9) = 9
write(1, "[foo.mp~]\n", 10) = 10
getdents(4, /* 0 entries */, 3391) = 0
rt_sigprocmask(SIG_BLOCK, NULL, [], 8) = 0
close(4) = 0
rt_sigprocmask(SIG_BLOCK, NULL, [], 8) = 0
rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0
rt_sigprocmask(SIG_BLOCK, NULL, [], 8) = 0
rt_sigprocmask(SIG_BLOCK, NULL, [], 8) = 0
rt_sigprocmask(SIG_BLOCK, NULL, [], 8) = 0
rt_sigprocmask(SIG_BLOCK, NULL, [], 8) = 0
munmap(0x40017000, 4096) = 0
_exit(0) = ?
---------------------------------------------------------------
strace of seemingly-relevant bits via Apache::Registry
(this doesn't work)
---------------------------------------------------------------
munmap(0x40018000, 4096) = 0
open("/dev/null", O_RDONLY|O_NONBLOCK|0x10000) = -1 ENOTDIR (Not a directory)
open("/web/ShadNet/sys/cvs/webdocs", O_RDONLY|O_NONBLOCK|0x10000) = 5
fstat(5, {st_mode=S_IFDIR|0755, st_size=1024, ...}) = 0
fcntl(5, F_SETFD, FD_CLOEXEC) = 0
brk(0x858d000) = 0x858d000
alarm(300) = 0
alarm(0) = 300
getdents(5, /* 43 entries */, 2980) = 936
alarm(300) = 0
alarm(0) = 300
alarm(300) = 0
alarm(0) = 300
alarm(300) = 0
alarm(0) = 300
alarm(300) = 0
alarm(0) = 300
alarm(300) = 0
alarm(0) = 300
alarm(300) = 0
alarm(0) = 300
alarm(300) = 0
alarm(0) = 300
alarm(300) = 0
alarm(0) = 300
alarm(300) = 0
alarm(0) = 300
alarm(300) = 0
alarm(0) = 300
alarm(300) = 0
alarm(0) = 300
alarm(300) = 0
alarm(0) = 300
alarm(300) = 0
alarm(0) = 300
alarm(300) = 0
alarm(0) = 300
alarm(300) = 0
alarm(0) = 300
alarm(300) = 0
alarm(0) = 300
alarm(300) = 0
alarm(0) = 300
alarm(300) = 0
alarm(0) = 300
alarm(300) = 0
alarm(0) = 300
alarm(300) = 0
alarm(0) = 300
alarm(300) = 0
alarm(0) = 300
alarm(300) = 0
alarm(0) = 300
alarm(300) = 0
alarm(0) = 300
alarm(300) = 0
alarm(0) = 300
alarm(300) = 0
alarm(0) = 300
alarm(300) = 0
alarm(0) = 300
alarm(300) = 0
alarm(0) = 300
alarm(300) = 0
alarm(0) = 300
alarm(300) = 0
alarm(0) = 300
alarm(300) = 0
alarm(0) = 300
alarm(300) = 0
alarm(0) = 300
alarm(300) = 0
alarm(0) = 300
alarm(300) = 0
alarm(0) = 300
alarm(300) = 0
alarm(0) = 300
alarm(300) = 0
alarm(0) = 300
alarm(300) = 0
alarm(0) = 300
alarm(300) = 0
alarm(0) = 300
alarm(300) = 0
alarm(0) = 300
alarm(300) = 0
alarm(0) = 300
alarm(300) = 0
alarm(0) = 300
alarm(300) = 0
alarm(0) = 300
alarm(300) = 0
alarm(0) = 300
alarm(300) = 0
alarm(0) = 300
getdents(5, /* 0 entries */, 2980) = 0
rt_sigprocmask(SIG_BLOCK, NULL, [], 8) = 0
close(5) = 0
rt_sigprocmask(SIG_BLOCK, NULL, [], 8) = 0
write(4, "Content-type: text/plain\n\n[]\n[]\n"..., 155) = 155
rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0
chdir("/usr/local/apache/bin") = 0
time(NULL) = 976562276
open("/etc/localtime", O_RDONLY) = 5
fstat(5, {st_mode=S_IFREG|0644, st_size=1218, ...}) = 0
old_mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) =
0x40018000
read(5, "TZif\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\2\0\0\0\2\0"..., 4096) = 1218
close(5) = 0
munmap(0x40018000, 4096) = 0
write(18, "127.0.0.1 - - [11/Dec/2000:14:17"..., 72) = 72
alarm(30) = 0
shutdown(4, 1 /* send */) = 0
select(5, [4], NULL, NULL, {2, 0}) = 1 (in [4], left {1, 960000})
read(4, "", 512) = 0
close(4) = 0
alarm(0) = 30
rt_sigaction(SIGUSR1, {0x80ac6e4, [], SA_INTERRUPT|0x4000000}, {SIG_IGN}, 8) = 0
alarm(0) = 0
rt_sigaction(SIGALRM, {0x80ab344, [], SA_RESTART|0x4000000}, {0x80ab344, [],
SA_INTERRUPT|0x4000000}, 8) = 0
fcntl(19, F_SETLKW, {type=F_WRLCK, whence=SEEK_SET, start=0, len=0}) = 0
select(18, [16 17], NULL, NULL, NULL) = ? ERESTARTNOHAND (To be restarted)
--- SIGTERM (Terminated) ---
rt_sigaction(SIGHUP, {SIG_IGN}, {0x80ac6b4, [], SA_INTERRUPT|0x4000000}, 8) = 0
rt_sigaction(SIGUSR1, {SIG_IGN}, {0x80ac6e4, [], SA_INTERRUPT|0x4000000}, 8) = 0
rt_sigprocmask(SIG_BLOCK, NULL, [TERM], 8) = 0
rt_sigprocmask(SIG_BLOCK, NULL, [TERM], 8) = 0
rt_sigprocmask(SIG_BLOCK, NULL, [TERM], 8) = 0
rt_sigprocmask(SIG_BLOCK, NULL, [TERM], 8) = 0
rt_sigprocmask(SIG_BLOCK, NULL, [TERM], 8) = 0
rt_sigprocmask(SIG_BLOCK, NULL, [TERM], 8) = 0
rt_sigprocmask(SIG_BLOCK, NULL, [TERM], 8) = 0
rt_sigprocmask(SIG_BLOCK, NULL, [TERM], 8) = 0
rt_sigprocmask(SIG_BLOCK, NULL, [TERM], 8) = 0
rt_sigprocmask(SIG_BLOCK, NULL, [TERM], 8) = 0
_exit(0) = ?
---------------------------------------------------------------
Notice all the 'alarm' calls where the mem writing was occuring
before.
ltrace of seemingly-relevant bits via command line:
(this works)
---------------------------------------------------------------
opendir("/web/ShadNet/sys/cvs/webdocs") = 0x081c78f0
malloc(32) = 0x080fa1f0
memset(0x080fa1f0, '\000', 32) = 0x080fa1f0
malloc(20) = 0x080fe508
memcpy(0x080fe510, "io_dir_path", 11) = 0x080fe510
malloc(29) = 0x080fa218
memmove(0x080fa218, 0x080fe5b0, 28, 0x080fa1f0, 0x081c60cc) = 0x080fa218
memcpy(0xbffff7dc, "IO::Dir", 7) = 0xbffff7dc
memcpy(0xbffff69c, "IO", 2) = 0xbffff69c
memcpy(0xbffff69c, "Dir", 3) = 0xbffff69c
fwrite("Content-type: text/plain\n\n", 1, 26, 0x401581e0) = 26
ferror(0x401581e0) = 0
ferror(0x401581e0) = 0
memcpy(0x081c17e0, "|\252\017\b", 4) = 0x081c17e0
memcpy(0x08146f8c, "|\252\017\b", 4) = 0x08146f8c
readdir64(0x081c78f0, 0x400165a4, 0xbffff90c, 0x080c1b25, 0) = 0x081c7920
malloc(2) = 0x080fa240
memmove(0x080fa240, 0x081c792f, 1, 0x3ff00000, 0x081c60d8) = 0x080fa240
malloc(2) = 0x080fa250
memmove(0x080fa250, 0x08117670, 1, 0x080a02ec, 0x08117670) = 0x080fa250
realloc(0x080fa250, 3) = 0x080fa250
memmove(0x080fa251, 0x080fa240, 1, 0x080a02ec, 0x080fa240) = 0x080fa251
realloc(0x080fa250, 5) = 0x080fa250
memmove(0x080fa252, 0x080fc420, 2, 0x080a02ec, 0x080fc420) = 0x080fa252
fwrite("[.]\n", 1, 4, 0x401581e0) = 4
ferror(0x401581e0) = 0
ferror(0x401581e0) = 0
memcpy(0x081c17e0, "|\252\017\b", 4) = 0x081c17e0
memcpy(0x08146f8c, "|\252\017\b", 4) = 0x08146f8c
readdir64(0x081c78f0, 0x400165a4, 0xbffff90c, 0x080c1b25, 0) = 0x081c7934
malloc(3) = 0x080fa260
memmove(0x080fa260, 0x081c7943, 2, 0x081933c0, 0x081c60d8) = 0x080fa260
free(0x080fa240) = <void>
memmove(0x080fa250, 0x08117670, 1, 0x080a02ec, 0x08117670) = 0x080fa250
memmove(0x080fa251, 0x080fa260, 2, 0x080a02ec, 0x080fa260) = 0x080fa251
realloc(0x080fa250, 6) = 0x080fa250
memmove(0x080fa253, 0x080fc420, 2, 0x080a02ec, 0x080fc420) = 0x080fa253
fwrite("[..]\n", 1, 5, 0x401581e0) = 5
ferror(0x401581e0) = 0
ferror(0x401581e0) = 0
memcpy(0x081c17e0, "|\252\017\b", 4) = 0x081c17e0
memcpy(0x08146f8c, "|\252\017\b", 4) = 0x08146f8c
readdir64(0x081c78f0, 0x400165a4, 0xbffff90c, 0x080c1b25, 0) = 0x081c794c
malloc(4) = 0x080fa240
memmove(0x080fa240, 0x081c795b, 3, 0x081933c0, 0x081c60d8) = 0x080fa240
free(0x080fa260) = <void>
memmove(0x080fa250, 0x08117670, 1, 0x080a02ec, 0x08117670) = 0x080fa250
memmove(0x080fa251, 0x080fa240, 3, 0x080a02ec, 0x080fa240) = 0x080fa251
realloc(0x080fa250, 7) = 0x080fa250
memmove(0x080fa254, 0x080fc420, 2, 0x080a02ec, 0x080fc420) = 0x080fa254
.
.
. (repeated for each file in the directory)
.
.
ferror(0x401581e0) = 0
ferror(0x401581e0) = 0
memcpy(0x081c17e0, "|\252\017\b", 4) = 0x081c17e0
memcpy(0x08146f8c, "|\252\017\b", 4) = 0x08146f8c
readdir64(0x081c78f0, 0x400165a4, 0xbffff90c, 0x080c1b25, 0) = 0x081c7e04
malloc(8) = 0x080f5b08
memmove(0x080f5b08, 0x081c7e13, 7, 0x081933c0, 0x081c60d8) = 0x080f5b08
free(0x080f5af0) = <void>
memmove(0x080fa240, 0x08117670, 1, 0x080a02ec, 0x08117670) = 0x080fa240
memmove(0x080fa241, 0x080f5b08, 7, 0x080a02ec, 0x080f5b08) = 0x080fa241
memmove(0x080fa248, 0x080fc420, 2, 0x080a02ec, 0x080fc420) = 0x080fa248
fwrite("[foo.mp~]\n", 1, 10, 0x401581e0) = 10
ferror(0x401581e0) = 0
ferror(0x401581e0) = 0
memcpy(0x081c17e0, "|\252\017\b", 4) = 0x081c17e0
memcpy(0x08146f8c, "|\252\017\b", 4) = 0x08146f8c
readdir64(0x081c78f0, 0x400165a4, 0xbffff90c, 0x080c1b25, 0) = 0
__errno_location() = 0x4015b120
__sigsetjmp(0xbffff798, 1, 0xbffff85c, 0x0805c38a, 0x081b30c0) = 0
memcpy(0x081b6d50, "\220\370EOF\277", 4) = 0x081b6d50
memcpy(0x081b43e4, "\220\370EOF\277", 4) = 0x081b43e4
closedir(0x081c78f0) = 0
malloc(2) = 0x080f5af0
---------------------------------------------------------------
ltrace of seemingly-relevant bits via Apache::Registry:
(this doesn't work)
---------------------------------------------------------------
opendir("/web/ShadNet/sys/cvs/webdocs") = 0x0858aaa8
malloc(32) = 0x08536380
memset(0x08536380, '\000', 32) = 0x08536380
malloc(20) = 0x08533268
memcpy(0x08533270, "io_dir_path", 11) = 0x08533270
malloc(29) = 0x085363a8
memmove(0x085363a8, 0x085362f8, 28, 0x08536380, 0x085890c8) = 0x085363a8
memcpy(0xbffff53c, "IO::Dir", 7) = 0xbffff53c
memcpy(0xbffff3fc, "IO", 2) = 0xbffff3fc
memcpy(0xbffff3fc, "Dir", 3) = 0xbffff3fc
memcpy(0xbffff33c, "Tie::Hash", 9) = 0xbffff33c
memcpy(0xbffff1fc, "Tie", 3) = 0xbffff1fc
memcpy(0xbffff1fc, "Hash", 4) = 0xbffff1fc
memcpy(0xbffff33c, "Exporter", 8) = 0xbffff33c
memcpy(0xbffff1fc, "Exporter", 8) = 0xbffff1fc
memcpy(0xbffff36c, "UNIVERSAL", 9) = 0xbffff36c
memcpy(0xbffff22c, "UNIVERSAL", 9) = 0xbffff22c
malloc(24) = 0x085363d0
malloc(13) = 0x085363f0
memcpy(0x085363f0, "\350\t", 12) = 0x085363f0
memmove(0x08300758, 0x08300754, 4, 0x0810a1ac, 0x08263cf4) = 0x08300758
malloc(6) = 0x08536408
memmove(0x08536408, 0x0816c0e1, 5, 29, 0x085890d4) = 0x08536408
strcmp("SCALAR", "Apache") = 18
strcmp("Apache", "Apache") = 0
memcpy(0xbffff2fc, "Apache", 6) = 0xbffff2fc
alarm(300) = 0
strcmp("SCALAR", "Apache") = 18
strcmp("Apache", "Apache") = 0
memcpy(0x08527b5c, "Content-type: text/plain\n\n", 26) = 0x08527b5c
alarm(0) = 300
free(0x08536408) = <void>
memcpy(0x08584998, "|IS\b", 4) = 0x08584998
malloc(1008) = 0x08533cc0
memcpy(0x08300754, "|IS\b", 4) = 0x08300754
readdir64(0x0858aaa8, 0x08300754, 0xbffff66c, 0x081376e5, 0x08263cf4) = 0x0858aad8
malloc(1) = 0x085340b8
memmove(0x085340b8, 0x0858aae7, 0, 0x3ff00000, 0x085890d4) = 0x085340b8
malloc(2) = 0x085340c8
memmove(0x085340c8, 0x08272c48, 1, 0x08115eac, 0x08272c48) = 0x085340c8
memmove(0x085340c9, 0x085340b8, 0, 0x08115eac, 0x085340b8) = 0x085340c9
realloc(0x085340c8, 4) = 0x085340c8
memmove(0x085340c9, 0x08535930, 2, 0x08115eac, 0x08535930) = 0x085340c9
memmove(0x08300758, 0x08300754, 4, 0x0810a1ac, 0x08263cf4) = 0x08300758
malloc(6) = 0x085340d8
memmove(0x085340d8, 0x0816c0e1, 5, 4, 0x085890d4) = 0x085340d8
strcmp("SCALAR", "Apache") = 18
strcmp("Apache", "Apache") = 0
memcpy(0xbffff2fc, "Apache", 6) = 0xbffff2fc
alarm(300) = 0
strcmp("SCALAR", "Apache") = 18
strcmp("Apache", "Apache") = 0
memcpy(0x08527b76, "[]\n", 3) = 0x08527b76
alarm(0) = 300
free(0x085340d8) = <void>
memcpy(0x08584998, "|IS\b", 4) = 0x08584998
.
.
. (repeated dozens of times, roughtly corresponding to the # of
. files in the directly I want to read, but off by one or two)
.
.
strcmp("SCALAR", "Apache") = 18
strcmp("Apache", "Apache") = 0
memcpy(0xbffff2fc, "Apache", 6) = 0xbffff2fc
alarm(300) = 0
strcmp("SCALAR", "Apache") = 18
strcmp("Apache", "Apache") = 0
memcpy(0x08527bf1, "[]\n", 3) = 0x08527bf1
alarm(0) = 300
free(0x085340b8) = <void>
memcpy(0x08584998, "|IS\b", 4) = 0x08584998
memcpy(0x08300754, "|IS\b", 4) = 0x08300754
readdir64(0x0858aaa8, 0x08300754, 0xbffff66c, 0x081376e5, 0x08263cf4) = 0x0858b064
malloc(1) = 0x085340b8
memmove(0x085340b8, 0x0858b073, 0, 0x08539670, 0x085890d4) = 0x085340b8
free(0x085340d8) = <void>
memmove(0x085340c8, 0x08272c48, 1, 0x08115eac, 0x08272c48) = 0x085340c8
memmove(0x085340c9, 0x085340b8, 0, 0x08115eac, 0x085340b8) = 0x085340c9
memmove(0x085340c9, 0x08535930, 2, 0x08115eac, 0x08535930) = 0x085340c9
memmove(0x08300758, 0x08300754, 4, 0x0810a1ac, 0x08263cf4) = 0x08300758
malloc(6) = 0x085340d8
memmove(0x085340d8, 0x0816c0e1, 5, 0x4018d48c, 0x085890d4) = 0x085340d8
strcmp("SCALAR", "Apache") = 18
strcmp("Apache", "Apache") = 0
memcpy(0xbffff2fc, "Apache", 6) = 0xbffff2fc
alarm(300) = 0
strcmp("SCALAR", "Apache") = 18
strcmp("Apache", "Apache") = 0
memcpy(0x08527bf4, "[]\n", 3) = 0x08527bf4
alarm(0) = 300
free(0x085340d8) = <void>
memcpy(0x08584998, "|IS\b", 4) = 0x08584998
memcpy(0x08300754, "|IS\b", 4) = 0x08300754
readdir64(0x0858aaa8, 0x08300754, 0xbffff66c, 0x081376e5, 0x08263cf4) = 0
__errno_location() = 0x4018e120
__sigsetjmp(0xbffff4f8, 1, 0xbffff5bc, 0x080cec7a, 0x081e6f9c) = 0
memcpy(0x08579940, "\360\365EOF\277", 4) = 0x08579940
memcpy(0x081e072c, "\360\365EOF\277", 4) = 0x081e072c
closedir(0x0858aaa8) = 0
malloc(2) = 0x085340d8
---------------------------------------------------------------
Cheers,
Richard
--
----------------------------------------------------------------------------
Richard Dice * Personal 519 635 9568 * Fax 519 635 9569
ShadNet Creator * http://shadnet.shad.ca/ * [EMAIL PROTECTED]
Occasional Writer, HotWired * http://www.hotwired.com/webmonkey/
"squeeze the world 'til it's small enough to join us heel to toe"
- jesus jones