Add basic support for system messages

This change provides support for Cowboy process handling requests to
handle system messages from the `sys` module.

When receving a message of the form `{system, From, Msg}` a
middleware (or sub_protocol) should return the following to handle the
message:

`{system, From, Msg, Module, Req, State}`

The system message will be handled for the middleware (or sub_protocol)
using the `sys` module. Control is returned via the `cowboy_sys`
callbacks:

* `sys_continue(Req, State)` - called when the middleware (or
sub_protocol) should continue processing as before.
* `sys_terminate(Reason, Req, State)` - called when the middleware (or
sub_protocol) should do any cleanup and then exit with reason `Reason`.

`cowboy_loop` and `cowboy_websocket` both handle system messages,
allowing live debugging of long running requests.

If a handler does not upgrade to a sub_protocol that handles system
messages, a system message received by a Cowboy request process may
be handled after the current requested has finished processing but
before the next request.

Calling `sys:get_state/{1,2}` on a Cowboy request process will return:

`{cowboy_protocol, undefined, State}`

Or:

`{Module, Req, State}`

The `Module` will be either `cowboy_protocol` or `cowboy_spdy_request`,
depending whether the process is handling HTTP(S) or SPDY requests. Note
the special case of `cowboy_protocol` where `Req` is `undefined` as
there is currently no request object because the process is between
requests. This will occur when a middleware (or sub_protocol) does not
handle system messages.

`State` is the internal state of the current module (e.g.
`cowboy_protocol`), rather than the current middleware or subprotocol.
The internal state formats of `cowboy_protocol` and
`cowboy_spdy_request` are not documented. However the module and state
of the current middleware will be included in somewhere in state.

The replace fun used in `sys:replace_state/{2,3}` on a Cowboy request
process should accept, and return, a state of the form returned by
`sys:get_state/{1,2}`.

Calling `sys:get_status/{1,2}` on a Cowboy request process will yield
slightly more information.

Note that all `sys` module functions will work on Cowboy processes, but
calling `sys:change_code/{4,5}` will not change the state of a process.
Also Cowboy processes do not generate any `sys` debug events, so some
other functions are of limited use.

A requirement of supporting the `sys` module is using `proc_lib`. This
has the following side effects:
* A `crash_report` is sent to the error logger on abnormal exit.
* The emulator will nolonger send an event to the error logger when an
error or throw is not caught.
Improve support for sys:get_state/{1,2} and sys:replace_state/{3,4}

Adds `sys_get_state/2` callback to `cowboy_sys` behaviour:

The callback is called as `sys_get_state(Req, State)`, with possible return
values:
* `{ok, Req, State}`
* `{Mod, Req, ModState}`

This callback is used to handle `sys:get_state/{1,2}` system messages.
The return value `{ok, Req, State}` will return `{?MODULE, Req, State}
from `sys:get_state/{1,2}`. The return value `{Mod, Req, ModState}` will
return itself from `sys:get_state/{1,2}`.

Adds `sys_replace_state/3` callback to `cowboy_sys` behaviour:

The callback is called as, `sys_replace_state(Replace, Req, State)` with
possible return values:
* `{ok, Req, State2}`
* `{Mod, Req, ModState, State2}`

This callback is used to handle the `sys:replace_state/{2,3}` system
messages. The `Replace` term is a 1-arity fun taking the form:

`fun({Mod, Req, ModState}) -> {Mod, Req2, ModState2} end`

It should be applied to the same module, request object and module state
tuple that is returned from `sys_get_state/2`. For example:

`{?MODULE, Req, State2} = Replace({?MODULE, Req, State})`

The callback's return value `{ok, Req, State2}` will return
`{?MODULE, Req, State}` from `sys:replace_state/{2,3}` and replace the
state of `?MODULE` with the new `State2`. The return value
`{Mod, Req, ModState, State2}` will return `{Mod, Req, ModState}` from
`sys:replace_state/{2,3}` and replace the state of `?MODULE with the new
`State2`.