* Debugging embeded scheme
@ 2004-04-03 4:31 Linas Vepstas
2004-04-03 5:08 ` Viktor Pavlenko
` (2 more replies)
0 siblings, 3 replies; 6+ messages in thread
From: Linas Vepstas @ 2004-04-03 4:31 UTC (permalink / raw)
Cc: linas
Hi,
I'm having a miserable time figuring out how to debug embeded
scheme/guile. I just can't figure out how to get meaningful
debugging info. Let me explain what the problem is:
Application is GnoTime (gttr.sourceforge.net)
The pseudocode is roughly:
scm_c_define_gsubr(...) /* 20 or 30 of these */
scm_c_primitive_load ("/wherever/gtt.scm");
while () {
gh_eval_str_with_catch (str, my_catch_handler);
}
where I use the following:
static SCM
my_catch_handler (void *data, SCM tag, SCM throw_args)
{
printf ("Error: GnoTime caught error during scheme parse\n");
if (SCM_SYMBOLP(tag))
{
char * str = SCM_SYMBOL_CHARS (tag);
printf ("\tScheme error was: %s\n", str);
}
scm_backtrace();
return SCM_EOL;
}
As long as things were simple, I could "guess" where the bug was;
but its now gotten out of control. The above setup gives me output
that is unhelpful to the extreme: gtt.scm is several hundred lines
long, and the embeded stuff in gh_eval_str_with_catch() is dozens
of lines longer. And all I get is:
Error: GnoTime caught error during scheme parse
Scheme error was: unbound-variable
No backtrace available.
Error: GnoTime caught error during scheme parse
Scheme error was: misc-error
No backtrace available.
Error: GnoTime caught error during scheme parse
Scheme error was: wrong-type-arg
No backtrace available.
Adding things like
(trace (my-fun)) is what produced the first unbound-variable.
Although clearly my-fun is defined and works fine...
After googling, I tried adding things like
(debug-enable 'debug 'backtrace) and all I got
for my efforts was a flat out crash:
ERROR: In procedure debug-options-interface:
ERROR: Unknown mode flag: debug
Program exited with code 02.
I am trying to decipher the gh_stack_trace type functions right now,
but I thought I'd ask on the mailing list ... It sure would be nice
if the guile documentation actually described how to use this stuff.
I'm also looking at scm_display_backtrace() but I can't figure out
how to use 'ports' (since my app does no i/o; there's no stdin/stdout,
since its a graphical app. ). I'm also staring at
scm_internal_stack_catch() but with a name like that, can't figure out
if its legal for apps to use it or not.
--linas.
--
pub 1024D/01045933 2001-02-01 Linas Vepstas (Labas!) <linas@linas.org>
PGP Key fingerprint = 8305 2521 6000 0B5E 8984 3F54 64A9 9A82 0104 5933
_______________________________________________
Guile-user mailing list
Guile-user@gnu.org
http://mail.gnu.org/mailman/listinfo/guile-user
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Debugging embeded scheme
2004-04-03 4:31 Debugging embeded scheme Linas Vepstas
@ 2004-04-03 5:08 ` Viktor Pavlenko
2004-04-03 16:05 ` Linas Vepstas
2004-04-16 16:43 ` Thien-Thi Nguyen
2004-04-03 23:24 ` Arno Peters
2004-04-05 16:50 ` Mike Gran
2 siblings, 2 replies; 6+ messages in thread
From: Viktor Pavlenko @ 2004-04-03 5:08 UTC (permalink / raw)
Cc: guile-user, linas
>>>>> "LV" == Linas Vepstas <linas@linas.org> writes:
LV> Hi,
LV> I'm having a miserable time figuring out how to debug embeded
LV> scheme/guile. I just can't figure out how to get meaningful
LV> debugging info. Let me explain what the problem is:
LV> [...]
LV> static SCM
LV> my_catch_handler (void *data, SCM tag, SCM throw_args)
LV> {
LV> printf ("Error: GnoTime caught error during scheme parse\n");
LV> if (SCM_SYMBOLP(tag))
LV> {
LV> char * str = SCM_SYMBOL_CHARS (tag);
LV> printf ("\tScheme error was: %s\n", str);
LV> }
LV> scm_backtrace();
LV> return SCM_EOL;
LV> }
I don't know how to get backtrace but printing throw_args may help.
I find using a function similar to this often during debugging:
std::string
obj2str( const SCM& object )
{
SCM fmt = scm_makfrom0str( "~S" );
SCM s_str = scm_simple_format( SCM_BOOL_F, fmt, SCM_LIST1(object) );
return SCM_STRING_CHARS( s_str );
}
--
Viktor
_______________________________________________
Guile-user mailing list
Guile-user@gnu.org
http://mail.gnu.org/mailman/listinfo/guile-user
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Debugging embeded scheme
2004-04-03 5:08 ` Viktor Pavlenko
@ 2004-04-03 16:05 ` Linas Vepstas
2004-04-16 16:43 ` Thien-Thi Nguyen
1 sibling, 0 replies; 6+ messages in thread
From: Linas Vepstas @ 2004-04-03 16:05 UTC (permalink / raw)
Cc: guile-user
Hi,
Thanks,
On Sat, Apr 03, 2004 at 12:08:46AM -0500, Viktor Pavlenko was heard to remark:
> I don't know how to get backtrace but printing throw_args may help.
>
> std::string
> obj2str( const SCM& object )
> {
> SCM fmt = scm_makfrom0str( "~S" );
> SCM s_str = scm_simple_format( SCM_BOOL_F, fmt, SCM_LIST1(object) );
> return SCM_STRING_CHARS( s_str );
> }
That actually helped; although the first thing it printed was
("car" "Wrong type argument in position ~A: ~S" (1 135725616) #f)
Given a clue, I took a step back, and used my handy-dandy list printer,
hoping to find a string where 135725616 was, but, no, it really does
seem to be an int. Actually a pointer, look about right in hex ...
--linas
--
pub 1024D/01045933 2001-02-01 Linas Vepstas (Labas!) <linas@linas.org>
PGP Key fingerprint = 8305 2521 6000 0B5E 8984 3F54 64A9 9A82 0104 5933
_______________________________________________
Guile-user mailing list
Guile-user@gnu.org
http://mail.gnu.org/mailman/listinfo/guile-user
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Debugging embeded scheme
2004-04-03 4:31 Debugging embeded scheme Linas Vepstas
2004-04-03 5:08 ` Viktor Pavlenko
@ 2004-04-03 23:24 ` Arno Peters
2004-04-05 16:50 ` Mike Gran
2 siblings, 0 replies; 6+ messages in thread
From: Arno Peters @ 2004-04-03 23:24 UTC (permalink / raw)
On Fri, Apr 02, 2004 at 10:31:28PM -0600, Linas Vepstas wrote:
> After googling, I tried adding things like
> (debug-enable 'debug 'backtrace) and all I got
> for my efforts was a flat out crash:
That should have read:
(debug-enable 'backtrace)
--
Arno
_______________________________________________
Guile-user mailing list
Guile-user@gnu.org
http://mail.gnu.org/mailman/listinfo/guile-user
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Debugging embeded scheme
2004-04-03 4:31 Debugging embeded scheme Linas Vepstas
2004-04-03 5:08 ` Viktor Pavlenko
2004-04-03 23:24 ` Arno Peters
@ 2004-04-05 16:50 ` Mike Gran
2 siblings, 0 replies; 6+ messages in thread
From: Mike Gran @ 2004-04-05 16:50 UTC (permalink / raw)
Cc: linas
Hi,
I found this bit of magic. Haven't had a chance to try it.
This file
http://www.glug.org/docbits/IncorporatingGuileIntoYourCProgram.txt
suggests adding this to your C code
/* debugging voodoo */
SCM_DEVAL_P = 1;
SCM_BACKTRACE_P = 1;
SCM_RECORD_POSITIONS_P = 1;
SCM_RESET_DEBUG_MODE;
--- Linas Vepstas <linas@linas.org> wrote:
>
> Hi,
>
>
> I'm having a miserable time figuring out how to debug embeded
> scheme/guile. I just can't figure out how to get meaningful
> debugging info. Let me explain what the problem is:
>
__________________________________
Do you Yahoo!?
Yahoo! Small Business $15K Web Design Giveaway
http://promotions.yahoo.com/design_giveaway/
_______________________________________________
Guile-user mailing list
Guile-user@gnu.org
http://mail.gnu.org/mailman/listinfo/guile-user
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Debugging embeded scheme
2004-04-03 5:08 ` Viktor Pavlenko
2004-04-03 16:05 ` Linas Vepstas
@ 2004-04-16 16:43 ` Thien-Thi Nguyen
1 sibling, 0 replies; 6+ messages in thread
From: Thien-Thi Nguyen @ 2004-04-16 16:43 UTC (permalink / raw)
Cc: guile-user, linas
From: Viktor Pavlenko <vvp@rogers.com>
Date: Sat, 3 Apr 2004 00:08:46 -0500
I find using a function similar to this often during debugging:
std::string
obj2str( const SCM& object )
{ [...] }
see also:
http://www.glug.org/snap/workbook/build/dist-files/.gdbinit
thi
_______________________________________________
Guile-user mailing list
Guile-user@gnu.org
http://mail.gnu.org/mailman/listinfo/guile-user
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2004-04-16 16:43 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-04-03 4:31 Debugging embeded scheme Linas Vepstas
2004-04-03 5:08 ` Viktor Pavlenko
2004-04-03 16:05 ` Linas Vepstas
2004-04-16 16:43 ` Thien-Thi Nguyen
2004-04-03 23:24 ` Arno Peters
2004-04-05 16:50 ` Mike Gran
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).