How to Debug programs in Erlang

Source: Internet
Author: User

Learning a language, when learning those basic grammar, we often ignore its program debugging, when the program is a little more complex, we can not guarantee that the program is completely correct, we will worry about it, then, the program debugging becomes quite important.
Once the Erlang environment is set up, it will default to a debug tool---Erlang debugger (the name is Good (^_^)).
Simple use of Erlang debugger:
Suppose we have a well-written test.erl.
1. Compile the module. When compiling the module, this should be compiled
C (Test,[debug_info]).
2. Open Debugger. In the Erlang shell, enter "Im ()." Can.
3. Set Breakpoints. In the open monitor, select all three options under Auto attach at the bottom left, that is, first call, on break, and on Exit (this detail is important). Then select Module->interpret Modules, in the window that opens, select the Test.erl source file. At this point, in the Monitor window just now, double-click on the left top of the test, in the open "View Module Test" New window, select Break->function break, select a function (of course, in the break, You can choose a different way to set the breakpoint). At this point, the breakpoint is set successfully.
4. Start Debugging. Enter the function to be called in the Erlang shell (as if we were not debugging at the time, just enter the module call.)  Eg:test:reverse ([1, 2, 3, 4]). This is my random loss. Then you can debug your program in the open window.
Summary: This is a very simple use of Erlang debugger, there are many details I do not understand, but I hope this article can play a role for everyone. The use of specific debugging tools, you can refer to:Http://www.erlang.org/doc/apps/debugger/debugger_chapter.html

A reference video address:
http://files.cnblogs.com/goldli/test_tuple.swf

Prerequisite: The Erl file must be compiled with the Debug_info option. Otherwise, Invalid beam file or no abstract code:error is present

Compile by: Make:all ([Debug_info]). | C (test.erl,debug_info).

Basic Debugging Method:<br>
im/0: Open Debugger <br>
I/1: Adding files to the debugger <br>
NI: Usage for multiple node <br>
N/1: Contrary to I/1 <br>
NN/1: Contrary to NI/1 <br>
interrepted/0: List all the module<br> you want to debug
FILE/1: Show Source Files <br>
BREAK/2: Add Breakpoints <br>
DELETE_BREAK/2 Delete Breakpoints <br>
BREAK_IN/3: Adding breakpoints to specific functions <br>
DEL_BREAK_IN/3: Remove breakpoints in a specific function <br>
no_break/0: Delete all breakpoints <br>
NO_BREAK/1: Delete all breakpoints for a module <br>
DISABLE_BREAK/2: Disable breakpoint on a module <br>
ENABLE_BREAK/2: Recovering breakpoints for a module <br>
ACTION_AT_BREAK/1: Set the state of the breakpoint, the experiment found that enable does not work <br>
all_breaks/0: Show all breakpoint states <br>
ALL_BREAKS/1: Displays all breakpoint states specified <br>
snapshot/0: Playback Debugging process Information <br>

How to Debug programs in Erlang

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.