LLDB mainline
Utils.h
Go to the documentation of this file.
1//===-- Utils.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_SOURCE_API_UTILS_H
10#define LLDB_SOURCE_API_UTILS_H
11
12#include "lldb/Core/Debugger.h"
13#include "lldb/Target/Target.h"
15#include "llvm/ADT/STLExtras.h"
16#include <memory>
17
18namespace lldb_private {
19
20/// Strings interned here live as long as \p target's debugger.
22 return target.GetDebugger().GetStringPool();
23}
24
25template <typename T> std::unique_ptr<T> clone(const std::unique_ptr<T> &src) {
26 if (src)
27 return std::make_unique<T>(*src);
28 return nullptr;
29}
30
31template <typename T> std::shared_ptr<T> clone(const std::shared_ptr<T> &src) {
32 if (src)
33 return std::make_shared<T>(*src);
34 return nullptr;
35}
36
37} // namespace lldb_private
38#endif
StringPoolRef GetStringPool() const
The pool for strings handed out through the SB API that belong to this debugger.
Definition Debugger.h:435
A handle to a StringPool that does not own it.
Definition StringPool.h:72
Debugger & GetDebugger() const
Definition Target.h:1378
A class that represents a running process on the host machine.
std::unique_ptr< T > clone(const std::unique_ptr< T > &src)
Definition Utils.h:25
StringPoolRef GetDebuggerStringPool(const Target &target)
Strings interned here live as long as target's debugger.
Definition Utils.h:21