Commit 839078f3c08658b4f0748bd68379c0e396169f48

Thomas de Grivel 2023-01-17T10:51:23

rtbuf_gtk3 test/sinus

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
diff --git a/.gitignore b/.gitignore
index a12f5a3..8389829 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,13 +1,20 @@
 *.a
 /cli/rtbuf
+/cli/rtbuf_asan
+/cli/rtbuf_cov
+/cli/rtbuf_debug
 config.mk
 /doc/
 .gdb_history
 *.gcda
 *.gcno
-/gtk3/rtbuf-gtk3
+/gtk3/rtbuf_gtk3
+/gtk3/rtbuf_gtk3_asan
+/gtk3/rtbuf_gtk3_cov
+/gtk3/rtbuf_gtk3_debug
 /gtk3/rtbuf_gtk3_resources.c
 *.la
+*.lai
 /lib/.*.log
 /lib/*/.*.log
 /lib/*_type
diff --git a/Makefile b/Makefile
index 8d969e6..60114eb 100644
--- a/Makefile
+++ b/Makefile
@@ -29,6 +29,12 @@ clean:
 	${MAKE} -C ${PWD}/cli      clean
 	${MAKE} -C ${PWD}/gtk3     clean
 
+debug:
+	${MAKE} -C ${PWD}/librtbuf debug
+	${MAKE} -C ${PWD}/lib debug
+	${MAKE} -C ${PWD}/cli debug
+	${MAKE} -C ${PWD}/gtk3 debug
+
 doc:
 	doxygen doxygen.conf
 
@@ -38,11 +44,17 @@ install:
 	${MAKE} -C ${PWD}/cli      install
 	${MAKE} -C ${PWD}/gtk3     install
 
+install-debug:
+	${MAKE} -C ${PWD}/librtbuf install-debug
+	${MAKE} -C ${PWD}/lib      install-debug
+	${MAKE} -C ${PWD}/cli      install-debug
+	${MAKE} -C ${PWD}/gtk3     install-debug
+
 licence:
 	update_header config.subr ${RTBUF_CONFIGURES}
 	update_header Makefile ${RTBUF_MAKEFILES}
 	update_header librtbuf/rtbuf.h ${RTBUF_C_SOURCES}
 
-.PHONY: all build clean doc install
+.PHONY: all build clean doc install install-debug
 
 include config.mk
diff --git a/cli/rtbuf_cli_main.c b/cli/rtbuf_cli_main.c
index 469ee70..142d9f9 100644
--- a/cli/rtbuf_cli_main.c
+++ b/cli/rtbuf_cli_main.c
@@ -12,6 +12,7 @@
  * THIS SOFTWARE.
  */
 #include <assert.h>
+#include <stdio.h>
 #include "../librtbuf/rtbuf.h"
 #include "rtbuf_cli.h"
 
diff --git a/cli/rtbuf_debug b/cli/rtbuf_debug
deleted file mode 100755
index b489544..0000000
Binary files a/cli/rtbuf_debug and /dev/null differ
diff --git a/config.subr b/config.subr
index 8118a92..7d6bc3f 100644
--- a/config.subr
+++ b/config.subr
@@ -29,6 +29,10 @@ lo_rule() {
     ext_rule .lo "$1"
 }
 
+prog_ext_rule() {
+    { o_rule "$2" || exit 1; } | sed -e "s/[.]o:/$1:/"
+}
+
 prog_rule() {
     { o_rule "$1" || exit 1; } | sed -e 's/[.]o:/:/'
 }
