LLVM 20.0.0git
StringTable.h
Go to the documentation of this file.
1//===- StringTable.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 LLVM_DEBUGINFO_GSYM_STRINGTABLE_H
10#define LLVM_DEBUGINFO_GSYM_STRINGTABLE_H
11
12#include "llvm/ADT/StringRef.h"
14#include <stdint.h>
15
16namespace llvm {
17namespace gsym {
18
19/// String tables in GSYM files are required to start with an empty
20/// string at offset zero. Strings must be UTF8 NULL terminated strings.
23 StringTable() = default;
25 StringRef operator[](size_t Offset) const { return getString(Offset); }
27 if (Offset < Data.size()) {
28 auto End = Data.find('\0', Offset);
29 return Data.substr(Offset, End - Offset);
30 }
31 return StringRef();
32 }
33 void clear() { Data = StringRef(); }
34};
35
37 OS << "String table:\n";
38 uint32_t Offset = 0;
39 const size_t Size = S.Data.size();
40 while (Offset < Size) {
41 StringRef Str = S.getString(Offset);
42 OS << HEX32(Offset) << ": \"" << Str << "\"\n";
43 Offset += Str.size() + 1;
44 }
45 return OS;
46}
47
48} // namespace gsym
49} // namespace llvm
50#endif // LLVM_DEBUGINFO_GSYM_STRINGTABLE_H
static GCRegistry::Add< StatepointGC > D("statepoint-example", "an example strategy for statepoint")
uint64_t Size
bool End
Definition: ELF_riscv.cpp:480
#define HEX32(v)
Definition: ExtractRanges.h:19
raw_pwrite_stream & OS
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:51
constexpr StringRef substr(size_t Start, size_t N=npos) const
Return a reference to the substring from [Start, Start + N).
Definition: StringRef.h:571
constexpr size_t size() const
size - Get the string size.
Definition: StringRef.h:150
size_t find(char C, size_t From=0) const
Search for the first character C in the string.
Definition: StringRef.h:297
This class implements an extremely fast bulk output stream that can only output to a stream.
Definition: raw_ostream.h:52
raw_ostream & operator<<(raw_ostream &OS, const CallSiteInfo &CSI)
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
@ Offset
Definition: DWP.cpp:480
String tables in GSYM files are required to start with an empty string at offset zero.
Definition: StringTable.h:21
StringTable(StringRef D)
Definition: StringTable.h:24
StringRef operator[](size_t Offset) const
Definition: StringTable.h:25
StringRef getString(uint32_t Offset) const
Definition: StringTable.h:26