GithubHelp home page GithubHelp logo

mchalupa / wldbg Goto Github PK

View Code? Open in Web Editor NEW
40.0 11.0 10.0 443 KB

Capture and debug/modify Wayland connections

License: MIT License

Shell 0.09% C 98.17% Makefile 1.10% M4 0.64%
wayland wayland-protocol

wldbg's Introduction

What is wldbg?

Wldbg is a tool that allows you to debug or modify events in Wayland connections. It works on the man-in-the-middle basis. When a Wayland client is run under wldbg, every message to or from the client is handed out to a pipeline of passes that can process the message. Passes are simple-to-write plugins. Wldbg has also an interactive gdb-like mode.

What is a pass?

The passes in wldbg are inspired by LLVM passes. A pass is a plugin that defines two functions - one for messages going from the client to the server and the another for messages from server to the client. It can analyze or arbitriraly modify the message and then pass the message to the next pass (or stop the whole pipeline) and so on..

Using passes

Run wldbg with passes is very easy, just type on command-line:

  $ wldbg pass1 ARGUMENTS, pass2 ARGUMENTS -- wayland-client

pass1 and pass2 are names of the passes without .so extension (i. e. dump.so ~~> dump)

If you do not know what passes are available, use:

  $ wldbg list

To get better understanding how it works, there's an example pass in passes/example.c. This pass is also compiled by default, so you can try it out as follows:

  $ wldbg example -- wayland_client

Using the interactive mode

To run wldbg in the interactive mode, just do:

  $ wldbg -i wayland-client

If everything goes well, you'll see:

  Stopped on the first message
  C: [email protected]_registry(new id wl_registry@2)
  (wldbg)

wldbg is now waiting for your input. By typing 'c' or 'continue', the program will continue running. Other usefull commands are:

'help'                    -- show help message
'help COMMAND'            -- show help to COMMAND
'b' or 'break'            -- stop running on specified messages
    b id 10                   --> stop on messages with id 10
    b re REGEXP               --> stop on any message matching regexp)
'i' or 'info'             -- show information about running state
    i b(reakpoints)           --> info about breakpoints
    i objects                 --> info about objects
    i proc                    --> info about process
'autocmd'                 -- run command after messages of intereset
    autocmd add RE CMD        --> run CMD on every message matching RE
    autocmd add '' i o        --> display info about objects after every message
'h' or 'hide              -- hide specified messages matching REGEXP, e. g.:
    h wl_pointer.*            --> hide everything for/from wl_pointer
    h wl_display@.*done       --> hide done messages from wl_display
'so' or 'showonly'        -- show only messages matching REGEXP
    so wl_display.*done       --> show only wl_display.done event
's' or 'send'             -- send message to client/server (in wire format)
'e' or 'edit'             -- edit message that we stopped at
'q' or 'quit'             -- exit wldbg

When wldbg is run with -g (-objinfo) option, it gathers information about objects. User then can just type:

(wldbg) i o ID

where ID is the id of the object of interest and wldbg will dump information it gathered about it. NOTE: this is new and incomplete feature. At this moment wldbg gathers information about xdg_surface, wl_surface and wl_buffer objects.

Ctrl-C interrupts the program and prompts user for input.

Using server mode

Wldbg can run in the server mode in which every new connection is redirected to wldbg and only then to the Wayland compositor. Upon the first connection, the user is prompted for an action, every other connection is then connected automatically without stopping. The server mode is interactive, so everything that works in the interactive mode, works in the server mode too. To start wldbg in the server mode, use the -s switch:

$ wldbg -s
Listening for incoming connections...

when client connects, you'll see something like:

Stopped on the first message
[weston-terminal: 7874] C: [email protected]_registry(new id wl_registry@2)

After another client is connected, the messages from both are just interleaved:

[weston-terminal |7874] S: [email protected](2739198098, 197.000000, 142.000000)
[weston-terminal |7874] S: [email protected]()
[weston-dnd      |7930] S: [email protected]()
[weston-dnd      |7930] S: [email protected](166, wl_surface@14)
[weston-dnd      |7930] S: [email protected]()
[weston-terminal |7874] C: [email protected](wl_buffer@17, 0, 0)
[weston-terminal |7874] C: [email protected](0, 0, 9, 16)
[weston-terminal |7874] C: [email protected]()

Server mode is handy, for example, for debugging the interaction between two clients, like two weston-dnd instances dragging and dropping between them.


An active development of Wldbg stopped some years ago, but it still should work. There are features missing and probably some bugs, but the features described above should mostly work.

Author: Marek Chalupa [email protected]

wldbg's People

Contributors

carlosolmedo avatar jamespthomas avatar mchalupa avatar tomeuv avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

wldbg's Issues

do not leak private symbols

currently we leak at least these:

0000000000000dc7 T wldbg_ids_map_get
0000000000000d10 T wldbg_ids_map_init
0000000000000d40 T wldbg_ids_map_insert
0000000000000d28 T wldbg_ids_map_release

add file with exported symbols and make linker use it

Add server mode

Sit on wayland (named) socket and catch every connection. Prompt user (in interactive mode) if she wants to accept the connection and if yes, then accept the socket and use this connection.

In the first release, this is supposed to just let one client to connect, i. e. the behavior will be the same as now, but instead of spawning client given on command line, it will wait for the client on the socket.
Later there should be support for multiple clients (right in wldbg - both in passes or in interactive).

Give better help message with wrong break

(wldbg) break xdg_surface@configure
Unknown interface

write out: wait until resolve pass registers this interface
until (if ever) we have pending breakpoints

Add command that will continue until registry.global and bind are processed (thus the client is initialized)

add shortcuts for some filters

