caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* [Caml-list] Debugging mixed ocaml/C code
@ 2002-09-12  2:15 Yaron M. Minsky
  2002-09-12 10:09 ` Olivier Andrieu
       [not found] ` <15744.40944.948274.528474@monkey.x.aarg.net>
  0 siblings, 2 replies; 4+ messages in thread
From: Yaron M. Minsky @ 2002-09-12  2:15 UTC (permalink / raw)
  To: caml-list

Does anyone have any suggestions for debugging mixed ocaml/C code?  I 
have some code that uses a wrapper for the Berkeley DB.  When using some 
features of that wrapper (namely transaction support), I find that my 
app segfaults.  Unfortunately, it doesn't do the nice thing and segfault 
inside of the wrapper in a way that makes the bug findable with printfs. 
  Instead, it segfaults in a predictable place in the ocaml code 
instead.  (Surprisingly, it segfaults in the same place if I compile to 
native code or bytecode.)

My question is, does anyone have any suggestions as to how one might go 
about tracking down such a bug?  Are any of the standard debuggers (gdb, 
ocamldebug) useful for mixed ocaml/C code?

Thanks,
Yaron

-------------------
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] Debugging mixed ocaml/C code
  2002-09-12  2:15 [Caml-list] Debugging mixed ocaml/C code Yaron M. Minsky
@ 2002-09-12 10:09 ` Olivier Andrieu
       [not found] ` <15744.40944.948274.528474@monkey.x.aarg.net>
  1 sibling, 0 replies; 4+ messages in thread
From: Olivier Andrieu @ 2002-09-12 10:09 UTC (permalink / raw)
  To: Yaron M. Minsky; +Cc: caml-list

 Yaron M. Minsky [Wednesday 11 September 2002] :
 >   Instead, it segfaults in a predictable place in the ocaml code 
 > instead.  (Surprisingly, it segfaults in the same place if I compile to 
 > native code or bytecode.)

Why is it surprising ? It probably means your C stub returns a
non-block value and caml thinks it's a block value (and when it tries
to access the block, it gets a segfault). Or it could be a block that
was allocated with a wrong size, etc.

You could use a generic function (using Obj) to print the actual
structure of the returned value (block/long, nb of fields, tag, etc).

-- 
   Olivier
-------------------
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] Debugging mixed ocaml/C code
       [not found] ` <15744.40944.948274.528474@monkey.x.aarg.net>
@ 2002-09-12 17:31   ` Yaron M. Minsky
  2002-09-18 19:45   ` Yaron M. Minsky
  1 sibling, 0 replies; 4+ messages in thread
From: Yaron M. Minsky @ 2002-09-12 17:31 UTC (permalink / raw)
  To: erik; +Cc: Caml List 

The wrappers are part of a larger project which will itself be released
publicly in the next few days.  In any case, I'll post a link to a copy of
just the Berkeley DB wrapper if I remember this evening.  I actually fixed
the bug in question, and the wrapper has decent support for the DB
environments, databases, cursors and transactions.  It's currently
compatible with Berkeley DB 3.3.11 and 3.2.9, but it could be updated for
the 4.x versions without too much work.
I'd be happy to have another pair of eyes on the code.  I find tracking
down bugs in C wrapper code much harder per loen of code than finding bugs
in Caml code proper.
y

> On 11 Sep 02, Yaron M. Minsky <yminsky@CS.Cornell.EDU> wrote:
>> Does anyone have any suggestions for debugging mixed ocaml/C code?  I
>> have some code that uses a wrapper for the Berkeley DB.
>
> Yaron,
>
> I unfortunately don't have any debugging hints for you, but I'm
> interested in hearing more about your BerkeleyDB module.  Do you need
> any help with it?  Will it be available to the public when you're
> done?  I have some projects coming up that will need BerkeleyDB
> access, and I've been putting them off because I didn't feel like
> writing an OCaml interface, but I would be more than happy to help you
> out!
>
> --
> ;; Erik Arneson <erik@aarg.net>      JD, Ashland Lodge No. 23 ;;
> ;; GPG Key ID: 2048R/8B4CBC9C    RAM, Siskiyou Chapter No. 21 ;;
> ;; <http://erik.arneson.org/>     <http://www.aarg.net/mason> ;;


-- 
|--------/            Yaron M. Minsky              \--------|
|--------\ http://www.cs.cornell.edu/home/yminsky/ /--------|

Open PGP --- KeyID B1FFD916 (new key as of Dec 4th)
Fingerprint: 5BF6 83E1 0CE3 1043 95D8 F8D5 9F12 B3A9 B1FF D916



-------------------
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] Debugging mixed ocaml/C code
       [not found] ` <15744.40944.948274.528474@monkey.x.aarg.net>
  2002-09-12 17:31   ` Yaron M. Minsky
@ 2002-09-18 19:45   ` Yaron M. Minsky
  1 sibling, 0 replies; 4+ messages in thread
From: Yaron M. Minsky @ 2002-09-18 19:45 UTC (permalink / raw)
  To: Erik Arneson, caml-list

It took me a while, but I just posted a version of my Berkeley DB 
wrapper.  Here's the URL:

   http://minsky-primus.homeip.net/ocaml/bdb.tar.gz

There are currently problems with the transactional support (it 
segfaults and I don't know why), but other than that seems to work 
pretty well.  There is currently good-but-not-complete support for 
dbenvs, dbs, cursors and transactions.

y

Erik Arneson wrote:
> On 11 Sep 02, Yaron M. Minsky <yminsky@CS.Cornell.EDU> wrote:
> 
>>Does anyone have any suggestions for debugging mixed ocaml/C code?  I 
>>have some code that uses a wrapper for the Berkeley DB.
> 
> 
> Yaron,
> 
> I unfortunately don't have any debugging hints for you, but I'm
> interested in hearing more about your BerkeleyDB module.  Do you need
> any help with it?  Will it be available to the public when you're
> done?  I have some projects coming up that will need BerkeleyDB
> access, and I've been putting them off because I didn't feel like
> writing an OCaml interface, but I would be more than happy to help you
> out!
> 

-------------------
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-09-18 19:45 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-09-12  2:15 [Caml-list] Debugging mixed ocaml/C code Yaron M. Minsky
2002-09-12 10:09 ` Olivier Andrieu
     [not found] ` <15744.40944.948274.528474@monkey.x.aarg.net>
2002-09-12 17:31   ` Yaron M. Minsky
2002-09-18 19:45   ` Yaron M. Minsky

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