DebugLocStream.cpp 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. //===- DebugLocStream.cpp - DWARF debug_loc stream --------------*- C++ -*-===//
  2. //
  3. // The LLVM Compiler Infrastructure
  4. //
  5. // This file is distributed under the University of Illinois Open Source
  6. // License. See LICENSE.TXT for details.
  7. //
  8. //===----------------------------------------------------------------------===//
  9. #include "DebugLocStream.h"
  10. #include "DwarfDebug.h"
  11. #include "llvm/CodeGen/AsmPrinter.h"
  12. using namespace llvm;
  13. bool DebugLocStream::finalizeList(AsmPrinter &Asm) {
  14. if (Lists.back().EntryOffset == Entries.size()) {
  15. // Empty list. Delete it.
  16. Lists.pop_back();
  17. return false;
  18. }
  19. // Real list. Generate a label for it.
  20. Lists.back().Label = Asm.createTempSymbol("debug_loc");
  21. return true;
  22. }
  23. void DebugLocStream::finalizeEntry() {
  24. if (Entries.back().ByteOffset != DWARFBytes.size())
  25. return;
  26. // The last entry was empty. Delete it.
  27. Comments.erase(Comments.begin() + Entries.back().CommentOffset,
  28. Comments.end());
  29. Entries.pop_back();
  30. assert(Lists.back().EntryOffset <= Entries.size() &&
  31. "Popped off more entries than are in the list");
  32. }
  33. DebugLocStream::ListBuilder::~ListBuilder() {
  34. if (!Locs.finalizeList(Asm))
  35. return;
  36. V.initializeDbgValue(&MI);
  37. V.setDebugLocListIndex(ListIndex);
  38. }