Rate This Document
Findability
Accuracy
Completeness
Readability

Example

This section demonstrates how to collect data during runtime, analyze and display a function call sequence diagram, and analyze the POSIX function compatibility.

Example

  1. Collect POSIX function and parameter information in the configuration file. Assume that the configuration file is /home/demo/config.txt and the binary file is test_posix.
    cd /home/demo/
    LD_PRELOAD=./librecord.so RECORD_CONF=config.txt RECORD_OUT_DIR=/home/demo/data/ ./test_posix

    The librecord.so, libglib-2.0.so, and libgobject-2.0.so files are stored in /home/demo/.

    Content of the config.txt file:

    socket 1
    listen 1
    bind 1
    setsockopt 1
    epoll_create1 1
    epoll_ctl 1
    epoll_wait 1
    epoll_pwait 1
    send 1
    recv 1

    The data file record.3088471 is generated in the /home/demo/data/ directory.

  2. View the data file.
    vim /home/demo/data/record.3088471

    Content of the record.3088471 data file

    1 35507430 3088471 3088471 3088471 3088471 2740656
    0 35552550 socket 3 2 1 0
    0 35586810 setsockopt 5 4 1 2 281474293380980 4
    0 35610790 bind 3 4 281474293382192 16
    0 35628930 listen 2 4 3
    0 35643730 epoll_create1 1 0
    0 35656940 epoll_ctl 4 5 1 4 281474293382168
    0 35676960 epoll_wait 4 5 281474293382008 10 4294967295
    0 35695430 epoll_pwait 5 5 281474293382008 10 4294967295 0
  3. Display the sequence diagram. Assume that the data file path is /home/demo/data/.
    devkit advisor knet seq-diag -d /home/demo/data -o /home/demo/test.md

    The file content is as follows:

    Figure 1 Sequence diagram

    The sequence diagram file is in .md format. A tool that supports the .md format must contain the Mermaid plugin for rendering.

  4. Display the compatibility information. Assume that the compatibility configuration file is /home/demo/compat_conf.json.
    devkit advisor knet compat -d /home/demo/data -c /home/demo/compat_conf.json

    Command output:

    =====ERROR: some function calls do not satisfy conditions======
    [Function call] socket 2 1 0
    [Condition] when value of arg 1 is 1,condition should be satisfied: arg 2 should be one of them: 6
    [Function call] setsockopt 4 1 2 281474293380980 4
    [Condition] when value of arg 2 is 2,condition should be satisfied: arg 3 should be in the range: [88,32767]
    ===============================================================
    K-NET tools executed successfully.

    The command output shows that the socket () and setsockopt () functions are incompatible with each other.