- GNU Autotools
- Autoconf
- Generates a “configure” script which sets up your makefiles
and helps your pgoram be portable across many Unix-like and
Linux systems.
- Automake
- Generates Makefiles which work across many systems (the common
feature set of “make” itself is surprisingly limited)
- The generated makefiles will automatically track dependencies
- See An Introduction to the
Autotools
- GNU Autotools has a reputation for being hard to use. This is
fair, but they are also more powerful than any other approach to
the same set of problems.
- GNU libtool
- Provides a machine-independent way to build libraries, including
shared (dynamic link) libraries.
- The best way to use this is via GNU Autotools.
- Metaconfig is primarily
intended for building Perl.
- Try Your Build Tool
- Some build tools, for example CMake, also attempt to solve
portability challenges, though arguably attempts only a narrower
scope
- Obsolete
- GNU Autotools essentially out-competed a number of predecessor
systems; if you see these in use today you could well have a lot
of trouble getting them to help you build on modern systems
- imake (and xmkmf) has been
obsolete since the early 2000s. See conversion
guide
Configuration Management
Software configuration management is a very broad category and
encompasses how you build, version-control and audit your software and
computer systems. Because of this breadth, it doesn’t make much sense
to link to particular tools here. Instead we link to more specific
categories.
- Version Control
(also known as Revision Control) is probably what most people
understand when they hear the phrase “Configuration Management”.
- Build Management is already covered above
- Software Development Lifecycle Tools
- These vary from lightweight and flexible to comprehensive and burdensome.
- Nothing about them is C-specific and many C programmers will not
need or use these, so we don’t list them here.
- Defect and Work Item Tracking
- Not really specific to C so try some related subreddits:
Working With Source Code
- Matt Godbolt’s Compiler Explorer lets you paste or type code fragments and examine the machine code they compile to.
Pastebins
-
If your source code is long, it is much better to cut down your
example before posting it (and in any case this will often help you
debug it!). But if you really really can’t, you could use a
“pastebin” site. Beware though, some of these sites can contain
malicious content.
- GitHub Gist
- https://pastebin.com/
- https://textbin.net/
- https://ideone.com/ (will compile some programs)
- https://pastecode.io/
- https://pastesio.com/
- More: https://github.com/lorien/awesome-pastebins
Style Checkers
See the static-analysis page.
Documentation Generators (from source code)
Static (Source Code) Analysis
There are a lot of these; see the static-analysis page.
- IDEs often have this feature built-in so you may not need a separate tool for this.
- Some static analysis tools also have program transformation featurs.
- Coccinelle
Working With Your Compiled Program
Debugging
- IDEs generally incorporate a debugger.
- Traditional Debuggers
- GDB: The GNU Project Debugger
- Tutorial: Beej’s Guide to the GNU Debugger
(GDB)
- If you’re not familiar with GDB, learn how to use “TUI mode”,
it is more user-friendly.
- Debugging remote programs
- Link the GDB remote debugging stub into your program
- Run gdbserver on the remote system
- Debugging without Debuggers
- Logging (i.e. emitting messages about what the program is doing)
is an enduringly popular debugging strategy
- Unit tests: if you have a hypothesis about what the problem is,
you can write a unit test that verifies your program’s behaviour.
If your unit test uncovers the bug, you can fix the bug and keep
the test.
- See also the Dynamic Analysis section
Profiling
Profiling (i.e. determining what your program spends its time doing)
is often a feature of the compiler itself, and to “profiling tools”
are often more concerned with the analysis of the output of the
compiler’s profiling featuire.
- gprof is part of GNU binutils (as is
ld
, so if you are programming
on Linux you likely already have this installed)
- flamegraph is an
interactive tool for exploring profiling data
Code Coverage
The most important use of code coverage tools is to figure out what
parts of your code are not yet covered by tests. Many coverage tools
use the same techniques as profilers, and often a single tool can do
both jobs.
- gcov
- gcov is included with GCC
- clang has a different, compatible, tool with the same name
Dynamic Analysis
These are tools which deduce problems with your program at runtime.
- Memory Access debugging
- Sanitizers
These are tools which inspect the operation of a program without
necessarily requiring source code for it.
- Program Tracing
- General-prupose
- dtrace led the way and primarily
targets FreeBSD and the Solaris family of operating systems.
- bpftrace
- lttng
- perf
- System-call tracing
- Library-function call tracing
- Synthetic Execution
- Valgrind suite; the analyzers described
below are all included.
- Memcheck is Valgrind’s default checker; it tells you if your
program’s execution depends on uninitialised values or your
pogram accesses memory it should not.
- Cachegrind analyses how your program interacts with a CPUs
cache and branch predictor
- Callgrind collects call-graph (which functions call which
other functions) data; you can visualize the result with
Kcachegrind.
- Threading issues
- Heap profiling
- Massif is a heap profiler (analyzes your program’s use of
heap and, optionally, stack)
- DHAT
Inspecting Things Other Than Programs
Sometimes you want to inspect the general state of your system or its
actions to figure out what is happening, as opposed to just inspecting
the actions of your program.
- Linux / Unix
- Brendan Gregg gave a good overview at LISA
2014
- These tools all have manual pages, so many of them don’t need
links.
- Network
- tcpdump works on many Unix-like
systems, sometimes with slight differences in filter syntax.
- wireshark provides an excellent
way to analyse packet dumps (generated by, for example,
tcpdump)
- netstat, ss, nstat
- CPU
- File System
- Windows
- I’m sure these exist, but I am not familiar with anything that
post-dates SoftICE.
- Embedded
- Embedded systems with a Linix kernel can take advantage of the
tools listed above.
- Bare-Metal
- Logic Analyzers
- Oscilloscopes
- In-Circuit (CPU) Emulators
- Bare-Metal debugging
- Multi-Function Analyzers
- Protocol Analyzers
- TCP/IP: You can do TCP/IP analysis on a separate
computer/device, for example tcpdump on a nearby Linux box.
You may need an Ethernet switch on which you can configure
port mirroring.
- USB: TotalPhase Beagle
- Multi-Purpose: HHD Device Monitor Studio