summaryrefslogtreecommitdiff
path: root/lib/reltool
diff options
context:
space:
mode:
authorAnton Thomasson <anton.thomasson@ericsson.com>2022-04-27 16:51:21 +0200
committerAnton Thomasson <anton.thomasson@ericsson.com>2022-05-03 08:25:03 +0200
commit5f09e914610d097dfcac3561cc020b11279aa6a9 (patch)
treeca0a6bc4676e04e1da03c25a63743376c504de23 /lib/reltool
parent3ce345becdcbad8bb06b9c5e119b0787b9ba3913 (diff)
downloaderlang-5f09e914610d097dfcac3561cc020b11279aa6a9.tar.gz
reltool: Add option for selective beam stripping
The debug_info option can now take a list of chunk ids to keep. Chunk ids are as per beam_lib:chunkid(). For example, {debug_info, ["Attr"]} will keep only the attributes in the beam files and strip the rest.
Diffstat (limited to 'lib/reltool')
-rw-r--r--lib/reltool/doc/src/reltool.xml10
-rw-r--r--lib/reltool/src/reltool.hrl2
-rw-r--r--lib/reltool/src/reltool_server.erl7
-rw-r--r--lib/reltool/src/reltool_target.erl15
4 files changed, 20 insertions, 14 deletions
diff --git a/lib/reltool/doc/src/reltool.xml b/lib/reltool/doc/src/reltool.xml
index 136ec2ed69..efbd28f849 100644
--- a/lib/reltool/doc/src/reltool.xml
+++ b/lib/reltool/doc/src/reltool.xml
@@ -226,10 +226,10 @@
<tag><c>debug_info</c></tag>
<item>
- <p>The <c>debug_info</c> parameter controls whether the debug
- information in the beam file should be kept (<c>keep</c>) or
- stripped <c>strip</c> when the file is copied to the target
- system.</p>
+ <p>The <c>debug_info</c> parameter controls what debug
+ information in the beam file should be kept or stripped.
+ <c>keep</c> keeps all debug info, <c>strip</c> strips all debug
+ info, and a list of chunkids keeps only those chunks.</p>
</item>
<tag><c>excl_lib</c></tag>
@@ -542,7 +542,7 @@ app_vsn() = string()
archive_opt = zip_create_opt()
boot_rel() = rel_name()
app_file() = keep | strip | all
-debug_info() = keep | strip
+debug_info() = keep | strip | [beam_lib:chunkid()]
dir() = string()
escript() = {incl_cond, incl_cond()}
escript_file() = file()
diff --git a/lib/reltool/src/reltool.hrl b/lib/reltool/src/reltool.hrl
index 844a3a880a..6cbadc3ade 100644
--- a/lib/reltool/src/reltool.hrl
+++ b/lib/reltool/src/reltool.hrl
@@ -28,7 +28,7 @@
%% derived - Include only those modules that others are dependent on
-type mod_cond() :: all | app | ebin | derived | none.
-type incl_cond() :: include | exclude | derived.
--type debug_info() :: keep | strip.
+-type debug_info() :: keep | strip | [beam_lib:chunkid()].
-type app_file() :: keep | strip | all.
-type re_regexp() :: string(). % re:regexp()
-type regexps() :: [re_regexp()] |
diff --git a/lib/reltool/src/reltool_server.erl b/lib/reltool/src/reltool_server.erl
index 43e9d50b18..7813a335f8 100644
--- a/lib/reltool/src/reltool_server.erl
+++ b/lib/reltool/src/reltool_server.erl
@@ -1587,7 +1587,7 @@ decode(#sys{} = Sys, [{Key, Val} | KeyVals]) ->
Sys#sys{embedded_app_type = Val};
app_file when Val =:= keep; Val =:= strip; Val =:= all ->
Sys#sys{app_file = Val};
- debug_info when Val =:= keep; Val =:= strip ->
+ debug_info when Val =:= keep; Val =:= strip; is_list(Val) ->
Sys#sys{debug_info = Val};
_ ->
reltool_utils:throw_error("Illegal option: ~tp", [{Key, Val}])
@@ -1608,7 +1608,8 @@ decode(#app{} = App, [{Key, Val} | KeyVals]) ->
App#app{incl_cond = Val};
debug_info when Val =:= keep;
- Val =:= strip ->
+ Val =:= strip;
+ is_list(Val) ->
App#app{debug_info = Val};
app_file when Val =:= keep;
Val =:= strip;
@@ -1663,7 +1664,7 @@ decode(#mod{} = Mod, [{Key, Val} | KeyVals]) ->
case Key of
incl_cond when Val =:= include; Val =:= exclude; Val =:= derived ->
Mod#mod{incl_cond = Val};
- debug_info when Val =:= keep; Val =:= strip ->
+ debug_info when Val =:= keep; Val =:= strip; is_list(Val) ->
Mod#mod{debug_info = Val};
_ ->
reltool_utils:throw_error("Illegal option: ~tp", [{Key, Val}])
diff --git a/lib/reltool/src/reltool_target.erl b/lib/reltool/src/reltool_target.erl
index 773e752ad4..525a959d7f 100644
--- a/lib/reltool/src/reltool_target.erl
+++ b/lib/reltool/src/reltool_target.erl
@@ -1172,7 +1172,9 @@ spec_mod(Mod, DebugInfo) ->
keep ->
{copy_file, File};
strip ->
- {strip_beam, File}
+ {strip_beam, File, []};
+ ChunkIds ->
+ {strip_beam, File, ChunkIds}
end.
spec_app_file(#app{name = Name,
@@ -1315,11 +1317,14 @@ do_eval_spec({write_file, File, Bin},
TargetDir) ->
TargetFile = filename:join([TargetDir, File]),
reltool_utils:write_file(TargetFile, Bin);
-do_eval_spec({strip_beam, File}, _OrigSourceDir, SourceDir, TargetDir) ->
+do_eval_spec({strip_beam, File, ChunkIds},
+ _OrigSourceDir,
+ SourceDir,
+ TargetDir) ->
SourceFile = filename:join([SourceDir, File]),
TargetFile = filename:join([TargetDir, File]),
BeamBin = reltool_utils:read_file(SourceFile),
- {ok, {_, BeamBin2}} = beam_lib:strip(BeamBin),
+ {ok, {_, BeamBin2}} = beam_lib:strip(BeamBin, ChunkIds),
reltool_utils:write_file(TargetFile, BeamBin2).
cleanup_spec(List, TargetDir) when is_list(List) ->
@@ -1349,7 +1354,7 @@ cleanup_spec({copy_file, NewFile, _OldFile}, TargetDir) ->
cleanup_spec({write_file, File, _}, TargetDir) ->
TargetFile = filename:join([TargetDir, File]),
file:delete(TargetFile);
-cleanup_spec({strip_beam, File}, TargetDir) ->
+cleanup_spec({strip_beam, File, _ChunkIds}, TargetDir) ->
TargetFile = filename:join([TargetDir, File]),
file:delete(TargetFile).
@@ -1419,7 +1424,7 @@ do_filter_spec(Path,
do_filter_spec(Path, {write_file, File, _}, InclRegexps, ExclRegexps) ->
Path2 = opt_join(Path, File),
match(Path2, InclRegexps, ExclRegexps);
-do_filter_spec(Path, {strip_beam, File}, InclRegexps, ExclRegexps) ->
+do_filter_spec(Path, {strip_beam, File, _ChunkIds}, InclRegexps, ExclRegexps) ->
Path2 = opt_join(Path, File),
match(Path2, InclRegexps, ExclRegexps).