Uploaded image for project: 'Erlang/OTP'
  1. Erlang/OTP
  2. ERL-359

Enable debugging for Elixir sources with loader hack

    XMLWordPrintable

    Details

    • Type: New Feature
    • Status: Help Wanted
    • Priority: Trivial
    • Resolution: Unresolved
    • Affects Version/s: 20.0
    • Fix Version/s: None
    • Component/s: debugger
    • Labels:
      None

      Description

      If a user tries to load debug Elixir source code via Module -> Interpret -> Interpret Modules

      The following error is generated:

      "Error when interpreting: EchoProtocol.ex: No Beam file"

      On the console the following is output:

      "Invalid beam file or no abstract code: "/common/elixir_ranch/lib/EchoProtocol.ex"

      The work around to get this working is:

      {{iex(15)> {:ok,beam_bin} = File.read("_build/dev/lib/elixir_ranch/ebin/Elixir.ElixirRanch.beam")
      
      {:ok,
       <<70, 79, 82, 49, 0, 0, 7, 68, 66, 69, 65, 77, 69, 120, 68, 99, 0, 0, 0, 226,
         131, 104, 2, 100, 0, 14, 101, 108, 105, 120, 105, 114, 95, 100, 111, 99, 115,
         95, 118, 49, 108, 0, 0, 0, 4, 104, 2, 100, 0, ...>>}
      
      iex(16)> :int.i({ElixirRanch, 'lib/elixir_ranch.ex', '_build/dev/lib/elixir_ranch/ebin/Elixir.ElixirRanch.beam', beam_bin})
      {:module, ElixirRanch}}}

      This workaround has been known for a long time (since 2014) and is described in depth by Josh Burroughs (qhool) here: http://qhool.github.io/elixir/2014/02/06/elixir-debug.html

      I have also attached a PDF of that page in case the site vanishes some day.

      It would be nice if this worked a little better, the obviously comparison will be with Java tooling which can handle any source files it pleases, provided line number info has been generated.

        Attachments

          Activity

            People

            Assignee:
            otp_team_vm Team VM
            Reporter:
            bryanhunt bryan hunt
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Dates

              Created:
              Updated: