2011-09-13 19:42:23 +00:00
|
|
|
//===-- DWARFFormValue.h ----------------------------------------*- C++ -*-===//
|
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#ifndef LLVM_DEBUGINFO_DWARFFORMVALUE_H
|
|
|
|
#define LLVM_DEBUGINFO_DWARFFORMVALUE_H
|
|
|
|
|
2013-10-28 23:41:49 +00:00
|
|
|
#include "llvm/ADT/ArrayRef.h"
|
2013-10-28 23:01:48 +00:00
|
|
|
#include "llvm/ADT/Optional.h"
|
2011-09-13 19:42:23 +00:00
|
|
|
#include "llvm/Support/DataExtractor.h"
|
|
|
|
|
|
|
|
namespace llvm {
|
|
|
|
|
2013-09-23 22:44:40 +00:00
|
|
|
class DWARFUnit;
|
2011-09-13 19:42:23 +00:00
|
|
|
class raw_ostream;
|
|
|
|
|
|
|
|
class DWARFFormValue {
|
2013-10-28 23:01:48 +00:00
|
|
|
public:
|
|
|
|
enum FormClass {
|
|
|
|
FC_Unknown,
|
|
|
|
FC_Address,
|
|
|
|
FC_Block,
|
|
|
|
FC_Constant,
|
|
|
|
FC_String,
|
|
|
|
FC_Flag,
|
|
|
|
FC_Reference,
|
|
|
|
FC_Indirect,
|
|
|
|
FC_SectionOffset,
|
|
|
|
FC_Exprloc
|
|
|
|
};
|
|
|
|
|
|
|
|
private:
|
2011-09-13 19:42:23 +00:00
|
|
|
struct ValueType {
|
2014-04-15 06:32:26 +00:00
|
|
|
ValueType() : data(nullptr) {
|
2011-09-13 19:42:23 +00:00
|
|
|
uval = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
union {
|
|
|
|
uint64_t uval;
|
|
|
|
int64_t sval;
|
|
|
|
const char* cstr;
|
|
|
|
};
|
|
|
|
const uint8_t* data;
|
|
|
|
};
|
|
|
|
|
|
|
|
uint16_t Form; // Form for this value.
|
|
|
|
ValueType Value; // Contains all data for the form.
|
|
|
|
|
|
|
|
public:
|
2013-10-28 23:01:48 +00:00
|
|
|
DWARFFormValue(uint16_t Form = 0) : Form(Form) {}
|
2011-09-13 19:42:23 +00:00
|
|
|
uint16_t getForm() const { return Form; }
|
2013-10-28 23:01:48 +00:00
|
|
|
bool isFormClass(FormClass FC) const;
|
|
|
|
|
2013-09-23 22:44:40 +00:00
|
|
|
void dump(raw_ostream &OS, const DWARFUnit *U) const;
|
2011-09-13 19:42:23 +00:00
|
|
|
bool extractValue(DataExtractor data, uint32_t *offset_ptr,
|
2013-09-23 22:44:40 +00:00
|
|
|
const DWARFUnit *u);
|
2011-09-13 19:42:23 +00:00
|
|
|
bool isInlinedCStr() const {
|
2014-04-15 06:32:26 +00:00
|
|
|
return Value.data != nullptr && Value.data == (const uint8_t*)Value.cstr;
|
2011-09-13 19:42:23 +00:00
|
|
|
}
|
|
|
|
|
2013-10-28 23:01:48 +00:00
|
|
|
/// getAsFoo functions below return the extracted value as Foo if only
|
|
|
|
/// DWARFFormValue has form class is suitable for representing Foo.
|
|
|
|
Optional<uint64_t> getAsReference(const DWARFUnit *U) const;
|
|
|
|
Optional<uint64_t> getAsUnsignedConstant() const;
|
|
|
|
Optional<const char *> getAsCString(const DWARFUnit *U) const;
|
|
|
|
Optional<uint64_t> getAsAddress(const DWARFUnit *U) const;
|
|
|
|
Optional<uint64_t> getAsSectionOffset() const;
|
2013-10-18 07:03:16 +00:00
|
|
|
|
2011-09-13 19:42:23 +00:00
|
|
|
bool skipValue(DataExtractor debug_info_data, uint32_t *offset_ptr,
|
2013-09-23 22:44:40 +00:00
|
|
|
const DWARFUnit *u) const;
|
2011-09-13 19:42:23 +00:00
|
|
|
static bool skipValue(uint16_t form, DataExtractor debug_info_data,
|
2013-09-23 22:44:40 +00:00
|
|
|
uint32_t *offset_ptr, const DWARFUnit *u);
|
2013-10-18 07:03:16 +00:00
|
|
|
|
2013-10-28 23:41:49 +00:00
|
|
|
static ArrayRef<uint8_t> getFixedFormSizes(uint8_t AddrSize,
|
|
|
|
uint16_t Version);
|
2011-09-13 19:42:23 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|