blob: 235123a31ceeaf93b7189b759e78b8dadb823664 [file] [log] [blame]
Raphael Isemann80814282020-01-24 08:23:27 +01001//===-- DataBufferLLVM.cpp ------------------------------------------------===//
Zachary Turner3f4a4b32017-02-24 18:56:49 +00002//
Chandler Carruth2946cd72019-01-19 08:50:56 +00003// 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
Zachary Turner3f4a4b32017-02-24 18:56:49 +00006//
7//===----------------------------------------------------------------------===//
8
Zachary Turner666cc0b2017-03-04 01:30:05 +00009#include "lldb/Utility/DataBufferLLVM.h"
Zachary Turner3f4a4b32017-02-24 18:56:49 +000010
Zachary Turner3f4a4b32017-02-24 18:56:49 +000011#include "llvm/Support/MemoryBuffer.h"
12
Jonas Devlieghere672d2c12018-11-11 23:16:43 +000013#include <assert.h>
Zachary Turner4479ac12017-04-06 18:12:24 +000014
Zachary Turner3f4a4b32017-02-24 18:56:49 +000015using namespace lldb_private;
16
Pavel Labath50251fc2017-12-21 10:54:30 +000017DataBufferLLVM::DataBufferLLVM(
18 std::unique_ptr<llvm::WritableMemoryBuffer> MemBuffer)
Zachary Turner3f4a4b32017-02-24 18:56:49 +000019 : Buffer(std::move(MemBuffer)) {
20 assert(Buffer != nullptr &&
21 "Cannot construct a DataBufferLLVM with a null buffer");
22}
23
24DataBufferLLVM::~DataBufferLLVM() {}
25
Zachary Turner3f4a4b32017-02-24 18:56:49 +000026uint8_t *DataBufferLLVM::GetBytes() {
Pavel Labath50251fc2017-12-21 10:54:30 +000027 return reinterpret_cast<uint8_t *>(Buffer->getBufferStart());
Zachary Turner3f4a4b32017-02-24 18:56:49 +000028}
29
Pavel Labath50251fc2017-12-21 10:54:30 +000030const uint8_t *DataBufferLLVM::GetBytes() const {
31 return reinterpret_cast<const uint8_t *>(Buffer->getBufferStart());
32}
Zachary Turner3f4a4b32017-02-24 18:56:49 +000033
34lldb::offset_t DataBufferLLVM::GetByteSize() const {
35 return Buffer->getBufferSize();
36}