[llvm] Make GSYM 64 bit safe and add a new version 2 of the GSYM files. (PR #189119)
Greg Clayton via llvm-commits
llvm-commits at lists.llvm.org
Fri Mar 27 15:50:51 PDT 2026
================
@@ -0,0 +1,130 @@
+//===- HeaderV2.cpp ---------------------------------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "llvm/DebugInfo/GSYM/HeaderV2.h"
+#include "llvm/DebugInfo/GSYM/FileWriter.h"
+#include "llvm/Support/DataExtractor.h"
+#include "llvm/Support/Format.h"
+#include "llvm/Support/raw_ostream.h"
+
+#define HEX8(v) llvm::format_hex(v, 4)
+#define HEX16(v) llvm::format_hex(v, 6)
+#define HEX32(v) llvm::format_hex(v, 10)
+#define HEX64(v) llvm::format_hex(v, 18)
+
+using namespace llvm;
+using namespace gsym;
+
+raw_ostream &llvm::gsym::operator<<(raw_ostream &OS, const HeaderV2 &H) {
+ OS << "HeaderV2:\n";
+ OS << " Magic = " << HEX32(H.Magic) << "\n";
+ OS << " Version = " << HEX16(H.Version) << '\n';
+ OS << " BaseAddress = " << HEX64(H.BaseAddress) << '\n';
+ OS << " NumAddresses = " << HEX32(H.NumAddresses) << '\n';
+ OS << " AddrOffSize = " << HEX8(H.AddrOffSize) << '\n';
+ OS << " AddrInfoOffSize = " << HEX8(H.AddrInfoOffSize) << '\n';
+ OS << " StrpSize = " << HEX8(H.StrpSize) << '\n';
+ return OS;
+}
+
+llvm::Error HeaderV2::checkForError() const {
+ if (Magic != GSYM_MAGIC)
+ return createStringError(std::errc::invalid_argument,
+ "invalid GSYM magic 0x%8.8x", Magic);
+ if (Version != GSYM_VERSION_2)
+ return createStringError(std::errc::invalid_argument,
+ "unsupported GSYM version %u", Version);
+ switch (AddrOffSize) {
+ case 1:
+ case 2:
+ case 4:
+ case 8:
+ break;
+ default:
+ return createStringError(std::errc::invalid_argument,
+ "invalid address offset size %u", AddrOffSize);
+ }
+ switch (AddrInfoOffSize) {
+ case 4:
+ case 8:
----------------
clayborg wrote:
accept any value 1-8
https://github.com/llvm/llvm-project/pull/189119
More information about the llvm-commits
mailing list