Age | Commit message (Collapse) | Author |
|
|
|
Also eliminate use of erlang:get_stacktrace/0 in code generated
by the ASN.1 compiler.
|
|
|
|
|
|
* maint:
asn1: asn1:test now handles no_ok_wrapper and undec_rest
asn1: Further adjustments on generated code
asn1: Protect more by try..catch
|
|
* hans/asn1/asn1ct_test_fix/ERL-518/OTP-14787:
asn1: asn1:test now handles no_ok_wrapper and undec_rest
|
|
|
|
|
|
|
|
* siri/string-new-api: (28 commits)
hipe (test): Do not use deprecated functions in string(3)
dialyzer (test): Do not use deprecated functions in string(3)
eunit (test): Do not use deprecated functions in string(3)
system (test): Do not use deprecated functions in string(3)
system (test): Do not use deprecated functions in string(3)
mnesia (test): Do not use deprecated functions in string(3)
Deprecate old string functions
observer: Do not use deprecated functions in string(3)
common_test: Do not use deprecated functions in string(3)
eldap: Do not use deprecated functions in string(3)
et: Do not use deprecated functions in string(3)
os_mon: Do not use deprecated functions in string(3)
debugger: Do not use deprecated functions in string(3)
runtime_tools: Do not use deprecated functions in string(3)
asn1: Do not use deprecated functions in string(3)
compiler: Do not use deprecated functions in string(3)
sasl: Do not use deprecated functions in string(3)
reltool: Do not use deprecated functions in string(3)
kernel: Do not use deprecated functions in string(3)
hipe: Do not use deprecated functions in string(3)
...
Conflicts:
lib/eunit/src/eunit_lib.erl
lib/observer/src/crashdump_viewer.erl
lib/reltool/src/reltool_target.erl
|
|
|
|
* maint-20:
Updated OTP version
Prepare release
Accept non-binary options as socket-options
Bump version
Fix broken handling of default values in extensions for PER
compiler: Fix live regs update on allocate in validator
Take fail labels into account when determining liveness in block ops
Check for overflow when appending binaries, and error out with system_limit
|
|
Default values have never worked in extension for PER.
Note that for default values in the root part of SEQUENCE,
giving a value equal to the DEFAULT value, will result in
the same encoding as if asn1_DEFAULT was given. However,
that behavior is not promised by the documentation. The
documentation says that asn1_DEFAULT should be used for
default values. For DEFAULT in extensions, only implement
what the documentation promises and nothing more.
ERIERL-60
|
|
* maint-20:
Updated OTP version
Update release notes
Update version numbers
Fix doc for the 'quiet' option; it defaults to false
asn1: Fix missing quotes of external encoding call
Add a dedicated close function for TCP ports to prevent issues like ERL-430/448
Close TCP ports properly on send timeout
erts: Add missing release note
|
|
introduced by 8e4a9864385242b962ce7446f7daa4f58cfecca5.
|
|
EnumTypeName contains a hypen like fore example Cause-Misc. This caused
syntax errors when compiling the generated Erlang code.
|
|
|
|
This is a poor man's solution that allows to build and test the
system with all files compiled to native code simply by setting
the ERL_COMPILER_OPTS environment variable. Better solutions,
like automatically setting the no_native option whenever the
compiler sees an on_load attribute, obviously exist but require
more time to implement.
|
|
Just crash if there is an internal error.
|
|
* Remove out-commented code
* Fix obvious typos and bad grammar
* Adhere to the conventions for when to use "%" and "%%".
|
|
Remove blank lines between clauses; use matching instead of
is_list/1 guards.
|
|
|
|
Stop up using asn1ct_gen:emit/1 with a tuple instead of a list.
Also remove the remaining uses of asn1ct_gen:demit/1.
|
|
The debug option no longer serves any useful purpose.
|
|
That will make code slightly easier to read.
|
|
The code is not covered. The code is also not present
in the PER backend.
Here is a somewhat more formal proof that the code cannot
be reached:
asn1ct_gen_ber_bin_v2:gen_encode_user/3 calls
asn1ct_gen:gen_encode_constructed/4 where Typename is a list
of one element.
asn1ct_gen:gen_encode_constructed/4 will call
asn1ct_gen_ber_bin_v2:gen_encode/3 via asn1ct_gen:gen_types/4.
Note that if InnerType in asn1ct_gen:gen_encode_constructed/4
is 'SEQUENCE OF' or 'SET OF', Typename will be extended to a
list with two elements.
If InnerType in asn1ct_gen:gen_encode_constructed/4 is
'SET', 'SEQUENCE', or 'CHOICE', then asn1ct_gen_ber_bin_v2:gen_encode/3
will be called with the last argument being a #'ComponentType'{}.
asn1ct_gen_ber_bin_v2:gen_encode/3 will in that cause extend
Typename before calling itself recursively.
Therefore, Typename is always a list with at least two elements
when the removed code is called.
|
|
ce431409d0daba broke generation of dialyzer suppressions
for per and uper.
While we are it, add type tests to asn1ct_func:is_used/1
to avoid similar problems in the future.
|
|
|
|
The generated encode/2 and decode/2 functions can return
cryptic error messages. Consider this ASN.1 spec:
T DEFINITIONS AUTOMATIC TAGS ::=
BEGIN
S ::= SEQUENCE {
b BOOLEAN,
i INTEGER (1..100),
j INTEGER (0..7),
s OCTET STRING
}
END
In OTP 19, the error terms will look like this:
Eshell V8.2 (abort with ^G)
1> asn1ct:compile('T', [ber]).
ok
2> rr('T').
['S']
3> 'T':encode('S', #'S'{}).
{error,{asn1,{encode_boolean,undefined}}}
4> 'T':encode('S', #'S'{b=false}).
{error,{asn1,{encode_integer,undefined}}}
5> 'T':encode('S', #'S'{b=false,i=7,j=0}).
{error,{asn1,function_clause}}
Some error terms are clearer than other. In the first error
term, it is clear that the error refers to the 'b' field,
since there is only one BOOLEAN in 'S'. The second error
term could refer to either 'i' or 'j'. The last error term...
well... in this case we can infer that it must refer to 's'.
The easiest way to provide more information is to include
the stack trace with line numbers in the error term:
3> 'T':encode('S', #'S'{b=false}).
{error,{asn1,{{encode_integer,undefined},
[{'T',encode_integer,2,[{file,"T.erl"},{line,240}]},
{'T',enc_S,2,[{file,"T.erl"},{line,102}]},
{'T',encode,2,[{file,"T.erl"},{line,36}]},
{erl_eval,do_apply,6,[{file,"erl_eval.erl"},{line,674}]},
{shell,exprs,7,[{file,"shell.erl"},{line,686}]},
{shell,eval_exprs,7,[{file,"shell.erl"},{line,641}]},
{shell,eval_loop,3,[{file,"shell.erl"},{line,626}]}]}}}
By looking at the generated Erlang code, we can see that encoding
failed for 'i'.
This is an compatible change. All that the documentation says is
that the format of the error tuple is:
{error,{asn1,Description}}
With this change, Description is always a tuple:
{ErrorDescription,StackTrace}
Alternatives considered: Providing more information in the error
term itself and make sure there can be no 'function_clause', 'badarg',
or 'badmatch' exceptions. That would be possible, but it would
require a lot of work and it would increase the size of the generated
code and make it slower. Therefore, this solution was rejected.
|
|
When an invalid value is encountered when trying to decode an
ENUMERATED, the exception can be quite verbose. Here is an actual
example from NBAP-PDU-Contents:
_ -> exit({error,{asn1,{decode_enumerated,{V4@V3,[chCode1div1,chCode2div1,chCode2div2,chCode4div1,chCode4div2,chCode4div3,chCode4div4,chCode8div1,chCode8div2,chCode8div3,chCode8div4,chCode8div5,chCode8div6,chCode8div7,chCode8div8,chCode16div1,chCode16div2,chCode16div3,chCode16div4,chCode16div5,chCode16div6,chCode16div7,chCode16div8,chCode16div9,chCode16div10,chCode16div11,chCode16div12,chCode16div13,chCode16div14,chCode16div15,chCode16div16]}}}})
Listing the possible values for an ENUMERATED when decoding fails is
not helpful and increases the code size (it would have made somewhat
more sense to list the possible values if *encoding* failed).
|
|
To make it easier to find your way in the generated code,
add a comment about each attribute in the generated code
for SEQUENCE and SET.
|
|
Generate slightly better error reasons when encoding of INTEGER,
ENUMERATED, or BOOLEAN fails.
|
|
|
|
For now, do the packaging before call asn1ct_gen:pgen().
|
|
|
|
Note that put(currmod, Mod) is not needed because it has already
been done by the caller.
|
|
|
|
|
|
|
|
When the 'maps' option is given, the SEQUENCE and SET types are
represented as maps instead of as records. Optional and default values
must be not be given as asn1_NOVALUE or asn1_DEFAULT in a map passed
to the M:encode/2 function; they must be omitted from the
map. Similarly, when decoding missing values will be omitted from the
map.
No .hrl files will be generated when the 'maps' options is used.
That means values in an ASN.1 module must be retrieved by calling the
appropriate function in generated module.
Since we one day hope to get rid of the options 'compact_bit_string',
'legacy_bit_string', and 'legacy_erlang_types', we will not allow them
to be combined with the 'maps' option.
|
|
|
|
As a preparation for supporting maps in a future commit, refactor
the functions for encoding optional values.
|
|
|
|
Most options to the code generation pass are passed through the
process dictionary. At the same time, an Erule or Erules argument
is passed to most code generation functions. The Erule argument
is only an atom indicating the encoding rules ('ber', 'per', or
'uper').
Introduce a new record #gen{} to contain code generation options
and parameters. Pass it as the Erule argument (renaming it to Gen
in functions that we will have to touch anyway). In this commit,
eliminate the use of the variable 'encoding_options' in the process
dictionary.
|
|
|
|
asn1ct_check numbers all components in SEQUENCEs and SETs, except
for the associated sequence for INSTANCE OF. Remove this exception
so that the code generation pass can depend on SEQUENCEs being
numbered.
|
|
Introduce helper functions to simplify and reduce the size of
gen_encode_constructed_imm/3.
|
|
The to_encoding_order/1 function can be eliminated if we
incorporate its functionality into textual_order/2.
textual_order/2 has a workaround for TermList being longer
than OrderList. Remove the workaround, because the code
being generated would certainly be wrong (better let the compiler
crash and receive a bug report if it happens). The workaround
was not necessary to successfully compile the entire Erlang/OTP
and to run the asn1 test suite.
|
|
As a preparation for future changes, simplify
gen_dec_constructed_imm_2/6 by breaking it apart to two
functions.
|
|
Remove the entire asn1rt module. All functions in it were deprecated in
OTP 17.
In asn1ct, remove the deprecated functions asn1ct:encode/3 and
asn1ct:decode/3. Also remove asn1ct:encode/2, which has not been
formally deprecated but is undocumented.
|