Initiating kernel logging

QNX Toolkit1.1QNX Toolkit User's GuideDeveloperSetup

You can use kernel logging on a selected target. When you run the logging command, QNX Toolkit attempts to find a launch configuration for the selected target in the currently active Workspace. If none is found, then it creates the default launch configuration and runs it.

Capturing a kernel event trace

To capture an event trace:

  1. From QNX TARGETS, right-click the target.
  2. Click Capture QNX Kernel Event Trace (with tracelogger):

    Tracelogger is launched and a trace.kev file is saved in the project.
Note:
You can customize this command using the launch configuration for tracing, as described in the section that follows.

Modifying kernel logging using a launch configuration

In the launch configuration, you can specify kernel tracing behavior to run with or without a program. When you configure the trace logging behavior, you can set how long for the daemon to run and specify where the results should be stored.

To add the tracelogger configuration to launch.json:

  1. From a mounted workspace, expand the project folder, and then navigate to the .vscode directory and click launch.json.
  2. Click the Add Configuration... button.
  3. From the dropdown menu, select Run Tracelogger. The configuration to run trace logging from is added to the launch.json file:
    {
      "type": "qnx-gdb",
      "request": "launch",
      "name": "tracelogger",
      "gdb": "none",
      "program": "tracelogger",
      "args": [
        "-s10",
        "-f/dev/shmem/trace.kev"
      ],
      "qnxtarget": "default",
      "upload": false,
      "files": [
        {
          "operation": "download",
          "remotePath": "/dev/shmem/trace.kev"
        }
      ]
    }
    Note:
    Don't edit the name option if you want to run the default Capture QNX Kernel Event Trace (with tracelogger) command.
  4. Launch the configuration as described in the previous section or use the Capture QNX Kernel Event Trace (with tracelogger) command.

Creating advanced launch configurations for application tracing

You can create a configuration to run your program and tracelogger at the same time and download the resulting trace back to your host.

Example:

{
  "version": "2.0.0",
  "configurations": [
    {
      "type": "qnx-gdb",
      "request": "launch",
      "name": "QNX: kernel_trace_demo",
      "gdb": "none",
      "program": "${command:qnx.autodetectBinary}",
      "args": [
          "-s1",
          "-c4",
          "-n100"
      ],
      "remotePath": "kernel_trace_demo",
      "qnxtarget": "default",
      "upload": true,
      "stopAtEntry": false,
      "preLaunchTask": "${defaultBuildTask}"
    },
    {
      "type": "qnx-gdb",
      "request": "launch",
      "name": "start tracelogger daemon",
      "gdb": "none",
      "stopAtEntry": false,
      "program": "tracelogger",
      "args": [
          "-d1", // Daemon mode
          "-s4", // Stop after 4 seconds
          "-E", // Enable Events
          "-c", // Continuous mode
          "-f/tmp/trace.kev" // Save to path
      ],
      "upload": false,
      "files": [
          {
            "operation": "download",
            "remotePath": "/tmp/trace.kev",
            "hostPath": "${workspaceFolder}/trace.kev"
          }
      ]
    },
  ],
  "compounds": [
    {
      "name": "QNX: kernel_trace_demo + trace",
      "configurations": [
        "start tracelogger daemon",
        "QNX: kernel_trace_demo"
      ]
    }
  ]
}

Starting kernel logging with the remote shell command

You can use a task configuration to set up kernel logging using a remote shell command. This allows you to initiate kernel logging from the terminal or assign a shortcut.

To configure the remote shell command:

  1. In the workspace, click tasks.json.
  2. Configure a task of the qnx-shell type.

Example:

{
  "version": "2.0.0",
  "tasks": [
    {
      "label": "Download trace",
      "type": "qnx-shell",
      "command": "download",
      "args": [
        "/tmp/sample-trace.kev",
        "${workspaceFolder}/task-trace.kev"
      ],
      "dependsOn": [
        "Run Tracelogger"
      ]
    },
    {
      "label": "Run Tracelogger",
      "type": "qnx-shell",
      "command": "exec",
      "args": [
        "tracelogger",
        "-s3",
        "-f/tmp/sample-trace.kev",
      ],
    }
  ]
}
Page updated: