llvm-6502/lib/DebugInfo/DWARFDebugLoc.h
David Blaikie b13d54f588 DebugInfo: Support debug_loc under fission
Implement debug_loc.dwo, as well as llvm-dwarfdump support for dumping
this section.

Outlined in the DWARF5 spec and http://gcc.gnu.org/wiki/DebugFission the
debug_loc.dwo section has more variation than the standard debug_loc,
allowing 3 different forms of entry (plus the end of list entry). GCC
seems to, and Clang certainly, only use one form, so I've just
implemented dumping support for that for now.

It wasn't immediately obvious that there was a good refactoring to share
the implementation of dumping support between debug_loc and
debug_loc.dwo, so they're separate for now - ideas welcome or I may come
back to it at some point.

As per a comment in the code, we could choose different forms that may
reduce the number of debug_addr entries we emit, but that will require
further study.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@204697 91177308-0d34-0410-b5e6-96231b3b80d8
2014-03-25 01:44:02 +00:00

82 lines
2.2 KiB
C++

//===-- DWARFDebugLoc.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_DWARFDEBUGLOC_H
#define LLVM_DEBUGINFO_DWARFDEBUGLOC_H
#include "DWARFRelocMap.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/Support/DataExtractor.h"
namespace llvm {
class raw_ostream;
class DWARFDebugLoc {
/// A single location within a location list.
struct Entry {
/// The beginning address of the instruction range.
uint64_t Begin;
/// The ending address of the instruction range.
uint64_t End;
/// The location of the variable within the specified range.
SmallVector<unsigned char, 4> Loc;
};
/// A list of locations that contain one variable.
struct LocationList {
/// The beginning offset where this location list is stored in the debug_loc
/// section.
unsigned Offset;
/// All the locations in which the variable is stored.
SmallVector<Entry, 2> Entries;
};
typedef SmallVector<LocationList, 4> LocationLists;
/// A list of all the variables in the debug_loc section, each one describing
/// the locations in which the variable is stored.
LocationLists Locations;
/// A map used to resolve binary relocations.
const RelocAddrMap &RelocMap;
public:
DWARFDebugLoc(const RelocAddrMap &LocRelocMap) : RelocMap(LocRelocMap) {}
/// Print the location lists found within the debug_loc section.
void dump(raw_ostream &OS) const;
/// Parse the debug_loc section accessible via the 'data' parameter using the
/// specified address size to interpret the address ranges.
void parse(DataExtractor data, unsigned AddressSize);
};
class DWARFDebugLocDWO {
struct Entry {
uint64_t Start;
uint32_t Length;
SmallVector<unsigned char, 4> Loc;
};
struct LocationList {
unsigned Offset;
SmallVector<Entry, 2> Entries;
};
typedef SmallVector<LocationList, 4> LocationLists;
LocationLists Locations;
public:
void parse(DataExtractor data);
void dump(raw_ostream &OS) const;
};
}
#endif