diff options
author | Fred Hebert <mononcqc@ferd.ca> | 2017-08-05 17:35:15 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-08-05 17:35:15 -0400 |
commit | b956c145938cab288d683b0977a2314e280ca02d (patch) | |
tree | 80d0a31a12b3357cf3244980ebd41d1e5ea97882 | |
parent | 330baef58fa02c8cddc31c5c373fc5bda30f11dd (diff) | |
parent | e8e20e32a8683daa6848c0bb0b715eae842bc4a9 (diff) |
Merge pull request #1597 from g-andrade/fix/avoid_crashing_xref_upon_stripped_modules
Avoid xref crash upon undefined functions in modules without debug_info
-rw-r--r-- | src/rebar_prv_xref.erl | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/src/rebar_prv_xref.erl b/src/rebar_prv_xref.erl index db0f4e4..f358787 100644 --- a/src/rebar_prv_xref.erl +++ b/src/rebar_prv_xref.erl @@ -281,12 +281,21 @@ find_mfa_source({M, F, A}) -> end. find_function_source(M, F, A, Bin) -> - AbstractCode = beam_lib:chunks(Bin, [abstract_code]), - {ok, {M, [{abstract_code, {raw_abstract_v1, Code}}]}} = AbstractCode, + ChunksLookup = beam_lib:chunks(Bin, [abstract_code]), + {ok, {M, [{abstract_code, AbstractCodeLookup}]}} = ChunksLookup, + case AbstractCodeLookup of + no_abstract_code -> + % There isn't much else we can do at this point + {module_not_found, function_not_found}; + {raw_abstract_v1, AbstractCode} -> + find_function_source_in_abstract_code(F, A, AbstractCode) + end. + +find_function_source_in_abstract_code(F, A, AbstractCode) -> %% Extract the original source filename from the abstract code - [{attribute, _, file, {Source, _}} | _] = Code, + [{attribute, _, file, {Source, _}} | _] = AbstractCode, %% Extract the line number for a given function def - Fn = [E || E <- Code, + Fn = [E || E <- AbstractCode, safe_element(1, E) == function, safe_element(3, E) == F, safe_element(4, E) == A], |