Changes between Version 29 and Version 30 of Debugging
- Timestamp:
- 12/11/13 10:44:20 (9 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
Debugging
v29 v30 1 {{{#!div class="box" 1 2 = Debugging = 2 3 … … 7 8 * [/wiki/WindowRefresh Window Refresh] 8 9 10 * [/wiki/Debugging/VisualStudio Debugging using Visual Studio] 11 * [/wiki/Debugging/OpenGL OpenGL Debugging] 12 13 [[BR]] 14 9 15 == First Things == 10 16 Always try to narrow it down as much as possible, by turning off as many features as possible (clipboard, etc) and trying various encodings. … … 13 19 If a debug build is available, please use it. It may provide more useful diagnostic messages. 14 20 You can generate debug builds by calling {{{setup.py}}} with the {{{--with-debug}}} flag (or by setting {{{DEBUG=1}}} in the MS Windows [/browser/xpra/trunk/src/win32/MAKE-INSTALLER.BAT BAT file]) 15 16 [[BR]] 17 18 ---- 21 }}} 19 22 20 23 24 {{{#!div class="box" 21 25 == Via Logging == 22 26 Sometimes the problem is so obvious that you will simply get the error directly from the command line or in the server log file. … … 40 44 * {{{XPRA_X11_LOG}}} (enables logging for X11 events) 41 45 * {{{XPRA_X11_DEBUG}}} (logs all X11 events through going through our loop - this is very verbose) 46 }}} 42 47 43 48 49 {{{#!div class="box" 44 50 == Other Environment Variables == 45 51 There are other environment variables which can be used to tune the behaviour of the system and may be used for debugging or testing, you can obtain the full list with: 46 52 {{{ 47 53 grep 'os.environ' src/xpra 48 grep 'os.environ' src/wimpiggy49 54 }}} 50 55 Notably: … … 58 63 * use PIL for parsing png and jpeg packets (on/off): {{{XPRA_USE_PIL}}} 59 64 Please refer to the actual code for details. 60 61 [[BR]] 65 }}} 62 66 63 67 64 ---- 65 66 68 {{{#!div class="box" 67 69 == Network Traffic == 68 70 … … 73 75 The packet type is the first thing in each packet and it is a simple string which makes it easy to observe traffic. 74 76 With version 0.9 onwards, it is best to set {{{XPRA_USE_ALIASES=0}}} to ensure that the packets will use plain-text headers rather than numeric aliases. 75 76 [[BR]] 77 }}} 77 78 78 79 80 {{{#!div class="box" 79 81 == xtrace == 80 82 (X11 traffic) … … 101 103 xtrace xpra attach .. 102 104 }}} 105 }}} 103 106 104 107 105 ---- 106 107 108 {{{#!div class="box" 108 109 == GDB == 109 110 When dealing with crashes ("core dumped"), the best way to debug is to fire gdb. … … 119 120 Then once you get a crash, gdb should show you its prompt again and you can extract the python stacktrace with {{{py-bt}}} and the full stacktrace with {{{bt}}}. Having both is useful. 120 121 Note: installing the required "debug" symbol packages for your distribution is out of scope, please refer to your vendor's package manager for details (ie: [http://wiki.debian.org/HowToGetABacktrace debian] and [http://yum.baseurl.org/wiki/YumUtils/DebugInfoInstall yum debuginfo-install]). 122 }}} 121 123 124 125 {{{#!div class="box" 122 126 === X11 errors === 123 127 Occasionally you may encounter an X11 crash ({{{BadDrawable}}}, {{{BadWindow}}}, etc). These are more tricky. You may need to set a breakpoint: … … 137 141 In this case, we may want to force all X11 calls to be synchronized (which will hurt performance and may even hide the bugs - beware of heisenbugs!), trace all X11 calls, etc. 138 142 [/attachment/wiki/Debugging/error.py this modified error.py] allows you to do just that (see the constants at the top). 143 }}} 139 144 140 145 141 ---- 146 {{{#!div class="box" 147 == Venerable Print Statements == 148 When all else fails, or just when appropriate, sprinkling some {{{print}}} statements around the critical sections of code is often the best way to get a clearer picture of what is really going on.. 149 }}} 142 150 143 151 144 == Venerable Print Statements == 145 When all else fails, or just when appropriate, sprinkling some {{{print}}} statements around the critical sections of code is often the best way to get a clearer picture of what is really going on.. 146 147 148 ---- 149 150 152 {{{#!div class="box" 151 153 == Memory Leaks == 152 154 … … 162 164 * [http://stackoverflow.com/a/1641280/428751 simple leak code] 163 165 * [http://code.activestate.com/recipes/65333/ Debug with garbage collection recipe] 164 165 166 ----167 168 169 == Debugging in Windows ==170 171 === Using Microsoft Visual Studio Express ===172 173 You will need to create a new, empty project (File->New->Project), select "General" and "Empty Project". Visual Studio will require a name for the project and will ask for a place to save it.174 This project will contain nothing but basic information to start Xpra with the debugger, so save it somewhere for later use.175 176 You will be placed in the tree, containing the "Solution" and the project you've created. Right click on the project in the tree and select "properties".177 178 Go to "Debugging", in fill in the fields to attach your Xpra client - example below.179 180 [[Image(screenshot_1363196248.jpg)]]181 182 Then you can do F5 to start the application with the debugger.183 184 Alternatively, if you set "Attach" to yes, the debugger will ask you to what running process you want to attach upon pressing F5.185 186 ---187 188 == OpenGL ==189 190 Whenever you encounter problems with client-side OpenGL rendering, for example with OpenGL error messages, crashes, or visual artifacts, there are some specific steps to take to investigate. The *Apitrace* tool will get a dump of the OpenGL command stream, allowing it to be sent to the developers for replaying and investigation.191 192 === Installation of Apitrace ===193 194 ==== On Linux ====195 196 Download [https://github.com/apitrace/apitrace Apitrace], build it according to the documentation: [https://github.com/apitrace/apitrace/blob/master/INSTALL.markdown]197 198 ==== On Windows ====199 200 You can use pre-built binaries found at [http://people.freedesktop.org/~jrfonseca/apitrace/]201 Try to always use the latest version and fallback to an older one if it doesn't work.202 203 === Trace generation ===204 205 This trace will enable you to replay the actions of the client without having to re-run it; giving you additional error tracing, ability to send the trace to another person, and ability to replay the exact same steps every time.206 207 Use as follows:208 {{{209 $ apitrace trace xpra attach <your regular commandline>210 166 }}} 211 - Do whatever is needed to reproduce the issue you are experiencing. Beware: Apitrace is keeping a copy of everything you do in RAM, it's going to be huge, so don't run the session for too long, and focus on reproducing one issue at a time.212 - Exit Xpra when done213 {{{214 $ qapitrace215 }}}216 File -> load the trace217 Then go to Trace -> Replay and check both boxes218 219 Apitrace will replay your trace and report in the bottom panel any errors it found, with additional explanation as compared to what the GL driver typically gives.220 221 Be ready to send the .trace file to the developers for further investigation.