Deleted Added
full compact
DWARFFormValue.h (256281) DWARFFormValue.h (263508)
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
10#ifndef LLVM_DEBUGINFO_DWARFFORMVALUE_H
11#define LLVM_DEBUGINFO_DWARFFORMVALUE_H
12
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
10#ifndef LLVM_DEBUGINFO_DWARFFORMVALUE_H
11#define LLVM_DEBUGINFO_DWARFFORMVALUE_H
12
13#include "llvm/ADT/ArrayRef.h"
14#include "llvm/ADT/Optional.h"
13#include "llvm/Support/DataExtractor.h"
14
15namespace llvm {
16
15#include "llvm/Support/DataExtractor.h"
16
17namespace llvm {
18
17class DWARFCompileUnit;
19class DWARFUnit;
18class raw_ostream;
19
20class DWARFFormValue {
21public:
20class raw_ostream;
21
22class DWARFFormValue {
23public:
24 enum FormClass {
25 FC_Unknown,
26 FC_Address,
27 FC_Block,
28 FC_Constant,
29 FC_String,
30 FC_Flag,
31 FC_Reference,
32 FC_Indirect,
33 FC_SectionOffset,
34 FC_Exprloc
35 };
36
37private:
22 struct ValueType {
23 ValueType() : data(NULL) {
24 uval = 0;
25 }
26
27 union {
28 uint64_t uval;
29 int64_t sval;
30 const char* cstr;
31 };
32 const uint8_t* data;
33 };
34
38 struct ValueType {
39 ValueType() : data(NULL) {
40 uval = 0;
41 }
42
43 union {
44 uint64_t uval;
45 int64_t sval;
46 const char* cstr;
47 };
48 const uint8_t* data;
49 };
50
35 enum {
36 eValueTypeInvalid = 0,
37 eValueTypeUnsigned,
38 eValueTypeSigned,
39 eValueTypeCStr,
40 eValueTypeBlock
41 };
42
43private:
44 uint16_t Form; // Form for this value.
45 ValueType Value; // Contains all data for the form.
46
47public:
51 uint16_t Form; // Form for this value.
52 ValueType Value; // Contains all data for the form.
53
54public:
48 DWARFFormValue(uint16_t form = 0) : Form(form) {}
55 DWARFFormValue(uint16_t Form = 0) : Form(Form) {}
49 uint16_t getForm() const { return Form; }
56 uint16_t getForm() const { return Form; }
50 const ValueType& value() const { return Value; }
51 void dump(raw_ostream &OS, const DWARFCompileUnit* cu) const;
57 bool isFormClass(FormClass FC) const;
58
59 void dump(raw_ostream &OS, const DWARFUnit *U) const;
52 bool extractValue(DataExtractor data, uint32_t *offset_ptr,
60 bool extractValue(DataExtractor data, uint32_t *offset_ptr,
53 const DWARFCompileUnit *cu);
61 const DWARFUnit *u);
54 bool isInlinedCStr() const {
55 return Value.data != NULL && Value.data == (const uint8_t*)Value.cstr;
56 }
62 bool isInlinedCStr() const {
63 return Value.data != NULL && Value.data == (const uint8_t*)Value.cstr;
64 }
57 const uint8_t *BlockData() const;
58 uint64_t getReference(const DWARFCompileUnit* cu) const;
59
65
60 /// Resolve any compile unit specific references so that we don't need
61 /// the compile unit at a later time in order to work with the form
62 /// value.
63 bool resolveCompileUnitReferences(const DWARFCompileUnit* cu);
64 uint64_t getUnsigned() const { return Value.uval; }
65 int64_t getSigned() const { return Value.sval; }
66 const char *getAsCString(const DataExtractor *debug_str_data_ptr) const;
67 const char *getIndirectCString(const DataExtractor *,
68 const DataExtractor *) const;
69 uint64_t getIndirectAddress(const DataExtractor *,
70 const DWARFCompileUnit *) const;
66 /// getAsFoo functions below return the extracted value as Foo if only
67 /// DWARFFormValue has form class is suitable for representing Foo.
68 Optional<uint64_t> getAsReference(const DWARFUnit *U) const;
69 Optional<uint64_t> getAsUnsignedConstant() const;
70 Optional<const char *> getAsCString(const DWARFUnit *U) const;
71 Optional<uint64_t> getAsAddress(const DWARFUnit *U) const;
72 Optional<uint64_t> getAsSectionOffset() const;
73
71 bool skipValue(DataExtractor debug_info_data, uint32_t *offset_ptr,
74 bool skipValue(DataExtractor debug_info_data, uint32_t *offset_ptr,
72 const DWARFCompileUnit *cu) const;
75 const DWARFUnit *u) const;
73 static bool skipValue(uint16_t form, DataExtractor debug_info_data,
76 static bool skipValue(uint16_t form, DataExtractor debug_info_data,
74 uint32_t *offset_ptr, const DWARFCompileUnit *cu);
75 static bool isBlockForm(uint16_t form);
76 static bool isDataForm(uint16_t form);
77 static const uint8_t *getFixedFormSizes(uint8_t AddrSize, uint16_t Version);
77 uint32_t *offset_ptr, const DWARFUnit *u);
78
79 static ArrayRef<uint8_t> getFixedFormSizes(uint8_t AddrSize,
80 uint16_t Version);
78};
79
80}
81
82#endif
81};
82
83}
84
85#endif