[PATCH] Allow printing of Guile values

Ludovic Courtès ludo@gnu.org
Fri Jul 20 15:19:00 GMT 2007


Hi,

The attached patch fixes printing of Guile objects.  It does so by
querying the inferior Guile process for a textual representation of the
values.

Actually, support routines (namely `gdb_print ()') have been in Guile
for a long time, but have never been used by GDB.  I tested it with
Guile 1.8, but it should also work with 1.6, and perhaps even with older
versions.

Example:

  Breakpoint 4, scm_sum (x=0xf2, y=0x6) at numbers.c:3953
  3953      if (SCM_UNBNDP (y))
  (gdb) set language scheme
  Warning: the current language does not match this frame.
  (gdb) frame
  #0  scm_sum (x=60, y=1) at numbers.c:3953
  3953      if (SCM_UNBNDP (y))

Same with non-immediate values:

  Breakpoint 3, deval (x=0xb7c38978, env=0xb7bc7370) at eval.i.c:215
  215   debug.prev = scm_i_last_debug_frame ();
  (gdb) set language scheme
  (gdb) frame
  #0  deval (
      x=(#<variable b7c3dbc0 value: #<primitive-procedure copy-tree>> (#<variable b7c3e5b0 value: #<procedure apply (fun . args)>> #@1+0 (#<variable b7c094c0 value: #<primitive-procedure cdr>> #@0+0))), env=(((exp env) (false-if-exception (stat str)) (((str) "/home/ludo/.guile"))) ((f) #<procedure #f (expr)>))) at eval.i.c:215
  215   debug.prev = scm_i_last_debug_frame ();


It's my first time hacking GDB, so please don't hesitate to correct me
if the patch looks bad.

I have not yet signed copyright assignment papers for GDB.  I will do it
if deemed necessary.

Thanks,
Ludovic.


gdb/ChangeLog

2007-07-20  Ludovic Courtès  <ludo@gnu.org>

	* scm-lang.c (is_scmvalue_type): Don't check for `TYPE_CODE' of
	TYPE since it may lead to wrong results.
	* scm-valprint.c (scm_inferior_print): Use facilities provided
	by the inferior Guile process, namely `gdb_print ()'.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: ,,guile-1.diff
Type: text/x-patch
Size: 3051 bytes
Desc: The patch
URL: <http://sourceware.org/pipermail/gdb-patches/attachments/20070720/21a01a8e/attachment.bin>


More information about the Gdb-patches mailing list