From 959a660d8867aa1690d70f656316db98ed8a504f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Gustavsson?= Date: Thu, 24 Mar 2011 11:29:05 +0100 Subject: debugger: Include line numbers in exceptions --- lib/debugger/src/dbg_istk.erl | 32 +++++++++++++++++++++----------- 1 file changed, 21 insertions(+), 11 deletions(-) (limited to 'lib/debugger/src/dbg_istk.erl') diff --git a/lib/debugger/src/dbg_istk.erl b/lib/debugger/src/dbg_istk.erl index e0c4c61333..c6922a80e4 100644 --- a/lib/debugger/src/dbg_istk.erl +++ b/lib/debugger/src/dbg_istk.erl @@ -120,26 +120,27 @@ delayed_stacktrace() -> Stack0 = get(?STACK), fun(NumEntries) -> Stack = stacktrace(NumEntries, Stack0, []), - [ArityOnly || {ArityOnly,_} <- Stack] + [finalize(ArityOnly) || {ArityOnly,_} <- Stack] end. delayed_stacktrace(include_args, Ieval) -> - #ieval{module=Mod,function=Name,arguments=As} = Ieval, - Stack0 = [#e{mfa={Mod,Name,As}}|get(?STACK)], + #ieval{module=Mod,function=Name,arguments=As,line=Li} = Ieval, + Stack0 = [#e{mfa={Mod,Name,As},line=Li}|get(?STACK)], fun(NumEntries) -> case stacktrace(NumEntries, Stack0, []) of [] -> []; [{_,WithArgs}|Stack] -> - [WithArgs | [ArityOnly || {ArityOnly,_} <- Stack]] + [finalize(WithArgs) | + [finalize(ArityOnly) || {ArityOnly,_} <- Stack]] end end; delayed_stacktrace(no_args, Ieval) -> - #ieval{module=Mod,function=Name,arguments=As} = Ieval, - Stack0 = [#e{mfa={Mod,Name,As}}|get(?STACK)], + #ieval{module=Mod,function=Name,arguments=As,line=Li} = Ieval, + Stack0 = [#e{mfa={Mod,Name,As},line=Li}|get(?STACK)], fun(NumEntries) -> Stack = stacktrace(NumEntries, Stack0, []), - [ArityOnly || {ArityOnly,_} <- Stack] + [finalize(ArityOnly) || {ArityOnly,_} <- Stack] end. stacktrace(N, [#e{lc=true}|T], Acc) -> @@ -156,10 +157,19 @@ stacktrace(N, [E|T], [{P,_}|_]=Acc) when N > 0 -> stacktrace(_, _, Acc) -> lists:reverse(Acc). -normalize(#e{mfa={_,Fun,As}}) when is_function(Fun) -> - {{Fun,length(As),[]},{Fun,As,[]}}; -normalize(#e{mfa={M,F,As}}) -> - {{M,F,length(As),[]},{M,F,As,[]}}. +normalize(#e{mfa={M,Fun,As},line=Li}) when is_function(Fun) -> + Loc = {M,Li}, + {{Fun,length(As),Loc},{Fun,As,Loc}}; +normalize(#e{mfa={M,F,As},line=Li}) -> + Loc = {M,Li}, + {{M,F,length(As),Loc},{M,F,As,Loc}}. + +finalize({M,F,A,Loc}) -> {M,F,A,line(Loc)}; +finalize({Fun,A,Loc}) -> {Fun,A,line(Loc)}. + +line({Mod,Line}) when Line > 0 -> + [{file,atom_to_list(Mod)++".erl"},{line,Line}]; +line(_) -> []. %% bindings(SP) -> Bs %% SP = Le % stack pointer -- cgit v1.2.3