dwarf.h 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868
  1. /*++
  2. Copyright (c) 2015 Minoca Corp. All Rights Reserved
  3. Module Name:
  4. dwarf.h
  5. Abstract:
  6. This header contains definitions for the DWARF 2+ symbol format.
  7. Author:
  8. Evan Green 2-Dec-2015
  9. --*/
  10. //
  11. // ------------------------------------------------------------------- Includes
  12. //
  13. //
  14. // ---------------------------------------------------------------- Definitions
  15. //
  16. //
  17. // Parser definitions.
  18. //
  19. //
  20. // Set this flag to print all the DWARF entities processed.
  21. //
  22. #define DWARF_CONTEXT_DEBUG 0x00000001
  23. //
  24. // Set this flag to print all the abbreviations.
  25. //
  26. #define DWARF_CONTEXT_DEBUG_ABBREVIATIONS 0x00000002
  27. //
  28. // Set this flag to print all the line number table information.
  29. //
  30. #define DWARF_CONTEXT_DEBUG_LINE_NUMBERS 0x00000004
  31. //
  32. // Set this flag to print unwinding information.
  33. //
  34. #define DWARF_CONTEXT_DEBUG_FRAMES 0x00000008
  35. //
  36. // Set this flag to print just the unwinding results.
  37. //
  38. #define DWARF_CONTEXT_VERBOSE_UNWINDING 0x00000010
  39. //
  40. // Define the maximum currently implemented depth of the stack. Bump this up if
  41. // applications seem to be heavily using the DWARF expression stack.
  42. //
  43. #define DWARF_EXPRESSION_STACK_SIZE 12
  44. //
  45. // ------------------------------------------------------ Data Type Definitions
  46. //
  47. typedef enum _DWARF_TAG {
  48. DwarfTagArrayType = 0x01,
  49. DwarfTagClassType = 0x02,
  50. DwarfTagEntryPoint = 0x03,
  51. DwarfTagEnumerationType = 0x04,
  52. DwarfTagFormalParameter = 0x05,
  53. DwarfTagImportedDeclaration = 0x08,
  54. DwarfTagLabel = 0x0A,
  55. DwarfTagLexicalBlock = 0x0B,
  56. DwarfTagMember = 0x0D,
  57. DwarfTagPointerType = 0x0F,
  58. DwarfTagReferenceType = 0x10,
  59. DwarfTagCompileUnit = 0x11,
  60. DwarfTagStringType = 0x12,
  61. DwarfTagStructureType = 0x13,
  62. DwarfTagSubroutineType = 0x15,
  63. DwarfTagTypedef = 0x16,
  64. DwarfTagUnionType = 0x17,
  65. DwarfTagUnspecifiedParameters = 0x18,
  66. DwarfTagVariant = 0x19,
  67. DwarfTagCommonBlock = 0x1A,
  68. DwarfTagCommonInclusion = 0x1B,
  69. DwarfTagInheritance = 0x1C,
  70. DwarfTagInlinedSubroutine = 0x1D,
  71. DwarfTagModule = 0x1E,
  72. DwarfTagPointerToMemberType = 0x1F,
  73. DwarfTagSetType = 0x20,
  74. DwarfTagSubrangeType = 0x21,
  75. DwarfTagWithStatement = 0x22,
  76. DwarfTagAccessDeclaration = 0x23,
  77. DwarfTagBaseType = 0x24,
  78. DwarfTagCatchBlock = 0x25,
  79. DwarfTagConstType = 0x26,
  80. DwarfTagConstant = 0x27,
  81. DwarfTagEnumerator = 0x28,
  82. DwarfTagFileType = 0x29,
  83. DwarfTagFriend = 0x2A,
  84. DwarfTagNameList = 0x2B,
  85. DwarfTagNameListItem = 0x2C,
  86. DwarfTagPackedType = 0x2D,
  87. DwarfTagSubprogram = 0x2E,
  88. DwarfTagTemplateTypeParameter = 0x2F,
  89. DwarfTagTemplateValueParameter = 0x30,
  90. DwarfTagThrownType = 0x31,
  91. DwarfTagTryBlock = 0x32,
  92. DwarfTagVariantPart = 0x33,
  93. DwarfTagVariable = 0x34,
  94. DwarfTagVolatileType = 0x35,
  95. DwarfTagDwarfProcedure = 0x36,
  96. DwarfTagRestrictType = 0x37,
  97. DwarfTagInterfaceType = 0x38,
  98. DwarfTagNamespace = 0x39,
  99. DwarfTagImportedModule = 0x3A,
  100. DwarfTagUnspecifiedType = 0x3B,
  101. DwarfTagPartialUnit = 0x3C,
  102. DwarfTagImportedUnit = 0x3D,
  103. DwarfTagCondition = 0x3F,
  104. DwarfTagSharedType = 0x40,
  105. DwarfTagTypeUnit = 0x41,
  106. DwarfTagRvalueReferenceType = 0x42,
  107. DwarfTagTemplateAlias = 0x43,
  108. DwarfTagLowUser = 0x4080,
  109. DwarfTagHighUser = 0xFFFF
  110. } DWARF_TAG, *PDWARF_TAG;
  111. typedef enum _DWARF_CHILDREN_VALUE {
  112. DwarfChildrenNo = 0x00,
  113. DwarfChildrenYes = 0x01
  114. } DWARF_CHILDREN_VALUE, *PDWARF_CHILDREN_VALUE;
  115. typedef enum _DWARF_ATTRIBUTE {
  116. DwarfAtSibling = 0x01,
  117. DwarfAtLocation = 0x02,
  118. DwarfAtName = 0x03,
  119. DwarfAtOrdering = 0x09,
  120. DwarfAtByteSize = 0x0B,
  121. DwarfAtBitOffset = 0x0C,
  122. DwarfAtBitSize = 0x0D,
  123. DwarfAtStatementList = 0x10,
  124. DwarfAtLowPc = 0x11,
  125. DwarfAtHighPc = 0x12,
  126. DwarfAtLanguage = 0x13,
  127. DwarfAtDiscr = 0x15,
  128. DwarfAtDiscrValue = 0x16,
  129. DwarfAtVisibility = 0x17,
  130. DwarfAtImport = 0x18,
  131. DwarfAtStringLength = 0x19,
  132. DwarfAtCommonReference = 0x1A,
  133. DwarfAtCompDir = 0x1B,
  134. DwarfAtConstValue = 0x1C,
  135. DwarfAtContainingType = 0x1D,
  136. DwarfAtDefaultValue = 0x1E,
  137. DwarfAtInline = 0x20,
  138. DwarfAtIsOptional = 0x21,
  139. DwarfAtLowerBound = 0x22,
  140. DwarfAtProducer = 0x25,
  141. DwarfAtPrototyped = 0x27,
  142. DwarfAtReturnAddress = 0x2A,
  143. DwarfAtStartScope = 0x2C,
  144. DwarfAtBitStride = 0x2E,
  145. DwarfAtUpperBound = 0x2F,
  146. DwarfAtAbstractOrigin = 0x31,
  147. DwarfAtAccessibility = 0x32,
  148. DwarfAtAddressClass = 0x33,
  149. DwarfAtArtificial = 0x34,
  150. DwarfAtBaseTypes = 0x35,
  151. DwarfAtCallingConvention = 0x36,
  152. DwarfAtCount = 0x37,
  153. DwarfAtDataMemberLocation = 0x38,
  154. DwarfAtDeclColumn = 0x39,
  155. DwarfAtDeclFile = 0x3A,
  156. DwarfAtDeclLine = 0x3B,
  157. DwarfAtDeclaration = 0x3C,
  158. DwarfAtDiscrList = 0x3D,
  159. DwarfAtEncoding = 0x3E,
  160. DwarfAtExternal = 0x3F,
  161. DwarfAtFrameBase = 0x40,
  162. DwarfAtFriend = 0x41,
  163. DwarfAtIdentifierCase = 0x42,
  164. DwarfAtMacroInfo = 0x43,
  165. DwarfAtNameListItem = 0x44,
  166. DwarfAtPriority = 0x45,
  167. DwarfAtSegment = 0x46,
  168. DwarfAtSpecification = 0x47,
  169. DwarfAtStaticLink = 0x48,
  170. DwarfAtType = 0x49,
  171. DwarfAtUseLocation = 0x4A,
  172. DwarfAtVariableParameter = 0x4B,
  173. DwarfAtVirtuality = 0x4C,
  174. DwarfAtVtableElementLocation = 0x4D,
  175. DwarfAtAllocated = 0x4E,
  176. DwarfAtAssociated = 0x4F,
  177. DwarfAtDataLocation = 0x50,
  178. DwarfAtByteStride = 0x51,
  179. DwarfAtEntryPc = 0x52,
  180. DwarfAtUseUtf8 = 0x53,
  181. DwarfAtExtension = 0x54,
  182. DwarfAtRanges = 0x55,
  183. DwarfAtTrampoline = 0x56,
  184. DwarfAtCallColumn = 0x57,
  185. DwarfAtCallFile = 0x58,
  186. DwarfAtCallLine = 0x59,
  187. DwarfAtDescription = 0x5A,
  188. DwarfAtBinaryScale = 0x5B,
  189. DwarfAtDecimalScale = 0x5C,
  190. DwarfAtSmall = 0x5D,
  191. DwarfAtDecimalSign = 0x5E,
  192. DwarfAtDigitCount = 0x5F,
  193. DwarfAtPictureString = 0x60,
  194. DwarfAtMutable = 0x61,
  195. DwarfAtThreadsScaled = 0x62,
  196. DwarfAtExplicit = 0x63,
  197. DwarfAtObjectPointer = 0x64,
  198. DwarfAtEndianity = 0x65,
  199. DwarfAtElemental = 0x66,
  200. DwarfAtPure = 0x67,
  201. DwarfAtRecursive = 0x68,
  202. DwarfAtSignature = 0x69,
  203. DwarfAtMainSubprogram = 0x6A,
  204. DwarfAtDataBitOffset = 0x6B,
  205. DwarfAtConstExpression = 0x6C,
  206. DwarfAtEnumClass = 0x6D,
  207. DwarfAtLinkageName = 0x6E,
  208. DwarfAtLowUser = 0x2000,
  209. DwarfAtHighUser = 0x3FFF
  210. } DWARF_ATTRIBUTE, *PDWARF_ATTRIBUTE;
  211. typedef enum _DWARF_FORM {
  212. DwarfFormAddress = 0x01,
  213. DwarfFormBlock2 = 0x03,
  214. DwarfFormBlock4 = 0x04,
  215. DwarfFormData2 = 0x05,
  216. DwarfFormData4 = 0x06,
  217. DwarfFormData8 = 0x07,
  218. DwarfFormString = 0x08,
  219. DwarfFormBlock = 0x09,
  220. DwarfFormBlock1 = 0x0A,
  221. DwarfFormData1 = 0x0B,
  222. DwarfFormFlag = 0x0C,
  223. DwarfFormSData = 0x0D,
  224. DwarfFormStringPointer = 0x0E,
  225. DwarfFormUData = 0x0F,
  226. DwarfFormRefAddress = 0x10,
  227. DwarfFormRef1 = 0x11,
  228. DwarfFormRef2 = 0x12,
  229. DwarfFormRef4 = 0x13,
  230. DwarfFormRef8 = 0x14,
  231. DwarfFormRefUData = 0x15,
  232. DwarfFormIndirect = 0x16,
  233. DwarfFormSecOffset = 0x17,
  234. DwarfFormExprLoc = 0x18,
  235. DwarfFormFlagPresent = 0x19,
  236. DwarfFormRefSig8 = 0x20
  237. } DWARF_FORM, *PDWARF_FORM;
  238. typedef enum _DWARF_OP {
  239. DwarfOpAddress = 0x03,
  240. DwarfOpDereference = 0x06,
  241. DwarfOpConst1U = 0x08,
  242. DwarfOpConst1S = 0x09,
  243. DwarfOpConst2U = 0x0A,
  244. DwarfOpConst2S = 0x0B,
  245. DwarfOpConst4U = 0x0C,
  246. DwarfOpConst4S = 0x0D,
  247. DwarfOpConst8U = 0x0E,
  248. DwarfOpConst8S = 0x0F,
  249. DwarfOpConstU = 0x10,
  250. DwarfOpConstS = 0x11,
  251. DwarfOpDup = 0x12,
  252. DwarfOpDrop = 0x13,
  253. DwarfOpOver = 0x14,
  254. DwarfOpPick = 0x15,
  255. DwarfOpSwap = 0x16,
  256. DwarfOpRot = 0x17,
  257. DwarfOpXDeref = 0x18,
  258. DwarfOpAbs = 0x19,
  259. DwarfOpAnd = 0x1A,
  260. DwarfOpDiv = 0x1B,
  261. DwarfOpMinus = 0x1C,
  262. DwarfOpMod = 0x1D,
  263. DwarfOpMul = 0x1E,
  264. DwarfOpNeg = 0x1F,
  265. DwarfOpNot = 0x20,
  266. DwarfOpOr = 0x21,
  267. DwarfOpPlus = 0x22,
  268. DwarfOpPlusUConst = 0x23,
  269. DwarfOpShl = 0x24,
  270. DwarfOpShr = 0x25,
  271. DwarfOpShra = 0x26,
  272. DwarfOpXor = 0x27,
  273. DwarfOpBra = 0x28,
  274. DwarfOpEq = 0x29,
  275. DwarfOpGe = 0x2A,
  276. DwarfOpGt = 0x2B,
  277. DwarfOpLe = 0x2C,
  278. DwarfOpLt = 0x2D,
  279. DwarfOpNe = 0x2E,
  280. DwarfOpSkip = 0x2F,
  281. DwarfOpLit0 = 0x30,
  282. DwarfOpLit31 = 0x4F,
  283. DwarfOpReg0 = 0x50,
  284. DwarfOpReg31 = 0x6F,
  285. DwarfOpBreg0 = 0x70,
  286. DwarfOpBreg31 = 0x8F,
  287. DwarfOpRegX = 0x90,
  288. DwarfOpFbreg = 0x91,
  289. DwarfOpBregX = 0x92,
  290. DwarfOpPiece = 0x93,
  291. DwarfOpDerefSize = 0x94,
  292. DwarfOpXDerefSize = 0x95,
  293. DwarfOpNop = 0x96,
  294. DwarfOpPushObjectAddress = 0x97,
  295. DwarfOpCall2 = 0x98,
  296. DwarfOpCall4 = 0x99,
  297. DwarfOpCallRef = 0x9A,
  298. DwarfOpFormTlsAddress = 0x9B,
  299. DwarfOpCallFrameCfa = 0x9C,
  300. DwarfOpBitPiece = 0x9D,
  301. DwarfOpImplicitValue = 0x9E,
  302. DwarfOpStackValue = 0x9F,
  303. DwarfOpLowUser = 0xE0,
  304. DwarfOpGnuPushTlsAddress = 0xE0,
  305. DwarfOpGnuUninit = 0xF0,
  306. DwarfOpGnuEncodedAddr = 0xF1,
  307. DwarfOpGnuImplicitPointer = 0xF2,
  308. DwarfOpGnuEntryValue = 0xF3,
  309. DwarfOpGnuConstType = 0xF4,
  310. DwarfOpGnuRegvalType = 0xF5,
  311. DwarfOpGnuDerefType = 0xF6,
  312. DwarfOpGnuConvert = 0xF7,
  313. DwarfOpGnuReinterpret = 0xF9,
  314. DwarfOpGnuParameterRef = 0xFA,
  315. DwarfOpGnuAddrIndex = 0xFB,
  316. DwarfOpGnuConstIndex = 0xFC,
  317. DwarfOpHighUser = 0xFF
  318. } DWARF_OP, *PDWARF_OP;
  319. typedef enum _DWARF_BASE_TYPE_ATTRIBUTE {
  320. DwarfAteAddress = 0x01,
  321. DwarfAteBoolean = 0x02,
  322. DwarfAteComplexFloat = 0x03,
  323. DwarfAteFloat = 0x04,
  324. DwarfAteSigned = 0x05,
  325. DwarfAteSignedChar = 0x06,
  326. DwarfAteUnsigned = 0x07,
  327. DwarfAteUnsignedChar = 0x08,
  328. DwarfAteImaginaryFloat = 0x09,
  329. DwarfAtePackedDecimal = 0x0A,
  330. DwarfAteNumericString = 0x0B,
  331. DwarfAteEdited = 0x0C,
  332. DwarfAteSignedFixed = 0x0D,
  333. DwarfAteUnsignedFixed = 0x0E,
  334. DwarfAteDecimalFloat = 0x0F,
  335. DwarfAteUtf = 0x10,
  336. DwarfAteLowUser = 0x80,
  337. DwarfAteHighUser = 0xFF
  338. } DWARF_BASE_TYPE_ATTRIBUTE, *PDWARF_BASE_TYPE_ATTRIBUTE;
  339. typedef enum _DWARF_DECIMAL_SIGN {
  340. DwarfDsUnsigned = 0x01,
  341. DwarfDsLeadingOverpunch = 0x02,
  342. DwarfDsTrailingOverpunch = 0x03,
  343. DwarfDsLeadingSeparate = 0x04,
  344. DwarfDsTrailingSeparate = 0x05,
  345. } DWARF_DECIMAL_SIGN, *PDWARF_DECIMAL_SIGN;
  346. typedef enum _DWARF_ENDIANITY {
  347. DwarfEndDefault = 0x00,
  348. DwarfEndBig = 0x01,
  349. DwarfEndLittle = 0x02,
  350. DwarfEndLowUser = 0x40,
  351. DwarfEndHighUser = 0xFF
  352. } DWARF_ENDIANITY, *PDWARF_ENDIANITY;
  353. typedef enum _DWARF_ACCESSIBILITY {
  354. DwarfAccessPublic = 0x01,
  355. DwarfAccessProtected = 0x02,
  356. DwarfAccessPrivate = 0x03,
  357. } DWARF_ACCESSIBILITY, *PDWARF_ACCESSIBILITY;
  358. typedef enum _DWARF_VISIBILITY {
  359. DwarfVisLocal = 0x01,
  360. DwarfVisExported = 0x02,
  361. DwarfVisQualified = 0x03
  362. } DWARF_VISIBILITY, *PDWARF_VISIBILITY;
  363. typedef enum _DWARF_VIRTUALITY {
  364. DwarfVirtualityNone = 0x00,
  365. DwarfVirtualityVirtual = 0x01,
  366. DwarfVirtualityPureVirtual = 0x02
  367. } DWARF_VIRTUALITY, *PDWARF_VIRTUALITY;
  368. typedef enum _DWARF_LANGUAGE {
  369. DwarfLanguageC89 = 0x0001,
  370. DwarfLanguageC = 0x0002,
  371. DwarfLanguageAda83 = 0x0003,
  372. DwarfLanguageCPlusPlus = 0x0004,
  373. DwarfLanguageCobol74 = 0x0005,
  374. DwarfLanguageCobol85 = 0x0006,
  375. DwarfLanguageFortran77 = 0x0007,
  376. DwarfLanguageFortran90 = 0x0008,
  377. DwarfLanguagePascal83 = 0x0009,
  378. DwarfLanguageModula2 = 0x000A,
  379. DwarfLanguageJava = 0x000B,
  380. DwarfLanguageC99 = 0x000C,
  381. DwarfLanguageAda95 = 0x000D,
  382. DwarfLanguageFortran95 = 0x000E,
  383. DwarfLanguagePli = 0x000F,
  384. DwarfLanguageObjC = 0x0010,
  385. DwarfLanguageObjCPlusPlus = 0x0011,
  386. DwarfLanguageUpc = 0x0012,
  387. DwarfLanguageD = 0x0013,
  388. DwarfLanguagePython = 0x0014,
  389. DwarfLanguageLowUser = 0x8000,
  390. DwarfLanguageHighUser = 0xFFFF
  391. } DWARF_LANGUAGE, *PDWARF_LANGUAGE;
  392. typedef enum _DWARF_IDENTIFIER_CASE {
  393. DwarfIdCaseSensitive = 0x00,
  394. DwarfIdUpCase = 0x01,
  395. DwarfIdDownCase = 0x02,
  396. DwarfIdCaseInsensitive = 0x03
  397. } DWARF_IDENTIFIER_CASE, *PDWARF_IDENTIFIER_CASE;
  398. typedef enum _DWARF_CALLING_CONVENTION {
  399. DwarfCcNormal = 0x01,
  400. DwarfCcProgram = 0x02,
  401. DwarfCcNoCall = 0x03,
  402. DwarfCcLowUser = 0x40,
  403. DwarfCcHighUser = 0xFF
  404. } DWARF_CALLING_CONVENTION, *PDWARF_CALLING_CONVENTION;
  405. typedef enum _DWARF_INLINE_CODE {
  406. DwarfInlNotInlined = 0x00,
  407. DwarfInlInlined = 0x01,
  408. DwarfInlDeclaredNotInlined = 0x02,
  409. DwarfInlDeclaredInlined = 0x03
  410. } DWARF_INLINE_CODE, *PDWARF_INLINE_CODE;
  411. typedef enum _DWARF_ARRAY_ORDERING {
  412. DwarfOrdRowMajor = 0x00,
  413. DwarfOrdColumnMajor = 0x01
  414. } DWARF_ARRAY_ORDERING, *PDWARF_ARRAY_ORDERING;
  415. typedef enum _DWARF_DISCRIMINANT_LIST {
  416. DwarfDscLabel = 0x00,
  417. DwarfDscRange = 0x01
  418. } DWARF_DISCRIMINANT_LIST, *PDWARF_DISCRIMINANT_LIST;
  419. typedef enum _DWARF_LINE_STANDARD_OP {
  420. DwarfLnsCopy = 0x01,
  421. DwarfLnsAdvancePc = 0x02,
  422. DwarfLnsAdvanceLine = 0x03,
  423. DwarfLnsSetFile = 0x04,
  424. DwarfLnsSetColumn = 0x05,
  425. DwarfLnsNegateStatement = 0x06,
  426. DwarfLnsSetBasicBlock = 0x07,
  427. DwarfLnsConstAddPc = 0x08,
  428. DwarfLnsFixedAdvancePc = 0x09,
  429. DwarfLnsSetPrologueEnd = 0x0A,
  430. DwarfLnsSetEpilogueBegin = 0x0B,
  431. DwarfLnsSetIsa = 0x0C,
  432. } DWARF_LINE_STANDARD_OP, *PDWARF_LINE_STANDARD_OP;
  433. typedef enum _DWARF_LINE_EXTENDED_OP {
  434. DwarfLneEndSequence = 0x01,
  435. DwarfLneSetAddress = 0x02,
  436. DwarfLneDefineFile = 0x03,
  437. DwarfLneSetDiscriminator = 0x04,
  438. DwarfLneLowUser = 0x80,
  439. DwarfLneHighUser = 0xFF
  440. } DWARF_LINE_EXTENDED_OP, *PDWARF_LINE_EXTENDED_OP;
  441. typedef enum _DWARF_MACRO_INFORMATION {
  442. DwarfMacInfoDefine = 0x01,
  443. DwarfMacInfoUndefine = 0x02,
  444. DwarfMacInfoStartFile = 0x03,
  445. DwarfMacInfoEndFile = 0x04,
  446. DwarfMacInfoVendorExt = 0xFF
  447. } DWARF_MACRO_INFORMATION, *PDWARF_MACRO_INFORMATION;
  448. typedef enum _DWARF_CALL_FRAME_ENCODING {
  449. DwarfCfaNop = 0x00,
  450. DwarfCfaSetLoc = 0x01,
  451. DwarfCfaAdvanceLoc1 = 0x02,
  452. DwarfCfaAdvanceLoc2 = 0x03,
  453. DwarfCfaAdvanceLoc4 = 0x04,
  454. DwarfCfaOffsetExtended = 0x05,
  455. DwarfCfaRestoreExtended = 0x06,
  456. DwarfCfaUndefined = 0x07,
  457. DwarfCfaSameValue = 0x08,
  458. DwarfCfaRegister = 0x09,
  459. DwarfCfaRememberState = 0x0A,
  460. DwarfCfaRestoreState = 0x0B,
  461. DwarfCfaDefCfa = 0x0C,
  462. DwarfCfaDefCfaRegister = 0x0D,
  463. DwarfCfaDefCfaOffset = 0x0E,
  464. DwarfCfaDefCfaExpression = 0x0F,
  465. DwarfCfaExpression = 0x10,
  466. DwarfCfaOffsetExtendedSf = 0x11,
  467. DwarfCfaDefCfaSf = 0x12,
  468. DwarfCfaDefCfaOffsetSf = 0x13,
  469. DwarfCfaValOffset = 0x14,
  470. DwarfCfaValOffsetSf = 0x15,
  471. DwarfCfaValExpression = 0x16,
  472. DwarfCfaLowUser = 0x1C,
  473. DwarfCfaHighUser = 0x3F,
  474. DwarfCfaAdvanceLoc = 0x40,
  475. DwarfCfaOffset = 0x80,
  476. DwarfCfaRestore = 0xC0,
  477. DwarfCfaHighMask = 0xC0
  478. } DWARF_CALL_FRAME_ENCODING, *PDWARF_CALL_FRAME_ENCODING;
  479. typedef enum _DWARF_ADDRESS_ENCODING {
  480. DwarfPeAbsolute = 0x00,
  481. DwarfPeLeb128 = 0x01,
  482. DwarfPeUdata2 = 0x02,
  483. DwarfPeUdata4 = 0x03,
  484. DwarfPeUdata8 = 0x04,
  485. DwarfPeSigned = 0x08,
  486. DwarfPeSleb128 = 0x09,
  487. DwarfPeSdata2 = 0x0A,
  488. DwarfPeSdata4 = 0x0B,
  489. DwarfPeSdata8 = 0x0C,
  490. DwarfPeTypeMask = 0x0F,
  491. DwarfPePcRelative = 0x10,
  492. DwarfPeTextRelative = 0x20,
  493. DwarfPeDataRelative = 0x30,
  494. DwarfPeFunctionRelative = 0x40,
  495. DwarfPeAligned = 0x50,
  496. DwarfPeModifierMask = 0x70,
  497. DwarfPeIndirect = 0x80,
  498. DwarfPeOmit = 0xFF,
  499. } DWARF_ADDRESS_ENCODING, *PDWARF_ADDRESS_ENCODING;
  500. //
  501. // Parser data types.
  502. //
  503. typedef enum _DWARF_LOCATION_TYPE {
  504. DwarfLocationInvalid,
  505. DwarfLocationMemory,
  506. DwarfLocationRegister,
  507. DwarfLocationKnownValue,
  508. DwarfLocationKnownData,
  509. DwarfLocationUndefined,
  510. } DWARF_LOCATION_TYPE, *PDWARF_LOCATION_TYPE;
  511. /*++
  512. Structure Description:
  513. This structure describes a single DWARF debug section.
  514. Members:
  515. Data - Stores a pointer to the data.
  516. Size - Stores the size of the section in bytes.
  517. --*/
  518. typedef struct _DWARF_SECTION {
  519. PVOID Data;
  520. ULONG Size;
  521. } DWARF_SECTION, *PDWARF_SECTION;
  522. /*++
  523. Structure Description:
  524. This structure contains the various debug sections used in DWARF symbols.
  525. Members:
  526. Info - Stores the primary .debug_info section.
  527. Abbreviations - Stores the .debug_abbrev abbreviations table.
  528. Strings - Stores the .debug_str string table.
  529. Locations - Stores the .debug_loc locations section.
  530. Aranges - Stores the .debug_aranges section.
  531. Ranges - Stores the .debug_ranges section.
  532. Macros - Stores the .debug_macinfo preprocessor macros information section.
  533. Lines - Stores the .debug_line line number information.
  534. PubNames - Store the .debug_pubnames name information.
  535. PubTypes - Stores the .debug_pubtypes type name information.
  536. Types - Stores the .debug_types type information, new in DWARF4.
  537. Frame - Stores the .debug_frame section.
  538. EhFrame - Stores the .eh_frame section.
  539. EhFrameAddress - Stores the virtual address of the .eh_frame section.
  540. --*/
  541. typedef struct _DWARF_DEBUG_SECTIONS {
  542. DWARF_SECTION Info;
  543. DWARF_SECTION Abbreviations;
  544. DWARF_SECTION Strings;
  545. DWARF_SECTION Locations;
  546. DWARF_SECTION Aranges;
  547. DWARF_SECTION Ranges;
  548. DWARF_SECTION Macros;
  549. DWARF_SECTION Lines;
  550. DWARF_SECTION PubNames;
  551. DWARF_SECTION PubTypes;
  552. DWARF_SECTION Types;
  553. DWARF_SECTION Frame;
  554. DWARF_SECTION EhFrame;
  555. ULONGLONG EhFrameAddress;
  556. } DWARF_DEBUG_SECTIONS, *PDWARF_DEBUG_SECTIONS;
  557. /*++
  558. Structure Description:
  559. This structure contains the context for a DWARF symbol table.
  560. Members:
  561. Flags - Stores a bitfield of flags. See DWARF_CONTEXT_* definitions.
  562. FileData - Stores a pointer to the file data.
  563. FileSize - Stores the size of the file data in bytes.
  564. Sections - Stores pointers to the various DWARF debug sections.
  565. UnitList - Stores the head of the list of Compilation Units.
  566. SourcesHead - Stores a pointer to the head of the list of source file
  567. symbols.
  568. LoadingContext - Stores a pointer to internal state used during the load of
  569. the module. This is of type DWARF_LOADING_CONTEXT.
  570. --*/
  571. typedef struct _DWARF_CONTEXT {
  572. ULONG Flags;
  573. PSTR FileData;
  574. UINTN FileSize;
  575. DWARF_DEBUG_SECTIONS Sections;
  576. LIST_ENTRY UnitList;
  577. PLIST_ENTRY SourcesHead;
  578. PVOID LoadingContext;
  579. } DWARF_CONTEXT, *PDWARF_CONTEXT;
  580. //
  581. // Location support stuctures
  582. //
  583. /*++
  584. Structure Description:
  585. This union contains the different forms of a DWARF location.
  586. Members:
  587. Address - Stores the target memory address location form.
  588. Register - Stores the register address form.
  589. Value - Stores the direct value, rather than the location.
  590. Buffer - Stores a pointer and size of a buffer that contains the direct
  591. value, rather than the location.
  592. --*/
  593. typedef union _DWARF_LOCATION_UNION {
  594. ULONGLONG Address;
  595. ULONG Register;
  596. ULONGLONG Value;
  597. DWARF_SECTION Buffer;
  598. } DWARF_LOCATION_UNION, *PDWARF_LOCATION_UNION;
  599. typedef struct _DWARF_LOCATION DWARF_LOCATION, *PDWARF_LOCATION;
  600. typedef struct _DWARF_COMPILATION_UNIT
  601. DWARF_COMPILATION_UNIT, *PDWARF_COMPILATION_UNIT;
  602. /*++
  603. Structure Description:
  604. This structure describes a DWARF location.
  605. Members:
  606. ListEntry - Stores pointers to the next and previous pieces of the
  607. complete location if this location is part of a list.
  608. Form - Stores the location form.
  609. Value - Stores the location value union.
  610. BitSize - Stores the size of this piece, or 0 if this describes the entire
  611. object.
  612. BitOffset - Stores the offset from the start of the source data in bits if
  613. this piece is offset in some way.
  614. NextPiece - Stores a pointer to the next piece of the object if it's a
  615. composite description.
  616. --*/
  617. struct _DWARF_LOCATION {
  618. DWARF_LOCATION_TYPE Form;
  619. DWARF_LOCATION_UNION Value;
  620. ULONG BitSize;
  621. ULONG BitOffset;
  622. PDWARF_LOCATION NextPiece;
  623. };
  624. /*++
  625. Structure Description:
  626. This structure describes the context needed to compute a DWARF location.
  627. Members:
  628. Stack - Stores the DWARF expression stack. Element zero is the first
  629. pushed and last popped.
  630. StackSize - Stores the number of valid elements on the expression stack.
  631. Unit - Stores a pointer to the compilation unit the expression lives in.
  632. AddressSize - Stores the size of a target address.
  633. Pc - Stores the current value of the instruction pointer, which may be
  634. needed for computing the frame base.
  635. ObjectAddress - Stores the base address of the object being evaluated. This
  636. is the value pushed if a push object address op is executed.
  637. TlsBase - Stores the thread local storage base region for this thread and
  638. module. This value is added if a Form TLS Address op is executed.
  639. CurrentFunction - Stores a pointer to the current function.
  640. Location - Stores the final location of the entity. This may end up being a
  641. list.
  642. Constant - Stores a boolean indicating whether or not the expression is
  643. constant or depends on machine state.
  644. --*/
  645. typedef struct _DWARF_LOCATION_CONTEXT {
  646. ULONGLONG Stack[DWARF_EXPRESSION_STACK_SIZE];
  647. ULONG StackSize;
  648. PDWARF_COMPILATION_UNIT Unit;
  649. UCHAR AddressSize;
  650. ULONGLONG Pc;
  651. ULONGLONG ObjectAddress;
  652. ULONGLONG TlsBase;
  653. PFUNCTION_SYMBOL CurrentFunction;
  654. DWARF_LOCATION Location;
  655. BOOL Constant;
  656. } DWARF_LOCATION_CONTEXT, *PDWARF_LOCATION_CONTEXT;
  657. //
  658. // -------------------------------------------------------------------- Globals
  659. //
  660. //
  661. // -------------------------------------------------------- Function Prototypes
  662. //
  663. INT
  664. DwarfLoadSymbols (
  665. PSTR Filename,
  666. IMAGE_MACHINE_TYPE MachineType,
  667. ULONG Flags,
  668. PVOID HostContext,
  669. PDEBUG_SYMBOLS *Symbols
  670. );
  671. /*++
  672. Routine Description:
  673. This routine loads DWARF symbols for the given file.
  674. Arguments:
  675. Filename - Supplies the name of the binary to load symbols from.
  676. MachineType - Supplies the required machine type of the image. Set to
  677. unknown to allow the symbol library to load a file with any machine
  678. type.
  679. Flags - Supplies a bitfield of flags governing the behavior during load.
  680. These flags are specific to each symbol library.
  681. HostContext - Supplies the value to store in the host context field of the
  682. debug symbols.
  683. Symbols - Supplies an optional pointer where a pointer to the symbols will
  684. be returned on success.
  685. Return Value:
  686. 0 on success.
  687. Returns an error number on failure.
  688. --*/
  689. INT
  690. DwarfStackUnwind (
  691. PDEBUG_SYMBOLS Symbols,
  692. ULONGLONG DebasedPc,
  693. PSTACK_FRAME Frame
  694. );
  695. /*++
  696. Routine Description:
  697. This routine attempts to unwind the stack by one frame.
  698. Arguments:
  699. Symbols - Supplies a pointer to the debug symbols.
  700. DebasedPc - Supplies the program counter value, assuming the image were
  701. loaded at its preferred base address (that is, actual PC minus loaded
  702. base difference of the module).
  703. Frame - Supplies a pointer where the basic frame information for this
  704. frame will be returned.
  705. Return Value:
  706. 0 on success.
  707. EOF if there are no more stack frames.
  708. Returns an error code on failure.
  709. --*/