Version française
Home     About     Download     Resources     Contact us    
Browse thread
OCamldebug breakpoint issues (fwd)
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Nathaniel J. Gaylinn <ngaylinn@c...>
Subject: OCamldebug breakpoint issues (fwd)


I'm having trouble dealing with breakpoints in OCamldebug. The documentation 
seems to make it clear that you can set a breakpoint at any event in your 
program, but ONLY at an event. This makes sense to me.

The problem is, in practice, I can't seem to set a breakpoint at an arbitrary 
event.

For starters, I used "info events Bignum" to get a list of events for my module 
(its name is Bignum). Fine. I get a long list of event points.

Then I started trying to set breakpoints at each event one after the other. 
That's when I began to see odd behavior.

I can set breakpoints at some events with no difficulty. For instance, "break @ 
Bignum #31" sets a breakpoint at offset 31 just as it should. With other 
events, instead of setting a breakpoint where I requested, the breakpoint is 
put at some earlier event. For instance, "break @ Bignum #50" sets a breakpoint 
at offset 31. This is odd, since as far as I know I should be able to set a 
breakpoint at any event. Usually this earlier event is the one right before the 
event I requested, but sometimes its as many as three events back.

What's truly baffling to me, though, is this: if I try to set an event at 
offset 185 (break @ Bignum #185) a breakpoint is created at offset 168, the 
event before the one I requested. However, when I try to set a breakpoint at 
offset 208, I get a breakpoint set at offset 185!!!

Either something's very wrong here, or I have a fundamental misunderstanding 
about how the debugger works with breakpoints. Any tips or suggestions would be 
greatly appreciated. For reference, the file I refer to in this email is 
attached for reference.

Thank you,

   -- Nate




bignum.ml:

let rec longAddWithoutCarry =
  function
  [], x -> x
  | x, [] -> x
  | hd1 :: tl1, hd2 :: tl2 -> hd1 + hd2 :: longAddWithoutCarry (tl1, tl2)

let longAdd (lst1, lst2) =
  let rec helper = function
  [], [], 0 -> []
  | [], [], carry -> [carry]
  | [], hd :: tl, carry -> (hd + carry) mod 10 :: helper ([], tl, (hd + 
carry) / 10)
  | hd :: tl, [], carry -> (hd + carry) mod 10 :: helper (tl, [], (hd + 
carry) / 10)
  | hd1 :: tl1, hd2 :: tl2, carry -> (hd1 + hd2 + carry) mod 10 :: helper 
(tl1, tl2, (hd1 + hd2 + carry) / 10)
  in
  helper (lst1, lst2, 0)

let multAll prod lst = List.map (fun x -> x * prod) lst
let timesTen lst = 0 :: lst

let rec longMult = function
  [], num2 -> []
  | hd :: tl, num2 -> longAdd (multAll hd num2, timesTen (longMult (tl, 
num2)));;


longMult ([3; 2; 1], [2; 1]);;
longMult ([2; 1], [3; 2; 1]);;
longMult ([9; 7; 6; 5; 4; 3; 2; 1], [8; 1]);;
longMult ([], [9; 9; 9; 9; 9; 9]);;
longMult ([1], [9; 9; 9; 9; 9; 9]);;
longMult ([1; 1; 1; 1; 1; 1; 1; 1; 1], [1; 1; 1; 1; 1; 1; 1; 1; 1]);;

let rec forever a = forever a;;