For example:
hide _mess will hide wl_pointer@motion, wl_callbacks' and wl_display@delete_id
showonly _events would show only wl_seat's and its child's events (without wl_pointer@motion)
showonly _events_with_motion -- " -- with motion

enhance edit command

Add in-line message editing, I would really use that...

also print the message after editing, so that we know what we are sending (the same as for send command)

add translation pass

Translate messages so that they behave like from another interface, i. e.
wl_pointer -> wl_touch (mouse would behive like touch)

It is tricky and the pass will have to create it's own globals and announce it when server announces them, but it is possible :)

objinfo bugs + enhancements

--- bugs ---

  • destroying wl_subsurface leads to error message about not having that object

--- adds ---

  • track role of surfaces
  • wl_surface damage
  • wl_subsurface interface (sync/desync, position, etc., pending state)

Add multi-client mode

Enable running more than one client (either directly or catched in server mode). Expected output for interactive mode (or dump):

[weston-terminal] S: wl_pointer@motion(...)
[weston-terminal] S: wl_pointer@motion(...)
[Xwayland] ............. S: wl_compositor@...
[weston-terminal] S: wl_pointer@motion(...)
[Xwayland] ........... S: wl_surface@...
[Xwayland] ............ S: wl_surface@...

check licence

wayland & weston are changing licence. Should we follow them?

WL_DATA_DEVICE_MANAGER_* undeclared

I'm trying to build wldbg on an ubuntu 14.04 but it failed:

$ make
make all-recursive
make[1]: Entering directory /build/zakaria/wayland/tools/wldbg' Making all in src make[2]: Entering directory/build/zakaria/wayland/tools/wldbg/src'
CC print.lo
print.c: In function 'print_actions':
print.c:389:13: error: 'WL_DATA_DEVICE_MANAGER_DND_ACTION_NONE' undeclared (first use in this function)
if (act == WL_DATA_DEVICE_MANAGER_DND_ACTION_NONE) {
^
print.c:389:13: note: each undeclared identifier is reported only once for each function it appears in
print.c:395:12: error: 'WL_DATA_DEVICE_MANAGER_DND_ACTION_COPY' undeclared (first use in this function)
if (act & WL_DATA_DEVICE_MANAGER_DND_ACTION_COPY) {
^
print.c:400:12: error: 'WL_DATA_DEVICE_MANAGER_DND_ACTION_MOVE' undeclared (first use in this function)
if (act & WL_DATA_DEVICE_MANAGER_DND_ACTION_MOVE) {
^
print.c:405:12: error: 'WL_DATA_DEVICE_MANAGER_DND_ACTION_ASK' undeclared (first use in this function)
if (act & WL_DATA_DEVICE_MANAGER_DND_ACTION_ASK) {
^
make[2]: *** [print.lo] Error 1
make[2]: Leaving directory /build/zakaria/wayland/tools/wldbg/src' make[1]: *** [all-recursive] Error 1 make[1]: Leaving directorybuild/zakaria/wayland/tools/wldbg'
make: *** [all] Error 2

allow removing filters

we can filter messages, but we cannot stop filtering messages. Also add info filters command

SIGBUS in gtk applications

wldbg closes some fd that gtk tries to map afterwards

  1. run gtk3-demo (or other gtk app) in wldbg
  2. select something, drag it

Add message parser

Factor out common code for parsing raw messages and make it available to the user, so that he/she can use it in a pass (and we can use it throughout the code base). Something like:

struct parsed_message *pm = parse_message(message->data);

pm->id
pm->object

args_iterator(pm, ...)
arg_handle

assertion failed on EGL applications

wldbg failed to start when launching with an EGL Wayland application "weston-simple-egl",
but it works fine for shm ones.

$ wldbg example -- weston-simple-egl
...
...
weston-simple-egl: /project/build/bazoka/tmp/work/corei7-64-poky-linux/weston/1.8.0-r0/weston-1.8.0/clients/simple-egl.c:399: create_surface: Assertion `0' failed.
-- Destroying example pass

interactive: modify filters functioning

When you have filters active and use next command, one would expect that we'll stop on next message that is not suppressed by filter, but we stop on the very next message, we just don't display it

filter command: fix parsing id's

filter takes as id anything that starts with a number (probably atoi?) use str_to_uint

(wldbg) f d 1e
Didn't find filter with id '1'

0-length messages bug

When we get message of length 4096, the last message may have size for example 40, but in the buffer there's only 12 bytes.

(Actually, isn't that a bug in wayland? Wayland sends always whole events... - anyway, without wldbg the client works, but running wldbg leads to crash)

How to reproduce: run wldbg -i shotwell (current as of writing) and drag an image (there's bug in wldbg that will lead to sending full-length buffers)

add pending breakpoints

add signal new_id to resolve pass, so that anything can listen to that and react. Interactive then could implement pending breakpoints

store information about alive objects

basically something like weston-info. Currently resolve can only store interface. We could store versions and names of globals and more! Information about xdg_surfaces (current size and buffer size and states). Wild idea is catching buffers (fds) and letting user to look into the contents (store to file to investigate) - wild but possible :)

running non-wayland programs is buggy

Running X clients via wldbg is possible. Either disallow it or fix the bug

info objects -> SIGSEGV (connection is NULL)
info connection -> program: wldbg (that is wrong, it should be name of the client)

add command line option -n and -t

stands for numbers and times - that is print number of message or timestamp, for better orientation. And some option to skip first query, since it is needed when debuggin in interactive mode

SIGSEGV in resolve

Run:

GDK_BACKEND=wayland wldbg -i gtk3-demo and then select some text and try to drag it. I think it is in get_new_id function, because the id returned is some garbage...

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.