xfce4 debugging

# xfce4 debugging # Debugging Xfce Debugging crashing Xfce apps isn't terribly difficult, and can be a big help to Xfce developers when they're trying to fix bugs. If the problem you're having is a crash of a particular application, usually you'll want to get what's called a 'backtrace' or 'stack trace' using a debugger, such as gdb. ## What should I do first? First, check the [Xfce bug tracker](http://bugzilla.xfce.org/). Maybe someone has already seen this problem and done all the work for you. Or maybe they've seen the problem, but haven't provided any useful information yet. If that's the case, perhaps you could help out and add to their bug report. Next, be sure you can reproduce the problem. If you can't, it's going to be hard to get debug information. You'll need a debugger. The one I use most frequently is called gdb, and should be available on pretty much any distribution/OS where you can run Xfce. ## What caused the crash? The next task is to determine what's crashing. Here are some ways to determine what's going on: - All of Xfce (or X) crashed. - In this case, it's possible that Xfce was not at fault. Check the messages printed to console. If it was actually X itself that crashed, you'll want to report that elsewhere. - If, however, Xfce is at fault, it's likely a crash in xfce4-session. [Debugging xfce4-session](#xfce4-session) is a little bit more involved than other apps, since it's what's known as the 'session controlling app'. More about this later. - The borders around all my windows disappeared, and all my minimised windows are shown. - This is likely a crash in xfwm4. Since focusing particular windows is difficult without a window manager, [debugging xfwm4](#xfwm4) can be a little annoying. More about this later, as well. - The panel/app launcher/toolbar or taskbar disappeared. - This is [xfce4-panel](#xfce4-panel), or one of its built-in ['internal' plugins](#panel-internal), crashing. - One of the plugins/applets in my panel disappeared, but the panel is still running. - The panel is OK here, but one of its ['external' plugins](#panel-external) crashed. - The desktop background and/or icons disappeared. I also can't access the desktop's right-click or middle-click menus. - It looks like [xfdesktop](#xfdesktop) has crashed... maybe. Did you run another file manager, such as Nautilus? If so, please read [the FAQ](/projects/xfce4#faq). Otherwise, it's probably a crash. - I'm not sure that anything crashed, but my user interface theme went back to this ugly default, as did my fonts and icons. - It's possible that [xfce-mcs-manager](#xfce-mcs-manager) has crashed. - Some other thing happened. Application X was running, and disappeared from the screen. - Unfortunately, we probably can't help you. It seems like some non-Xfce application has crashed. You should report this to whomever writes/maintains that software. However, the debugging strategies below will probably still be useful to that person. ## What's a debug build? If you've submitted debugging information before, you might have been asked to recompile and use a debug build (or an unstripped build). Unfortunately, most distributions/OSes ship without debugging information in their binaries. While this decreases file size (often dramatically) and can increase performance to some (probably small) extent, it makes it very difficult to get useful debugging information. If it isn't possible for you to run a debug/unstripped build for some reason, please still try to follow the steps below. A stripped build may still yield some useful information to the developer, though they may end up asking you to use a debug build later on. To create a debug build, you'll need to recompile the software by hand, passing '--enable-debug=yes' to the configure script. ## So what do I do now? Well, now that you know what crashed, and that you hopefully have a debug build, you can try to help figure out why. The basic procedure is the same, but different applications may need to be handled in different ways. <>### xfce4-session 1. Quit Xfce (and X), and drop down to a normal console. 2. If you get a graphical login prompt, try pressing Alt+Ctrl+F1 to get a console. You may have to log in at this point, and you may have to stop your graphical login manager. Unfortunately, this is distribution/OS-dependent, so I probably can't help you. 3. From the console, run 'ulimit -c unlimited'. This will allow crashed applications launched from this console to leave behind 'core' files that help with debugging. 4. Next run 'startxfce4' to start Xfce. 5. Do what you did to make Xfce crash. 6. After dropping back to console, look for a file that starts with 'core'. In some cases this might be the word 'core' followed by a dot and then a number. If you have several of these files, check the dates. The one you're looking for should be the one with the most recent date. On some systems, the file name might be the name of the application, followed by a dot, and then the word 'core'. For reference, let's call this file $CORE. 7. Next we'll use the debugger. From the console, run 'gdb xfce4-session $CORE', substituting $CORE for the filename we found above. 8. gdb will spit out some text. If you get something asking you to press enter to continue, do so until you get a '(gdb)' prompt. 9. At this point gdb will say something about the app crashing. At the prompt, type 'bt' and press enter. 10. A lot of useful information should be printed out. If you need to press enter to get more screens of data, do so. Copy and paste this into a bug report. <>### xfwm4 1. Start Xfce. 2. Close all windows and applications. It's OK to leave the standard desktop apps running, like that panel. 3. Start a single terminal program, like Terminal or xterm. 4. Type 'ulimit -c unlimited' in the terminal 5. Type 'pkill xfwm4' in the terminal. At this point, your window borders should disappear. 6. So you can continue typing, keep the mouse cursor over the terminal window. Type 'xfwm4' in the terminal window. 7. Do whatever it was you did to make xfwm4 crash. If this means opening and interacting with an application, that's fine. Just try to keep the terminal window unobscured. 8. When xfwm4 crashes, move the mouse cursor over the terminal window, and type 'xfwm4 &' again to start it up and put it in the background. 9. In the terminal, look in the current directory for a core file. This file may simply be named 'core', or it might be called 'core', followed by a dot and some numbers. On some systems, it might be 'xfwm4.core'. If there are several files of this name, find the one with the date and time of when xfwm4 just crashed. 10. Type 'gdb xfwm4 $CORE' into the terminal, replacing '$CORE' with the filename you just found above. 11. Some text should scroll by. Press the enter key if you need to, until you come to a '(gdb)' prompt. There should be some information about xfwm4 crashing. 12. Type 'bt' at the prompt, and press enter until you get another prompt. Copy and paste all of this output into a bug report. <>### xfce4-panel 1. While Xfce is running, open a terminal. 2. If you are using Xfce 4.4, type 'xfce4-panel -x' to cause the panel to exit. If you are using Xfce 4.2, type 'pkill xfce4-panel' to kill it. 3. Start the panel again, but inside the debugger. Run 'gdb xfce4-panel'. 4. When you get the '(gdb)' prompt, type 'run'. The panel should start. 5. Do whatever you did to make the panel crash. Since the debugger will halt the panel when it crashes, the panel windows themselves will likely not disappear from the screen, though you will be unable to interact with them. 6. In the debugger, you should see another '(gdb)' prompt, and a message about the panel crashing. Type 'bt' at the prompt. 7. If the output is long, press enter several times to get it all. Paste this into a bug report. <>### Panel 'internal' plugins Since 'internal' panel plugins are actually run inside the panel process, you can debug this in exactly the same way as you would for [the panel itself](#xfce4-panel). <>### Panel 'external' plugins NB: This method will only work if you can successfully add the plugin to the panel without it crashing. If the act of adding the plugin to the panel causes it to crash, there isn't an easy way to debug it. 1. With the panel running, add the offending plugin back to the panel. It's easiest if you only have _one_ instance of the plugin in the panel when you're trying to debug this. 2. Open a terminal and find the PID (process ID) of the plugin process. Depending on your system, you can probably type 'ps eax' or simply 'ps e' to list all running processes. You can either manually look down the entire list, or use grep to try to find your plugin. A command like 'ps eax | grep xfce4-mailwatch' should find what you need. Obviously replace 'xfce4-mailwatch' above with the binary name of the crashing plugin. If you're not sure what that is, either look at the complete list, or dig around in /usr/lib/xfce4/panel-plugins/ to figure out what it's called. At any rate, the 3-, 4-, ot 5-digit number should be the plugin's process ID. Let's call it $PID. 3. Start the debugger and attach it to the running plugin process. Run 'gdb $PLUGIN_NAME $PID' in the terminal. Replace '$PLUGIN_NAME' with the binary name of the plugin, and '$PID' with the process ID found above. 4. The debugger should start, attach to the program, and eventually give you a '(gdb)' prompt. At this point, it has interrupted execution, so type 'continue' at the prompt. 5. Now go back to the panel, and reproduce the crash. Since the debugger will halt the program, the plugin shouldn't disappear from the panel, but you won't be able to interact with it anymore. 6. Go back to the debugger. There should be a message about the plugin crashing, followed by a '(gdb)' prompt. Type 'bt' at the prompt, and hit enter if there are several screens of output. Paste this output into a bug report <>### xfdesktop 1. With Xfce running, open a terminal. 2. If xfdesktop is running, kill it by typing 'xfdesktop --quit' in the terminal. If that doesn't work, type 'pkill xfdesktop'. (With xfdesktop 4.5.91 and later, the '--quit' option is required, otherwise xfdesktop will respawn itself automatically.) 3. Type 'gdb xfdesktop' into the terminal. 4. At the '(gdb)' prompt, type 'run'. 5. Try to reproduce the crash. When it does crash, the xfdesktop window and/or icons will not disappear, as gdb will halt the application. You will not be able to interact with the desktop anymore, though. 6. Go back to the debugger. There should be a message about xfdesktop crashing, followed by a '(gdb)' prompt. Type 'bt' at the prompt. The debugger will print out a bunch of data; press enter several times if there are multiple screens of data. Paste all this into a bug report. <>### xfce-mcs-manager 1. With Xfce running, open a terminal. 2. If xfce-mcs-manager is running, kill it by typing 'pkill xfce-mcs-manager' in the terminal. 3. Type 'gdb xfce-mcs-manager' into the terminal. 4. At the '(gdb)' prompt, type 'run --no-daemon-debug'. 5. Try to reproduce the crash. 6. Go back to the debugger. There should be a message about xfce-mcs-manager crashing, followed by a '(gdb)' prompt. Type 'bt' at the prompt. The debugger will print out a bunch of data; press enter several times if there are multiple screens of data. Paste all this into a bug report.   This document is not quite finished or polished. Please send any comments or suggestions to [Brian](mailto:kelnos@xfce.org). last modified 2 dec 2008 at 23:35.