Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

compiler: Provide more information if the v3_life pass crashes

Print the name and arity of the function being compiled
if the v3_life compiler pass crashes to facilitate finding
out which part of the source code that triggered the problem.
  • Loading branch information...
commit 7d2981f0896113d6dce20c777bbadbbb1d641554 1 parent ba24a5d
Björn Gustavsson bjorng authored Erlang/OTP committed

Showing 1 changed file with 26 additions and 20 deletions. Show diff stats Hide diff stats

  1. +26 20 lib/compiler/src/v3_life.erl
46 lib/compiler/src/v3_life.erl
... ... @@ -1,19 +1,19 @@
1 1 %%
2 2 %% %CopyrightBegin%
3   -%%
4   -%% Copyright Ericsson AB 1999-2009. All Rights Reserved.
5   -%%
  3 +%%
  4 +%% Copyright Ericsson AB 1999-2010. All Rights Reserved.
  5 +%%
6 6 %% The contents of this file are subject to the Erlang Public License,
7 7 %% Version 1.1, (the "License"); you may not use this file except in
8 8 %% compliance with the License. You should have received a copy of the
9 9 %% Erlang Public License along with this software. If not, it can be
10 10 %% retrieved online at http://www.erlang.org/.
11   -%%
  11 +%%
12 12 %% Software distributed under the License is distributed on an "AS IS"
13 13 %% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
14 14 %% the License for the specific language governing rights and limitations
15 15 %% under the License.
16   -%%
  16 +%%
17 17 %% %CopyrightEnd%
18 18 %%
19 19 %% Purpose : Convert annotated kernel expressions to annotated beam format.
@@ -66,21 +66,27 @@ functions([], Acc) -> reverse(Acc).
66 66 %% function(Kfunc) -> Func.
67 67
68 68 function(#k_fdef{func=F,arity=Ar,vars=Vs,body=Kb}) ->
69   - %ok = io:fwrite("life ~w: ~p~n~p~n", [?LINE,{F,Ar},Kb]),
70   - As = var_list(Vs),
71   - Vdb0 = foldl(fun ({var,N}, Vdb) -> new_var(N, 0, Vdb) end, [], As),
72   - %% Force a top-level match!
73   - B0 = case Kb of
74   - #k_match{} -> Kb;
75   - _ ->
76   - Ka = get_kanno(Kb),
77   - #k_match{anno=#k{us=Ka#k.us,ns=[],a=Ka#k.a},
78   - vars=Vs,body=Kb,ret=[]}
79   - end,
80   - put(guard_refc, 0),
81   - {B1,_,Vdb1} = body(B0, 1, Vdb0),
82   - erase(guard_refc),
83   - {function,F,Ar,As,B1,Vdb1}.
  69 + try
  70 + As = var_list(Vs),
  71 + Vdb0 = foldl(fun ({var,N}, Vdb) -> new_var(N, 0, Vdb) end, [], As),
  72 + %% Force a top-level match!
  73 + B0 = case Kb of
  74 + #k_match{} -> Kb;
  75 + _ ->
  76 + Ka = get_kanno(Kb),
  77 + #k_match{anno=#k{us=Ka#k.us,ns=[],a=Ka#k.a},
  78 + vars=Vs,body=Kb,ret=[]}
  79 + end,
  80 + put(guard_refc, 0),
  81 + {B1,_,Vdb1} = body(B0, 1, Vdb0),
  82 + erase(guard_refc),
  83 + {function,F,Ar,As,B1,Vdb1}
  84 + catch
  85 + Class:Error ->
  86 + Stack = erlang:get_stacktrace(),
  87 + io:fwrite("Function: ~w/~w\n", [F,Ar]),
  88 + erlang:raise(Class, Error, Stack)
  89 + end.
84 90
85 91 %% body(Kbody, I, Vdb) -> {[Expr],MaxI,Vdb}.
86 92 %% Handle a body, need special cases for transforming match_fails.

0 comments on commit 7d2981f

Please sign in to comment.
Something went wrong with that request. Please try again.