In most cases it all works fine – when writing a linux driver you:
1. insert pr_debug()/dev_dbg() for debug messaging.
2. compile kernel with dyndbg enabled (CONFIG_DYNAMIC_DEBUG=y)
3. then just ‘echo‘ query strings or ‘cat‘ files with commands to switch on/off the debug messages at runtime. Examples:
echo -c 'file svcsock.c line 1603 +pfmt' > /dynamic_debug/control
- batch file:
cat query-batch-file > /dynamic_debug/control
When it’s all small – enabling/disabling the whole file or a function is not a problem. When the driver grows big with lots of debug messages or there are a few drivers interact with each other it becomes more convenient to have multiple configurations with certain debug lines on or off. As the source code changes the lines get shifted – and so, the batch files require editing.
If the target system (embedded or not) has network and a web browser (Apache2 + PHP) a quite simple solution is to add a web interface to the dynamic debug. The one we have developed has the following features:
- allows having multiple configurations for each file
- displays only files of interest
- updates debug configuration for modified files where debug lines got shifted
- keeps/updates the current config (in json format) in tmpfs – saves to disk on button click
- p, f, l, m, t flags are supported