Coverage Report

Created: 2022-01-18 06:27

/Users/buildslave/jenkins/workspace/coverage/llvm-project/lldb/include/lldb/Interpreter/ScriptedInterface.h
Line
Count
Source (jump to first uncovered line)
1
//===-- ScriptedInterface.h -------------------------------------*- C++ -*-===//
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
#ifndef LLDB_INTERPRETER_SCRIPTEDINTERFACE_H
10
#define LLDB_INTERPRETER_SCRIPTEDINTERFACE_H
11
12
#include "lldb/Core/StructuredDataImpl.h"
13
#include "lldb/Target/ExecutionContext.h"
14
#include "lldb/Utility/Log.h"
15
#include "lldb/Utility/Logging.h"
16
#include "lldb/lldb-private.h"
17
18
#include "llvm/Support/Compiler.h"
19
20
#include <string>
21
22
namespace lldb_private {
23
class ScriptedInterface {
24
public:
25
2.87k
  ScriptedInterface() = default;
26
2.87k
  virtual ~ScriptedInterface() = default;
27
28
  virtual StructuredData::GenericSP
29
  CreatePluginObject(llvm::StringRef class_name, ExecutionContext &exe_ctx,
30
                     StructuredData::DictionarySP args_sp) = 0;
31
32
  template <typename Ret>
33
  Ret ErrorWithMessage(llvm::StringRef caller_name, llvm::StringRef error_msg,
34
                       Status &error,
35
150
                       uint32_t log_caterogy = LIBLLDB_LOG_PROCESS) {
36
150
    LLDB_LOGF(GetLogIfAllCategoriesSet(log_caterogy), "%s ERROR = %s",
37
150
              caller_name.data(), error_msg.data());
38
150
    error.SetErrorString(llvm::Twine(caller_name + llvm::Twine(" ERROR = ") +
39
150
                                     llvm::Twine(error_msg))
40
150
                             .str());
41
150
    return {};
42
150
  }
Unexecuted instantiation: unsigned long lldb_private::ScriptedInterface::ErrorWithMessage<unsigned long>(llvm::StringRef, llvm::StringRef, lldb_private::Status&, unsigned int)
bool lldb_private::ScriptedInterface::ErrorWithMessage<bool>(llvm::StringRef, llvm::StringRef, lldb_private::Status&, unsigned int)
Line
Count
Source
35
72
                       uint32_t log_caterogy = LIBLLDB_LOG_PROCESS) {
36
72
    LLDB_LOGF(GetLogIfAllCategoriesSet(log_caterogy), "%s ERROR = %s",
37
72
              caller_name.data(), error_msg.data());
38
72
    error.SetErrorString(llvm::Twine(caller_name + llvm::Twine(" ERROR = ") +
39
72
                                     llvm::Twine(error_msg))
40
72
                             .str());
41
72
    return {};
42
72
  }
std::__1::shared_ptr<lldb_private::RegisterContext> lldb_private::ScriptedInterface::ErrorWithMessage<std::__1::shared_ptr<lldb_private::RegisterContext> >(llvm::StringRef, llvm::StringRef, lldb_private::Status&, unsigned int)
Line
Count
Source
35
36
                       uint32_t log_caterogy = LIBLLDB_LOG_PROCESS) {
36
36
    LLDB_LOGF(GetLogIfAllCategoriesSet(log_caterogy), "%s ERROR = %s",
37
36
              caller_name.data(), error_msg.data());
38
36
    error.SetErrorString(llvm::Twine(caller_name + llvm::Twine(" ERROR = ") +
39
36
                                     llvm::Twine(error_msg))
40
36
                             .str());
41
36
    return {};
42
36
  }
Unexecuted instantiation: std::__1::shared_ptr<lldb_private::DynamicRegisterInfo> lldb_private::ScriptedInterface::ErrorWithMessage<std::__1::shared_ptr<lldb_private::DynamicRegisterInfo> >(llvm::StringRef, llvm::StringRef, lldb_private::Status&, unsigned int)
Unexecuted instantiation: lldb_private::Status lldb_private::ScriptedInterface::ErrorWithMessage<lldb_private::Status>(llvm::StringRef, llvm::StringRef, lldb_private::Status&, unsigned int)
std::__1::shared_ptr<lldb_private::StructuredData::Object> lldb_private::ScriptedInterface::ErrorWithMessage<std::__1::shared_ptr<lldb_private::StructuredData::Object> >(llvm::StringRef, llvm::StringRef, lldb_private::Status&, unsigned int)
Line
Count
Source
35
36
                       uint32_t log_caterogy = LIBLLDB_LOG_PROCESS) {
36
36
    LLDB_LOGF(GetLogIfAllCategoriesSet(log_caterogy), "%s ERROR = %s",
37
36
              caller_name.data(), error_msg.data());
38
36
    error.SetErrorString(llvm::Twine(caller_name + llvm::Twine(" ERROR = ") +
39
36
                                     llvm::Twine(error_msg))
40
36
                             .str());
41
36
    return {};
42
36
  }
llvm::Optional<lldb_private::MemoryRegionInfo> lldb_private::ScriptedInterface::ErrorWithMessage<llvm::Optional<lldb_private::MemoryRegionInfo> >(llvm::StringRef, llvm::StringRef, lldb_private::Status&, unsigned int)
Line
Count
Source
35
3
                       uint32_t log_caterogy = LIBLLDB_LOG_PROCESS) {
36
3
    LLDB_LOGF(GetLogIfAllCategoriesSet(log_caterogy), "%s ERROR = %s",
37
3
              caller_name.data(), error_msg.data());
38
3
    error.SetErrorString(llvm::Twine(caller_name + llvm::Twine(" ERROR = ") +
39
3
                                     llvm::Twine(error_msg))
40
3
                             .str());
41
3
    return {};
42
3
  }
