chore(gdb): add LVImageDecoder complete fields and dump image_decoder command

This commit is contained in:
Benign X
2026-03-06 03:07:09 +08:00
committed by VIFEX
parent 64c46e8c1b
commit b93ef79422
8 changed files with 94 additions and 0 deletions

View File

@@ -36,6 +36,7 @@ from .lvgl import (
EVENT_CODE_NAMES,
LVAnim,
LVTimer,
LVImageDecoder,
LVFsDrv,
)
from . import cmds as cmds
@@ -76,5 +77,6 @@ __all__ = [
"EVENT_CODE_NAMES",
"LVAnim",
"LVTimer",
"LVImageDecoder",
"LVFsDrv",
]

View File

@@ -10,6 +10,7 @@ from .misc import (
CheckCache,
DumpAnim,
DumpTimer,
DumpImageDecoder,
DumpFsDrv,
)
from .debugger import Debugger
@@ -35,6 +36,7 @@ CheckPrefix()
CheckCache()
DumpAnim()
DumpTimer()
DumpImageDecoder()
DumpFsDrv()
DumpDrawTask()

View File

@@ -2,6 +2,7 @@ from .lv_style import InfoStyle
from .lv_cache import DumpCache, CheckPrefix, CheckCache
from .lv_anim import DumpAnim
from .lv_timer import DumpTimer
from .lv_image_decoder import DumpImageDecoder
from .lv_fs import DumpFsDrv
__all__ = [
@@ -11,5 +12,6 @@ __all__ = [
"CheckCache",
"DumpAnim",
"DumpTimer",
"DumpImageDecoder",
"DumpFsDrv",
]

View File

@@ -0,0 +1,16 @@
import gdb
from lvglgdb.lvgl import curr_inst
from lvglgdb.lvgl.misc.lv_image_decoder import LVImageDecoder
class DumpImageDecoder(gdb.Command):
"""dump all registered image decoders"""
def __init__(self):
super(DumpImageDecoder, self).__init__(
"dump image_decoder", gdb.COMMAND_USER, gdb.COMPLETE_EXPRESSION
)
def invoke(self, args, from_tty):
LVImageDecoder.print_entries(curr_inst().image_decoders())

View File

@@ -37,6 +37,7 @@ from .misc import (
EVENT_CODE_NAMES,
LVAnim,
LVTimer,
LVImageDecoder,
LVFsDrv,
)
@@ -81,5 +82,6 @@ __all__ = [
"EVENT_CODE_NAMES",
"LVAnim",
"LVTimer",
"LVImageDecoder",
"LVFsDrv",
]

View File

@@ -73,6 +73,12 @@ class LVGL:
for timer in LVList(self.lv_global.timer_state.timer_ll, "lv_timer_t"):
yield LVTimer(timer)
def image_decoders(self):
from ..misc.lv_image_decoder import LVImageDecoder
for dec in LVList(self.lv_global.img_decoder_ll, "lv_image_decoder_t"):
yield LVImageDecoder(dec)
def fs_drivers(self):
from ..misc.lv_fs import LVFsDrv

View File

@@ -25,6 +25,7 @@ from .lv_event import (
)
from .lv_anim import LVAnim
from .lv_timer import LVTimer
from .lv_image_decoder import LVImageDecoder
from .lv_fs import LVFsDrv
__all__ = [
@@ -56,5 +57,6 @@ __all__ = [
"EVENT_CODE_NAMES",
"LVAnim",
"LVTimer",
"LVImageDecoder",
"LVFsDrv",
]

View File

@@ -0,0 +1,62 @@
from prettytable import PrettyTable
from lvglgdb.value import Value, ValueInput
class LVImageDecoder(Value):
"""LVGL image decoder wrapper"""
def __init__(self, decoder: ValueInput):
super().__init__(Value.normalize(decoder, "lv_image_decoder_t"))
@property
def name(self) -> str:
n = self.super_value("name")
return n.string() if int(n) else "(unnamed)"
@property
def info_cb(self) -> Value:
return self.super_value("info_cb")
@property
def open_cb(self) -> Value:
return self.super_value("open_cb")
@property
def close_cb(self) -> Value:
return self.super_value("close_cb")
@property
def get_area_cb(self) -> Value:
return self.super_value("get_area_cb")
@property
def custom_draw_cb(self) -> Value:
return self.super_value("custom_draw_cb")
@property
def user_data(self) -> Value:
return self.super_value("user_data")
@staticmethod
def print_entries(decoders):
"""Print image decoders as a PrettyTable."""
table = PrettyTable()
table.field_names = ["#", "name", "info_cb", "open_cb", "close_cb"]
table.align = "l"
for i, dec in enumerate(decoders):
table.add_row(
[
i,
dec.name,
dec.info_cb.format_string(symbols=True),
dec.open_cb.format_string(symbols=True),
dec.close_cb.format_string(symbols=True),
]
)
if not table.rows:
print("No registered image decoders.")
else:
print(table)