erts: Print that we are crashdumping earlier

Change so that we print that the we generating a crash dump
before we actually generate it. So that if a huge crashdump is
being dumped, the user knows that something is going on.
Add more tests of supervisor

Add tests of code_change/3 and error handling of supervisor flags.
Rebase supervisor

Remove duplicated code related to checking of supervisor flags.
[sasl] Remove undocumented upgrade instruction

The upgrade instruction 'remove_module' was added in OTP R7B (and
possibly in a patch in R5B or R6B, ticket OTP-3477), and translates to
the low level instruction 'remove', but adds the parameter DepMods
(modules on which Mod is dependent). The ticket says that
"remove_module should be added for symmetry with the add_module
instruction". remove_module was never documented or tested, and it was
never mentioned in a release note. It therefore seems to be low risk
in removing it.

The correct instruction to use when removing a module is

{delete_module,Mod}

which was added in OTP R10B and which is also documented and
tested. This translates to low level instructions 'remove' and 'purge'
i.e. the module is brutally purged after setting the current code to
old. This hardcoded brutal purge is the reason why PrePurge and
PostPurge parameters can not be given with the delete_module
instruction.

The parameter DepMods which was inclued in the remove_module
instruction does not exist for delete_module. From the documentation's
point of view, this is the same for add_module, and thus the two
instructions {add_module,Mod} and {delete_module,Mod} are now
symmetric. However, in the code there is a second instruction for
adding a module, {add_module,Mod,DepMods}, which is not documented. To
add symmetry even for this, {delete_module,Mod,DepMods} is now also
added. Documentation is added for all instructions.
Allow maps for supervisor flags and child specs

Earlier, supervisor flags and child specs were given as tuples. While
this is kept for backwards compatibility, it is now also allowed to
give these parameters as maps:

-type sup_flags() :: #{strategy => strategy(),         % optional
		       intensity => non_neg_integer(), % optional
		       period => pos_integer()}        % optional

-type child_spec() :: #{id => child_id(),       % mandatory
			start => mfargs(),      % mandatory
			restart => restart(),   % optional
			shutdown => shutdown(), % optional
			type => worker(),       % optional
			modules => modules()}   % optional

Default values are as follows:

Supervisor flags:

strategy: one_for_one
intensity: 1
period: 5

Child specs:

restart: permanent
type: worker
shutdown: 5000 for workers, 'infinity' for supervisors
modules: [M], where M comes from the child's start {M,F,A}

Some of these default values are quite hard to decide on, since there
really is no "most common way". It always depends on the use case. So
we decided that the most important reason for having default values is
to lower the start barrier and get "something" running. For production
use, most systems must be fine tuned in this respect anyway.

This is how we reasoned about it:

Strategy: just pick one - and 'one_for_one' was most used in OTP.

Max restart frequency (intensity/period): by allowing one restart only
we keep the important supervisor feature of restarting children, but
we also avoid the possibility of scaling to a huge amount of restarts
if the supervisor tree is deep.

Restart: just pick one - and 'permanent' is fairly common.

Shutdown for workers: to avoid the confusion of why the terminate
function is not executed, we decided not to use 'brutal_kill'. Which
number to use is probably not that important, so we chose 5000.

Shutdown for supervisors: the recommended shutdown value for
supervisors is 'infinity', so we decied to use that. Having the same
(integer) value as for workers can give very strange results.

Type: just pick one - and we believe that 'worker' is most common
New function supervisor:get_childspec/2

Takes the name of the child (or Pid, in the case of a
simple_one_for_one supervisor) and returns the map which specifies the
child.
Fix "-smp disable" for emulator with dirty schedulers

Running "erl -smp disable" on an emulator built with dirty scheduler
support caused problems such as segmentation violations and emulator status
line outputs containing garbage. For example:

    $ erl -smp disable
    Segmentation fault (core dumped)

and:

    $ erl -smp disable
    Erlang/OTP 17 [DEVELOPMENT] [erts-6.2] [source] [64-bit] [ds:10:4297895689:4299948152] [async-threads:280]

This problem also caused the emulator smoke_test_SUITE to hit these same
problems if run in an emulator started with the "-smp disable" option.

Fix this segmentation violation by ensuring that dirty scheduler
information is printed in the status line only when the emulator is
compiled with ERTS_SMP enabled.

With this fix in place, the smoke_test_SUITE now passes when the "-smp
disable" option is used, and the emulator status line prints correctly for
both "-smp enable" and "-smp disable":

    $ erl -smp enable
    Erlang/OTP 17 [DEVELOPMENT] [erts-6.2] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:10] [kernel-poll:false]

and:

    $ erl -smp disable
    Erlang/OTP 17 [DEVELOPMENT] [erts-6.2] [source] [64-bit] [async-threads:10] [kernel-poll:false]
erts: Fix hanging in fd_stop on windows

When reaping ports the flushReplyEvent is not signalled and therefore
an errornous loop check caused the emulator to hang forever during
shutdown.
Expose NIF version

This patch allows checking for NIF API version in a way similar to
driver version. E.g. by calling erlang:system_info(nif_version).

Signed-off-by: Peter Lemenkov <lemenkov@gmail.com>
fix doc for maps:with/2
Section reference number incorrect
Merge branch 'lukas/erts/win32-flush-block/OTP-12291' into maint

* lukas/erts/win32-flush-block/OTP-12291:
  erts: Fix hanging in fd_stop on windows
Merge branch 'maint'

* maint:
  erts: Fix hanging in fd_stop on windows
Merge branch 'lukas/erts/crash_dump_shell_info/OTP-12292'

* lukas/erts/crash_dump_shell_info/OTP-12292:
  erts: Print that we are crashdumping earlier
Merge branch 'dcy/maint' into maint

* dcy/maint:
  fix doc for maps:with/2
Merge branch 'maint'
Merge branch 'vinoski/fix-smp-disable-with-ds/OTP-12295' into maint

* vinoski/fix-smp-disable-with-ds/OTP-12295:
  Fix "-smp disable" for emulator with dirty schedulers
Merge branch 'maint'
Add test of maps in supervisor flags and child specs
Add documentation of maps in supervisor flags and child specs