This works under Linux with glibc, but there are two problems. I've fixed one, and it looks like fixing the other might have to wait until the current (Aug 2002) flurry of Linuxthread work is finished.
The heuristic used to size the call graph table (tos[]) might be a suprise to some users, so I've added a line to output a message to stderr when the heuristic picks too low a value, causing table overflow.
The heuristic does pick too low a value when running Jim's regression test; to work around this, tweak the constant ARCDENSITY up to 3 from 2, and link the test program statically (which just happens to make the heuristic allocate a much larger call graph table, due to the increased text size).
I must say, the table sizing and indexing in gmon is a bit tricky to understand. Thus I don't trust my patch yet. There may be some table sizing or indexing bug lurking still.
I have yet to use this on the real program that caused me to look into the problem, but it does seem to let Jim's regression test pass.