caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* [Caml-list] DWARF output for native-code
@ 2012-11-19 15:37 Pierre-Marie de Rodat
  2012-11-19 16:05 ` Mark Shinwell
  0 siblings, 1 reply; 2+ messages in thread
From: Pierre-Marie de Rodat @ 2012-11-19 15:37 UTC (permalink / raw)
  To: caml-list

Greetings programs,

For fun, I’ve started to write some gdb scripts to inspect the memory
of an OCaml program. Without type information, I can only print
immediates and blocks hierarchy, and of course with type information I
can display values as they appear in the source code.

The way to pass type information (and other things) to the debugger
would be to make the compiler output DWARF data. OCaml just started to
output debug information with CFI (Calling Frame Information, since
OCaml 4.0.0), but debugging OCaml native programs with gdb could
become awesome with information like a precise source code →
executable code mapping, values location, type information, etc.

I’ve read some docs about the DWARF format, and I’ve looked at the
OCaml compiler : a lot of code is to be (re)written in order to pass
debug information from source code AST to backends, but I would like
to try anyway. I’ve discovered that a « dwarf » branch already exist
on the repository: it is actively developped by « shinwell » since
september. Even if it looks far from completion, it seems to have the
same goal.

I could not find any reference to this branch on the Web nor on this
list, so before I contact directly this developper, I prefer to ask
here: are there any information about this on the Internet? (goal,
roadmap, …) I would be very interested in contributing to this.

Regards,

-- 
Pierre-Marie de Rodat <pmderodat@kawie.fr>
http://canartichaut.kawie.fr/

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

* Re: [Caml-list] DWARF output for native-code
  2012-11-19 15:37 [Caml-list] DWARF output for native-code Pierre-Marie de Rodat
@ 2012-11-19 16:05 ` Mark Shinwell
  0 siblings, 0 replies; 2+ messages in thread
From: Mark Shinwell @ 2012-11-19 16:05 UTC (permalink / raw)
  To: Pierre-Marie de Rodat; +Cc: caml-list

On 19 November 2012 15:37, Pierre-Marie de Rodat <pmderodat@kawie.fr> wrote:
> I’ve discovered that a « dwarf » branch already exist
> on the repository: it is actively developped by « shinwell » since
> september. Even if it looks far from completion, it seems to have the
> same goal.

Yeah, I'm working on full DWARF output for ocamlopt, including the
appropriate gdb support.  This is a fairly complicated undertaking,
shall we say, and it will be a while until it's ready for a first
release.

This work should also permit reverse debugging of OCaml programs
using gdb.

A very small snippet of the work in progress is below.

Mark

--

(gdb) b Foo.blah2
Breakpoint 1 at 0x408d00: file foo.ml, line 9.
(gdb) r
Starting program: foo

Breakpoint 1, Foo.blah2 (arg1="foo", arg2=64, arg3=<foo.ml:19>,
arg4="some string") at foo.ml:9
9	let blah2 arg1 arg2 arg3 arg4 =
(gdb) show lang
The current source language is "auto; currently ocaml".
(gdb) step
10	  let x = Printf.sprintf "42%d%s" 64 arg1 in
(gdb) step
Printf.sprintf (fmt="42%d%s") at printf.ml:679
679	let sprintf fmt = ksprintf (fun s -> s) fmt;;
(gdb) step
Printf.ksprintf (k=<printf.ml:679>) at printf.ml:675
675	let ksprintf k =

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

end of thread, other threads:[~2012-11-19 16:05 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-11-19 15:37 [Caml-list] DWARF output for native-code Pierre-Marie de Rodat
2012-11-19 16:05 ` Mark Shinwell

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