Debugging app's native code - flutter-tizen/flutter-tizen Wiki

Your app may contain some native (C/C++) source code if the app language is C++ or it depends on one or more native plugins. A source-level debugger like GDB/LLDB can be used to debug your native code, e.g. by setting breakpoints and examining variables.

See also

Support status

Device type

GDB LLDB Remarks
TV device Except development boards
Non-TV device (normal) ✔️
Non-TV device (rooted) ✔️ ✔️ Including Tizen emulators

App language

C++ (native app) ✔️ ✔️
C# (.NET app) ✔️

Note that LLDB is applicable for local (CLI) debugging only and requires a super user privilege. If your app's current langauge is C#, you may (temporarily) switch the language to C++ as follows to enable GDB support:

# Go to the app project directory and back up the "tizen" directory.
$ mv tizen tizen_csharp

# Create the project again.
$ flutter-tizen create --tizen-language cpp .

Remote debugging with GDB and gdbserver

Starting gdbserver

Note: If your device is rooted, make sure to sdb root off before proceeding.

  1. Build an app that you want to debug in debug mode and install to your device.

  2. Start the app without loader process using the app_launcher -e command.

    # Stop if already running.
    $ sdb shell app_launcher -k [APP_ID]
    # Start the app.
    $ sdb shell app_launcher -e [APP_ID]

    Note: You can debug an already running app only if it has been launched without loader process. To always launch the app without loader process, set the direct-launch metadata value to yes in your tizen-manifest.xml:

    <metadata key="" value="yes"/>

    Do not include this metadata when you create a release build of your app as it affects the app's startup performance.

  3. Go to the app project directory and run flutter-tizen-gdb.

    $ flutter-tizen-gdb
    gdbserver is listening for debug connection on port 37375.
    Available commands:
    r Run GDB client
    p Print launch.json configuration
    v Open this project in VS Code
    q Quit

    Note: Python 3.6 or above is required to run flutter-tizen-gdb. If you are on Windows, you can use the python3 command to run the script (flutter-tizen/bin/flutter-tizen-gdb) directly.

    If successful, you will see a message that says gdbserver is listening for a debug connection. You can start GDB either from the command line (for CLI debugging) or by using VS Code's built-in debugger (for GUI debugging) to connect to the gdbserver.

a. Connecting from the command line

Entering the r command will open a GDB client in the same window. Once a debug session starts, you can start debugging by typing any GDB command (such as bt and b) in the debugger console.

Enter a command: r
Reading /lib/ from remote target...
0xf7435038 in ?? () from target:/lib/
Reading symbols from target:/opt/usr/globalapps/com.example.my_app/bin/../lib/

b. Connecting from VS Code

  1. Enter the p command to display a recommended VS Code debug configuration. For example,

        "version": "0.2.0",
        "configurations": [
                "name": "flutter-tizen: gdb",
                "request": "launch",
                "type": "cppdbg",
                "externalConsole": false,
                "MIMode": "gdb",
                "symbolLoadInfo": {
                    "loadAll": false,
                    "exceptionList": "libflutter*.so"
                "cwd": "path_to_app",
                "program": "path_to_runner",
                "miDebuggerPath": "path_to_gdb",
                "miDebuggerServerAddress": "debug_uri"
  2. Launch VS Code and install the C/C++ extension if it's not installed.

  3. Open the app project folder (or add to the workspace).

  4. Click the Run and Debug icon in the left menu bar, and click create a launch.json file to create a launch.json file for your project. Click the ⚙️ button if the file already exists.

  5. Replace the content of the file with the debug configuration you obtained in the above.

  6. Make sure flutter-tizen: gdb is now selected as an active debug configuration.

    Debug configuration

  7. Click the Run (▷) button or press F5 to start debugging. Once a debug session starts, the Debug toolbar will appear on the top of the editor. (It might take a while for the debugger to connect to the remote gdbserver according to your connection speed.)


Debugging with LLDB

Note: LLDB is available for rooted devices (such as a mobile emulator) only.

  1. Download the LLDB RPM package for your target device from the Tizen package repository. For example, if your device is a mobile 6.5 emulator, you should download the lldb-5.0.2-*.i686.rpm file from Tizen 6.5 base packages for i686.

  2. Install the downloaded package to the device.

    $ sdb root on
    $ sdb push [.rpm] /tmp
    $ sdb shell
    bash-3.2# mount -o remount,rw /
    bash-3.2# rpm -Uvh --force /tmp/[.rpm]
    bash-3.2# rm /tmp/[.rpm]
  3. Build and run your app in debug mode.

  4. Find the process ID (PID) of the running app. In the following example, the PID is 6691.

    $ sdb shell app_launcher -S
         appId (PID)
          com.example.my_app (6691)
  5. Attach LLDB to the running app using the PID.

    bash-3.2# lldb -p [PID]

    You can now start debugging by typing any LLDB command (such as bt and b) in the debugger console. If you're not familiar with LLDB and LLDB commands, see the GDB to LLDB command map.