@@ -261,6 +265,7 @@ rtbuf_library() {
     echo "RTBUF_LIBRARY_LIBDIR = $RTBUF_LIBRARY_LIBDIR" >> ${CONFIG_MK}
 
     LIBRARIES=
+    LIBRARIES_DEBUG=
 
     for SRC in $SOURCES; do
         SRC_LO="$(c2ext .main.lo "$SRC")"
@@ -272,12 +277,25 @@ rtbuf_library() {
         echo "$SRC_LA: $SRC_LO" >> ${CONFIG_MK}
         echo "	${LIBTOOL} --tag=CC --mode=link \${CC} -no-undefined -module \${LDFLAGS} $SRC_LO \${LIBS} -o $SRC_LA -rpath ${RTBUF_LIBRARY_LIBDIR}" >> ${CONFIG_MK}
         LIBRARIES="$LIBRARIES $SRC_LA"
-    done
+
+        SRC_LO="$(c2ext .debug.lo "$SRC")"
+        echo >> ${CONFIG_MK}
+        ext_rule .debug.lo "$SRC" >> ${CONFIG_MK}
+        echo "	${LIBTOOL} --tag=CC --mode=compile \${CC} \${CPPFLAGS} \${CFLAGS_DEBUG} -c $SRC -o $SRC_LO" >> ${CONFIG_MK}
+        SRC_LA="$(c2ext _debug.la "$SRC")"
+        echo >> ${CONFIG_MK}
+        echo "$SRC_LA: $SRC_LO" >> ${CONFIG_MK}
+        echo "	${LIBTOOL} --tag=CC --mode=link \${CC} -no-undefined -module \${LDFLAGS} $SRC_LO \${LIBS_DEBUG} -o $SRC_LA -rpath ${RTBUF_LIBRARY_LIBDIR}" >> ${CONFIG_MK}
+        LIBRARIES_DEBUG="$LIBRARIES_DEBUG $SRC_LA"
+done
 
     echo >> ${CONFIG_MK}
     echo "libraries:${LIBRARIES}" >> ${CONFIG_MK}
 
     echo >> ${CONFIG_MK}
+    echo "libraries-debug:${LIBRARIES_DEBUG}" >> ${CONFIG_MK}
+
+    echo >> ${CONFIG_MK}
     echo "install:${LIBRARIES}" >> ${CONFIG_MK}
     for LIB in $LIBRARIES; do
         echo "	\${INSTALL} -o \${OWNER} -g \${GROUP} -m 0755 -d \${RTBUF_LIBRARY_LIBDIR}" >> ${CONFIG_MK}
diff --git a/gtk3/rtbuf_gtk3 b/gtk3/rtbuf_gtk3
deleted file mode 100755
index 92df277..0000000
--- a/gtk3/rtbuf_gtk3
+++ /dev/null
@@ -1,210 +0,0 @@
-#! /bin/sh
-
-# rtbuf_gtk3 - temporary wrapper script for .libs/rtbuf_gtk3
-# Generated by libtool (GNU libtool) 2.4.2
-#
-# The rtbuf_gtk3 program cannot be directly executed until all the libtool
-# libraries that it depends on are installed.
-#
-# This wrapper script should never be moved out of the build directory.
-# If it is, it will not operate correctly.
-
-# Sed substitution that helps us do robust quoting.  It backslashifies
-# metacharacters that are still active within double-quoted strings.
-sed_quote_subst='s/\([`"$\\]\)/\\\1/g'
-
-# Be Bourne compatible
-if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then
-  emulate sh
-  NULLCMD=:
-  # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which
-  # is contrary to our usage.  Disable this feature.
-  alias -g '${1+"$@"}'='"$@"'
-  setopt NO_GLOB_SUBST
-else
-  case `(set -o) 2>/dev/null` in *posix*) set -o posix;; esac
-fi
-BIN_SH=xpg4; export BIN_SH # for Tru64
-DUALCASE=1; export DUALCASE # for MKS sh
-
-# The HP-UX ksh and POSIX shell print the target directory to stdout
-# if CDPATH is set.
-(unset CDPATH) >/dev/null 2>&1 && unset CDPATH
-
-relink_command=""
-
-# This environment variable determines our operation mode.
-if test "$libtool_install_magic" = "%%%MAGIC variable%%%"; then
-  # install mode needs the following variables:
-  generated_by_libtool_version='2.4.2'
-  notinst_deplibs=' /home/dx/c/rtbuf/rtbuf/lib/librtbuf_signal.la /home/dx/c/rtbuf/rtbuf/cli/librtbuf_cli.la /home/dx/c/rtbuf/rtbuf/librtbuf/librtbuf.la'
-else
-  # When we are sourced in execute mode, $file and $ECHO are already set.
-  if test "$libtool_execute_magic" != "%%%MAGIC variable%%%"; then
-    file="$0"
-
-# A function that is used when there is no print builtin or printf.
-func_fallback_echo ()
-{
-  eval 'cat <<_LTECHO_EOF
-$1
-_LTECHO_EOF'
-}
-    ECHO="print -r --"
-  fi
-
-# Very basic option parsing. These options are (a) specific to
-# the libtool wrapper, (b) are identical between the wrapper
-# /script/ and the wrapper /executable/ which is used only on
-# windows platforms, and (c) all begin with the string --lt-
-# (application programs are unlikely to have options which match
-# this pattern).
-#
-# There are only two supported options: --lt-debug and
-# --lt-dump-script. There is, deliberately, no --lt-help.
-#
-# The first argument to this parsing function should be the
-# script's /usr/local/bin/libtool value, followed by no.
-lt_option_debug=
-func_parse_lt_options ()
-{
-  lt_script_arg0=$0
-  shift
-  for lt_opt
-  do
-    case "$lt_opt" in
-    --lt-debug) lt_option_debug=1 ;;
-    --lt-dump-script)
-        lt_dump_D=`$ECHO "X$lt_script_arg0" | /usr/bin/sed -e 's/^X//' -e 's%/[^/]*$%%'`
-        test "X$lt_dump_D" = "X$lt_script_arg0" && lt_dump_D=.
-        lt_dump_F=`$ECHO "X$lt_script_arg0" | /usr/bin/sed -e 's/^X//' -e 's%^.*/%%'`
-        cat "$lt_dump_D/$lt_dump_F"
-        exit 0
-      ;;
-    --lt-*)
-        $ECHO "Unrecognized --lt- option: '$lt_opt'" 1>&2
-        exit 1
-      ;;
-    esac
-  done
-
-  # Print the debug banner immediately:
-  if test -n "$lt_option_debug"; then
-    echo "rtbuf_gtk3:rtbuf_gtk3:${LINENO}: libtool wrapper (GNU libtool) 2.4.2" 1>&2
-  fi
-}
-
-# Used when --lt-debug. Prints its arguments to stdout
-# (redirection is the responsibility of the caller)
-func_lt_dump_args ()
-{
-  lt_dump_args_N=1;
-  for lt_arg
-  do
-    $ECHO "rtbuf_gtk3:rtbuf_gtk3:${LINENO}: newargv[$lt_dump_args_N]: $lt_arg"
-    lt_dump_args_N=`expr $lt_dump_args_N + 1`
-  done
-}
-
-# Core function for launching the target application
-func_exec_program_core ()
-{
-
-      if test -n "$lt_option_debug"; then
-        $ECHO "rtbuf_gtk3:rtbuf_gtk3:${LINENO}: newargv[0]: $progdir/$program" 1>&2
-        func_lt_dump_args ${1+"$@"} 1>&2
-      fi
-      exec "$progdir/$program" ${1+"$@"}
-
-      $ECHO "$0: cannot exec $program $*" 1>&2
-      exit 1
-}
-
-# A function to encapsulate launching the target application
-# Strips options in the --lt-* namespace from $@ and
-# launches target application with the remaining arguments.
-func_exec_program ()
-{
-  case " $* " in
-  *\ --lt-*)
-    for lt_wr_arg
-    do
-      case $lt_wr_arg in
-      --lt-*) ;;
-      *) set x "$@" "$lt_wr_arg"; shift;;
-      esac
-      shift
-    done ;;
-  esac
-  func_exec_program_core ${1+"$@"}
-}
-
-  # Parse options
-  func_parse_lt_options "$0" ${1+"$@"}
-
-  # Find the directory that this script lives in.
-  thisdir=`$ECHO "$file" | /usr/bin/sed 's%/[^/]*$%%'`
-  test "x$thisdir" = "x$file" && thisdir=.
-
-  # Follow symbolic links until we get to the real thisdir.
-  file=`ls -ld "$file" | /usr/bin/sed -n 's/.*-> //p'`
-  while test -n "$file"; do
-    destdir=`$ECHO "$file" | /usr/bin/sed 's%/[^/]*$%%'`
-
-    # If there was a directory component, then change thisdir.
-    if test "x$destdir" != "x$file"; then
-      case "$destdir" in
-      [\\/]* | [A-Za-z]:[\\/]*) thisdir="$destdir" ;;
-      *) thisdir="$thisdir/$destdir" ;;
-      esac
-    fi
-
-    file=`$ECHO "$file" | /usr/bin/sed 's%^.*/%%'`
-    file=`ls -ld "$thisdir/$file" | /usr/bin/sed -n 's/.*-> //p'`
-  done
-
-  # Usually 'no', except on cygwin/mingw when embedded into
-  # the cwrapper.
-  WRAPPER_SCRIPT_BELONGS_IN_OBJDIR=no
-  if test "$WRAPPER_SCRIPT_BELONGS_IN_OBJDIR" = "yes"; then
-    # special case for '.'
-    if test "$thisdir" = "."; then
-      thisdir=`pwd`
-    fi
-    # remove .libs from thisdir
-    case "$thisdir" in
-    *[\\/].libs ) thisdir=`$ECHO "$thisdir" | /usr/bin/sed 's%[\\/][^\\/]*$%%'` ;;
-    .libs )   thisdir=. ;;
-    esac
-  fi
-
-  # Try to get the absolute directory name.
-  absdir=`cd "$thisdir" && pwd`
-  test -n "$absdir" && thisdir="$absdir"
-
-  program='rtbuf_gtk3'
-  progdir="$thisdir/.libs"
-
-
-  if test -f "$progdir/$program"; then
-    # Add our own library path to LD_LIBRARY_PATH
-    LD_LIBRARY_PATH="/usr/local/lib:/usr/X11R6/lib:/home/dx/c/rtbuf/rtbuf/lib/.libs:/home/dx/c/rtbuf/rtbuf/cli/.libs:/home/dx/c/rtbuf/rtbuf/librtbuf/.libs:$LD_LIBRARY_PATH"
-
-    # Some systems cannot cope with colon-terminated LD_LIBRARY_PATH
-    # The second colon is a workaround for a bug in BeOS R4 sed
-    LD_LIBRARY_PATH=`$ECHO "$LD_LIBRARY_PATH" | /usr/bin/sed 's/::*$//'`
-
-    export LD_LIBRARY_PATH
-
-    if test "$libtool_execute_magic" != "%%%MAGIC variable%%%"; then
-      # Run the actual program with our arguments.
-      func_exec_program ${1+"$@"}
-    fi
-  else
-    # The program doesn't exist.
-    $ECHO "$0: error: \`$progdir/$program' does not exist" 1>&2
-    $ECHO "This script is just a wrapper for $program." 1>&2
-    $ECHO "See the libtool documentation for more information." 1>&2
-    exit 1
-  fi
-fi
diff --git a/gtk3/rtbuf_gtk3.c b/gtk3/rtbuf_gtk3.c
index 2fa2778..f010d16 100644
--- a/gtk3/rtbuf_gtk3.c
+++ b/gtk3/rtbuf_gtk3.c
@@ -48,6 +48,8 @@ GtkWidget              *drag_widget = NULL;
 gint                    drag_x = 0;
 gint                    drag_y = 0;
 
