report_linux.cpp 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. //===-- report_linux.cpp ----------------------------------------*- 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. #include "platform.h"
  9. #if SCUDO_LINUX || SCUDO_TRUSTY
  10. #include "common.h"
  11. #include "internal_defs.h"
  12. #include "report.h"
  13. #include "report_linux.h"
  14. #include "string_utils.h"
  15. #include <errno.h>
  16. #include <stdlib.h>
  17. #include <string.h>
  18. namespace scudo {
  19. // Fatal internal map() error (potentially OOM related).
  20. void NORETURN reportMapError(uptr SizeIfOOM) {
  21. char Error[128] = "Scudo ERROR: internal map failure\n";
  22. if (SizeIfOOM) {
  23. formatString(
  24. Error, sizeof(Error),
  25. "Scudo ERROR: internal map failure (NO MEMORY) requesting %zuKB\n",
  26. SizeIfOOM >> 10);
  27. }
  28. reportRawError(Error);
  29. }
  30. void NORETURN reportUnmapError(uptr Addr, uptr Size) {
  31. char Error[128];
  32. formatString(Error, sizeof(Error),
  33. "Scudo ERROR: internal unmap failure (error desc=%s) Addr 0x%zx "
  34. "Size %zu\n",
  35. strerror(errno), Addr, Size);
  36. reportRawError(Error);
  37. }
  38. void NORETURN reportProtectError(uptr Addr, uptr Size, int Prot) {
  39. char Error[128];
  40. formatString(
  41. Error, sizeof(Error),
  42. "Scudo ERROR: internal protect failure (error desc=%s) Addr 0x%zx "
  43. "Size %zu Prot %x\n",
  44. strerror(errno), Addr, Size, Prot);
  45. reportRawError(Error);
  46. }
  47. } // namespace scudo
  48. #endif // SCUDO_LINUX || SCUDO_TRUSTY