Loading ...
Sorry, an error occurred while loading the content.

basic use of the debugger

Expand Messages
  • darooha
    Can somebody tell me how to do the following with ocamldebug? (I ve tried and failed to figure how how to do this from the manual. But these are such
    Message 1 of 4 , Oct 23, 2011
    • 0 Attachment
      Can somebody tell me how to do the following with ocamldebug? (I've tried and failed to figure how how to do this from the manual. But these are such absolutely basic things that they have to be possible to do.)

      (1) I want it to tell me the line on which my program did an array index that is out of bounds.

      (2) The program being debugged reads from standard input. I want to supply that standard input from a file. I.e in the shell I compile the program and run it with the command "a.out < blah", where blah is the file containing the input to my program. I want to run it this way inside the debugger.

      Thanks.

      Danny Sleator
    • Gabriel Scherer
      ... The ocamldebug interface is relatively primitive. To get source positions, you must run it with the -emacs option that sends position as number of chars
      Message 2 of 4 , Oct 23, 2011
      • 0 Attachment
        >
        > (1) I want it to tell me the line on which my program did an array index
        > that is out of bounds.
        >

        The ocamldebug interface is relatively primitive. To get source positions,
        you must run it with the "-emacs" option that sends position as number of
        chars since the beginning of the file. The emacs ocaml modes have glue code
        to jump to the right file and so on; if you're using Emacs, running the
        debugger under Emacs is the best choice. This interface has also been
        adapted to Vim ( http://upsilon.cc/~zack/hacking/software/wowcamldebug/ )
        and some other IDEs, but is not optimal for direct consumption.

        (2) The program being debugged reads from standard input. I want to supply
        > that standard input from a file. I.e in the shell I compile the program and
        > run it with the command "a.out < blah", where blah is the file containing
        > the input to my program. I want to run it this way inside the debugger.
        >

        As an ocamldebug command :
        set arguments < blah
        (Found here :
        http://florent.bouchez.free.fr/?download=informatique/ocaml.php )

        Note that if you're familiar with gdb's tooling, you can also probably run
        ocamlopt-compiled programs under gdb directly.

        On Sun, Oct 23, 2011 at 4:41 PM, darooha <sleator@...> wrote:

        > Can somebody tell me how to do the following with ocamldebug? (I've tried
        > and failed to figure how how to do this from the manual. But these are such
        > absolutely basic things that they have to be possible to do.)
        >
        > (1) I want it to tell me the line on which my program did an array index
        > that is out of bounds.
        >
        > (2) The program being debugged reads from standard input. I want to supply
        > that standard input from a file. I.e in the shell I compile the program and
        > run it with the command "a.out < blah", where blah is the file containing
        > the input to my program. I want to run it this way inside the debugger.
        >
        > Thanks.
        >
        > Danny Sleator
        >
        >
        >
        >
        > ------------------------------------
        >
        > Archives up to December 31, 2010 are also downloadable at
        > http://www.connettivo.net/cntprojects/ocaml_beginners
        > The archives of the very official ocaml list (the seniors' one) can be
        > found at http://caml.inria.fr
        > Attachments are banned and you're asked to be polite, avoid flames
        > etc.Yahoo! Groups Links
        >
        >
        >
        >


        [Non-text portions of this message have been removed]
      • darooha
        ... My question is not about line numbers. The question is how do I get it to tell me where the error occurred, in any format at all. All I m able to get out
        Message 3 of 4 , Oct 23, 2011
        • 0 Attachment
          > The ocamldebug interface is relatively primitive. To get source positions,
          > you must run it with the "-emacs" option that sends position as number of
          > chars since the beginning of the file. The emacs ocaml modes have glue code
          > to jump to the right file and so on; if you're using Emacs, running the
          > debugger under Emacs is the best choice. This interface has also been
          > adapted to Vim ( http://upsilon.cc/~zack/hacking/software/wowcamldebug/ )
          > and some other IDEs, but is not optimal for direct consumption.

          My question is not about line numbers. The question is how do I get it to tell me where the error occurred, in any format at all. All I'm able to get out of it is "Uncaught exception: Invalid_argument "index out of bounds"". This is the same with or without running in -emacs mode.

          Thanks for your useful answer to my other question.

          Danny Sleator
        • Gabriel Scherer
          If you re only hunting for where an uncaught exception is raised, you don t need to use the debugger, just run the program with backtraces activated.
          Message 4 of 4 , Oct 23, 2011
          • 0 Attachment
            If you're only hunting for where an uncaught exception is raised, you don't
            need to use the debugger, just run the program with backtraces activated.
            OCAMLRUNPARAM="b" ./foo bar

            On Sun, Oct 23, 2011 at 6:23 PM, darooha <sleator@...> wrote:

            > > The ocamldebug interface is relatively primitive. To get source
            > positions,
            > > you must run it with the "-emacs" option that sends position as number of
            > > chars since the beginning of the file. The emacs ocaml modes have glue
            > code
            > > to jump to the right file and so on; if you're using Emacs, running the
            > > debugger under Emacs is the best choice. This interface has also been
            > > adapted to Vim ( http://upsilon.cc/~zack/hacking/software/wowcamldebug/)
            > > and some other IDEs, but is not optimal for direct consumption.
            >
            > My question is not about line numbers. The question is how do I get it to
            > tell me where the error occurred, in any format at all. All I'm able to get
            > out of it is "Uncaught exception: Invalid_argument "index out of bounds"".
            > This is the same with or without running in -emacs mode.
            >
            > Thanks for your useful answer to my other question.
            >
            > Danny Sleator
            >
            >
            >
            >
            > ------------------------------------
            >
            > Archives up to December 31, 2010 are also downloadable at
            > http://www.connettivo.net/cntprojects/ocaml_beginners
            > The archives of the very official ocaml list (the seniors' one) can be
            > found at http://caml.inria.fr
            > Attachments are banned and you're asked to be polite, avoid flames
            > etc.Yahoo! Groups Links
            >
            >
            >
            >


            [Non-text portions of this message have been removed]
          Your message has been successfully submitted and would be delivered to recipients shortly.