~ubuntu-branches/ubuntu/trusty/xorg/trusty-updates

« back to all changes in this revision

Viewing changes to xsf-docs/howto/use-gdb.txt

  • Committer: Bazaar Package Importer
  • Author(s): Timo Aaltonen, Bryce Harrington, Timo Aaltonen
  • Date: 2011-06-14 15:39:40 UTC
  • mfrom: (6.3.18 sid)
  • Revision ID: james.westby@ubuntu.com-20110614153940-b9i0fr1v2kchiozh
Tags: 1:7.6+7ubuntu1
* Merge from Debian unstable, remaining changes:
  - Add apport hook
  - Demote xfonts-{75DPI,100DPI} to Suggests. Demote xfonts-scalable to
    Recommends.
  - debian/local/Xsession:
    Truncate xsession-errors on startup if too big
  - debian/local/Xsession.d/20x11-common_process-args:
    Add support for session command containing args.
  - debian/local/Xsession.d/60x11-common_localhost:
    Authorise all processes running with the user's credentials to connect
    to the server.
  - debian/rules, debian/control:
    Add dependencies on x11-common, and symlink /usr/share/doc directories
    of all packages to x11-common's.
  - debian/scripts/vars.*:
    + Don't drop wacom from input-all.
    + Add -vmmouse to input-all for amd64 and i386.
    + Add -qxl to video-all for amd64 and i386.
    + Add -geode to video-all for i386.
    + Drop video drivers that are likely irrelevant for ARM.
  - debian/xserver-xorg.postinst.in: Also migrate users from psb → vesa.

