Commit f4593d39 authored by Jeremy White's avatar Jeremy White Committed by Frediano Ziglio

Make some debug facilities be available at run time.

This is nice for helping users with a fixed binary,
so they do not have to recompile to generate forensics.
Acked-by: Frediano Ziglio's avatarFrediano Ziglio <fziglio@redhat.com>
parent 21c9b068
......@@ -27,6 +27,7 @@
#include <stdlib.h>
#include <stdio.h>
#include <stdarg.h>
#include <glib.h>
......@@ -81,10 +82,10 @@ static void handle_cursor_notify(display_t *display,
int imglen;
uint32_t *imgdata;
#if defined(DEBUG_DISPLAY_EVENTS)
g_debug("Cursor Notify [seq %d|subtype %d|serial %u]",
cev->sequence, cev->subtype, cev->cursor_serial);
#endif
if (display->session->options.debug_draws >= DEBUG_DRAWS_BASIC) {
display_debug("Cursor Notify [seq %d|subtype %d|serial %u]\n",
cev->sequence, cev->subtype, cev->cursor_serial);
}
icookie = xcb_xfixes_get_cursor_image(display->c);
......@@ -136,13 +137,13 @@ static void handle_damage_notify(display_t *display, xcb_damage_notify_event_t *
display->fullscreen_damage_count = 0;
}
#if defined(DEBUG_DISPLAY_EVENTS)
g_debug("Damage Notify [seq %d|level %d|more %d|area (%dx%d)@%dx%d|geo (%dx%d)@%dx%d%s",
dev->sequence, dev->level, dev->level & 0x80,
dev->area.width, dev->area.height, dev->area.x, dev->area.y,
dev->geometry.width, dev->geometry.height, dev->geometry.x, dev->geometry.y,
display_trust_damage(display) ? "" : " SKIPPED");
#endif
if (display->session->options.debug_draws >= DEBUG_DRAWS_BASIC) {
display_debug
("Damage Notify [seq %d|level %d|more %d|area (%dx%d)@%dx%d|geo (%dx%d)@%dx%d%s\n",
dev->sequence, dev->level, dev->level & 0x80, dev->area.width, dev->area.height,
dev->area.x, dev->area.y, dev->geometry.width, dev->geometry.height, dev->geometry.x,
dev->geometry.y, display_trust_damage(display) ? "" : " SKIPPED");
}
if (display_trust_damage(display)) {
for (i = 0; i < n; i++)
......@@ -157,12 +158,12 @@ static void handle_damage_notify(display_t *display, xcb_damage_notify_event_t *
static void handle_configure_notify(display_t *display, xcb_configure_notify_event_t *cev)
{
#if defined(DEBUG_DISPLAY_EVENTS)
g_debug
("%s:[event %u|window %u|above_sibling %u|x %d|y %d|width %d|height %d|border_width %d|override_redirect %d]",
__func__, cev->event, cev->window, cev->above_sibling, cev->x, cev->y, cev->width,
cev->height, cev->border_width, cev->override_redirect);
#endif
if (display->session->options.debug_draws >= DEBUG_DRAWS_BASIC) {
display_debug
("%s:[event %u|window %u|above_sibling %u|x %d|y %d|width %d|height %d|border_width %d|override_redirect %d]\n",
__func__, cev->event, cev->window, cev->above_sibling, cev->x, cev->y, cev->width,
cev->height, cev->border_width, cev->override_redirect);
}
if (cev->window != display->root) {
g_debug("not main window; skipping.");
......@@ -576,13 +577,13 @@ int display_find_changed_tiles(display_t *d, int row, bool *tiles, int tiles_acr
}
}
}
#if defined(DEBUG_SCANLINES)
fprintf(stderr, "%d: ", row);
for (i = 0; i < tiles_across; i++)
fprintf(stderr, "%c", tiles[i] ? 'X' : '-');
fprintf(stderr, "\n");
fflush(stderr);
#endif
if (d->session->options.debug_draws >= DEBUG_DRAWS_DETAIL) {
fprintf(stderr, "%d: ", row);
for (i = 0; i < tiles_across; i++)
fprintf(stderr, "%c", tiles[i] ? 'X' : '-');
fprintf(stderr, "\n");
fflush(stderr);
}
return ret;
}
......@@ -655,13 +656,13 @@ int display_scan_whole_screen(display_t *d, int num_vertical_tiles, int num_hori
}
}
}
#if defined(DEBUG_SCANLINES)
fprintf(stderr, "%d: ", v_tile);
for (h_tile = 0; h_tile < num_horizontal_tiles; h_tile++)
fprintf(stderr, "%c", tiles[v_tile][h_tile] ? 'X' : '-');
fprintf(stderr, "\n");
fflush(stderr);
#endif
if (d->session->options.debug_draws >= DEBUG_DRAWS_DETAIL) {
fprintf(stderr, "%d: ", v_tile);
for (h_tile = 0; h_tile < num_horizontal_tiles; h_tile++)
fprintf(stderr, "%c", tiles[v_tile][h_tile] ? 'X' : '-');
fprintf(stderr, "\n");
fflush(stderr);
}
}
}
......@@ -771,3 +772,16 @@ int display_trust_damage(display_t *d)
return 0;
return d->fullscreen_damage_count <= 2;
}
void display_debug(const char *fmt, ...)
{
va_list ap;
struct timeval tv;
gettimeofday(&tv, NULL);
va_start(ap, fmt);
fprintf(stderr, "draw:%04ld.%06ld:", tv.tv_sec, tv.tv_usec);
vfprintf(stderr, fmt, ap);
fflush(stderr);
va_end(ap);
}
......@@ -75,6 +75,13 @@ typedef struct {
struct session_struct *session;
} display_t;
/* Levels for debug-draws */
enum {
DEBUG_DRAWS_NONE,
DEBUG_DRAWS_BASIC,
DEBUG_DRAWS_DETAIL,
};
/*----------------------------------------------------------------------------
** Prototypes
......@@ -95,5 +102,10 @@ int read_shm_image(display_t *d, shm_image_t *shmi, int x, int y);
void destroy_shm_image(display_t *d, shm_image_t *shmi);
int display_trust_damage(display_t *d);
#if defined(__GNUC__)
void display_debug(const char *fmt, ...) __attribute__((format(printf, 1, 2)));
#else
void display_debug(const char *fmt, ...);
#endif
#endif
......@@ -398,6 +398,7 @@ static void options_from_config(options_t *options)
options->full_screen_fps = int_option(userkey, systemkey, "spice", "full-screen-fps");
string_option(&options->codecs, userkey, systemkey, "spice", "codecs");
options->debug_draws = int_option(userkey, systemkey, "spice", "debug-draws");
#if defined(HAVE_LIBAUDIT_H)
/* Pick an arbitrary default in the user range. CodeWeavers was founed in 1996, so 1196 it is... */
......
......@@ -67,6 +67,7 @@ typedef struct {
int audit_message_type;
damage_trust_t trust_damage;
int full_screen_fps;
int debug_draws;
/* file names of config files */
char *user_config_file;
......
......@@ -332,6 +332,10 @@ static void scanner_periodic(scanner_t *scanner)
offset = scanlines[scanner->current_scanline++];
scanner->current_scanline %= NUM_SCANLINES;
if (scanner->session->options.debug_draws >= DEBUG_DRAWS_DETAIL) {
display_debug("scanner_periodic start; scanline %d\n", scanner->current_scanline);
}
for (y = offset, i = 0; i < num_vertical_tiles; i++, y += NUM_SCANLINES) {
if (y >= scanner->session->display.fullscreen->h)
rc = 0;
......@@ -348,6 +352,10 @@ static void scanner_periodic(scanner_t *scanner)
grow_changed_tiles(scanner, tiles_changed_in_row, tiles_changed, num_vertical_tiles);
push_changed_tiles(scanner, tiles_changed_in_row, tiles_changed, num_vertical_tiles);
if (scanner->session->options.debug_draws >= DEBUG_DRAWS_DETAIL) {
display_debug("scanner_periodic done; scanline %d\n", scanner->current_scanline);
}
g_mutex_unlock(scanner->session->lock);
}
......@@ -475,10 +483,9 @@ int scanner_push(scanner_t *scanner, scan_type_t type, int x, int y, int w, int
{
scan_report_t *r;
#if defined(DEBUG_SCANLINES)
fprintf(stderr, "scan: type %d, %dx%d @ %dx%d\n", type, w, h, x, y);
fflush(stderr);
#endif
if (scanner->session->options.debug_draws >= DEBUG_DRAWS_DETAIL) {
display_debug("scan: type %d, %dx%d @ %dx%d\n", type, w, h, x, y);
}
g_mutex_lock(scanner->lock);
......
......@@ -146,6 +146,13 @@
#-----------------------------------------------------------------------------
#exit-on-disconnect=false
#-----------------------------------------------------------------------------
# debug-draws If non zero, provide debug information on draws to
# stderr. 1 provides basic draw, 2 more detail.
# Default 0.
#-----------------------------------------------------------------------------
#debug-draws=0
#-----------------------------------------------------------------------------
# ssl The ssl section governs spice SSL parameters
#-----------------------------------------------------------------------------
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment