[pango/pango2: 3/3] Add debug spew




commit ae5a645c21e69e086c72668db90ec29847a98086
Author: Matthias Clasen <mclasen redhat com>
Date:   Tue Jun 14 07:26:02 2022 -0400

    Add debug spew

 pango/pango-hbface.c | 45 ++++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 44 insertions(+), 1 deletion(-)
---
diff --git a/pango/pango-hbface.c b/pango/pango-hbface.c
index 937c22cd9..93d394729 100644
--- a/pango/pango-hbface.c
+++ b/pango/pango-hbface.c
@@ -30,6 +30,34 @@
 #include <hb-ot.h>
 #include <hb-gobject.h>
 
+#ifdef __linux__
+#include <execinfo.h>
+
+static inline char *
+get_backtrace (void)
+{
+  void *buffer[1024];
+  int size;
+  char **symbols;
+  GString *s;
+
+  size = backtrace (buffer, 1024);
+  symbols = backtrace_symbols (buffer, size);
+
+  s = g_string_new ("");
+
+  for (int i = 0; i < size; i++)
+    {
+      g_string_append (s, symbols[i]);
+      g_string_append_c (s, '\n');
+    }
+
+  free (symbols);
+
+  return g_string_free (s, FALSE);
+}
+#endif
+
 /**
  * PangoHbFace:
  *
@@ -448,7 +476,22 @@ pango_hb_face_create_font (PangoFontFace              *face,
                            float                       dpi,
                            const PangoMatrix          *ctm)
 {
-  PangoHbFace *self = PANGO_HB_FACE (face);
+  PangoHbFace *self;
+
+  if (!PANGO_IS_FONT_FACE (face))
+    {
+      char *s = pango_font_description_to_string (desc);
+#ifdef __linux__
+      char *bs = get_backtrace ();
+#else
+      char *bs = g_strdup ("");
+#endif
+      g_critical ("pango_font_face_create_font called without a face for %s\n%s", s, bs);
+      g_free (s);
+      g_free (bs);
+    }
+
+  self = PANGO_HB_FACE (face);
 
   return PANGO_FONT (pango_hb_font_new_for_description (self, desc, dpi, ctm));
 }


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