Counter Strike : Global Offensive Source Code
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

82 lines
2.5 KiB

  1. //===-- DWARFFormValue.h ----------------------------------------*- 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. #ifndef LLVM_DEBUGINFO_DWARFFORMVALUE_H
  10. #define LLVM_DEBUGINFO_DWARFFORMVALUE_H
  11. #include "llvm/Support/DataExtractor.h"
  12. namespace llvm {
  13. class DWARFCompileUnit;
  14. class raw_ostream;
  15. class DWARFFormValue {
  16. public:
  17. struct ValueType {
  18. ValueType() : data(NULL) {
  19. uval = 0;
  20. }
  21. union {
  22. uint64_t uval;
  23. int64_t sval;
  24. const char* cstr;
  25. };
  26. const uint8_t* data;
  27. };
  28. enum {
  29. eValueTypeInvalid = 0,
  30. eValueTypeUnsigned,
  31. eValueTypeSigned,
  32. eValueTypeCStr,
  33. eValueTypeBlock
  34. };
  35. private:
  36. uint16_t Form; // Form for this value.
  37. ValueType Value; // Contains all data for the form.
  38. public:
  39. DWARFFormValue(uint16_t form = 0) : Form(form) {}
  40. uint16_t getForm() const { return Form; }
  41. const ValueType& value() const { return Value; }
  42. void dump(raw_ostream &OS, const DWARFCompileUnit* cu) const;
  43. bool extractValue(DataExtractor data, uint32_t *offset_ptr,
  44. const DWARFCompileUnit *cu);
  45. bool isInlinedCStr() const {
  46. return Value.data != NULL && Value.data == (const uint8_t*)Value.cstr;
  47. }
  48. const uint8_t *BlockData() const;
  49. uint64_t getReference(const DWARFCompileUnit* cu) const;
  50. /// Resolve any compile unit specific references so that we don't need
  51. /// the compile unit at a later time in order to work with the form
  52. /// value.
  53. bool resolveCompileUnitReferences(const DWARFCompileUnit* cu);
  54. uint64_t getUnsigned() const { return Value.uval; }
  55. int64_t getSigned() const { return Value.sval; }
  56. const char *getAsCString(const DataExtractor *debug_str_data_ptr) const;
  57. const char *getIndirectCString(const DataExtractor *,
  58. const DataExtractor *) const;
  59. uint64_t getIndirectAddress(const DataExtractor *,
  60. const DWARFCompileUnit *) const;
  61. bool skipValue(DataExtractor debug_info_data, uint32_t *offset_ptr,
  62. const DWARFCompileUnit *cu) const;
  63. static bool skipValue(uint16_t form, DataExtractor debug_info_data,
  64. uint32_t *offset_ptr, const DWARFCompileUnit *cu);
  65. static bool isBlockForm(uint16_t form);
  66. static bool isDataForm(uint16_t form);
  67. static const uint8_t *getFixedFormSizes(uint8_t AddrSize, uint16_t Version);
  68. };
  69. }
  70. #endif