Files
RedBear-OS/local/recipes/dev/libclc/source/lldb/tools/lldb-dap/DAPLog.h
T
vasilito cb424d7448 build: static patch-sanity linter (shift-left the malformed-patch class)
verify-patch-sanity.py validates every active recipe .patch has internally-
consistent hunk line counts — catching the 'malformed patch at line N' failure
at commit/CI/preflight time instead of hours into a cook. This cycle hit that
class three times (qtwaylandscanner, sddm, xwayland), each only discovered when
cookbook tried to apply the patch.

Running it across the repo found 29 latent malformed patches (validated against
GNU patch: e.g. relibc/P3-sysv-ipc reproduces 'malformed patch at line 22').
They were harmless only because they sit in vendored recipes (baked, not re-
applied) — but would fail on any version-bump re-derivation. --fix recounts the
hunk headers (body untouched) and repaired all 29.

Wired into build-preflight.sh (Phase 1.0D) and redbear-ci.yml, with a unit test
(test-patch-sanity.sh). Skips archived/legacy trees and unvalidatable formats
(empty placeholders, bare-@@ git hunks).
2026-08-01 05:13:02 +03:00

68 lines
2.7 KiB
C++

//===-- DAPLog.h ----------------------------------------------------------===//
//
// 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
//
//===----------------------------------------------------------------------===//
#ifndef LLDB_TOOLS_LLDB_DAP_DAPLOG_H
#define LLDB_TOOLS_LLDB_DAP_DAPLOG_H
#include "llvm/ADT/StringRef.h"
#include "llvm/Support/Error.h"
#include "llvm/Support/FormatAdapters.h"
#include "llvm/Support/FormatVariadic.h"
#include "llvm/Support/raw_ostream.h"
#include <mutex>
#include <string>
#include <system_error>
// Write a message to log, if logging is enabled.
#define DAP_LOG(log, ...) \
do { \
::lldb_dap::Log *log_private = (log); \
if (log_private) { \
log_private->WriteMessage(::llvm::formatv(__VA_ARGS__).str()); \
} \
} while (0)
// Write message to log, if error is set. In the log message refer to the error
// with {0}. Error is cleared regardless of whether logging is enabled.
#define DAP_LOG_ERROR(log, error, ...) \
do { \
::lldb_dap::Log *log_private = (log); \
::llvm::Error error_private = (error); \
if (log_private && error_private) { \
log_private->WriteMessage( \
::lldb_dap::FormatError(::std::move(error_private), __VA_ARGS__)); \
} else \
::llvm::consumeError(::std::move(error_private)); \
} while (0)
namespace lldb_dap {
/// Log manages the lldb-dap log file, used with the corresponding `DAP_LOG` and
/// `DAP_LOG_ERROR` helpers.
class Log final {
public:
/// Creates a log file with the given filename.
Log(llvm::StringRef filename, std::error_code &EC);
void WriteMessage(llvm::StringRef message);
private:
std::mutex m_mutex;
llvm::raw_fd_ostream m_stream;
};
template <typename... Args>
inline auto FormatError(llvm::Error error, const char *format, Args &&...args) {
return llvm::formatv(format, llvm::toString(std::move(error)),
std::forward<Args>(args)...)
.str();
}
} // namespace lldb_dap
#endif