003 File Manager
Current Path:
/usr/src/contrib/llvm-project/compiler-rt/lib/ubsan
usr
/
src
/
contrib
/
llvm-project
/
compiler-rt
/
lib
/
ubsan
/
📁
..
📄
ubsan.syms.extra
(10 B)
📄
ubsan_checks.inc
(3.71 KB)
📄
ubsan_diag.cpp
(14.53 KB)
📄
ubsan_diag.h
(7.57 KB)
📄
ubsan_diag_standalone.cpp
(1.24 KB)
📄
ubsan_flags.cpp
(2.26 KB)
📄
ubsan_flags.h
(1.28 KB)
📄
ubsan_flags.inc
(1.25 KB)
📄
ubsan_handlers.cpp
(32.22 KB)
📄
ubsan_handlers.h
(7.12 KB)
📄
ubsan_handlers_cxx.cpp
(7.2 KB)
📄
ubsan_handlers_cxx.h
(2.1 KB)
📄
ubsan_init.cpp
(1.79 KB)
📄
ubsan_init.h
(1.06 KB)
📄
ubsan_init_standalone.cpp
(977 B)
📄
ubsan_init_standalone_preinit.cpp
(1.04 KB)
📄
ubsan_interface.inc
(3.25 KB)
📄
ubsan_monitor.cpp
(2.67 KB)
📄
ubsan_monitor.h
(1.72 KB)
📄
ubsan_platform.h
(952 B)
📄
ubsan_signals_standalone.cpp
(2.46 KB)
📄
ubsan_signals_standalone.h
(775 B)
📄
ubsan_type_hash.cpp
(1.25 KB)
📄
ubsan_type_hash.h
(2.73 KB)
📄
ubsan_type_hash_itanium.cpp
(9.47 KB)
📄
ubsan_type_hash_win.cpp
(2.82 KB)
📄
ubsan_value.cpp
(5.21 KB)
📄
ubsan_value.h
(6.04 KB)
📄
ubsan_win_dll_thunk.cpp
(1.02 KB)
📄
ubsan_win_dynamic_runtime_thunk.cpp
(952 B)
📄
ubsan_win_weak_interception.cpp
(1.15 KB)
📄
weak_symbols.txt
(25 B)
Editing: ubsan_monitor.cpp
//===-- ubsan_monitor.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 // //===----------------------------------------------------------------------===// // // Hooks which allow a monitor process to inspect UBSan's diagnostics. // //===----------------------------------------------------------------------===// #include "ubsan_monitor.h" using namespace __ubsan; UndefinedBehaviorReport::UndefinedBehaviorReport(const char *IssueKind, Location &Loc, InternalScopedString &Msg) : IssueKind(IssueKind), Loc(Loc), Buffer(Msg.length() + 1) { // We have the common sanitizer reporting lock, so it's safe to register a // new UB report. RegisterUndefinedBehaviorReport(this); // Make a copy of the diagnostic. Buffer.append("%s", Msg.data()); // Let the monitor know that a report is available. __ubsan_on_report(); } static UndefinedBehaviorReport *CurrentUBR; void __ubsan::RegisterUndefinedBehaviorReport(UndefinedBehaviorReport *UBR) { CurrentUBR = UBR; } SANITIZER_WEAK_DEFAULT_IMPL void __ubsan::__ubsan_on_report(void) {} void __ubsan::__ubsan_get_current_report_data(const char **OutIssueKind, const char **OutMessage, const char **OutFilename, unsigned *OutLine, unsigned *OutCol, char **OutMemoryAddr) { if (!OutIssueKind || !OutMessage || !OutFilename || !OutLine || !OutCol || !OutMemoryAddr) UNREACHABLE("Invalid arguments passed to __ubsan_get_current_report_data"); InternalScopedString &Buf = CurrentUBR->Buffer; // Ensure that the first character of the diagnostic text can't start with a // lowercase letter. char FirstChar = Buf.data()[0]; if (FirstChar >= 'a' && FirstChar <= 'z') Buf.data()[0] = FirstChar - 'a' + 'A'; *OutIssueKind = CurrentUBR->IssueKind; *OutMessage = Buf.data(); if (!CurrentUBR->Loc.isSourceLocation()) { *OutFilename = "<unknown>"; *OutLine = *OutCol = 0; } else { SourceLocation SL = CurrentUBR->Loc.getSourceLocation(); *OutFilename = SL.getFilename(); *OutLine = SL.getLine(); *OutCol = SL.getColumn(); } if (CurrentUBR->Loc.isMemoryLocation()) *OutMemoryAddr = (char *)CurrentUBR->Loc.getMemoryLocation(); else *OutMemoryAddr = nullptr; }
Upload File
Create Folder