lldb_private::MemoryRegionInfo lldb_private::ScriptedInterface::ErrorWithMessage<lldb_private::MemoryRegionInfo>(llvm::StringRef, llvm::StringRef, lldb_private::Status&, unsigned int)
Line
Count
Source
35
3
                       uint32_t log_caterogy = LIBLLDB_LOG_PROCESS) {
36
3
    LLDB_LOGF(GetLogIfAllCategoriesSet(log_caterogy), "%s ERROR = %s",
37
3
              caller_name.data(), error_msg.data());
38
3
    error.SetErrorString(llvm::Twine(caller_name + llvm::Twine(" ERROR = ") +
39
3
                                     llvm::Twine(error_msg))
40
3
                             .str());
41
3
    return {};
42
3
  }
Unexecuted instantiation: std::__1::shared_ptr<lldb_private::DataExtractor> lldb_private::ScriptedInterface::ErrorWithMessage<std::__1::shared_ptr<lldb_private::DataExtractor> >(llvm::StringRef, llvm::StringRef, lldb_private::Status&, unsigned int)
Unexecuted instantiation: std::__1::shared_ptr<lldb_private::StructuredData::Dictionary> lldb_private::ScriptedInterface::ErrorWithMessage<std::__1::shared_ptr<lldb_private::StructuredData::Dictionary> >(llvm::StringRef, llvm::StringRef, lldb_private::Status&, unsigned int)
43
44
  template <typename T = StructuredData::ObjectSP>
45
159
  bool CheckStructuredDataObject(llvm::StringRef caller, T obj, Status &error) {
46
159
    if (!obj) {
47
36
      return ErrorWithMessage<bool>(caller,
48
36
                                    llvm::Twine("Null StructuredData object (" +
49
36
                                                llvm::Twine(error.AsCString()) +
50
36
                                                llvm::Twine(")."))
51
36
                                        .str(),
52
36
                                    error);
53
36
    }
54
55
123
    if (!obj->IsValid()) {
56
0
      return ErrorWithMessage<bool>(
57
0
          caller,
58
0
          llvm::Twine("Invalid StructuredData object (" +
59
0
                      llvm::Twine(error.AsCString()) + llvm::Twine(")."))
60
0
              .str(),
61
0
          error);
62
0
    }
63
64
123
    if (error.Fail())
65
0
      return ErrorWithMessage<bool>(caller, error.AsCString(), error);
66
67
123
    return true;
68
123
  }
bool lldb_private::ScriptedInterface::CheckStructuredDataObject<std::__1::shared_ptr<lldb_private::StructuredData::Object> >(llvm::StringRef, std::__1::shared_ptr<lldb_private::StructuredData::Object>, lldb_private::Status&)
Line
Count
Source
45
147
  bool CheckStructuredDataObject(llvm::StringRef caller, T obj, Status &error) {
46
147
    if (!obj) {
47
36
      return ErrorWithMessage<bool>(caller,
48
36
                                    llvm::Twine("Null StructuredData object (" +
49
36
                                                llvm::Twine(error.AsCString()) +
50
36
                                                llvm::Twine(")."))
51
36
                                        .str(),
52
36
                                    error);
53
36
    }
54
55
111
    if (!obj->IsValid()) {
56
0
      return ErrorWithMessage<bool>(
57
0
          caller,
58
0
          llvm::Twine("Invalid StructuredData object (" +
59
0
                      llvm::Twine(error.AsCString()) + llvm::Twine(")."))
60
0
              .str(),
61
0
          error);
62
0
    }
63
64
111
    if (error.Fail())
65
0
      return ErrorWithMessage<bool>(caller, error.AsCString(), error);
66
67
111
    return true;
68
111
  }
bool lldb_private::ScriptedInterface::CheckStructuredDataObject<std::__1::shared_ptr<lldb_private::StructuredData::Dictionary> >(llvm::StringRef, std::__1::shared_ptr<lldb_private::StructuredData::Dictionary>, lldb_private::Status&)
Line
Count
Source
45
12
  bool CheckStructuredDataObject(llvm::StringRef caller, T obj, Status &error) {
46
12
    if (!obj) {
47
0
      return ErrorWithMessage<bool>(caller,
48
0
                                    llvm::Twine("Null StructuredData object (" +
49
0
                                                llvm::Twine(error.AsCString()) +
50
0
                                                llvm::Twine(")."))
51
0
                                        .str(),
52
0
                                    error);
53
0
    }
54
55
12
    if (!obj->IsValid()) {
56
0
      return ErrorWithMessage<bool>(
57
0
          caller,
58
0
          llvm::Twine("Invalid StructuredData object (" +
59
0
                      llvm::Twine(error.AsCString()) + llvm::Twine(")."))
60
0
              .str(),
61
0
          error);
62
0
    }
63
64
12
    if (error.Fail())
65
0
      return ErrorWithMessage<bool>(caller, error.AsCString(), error);
66
67
12
    return true;
68
12
  }
69
70
protected:
71
  StructuredData::GenericSP m_object_instance_sp;
72
};
73
} // namespace lldb_private
74
#endif // LLDB_INTERPRETER_SCRIPTEDINTERFACE_H