+void rtbuf_gtk_err_cb (const char *msg);
+
 void rtbuf_gtk_drag_connection_end (RtbufInputWidget *input_widget)
 {
   if (drag_connection) {
@@ -146,6 +148,7 @@ void rtbuf_gtk_new (gchar *library, const gint x, const gint y)
     fprintf(stderr, "rtbuf-gtk new rtbuf_new failed: %s\n", library);
     return;
   }
+  rtbuf_print(g_rtbuf + i);
 }
 
 void rtbuf_gtk_library_menu_activate (GtkMenuItem *menuitem,
@@ -154,9 +157,9 @@ void rtbuf_gtk_library_menu_activate (GtkMenuItem *menuitem,
   gchar *proc;
   gchar *library = (gchar*) data;
   g_object_get(menuitem, "label", &proc, NULL);
-  rtbuf_gtk_new(library, rtbuf_x, rtbuf_y);
   rtbuf_x = 100;
   rtbuf_y = 100;
+  rtbuf_gtk_new(library, rtbuf_x, rtbuf_y);
   g_free(proc);
 }
 
@@ -469,6 +472,21 @@ void rtbuf_gtk_unlock ()
     g_mutex_unlock(&g_mutex);
 }
 
+void rtbuf_gtk_new_cb (s_rtbuf *rtbuf)
+{
+  s_rtbuf_gtk_rtbuf_info *info;
+  assert(rtbuf);
+  rtbuf_print(rtbuf);
+  info = rtbuf_gtk_rtbuf_info_new();
+  assert(info);
+  rtbuf->user_ptr = info;
+  info->x = 10;
+  info->y = 10;
+  rtbuf_gtk_lock();
+  rtbuf_gtk_modular_layout_new(rtbuf);
+  rtbuf_gtk_unlock();
+}
+
 void rtbuf_gtk_position_cb (s_rtbuf *rtbuf, short x, short y)
 {
   s_rtbuf_gtk_rtbuf_info *info =
@@ -605,6 +623,8 @@ int main (int argc, char *argv[])
 {
   g_mutex_init(&g_mutex);
   symbols_init();
+  g_rtbuf_err_cb = rtbuf_gtk_err_cb;
+  g_rtbuf_new_cb = rtbuf_gtk_new_cb;
   g_rtbuf_position_cb = rtbuf_gtk_position_cb;
   g_rtbuf_delete_cb = rtbuf_gtk_delete_cb;
   g_rtbuf_bind_cb = rtbuf_gtk_bind_cb;
@@ -624,8 +644,7 @@ int main (int argc, char *argv[])
   return 0;
 }
 
-extern int rtbuf_err (const char *msg)
+void rtbuf_gtk_err_cb (const char *msg)
 {
   fprintf(stderr, "rtbuf-gtk: %s\n", msg);
-  return -1;
 }
diff --git a/gtk3/rtbuf_gtk3_input_widget.c b/gtk3/rtbuf_gtk3_input_widget.c
index 98cbd05..59220df 100644
--- a/gtk3/rtbuf_gtk3_input_widget.c
+++ b/gtk3/rtbuf_gtk3_input_widget.c
@@ -79,7 +79,7 @@ rtbuf_input_widget_class_init (RtbufInputWidgetClass *klass)
                      G_PARAM_READWRITE|G_PARAM_EXPLICIT_NOTIFY);
   g_object_class_install_properties(gobject_class, LAST_PROP, rtbuf_input_widget_props);
   gtk_widget_class_set_template_from_resource(widget_class,
-                                              "/rtbuf/rtbuf_input_widget.ui");
+                                              "/rtbuf/rtbuf_gtk3_input_widget.ui");
   gtk_widget_class_bind_template_child_private(widget_class,
                                                RtbufInputWidget, check);
   gtk_widget_class_bind_template_child_private(widget_class,
diff --git a/gtk3/rtbuf_gtk3_output_widget.c b/gtk3/rtbuf_gtk3_output_widget.c
index e555039..a6f8ddd 100644
--- a/gtk3/rtbuf_gtk3_output_widget.c
+++ b/gtk3/rtbuf_gtk3_output_widget.c
@@ -68,7 +68,7 @@ rtbuf_output_widget_class_init (RtbufOutputWidgetClass *klass)
                      G_PARAM_READWRITE|G_PARAM_EXPLICIT_NOTIFY);
   g_object_class_install_properties(gobject_class, LAST_PROP, rtbuf_output_widget_props);
   gtk_widget_class_set_template_from_resource(widget_class,
-                                              "/rtbuf/rtbuf_output_widget.ui");
+                                              "/rtbuf/rtbuf_gtk3_output_widget.ui");
   gtk_widget_class_bind_template_child_private(widget_class,
                                                RtbufOutputWidget, check);
   gtk_widget_class_bind_template_child_private(widget_class,
diff --git a/gtk3/rtbuf_gtk3_widget.c b/gtk3/rtbuf_gtk3_widget.c
index a2b929b..3441e52 100644
--- a/gtk3/rtbuf_gtk3_widget.c
+++ b/gtk3/rtbuf_gtk3_widget.c
@@ -71,7 +71,7 @@ rtbuf_widget_class_init (RtbufWidgetClass *klass)
                          G_PARAM_READWRITE|G_PARAM_EXPLICIT_NOTIFY);
   g_object_class_install_properties(gobject_class, LAST_PROP, rtbuf_widget_props);
   gtk_widget_class_set_template_from_resource(widget_class,
-                                              "/rtbuf/rtbuf_widget.ui");
+                                              "/rtbuf/rtbuf_gtk3_widget.ui");
   gtk_widget_class_bind_template_child_private(widget_class,
                                                RtbufWidget, event_box);
   gtk_widget_class_bind_template_child_private(widget_class,
diff --git a/lib/Makefile b/lib/Makefile
index 6a045d0..c50ac7f 100644
--- a/lib/Makefile
+++ b/lib/Makefile
@@ -13,13 +13,25 @@
 
 CLEANFILES = .libs *.o *.lo *.la *.gcno *.gcna *.gcda
 
-all: types libraries subdirs
+build: types libraries subdirs
+
+all: build
 
 clean: subdirs-clean
 	rm -rf ${CLEANFILES}
 
+debug: types libraries-debug subdirs-debug
+
 install: libraries-install subdirs-install
 
+libraries: types
+
+libraries-debug: types
+
 .PHONY: all clean libraries subdirs subdirs-clean subdirs-install
 
+subdirs: libraries
+
+subdirs-debug: libraries-debug
+
 include config.mk
diff --git a/lib/configure b/lib/configure
index c2b2daa..28c6be5 100755
--- a/lib/configure
+++ b/lib/configure
@@ -41,16 +41,19 @@ config_sndio
 CFLAGS_ASAN="$CFLAGS -fsanitize=address -O1 -fno-omit-frame-pointer -g"
 LDFLAGS_ASAN="$LDFLAGS"
 LIBS_ASAN="$LIBS"
+LIBS_ASAN="$LIBS_ASAN $SRC_TOP/librtbuf/librtbuf_asan.la"
 
 # Coverage config
 CFLAGS_COV="$CFLAGS -ftest-coverage -fprofile-arcs"
 LDFLAGS_COV="$LDFLAGS"
 LIBS_COV="$LIBS"
+LIBS_COV="$LIBS_COV $SRC_TOP/librtbuf/librtbuf_cov.la"
 
 # Debug config
 CFLAGS_DEBUG="$CFLAGS -DDEBUG -O0 -ggdb"
 LDFLAGS_DEBUG="$LDFLAGS"
 LIBS_DEBUG="$LIBS"
+LIBS_DEBUG="$LIBS_DEBUG $SRC_TOP/librtbuf/librtbuf_debug.la"
 
 # Main config
 if [ "x$ENV_CFLAGS" = "x" ]; then
@@ -102,6 +105,7 @@ type_prog synth
 echo "types:${TYPES}" >> ${CONFIG_MK}
 
 LIBRARIES=
+LIBRARIES_DEBUG=
 
 for SRC in $SOURCES; do
     SRC_LO="$(c2ext .main.lo "$SRC")"
@@ -114,12 +118,26 @@ for SRC in $SOURCES; do
     echo "$SRC_LA: $SRC_LO" >> ${CONFIG_MK}
     echo "	${LIBTOOL} --tag=CC --mode=link \${CC} -shared \${LDFLAGS} $SRC_LO \${LIBS} -o $SRC_LA -rpath \${LIBDIR}" >> ${CONFIG_MK}
     LIBRARIES="$LIBRARIES $SRC_LA"
+
+    SRC_LO="$(c2ext .debug.lo "$SRC")"
+    echo >> ${CONFIG_MK}
+    ext_rule .debug.lo "$SRC" >> ${CONFIG_MK}
+    echo "	${LIBTOOL} --tag=CC --mode=compile \${CC} \${CPPFLAGS} \${CFLAGS_DEBUG} -c $SRC -o $SRC_LO" >> ${CONFIG_MK}
+
+    SRC_LA="librtbuf_$(c2ext _debug.la "$SRC")"
+    echo >> ${CONFIG_MK}
+    echo "$SRC_LA: $SRC_LO" >> ${CONFIG_MK}
+    echo "	${LIBTOOL} --tag=CC --mode=link \${CC} -shared \${LDFLAGS_DEBUG} $SRC_LO \${LIBS_DEBUG} -o $SRC_LA -rpath \${LIBDIR}" >> ${CONFIG_MK}
+    LIBRARIES_DEBUG="$LIBRARIES_DEBUG $SRC_LA"
 done
 
 echo >> ${CONFIG_MK}
 echo "libraries:${LIBRARIES} ${TYPES}" >> ${CONFIG_MK}
 
 echo >> ${CONFIG_MK}
+echo "libraries-debug:${LIBRARIES_DEBUG} ${TYPES}" >> ${CONFIG_MK}
+
+echo >> ${CONFIG_MK}
 echo "libraries-install: ${LIBRARIES}" >> ${CONFIG_MK}
 for LIB in $LIBRARIES; do
     echo "	\${LIBTOOL} --tag=CC --mode=install \${INSTALL} -o \${OWNER} -g \${GROUP} -m 0755 $LIB \${LIBDIR}" >> ${CONFIG_MK}
@@ -138,6 +156,12 @@ for DIR in $DIRS; do
 done
 
 echo >> ${CONFIG_MK}
+echo "subdirs-debug:" >> ${CONFIG_MK}
+for DIR in $DIRS; do
+    echo "	\${MAKE} -C $DIR debug" >> ${CONFIG_MK}
+done
+
+echo >> ${CONFIG_MK}
 echo "subdirs-install: libraries" >> ${CONFIG_MK}
 for DIR in $DIRS; do
     echo "	\${MAKE} -C $DIR install" >> ${CONFIG_MK}
@@ -154,6 +178,6 @@ for TYPE_SRC in $TYPE_SOURCES; do
 done
 
 echo >> ${CONFIG_MK}
-echo ".PHONY: types libraries install subdirs subdirs-clean subdirs-install" >> ${CONFIG_MK}
+echo ".PHONY: types libraries libraries-debug install subdirs subdirs-clean subdirs-debug subdirs-install" >> ${CONFIG_MK}
 
 update_config_mk
diff --git a/lib/dynamic/Makefile b/lib/dynamic/Makefile
index 4f5818b..f64ee79 100644
--- a/lib/dynamic/Makefile
+++ b/lib/dynamic/Makefile
@@ -11,11 +11,16 @@
 ## AUTHOR BE CONSIDERED LIABLE FOR THE USE AND PERFORMANCE OF
 ## THIS SOFTWARE.
 
-all: libraries
+build: libraries
+
+all: build debug
 
 clean:
-	rm -rf .libs *.o *.lo *.la
+	rm -rf .libs *.o *.lo *.la *.gcno *.gcna *.gcda
+
+debug: libraries-debug
 
-.PHONY: all clean libraries
+.PHONY: all clean debug libraries libraries-debug
 
 include config.mk
+include sources.mk
diff --git a/lib/dynamic/configure b/lib/dynamic/configure
index 99b624c..025d5f3 100755
--- a/lib/dynamic/configure
+++ b/lib/dynamic/configure
@@ -33,30 +33,34 @@ CPPFLAGS="$CPPFLAGS -DRTBUF_LIBDIR=\\\"${RTBUF_LIBDIR}\\\""
 CPPFLAGS="$CPPFLAGS -DVER=\\\"${VER}\\\""
 config_asan
 config_gnu
-pkg_config libbsd-overlay
-pkg_config libffi
-pkg_config libmd
 
 # Address Sanitizer config
 CFLAGS_ASAN="$CFLAGS -fsanitize=address -O1 -fno-omit-frame-pointer -g"
 LDFLAGS_ASAN="$LDFLAGS"
 LIBS_ASAN="$LIBS"
+LIBS_ASAN="$LIBS_ASAN $SRC_TOP/lib/librtbuf_signal_asan.la"
+LIBS_ASAN="$LIBS_ASAN $SRC_TOP/librtbuf/librtbuf_asan.la"
 
 # Coverage config
 CFLAGS_COV="$CFLAGS -ftest-coverage -fprofile-arcs"
 LDFLAGS_COV="$LDFLAGS"
 LIBS_COV="$LIBS"
+LIBS_COV="$LIBS_COV $SRC_TOP/lib/librtbuf_signal_cov.la"
+LIBS_COV="$LIBS_COV $SRC_TOP/librtbuf/librtbuf_cov.la"
 
 # Debug config
 CFLAGS_DEBUG="$CFLAGS -DDEBUG -O0 -ggdb"
 LDFLAGS_DEBUG="$LDFLAGS"
 LIBS_DEBUG="$LIBS"
+LIBS_DEBUG="$LIBS_DEBUG $SRC_TOP/lib/librtbuf_signal_debug.la"
+LIBS_DEBUG="$LIBS_DEBUG $SRC_TOP/librtbuf/librtbuf_debug.la"
 
 # Main config
 if [ "x$ENV_CFLAGS" = "x" ]; then
     CFLAGS="$CFLAGS $DEFAULT_CFLAGS"
 fi
 CFLAGS="$CFLAGS -DNDEBUG"
+LIBS="$LIBS"
 LIBS="$LIBS $SRC_TOP/lib/librtbuf_signal.la"
 LIBS="$LIBS $SRC_TOP/librtbuf/librtbuf.la"
 
diff --git a/lib/glfw3/Makefile b/lib/glfw3/Makefile
index 8f3e573..a1b7196 100644
--- a/lib/glfw3/Makefile
+++ b/lib/glfw3/Makefile
@@ -11,11 +11,16 @@
 ## AUTHOR BE CONSIDERED LIABLE FOR THE USE AND PERFORMANCE OF
 ## THIS SOFTWARE.
 
-all: libraries
+build: libraries
+
+all: build debug
 
 clean:
 	rm -rf .libs *.o *.lo *.la *.gcno *.gcna *.gcda
 
-.PHONY: all clean libraries
+debug: libraries-debug
+
+.PHONY: all clean libraries libraries-debug
 
 include config.mk
+include sources.mk
diff --git a/lib/portaudio/Makefile b/lib/portaudio/Makefile
index 8f3e573..f64ee79 100644
--- a/lib/portaudio/Makefile
+++ b/lib/portaudio/Makefile
@@ -11,11 +11,16 @@
 ## AUTHOR BE CONSIDERED LIABLE FOR THE USE AND PERFORMANCE OF
 ## THIS SOFTWARE.
 
-all: libraries
+build: libraries
+
+all: build debug
 
 clean:
 	rm -rf .libs *.o *.lo *.la *.gcno *.gcna *.gcda
 
-.PHONY: all clean libraries
+debug: libraries-debug
+
+.PHONY: all clean debug libraries libraries-debug
 
 include config.mk
+include sources.mk
diff --git a/lib/reverb/Makefile b/lib/reverb/Makefile
index 8f3e573..f64ee79 100644
--- a/lib/reverb/Makefile
+++ b/lib/reverb/Makefile
@@ -11,11 +11,16 @@
 ## AUTHOR BE CONSIDERED LIABLE FOR THE USE AND PERFORMANCE OF
 ## THIS SOFTWARE.
 
-all: libraries
+build: libraries
+
+all: build debug
 
 clean:
 	rm -rf .libs *.o *.lo *.la *.gcno *.gcna *.gcda
 
-.PHONY: all clean libraries
+debug: libraries-debug
+
+.PHONY: all clean debug libraries libraries-debug
 
 include config.mk
+include sources.mk
diff --git a/lib/signal/Makefile b/lib/signal/Makefile
index 8f3e573..f64ee79 100644
--- a/lib/signal/Makefile
+++ b/lib/signal/Makefile
@@ -11,11 +11,16 @@
 ## AUTHOR BE CONSIDERED LIABLE FOR THE USE AND PERFORMANCE OF
 ## THIS SOFTWARE.
 
-all: libraries
+build: libraries
+
+all: build debug
 
 clean:
 	rm -rf .libs *.o *.lo *.la *.gcno *.gcna *.gcda
 
-.PHONY: all clean libraries
+debug: libraries-debug
+
+.PHONY: all clean debug libraries libraries-debug
 
 include config.mk
+include sources.mk
diff --git a/lib/sndio/Makefile b/lib/sndio/Makefile
index 8f3e573..f64ee79 100644
--- a/lib/sndio/Makefile
+++ b/lib/sndio/Makefile
@@ -11,11 +11,16 @@
 ## AUTHOR BE CONSIDERED LIABLE FOR THE USE AND PERFORMANCE OF
 ## THIS SOFTWARE.
 
-all: libraries
+build: libraries
+
+all: build debug
 
 clean:
 	rm -rf .libs *.o *.lo *.la *.gcno *.gcna *.gcda
 
-.PHONY: all clean libraries
+debug: libraries-debug
+
+.PHONY: all clean debug libraries libraries-debug
 
 include config.mk
+include sources.mk
diff --git a/lib/synth/Makefile b/lib/synth/Makefile
index 8f3e573..f64ee79 100644
--- a/lib/synth/Makefile
+++ b/lib/synth/Makefile
@@ -11,11 +11,16 @@
 ## AUTHOR BE CONSIDERED LIABLE FOR THE USE AND PERFORMANCE OF
 ## THIS SOFTWARE.
 
-all: libraries
+build: libraries
+
+all: build debug
 
 clean:
 	rm -rf .libs *.o *.lo *.la *.gcno *.gcna *.gcda
 
-.PHONY: all clean libraries
+debug: libraries-debug
+
+.PHONY: all clean debug libraries libraries-debug
 
 include config.mk
+include sources.mk
diff --git a/librtbuf/rtbuf.c b/librtbuf/rtbuf.c
index 2545685..402f907 100644
--- a/librtbuf/rtbuf.c
+++ b/librtbuf/rtbuf.c
@@ -38,6 +38,7 @@ unsigned int  g_rtbuf_sort = 0;
 unsigned int  g_rtbuf_sorted[RTBUF_MAX];
 unsigned int  g_rtbuf_sorted_n = 0;
 
+f_rtbuf_err_cb    g_rtbuf_err_cb = 0;
 f_rtbuf_new_cb    g_rtbuf_new_cb = 0;
 f_rtbuf_delete_cb g_rtbuf_delete_cb = 0;
 f_rtbuf_bind_cb   g_rtbuf_bind_cb = 0;
@@ -68,6 +69,20 @@ void librtbuf_shutdown ()
   libdata_shutdown();
 }
 
