Anchor filename locations in .gitignore
[nasm.git] / nasmlib.c
blob7f7fdef7d97fe8b6b209484b6a9d2d3da8e5f197
1 /* nasmlib.c library routines for the Netwide Assembler
3 * The Netwide Assembler is copyright (C) 1996 Simon Tatham and
4 * Julian Hall. All rights reserved. The software is
5 * redistributable under the licence given in the file "Licence"
6 * distributed in the NASM archive.
7 */
9 #include "compiler.h"
11 #include <stdio.h>
12 #include <stdlib.h>
13 #include <string.h>
14 #include <ctype.h>
15 #include <inttypes.h>
17 #include "nasm.h"
18 #include "nasmlib.h"
19 #include "insns.h"
21 int globalbits = 0; /* defined in nasm.h, works better here for ASM+DISASM */
22 efunc nasm_malloc_error; /* Exported for the benefit of vsnprintf.c */
24 #ifdef LOGALLOC
25 static FILE *logfp;
26 #endif
28 void nasm_set_malloc_error(efunc error)
30 nasm_malloc_error = error;
31 #ifdef LOGALLOC
32 logfp = fopen("malloc.log", "w");
33 setvbuf(logfp, NULL, _IOLBF, BUFSIZ);
34 fprintf(logfp, "null pointer is %p\n", NULL);
35 #endif
38 #ifdef LOGALLOC
39 void *nasm_malloc_log(char *file, int line, size_t size)
40 #else
41 void *nasm_malloc(size_t size)
42 #endif
44 void *p = malloc(size);
45 if (!p)
46 nasm_malloc_error(ERR_FATAL | ERR_NOFILE, "out of memory");
47 #ifdef LOGALLOC
48 else
49 fprintf(logfp, "%s %d malloc(%ld) returns %p\n",
50 file, line, (long)size, p);
51 #endif
52 return p;
55 #ifdef LOGALLOC
56 void *nasm_zalloc_log(char *file, int line, size_t size)
57 #else
58 void *nasm_zalloc(size_t size)
59 #endif
61 void *p = calloc(size, 1);
62 if (!p)
63 nasm_malloc_error(ERR_FATAL | ERR_NOFILE, "out of memory");
64 #ifdef LOGALLOC
65 else
66 fprintf(logfp, "%s %d calloc(%ld, 1) returns %p\n",
67 file, line, (long)size, p);
68 #endif
69 return p;
72 #ifdef LOGALLOC
73 void *nasm_realloc_log(char *file, int line, void *q, size_t size)
74 #else
75 void *nasm_realloc(void *q, size_t size)
76 #endif
78 void *p = q ? realloc(q, size) : malloc(size);
79 if (!p)
80 nasm_malloc_error(ERR_FATAL | ERR_NOFILE, "out of memory");
81 #ifdef LOGALLOC
82 else if (q)
83 fprintf(logfp, "%s %d realloc(%p,%ld) returns %p\n",
84 file, line, q, (long)size, p);
85 else
86 fprintf(logfp, "%s %d malloc(%ld) returns %p\n",
87 file, line, (long)size, p);
88 #endif
89 return p;
92 #ifdef LOGALLOC
93 void nasm_free_log(char *file, int line, void *q)
94 #else
95 void nasm_free(void *q)
96 #endif
98 if (q) {
99 free(q);
100 #ifdef LOGALLOC
101 fprintf(logfp, "%s %d free(%p)\n", file, line, q);
102 #endif
106 #ifdef LOGALLOC
107 char *nasm_strdup_log(char *file, int line, const char *s)
108 #else
109 char *nasm_strdup(const char *s)
110 #endif
112 char *p;
113 int size = strlen(s) + 1;
115 p = malloc(size);
116 if (!p)
117 nasm_malloc_error(ERR_FATAL | ERR_NOFILE, "out of memory");
118 #ifdef LOGALLOC
119 else
120 fprintf(logfp, "%s %d strdup(%ld) returns %p\n",
121 file, line, (long)size, p);
122 #endif
123 strcpy(p, s);
124 return p;
127 #ifdef LOGALLOC
128 char *nasm_strndup_log(char *file, int line, char *s, size_t len)
129 #else
130 char *nasm_strndup(char *s, size_t len)
131 #endif
133 char *p;
134 int size = len + 1;
136 p = malloc(size);
137 if (!p)
138 nasm_malloc_error(ERR_FATAL | ERR_NOFILE, "out of memory");
139 #ifdef LOGALLOC
140 else
141 fprintf(logfp, "%s %d strndup(%ld) returns %p\n",
142 file, line, (long)size, p);
143 #endif
144 strncpy(p, s, len);
145 p[len] = '\0';
146 return p;
149 #ifndef nasm_stricmp
150 int nasm_stricmp(const char *s1, const char *s2)
152 while (*s1 && tolower(*s1) == tolower(*s2))
153 s1++, s2++;
154 if (!*s1 && !*s2)
155 return 0;
156 else if (tolower(*s1) < tolower(*s2))
157 return -1;
158 else
159 return 1;
161 #endif
163 #ifndef nasm_strnicmp
164 int nasm_strnicmp(const char *s1, const char *s2, int n)
166 while (n > 0 && *s1 && tolower(*s1) == tolower(*s2))
167 s1++, s2++, n--;
168 if ((!*s1 && !*s2) || n == 0)
169 return 0;
170 else if (tolower(*s1) < tolower(*s2))
171 return -1;
172 else
173 return 1;
175 #endif
177 #ifndef nasm_strsep
178 char *nasm_strsep(char **stringp, const char *delim)
180 char *s = *stringp;
181 char *e;
183 if (!s)
184 return NULL;
186 e = strpbrk(s, delim);
187 if (e)
188 *e++ = '\0';
190 *stringp = e;
191 return s;
193 #endif
196 #define lib_isnumchar(c) (isalnum(c) || (c) == '$' || (c) == '_')
197 #define numvalue(c) ((c)>='a' ? (c)-'a'+10 : (c)>='A' ? (c)-'A'+10 : (c)-'0')
199 int64_t readnum(char *str, bool *error)
201 char *r = str, *q;
202 int32_t radix;
203 uint64_t result, checklimit;
204 int digit, last;
205 bool warn = false;
206 int sign = 1;
208 *error = false;
210 while (isspace(*r))
211 r++; /* find start of number */
214 * If the number came from make_tok_num (as a result of an %assign), it
215 * might have a '-' built into it (rather than in a preceeding token).
217 if (*r == '-') {
218 r++;
219 sign = -1;
222 q = r;
224 while (lib_isnumchar(*q))
225 q++; /* find end of number */
228 * If it begins 0x, 0X or $, or ends in H, it's in hex. if it
229 * ends in Q, it's octal. if it ends in B, it's binary.
230 * Otherwise, it's ordinary decimal.
232 if (*r == '0' && (r[1] == 'x' || r[1] == 'X'))
233 radix = 16, r += 2;
234 else if (*r == '$')
235 radix = 16, r++;
236 else if (q[-1] == 'H' || q[-1] == 'h')
237 radix = 16, q--;
238 else if (q[-1] == 'Q' || q[-1] == 'q' || q[-1] == 'O' || q[-1] == 'o')
239 radix = 8, q--;
240 else if (q[-1] == 'B' || q[-1] == 'b' || q[-1] == 'Y' || q[-1] == 'y')
241 radix = 2, q--;
242 else if (q[-1] == 'D' || q[-1] == 'd' || q[-1] == 'T' || q[-1] == 't')
243 radix = 10, q--;
244 else
245 radix = 10;
248 * If this number has been found for us by something other than
249 * the ordinary scanners, then it might be malformed by having
250 * nothing between the prefix and the suffix. Check this case
251 * now.
253 if (r >= q) {
254 *error = true;
255 return 0;
259 * `checklimit' must be 2**(32|64) / radix. We can't do that in
260 * 32/64-bit arithmetic, which we're (probably) using, so we
261 * cheat: since we know that all radices we use are even, we
262 * can divide 2**(31|63) by radix/2 instead.
264 if (globalbits == 64)
265 checklimit = 0x8000000000000000ULL / (radix >> 1);
266 else
267 checklimit = 0x80000000UL / (radix >> 1);
270 * Calculate the highest allowable value for the last digit of a
271 * 32-bit constant... in radix 10, it is 6, otherwise it is 0
273 last = (radix == 10 ? 6 : 0);
275 result = 0;
276 while (*r && r < q) {
277 if (*r != '_') {
278 if (*r < '0' || (*r > '9' && *r < 'A')
279 || (digit = numvalue(*r)) >= radix) {
280 *error = true;
281 return 0;
283 if (result > checklimit ||
284 (result == checklimit && digit >= last)) {
285 warn = true;
288 result = radix * result + digit;
290 r++;
293 if (warn)
294 nasm_malloc_error(ERR_WARNING | ERR_PASS1 | ERR_WARN_NOV,
295 "numeric constant %s does not fit in 32 bits",
296 str);
298 return result * sign;
301 int64_t readstrnum(char *str, int length, bool *warn)
303 int64_t charconst = 0;
304 int i;
306 *warn = false;
308 str += length;
309 if (globalbits == 64) {
310 for (i = 0; i < length; i++) {
311 if (charconst & 0xFF00000000000000ULL)
312 *warn = true;
313 charconst = (charconst << 8) + (uint8_t)*--str;
315 } else {
316 for (i = 0; i < length; i++) {
317 if (charconst & 0xFF000000UL)
318 *warn = true;
319 charconst = (charconst << 8) + (uint8_t)*--str;
322 return charconst;
325 static int32_t next_seg;
327 void seg_init(void)
329 next_seg = 0;
332 int32_t seg_alloc(void)
334 return (next_seg += 2) - 2;
337 void fwriteint16_t(int data, FILE * fp)
339 fputc((int)(data & 255), fp);
340 fputc((int)((data >> 8) & 255), fp);
343 void fwriteint32_t(int32_t data, FILE * fp)
345 fputc((int)(data & 255), fp);
346 fputc((int)((data >> 8) & 255), fp);
347 fputc((int)((data >> 16) & 255), fp);
348 fputc((int)((data >> 24) & 255), fp);
351 void fwriteint64_t(int64_t data, FILE * fp)
353 fputc((int)(data & 255), fp);
354 fputc((int)((data >> 8) & 255), fp);
355 fputc((int)((data >> 16) & 255), fp);
356 fputc((int)((data >> 24) & 255), fp);
357 fputc((int)((data >> 32) & 255), fp);
358 fputc((int)((data >> 40) & 255), fp);
359 fputc((int)((data >> 48) & 255), fp);
360 fputc((int)((data >> 56) & 255), fp);
363 void standard_extension(char *inname, char *outname, char *extension,
364 efunc error)
366 char *p, *q;
368 if (*outname) /* file name already exists, */
369 return; /* so do nothing */
370 q = inname;
371 p = outname;
372 while (*q)
373 *p++ = *q++; /* copy, and find end of string */
374 *p = '\0'; /* terminate it */
375 while (p > outname && *--p != '.') ; /* find final period (or whatever) */
376 if (*p != '.')
377 while (*p)
378 p++; /* go back to end if none found */
379 if (!strcmp(p, extension)) { /* is the extension already there? */
380 if (*extension)
381 error(ERR_WARNING | ERR_NOFILE,
382 "file name already ends in `%s': "
383 "output will be in `nasm.out'", extension);
384 else
385 error(ERR_WARNING | ERR_NOFILE,
386 "file name already has no extension: "
387 "output will be in `nasm.out'");
388 strcpy(outname, "nasm.out");
389 } else
390 strcpy(p, extension);
393 #define LEAFSIZ (sizeof(RAA)-sizeof(RAA_UNION)+sizeof(RAA_LEAF))
394 #define BRANCHSIZ (sizeof(RAA)-sizeof(RAA_UNION)+sizeof(RAA_BRANCH))
396 #define LAYERSIZ(r) ( (r)->layers==0 ? RAA_BLKSIZE : RAA_LAYERSIZE )
398 static struct RAA *real_raa_init(int layers)
400 struct RAA *r;
401 int i;
403 if (layers == 0) {
404 r = nasm_zalloc(LEAFSIZ);
405 r->stepsize = 1L;
406 } else {
407 r = nasm_malloc(BRANCHSIZ);
408 r->layers = layers;
409 for (i = 0; i < RAA_LAYERSIZE; i++)
410 r->u.b.data[i] = NULL;
411 r->stepsize = RAA_BLKSIZE;
412 while (--layers)
413 r->stepsize *= RAA_LAYERSIZE;
415 return r;
418 struct RAA *raa_init(void)
420 return real_raa_init(0);
423 void raa_free(struct RAA *r)
425 if (r->layers == 0)
426 nasm_free(r);
427 else {
428 struct RAA **p;
429 for (p = r->u.b.data; p - r->u.b.data < RAA_LAYERSIZE; p++)
430 if (*p)
431 raa_free(*p);
435 int32_t raa_read(struct RAA *r, int32_t posn)
437 if (posn >= r->stepsize * LAYERSIZ(r))
438 return 0; /* Return 0 for undefined entries */
439 while (r->layers > 0) {
440 ldiv_t l;
441 l = ldiv(posn, r->stepsize);
442 r = r->u.b.data[l.quot];
443 posn = l.rem;
444 if (!r)
445 return 0; /* Return 0 for undefined entries */
447 return r->u.l.data[posn];
450 struct RAA *raa_write(struct RAA *r, int32_t posn, int32_t value)
452 struct RAA *result;
454 if (posn < 0)
455 nasm_malloc_error(ERR_PANIC, "negative position in raa_write");
457 while (r->stepsize * LAYERSIZ(r) <= posn) {
459 * Must add a layer.
461 struct RAA *s;
462 int i;
464 s = nasm_malloc(BRANCHSIZ);
465 for (i = 0; i < RAA_LAYERSIZE; i++)
466 s->u.b.data[i] = NULL;
467 s->layers = r->layers + 1;
468 s->stepsize = LAYERSIZ(r) * r->stepsize;
469 s->u.b.data[0] = r;
470 r = s;
473 result = r;
475 while (r->layers > 0) {
476 ldiv_t l;
477 struct RAA **s;
478 l = ldiv(posn, r->stepsize);
479 s = &r->u.b.data[l.quot];
480 if (!*s)
481 *s = real_raa_init(r->layers - 1);
482 r = *s;
483 posn = l.rem;
486 r->u.l.data[posn] = value;
488 return result;
491 /* Aggregate SAA components smaller than this */
492 #define SAA_BLKLEN 65536
494 struct SAA *saa_init(size_t elem_len)
496 struct SAA *s;
497 char *data;
499 s = nasm_zalloc(sizeof(struct SAA));
501 if (elem_len >= SAA_BLKLEN)
502 s->blk_len = elem_len;
503 else
504 s->blk_len = SAA_BLKLEN - (SAA_BLKLEN % elem_len);
506 s->elem_len = elem_len;
507 s->length = s->blk_len;
508 data = nasm_malloc(s->blk_len);
509 s->nblkptrs = s->nblks = 1;
510 s->blk_ptrs = nasm_malloc(sizeof(char *));
511 s->blk_ptrs[0] = data;
512 s->wblk = s->rblk = &s->blk_ptrs[0];
514 return s;
517 void saa_free(struct SAA *s)
519 char **p;
520 size_t n;
522 for (p = s->blk_ptrs, n = s->nblks; n; p++, n--)
523 nasm_free(*p);
525 nasm_free(s->blk_ptrs);
526 nasm_free(s);
529 /* Add one allocation block to an SAA */
530 static void saa_extend(struct SAA *s)
532 size_t blkn = s->nblks++;
534 if (blkn >= s->nblkptrs) {
535 size_t rindex = s->rblk - s->blk_ptrs;
536 size_t windex = s->wblk - s->blk_ptrs;
538 s->nblkptrs <<= 1;
539 s->blk_ptrs = nasm_realloc(s->blk_ptrs, s->nblkptrs*sizeof(char *));
541 s->rblk = s->blk_ptrs + rindex;
542 s->wblk = s->blk_ptrs + windex;
545 s->blk_ptrs[blkn] = nasm_malloc(s->blk_len);
546 s->length += s->blk_len;
549 void *saa_wstruct(struct SAA *s)
551 void *p;
553 if (s->wpos % s->elem_len)
554 nasm_malloc_error(ERR_PANIC|ERR_NOFILE,
555 "misaligned wpos in saa_wstruct");
557 if (s->wpos + s->elem_len > s->blk_len) {
558 if (s->wpos != s->blk_len)
559 nasm_malloc_error(ERR_PANIC|ERR_NOFILE,
560 "unfilled block in saa_wstruct");
562 if (s->wptr + s->elem_len > s->length)
563 saa_extend(s);
564 s->wblk++;
565 s->wpos = 0;
568 p = *s->wblk + s->wpos;
569 s->wpos += s->elem_len;
570 s->wptr += s->elem_len;
572 if (s->wptr > s->datalen)
573 s->datalen = s->wptr;
575 return p;
578 void saa_wbytes(struct SAA *s, const void *data, size_t len)
580 const char *d = data;
582 while (len) {
583 size_t l = s->blk_len - s->wpos;
584 if (l > len)
585 l = len;
586 if (l) {
587 if (d) {
588 memcpy(*s->wblk + s->wpos, d, l);
589 d += l;
590 } else
591 memset(*s->wblk + s->wpos, 0, l);
592 s->wpos += l;
593 s->wptr += l;
594 len -= l;
596 if (s->datalen < s->wptr)
597 s->datalen = s->wptr;
599 if (len) {
600 if (s->wptr >= s->length)
601 saa_extend(s);
602 s->wblk++;
603 s->wpos = 0;
608 void saa_rewind(struct SAA *s)
610 s->rblk = s->blk_ptrs;
611 s->rpos = s->rptr = 0;
614 void *saa_rstruct(struct SAA *s)
616 void *p;
618 if (s->rptr + s->elem_len > s->datalen)
619 return NULL;
621 if (s->rpos % s->elem_len)
622 nasm_malloc_error(ERR_PANIC|ERR_NOFILE,
623 "misaligned rpos in saa_rstruct");
625 if (s->rpos + s->elem_len > s->blk_len) {
626 s->rblk++;
627 s->rpos = 0;
630 p = *s->rblk + s->rpos;
631 s->rpos += s->elem_len;
632 s->rptr += s->elem_len;
634 return p;
637 const void *saa_rbytes(struct SAA *s, size_t *lenp)
639 const void *p;
640 size_t len;
642 if (s->rptr >= s->datalen) {
643 *lenp = 0;
644 return NULL;
647 if (s->rpos >= s->blk_len) {
648 s->rblk++;
649 s->rpos = 0;
652 len = *lenp;
653 if (len > s->datalen - s->rptr)
654 len = s->datalen - s->rptr;
655 if (len > s->blk_len - s->rpos)
656 len = s->blk_len - s->rpos;
658 *lenp = len;
659 p = *s->rblk + s->rpos;
661 s->rpos += len;
662 s->rptr += len;
664 return p;
667 void saa_rnbytes(struct SAA *s, void *data, size_t len)
669 char *d = data;
671 if (s->rptr + len > s->datalen) {
672 nasm_malloc_error(ERR_PANIC|ERR_NOFILE, "overrun in saa_rnbytes");
673 return;
676 while (len) {
677 size_t l;
678 const void *p;
680 l = len;
681 p = saa_rbytes(s, &l);
683 memcpy(d, p, l);
684 d += l;
685 len -= l;
689 /* Same as saa_rnbytes, except position the counter first */
690 void saa_fread(struct SAA *s, size_t posn, void *data, size_t len)
692 size_t ix;
694 if (posn+len > s->datalen) {
695 nasm_malloc_error(ERR_PANIC|ERR_NOFILE, "overrun in saa_fread");
696 return;
699 ix = posn / s->blk_len;
700 s->rptr = posn;
701 s->rpos = posn % s->blk_len;
702 s->rblk = &s->blk_ptrs[ix];
704 saa_rnbytes(s, data, len);
707 /* Same as saa_wbytes, except position the counter first */
708 void saa_fwrite(struct SAA *s, size_t posn, const void *data, size_t len)
710 size_t ix;
712 if (posn > s->datalen) {
713 /* Seek beyond the end of the existing array not supported */
714 nasm_malloc_error(ERR_PANIC|ERR_NOFILE, "overrun in saa_fwrite");
715 return;
718 ix = posn / s->blk_len;
719 s->wptr = posn;
720 s->wpos = posn % s->blk_len;
721 s->wblk = &s->blk_ptrs[ix];
723 if (!s->wpos) {
724 s->wpos = s->blk_len;
725 s->wblk--;
728 saa_wbytes(s, data, len);
731 void saa_fpwrite(struct SAA *s, FILE * fp)
733 const char *data;
734 size_t len;
736 saa_rewind(s);
737 while (len = s->datalen, (data = saa_rbytes(s, &len)) != NULL)
738 fwrite(data, 1, len, fp);
742 * Common list of prefix names
744 static const char *prefix_names[] = {
745 "a16", "a32", "lock", "o16", "o32", "rep", "repe", "repne",
746 "repnz", "repz", "times"
749 const char *prefix_name(int token)
751 unsigned int prefix = token-PREFIX_ENUM_START;
752 if (prefix > sizeof prefix_names / sizeof(const char *))
753 return NULL;
755 return prefix_names[prefix];
759 * Binary search.
761 int bsi(char *string, const char **array, int size)
763 int i = -1, j = size; /* always, i < index < j */
764 while (j - i >= 2) {
765 int k = (i + j) / 2;
766 int l = strcmp(string, array[k]);
767 if (l < 0) /* it's in the first half */
768 j = k;
769 else if (l > 0) /* it's in the second half */
770 i = k;
771 else /* we've got it :) */
772 return k;
774 return -1; /* we haven't got it :( */
777 int bsii(char *string, const char **array, int size)
779 int i = -1, j = size; /* always, i < index < j */
780 while (j - i >= 2) {
781 int k = (i + j) / 2;
782 int l = nasm_stricmp(string, array[k]);
783 if (l < 0) /* it's in the first half */
784 j = k;
785 else if (l > 0) /* it's in the second half */
786 i = k;
787 else /* we've got it :) */
788 return k;
790 return -1; /* we haven't got it :( */
793 static char *file_name = NULL;
794 static int32_t line_number = 0;
796 char *src_set_fname(char *newname)
798 char *oldname = file_name;
799 file_name = newname;
800 return oldname;
803 int32_t src_set_linnum(int32_t newline)
805 int32_t oldline = line_number;
806 line_number = newline;
807 return oldline;
810 int32_t src_get_linnum(void)
812 return line_number;
815 int src_get(int32_t *xline, char **xname)
817 if (!file_name || !*xname || strcmp(*xname, file_name)) {
818 nasm_free(*xname);
819 *xname = file_name ? nasm_strdup(file_name) : NULL;
820 *xline = line_number;
821 return -2;
823 if (*xline != line_number) {
824 int32_t tmp = line_number - *xline;
825 *xline = line_number;
826 return tmp;
828 return 0;
831 void nasm_quote(char **str)
833 int ln = strlen(*str);
834 char q = (*str)[0];
835 char *p;
836 if (ln > 1 && (*str)[ln - 1] == q && (q == '"' || q == '\''))
837 return;
838 q = '"';
839 if (strchr(*str, q))
840 q = '\'';
841 p = nasm_malloc(ln + 3);
842 strcpy(p + 1, *str);
843 nasm_free(*str);
844 p[ln + 1] = p[0] = q;
845 p[ln + 2] = 0;
846 *str = p;
849 char *nasm_strcat(char *one, char *two)
851 char *rslt;
852 int l1 = strlen(one);
853 rslt = nasm_malloc(l1 + strlen(two) + 1);
854 strcpy(rslt, one);
855 strcpy(rslt + l1, two);
856 return rslt;
859 void null_debug_init(struct ofmt *of, void *id, FILE * fp, efunc error)
861 (void)of;
862 (void)id;
863 (void)fp;
864 (void)error;
866 void null_debug_linenum(const char *filename, int32_t linenumber, int32_t segto)
868 (void)filename;
869 (void)linenumber;
870 (void)segto;
872 void null_debug_deflabel(char *name, int32_t segment, int32_t offset,
873 int is_global, char *special)
875 (void)name;
876 (void)segment;
877 (void)offset;
878 (void)is_global;
879 (void)special;
881 void null_debug_routine(const char *directive, const char *params)
883 (void)directive;
884 (void)params;
886 void null_debug_typevalue(int32_t type)
888 (void)type;
890 void null_debug_output(int type, void *param)
892 (void)type;
893 (void)param;
895 void null_debug_cleanup(void)
899 struct dfmt null_debug_form = {
900 "Null debug format",
901 "null",
902 null_debug_init,
903 null_debug_linenum,
904 null_debug_deflabel,
905 null_debug_routine,
906 null_debug_typevalue,
907 null_debug_output,
908 null_debug_cleanup
911 struct dfmt *null_debug_arr[2] = { &null_debug_form, NULL };