2018-05-31 18:00:30 +08:00
|
|
|
.. _usercrash_doc:
|
|
|
|
|
2018-07-19 02:21:07 +08:00
|
|
|
usercrash
|
2018-05-31 18:00:30 +08:00
|
|
|
#########
|
|
|
|
|
|
|
|
Description
|
|
|
|
***********
|
|
|
|
|
2018-07-19 02:21:07 +08:00
|
|
|
The ``usercrash`` tool gets the crash info for the crashing process in
|
2018-08-31 04:58:20 +08:00
|
|
|
userspace. The collected information is saved as usercrash_xx under
|
2018-05-31 18:00:30 +08:00
|
|
|
``/var/log/usercrashes/``.
|
|
|
|
|
|
|
|
Design
|
|
|
|
******
|
|
|
|
|
2018-07-19 02:21:07 +08:00
|
|
|
``usercrash`` is designed using a Client/Server model. The server is
|
|
|
|
autostarted at boot. The client is configured in ``core_pattern``, which
|
|
|
|
will be triggered when a crash occurs in userspace. The client then
|
|
|
|
sends the crash event to the server. The server checks the files under
|
|
|
|
``/var/log/usercrashes/`` and creates a new file usercrash_xx (xx means
|
|
|
|
the index of the crash file). Then it sends the file descriptor (fd) to
|
|
|
|
the client. The client is responsible for collecting crash information
|
|
|
|
and saving it in the crashlog file. After the saving work is done, the
|
|
|
|
client notifies server and the server will clean up.
|
2018-05-31 18:00:30 +08:00
|
|
|
|
2020-09-26 07:24:35 +08:00
|
|
|
The workflow diagram:
|
2018-05-31 18:00:30 +08:00
|
|
|
|
|
|
|
::
|
|
|
|
|
|
|
|
+--------------------------------------------------+
|
|
|
|
| |
|
|
|
|
| Server Client |
|
|
|
|
| + + |
|
|
|
|
| | Send crash event | |
|
|
|
|
| | <-----------------------+ |
|
|
|
|
| | | |
|
|
|
|
| Create usercrash_xx | |
|
|
|
|
| | | |
|
|
|
|
| | Send usercrash_xx fd | |
|
|
|
|
| +-----------------------> | |
|
|
|
|
| | | |
|
|
|
|
| | Fill usercrash_xx |
|
|
|
|
| | | |
|
|
|
|
| | Notify completion | |
|
|
|
|
| | <-----------------------+ |
|
|
|
|
| | | |
|
|
|
|
| Clean up | |
|
|
|
|
| | | |
|
|
|
|
| v v |
|
|
|
|
| |
|
|
|
|
+--------------------------------------------------+
|
|
|
|
|
|
|
|
Usage
|
|
|
|
*****
|
|
|
|
|
2018-10-09 16:57:48 +08:00
|
|
|
- The server is launched automatically at boot after this tool is enabled with
|
|
|
|
instruction ``sudo crashlogctl enable``, and the client is configured in
|
|
|
|
``usercrash-wrapper``, which is set as the app of ``core_pattern``. In
|
|
|
|
``usercrash-wrapper``, it will collect and reorder the parameters of the
|
|
|
|
client and default app. Once a crash occurs in user space, the client and
|
|
|
|
default app will be invoked separately.
|
2018-05-31 18:00:30 +08:00
|
|
|
|
|
|
|
- The ``debugger`` is an independent tool to dump the debug information of the
|
|
|
|
specific process, including backtrace, stack, opened files, registers value,
|
|
|
|
memory content around registers, and etc.
|
|
|
|
|
2018-07-19 00:18:01 +08:00
|
|
|
.. code-block:: none
|
2018-05-31 18:00:30 +08:00
|
|
|
|
|
|
|
$ debugger <pid>
|
|
|
|
|
|
|
|
.. note::
|
|
|
|
|
|
|
|
You need to be ``root`` to use the ``debugger``.
|
|
|
|
|
2019-03-09 03:01:04 +08:00
|
|
|
Source Code
|
|
|
|
***********
|
2018-05-31 18:00:30 +08:00
|
|
|
|
|
|
|
- client.c : This file is the implementation for client of ``usercrash``, which
|
|
|
|
is responsible for delivering the ``usercrash`` event to the server, and
|
|
|
|
collecting crash information and saving it to the crashfile.
|
|
|
|
- crash_dump.c : This file is the implementation for dumping the crash
|
|
|
|
information, including backtrace stack, opened files, registers value, memory
|
|
|
|
content around registers, and etc.
|
|
|
|
- debugger.c : This file is to implement a tool, which runs in command line to
|
|
|
|
dump the process information list above.
|
|
|
|
- protocol.c : This file is the socket protocol implement file.
|
|
|
|
- server.c : This file is the implement file for server of ``usercrash``, which
|
|
|
|
is responsible for creating the crashfile and handle the events from client.
|