DxilDiaTableLineNumbers.h 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. ///////////////////////////////////////////////////////////////////////////////
  2. // //
  3. // DxilDiaTableLineNumbers.h //
  4. // Copyright (C) Microsoft Corporation. All rights reserved. //
  5. // This file is distributed under the University of Illinois Open Source //
  6. // License. See LICENSE.TXT for details. //
  7. // //
  8. // DIA API implementation for DXIL modules. //
  9. // //
  10. ///////////////////////////////////////////////////////////////////////////////
  11. #pragma once
  12. #include "dxc/Support/WinIncludes.h"
  13. #include <vector>
  14. #include "dia2.h"
  15. #include "llvm/IR/DebugLoc.h"
  16. #include "llvm/IR/Instruction.h"
  17. #include "dxc/Support/Global.h"
  18. #include "dxc/Support/microcom.h"
  19. #include "DxilDia.h"
  20. #include "DxilDiaTable.h"
  21. namespace dxil_dia {
  22. class Session;
  23. class LineNumber : public IDiaLineNumber {
  24. private:
  25. DXC_MICROCOM_TM_REF_FIELDS()
  26. CComPtr<Session> m_pSession;
  27. const llvm::Instruction *m_inst;
  28. public:
  29. DXC_MICROCOM_TM_ADDREF_RELEASE_IMPL()
  30. STDMETHODIMP QueryInterface(REFIID iid, void **ppvObject) {
  31. return DoBasicQueryInterface<IDiaLineNumber>(this, iid, ppvObject);
  32. }
  33. LineNumber(
  34. /* [in] */ IMalloc *pMalloc,
  35. /* [in] */ Session *pSession,
  36. /* [in] */ const llvm::Instruction * inst);
  37. const llvm::DebugLoc &DL() const;
  38. const llvm::Instruction *Inst() const { return m_inst; }
  39. STDMETHODIMP get_compiland(
  40. /* [retval][out] */ IDiaSymbol **pRetVal) override { return ENotImpl(); }
  41. STDMETHODIMP get_sourceFile(
  42. /* [retval][out] */ IDiaSourceFile **pRetVal) override;
  43. STDMETHODIMP get_lineNumber(
  44. /* [retval][out] */ DWORD *pRetVal) override;
  45. STDMETHODIMP get_lineNumberEnd(
  46. /* [retval][out] */ DWORD *pRetVal) override;
  47. STDMETHODIMP get_columnNumber(
  48. /* [retval][out] */ DWORD *pRetVal) override;
  49. STDMETHODIMP get_columnNumberEnd(
  50. /* [retval][out] */ DWORD *pRetVal) override;
  51. STDMETHODIMP get_addressSection(
  52. /* [retval][out] */ DWORD *pRetVal) override { return ENotImpl(); }
  53. STDMETHODIMP get_addressOffset(
  54. /* [retval][out] */ DWORD *pRetVal) override;
  55. STDMETHODIMP get_relativeVirtualAddress(
  56. /* [retval][out] */ DWORD *pRetVal) override;
  57. STDMETHODIMP get_virtualAddress(
  58. /* [retval][out] */ ULONGLONG *pRetVal) override { return ENotImpl(); }
  59. STDMETHODIMP get_length(
  60. /* [retval][out] */ DWORD *pRetVal) override;
  61. STDMETHODIMP get_sourceFileId(
  62. /* [retval][out] */ DWORD *pRetVal) override;
  63. STDMETHODIMP get_statement(
  64. /* [retval][out] */ BOOL *pRetVal) override;
  65. STDMETHODIMP get_compilandId(
  66. /* [retval][out] */ DWORD *pRetVal) override;
  67. };
  68. class LineNumbersTable : public impl::TableBase<IDiaEnumLineNumbers, IDiaLineNumber> {
  69. public:
  70. LineNumbersTable(
  71. /* [in] */ IMalloc *pMalloc,
  72. /* [in] */ Session *pSession);
  73. LineNumbersTable(
  74. /* [in] */ IMalloc *pMalloc,
  75. /* [in] */ Session *pSession,
  76. /* [in] */ std::vector<const llvm::Instruction*> &&instructions);
  77. HRESULT GetItem(
  78. /* [in] */ DWORD index,
  79. /* [out] */ IDiaLineNumber **ppItem) override;
  80. private:
  81. // Keep a reference to the instructions that contain the line numbers.
  82. const std::vector<const llvm::Instruction *> &m_instructions;
  83. // Provide storage space for instructions for when the table contains
  84. // a subset of all instructions.
  85. std::vector<const llvm::Instruction *> m_instructionsStorage;
  86. };
  87. } // namespace dxil_dia