Project

General

Profile

Devtools » History » Version 12

laforge, 12/31/2020 01:01 PM
add toc

1 12 laforge
{{>toc}}
2
3 8 laforge
h1. Development tools
4 6
5 7 laforge
h2. C tools
6 1
7 9 laforge
* @Lindent@ (from kernel source), reformat C code to the Linux kernel (and osmocom) coding standards
8
* @cflow@ to generate flow-graphs from source code
9 7 laforge
10 1
h2. Patches
11
12 7 laforge
* @git format-patch -1@, generate a patch
13
* @checkpatch.pl@, check patches for common errors (Ignore x-signed-off-by)
14
* @make distcheck@ catches quite a few errors, run it before sending patches.
15
* @git send-email -1@ Send a patch to the mailing list (after configuration)
16 1
17 5
h2. Testing
18 1
19 7 laforge
* @make check@: run it and don't introduce regressions
20 10 laforge
* @make distcheck@: run it to make sure that @make dist@ contains everything needed and you didn't forget to add any files to Makefile.am
21
* Our extensive [[Titan_TTCN3_Testsuites]]
22 1
23 11 laforge
h2. AddressSanitizer
24
25
All Osmocom CNI projects support building iwth @./configure --enable-sanitize@, which enables support for "AddressSanitizer":https://github.com/google/sanitizers/wiki/AddressSanitizer
26
27
This is extremely useful in finding a variety of problems, such as use-after-free.
28
29
h3. meaniungful backtraces
30
31
Often  the backtraces you get from asan are too short to figure out where an allocation/free has happened, like:
32
33
<pre>
34
0x612000000eb8 is located 248 bytes inside of 296-byte region [0x612000000dc0,0x612000000ee8)
35
freed by thread T0 here:
36
    #0 0x7f42477d9b6f in __interceptor_free ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:123
37
    #1 0x7f4246b2678a in _tc_free_internal ../../talloc.c:1221
38
39
previously allocated by thread T0 here:
40
    #0 0x7f42477d9e8f in __interceptor_malloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:145
41
    #1 0x7f4246b28ecb in __talloc_with_prefix ../../talloc.c:782
42
</pre>
43
44
In this case, it is recommended to run with the environment variable @ASAN_OPTIONS="fast_unwind_on_malloc=0"@, which will produce a much more meaningful backtrace. The same bug as the above example now looks like this:
45
46
<pre>
47
0x612000000eb8 is located 248 bytes inside of 296-byte region [0x612000000dc0,0x612000000ee8)
48
freed by thread T0 here:
49
    #0 0x7f5c3e64bb6f in __interceptor_free ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:123
50
    #1 0x7f5c3d99878a in _tc_free_internal ../../talloc.c:1221
51
    #2 0x7f5c3daa648e in fsm_free_or_steal /space/home/laforge/projects/git/libosmocore/src/fsm.c:116
52
    #3 0x7f5c3daa648e in osmo_fsm_inst_free /space/home/laforge/projects/git/libosmocore/src/fsm.c:574
53
    #4 0x7f5c3daab8ef in _osmo_fsm_inst_term /space/home/laforge/projects/git/libosmocore/src/fsm.c:959
54
    #5 0x7f5c3daadb09 in fsm_tmr_cb /space/home/laforge/projects/git/libosmocore/src/fsm.c:337
55
    #6 0x7f5c3da893a6 in osmo_timers_update /space/home/laforge/projects/git/libosmocore/src/timer.c:273
56
    #7 0x7f5c3da8cf62 in _osmo_select_main /space/home/laforge/projects/git/libosmocore/src/select.c:373
57
    #8 0x7f5c3da8d548 in osmo_select_main /space/home/laforge/projects/git/libosmocore/src/select.c:417
58
    #9 0x55b16ce4705c in main /space/home/laforge/projects/git/osmo-cbc/src/cbc_main.c:216
59
    #10 0x7f5c3cd63d09 in __libc_start_main ../csu/libc-start.c:308
60
    #11 0x55b16ce47649 in _start (/space/home/laforge/projects/git/osmo-cbc/src/osmo-cbc+0x2a649)
61
62
previously allocated by thread T0 here:
63
    #0 0x7f5c3e64be8f in __interceptor_malloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:145
64
    #1 0x7f5c3d99aecb in __talloc_with_prefix ../../talloc.c:782
65
    #2 0x7f5c3d99b8a6 in __talloc ../../talloc.c:824
66
    #3 0x7f5c3d99b8a6 in _talloc_named_const ../../talloc.c:981
67
    #4 0x7f5c3d99b8a6 in _talloc_zero ../../talloc.c:2422
68
    #5 0x7f5c3daa4fcd in osmo_fsm_inst_alloc /space/home/laforge/projects/git/libosmocore/src/fsm.c:445
69
    #6 0x55b16ce4c3c8 in cbsp_cbc_accept_cb /space/home/laforge/projects/git/osmo-cbc/src/cbsp_server.c:127
70
    #7 0x7f5c3d931288 in osmo_stream_srv_fd_cb /space/home/laforge/projects/git/libosmo-netif/src/stream.c:880
71
    #8 0x7f5c3da8d1b1 in poll_disp_fds /space/home/laforge/projects/git/libosmocore/src/select.c:350
72
    #9 0x7f5c3da8d1b1 in _osmo_select_main /space/home/laforge/projects/git/libosmocore/src/select.c:378
73
    #10 0x7f5c3da8d548 in osmo_select_main /space/home/laforge/projects/git/libosmocore/src/select.c:417
74
    #11 0x55b16ce4705c in main /space/home/laforge/projects/git/osmo-cbc/src/cbc_main.c:216
75
    #12 0x7f5c3cd63d09 in __libc_start_main ../csu/libc-start.c:308
76
    #13 0x55b16ce47649 in _start (/space/home/laforge/projects/git/osmo-cbc/src/osmo-cbc+0x2a649)
77
</pre>
78
79 1
h2. Misc
80
81 7 laforge
* pahole (dwarves), http://www.ohloh.net/p/pahole See the memory layout of structures
82
* gdb, debugging
83
* valgrind, http://valgrind.org/, dynamic analysis of memory management/threading
84
* mudflap (gcc option), check array/pointer accesses. See http://zecke.blogspot.com/2012/10/know-your-tools-mudflap.html
85 6
86
87 7 laforge
h2. Python tools
88 2
89 7 laforge
h3. Formatting
90 1
91 7 laforge
* pep8, https://pypi.python.org/pypi/pep8 Check formatting for pep8 compliance
92
* autopep8, https://github.com/hhatto/autopep8 Reformat code to be pep8-complient
93 6
94 7 laforge
h3. Checking/analysis
95 3
96 7 laforge
* pyflakes, https://pypi.python.org/pypi/pyflakes Statically find some errors
Add picture from clipboard (Maximum size: 48.8 MB)