DebugLocStream.cpp 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. //===- DebugLocStream.cpp - DWARF debug_loc stream --------------*- 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 "DebugLocStream.h"
  9. #include "DwarfDebug.h"
  10. #include "llvm/CodeGen/AsmPrinter.h"
  11. using namespace llvm;
  12. bool DebugLocStream::finalizeList(AsmPrinter &Asm) {
  13. if (Lists.back().EntryOffset == Entries.size()) {
  14. // Empty list. Delete it.
  15. Lists.pop_back();
  16. return false;
  17. }
  18. // Real list. Generate a label for it.
  19. Lists.back().Label = Asm.createTempSymbol("debug_loc");
  20. return true;
  21. }
  22. void DebugLocStream::finalizeEntry() {
  23. if (Entries.back().ByteOffset != DWARFBytes.size())
  24. return;
  25. // The last entry was empty. Delete it.
  26. Comments.erase(Comments.begin() + Entries.back().CommentOffset,
  27. Comments.end());
  28. Entries.pop_back();
  29. assert(Lists.back().EntryOffset <= Entries.size() &&
  30. "Popped off more entries than are in the list");
  31. }
  32. DebugLocStream::ListBuilder::~ListBuilder() {
  33. if (!Locs.finalizeList(Asm))
  34. return;
  35. V.initializeDbgValue(&MI);
  36. V.setDebugLocListIndex(ListIndex);
  37. if (TagOffset)
  38. V.setDebugLocListTagOffset(*TagOffset);
  39. }