PreferredTechnologies
Contents
Overview
This page represents our best attempt at gathering the common tools and practices used by engineers on the Ubuntu Foundations team.
Development
Emacs
We are in alphabetical order, right?! =)
* PythonProgrammingInEmacs - for pyflakes, rope, etc.
* CEDET - for IDE like features
Vim
Plugins
Turns Vim into a fully-functional IDE:
Testing and Debugging
Python
Use pyflakes to check for common errors. Hook this up to your preferred test harness using something akin to the following:
Mock is one of the better mocking libraries and is already used in ubiquity, software-center, and apport.
ipdb iPython like debugging shell with superior tab completion. import ipdb; ipdb.set_trace() is pure heaven.
C
Tracing
strace: system call tracing.
ltrace: library function tracing.
atrace.sh: library function and application function tracing
Memory Checkers
Note: to use memory checkers reliably, you need to tell (e(g))libc and glib to disable all their checks too like this:
Note the trailing underscore at the end of the last variable!
valgrind
No need to recompile code.
Basic memory checking:
1 valgrind -v myprogram --arg=foo -baz
More aggressive checking:
Deep magic which will spawn gdb when an error is detected (--db-attach=yes):
1 valgrind \
2 -v \
3 --trace-children=yes \
4 --track-fds=yes \
5 --time-stamp=yes \
6 --db-attach=yes \
7 --read-var-info=yes \
8 --tool=memcheck \
9 --leak-check=full \
10 --leak-resolution=high \
11 --num-callers=40 \
12 --show-reachable=yes \
13 --track-origins=yes \
14 --undef-value-errors=yes \
15 --freelist-vol=60000000 \
16 --malloc-fill=0x7 \
17 --free-fill=0x8 \
18 myprogram --arg=foo -baz
dmalloc
Install:
1 sudo apt-get install -y libdmalloc5 libdmalloc-dev
Using dmalloc with LD_PRELOAD:
1 (eval `dmalloc -b -i 1 -l /tmp/dmalloc.log all`; LD_PRELOAD=libmalloc.so.5; ./myapp --arg=foo -bar)
wrap_malloc
Simpler more hackable/configurable tool than dmalloc/electric-fence:
http://people.canonical.com/~jhunt/utils/wrap_malloc/
Static Analysis
cppcheck
splint
Excellent static analysis tool. May now be unmaintained? Does not understand C99 (variadic macros).
1 splint -I/usr/include -I/some/where -DMY_DEFINE=1 -DFOO src/main.c 2>&1|tee splint.log
- LLVM/Clang
smatch
Smatch is a static analysis that uses Linus' sparse C parser.
Performance testing
judge runs two commands 50 times and provides the following report:
ubuntu@server-8149:~$ ./judge/judge ./2281 ./with_changes v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^ n mean sd min max cmd 50 10316.2ms 355.7 9945.9 11638.6 ./2281 50 9867.5ms 625.8 9385.6 13061.3 ./with_changes -448.636ms -4.3% p=0.000 difference is significant at 95.0% confidence (p=0.000): based on these samples, suggested sample size is n>=283 to have a 112.16ms confidence interval
Cloud infrastructure
cloud-init provides a means to run scripts during the creation of a Canonicloud instance. You can use this to create configurations for the infrastructure you need for a project and rapidly deploy that, either to develop or run tests against. See the code in whoopsie-daisy as an example.
Building
- sbuild (far superior to pbuilder: quicker per-build setup, closer to Launchpad buildd environment, integrates well with schroot for ad-hoc testing)
Productivity
Efficiently splitting a terminal into several smaller windows
tmux is a terminal multiplexer, similar to GNU Screen, but arguably better.
Some tips:
The default keybindings let you use ^b arrow to move between panes. However, because this is a sequence of keys rather than a modifier, you can easily get into timing issues where you meant to move to the pane above, then downward in the open file, but actually moved to the pane above and back into the previous one. You can fix this by telling tmux to not wait for commands:
set -g escape-time 0
- You can bind a key to take the current tmux selection and put it in the X11 clipboard:
unbind ^C bind ^C run "tmux show-buffer | xclip -i -selection clipboard"
Using the standard keybindings, you would hit ^b^[ to enter copy mode, ^space to mark the beginning of a selection, the arrow keys to mark the end, and alt-w to select. Then press ^b^c to copy that text to the X11 clipboard.
FoundationsTeam/PreferredTechnologies (last edited 2024-10-16 11:12:07 by rkratky)