* <cannot fetch remote object> - WHY ?
@ 2000-01-26 19:38 Sorin Stratulat
2000-02-03 18:28 ` Xavier Leroy
0 siblings, 1 reply; 2+ messages in thread
From: Sorin Stratulat @ 2000-01-26 19:38 UTC (permalink / raw)
To: caml-list
Hello !
I started to debug large OCaml code and apparently the only acceptable
solution to do this is to use the debugger. Unfortunately, I found
difficulties to convince the debugger to print objects.
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 ()
;;
(****************************)
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>
------------------------------------------------------------------
Can somebody tell me the "solution" to print the value "x" of my_p ?
Thank you,
Sorin
French version:
Bonjour !
Je suis en train de deboguer de gros fichiers en OCaml et je suis
contraint d'utiliser le debogueur. Malheureusement, je n'arrive pas a
afficher des objets.
Voici un tres simple exemple (pris du manuel):
(***** 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;;
(****************************)
Pour afficher la valeur x de my_p, j'ai defini separement une fonction
d'impression
(***** 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 ()
;;
(****************************)
Les etapes que j'ai suivi sont les suivantes:
1. Compiler essai.ml et essai_printer.ml
ocamlc -c -g essai.ml
ocamlc -c -g essai_printer.ml
2. Creer le fichier executable "essai":
ocamlc -custom -g -o essai essai.cmo
3. Lancer le debogueur sur le fichier "essai":
4. Charger le "printer"
(ocd) load_printer "essai_printer.cmo"
File ./essai_printer.cmo loaded
5. Installer la fonction d'impression my_print_point
(ocd) install_printer Essai_printer.my_print_point
6. ... fixer un breakpoint juste apres la definition de my_p
7. imprimer my_p
(ocd) p my_p
my_p : point = <cannot fetch remote object>
------------------------------------------------------------------
Et la question:
Quelle est la solution pour imprimer la valeur x de my_p ?
Merci d'avance,
Sorin
--
e-mail : Sorin.Stratulat@loria.fr
www : http://www.loria.fr/~stratula
Project: PROTHEO
Office : A201 | Home:
------ | ------
tel: 03.83.59.30.02 | 1, rue Charles Sadoul
LORIA - BP 239 | 54000 Nancy
F-54506 VANDOEUVRE-les-NANCY Cedex FRANCE | tel. 06.10.46.49.99
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: <cannot fetch remote object> - WHY ?
2000-01-26 19:38 <cannot fetch remote object> - WHY ? Sorin Stratulat
@ 2000-02-03 18:28 ` Xavier Leroy
0 siblings, 0 replies; 2+ messages in thread
From: Xavier Leroy @ 2000-02-03 18:28 UTC (permalink / raw)
To: stratula, caml-list
> Unfortunately, I found
> difficulties to convince the debugger to print objects.
> 5. install the printer function my_print_point
> (ocd) install_printer Essai_printer.my_print_point
> 7. print my_p
> (ocd) p my_p
> my_p : point = <cannot fetch remote object>
User-defined printing functions run in the memory space of the
debugger, which is distinct from that of the debugged program.
Structued I/O (output_value/input_value) is used to communicate the
value being printed between the two. Unfotunately, structured I/O is
currently unable to deal with objects and functions, hence the error
you've observed.
> Can somebody tell me the "solution" to print the value "x" of my_p ?
The only solution I can see right now is put a breakpoint in one of
the methods of my_p's class; then, "x" is in scope and "print x"
should show its value.
- Xavier Leroy
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2000-02-04 7:48 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2000-01-26 19:38 <cannot fetch remote object> - WHY ? Sorin Stratulat
2000-02-03 18:28 ` Xavier Leroy
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox