xref: /llvm-project/lldb/examples/summaries/cocoa/Class.py (revision 2238dcc39358353cac21df75c3c3286ab20b8f53)
1"""
2LLDB AppKit formatters
3
4Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
5See https://llvm.org/LICENSE.txt for license information.
6SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7"""
8import lldb
9import lldb.runtime.objc.objc_runtime
10import lldb.formatters.Logger
11
12
13def Class_Summary(valobj, dict):
14    logger = lldb.formatters.Logger.Logger()
15    runtime = lldb.runtime.objc.objc_runtime.ObjCRuntime.runtime_from_isa(valobj)
16    if runtime is None or not runtime.is_valid():
17        return "<error: unknown Class>"
18    class_data = runtime.read_class_data()
19    if class_data is None or not class_data.is_valid():
20        return "<error: unknown Class>"
21    return class_data.class_name()
22