[ Bryce Harrington ]
* apport/source_xorg.py:
  - Move Failsafe-X out of the xorg package to xdiagnose
    (LP: #480744)
  - Simplify answers for bug reporters filing post-release reports.
    (LP: #778758)
  - Remove attach_drm_info().  This is useful info but we use it very
    infrequently, and it is already available in other log files.  But the
    call makes bug reports a bit cluttered since it adds a lot of lines to
    the report itself.

[ Timo Aaltonen ]
* rules: A stampfile generation was commented out by mistake, uncomment
  it.
* Rework the x11-common.{postinst,postrm,preinst} failsafe conffile
  handling, the previous ones added in 1:7.6+4ubuntu1 were wrong too.
* scripts/vars.{amd64,i386,powerpc}: Remove apm, ark, chips, i128, i740,
  rendition, s3virge, tseng, voodoo from xserver-xorg-video-all
  dependencies. They are unmaintained and obsolete.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
How to use gdb
 
2
==============
 
3
:toc:
 
4
Cyril Brulebois <kibi@debian.org>
 
5
 
 
6
 
 
7
Foreword
 
8
--------
 
9
 
 
10
One should note that X is responsible for VT switching, meaning
 
11
switching between an X session and console terminals. In other words,
 
12
`Ctrl+Alt+Fn` is handled by X. If X is stopped, for example because
 
13
it’s running under `gdb`, one can no longer switch to another
 
14
VT. That’s why we’re recommending using a second machine to debug
 
15
X. Nevertheless, here are some instructions to attempt debugging X
 
16
with a single machine.
 
17
 
 
18
One-machine approach
 
19
~~~~~~~~~~~~~~~~~~~~
 
20
 
 
21
This is a _post-mortem_ approach. The idea is to run X with the
 
22
`-core` option. Once it dies, a core file (`/etc/X11/core`) is
 
23
generated, and can be loaded from `gdb`.
 
24
 
 
25
Follow these steps:
 
26
 
 
27
 1. Getting a core file.
 
28
 2. Loading a core file.
 
29
 3. Displaying/saving a backtrace.
 
30
 
 
31
Two-machine approach
 
32
~~~~~~~~~~~~~~~~~~~~
 
33
 
 
34
You pay the “need a second machine” price, but that buys you
 
35
interactivity. Just log into the first machine from the second one,
 
36
using `ssh`.
 
37
 
 
38
Follow these steps:
 
39
 
 
40
 1. Attaching/Starting X from gdb.
 
41
 2. Displaying/saving a backtrace.
 
42
 
 
43
Needed packages
 
44
~~~~~~~~~~~~~~~
 
45
 
 
46
Obviously, `gdb` is needed; `xserver-xorg-core-dbg` contains the
 
47
debugging symbols for the server itself. Other needed packages can be
 
48
determined by looking at the backtrace. **FIXME: More info about
 
49
that.**
 
50
 
 
51
 
 
52
<<<
 
53
Actual gdb work
 
54
---------------
 
55
 
 
56
Getting a core file
 
57
~~~~~~~~~~~~~~~~~~~
 
58
 
 
59
 * Using `gdm3`: The idea is to tweak the daemon’s
 
60
   `LocalXserverCommand` setting, adding the `-core` option. As of
 
61
   `gdm3 2.30`, the defaults can be found in
 
62
   `/usr/share/gdm/gdm.schemas`. Sample `/etc/gdm3/daemon.conf`
 
63
   excerpt:
 
64
 
 
65
----
 
66
[daemon]
 
67
LocalXserverCommand=/usr/bin/Xorg -br -verbose -audit 0 -novtswitch -core
 
68
----
 
69
 
 
70
 * Using `kdm`: One should look for the `ServerArgsLocal` variable in
 
71
   the `/etc/kde4/kdm/kdmrc` file, and add `-core` there. Example:
 
72
 
 
73
----
 
74
ServerArgsLocal=-br -nolisten tcp -core
 
75
----
 
76
 
 
77
 * Using `xdm`: It’s sufficient to add `-core` to the command
 
78
   configured through `/etc/X11/xdm/Xservers`, for example:
 
79
 
 
80
----
 
81
:0 local /usr/bin/X :0 vt7 -nolisten tcp -core
 
82
----
 
83
 
 
84
Loading a core file
 
85
~~~~~~~~~~~~~~~~~~~
 
86
 
 
87
That’s trivial, one just needs to pass both the core file and the path
 
88
to the binary:
 
89
 
 
90
----
 
91
# gdb -c /etc/X11/core /usr/bin/Xorg
 
92
----
 
93
 
 
94
Now `gdb` is ready to display backtraces.
 
95
 
 
96
Attaching X from gdb
 
97
~~~~~~~~~~~~~~~~~~~~
 
98
 
 
99
The way of starting X doesn’t really matter, as `gdb` makes it
 
100
possible to attach a running process. If there’s a single X instance
 
101
running, that will do the job:
 
102
 
 
103
----
 
104
# gdb attach $(pidof X)
 
105
[---GDB starts---]
 
106
(gdb) handle SIGPIPE nostop
 
107
(gdb) cont
 
108
----
 
109
 
 
110
If there are several instances, one can use `ps aux` to determine the
 
111
PID of the appropriate instance (2nd column → `$pid`), and then attach
 
112
it:
 
113
 
 
114
----
 
115
# gdb attach $pid
 
116
[---GDB starts---]
 
117
(gdb) handle SIGPIPE nostop
 
118
(gdb) cont
 
119
----
 
120
 
 
121
Starting X from gdb
 
122
~~~~~~~~~~~~~~~~~~~
 
123
 
 
124
In case X crashes at start-up, one can start X from `gdb` in the
 
125
following way. In this example, the only parameter is the display, but
 
126
more parameters can be added.
 
127
 
 
128
----
 
129
# gdb --args Xorg :0
 
130
[---GDB starts---]
 
131
(gdb) handle SIGPIPE nostop
 
132
(gdb) run
 
133
----
 
134
 
 
135
What is SIGPIPE?
 
136
~~~~~~~~~~~~~~~~
 
137
 
 
138
`SIGPIPE` is a signal that can reach the X server quite easily,
 
139
especially when performing a VT switch, or refreshing large parts of
 
140
the screen. That’s why we ask `gdb` not to stop when such a signal is
 
141
caught, thanks to the `handle SIGPIPE nostop` command.
 
142
 
 
143
How to display a backtrace?
 
144
~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
145
 
 
146
Once X is crashed, for example because it received a `SIGSEGV`
 
147
(segmentation fault, usually because of a NULL pointer dereference),
 
148
or a `SIGBUS`, one gets back to the `gdb` prompt. One can then request
 
149
a backtrace (`bt`) or a full backtrace (`bt full`). The latter is what
 
150
developers are usually interested in, because variable values are also
 
151
available.
 
152
 
 
153
----
 
154
(gdb) bt
 
155
(gdb) bt full
 
156
----
 
157
 
 
158
How to save a backtrace?
 
159
~~~~~~~~~~~~~~~~~~~~~~~~
 
160
 
 
161
To save a recording of the gdb session to a file (`gdb.txt` by
 
162
default):
 
163
 
 
164
----
 
165
(gdb) set logging on
 
166
----
 
167
 
 
168
To save in a different file, use this instead:
 
169
 
 
170
----
 
171
(gdb) set logging file my-file.txt
 
172
(gdb) set logging on
 
173
----
 
174
 
 
175
Once logging is enabled, you can request a (full) backtrace using the
 
176
previous commands.