Commit 85fece3e authored by Paul Eggert's avatar Paul Eggert

GLYPH_DEBUG fixes

The following patches are for when GLYPH_DEBUG && !XASSERT.
* dispextern.h (trace_redisplay_p, dump_glyph_string):
* dispnew.c (flush_stdout):
* xdisp.c (dump_glyph_row, dump_glyph_matrix, dump_glyph):
Mark as externally visible.
* dispnew.c (check_window_matrix_pointers): Now static.
* dispnew.c (window_to_frame_vpos):
* xfns.c (unwind_create_frame):
* xterm.c (x_check_font): Remove unused local.
* scroll.c (CHECK_BOUNDS):
* xfaces.c (cache_fache): Rename local to avoid shadowing.
* xfns.c, w32fns.c (image_cache_refcount, dpyinfo_refcount): Now static.
* xdisp.c (check_window_end): Now a no-op if !XASSERTS.
(debug_first_unchanged_at_end_vpos, debug_last_unchanged_at_beg_vpos)
(debug_dvpos, debug_dy, debug_delta, debug_delta_bytes, debug_end_vpos):
Now static.
(debug_method_add): Use va_list and vsprintf rather than relying
on undefined behavior with wrong number of arguments.
(dump_glyph, dump_glyph_row, Fdump_glyph_matrix):
Don't assume ptrdiff_t and EMACS_INT are the same width as int.
In this code, it's OK to assume C99 behavior for ptrdiff_t formats
since we're not interested in debugging glyphs with old libraries.
* xfaces.c (cache_face): Move debugging code earlier; this pacifies
GCC 4.6.0's static checking.
parent 94a807ac
2011-06-22 Paul Eggert <eggert@cs.ucla.edu>
GLYPH_DEBUG fixes
The following patches are for when GLYPH_DEBUG && !XASSERT.
* dispextern.h (trace_redisplay_p, dump_glyph_string):
* dispnew.c (flush_stdout):
* xdisp.c (dump_glyph_row, dump_glyph_matrix, dump_glyph):
Mark as externally visible.
* dispnew.c (check_window_matrix_pointers): Now static.
* dispnew.c (window_to_frame_vpos):
* xfns.c (unwind_create_frame):
* xterm.c (x_check_font): Remove unused local.
* scroll.c (CHECK_BOUNDS):
* xfaces.c (cache_fache): Rename local to avoid shadowing.
* xfns.c, w32fns.c (image_cache_refcount, dpyinfo_refcount): Now static.
* xdisp.c (check_window_end): Now a no-op if !XASSERTS.
(debug_first_unchanged_at_end_vpos, debug_last_unchanged_at_beg_vpos)
(debug_dvpos, debug_dy, debug_delta, debug_delta_bytes, debug_end_vpos):
Now static.
(debug_method_add): Use va_list and vsprintf rather than relying
on undefined behavior with wrong number of arguments.
(dump_glyph, dump_glyph_row, Fdump_glyph_matrix):
Don't assume ptrdiff_t and EMACS_INT are the same width as int.
In this code, it's OK to assume C99 behavior for ptrdiff_t formats
since we're not interested in debugging glyphs with old libraries.
* xfaces.c (cache_face): Move debugging code earlier; this pacifies
GCC 4.6.0's static checking.
2011-06-22 Paul Eggert <eggert@cs.ucla.edu>
Integer overflow and signedness fixes (Bug#8873).
......
......@@ -151,7 +151,7 @@ enum window_part
#if GLYPH_DEBUG
extern int trace_redisplay_p;
extern int trace_redisplay_p EXTERNALLY_VISIBLE;
#include <stdio.h>
#define TRACE(X) \
......@@ -3010,7 +3010,7 @@ extern EMACS_INT compute_display_string_end (EMACS_INT);
#ifdef HAVE_WINDOW_SYSTEM
#if GLYPH_DEBUG
extern void dump_glyph_string (struct glyph_string *);
extern void dump_glyph_string (struct glyph_string *) EXTERNALLY_VISIBLE;
#endif
extern void x_get_glyph_overhangs (struct glyph *, struct frame *,
......
......@@ -155,7 +155,6 @@ static int update_text_area (struct window *, int);
static void make_current (struct glyph_matrix *, struct glyph_matrix *,
int);
static void mirror_make_current (struct window *, int);
void check_window_matrix_pointers (struct window *);
#if GLYPH_DEBUG
static void check_matrix_pointers (struct glyph_matrix *,
struct glyph_matrix *);
......@@ -1478,6 +1477,8 @@ realloc_glyph_pool (struct glyph_pool *pool, struct dim matrix_dim)
stdout.
*/
void flush_stdout (void) EXTERNALLY_VISIBLE;
void
flush_stdout (void)
{
......@@ -3052,7 +3053,7 @@ mirror_line_dance (struct window *w, int unchanged_at_top, int nlines, int *copy
matrices of leaf window agree with their frame matrices about
glyph pointers. */
void
static void
check_window_matrix_pointers (struct window *w)
{
while (w)
......@@ -3116,12 +3117,10 @@ check_matrix_pointers (struct glyph_matrix *window_matrix,
static int
window_to_frame_vpos (struct window *w, int vpos)
{
struct frame *f = XFRAME (w->frame);
xassert (!FRAME_WINDOW_P (f));
xassert (!FRAME_WINDOW_P (XFRAME (w->frame)));
xassert (vpos >= 0 && vpos <= w->desired_matrix->nrows);
vpos += WINDOW_TOP_EDGE_LINE (w);
xassert (vpos >= 0 && vpos <= FRAME_LINES (f));
xassert (vpos >= 0 && vpos <= FRAME_LINES (XFRAME (w->frame)));
return vpos;
}
......
......@@ -268,10 +268,10 @@ do_scrolling (struct frame *frame, struct glyph_matrix *current_matrix,
# define CHECK_BOUNDS \
do \
{ \
int k; \
for (k = 0; k < window_size; ++k) \
xassert (copy_from[k] == -1 \
|| (copy_from[k] >= 0 && copy_from[k] < window_size)); \
int ck; \
for (ck = 0; ck < window_size; ++ck) \
xassert (copy_from[ck] == -1 \
|| (copy_from[ck] >= 0 && copy_from[ck] < window_size)); \
} \
while (0);
#endif
......
......@@ -184,7 +184,7 @@ unsigned int msh_mousewheel = 0;
static unsigned menu_free_timer = 0;
#if GLYPH_DEBUG
int image_cache_refcount, dpyinfo_refcount;
static int image_cache_refcount, dpyinfo_refcount;
#endif
static HWND w32_visible_system_caret_hwnd;
......
......@@ -2242,7 +2242,7 @@ check_it (it)
#endif /* not 0 */
#if GLYPH_DEBUG
#if GLYPH_DEBUG && XASSERTS
/* Check that the window end of window W is what we expect it
to be---the last row in the current matrix displaying text. */
......@@ -2264,11 +2264,11 @@ check_window_end (struct window *w)
#define CHECK_WINDOW_END(W) check_window_end ((W))
#else /* not GLYPH_DEBUG */
#else
#define CHECK_WINDOW_END(W) (void) 0
#endif /* not GLYPH_DEBUG */
#endif
......@@ -11101,40 +11101,42 @@ hscroll_windows (Lisp_Object window)
/* First and last unchanged row for try_window_id. */
int debug_first_unchanged_at_end_vpos;
int debug_last_unchanged_at_beg_vpos;
static int debug_first_unchanged_at_end_vpos;
static int debug_last_unchanged_at_beg_vpos;
/* Delta vpos and y. */
int debug_dvpos, debug_dy;
static int debug_dvpos, debug_dy;
/* Delta in characters and bytes for try_window_id. */
EMACS_INT debug_delta, debug_delta_bytes;
static EMACS_INT debug_delta, debug_delta_bytes;
/* Values of window_end_pos and window_end_vpos at the end of
try_window_id. */
EMACS_INT debug_end_vpos;
static EMACS_INT debug_end_vpos;
/* Append a string to W->desired_matrix->method. FMT is a printf
format string. A1...A9 are a supplement for a variable-length
argument list. If trace_redisplay_p is non-zero also printf the
format string. If trace_redisplay_p is non-zero also printf the
resulting string to stderr. */
static void debug_method_add (struct window *, char const *, ...)
ATTRIBUTE_FORMAT_PRINTF (2, 3);
static void
debug_method_add (w, fmt, a1, a2, a3, a4, a5, a6, a7, a8, a9)
struct window *w;
char *fmt;
int a1, a2, a3, a4, a5, a6, a7, a8, a9;
debug_method_add (struct window *w, char const *fmt, ...)
{
char buffer[512];
char *method = w->desired_matrix->method;
int len = strlen (method);
int size = sizeof w->desired_matrix->method;
int remaining = size - len - 1;
va_list ap;
sprintf (buffer, fmt, a1, a2, a3, a4, a5, a6, a7, a8, a9);
va_start (ap, fmt);
vsprintf (buffer, fmt, ap);
va_end (ap);
if (len && remaining)
{
method[len] = '|';
......@@ -16265,9 +16267,9 @@ try_window_id (struct window *w)
#if GLYPH_DEBUG
void dump_glyph_row (struct glyph_row *, int, int);
void dump_glyph_matrix (struct glyph_matrix *, int);
void dump_glyph (struct glyph_row *, struct glyph *, int);
void dump_glyph_row (struct glyph_row *, int, int) EXTERNALLY_VISIBLE;
void dump_glyph_matrix (struct glyph_matrix *, int) EXTERNALLY_VISIBLE;
void dump_glyph (struct glyph_row *, struct glyph *, int) EXTERNALLY_VISIBLE;
/* Dump the contents of glyph matrix MATRIX on stderr.
......@@ -16294,7 +16296,7 @@ dump_glyph (struct glyph_row *row, struct glyph *glyph, int area)
if (glyph->type == CHAR_GLYPH)
{
fprintf (stderr,
" %5d %4c %6d %c %3d 0x%05x %c %4d %1.1d%1.1d\n",
" %5td %4c %6"pI"d %c %3d 0x%05x %c %4d %1.1d%1.1d\n",
glyph - row->glyphs[TEXT_AREA],
'C',
glyph->charpos,
......@@ -16315,7 +16317,7 @@ dump_glyph (struct glyph_row *row, struct glyph *glyph, int area)
else if (glyph->type == STRETCH_GLYPH)
{
fprintf (stderr,
" %5d %4c %6d %c %3d 0x%05x %c %4d %1.1d%1.1d\n",
" %5td %4c %6"pI"d %c %3d 0x%05x %c %4d %1.1d%1.1d\n",
glyph - row->glyphs[TEXT_AREA],
'S',
glyph->charpos,
......@@ -16334,7 +16336,7 @@ dump_glyph (struct glyph_row *row, struct glyph *glyph, int area)
else if (glyph->type == IMAGE_GLYPH)
{
fprintf (stderr,
" %5d %4c %6d %c %3d 0x%05x %c %4d %1.1d%1.1d\n",
" %5td %4c %6"pI"d %c %3d 0x%05x %c %4d %1.1d%1.1d\n",
glyph - row->glyphs[TEXT_AREA],
'I',
glyph->charpos,
......@@ -16353,7 +16355,7 @@ dump_glyph (struct glyph_row *row, struct glyph *glyph, int area)
else if (glyph->type == COMPOSITE_GLYPH)
{
fprintf (stderr,
" %5d %4c %6d %c %3d 0x%05x",
" %5td %4c %6"pI"d %c %3d 0x%05x",
glyph - row->glyphs[TEXT_AREA],
'+',
glyph->charpos,
......@@ -16389,7 +16391,7 @@ dump_glyph_row (struct glyph_row *row, int vpos, int glyphs)
fprintf (stderr, "Row Start End Used oE><\\CTZFesm X Y W H V A P\n");
fprintf (stderr, "======================================================================\n");
fprintf (stderr, "%3d %5d %5d %4d %1.1d%1.1d%1.1d%1.1d\
fprintf (stderr, "%3d %5"pI"d %5"pI"d %4d %1.1d%1.1d%1.1d%1.1d\
%1.1d%1.1d%1.1d%1.1d%1.1d%1.1d%1.1d%1.1d %4d %4d %4d %4d %4d %4d %4d\n",
vpos,
MATRIX_ROW_START_CHARPOS (row),
......@@ -16417,7 +16419,7 @@ dump_glyph_row (struct glyph_row *row, int vpos, int glyphs)
fprintf (stderr, "%9d %5d\t%5d\n", row->start.overlay_string_index,
row->end.overlay_string_index,
row->continuation_lines_width);
fprintf (stderr, "%9d %5d\n",
fprintf (stderr, "%9"pI"d %5"pI"d\n",
CHARPOS (row->start.string_pos),
CHARPOS (row->end.string_pos));
fprintf (stderr, "%9d %5d\n", row->start.dpvec_index,
......@@ -16482,7 +16484,7 @@ glyphs in short form, otherwise show glyphs in long form. */)
struct window *w = XWINDOW (selected_window);
struct buffer *buffer = XBUFFER (w->buffer);
fprintf (stderr, "PT = %d, BEGV = %d. ZV = %d\n",
fprintf (stderr, "PT = %"pI"d, BEGV = %"pI"d. ZV = %"pI"d\n",
BUF_PT (buffer), BUF_BEGV (buffer), BUF_ZV (buffer));
fprintf (stderr, "Cursor x = %d, y = %d, hpos = %d, vpos = %d\n",
w->cursor.x, w->cursor.y, w->cursor.hpos, w->cursor.vpos);
......
......@@ -4380,6 +4380,21 @@ cache_face (struct face_cache *c, struct face *face, unsigned int hash)
break;
face->id = i;
#if GLYPH_DEBUG
/* Check that FACE got a unique id. */
{
int j, n;
struct face *face1;
for (j = n = 0; j < FACE_CACHE_BUCKETS_SIZE; ++j)
for (face1 = c->buckets[j]; face1; face1 = face1->next)
if (face1->id == i)
++n;
xassert (n == 1);
}
#endif /* GLYPH_DEBUG */
/* Maybe enlarge C->faces_by_id. */
if (i == c->used)
{
......@@ -4396,21 +4411,6 @@ cache_face (struct face_cache *c, struct face *face, unsigned int hash)
c->used++;
}
#if GLYPH_DEBUG
/* Check that FACE got a unique id. */
{
int j, n;
struct face *face;
for (j = n = 0; j < FACE_CACHE_BUCKETS_SIZE; ++j)
for (face = c->buckets[j]; face; face = face->next)
if (face->id == i)
++n;
xassert (n == 1);
}
#endif /* GLYPH_DEBUG */
c->faces_by_id[i] = face;
}
......
......@@ -145,7 +145,7 @@ static Lisp_Object Qcompound_text, Qcancel_timer;
Lisp_Object Qfont_param;
#if GLYPH_DEBUG
int image_cache_refcount, dpyinfo_refcount;
static int image_cache_refcount, dpyinfo_refcount;
#endif
#if defined (USE_GTK) && defined (HAVE_FREETYPE)
......@@ -2927,7 +2927,7 @@ unwind_create_frame (Lisp_Object frame)
/* If frame is ``official'', nothing to do. */
if (!CONSP (Vframe_list) || !EQ (XCAR (Vframe_list), frame))
{
#if GLYPH_DEBUG
#if GLYPH_DEBUG && XASSERTS
struct x_display_info *dpyinfo = FRAME_X_DISPLAY_INFO (f);
#endif
......
......@@ -9673,8 +9673,6 @@ x_wm_set_icon_position (struct frame *f, int icon_x, int icon_y)
static void
x_check_font (struct frame *f, struct font *font)
{
Lisp_Object frame;
xassert (font != NULL && ! NILP (font->props[FONT_TYPE_INDEX]));
if (font->driver->check)
xassert (font->driver->check (f, font) == 0);
......
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