1.. _gdb_plugin:
2
3===========
4GDB Plug-In
5===========
6
7Debugging LVGL with GDB
8-----------------------
9
10To facilitate debugging LVGL with GDB, a GDB plugin is provided. This plugin
11can be found in the ``lvgl/scripts/gdb`` directory. The GDB plugin can be used
12with any target where GDB is available. For example, you can use it to debug a
13device connected to a PC via JLink, which provides a GDB server. Additionally,
14if your device crashes and you have a core dump, you can use GDB to analyze the
15core dump. To load the LVGL GDB plugin within GDB's command line, type the
16following command:
17
18``source lvgl/scripts/gdb/gdbinit.py``
19
20
21Example of usage:
22
23.. code:: bash
24
25    (gdb) source lvgl/scripts/gdb/gdbinit.py
26
27    (gdb) dump obj -L 2
28    obj@0x60700000dd10 (0,0,799,599)
29    tabview@0x608000204ca0 (0,0,799,599)
30        obj@0x607000025da0 (0,0,799,69)
31        obj@0x607000025e80 (0,70,799,599)
32        obj@0x60700002bd70 (743,543,791,591)
33        btn@0x60700002c7f0 (747,547,787,587)
34    keyboard@0x60d0000f7040 (0,300,799,599)
35    dropdown-list@0x608000205420 (0,0,129,129)
36        label@0x60d0000f7ba0 (22,22,56,39)
37    (gdb)
38
39The plugin provides the following commands.
40
41- ``dump obj``: Dump the object tree.
42- ``info style``: Show the object's style.
43
44
45Dump obj tree
46-------------
47
48``dump obj``: Dump the object tree.
49
50``dump obj -L 2``: Dump the object tree with a depth of 2.
51
52``dump obj -a 0x60700000dd10``: Dump the object tree starting from the specified address.
53
54
55Show obj's style
56----------------
57
58This command can dump the object's local style, since style value is a union, it's displayed in all possible formats.
59
60``info style address_of_obj``: Show the object's style.
61
62
63Example:
64
65.. code:: bash
66
67    (gdb) info style 0x60700000dd10
68      32 = {num = 90, ptr = 0x5a, color = {blue = 90 'Z', green = 0 '\000', red = 0 '\000'}}
69      158 = {num = 32767, ptr = 0x7fff, color = {blue = 255 '\377', green = 127 '\177', red = 0 '\000'}}
70    (gdb) p lv_global->disp_default->act_scr
71    $4 = (lv_obj_t *) 0x60700000dd10
72    (gdb) info style $4
73      32 = {num = 90, ptr = 0x5a, color = {blue = 90 'Z', green = 0 '\000', red = 0 '\000'}}
74      158 = {num = 32767, ptr = 0x7fff, color = {blue = 255 '\377', green = 127 '\177', red = 0 '\000'}}
75    (gdb)
76
77Connect to Debugger
78-------------------
79
80This command provides the ability to connect and debug GDB Python Script using IDE.
81
82Connect to ``PyCharm`` / ``VSCode`` / ``Eclipse(not support yet)``
83
84``debugger -t pycharm``
85
86``debugger -t vscode``
87
88``debugger -t eclipse``
89
90How to use it specifically, search ``pydevd_pycharm`` / ``debugpy`` for details.
91