Another small step forward in figuring out how heap works.
There are a number of debug calls in the malloc library but they log on stdout so my problem was redirecting stdout for an already running process. I've spent loads of time trying to get freopen to work, but at least in the Preview process FILE * is undefined.
And then I found this Apple Technote that uses open instead if freopen.
There are a number of debug calls in the malloc library but they log on stdout so my problem was redirecting stdout for an already running process. I've spent loads of time trying to get freopen to work, but at least in the Preview process FILE * is undefined.
And then I found this Apple Technote that uses open instead if freopen.
(gdb) shell ps ax | grep Preview
1006 ?? S 0:00.22 /Applications/Preview.app/Contents/MacOS/Preview -psn_0_12976129
1014 p5 S+ 0:00.00 bash -c ps ax | grep Preview
1016 p5 R+ 0:00.00 grep Preview
(gdb) attach 1006
Attaching to process 1006.
Reading symbols for shared libraries . done
Reading symbols for shared libraries ............ done
0x90009cd7 in mach_msg_trap ()
(gdb) call (int) close(2)
$1 = 0
(gdb) shell tty
/dev/ttyp5
(gdb) call (int) open("/dev/ttyp5", 2, 0)
$2 = 2
(gdb) call (void) malloc_zone_print(0, 0)
Preview(1006) malloc: Scalable zone 0x1800000: inUse=13282(y)
touched=y allocated=y flags=1238032
Preview(1006) malloc: tiny=13079(y) small=675856(y)
large=194(y) huge=361472(y)
Preview(1006) malloc: 1 tiny regions:
Preview(1006) malloc: Tiny region [0x300000-0x400000, y]
Preview(1006) malloc: In_use=13079
Preview(1006) malloc: untouched=y Preview(1006) malloc:
Preview(1006) malloc: 1 small regions:
Preview(1006) malloc: Small region [0x1800000-0x2000000, y]
In_use=8421376 Preview(1006) malloc: Untouched=y Preview(1006) malloc:
(gdb) q