LLDB mainline
ScriptedStringSummaryPythonInterface.cpp
Go to the documentation of this file.
1//===----------------------------------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#include "../lldb-python.h"
10
15
18
19using namespace lldb;
20using namespace lldb_private;
21
25
26llvm::Expected<StructuredData::GenericSP>
28 llvm::StringRef class_name) {
29 if (class_name.empty())
30 return llvm::createStringError("empty class name");
31
33 ScriptedMetadata(class_name, nullptr), nullptr);
34}
35
37 ValueObject &valobj, const TypeSummaryOptions &options) {
40 Dispatch("get_summary", error, valobj.GetSP(), options);
41 if (!ScriptedInterface::CheckStructuredDataObject(LLVM_PRETTY_FUNCTION, obj,
42 error))
43 return error.ToError();
44 return obj->GetStringValue().str();
45}
46
48 const std::vector<llvm::StringRef> ci_usages = {
49 "type summary add -L <ClassName> [-K <key> -V <value> ...] <TypeName>"};
50 const std::vector<llvm::StringRef> api_usages = {
51 "SBTypeSummary.CreateWithClassName"};
54 "Provide a summary string for a type, used by 'type summary add -l'",
56 eScriptLanguagePython, {ci_usages, api_usages});
57}
58
static llvm::raw_ostream & error(Stream &strm)
static bool RegisterPlugin(llvm::StringRef name, llvm::StringRef description, ABICreateInstance create_callback)
static bool UnregisterPlugin(ABICreateInstance create_callback)
static bool CheckStructuredDataObject(llvm::StringRef caller, T obj, Status &error)
static bool CreateInstance(lldb::ScriptLanguage language, ScriptedInterfaceUsages usages)
ScriptedPythonInterface(ScriptInterpreterPythonImpl &interpreter)
T Dispatch(llvm::StringRef method_name, Status &error, Args &&...args)
llvm::Expected< StructuredData::GenericSP > CreatePluginObject(const ScriptedMetadata &scripted_metadata, StructuredData::Generic *script_obj, Args... args)
llvm::Expected< StructuredData::GenericSP > CreatePluginObject(llvm::StringRef class_name) override
llvm::Expected< std::string > GetSummary(ValueObject &valobj, const TypeSummaryOptions &options) override
ScriptedStringSummaryPythonInterface(ScriptInterpreterPythonImpl &interpreter)
An error handling class.
Definition Status.h:118
std::shared_ptr< Object > ObjectSP
lldb::ValueObjectSP GetSP()
A class that represents a running process on the host machine.
@ eScriptLanguagePython
@ eScriptedExtensionScriptedStringSummary