TODO revision 5821806d5e7f356e8fa4b058a389a808ea183019
1f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)* Get heap-profile-table.cc using DeleteMatchingFiles 2f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)* Get heap-profile-table.cc using FillProcSelfMaps, DumpProcSelfMaps 3f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)* Play around with ExperimentalGetStackTrace 4f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)* Support the windows-level memory-allocation functions? See 5f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) /home/build/googleclient/earth/client/tools/memorytracking/client/memorytrace/src/memorytrace.cpp 6f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) /home/build/googleclient/total_recall/common/sitestep/* 7f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) http://www.internals.com/articles/apispy/apispy.htm 8f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) http://www.wheaty.net/APISPY32.zip 9a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)* Verify /proc/xxx/maps: 10f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) http://www.geocities.com/wah_java_dotnet/procmap/index.html 11f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)* Figure out how to edit the executable IAT so tcmalloc.dll is loaded first 12f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)* Use QueryPerformanceCounter instead of GetTickCount() (also for sparsehash) 13f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) 146d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles)---- 156d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles)More info on windows-level memory-allocation functions: 166d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) C runtime malloc 176d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) LocalAlloc 186d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) GlobalAlloc 196d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) HeapAlloc 206d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) VirtualAlloc 216d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) mmap stuff 226d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) 236d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles)malloc, LocalAlloc and GlobalAlloc call HeapAlloc, which calls 246d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles)VirtualAlloc when needed, which calls VirtualAllocEx (the __sbrk equiv?) 25f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) 26f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)siggi sez: If you want to do a generic job, you probably need to 276d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles)preserve the semantics of all of these Win32 calls: 286d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) Heap32First 296d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) Heap32ListFirst 306d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) Heap32ListNext 316d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) Heap32Next 326d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) HeapAlloc 336d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) HeapCompact 346d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) HeapCreate 356d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) HeapCreateTagsW 366d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) HeapDestroy 376d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) HeapExtend 386d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) HeapFree 396d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) HeapLock 406d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) HeapQueryInformation 41116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch HeapQueryTagW 42116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch HeapReAlloc 436d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) HeapSetInformation 446d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) HeapSize 456d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) HeapSummary 466d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) HeapUnlock 476d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) HeapUsage 486d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) HeapValidate 496d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) HeapWalk 506d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) 516d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles)kernel32.dll export functions and nt.dll export functions: 526d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) http://www.shorthike.com/svn/trunk/tools_win32/dm/lib/kernel32.def 536d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) http://undocumented.ntinternals.net/ 546d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) 556d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles)You can edit the executable IAT to have the patching DLL be the 566d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles)first one loaded. 576d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) 586d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles)Most complete way to intercept system calls is patch the functions 59f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)(not the IAT). 60f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) 61f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)Microsoft has somee built-in routines for heap-checking: 62f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) http://support.microsoft.com/kb/268343 63f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) 64f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)---- 65f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)Itimer replacement: 66f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) http://msdn2.microsoft.com/en-us/library/ms712713.aspx 67f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) 68f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)---- 69f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)Changes I've had to make to the project file: 70f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) 71f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)0) When creating the project file, click on "no autogenerated files" 72f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) 73f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)--- For each project: 74f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)1) Alt-F7 -> General -> [pulldown "all configurations" ] -> Output Directory -> $(SolutionDir)$(ConfigurationName) 75f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)2) Alt-F7 -> General -> [pulldown "all configurations" ] -> Intermediate Directory -> $(ConfigurationName) 76f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) 77f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)--- For each .cc file: 78f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)1) Alt-F7 -> C/C++ -> General -> [pulldown "all configurations"] -> Additional Include Directives --> src/windows + src/ 79f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)2) Alt-F7 -> C/C++ -> Code Generation -> Runtime Library -> Multi-threaded, debug/release, DLL or not 80f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) 81f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)--- For DLL: 82f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)3) Alt-F7 -> Linker -> Input -> [pulldown "all configurations" ] -> Module Definition File -> src\windows\vc7and8.def 83f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)--- For binaries depending on a DLL: 84f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)3) Right-click on project -> Project Dependencies -> [add dll] 85f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)--- For static binaries (not depending on a DLL) 86f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)3) Alt-F7 -> C/C++ -> Command Line -> [pulldown "all configurations"] -> /D PERFTOOLS_DLL_DECL= 87f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)