Austin Schuh | 745610d | 2015-09-06 18:19:50 -0700 | [diff] [blame] | 1 | * Get heap-profile-table.cc using DeleteMatchingFiles |
| 2 | * Get heap-profile-table.cc using FillProcSelfMaps, DumpProcSelfMaps |
| 3 | * Play around with ExperimentalGetStackTrace |
| 4 | * Support the windows-level memory-allocation functions? See |
| 5 | /home/build/googleclient/earth/client/tools/memorytracking/client/memorytrace/src/memorytrace.cpp |
| 6 | /home/build/googleclient/total_recall/common/sitestep/* |
| 7 | http://www.internals.com/articles/apispy/apispy.htm |
| 8 | http://www.wheaty.net/APISPY32.zip |
| 9 | * Verify /proc/xxx/maps: |
| 10 | http://www.geocities.com/wah_java_dotnet/procmap/index.html |
| 11 | * Figure out how to edit the executable IAT so tcmalloc.dll is loaded first |
| 12 | * Use QueryPerformanceCounter instead of GetTickCount() (also for sparsehash) |
| 13 | |
| 14 | ---- |
| 15 | More info on windows-level memory-allocation functions: |
| 16 | C runtime malloc |
| 17 | LocalAlloc |
| 18 | GlobalAlloc |
| 19 | HeapAlloc |
| 20 | VirtualAlloc |
| 21 | mmap stuff |
| 22 | |
| 23 | malloc, LocalAlloc and GlobalAlloc call HeapAlloc, which calls |
| 24 | VirtualAlloc when needed, which calls VirtualAllocEx (the __sbrk equiv?) |
| 25 | |
| 26 | siggi sez: If you want to do a generic job, you probably need to |
| 27 | preserve the semantics of all of these Win32 calls: |
| 28 | Heap32First |
| 29 | Heap32ListFirst |
| 30 | Heap32ListNext |
| 31 | Heap32Next |
| 32 | HeapAlloc |
| 33 | HeapCompact |
| 34 | HeapCreate |
| 35 | HeapCreateTagsW |
| 36 | HeapDestroy |
| 37 | HeapExtend |
| 38 | HeapFree |
| 39 | HeapLock |
| 40 | HeapQueryInformation |
| 41 | HeapQueryTagW |
| 42 | HeapReAlloc |
| 43 | HeapSetInformation |
| 44 | HeapSize |
| 45 | HeapSummary |
| 46 | HeapUnlock |
| 47 | HeapUsage |
| 48 | HeapValidate |
| 49 | HeapWalk |
| 50 | |
| 51 | kernel32.dll export functions and nt.dll export functions: |
| 52 | http://www.shorthike.com/svn/trunk/tools_win32/dm/lib/kernel32.def |
| 53 | http://undocumented.ntinternals.net/ |
| 54 | |
| 55 | You can edit the executable IAT to have the patching DLL be the |
| 56 | first one loaded. |
| 57 | |
| 58 | Most complete way to intercept system calls is patch the functions |
| 59 | (not the IAT). |
| 60 | |
| 61 | Microsoft has somee built-in routines for heap-checking: |
| 62 | http://support.microsoft.com/kb/268343 |
| 63 | |
| 64 | ---- |
| 65 | Itimer replacement: |
| 66 | http://msdn2.microsoft.com/en-us/library/ms712713.aspx |
| 67 | |
| 68 | ---- |
| 69 | Changes I've had to make to the project file: |
| 70 | |
| 71 | 0) When creating the project file, click on "no autogenerated files" |
| 72 | |
| 73 | --- For each project: |
| 74 | 1) Alt-F7 -> General -> [pulldown "all configurations" ] -> Output Directory -> $(SolutionDir)$(ConfigurationName) |
| 75 | 2) Alt-F7 -> General -> [pulldown "all configurations" ] -> Intermediate Directory -> $(ConfigurationName) |
| 76 | |
| 77 | --- For each .cc file: |
| 78 | 1) Alt-F7 -> C/C++ -> General -> [pulldown "all configurations"] -> Additional Include Directives --> src/windows + src/ |
| 79 | 2) Alt-F7 -> C/C++ -> Code Generation -> Runtime Library -> Multi-threaded, debug/release, DLL or not |
| 80 | |
| 81 | --- For DLL: |
| 82 | 3) Alt-F7 -> Linker -> Input -> [pulldown "all configurations" ] -> Module Definition File -> src\windows\vc7and8.def |
| 83 | --- For binaries depending on a DLL: |
| 84 | 3) Right-click on project -> Project Dependencies -> [add dll] |
| 85 | --- For static binaries (not depending on a DLL) |
| 86 | 3) Alt-F7 -> C/C++ -> Command Line -> [pulldown "all configurations"] -> /D PERFTOOLS_DLL_DECL= |