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

« back to all changes in this revision

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

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