diff options
author | Dan Gudmundsson <[email protected]> | 2017-06-07 12:39:46 +0200 |
---|---|---|
committer | Dan Gudmundsson <[email protected]> | 2017-06-07 16:13:08 +0200 |
commit | 5167b60cfe076cf27368ad4a250e55e4507d42fa (patch) | |
tree | 4744c1566bdf1b8c1eaa9bb1fc6d893e8ef8bbc4 /lib/stdlib/src/shell.erl | |
parent | 106c7b1bd5d845b982796e4ab5d537b2e68c3f1d (diff) | |
download | otp-5167b60cfe076cf27368ad4a250e55e4507d42fa.tar.gz otp-5167b60cfe076cf27368ad4a250e55e4507d42fa.tar.bz2 otp-5167b60cfe076cf27368ad4a250e55e4507d42fa.zip |
stdlib: Lookup src path in beam
find and use source directive when searching for source file
Diffstat (limited to 'lib/stdlib/src/shell.erl')
-rw-r--r-- | lib/stdlib/src/shell.erl | 30 |
1 files changed, 15 insertions, 15 deletions
diff --git a/lib/stdlib/src/shell.erl b/lib/stdlib/src/shell.erl index 76a2789406..6eafc7b209 100644 --- a/lib/stdlib/src/shell.erl +++ b/lib/stdlib/src/shell.erl @@ -1238,22 +1238,22 @@ read_file_records(File, Opts) -> end. %% This is how the debugger searches for source files. See int.erl. -try_source(Beam, CB) -> - Os = case lists:keyfind(options, 1, binary_to_term(CB)) of - false -> []; - {_, Os0} -> Os0 - end, +try_source(Beam, RawCB) -> + EbinDir = filename:dirname(Beam), + CB = binary_to_term(RawCB), + Os = proplists:get_value(options,CB, []), Src0 = filename:rootname(Beam) ++ ".erl", - case is_file(Src0) of - true -> parse_file(Src0, Os); - false -> - EbinDir = filename:dirname(Beam), - Src = filename:join([filename:dirname(EbinDir), "src", - filename:basename(Src0)]), - case is_file(Src) of - true -> parse_file(Src, Os); - false -> {error, nofile} - end + Src1 = filename:join([filename:dirname(EbinDir), "src", + filename:basename(Src0)]), + Src2 = proplists:get_value(source, CB, []), + try_sources([Src0,Src1,Src2], Os). + +try_sources([], _) -> + {error, nofile}; +try_sources([Src|Rest], Os) -> + case is_file(Src) of + true -> parse_file(Src, Os); + false -> try_sources(Rest, Os) end. is_file(Name) -> |