Back to top

Documentation

Configuring VS Code extension

The following launch.json example adds debug configuration in VS Code that starts myexe executable for debugging with SLDB.

{
    "version": "0.2.0",
    "configurations": [
        {
            "type": "sldb",
            "request": "launch",
            "name": "(sldb) Launch",
            "program": "${workspaceFolder}/myexe",
            "args": ["aaa", "bbb"]
            "environment": [
                {
                    name: "PATH",
                    value: "/some/additional/path:$PATH"
                }
            ]
        }
    ]
}

Configuration options

Name Type Description
type String The type of the engine. Must be sldb.
request String Request to execute. Must be launch or attach.
program String Absolute path to an executable to launch for the launch request. Process name to attach to for the attach request. Required for the launch request.
pid Number ID of process to attach to for the attach request.
args Array of strings Command line arguments.
cwd String The working directory.
environment Array of {“name”: “”, “value”: “"} objects Environment variables
launchInTerminal Boolean Launch debuggee in integrated terminal. Default value is true.
displayRawData Boolean Display [Raw Data] field containing raw unformatted fields of formatted value. Default value is true.
displayHex Boolean Display integer values in hexadecimal format. Default value is false.
displayMinHexSize Integer Minimum number of bytes displayed in hexadecimal format. Default value is 4.
displayPointerAddresses Boolean Display memory addresses of pointer values. Default value is true.
displayStructAddresses Boolean Display memory addresses of class/struct/union values. Default value is false.
avoidNodebug Boolean Avoid functions with no debug info. Default value is true.
avoidStdFunctions Boolean Avoid functions from the C++ Standard library. Default value is true.
stepThroughStdFunctions Boolean Step through C++ Standard library functional objects code when performing step into. Default value is true.
avoidRegexList Array of strings List of regular expressions to match functions to avoid.
stepThroughRegexList Array of strings List of regular expressions to match functions to step through when performing step into.
markStdFunctions Boolean Mark C++ Standard library functional objects frames as subtle. Default value is true.
markRegexList Array of strings List of regular expressions to match functions to be marked as subtle in call stack.
platform String Name of platform to connect. Available platforms: host, remote-freebsd, remote-linux, remote-netbsd, remote-openbsd, remote-windows, remote-android, remote-ios, remote-macosx, remote-gdb-server.
platformUrl String URL of platform to connect. For most platforms, URL contains host name and port number in the form of <host-name>:<port>. For the android platform, URL is a device name. If URL is empty for the android platform then default device is used.
initCommands` Array of strings List of debugger initialization commands.
execSearchPaths Array of strings List of local paths to search for loaded executables and shared libraries.
androidSdk String Path to Android SDK for the android platform.
androidNdk String Path to Android NDK for the android platform.
androidJdb String Optional path to JDB to use with the android platform.
logToOutput Boolean Send Debug Adapter Protocol server executabe log to output. Default value if true.
logLevel String Logging level for Debug Adapter Protocol server executabe. Allowed values: fatal, error, warning, info, debug, trace. Default value is info.

Android debugging

Standalone application

To start Android debugging in standalone application you need to perform the following steps:

  1. Configure paths to Android SDK and NDK, and optional path to the jdb debugger in the Settings dialog.
  2. Click Open… in the File menu.
  3. Set the following fields in the Load executable dialog:
    • Select “android” in the Platform combo box.
    • Set launch target to application ID and activity name in the form of <app-id>/<activity-name>, for example com.example.testapp/.MainActivity.
    • Add paths to debug versions of native libraries in the list of shared libraries search paths.
  4. Click Ok and start debugging from the main menu or toolbar.

Alternatively, you can set Android target from command line, for example:

sldb --platform=android \
     --init="settings set target.exec-search-paths /path/to/libs" \
     "com.example.testapp/.MainActivity"

VS Code extension

To start debugging on local Android device or emulator you need to set the following parameters in the launch configuration:

  • The androidSdk parameter should be set to the full path to Android SDK.
  • The androidNdk parameter should be set to the full path to Android NDK.
  • The androidJdb parameter should be set to the full path to jdb debugger from JDK or Android Studio. You can leave it empty to use jdb from PATH environment variable.
  • The platform parameter should be set to android.
  • The platform-url parameter should be set to name of Android device or emulator. You can leave it empty to use default device or emulator.
  • The program parameter should be set to ID of the application and name of the activity in the form of <app-id>/<activity-name>, for example com.example.myapp/.MainActivity.
  • The execSearchPaths parameter should be set to array of paths to native shared libraries with debug info used in application.

Example of Android launch configuration:

{
    "version": "0.2.0",
    "configurations": [
        {
            "type": "sldb",
            "request": "launch",
            "name": "(sldb) Launch Android",
            "platform": "android",
            "program": "com.example.testapp/.MainActivity",
            "execSearchPaths": [
                "/home/user/AndroidStudioProjects/TestApp/app/build/intermediates/cmake/debug/obj/x86_64"
            ],
            "androidSdk": "/home/user/Android/Sdk",
            "androidNdk": "/home/user/Android/Sdk/ndk/21.0.6113669"
        }
    ]
}