caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* Debugging problem
@ 2006-01-25 21:29 vinh le sy
  2006-01-26  0:54 ` [Caml-list] " Jacques Garrigue
  0 siblings, 1 reply; 2+ messages in thread
From: vinh le sy @ 2006-01-25 21:29 UTC (permalink / raw)
  To: caml-list

Hi all,
I am debugging using camldebugger. I got the same
problem as Robin posted few years ago. 
Here comes the problem:


Let's take a simple example (took from the manual):

(***** File essai.ml *******)

class point =
    object
      val mutable x = 0
      method get_x = x
      method move d = x <- x + d
    end;;

let my_p = new point;;

(****************************)

In order to print the value x of my_p, I separately
defined a printer
function as

(***** File essai_printer.ml *******)

open Format

let my_print_point s =
   open_box 0;
   print_string ("The point is situated at" ^
string_of_int (s#get_x));
   print_space ();
   close_box ();
   print_newline ()
 ;;

Here are the steps I followed:

1. Compile essai.ml and essai_printer.ml
         ocamlc -c -g essai.ml
         ocamlc -c -g essai_printer.ml

2. Create the executable file "essai"
         ocamlc -custom -g -o essai essai.cmo

3. Launch the debugger on the file "essai"

4. load the printer (I show also the answer of the
debugger)
 (ocd) load_printer "essai_printer.cmo"
 File ./essai_printer.cmo loaded
 5. install the printer function my_print_point
 (ocd) install_printer Essai_printer.my_print_point
 6. ....put a breakpoint immediately after the
definition of my_p

7. print my_p
 (ocd) p my_p
 my_p : point = <cannot fetch remote object>


Do anyone know the solution for the problem?


Thank you,
VInh



__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [Caml-list] Debugging problem
  2006-01-25 21:29 Debugging problem vinh le sy
@ 2006-01-26  0:54 ` Jacques Garrigue
  0 siblings, 0 replies; 2+ messages in thread
From: Jacques Garrigue @ 2006-01-26  0:54 UTC (permalink / raw)
  To: vinhioi; +Cc: caml-list

From: vinh le sy <vinhioi@yahoo.com>

> I am debugging using camldebugger. I got the same
> problem as Robin posted few years ago. 
> Here comes the problem:
> 
> 
> Let's take a simple example (took from the manual):
> 
> (***** File essai.ml *******)
> 
> class point =
>     object
>       val mutable x = 0
>       method get_x = x
>       method move d = x <- x + d
>     end;;
> 
> let my_p = new point;;
> 
> (****************************)
> 
> In order to print the value x of my_p, I separately
> defined a printer
> function as
[...]
> 4. load the printer (I show also the answer of the
> debugger)
>  (ocd) load_printer "essai_printer.cmo"
>  File ./essai_printer.cmo loaded
>  5. install the printer function my_print_point
>  (ocd) install_printer Essai_printer.my_print_point
>  6. ....put a breakpoint immediately after the
> definition of my_p
> 
> 7. print my_p
>  (ocd) p my_p
>  my_p : point = <cannot fetch remote object>
> 
> Do anyone know the solution for the problem?

No simple solution: objects include the closures of their methods,
so you cannot marshall them (or only between identical programs, which
is not the case of the debugger). As printers run on the debugger
side, there is pretty little one can do. What would be needed is a way
for the debugger to inject code into the running program, which is a
rather extensive change...

What you can do is add a break point inside a method of the object,
and then you (should) be able to inspect its variables. But for it to
work, your program must call this method close enough to the point you
want to inspect.

Jacques


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2006-01-26  0:52 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-01-25 21:29 Debugging problem vinh le sy
2006-01-26  0:54 ` [Caml-list] " Jacques Garrigue

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 NNTP newsgroup(s).