-
Notifications
You must be signed in to change notification settings - Fork 34
/
TO_DO
117 lines (80 loc) · 5.42 KB
/
TO_DO
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
OK, this has turned out not to be a "to do" file so much as a place to put useful little snippets and such...
new cmake-based command line building:
cd SLiM
mkdir build
cd build
cmake ..
make
cause cmake to be re-run (after addition/removal of source files, etc.; this is necessary because we use GLOB with "file" in our cmake config):
cd SLiM
touch ./CMakeLists.txt
look for exported symbols that are not tagged with "eidos" or "Eidos" somewhere in the symbol before the parameter list:
nm -g -U -j ./EidosScribe | grep -E -v "^_+([^_\r\n]+_)*[^_]*[Ee]idos"
dump demangled symbols from SLiMgui:
nm -g -U -j ./SLiMgui | c++filt
some valgrind commands (set SLIM_LEAK_CHECKING to 1, and change the compile C/C++ flags to -O1 -g):
valgrind --leak-check=yes --track-origins=yes --expensive-definedness-checks=yes --num-callers=20 ./slim -testEidos (with Debug version)
valgrind --leak-check=yes --track-origins=yes --expensive-definedness-checks=yes --num-callers=20 ./slim -testSLiM (with Debug version)
valgrind --tool=cachegrind ./slim -seed 1 /Users/bhaller/Desktop/MK_SLiMGUIsim4.txt (with Release version)
cg_annotate --sort=DLmr:1,DLmw:1 cachegrind.out.71431
valgrind --tool=callgrind ./slim -seed 1 /Users/bhaller/Desktop/MK_SLiMGUIsim4.txt (with Release version)
callgrind_annotate --tree=both callgrind.out.72015
valgrind --tool=massif ./slim -seed 1 /Users/bhaller/Desktop/MK_SLiMGUIsim4.txt (with Release version)
ms_print massif.out.73964
valgrind --tool=exp-sgcheck ./slim -testEidos (with Debug version; not on Darwin yet)
valgrind --tool=exp-sgcheck ./slim -testSLiM (with Debug version; not on Darwin yet)
cpplint.py for checking includes (https://github.com/google/styleguide/tree/gh-pages/cpplint):
cd /Users/bhaller/Documents/Research/MesserLab/SLiM_project/SLiM
python2.7 /Users/bhaller/bin/cpplint.py --filter=-,+build/include_what_you_use ./core/*.cpp ./eidos/*.cpp ./eidostool/*.cpp ./QtSLiM/*.cpp
clang-tidy with CMake:
see https://danielsieger.com/blog/2021/12/21/clang-tidy-cmake.html
install a good version of clang first: sudo port install clang-17 if you use MacPorts
find where clang-tidy is living: port contents clang-17 (for me it is at /opt/local/libexec/llvm-17/bin/clang-tidy)
similarly locate clang and clang++ (for me, /opt/local/libexec/llvm-17/bin/clang and /opt/local/libexec/llvm-17/bin/clang++)
fix the CMakeLists.txt file to have the correct paths for these things (in the section near the top, "if(TIDY)")
make a build directory for SLiM with mkdir, and cd to it
run cmake (one of the below):
cmake -D TIDY=ON path-to-SLiM-repo
cmake -D TIDY=ON -D CMAKE_BUILD_TYPE=Debug path-to-SLiM-repo
cmake -D TIDY=ON -D CMAKE_BUILD_TYPE=Debug -D CMAKE_PREFIX_PATH=/Users/bhaller/Qt5.15.2/5.15.2/clang_64 -D BUILD_SLIMGUI=ON /Users/bhaller/Documents/Research/MesserLab/SLiM_project/SLiM
make eidos / make slim / make SLiMgui
CR/LF issues:
file -e soft <file> tells you what a file is (-e soft turns off "magic", which misdiagnoses SLiM files)
tab2space -lf <file> converts a file to Unix-style LF only
convert all text files in the current directory to use LF: find . -name \*.txt -exec tab2space -lf {} {} \; -print
tab issues:
convert leading spaces to tabs in recipes:
find . -name \*.txt -exec bash -c 'gunexpand -t 4 --first-only "$0" > /tmp/totabbuff && mv /tmp/totabbuff "$0"' {} \; -print
finding out the generation number of a running simulation in lldb:
lldb /usr/local/bin/slim
process attach --pid X (from ps -ax | grep slim)
breakpoint set --method _RunOneTick
c
(lldb breaks at _RunOneTick...)
if you have symbols, just p generation_; if not:
si (repeat until you reach movl $0x0, 0x40(%r15) which is perhaps around +30; this is generation_stage_ = SLiMGenerationStage::kStage0PreGeneration)
(now %r15 is the this pointer...)
register read r15 --format hex
memory read --size 4 --format x --count 50 `0x00007f9e28413f80` (where the hex value of r15 goes in the backquotes)
the generation is at the end of the fourth line, as SLiM is currently set up:
0x7f9e28413fb0: 0x28414310 0x00007f9e 0x00000001 0x000021ef -> 0x000021ef is the generation
if the memory layout moves, just look for 0x00000007 which will be the generation stage at this point in the code; the generation is immediately before it
reassuring the Clang analyzer that a precondition is met:
#ifdef __clang_analyzer__
assert(p_argument_count >= 5);
#endif
count total lines of code in the project (excluding the gsl code):
( find ./core/ ./eidos/ ./eidostool/ ./EidosScribe ./SLiMgui ./QtSLiM '(' -name '*.mm' -or -name '*.h' -or -name '*.cpp' ')' -print0 | xargs -0 cat ) | wc -l
( find ./core/ ./eidos/ '(' -name '*.mm' -or -name '*.h' -or -name '*.cpp' ')' -print0 | xargs -0 cat ) | wc -l
or better, use cloc (available in MacPorts); see https://stackoverflow.com/a/5121125/2752221
a useful LaTeX equation editor:
https://www.codecogs.com/latex/eqneditor.php
find all instances of a string (or regex) in the commit history:
git --no-pager log -G"pedigree"
to get a text diff of changes to the Xcode project file:
git --no-pager diff --text SLiM.xcodeproj/project.pbxproj
to dump class memory layouts in Xcode:
add -Xclang and -fdump-record-layouts to "Other C++ Flags" in the project
rebuild one file of interest with command-control-B
go to the Report navigator, click on the build of the file
click on the compile execution line in the build log, then click on the report viewer icon at the right edge of that line