Re: how to add some log in mutter?

On Fri, Oct 11, 2019 at 06:55:42PM +0800, Halley Zhao via gnome-shell-list wrote:
Hi experts:
I want to debug somthing in mutter, the question is how to add log in

the background is:
on my platform(fc30), weston-simple-dmabuf-drm fail to run, it fails after
call zwp_linux_buffer_params_v1_create().
after export WAYLAND_DEBUG=1, I don't get clue.
(create_dmabuf_buffer, 711)
(create_dmabuf_buffer,723)format: XR24, width: 256, height: 256, flags: 0x0
Error: zwp_linux_buffer_params.create failed.
Error: zwp_linux_buffer_params.create failed.
Error: zwp_linux_buffer_params.create failed.
then I decide to add some log in mutter to see where is the fail.
since is loaded by gnome-shell in the background, I try to
write my debug log to disk file. but when I add some log in dma_buf_bind(),
it doesn't take effect. why?
what's the correct way to add log in mutter?

You should be able to use e.g.

    fprintf (stderr, "Log this message\n");


    g_message ("Log this message");


    g_warning ("Log this warning");

If you run gnome-shell or mutter from GDM, the log entries will end up
in the journal. You can look in the journal with for example

    journalctl -e $(which gnome-shell)

If you run mutter or gnome-shell manually from a tty, it's easiest to
run and reroute stdout and stderr directly to a file, e.g mutter >&

If your added log entries doesn't show up even though you are sure the
functions where you added your log entries were called, then double
check that the libmutter you compiled yourself is the one used by the
executable when you run.



here are code piece to add log:
static void _my_print_test_log(const char* file_name)
    FILE* _tmp_fp = NULL;
    _tmp_fp = fopen(file_name, "w+");
    if (_tmp_fp) {
      fprintf(_tmp_fp, "#### my test ####");

static void
dma_buf_bind (struct wl_client *client,
              void             *data,
              uint32_t          version,
              uint32_t          id)
  MetaWaylandCompositor *compositor = data;
  struct wl_resource *resource;

  resource = wl_resource_create (client, &zwp_linux_dmabuf_v1_interface,
                                 version, id);
  wl_resource_set_implementation (resource, &dma_buf_implementation,
                                  compositor, NULL);


  send_modifiers (resource, DRM_FORMAT_ARGB8888);
  send_modifiers (resource, DRM_FORMAT_XRGB8888);
  send_modifiers (resource, DRM_FORMAT_ARGB2101010);
  send_modifiers (resource, DRM_FORMAT_RGB565);

gnome-shell-list mailing list
gnome-shell-list gnome org

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]