diff options
author | Björn Gustavsson <[email protected]> | 2016-08-10 10:09:56 +0200 |
---|---|---|
committer | Björn Gustavsson <[email protected]> | 2016-08-10 10:09:56 +0200 |
commit | 73d9d1d3adabce8636a0010d6fdb6be37c36cae2 (patch) | |
tree | ec1093d5760cdeb2f03a9929f355515dd5106af2 /lib/debugger | |
parent | 3dc416bb89e577c83e16c306fd4821da03681ab9 (diff) | |
parent | a5fcd4f26969a768950dc643eeed2fdb41a5dc41 (diff) | |
download | otp-73d9d1d3adabce8636a0010d6fdb6be37c36cae2.tar.gz otp-73d9d1d3adabce8636a0010d6fdb6be37c36cae2.tar.bz2 otp-73d9d1d3adabce8636a0010d6fdb6be37c36cae2.zip |
Merge branch 'josevalim/large-binary-strings/PR-1131/OTP-13794'
* josevalim/large-binary-strings/PR-1131/OTP-13794:
Move expansion of strings in binaries to v3_core
Diffstat (limited to 'lib/debugger')
-rw-r--r-- | lib/debugger/src/dbg_iload.erl | 19 | ||||
-rw-r--r-- | lib/debugger/test/bs_bincomp_SUITE.erl | 1 |
2 files changed, 17 insertions, 3 deletions
diff --git a/lib/debugger/src/dbg_iload.erl b/lib/debugger/src/dbg_iload.erl index 369b456524..f83684b605 100644 --- a/lib/debugger/src/dbg_iload.erl +++ b/lib/debugger/src/dbg_iload.erl @@ -216,7 +216,7 @@ pattern({op,_,'-',{float,Anno,I}}) -> pattern({op,_,'+',{float,Anno,I}}) -> {value,ln(Anno),I}; pattern({bin,Anno,Grp}) -> - Grp1 = pattern_list(Grp), + Grp1 = pattern_list(bin_expand_strings(Grp)), {bin,ln(Anno),Grp1}; pattern({bin_element,Anno,Expr,Size,Type}) -> Expr1 = pattern(Expr), @@ -297,7 +297,7 @@ gexpr({map,Anno,E0,Fs0}) -> Fs1 = map_fields(Fs0, fun gexpr/1), {map,ln(Anno),E1,Fs1}; gexpr({bin,Anno,Flds0}) -> - Flds = gexpr_list(Flds0), + Flds = gexpr_list(bin_expand_strings(Flds0)), {bin,ln(Anno),Flds}; gexpr({bin_element,Anno,Expr0,Size0,Type}) -> Expr = gexpr(Expr0), @@ -506,7 +506,7 @@ expr({op,Anno,Op,L0,R0}, _Lc) -> R1 = expr(R0, false), %They see the same variables {op,ln(Anno),Op,[L1,R1]}; expr({bin,Anno,Grp}, _Lc) -> - Grp1 = expr_list(Grp), + Grp1 = expr_list(bin_expand_strings(Grp)), {bin,ln(Anno),Grp1}; expr({bin_element,Anno,Expr,Size,Type}, _Lc) -> Expr1 = expr(Expr, false), @@ -519,6 +519,19 @@ consify([A|As]) -> {cons,0,A,consify(As)}; consify([]) -> {value,0,[]}. +%% The debugger converts both strings "abc" and lists [67, 68, 69] +%% into {value, Line, [67, 68, 69]}, making it impossible to later +%% distingish one or the other inside binaries when evaluating. To +%% avoid <<[67, 68, 69]>> from evaluating, we convert strings into +%% chars to avoid the ambiguity. +bin_expand_strings(Es) -> + lists:foldr(fun ({bin_element,Line,{string,_,S},Sz,Ts}, Es1) -> + lists:foldr(fun (C, Es2) -> + [{bin_element,Line,{char,Line,C},Sz,Ts}|Es2] + end, Es1, S); + (E, Es1) -> [E|Es1] + end, [], Es). + %% -type expr_list([Expression]) -> [Expression]. %% These expressions are processed "in parallel" for purposes of variable %% definition etc. diff --git a/lib/debugger/test/bs_bincomp_SUITE.erl b/lib/debugger/test/bs_bincomp_SUITE.erl index 39e2240f2d..064e9567b3 100644 --- a/lib/debugger/test/bs_bincomp_SUITE.erl +++ b/lib/debugger/test/bs_bincomp_SUITE.erl @@ -66,6 +66,7 @@ end_per_group(_GroupName, Config) -> byte_aligned(Config) when is_list(Config) -> <<"abcdefg">> = << <<(X+32)>> || <<X>> <= <<"ABCDEFG">> >>, + <<"AxyzBxyzCxyz">> = << <<X, "xyz">> || <<X>> <= <<"ABC">> >>, <<1:32/little,2:32/little,3:32/little,4:32/little>> = << <<X:32/little>> || <<X:32>> <= <<1:32,2:32,3:32,4:32>> >>, <<1:32/little,2:32/little,3:32/little,4:32/little>> = |