Jump to content

KWin/Debugging

From KDE Community Wiki
Revision as of 16:18, 19 June 2015 by Luebking (talk | contribs) (Created page with "= Debug & log KWin (or any process) via gdb = While interacting with gdb, the debugged process is stopped - that's of course nasty if the debugged process is what paints what ...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Debug & log KWin (or any process) via gdb

While interacting with gdb, the debugged process is stopped - that's of course nasty if the debugged process is what paints what you see. Therefore it's inevitable to debug KWin from a side-channel, eg. another VT or via ssh - depending on what's available on your system.

NOTICE that debugging from a ssh login is generally preferable, since it doesn't impact the framebuffer/scanout buffer state.

gdb says "ptrace: Operation not permitted."

This is a security feature in "newer" linux kernels - you must explicitly allow gdb to attach to a non-inferior process:

echo 0 | sudo tee /proc/sys/kernel/yama/ptrace_scope

Do I have to write down the debug output by hand ????

No ;-)

You just copy the gdb output into a file.

gdb --pid `pidof kwin_x11` 2>&1 | tee kwin.gdb

I don't know nothing about gdb, how do I obtain a stacktrace?

After attaching to the process, you likely want to cause a certain condition (halt or crash) - in that case you first need to

continue

the process.

If kwin does not crash, but you want to inspect the stack at some other time, you firt need to interrupt the process, press

Ctrl+C

To dump a stacktrace, issue

bt

then hit the

Enter

key until you reach the end of the stack.

Sometimes, you may want to see what's in another thread

thread 2
bt
thread 3
bt

Finally, to leave gdb thread 2

detach
quit