debug.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650
  1. /* Debugging extensions for Guile
  2. * Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2002 Free Software Foundation
  3. *
  4. * This program is free software; you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License as published by
  6. * the Free Software Foundation; either version 2, or (at your option)
  7. * any later version.
  8. *
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License
  15. * along with this software; see the file COPYING. If not, write to
  16. * the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
  17. * Boston, MA 02111-1307 USA
  18. *
  19. * As a special exception, the Free Software Foundation gives permission
  20. * for additional uses of the text contained in its release of GUILE.
  21. *
  22. * The exception is that, if you link the GUILE library with other files
  23. * to produce an executable, this does not by itself cause the
  24. * resulting executable to be covered by the GNU General Public License.
  25. * Your use of that executable is in no way restricted on account of
  26. * linking the GUILE library code into it.
  27. *
  28. * This exception does not however invalidate any other reasons why
  29. * the executable file might be covered by the GNU General Public License.
  30. *
  31. * This exception applies only to the code released by the
  32. * Free Software Foundation under the name GUILE. If you copy
  33. * code from other Free Software Foundation releases into a copy of
  34. * GUILE, as the General Public License permits, the exception does
  35. * not apply to the code that you add in this way. To avoid misleading
  36. * anyone as to the status of such modified files, you must delete
  37. * this exception notice from them.
  38. *
  39. * If you write modifications of your own for GUILE, it is your choice
  40. * whether to permit this exception to apply to your modifications.
  41. * If you do not wish that, delete this exception notice.
  42. *
  43. * The author can be reached at djurfeldt@nada.kth.se
  44. * Mikael Djurfeldt, SANS/NADA KTH, 10044 STOCKHOLM, SWEDEN */
  45. #include <stdio.h>
  46. #include "libguile/_scm.h"
  47. #include "libguile/eval.h"
  48. #include "libguile/stackchk.h"
  49. #include "libguile/throw.h"
  50. #include "libguile/macros.h"
  51. #include "libguile/smob.h"
  52. #include "libguile/procprop.h"
  53. #include "libguile/srcprop.h"
  54. #include "libguile/alist.h"
  55. #include "libguile/continuations.h"
  56. #include "libguile/strports.h"
  57. #include "libguile/read.h"
  58. #include "libguile/feature.h"
  59. #include "libguile/dynwind.h"
  60. #include "libguile/modules.h"
  61. #include "libguile/ports.h"
  62. #include "libguile/root.h"
  63. #include "libguile/validate.h"
  64. #include "libguile/debug.h"
  65. /* {Run time control of the debugging evaluator}
  66. */
  67. SCM_DEFINE (scm_debug_options, "debug-options-interface", 0, 1, 0,
  68. (SCM setting),
  69. "")
  70. #define FUNC_NAME s_scm_debug_options
  71. {
  72. SCM ans;
  73. SCM_DEFER_INTS;
  74. ans = scm_options (setting,
  75. scm_debug_opts,
  76. SCM_N_DEBUG_OPTIONS,
  77. FUNC_NAME);
  78. #ifndef SCM_RECKLESS
  79. if (!(1 <= SCM_N_FRAMES && SCM_N_FRAMES <= SCM_MAX_FRAME_SIZE))
  80. {
  81. scm_options (ans, scm_debug_opts, SCM_N_DEBUG_OPTIONS, FUNC_NAME);
  82. SCM_OUT_OF_RANGE (1, setting);
  83. }
  84. #endif
  85. SCM_RESET_DEBUG_MODE;
  86. scm_stack_checking_enabled_p = SCM_STACK_CHECKING_P;
  87. scm_debug_eframe_size = 2 * SCM_N_FRAMES;
  88. SCM_ALLOW_INTS;
  89. return ans;
  90. }
  91. #undef FUNC_NAME
  92. static void
  93. with_traps_before (void *data)
  94. {
  95. int *trap_flag = data;
  96. *trap_flag = SCM_TRAPS_P;
  97. SCM_TRAPS_P = 1;
  98. }
  99. static void
  100. with_traps_after (void *data)
  101. {
  102. int *trap_flag = data;
  103. SCM_TRAPS_P = *trap_flag;
  104. }
  105. static SCM
  106. with_traps_inner (void *data)
  107. {
  108. SCM thunk = SCM_PACK (data);
  109. return scm_apply (thunk, SCM_EOL, SCM_EOL);
  110. }
  111. SCM_DEFINE (scm_with_traps, "with-traps", 1, 0, 0,
  112. (SCM thunk),
  113. "")
  114. #define FUNC_NAME s_scm_with_traps
  115. {
  116. int trap_flag;
  117. SCM_VALIDATE_THUNK (1,thunk);
  118. return scm_internal_dynamic_wind (with_traps_before,
  119. with_traps_inner,
  120. with_traps_after,
  121. (void *) SCM_UNPACK (thunk),
  122. &trap_flag);
  123. }
  124. #undef FUNC_NAME
  125. static SCM scm_sym_source, scm_sym_dots;
  126. static SCM scm_sym_procname;
  127. /* {Memoized Source}
  128. */
  129. long scm_tc16_memoized;
  130. static int
  131. prinmemoized (SCM obj,SCM port,scm_print_state *pstate)
  132. {
  133. int writingp = SCM_WRITINGP (pstate);
  134. scm_puts ("#<memoized ", port);
  135. SCM_SET_WRITINGP (pstate, 1);
  136. #ifdef GUILE_DEBUG
  137. scm_iprin1 (SCM_MEMOIZED_EXP (obj), port, pstate);
  138. #else
  139. scm_iprin1 (scm_unmemoize (obj), port, pstate);
  140. #endif
  141. SCM_SET_WRITINGP (pstate, writingp);
  142. scm_putc ('>', port);
  143. return 1;
  144. }
  145. SCM_DEFINE (scm_memoized_p, "memoized?", 1, 0, 0,
  146. (SCM obj),
  147. "")
  148. #define FUNC_NAME s_scm_memoized_p
  149. {
  150. return SCM_BOOL(SCM_MEMOIZEDP (obj));
  151. }
  152. #undef FUNC_NAME
  153. SCM
  154. scm_make_memoized (SCM exp, SCM env)
  155. {
  156. /* *fixme* Check that env is a valid environment. */
  157. register SCM z, ans;
  158. SCM_ENTER_A_SECTION;
  159. SCM_NEWSMOB (z, SCM_UNPACK (exp), SCM_UNPACK (env));
  160. SCM_NEWSMOB (ans, scm_tc16_memoized, SCM_UNPACK (z));
  161. SCM_EXIT_A_SECTION;
  162. return ans;
  163. }
  164. #ifdef GUILE_DEBUG
  165. /*
  166. * Some primitives for construction of memoized code
  167. *
  168. * - procedure: memcons CAR CDR [ENV]
  169. *
  170. * Construct a pair, encapsulated in a memoized object.
  171. *
  172. * The CAR and CDR can be either normal or memoized. If ENV isn't
  173. * specified, the top-level environment of the current module will
  174. * be assumed. All environments must match.
  175. *
  176. * - procedure: make-gloc VARIABLE [ENV]
  177. *
  178. * Return a gloc, encapsulated in a memoized object.
  179. *
  180. * (Glocs can't exist in normal list structures, since they will
  181. * be mistaken for structs.)
  182. *
  183. * - procedure: gloc? OBJECT
  184. *
  185. * Return #t if OBJECT is a memoized gloc.
  186. *
  187. * - procedure: make-iloc FRAME BINDING CDRP
  188. *
  189. * Return an iloc referring to frame no. FRAME, binding
  190. * no. BINDING. If CDRP is non-#f, the iloc is referring to a
  191. * frame consisting of a single pair, with the value stored in the
  192. * CDR.
  193. *
  194. * - procedure: iloc? OBJECT
  195. *
  196. * Return #t if OBJECT is an iloc.
  197. *
  198. * - procedure: mem->proc MEMOIZED
  199. *
  200. * Construct a closure from the memoized lambda expression MEMOIZED
  201. *
  202. * WARNING! The code is not copied!
  203. *
  204. * - procedure: proc->mem CLOSURE
  205. *
  206. * Turn the closure CLOSURE into a memoized object.
  207. *
  208. * WARNING! The code is not copied!
  209. *
  210. * - constant: SCM_IM_AND
  211. * - constant: SCM_IM_BEGIN
  212. * - constant: SCM_IM_CASE
  213. * - constant: SCM_IM_COND
  214. * - constant: SCM_IM_DO
  215. * - constant: SCM_IM_IF
  216. * - constant: SCM_IM_LAMBDA
  217. * - constant: SCM_IM_LET
  218. * - constant: SCM_IM_LETSTAR
  219. * - constant: SCM_IM_LETREC
  220. * - constant: SCM_IM_OR
  221. * - constant: SCM_IM_QUOTE
  222. * - constant: SCM_IM_SET
  223. * - constant: SCM_IM_DEFINE
  224. * - constant: SCM_IM_APPLY
  225. * - constant: SCM_IM_CONT
  226. * - constant: SCM_IM_DISPATCH
  227. */
  228. #include "libguile/variable.h"
  229. #include "libguile/procs.h"
  230. SCM_DEFINE (scm_make_gloc, "make-gloc", 1, 1, 0,
  231. (SCM var, SCM env),
  232. "")
  233. #define FUNC_NAME s_scm_make_gloc
  234. {
  235. #if 1 /* Unsafe */
  236. if (SCM_CONSP (var))
  237. var = scm_cons (SCM_BOOL_F, var);
  238. else
  239. #endif
  240. SCM_VALIDATE_VARIABLE (1,var);
  241. if (SCM_UNBNDP (env))
  242. env = scm_top_level_env (SCM_CDR (scm_top_level_lookup_closure_var));
  243. else
  244. SCM_VALIDATE_NULLORCONS (2,env);
  245. return scm_make_memoized (SCM_VARVCELL (var) + 1, env);
  246. }
  247. #undef FUNC_NAME
  248. SCM_DEFINE (scm_gloc_p, "gloc?", 1, 0, 0,
  249. (SCM obj),
  250. "")
  251. #define FUNC_NAME s_scm_gloc_p
  252. {
  253. return SCM_BOOL((SCM_MEMOIZEDP (obj)
  254. && (SCM_UNPACK(SCM_MEMOIZED_EXP (obj)) & 7) == 1));
  255. }
  256. #undef FUNC_NAME
  257. SCM_DEFINE (scm_make_iloc, "make-iloc", 3, 0, 0,
  258. (SCM frame, SCM binding, SCM cdrp),
  259. "")
  260. #define FUNC_NAME s_scm_make_iloc
  261. {
  262. SCM_VALIDATE_INUM (1,frame);
  263. SCM_VALIDATE_INUM (2,binding);
  264. return (SCM_ILOC00
  265. + SCM_IFRINC * SCM_INUM (frame)
  266. + (SCM_NFALSEP (cdrp) ? SCM_ICDR : 0)
  267. + SCM_IDINC * SCM_INUM (binding));
  268. }
  269. #undef FUNC_NAME
  270. SCM_DEFINE (scm_iloc_p, "iloc?", 1, 0, 0,
  271. (SCM obj),
  272. "")
  273. #define FUNC_NAME s_scm_iloc_p
  274. {
  275. return SCM_BOOL(SCM_ILOCP (obj));
  276. }
  277. #undef FUNC_NAME
  278. SCM_DEFINE (scm_memcons, "memcons", 2, 1, 0,
  279. (SCM car, SCM cdr, SCM env),
  280. "")
  281. #define FUNC_NAME s_scm_memcons
  282. {
  283. if (SCM_MEMOIZEDP (car))
  284. {
  285. /*fixme* environments may be two different but equal top-level envs */
  286. if (!SCM_UNBNDP (env) && SCM_MEMOIZED_ENV (car) != env)
  287. SCM_MISC_ERROR ("environment mismatch arg1 <-> arg3",
  288. scm_cons2 (car, env, SCM_EOL));
  289. else
  290. env = SCM_MEMOIZED_ENV (car);
  291. car = SCM_MEMOIZED_EXP (car);
  292. }
  293. if (SCM_MEMOIZEDP (cdr))
  294. {
  295. if (!SCM_UNBNDP (env) && SCM_MEMOIZED_ENV (cdr) != env)
  296. SCM_MISC_ERROR ("environment mismatch arg2 <-> arg3",
  297. scm_cons2 (cdr, env, SCM_EOL));
  298. else
  299. env = SCM_MEMOIZED_ENV (cdr);
  300. cdr = SCM_MEMOIZED_EXP (cdr);
  301. }
  302. if (SCM_UNBNDP (env))
  303. env = scm_top_level_env (SCM_CDR (scm_top_level_lookup_closure_var));
  304. else
  305. SCM_VALIDATE_NULLORCONS (3,env);
  306. return scm_make_memoized (scm_cons (car, cdr), env);
  307. }
  308. #undef FUNC_NAME
  309. SCM_DEFINE (scm_mem_to_proc, "mem->proc", 1, 0, 0,
  310. (SCM obj),
  311. "")
  312. #define FUNC_NAME s_scm_mem_to_proc
  313. {
  314. SCM env;
  315. SCM_VALIDATE_MEMOIZED (1,obj);
  316. env = SCM_MEMOIZED_ENV (obj);
  317. obj = SCM_MEMOIZED_EXP (obj);
  318. if (!(SCM_NIMP (obj) && SCM_CAR (obj) == SCM_IM_LAMBDA))
  319. SCM_MISC_ERROR ("expected lambda expression",
  320. scm_cons (obj, SCM_EOL));
  321. return scm_closure (SCM_CDR (obj), env);
  322. }
  323. #undef FUNC_NAME
  324. SCM_DEFINE (scm_proc_to_mem, "proc->mem", 1, 0, 0,
  325. (SCM obj),
  326. "")
  327. #define FUNC_NAME s_scm_proc_to_mem
  328. {
  329. SCM_VALIDATE_CLOSURE (1, obj);
  330. return scm_make_memoized (scm_cons (SCM_IM_LAMBDA, SCM_CODE (obj)),
  331. SCM_ENV (obj));
  332. }
  333. #undef FUNC_NAME
  334. #endif /* GUILE_DEBUG */
  335. SCM_DEFINE (scm_unmemoize, "unmemoize", 1, 0, 0,
  336. (SCM m),
  337. "")
  338. #define FUNC_NAME s_scm_unmemoize
  339. {
  340. SCM_VALIDATE_MEMOIZED (1,m);
  341. return scm_unmemocopy (SCM_MEMOIZED_EXP (m), SCM_MEMOIZED_ENV (m));
  342. }
  343. #undef FUNC_NAME
  344. SCM_DEFINE (scm_memoized_environment, "memoized-environment", 1, 0, 0,
  345. (SCM m),
  346. "")
  347. #define FUNC_NAME s_scm_memoized_environment
  348. {
  349. SCM_VALIDATE_MEMOIZED (1,m);
  350. return SCM_MEMOIZED_ENV (m);
  351. }
  352. #undef FUNC_NAME
  353. SCM_DEFINE (scm_procedure_name, "procedure-name", 1, 0, 0,
  354. (SCM proc),
  355. "")
  356. #define FUNC_NAME s_scm_procedure_name
  357. {
  358. SCM_VALIDATE_PROC (1,proc);
  359. switch (SCM_TYP7 (proc)) {
  360. case scm_tcs_subrs:
  361. return SCM_SNAME (proc);
  362. default:
  363. {
  364. SCM name = scm_procedure_property (proc, scm_sym_name);
  365. #if 0
  366. /* Source property scm_sym_procname not implemented yet... */
  367. SCM name = scm_source_property (SCM_CAR (SCM_CDR (SCM_CODE (proc))), scm_sym_procname);
  368. if (SCM_FALSEP (name))
  369. name = scm_procedure_property (proc, scm_sym_name);
  370. #endif
  371. if (SCM_FALSEP (name) && SCM_CLOSUREP (proc))
  372. name = scm_reverse_lookup (SCM_ENV (proc), proc);
  373. return name;
  374. }
  375. }
  376. }
  377. #undef FUNC_NAME
  378. SCM_DEFINE (scm_procedure_source, "procedure-source", 1, 0, 0,
  379. (SCM proc),
  380. "")
  381. #define FUNC_NAME s_scm_procedure_source
  382. {
  383. SCM_VALIDATE_NIM (1,proc);
  384. switch (SCM_TYP7 (proc)) {
  385. case scm_tcs_closures:
  386. {
  387. SCM src;
  388. src = scm_source_property (SCM_CDR (SCM_CODE (proc)), scm_sym_copy);
  389. if (! SCM_FALSEP (src))
  390. return scm_cons2 (scm_sym_lambda, SCM_CAR (SCM_CODE (proc)), src);
  391. src = SCM_CODE (proc);
  392. return scm_cons (scm_sym_lambda,
  393. scm_unmemocopy (src,
  394. SCM_EXTEND_ENV (SCM_CAR (src),
  395. SCM_EOL,
  396. SCM_ENV (proc))));
  397. }
  398. case scm_tc7_contin:
  399. case scm_tcs_subrs:
  400. #ifdef CCLO
  401. case scm_tc7_cclo:
  402. #endif
  403. /* It would indeed be a nice thing if we supplied source even for
  404. built in procedures! */
  405. return scm_procedure_property (proc, scm_sym_source);
  406. default:
  407. SCM_WTA(1,proc);
  408. return SCM_BOOL_F;
  409. }
  410. }
  411. #undef FUNC_NAME
  412. SCM_DEFINE (scm_procedure_environment, "procedure-environment", 1, 0, 0,
  413. (SCM proc),
  414. "")
  415. #define FUNC_NAME s_scm_procedure_environment
  416. {
  417. SCM_VALIDATE_NIM (1,proc);
  418. switch (SCM_TYP7 (proc)) {
  419. case scm_tcs_closures:
  420. return SCM_ENV (proc);
  421. case scm_tc7_contin:
  422. case scm_tcs_subrs:
  423. #ifdef CCLO
  424. case scm_tc7_cclo:
  425. #endif
  426. return SCM_EOL;
  427. default:
  428. SCM_WTA(1,proc);
  429. return SCM_BOOL_F;
  430. }
  431. }
  432. #undef FUNC_NAME
  433. /* Eval in a local environment. We would like to have the ability to
  434. * evaluate in a specified local environment, but due to the
  435. * memoization this isn't normally possible. We solve it by copying
  436. * the code before evaluating. One solution would be to have eval.c
  437. * generate yet another evaluator. They are not very big actually.
  438. */
  439. SCM_DEFINE (scm_local_eval, "local-eval", 1, 1, 0,
  440. (SCM exp, SCM env),
  441. "Evaluate @var{exp} in its environment. If @var{env} is supplied,\n"
  442. "it is the environment in which to evaluate @var{exp}. Otherwise,\n"
  443. "@var{exp} must be a memoized code object (in which case, its environment\n"
  444. "is implicit).")
  445. #define FUNC_NAME s_scm_local_eval
  446. {
  447. if (SCM_UNBNDP (env))
  448. {
  449. SCM_VALIDATE_MEMOIZED (1,exp);
  450. return scm_eval_3 (SCM_MEMOIZED_EXP (exp), 0, SCM_MEMOIZED_ENV (exp));
  451. }
  452. return scm_eval_3 (exp, 1, env);
  453. }
  454. #undef FUNC_NAME
  455. #if 0
  456. SCM_REGISTER_PROC (s_reverse_lookup, "reverse-lookup", 2, 0, 0, scm_reverse_lookup);
  457. #endif
  458. SCM
  459. scm_reverse_lookup (SCM env, SCM data)
  460. {
  461. SCM names, values;
  462. while (SCM_NIMP (env) && SCM_SLOPPY_CONSP (SCM_CAR (env)))
  463. {
  464. names = SCM_CAAR (env);
  465. values = SCM_CDAR (env);
  466. while (SCM_CONSP (names))
  467. {
  468. if (SCM_EQ_P (SCM_CAR (values), data))
  469. return SCM_CAR (names);
  470. names = SCM_CDR (names);
  471. values = SCM_CDR (values);
  472. }
  473. if (! SCM_NULLP (names) && SCM_EQ_P (values, data))
  474. return names;
  475. env = SCM_CDR (env);
  476. }
  477. return SCM_BOOL_F;
  478. }
  479. SCM
  480. scm_start_stack (SCM id, SCM exp, SCM env)
  481. {
  482. SCM answer;
  483. scm_debug_frame vframe;
  484. scm_debug_info vframe_vect_body;
  485. vframe.prev = scm_last_debug_frame;
  486. vframe.status = SCM_VOIDFRAME;
  487. vframe.vect = &vframe_vect_body;
  488. vframe.vect[0].id = id;
  489. scm_last_debug_frame = &vframe;
  490. answer = scm_eval_3 (exp, 1, env);
  491. scm_last_debug_frame = vframe.prev;
  492. return answer;
  493. }
  494. SCM_SYNTAX(s_start_stack, "start-stack", scm_makacro, scm_m_start_stack);
  495. static SCM
  496. scm_m_start_stack (SCM exp, SCM env)
  497. {
  498. exp = SCM_CDR (exp);
  499. SCM_ASSERT (SCM_ECONSP (exp)
  500. && SCM_ECONSP (SCM_CDR (exp))
  501. && SCM_NULLP (SCM_CDDR (exp)),
  502. exp,
  503. SCM_WNA,
  504. s_start_stack);
  505. return scm_start_stack (scm_eval_car (exp, env), SCM_CADR (exp), env);
  506. }
  507. /* {Debug Objects}
  508. *
  509. * The debugging evaluator throws these on frame traps.
  510. */
  511. long scm_tc16_debugobj;
  512. static int
  513. prindebugobj (SCM obj,SCM port,scm_print_state *pstate)
  514. {
  515. scm_puts ("#<debug-object ", port);
  516. scm_intprint ((int) SCM_DEBUGOBJ_FRAME (obj), 16, port);
  517. scm_putc ('>', port);
  518. return 1;
  519. }
  520. SCM_DEFINE (scm_debug_object_p, "debug-object?", 1, 0, 0,
  521. (SCM obj),
  522. "")
  523. #define FUNC_NAME s_scm_debug_object_p
  524. {
  525. return SCM_BOOL(SCM_DEBUGOBJP (obj));
  526. }
  527. #undef FUNC_NAME
  528. SCM
  529. scm_make_debugobj (scm_debug_frame *frame)
  530. {
  531. register SCM z;
  532. SCM_NEWCELL (z);
  533. SCM_ENTER_A_SECTION;
  534. SCM_SET_DEBUGOBJ_FRAME (z, frame);
  535. SCM_SET_CELL_TYPE (z, scm_tc16_debugobj);
  536. SCM_EXIT_A_SECTION;
  537. return z;
  538. }
  539. /* Undocumented debugging procedure */
  540. #ifdef GUILE_DEBUG
  541. SCM_DEFINE (scm_debug_hang, "debug-hang", 0, 1, 0,
  542. (SCM obj),
  543. "")
  544. #define FUNC_NAME s_scm_debug_hang
  545. {
  546. int go = 0;
  547. while (!go) ;
  548. return SCM_UNSPECIFIED;
  549. }
  550. #undef FUNC_NAME
  551. #endif
  552. void
  553. scm_init_debug ()
  554. {
  555. scm_init_opts (scm_debug_options, scm_debug_opts, SCM_N_DEBUG_OPTIONS);
  556. scm_tc16_memoized = scm_make_smob_type_mfpe ("memoized", 0,
  557. scm_markcdr, NULL, prinmemoized, NULL);
  558. scm_tc16_debugobj = scm_make_smob_type_mfpe ("debug-object", 0,
  559. NULL, NULL, prindebugobj, NULL);
  560. scm_sym_procname = SCM_CAR (scm_sysintern ("procname", SCM_UNDEFINED));
  561. scm_sym_dots = SCM_CAR (scm_sysintern ("...", SCM_UNDEFINED));
  562. scm_sym_source = SCM_CAR (scm_sysintern ("source", SCM_UNDEFINED));
  563. #ifdef GUILE_DEBUG
  564. scm_sysintern ("SCM_IM_AND", SCM_IM_AND);
  565. scm_sysintern ("SCM_IM_BEGIN", SCM_IM_BEGIN);
  566. scm_sysintern ("SCM_IM_CASE", SCM_IM_CASE);
  567. scm_sysintern ("SCM_IM_COND", SCM_IM_COND);
  568. scm_sysintern ("SCM_IM_DO", SCM_IM_DO);
  569. scm_sysintern ("SCM_IM_IF", SCM_IM_IF);
  570. scm_sysintern ("SCM_IM_LAMBDA", SCM_IM_LAMBDA);
  571. scm_sysintern ("SCM_IM_LET", SCM_IM_LET);
  572. scm_sysintern ("SCM_IM_LETSTAR", SCM_IM_LETSTAR);
  573. scm_sysintern ("SCM_IM_LETREC", SCM_IM_LETREC);
  574. scm_sysintern ("SCM_IM_OR", SCM_IM_OR);
  575. scm_sysintern ("SCM_IM_QUOTE", SCM_IM_QUOTE);
  576. scm_sysintern ("SCM_IM_SET_X", SCM_IM_SET_X);
  577. scm_sysintern ("SCM_IM_DEFINE", SCM_IM_DEFINE);
  578. scm_sysintern ("SCM_IM_APPLY", SCM_IM_APPLY);
  579. scm_sysintern ("SCM_IM_CONT", SCM_IM_CONT);
  580. scm_sysintern ("SCM_IM_DISPATCH", SCM_IM_DISPATCH);
  581. #endif
  582. scm_add_feature ("debug-extensions");
  583. #include "libguile/debug.x"
  584. }
  585. /*
  586. Local Variables:
  587. c-file-style: "gnu"
  588. End:
  589. */