From c67dcea4a123ad7871040ec991674533953f8c48 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Gustavsson?= Date: Tue, 8 Mar 2011 11:12:56 +0100 Subject: Update examples in the documentation to include line numbers --- lib/debugger/doc/src/debugger_chapter.xml | 24 +++++++++++------------- system/doc/getting_started/seq_prog.xml | 22 ++++++++++++---------- 2 files changed, 23 insertions(+), 23 deletions(-) diff --git a/lib/debugger/doc/src/debugger_chapter.xml b/lib/debugger/doc/src/debugger_chapter.xml index 1f5d4dd5ff..67e95cd083 100644 --- a/lib/debugger/doc/src/debugger_chapter.xml +++ b/lib/debugger/doc/src/debugger_chapter.xml @@ -254,19 +254,17 @@ c_break(Bindings) -> used, for example, if an error occurs:

 1> catch a+1.
-{'EXIT',{badarith,[{erlang,'+',[a,1]},
-                   {erl_eval,do_apply,5},
-                   {erl_eval,expr,5},
-                   {shell,exprs,6},
-                   {shell,eval_exprs,6},
-                   {shell,eval_loop,3}]}}
- -

In the case above, the stack trace shows that the function called - last was erl_eval:eval_op/3. See Erlang Reference - Manual, Errors and Error handling, for more information - about stack trace.

- -

Debugger emulates the stack trace by keeping track of recently +{'EXIT',{badarith,[{erlang,'+',[a,1],[]}, + {erl_eval,do_apply,5,[{file,"erl_eval.erl"},{line,562}]}, + {erl_eval,expr,5,[{file,"erl_eval.erl"},{line,359}]}, + {shell,exprs,7,[{file,"shell.erl"},{line,668}]}, + {shell,eval_exprs,7,[{file,"shell.erl"},{line,623}]}, + {shell,eval_loop,3,[{file,"shell.erl"},{line,608}]}]}} + +

See the Erlang Reference Manual, Errors and Error handling, + for more information about the stack trace.

+ +

The Debugger emulates the stack trace by keeping track of recently called interpreted functions. (The real stack trace cannot be used, as it shows which functions of the Debugger have been called, rather than which interpreted functions).

diff --git a/system/doc/getting_started/seq_prog.xml b/system/doc/getting_started/seq_prog.xml index bc1758d855..96876ea513 100644 --- a/system/doc/getting_started/seq_prog.xml +++ b/system/doc/getting_started/seq_prog.xml @@ -4,7 +4,7 @@
- 20032009 + 20032011 Ericsson AB. All Rights Reserved. @@ -41,9 +41,9 @@ erl, you will see something like this.

 % erl
-Erlang (BEAM) emulator version 5.2 [source] [hipe]
+Erlang R15B (erts-5.9.1) [source] [smp:8:8] [rq:8] [async-threads:0] [hipe] [kernel-poll:false]
 
-Eshell V5.2  (abort with ^G)
+Eshell V5.9.1  (abort with ^G)
 1>

Now type in "2 + 5." as shown below.

@@ -245,7 +245,7 @@ convert(N, centimeter) ->
       inch in the convert function:

 12> tut2:convert(3, miles).
-** exception error: no function clause matching tut2:convert(3,miles)
+** exception error: no function clause matching tut2:convert(3,miles) (tut2.erl, line 4)

The two parts of the convert function are called its clauses. Here we see that "miles" is not part of either of the clauses. The Erlang system can't match either of @@ -255,11 +255,13 @@ convert(N, centimeter) -> command v/1:

 13> v(12).
-{'EXIT',{function_clause,[{tut2,convert,[3,miles]},
-                          {erl_eval,do_apply,5},
-                          {shell,exprs,6},
-                          {shell,eval_exprs,6},
-                          {shell,eval_loop,3}]}}
+{'EXIT',{function_clause,[{tut2,convert, + [3,miles], + [{file,"tut2.erl"},{line,4}]}, + {erl_eval,do_apply,5,[{file,"erl_eval.erl"},{line,482}]}, + {shell,exprs,7,[{file,"shell.erl"},{line,666}]}, + {shell,eval_exprs,7,[{file,"shell.erl"},{line,621}]}, + {shell,eval_loop,3,[{file,"shell.erl"},{line,606}]}]}} @@ -943,7 +945,7 @@ A == 1 ; B == 7 a_equals_1_or_b_equals_7 66> tut9:test_if(33, 33). ** exception error: no true branch found when evaluating an if expression - in function tut9:test_if/2 + in function tut9:test_if/2 (tut9.erl, line 5)

Notice that tut9:test_if(33,33) did not cause any condition to succeed so we got the run time error if_clause, here nicely formatted by the shell. See the chapter -- cgit v1.2.3