+int rtbuf_err (const char *msg)
+{
+  if (g_rtbuf_err_cb)
+    g_rtbuf_err_cb(msg);
+  else
+    rtbuf_err_default(msg);
+  return -1;
+}
+
+void rtbuf_err_default (const char *msg)
+{
+  fprintf(stderr, "rtbuf: %s\n", msg);
+}
+
 int rtbuf_new (s_rtbuf_proc *rp)
 {
   return rtbuf_new_ptr(rp, NULL);
@@ -563,6 +578,7 @@ int rtbuf_out_int (s_rtbuf *rtb, unsigned int out, int default_value)
 void rtbuf_print (const s_rtbuf *rtbuf)
 {
   unsigned int i;
+  assert(rtbuf);
   if (rtbuf >= g_rtbuf &&
       (i = rtbuf - g_rtbuf) < RTBUF_MAX)
     printf("#<rtbuf %i %s>\n", i, rtbuf->proc->lib->name);
@@ -596,7 +612,7 @@ void rtbuf_print_long (const s_rtbuf *rtbuf)
   s_rtbuf_proc *proc;
   int i;
   unsigned int j = 0;
-  assert(i < RTBUF_MAX);
+  assert(rtbuf);
   proc = rtbuf->proc;
   if (rtbuf >= g_rtbuf &&
       (i = rtbuf - g_rtbuf) < RTBUF_MAX)
@@ -646,12 +662,6 @@ double clamp (double inf, double x, double sup)
   return max(inf, min(x, sup));
 }
 
-int rtbuf_err (const char *msg)
-{
-  fprintf(stderr, "%s\n", msg);
-  return -1;
-}
-
 double * rtbuf_in_unbound_value (s_rtbuf *rtb, unsigned int in)
 {
   unsigned int offset;
diff --git a/librtbuf/rtbuf.h b/librtbuf/rtbuf.h
index 76b2253..6a00531 100644
--- a/librtbuf/rtbuf.h
+++ b/librtbuf/rtbuf.h
@@ -110,6 +110,11 @@ extern int          g_rtbuf_run;
 extern int          g_rtbuf_running;
 
 /**
+ * @brief Callback function for rtbuf_err.
+ */
+typedef void (*f_rtbuf_err_cb) (const char *msg);
+
+/**
  * @brief Callback function for rtbuf_new.
  */
 typedef void (*f_rtbuf_new_cb) (s_rtbuf *rtb);
@@ -132,6 +137,11 @@ typedef void (*f_rtbuf_unbind_cb) (s_rtbuf *src, unsigned int out,
                                    s_rtbuf *dest, unsigned int in);
 
 /**
+ * @brief Callback function for rtbuf_err.
+ */
+extern f_rtbuf_err_cb    g_rtbuf_err_cb;
+
+/**
  * @brief Callback function for rtbuf_new.
  */
 extern f_rtbuf_new_cb    g_rtbuf_new_cb;
@@ -172,6 +182,8 @@ void librtbuf_shutdown ();
 
 int rtbuf_err (const char *msg);
 
+void rtbuf_err_default (const char *msg);
+
 /**
  * @brief Create a new real time buffer.
  *
diff --git a/test/sinus b/test/sinus
index 1c3f238..5c654fd 100644
--- a/test/sinus
+++ b/test/sinus
@@ -1,6 +1,6 @@
 load signal/sinus
-let sinus00 = new signal/sinus
+let sinus00 = new signal/sinus 10 10
 load portaudio/output
-let output00 = new portaudio/output
+let output00 = new portaudio/output 200 400
 bind sinus00 signal output00 left
 bind sinus00 signal output00 right