caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* [Caml-list] debugger questions/feature requests
@ 2002-06-29 10:42 Michael Vanier
  2002-06-30 17:41 ` Mattias Waldau
  0 siblings, 1 reply; 4+ messages in thread
From: Michael Vanier @ 2002-06-29 10:42 UTC (permalink / raw)
  To: caml-list


I'm just starting to use the ocaml debugger.  I notice that when doing a
backtrace, the different stack frames are identified as character positions
in the source code file, but no line numbers are given.  This is a pretty
major annoyance.  However, when you go up and down the call stack, you get
the line numbers.  Is there any way to put the line numbers in the
backtrace as well?

I also would like a way to stop execution at the point at which an
exception was raised.  There was a bug in my code that raised an exception,
and the debugger was not helpful in tracking it down.  The last location I
could step through before the exception was raised bore no relation to
where the bug was occurring.  I'm not really sure why this was the case.

Sorry to sound so critical; ocaml is really the best language around.

Mike
-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners


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

* RE: [Caml-list] debugger questions/feature requests
  2002-06-29 10:42 [Caml-list] debugger questions/feature requests Michael Vanier
@ 2002-06-30 17:41 ` Mattias Waldau
  2002-07-01 22:40   ` Michael Vanier
  0 siblings, 1 reply; 4+ messages in thread
From: Mattias Waldau @ 2002-06-30 17:41 UTC (permalink / raw)
  To: 'Michael Vanier', caml-list

> I'm just starting to use the ocaml debugger.  I notice that 
> when doing a backtrace, the different stack frames are 
> identified as character positions in the source code file, 
> but no line numbers are given.  This is a pretty major 
> annoyance.  However, when you go up and down the call stack, 
> you get the line numbers.  Is there any way to put the line 
> numbers in the backtrace as well?

no line numbers, this is a recurrent complaint :-)

> 
> I also would like a way to stop execution at the point at 
> which an exception was raised.  There was a bug in my code 
> that raised an exception, and the debugger was not helpful in 
> tracking it down.  The last location I could step through 
> before the exception was raised bore no relation to where the 
> bug was occurring.  I'm not really sure why this was the case.
> 

it does stop at the point.

I normally do 'b' to backstep one step and then 'u' one or several times
to go up the stack trace.

if you use windows and use the debugger under emacs, there is a problem 
with crlf vs lf. In order to get the cursor at the right position when
using 
camldebug, I have now learned to do

dos2unix *.ml*

> Sorry to sound so critical; ocaml is really the best language around.
> 
> Mike
> -------------------
> To unsubscribe, mail caml-list-request@inria.fr Archives: 
http://caml.inria.fr Bug reports: http://caml.inria.fr/bin/caml-bugs
FAQ: http://caml.inria.fr/FAQ/ Beginner's list:
http://groups.yahoo.com/group/ocaml_beginners

-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners


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

* Re: [Caml-list] debugger questions/feature requests
  2002-06-30 17:41 ` Mattias Waldau
@ 2002-07-01 22:40   ` Michael Vanier
  2002-07-02  9:32     ` Xavier Leroy
  0 siblings, 1 reply; 4+ messages in thread
From: Michael Vanier @ 2002-07-01 22:40 UTC (permalink / raw)
  To: mattias.waldau; +Cc: caml-list

> From: "Mattias Waldau" <mattias.waldau@abc.se>
> Date: Sun, 30 Jun 2002 19:41:24 +0200
> 
> > I'm just starting to use the ocaml debugger.  I notice that 
> > when doing a backtrace, the different stack frames are 
> > identified as character positions in the source code file, 
> > but no line numbers are given.  This is a pretty major 
> > annoyance.  However, when you go up and down the call stack, 
> > you get the line numbers.  Is there any way to put the line 
> > numbers in the backtrace as well?
> 
> no line numbers, this is a recurrent complaint :-)

Actually, it turns out to be trivial to add this feature to the debugger.
In the file debugger/show_information.ml, apply this patch:

25a26
> open Source
72,73c73,78
<   fprintf ppf "#%i  Pc : %i  %s char %i@."
<          framenum event.ev_pos event.ev_module event.ev_char
---
>   let first_char_of_line, line = 
>     line_of_pos (get_buffer event.ev_module) event.ev_char in
>   let char_on_line = event.ev_char - first_char_of_line in
>   fprintf ppf "#%i  Pc : %i  %s line: %i char: %i@."
>     framenum event.ev_pos event.ev_module 
>       line char_on_line

Don't forget the "open Source" line, or you won't be able to access the
"line_of_pos" function.  Nothing like open source software ;-)

> 
> > 
> > I also would like a way to stop execution at the point at 
> > which an exception was raised.  There was a bug in my code 
> > that raised an exception, and the debugger was not helpful in 
> > tracking it down.  The last location I could step through 
> > before the exception was raised bore no relation to where the 
> > bug was occurring.  I'm not really sure why this was the case.
> > 
> 
> it does stop at the point.
> 
> I normally do 'b' to backstep one step and then 'u' one or several times
> to go up the stack trace.
> 

Hmm.  It doesn't work for me.  When I do this the last location I can see
before hitting the exception is about two lines before the location of the
bug.  I'm having a hard time wrapping my mind around the way the debugger
works.  

Mike
-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners


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

* Re: [Caml-list] debugger questions/feature requests
  2002-07-01 22:40   ` Michael Vanier
@ 2002-07-02  9:32     ` Xavier Leroy
  0 siblings, 0 replies; 4+ messages in thread
From: Xavier Leroy @ 2002-07-02  9:32 UTC (permalink / raw)
  To: Michael Vanier; +Cc: mattias.waldau, caml-list

> > I normally do 'b' to backstep one step and then 'u' one or several times
> > to go up the stack trace.
> > 
> 
> Hmm.  It doesn't work for me.  When I do this the last location I can see
> before hitting the exception is about two lines before the location of the
> bug.  I'm having a hard time wrapping my mind around the way the debugger
> works.  

Without seeing your code, I can only provide some general intuitions.
Briefly, the Caml debugger works just like popular debuggers for
conventional imperative language (C, Java, etc), with two exceptions:

- You get reverse execution in addition to forward execution,
e.g. while conventional debuggers offer (forward) single-stepping,
ocamldebug also offers back-stepping.

- Single-stepping in conventional debuggers stops at the beginning of
each statement, and at each function call.  Since Caml is an
expression-based language, statements don't play the central role that
they play in C or Java.  So, for Caml, single-stepping (and
back-stepping, and every other debugger command) stops at so-called
"debugging events", which are "interesting" locations in the program
source such as function entry, function application return, beginning
of loops, etc.  (See section 15.4.1 of the manual for a full listing.)  

So, if you bug occurs "between" two events, backstep takes you to the
immediately preceding event, which may be two lines before.

- Xavier Leroy
-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners


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

end of thread, other threads:[~2002-07-02  9:32 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-06-29 10:42 [Caml-list] debugger questions/feature requests Michael Vanier
2002-06-30 17:41 ` Mattias Waldau
2002-07-01 22:40   ` Michael Vanier
2002-07-02  9:32     ` Xavier Leroy

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).