Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revisionNext revisionBoth sides next revision | ||
howto:panel_plugin_debug [2007/12/09 20:25] – nowiki syntax 88.172.125.130 | howto:panel_plugin_debug [2012/06/22 18:28] – landry | ||
---|---|---|---|
Line 1: | Line 1: | ||
====== Panel Plugin Debugging ====== | ====== Panel Plugin Debugging ====== | ||
+ | Debugging **external** panel plugins is possible by wrapping the executable against a shell script that runs a debug tool. | ||
- | An easy way to debug an external | + | The exec command is available inside the desktop entry file that is shipped with every panel plugin. |
- | | + | So, this lets you quite some possibilities to wrap an external panel plugin. |
- | installed) rename the panel binary named foo-plugin to foo-plugin.real | + | |
- | * create an executable shellscript named foo-plugin | + | In the examples below we will use the first method that consists into creating a new desktop entry file. We will use as example a plugin called "'' |
- | containing : | + | |
+ | ===== Debug with Valgrind (full example) ===== | ||
+ | |||
+ | | ||
+ | |||
+ | cp /usr/local/share/ | ||
+ | / | ||
+ | |||
+ | * Edit the new file and change the Name= key to differentiate it from the original | ||
+ | * Change the Exec= key to point it to the shell script (remember the original path, you need it for the shell script) | ||
+ | * Create an **executable** shell script | ||
#!/bin/sh | #!/bin/sh | ||
- | valgrind --log-file=/ | + | valgrind --log-file=$HOME/clipman-valgrind.log \ |
+ | | ||
+ | |||
+ | * Now you can add the plugin " | ||
+ | * You are able to use < | ||
+ | |||
+ | {{wiki: | ||
+ | |||
+ | === More useful call to Valgrind === | ||
+ | |||
+ | G_SLICE=always-malloc G_DEBUG=gc-friendly valgrind --tool=memcheck --leak-check=full \ | ||
+ | --show-reachable=yes -v --log-file=$HOME/ | ||
+ | / | ||
+ | |||
+ | ===== Debug with GDB (short example) ===== | ||
+ | If you didn't read the example about Valgrind, do so, it contains mandatory information if you don't understand the following example. | ||
+ | |||
+ | * Make a copy of the desktop entry file | ||
+ | |||
+ | cp / | ||
+ | / | ||
+ | |||
+ | * Change the Exec= key to point it to the shell script (remember the original path, you need it for the shell script) | ||
+ | * Create an **executable** shell script containing: | ||
+ | |||
+ | #!/bin/sh | ||
+ | gdb -ex r -ex bt -ex continue -ex q --args / | ||
+ | > $HOME/ | ||
+ | |||
+ | === Using GDB on running instances === | ||
+ | |||
+ | If you want an interactive debug session with GDB, you can simply find the process id of the plugin by running | ||
+ | |||
+ | $ gdb / | ||
+ | ... | ||
+ | (gdb) continue | ||
+ | |||
+ | which will find the PID of clipman, and debug it using the debug symbols in / | ||
+ | |||
+ | (gdb) attach $PID | ||
+ | |||
+ | Again, the plugin must already be loaded for this to work. | ||
+ | |||
+ | ===== Temporarily capturing messages to stdout and stderr ===== | ||
+ | |||
+ | * Add the plugin to the panel | ||
+ | * Exit the panel: | ||
- | | + | |
- | Note. It'll be really slow as wrapped in valgrind, but you'll be able to hunt memory leaks using tail -f / | + | |
+ | * Start panel capturing stdout and stderr to file. Note that this will capture all messages from the panel, including all plugins, to ' | ||
- | ==== Alternative way ==== | + | $ xfce4-panel > file 2>&1 & disown |
- | Edit your .desktop file of the plugin (for most easy results, directly in the source directory) and append .valgrind to the xfce-exec line. Then create a file like described above, but named xfce4-my-plugin.valgrind in the same location. It will never ever be overwritten by any of your subsequent installations, | + | |
- | Pay attention to edit the xfce-exec line before checking into subversion or making a release. | + | * When done capturing, exit the panel and start it again: |
- | ==== More senseful call to Valgrind ==== | + | $ xfce4-panel -x |
+ | $ xfce4-panel & disown | ||
- | '' | + | ====== Some tips ====== |
+ | * By creating your own desktop entry file, it will never get overwritten by any installation, | ||
+ | * You can point the Exec= key to your development directory, for instance | ||