2017-03-01 01:14:23 +00:00
|
|
|
//===- DWARFDebugLoc.cpp --------------------------------------------------===//
|
2013-06-19 21:37:13 +00:00
|
|
|
//
|
2019-01-19 08:50:56 +00:00
|
|
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
|
|
// See https://llvm.org/LICENSE.txt for license information.
|
|
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
2013-06-19 21:37:13 +00:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2017-06-06 11:49:48 +00:00
|
|
|
#include "llvm/DebugInfo/DWARF/DWARFDebugLoc.h"
|
2017-03-01 01:14:23 +00:00
|
|
|
#include "llvm/ADT/StringRef.h"
|
2017-06-07 03:48:56 +00:00
|
|
|
#include "llvm/BinaryFormat/Dwarf.h"
|
2017-04-21 09:12:18 +00:00
|
|
|
#include "llvm/DebugInfo/DWARF/DWARFContext.h"
|
[dwarfdump] Pretty print location expressions and location lists
Summary:
Based on Fred's patch here: https://reviews.llvm.org/D6771
I can't seem to commandeer the old review, so I'm creating a new one.
With that change the locations exrpessions are pretty printed inline in the
DIE tree. The output looks like this for debug_loc entries:
DW_AT_location [DW_FORM_data4] (0x00000000
0x0000000000000001 - 0x000000000000000b: DW_OP_consts +3
0x000000000000000b - 0x0000000000000012: DW_OP_consts +7
0x0000000000000012 - 0x000000000000001b: DW_OP_reg0 RAX, DW_OP_piece 0x4
0x000000000000001b - 0x0000000000000024: DW_OP_breg5 RDI+0)
And like this for debug_loc.dwo entries:
DW_AT_location [DW_FORM_sec_offset] (0x00000000
Addr idx 2 (w/ length 190): DW_OP_consts +0, DW_OP_stack_value
Addr idx 3 (w/ length 23): DW_OP_reg0 RAX, DW_OP_piece 0x4)
Simple locations without ranges are printed inline:
DW_AT_location [DW_FORM_block1] (DW_OP_reg4 RSI, DW_OP_piece 0x4, DW_OP_bit_piece 0x20 0x0)
The debug_loc(.dwo) dumping in changed accordingly to factor the code.
Reviewers: dblaikie, aprantl, friss
Subscribers: mgorny, javed.absar, hiraditya, llvm-commits, JDevlieghere
Differential Revision: https://reviews.llvm.org/D37123
llvm-svn: 312042
2017-08-29 21:41:21 +00:00
|
|
|
#include "llvm/DebugInfo/DWARF/DWARFExpression.h"
|
2017-03-01 01:14:23 +00:00
|
|
|
#include "llvm/DebugInfo/DWARF/DWARFRelocMap.h"
|
[dwarfdump] Pretty print location expressions and location lists
Summary:
Based on Fred's patch here: https://reviews.llvm.org/D6771
I can't seem to commandeer the old review, so I'm creating a new one.
With that change the locations exrpessions are pretty printed inline in the
DIE tree. The output looks like this for debug_loc entries:
DW_AT_location [DW_FORM_data4] (0x00000000
0x0000000000000001 - 0x000000000000000b: DW_OP_consts +3
0x000000000000000b - 0x0000000000000012: DW_OP_consts +7
0x0000000000000012 - 0x000000000000001b: DW_OP_reg0 RAX, DW_OP_piece 0x4
0x000000000000001b - 0x0000000000000024: DW_OP_breg5 RDI+0)
And like this for debug_loc.dwo entries:
DW_AT_location [DW_FORM_sec_offset] (0x00000000
Addr idx 2 (w/ length 190): DW_OP_consts +0, DW_OP_stack_value
Addr idx 3 (w/ length 23): DW_OP_reg0 RAX, DW_OP_piece 0x4)
Simple locations without ranges are printed inline:
DW_AT_location [DW_FORM_block1] (DW_OP_reg4 RSI, DW_OP_piece 0x4, DW_OP_bit_piece 0x20 0x0)
The debug_loc(.dwo) dumping in changed accordingly to factor the code.
Reviewers: dblaikie, aprantl, friss
Subscribers: mgorny, javed.absar, hiraditya, llvm-commits, JDevlieghere
Differential Revision: https://reviews.llvm.org/D37123
llvm-svn: 312042
2017-08-29 21:41:21 +00:00
|
|
|
#include "llvm/DebugInfo/DWARF/DWARFUnit.h"
|
|
|
|
#include "llvm/Support/Compiler.h"
|
2013-06-19 21:37:13 +00:00
|
|
|
#include "llvm/Support/Format.h"
|
2018-04-14 22:07:23 +00:00
|
|
|
#include "llvm/Support/WithColor.h"
|
2013-06-19 21:37:13 +00:00
|
|
|
#include "llvm/Support/raw_ostream.h"
|
2017-03-01 01:14:23 +00:00
|
|
|
#include <algorithm>
|
|
|
|
#include <cinttypes>
|
|
|
|
#include <cstdint>
|
2013-06-19 21:37:13 +00:00
|
|
|
|
|
|
|
using namespace llvm;
|
|
|
|
|
[dwarfdump] Pretty print location expressions and location lists
Summary:
Based on Fred's patch here: https://reviews.llvm.org/D6771
I can't seem to commandeer the old review, so I'm creating a new one.
With that change the locations exrpessions are pretty printed inline in the
DIE tree. The output looks like this for debug_loc entries:
DW_AT_location [DW_FORM_data4] (0x00000000
0x0000000000000001 - 0x000000000000000b: DW_OP_consts +3
0x000000000000000b - 0x0000000000000012: DW_OP_consts +7
0x0000000000000012 - 0x000000000000001b: DW_OP_reg0 RAX, DW_OP_piece 0x4
0x000000000000001b - 0x0000000000000024: DW_OP_breg5 RDI+0)
And like this for debug_loc.dwo entries:
DW_AT_location [DW_FORM_sec_offset] (0x00000000
Addr idx 2 (w/ length 190): DW_OP_consts +0, DW_OP_stack_value
Addr idx 3 (w/ length 23): DW_OP_reg0 RAX, DW_OP_piece 0x4)
Simple locations without ranges are printed inline:
DW_AT_location [DW_FORM_block1] (DW_OP_reg4 RSI, DW_OP_piece 0x4, DW_OP_bit_piece 0x20 0x0)
The debug_loc(.dwo) dumping in changed accordingly to factor the code.
Reviewers: dblaikie, aprantl, friss
Subscribers: mgorny, javed.absar, hiraditya, llvm-commits, JDevlieghere
Differential Revision: https://reviews.llvm.org/D37123
llvm-svn: 312042
2017-08-29 21:41:21 +00:00
|
|
|
// When directly dumping the .debug_loc without a compile unit, we have to guess
|
|
|
|
// at the DWARF version. This only affects DW_OP_call_ref, which is a rare
|
|
|
|
// expression that LLVM doesn't produce. Guessing the wrong version means we
|
|
|
|
// won't be able to pretty print expressions in DWARF2 binaries produced by
|
|
|
|
// non-LLVM tools.
|
|
|
|
static void dumpExpression(raw_ostream &OS, ArrayRef<char> Data,
|
|
|
|
bool IsLittleEndian, unsigned AddressSize,
|
2019-02-21 08:20:24 +00:00
|
|
|
const MCRegisterInfo *MRI, DWARFUnit *U) {
|
[dwarfdump] Pretty print location expressions and location lists
Summary:
Based on Fred's patch here: https://reviews.llvm.org/D6771
I can't seem to commandeer the old review, so I'm creating a new one.
With that change the locations exrpessions are pretty printed inline in the
DIE tree. The output looks like this for debug_loc entries:
DW_AT_location [DW_FORM_data4] (0x00000000
0x0000000000000001 - 0x000000000000000b: DW_OP_consts +3
0x000000000000000b - 0x0000000000000012: DW_OP_consts +7
0x0000000000000012 - 0x000000000000001b: DW_OP_reg0 RAX, DW_OP_piece 0x4
0x000000000000001b - 0x0000000000000024: DW_OP_breg5 RDI+0)
And like this for debug_loc.dwo entries:
DW_AT_location [DW_FORM_sec_offset] (0x00000000
Addr idx 2 (w/ length 190): DW_OP_consts +0, DW_OP_stack_value
Addr idx 3 (w/ length 23): DW_OP_reg0 RAX, DW_OP_piece 0x4)
Simple locations without ranges are printed inline:
DW_AT_location [DW_FORM_block1] (DW_OP_reg4 RSI, DW_OP_piece 0x4, DW_OP_bit_piece 0x20 0x0)
The debug_loc(.dwo) dumping in changed accordingly to factor the code.
Reviewers: dblaikie, aprantl, friss
Subscribers: mgorny, javed.absar, hiraditya, llvm-commits, JDevlieghere
Differential Revision: https://reviews.llvm.org/D37123
llvm-svn: 312042
2017-08-29 21:41:21 +00:00
|
|
|
DWARFDataExtractor Extractor(StringRef(Data.data(), Data.size()),
|
|
|
|
IsLittleEndian, AddressSize);
|
2019-02-21 08:20:24 +00:00
|
|
|
DWARFExpression(Extractor, dwarf::DWARF_VERSION, AddressSize).print(OS, MRI, U);
|
[dwarfdump] Pretty print location expressions and location lists
Summary:
Based on Fred's patch here: https://reviews.llvm.org/D6771
I can't seem to commandeer the old review, so I'm creating a new one.
With that change the locations exrpessions are pretty printed inline in the
DIE tree. The output looks like this for debug_loc entries:
DW_AT_location [DW_FORM_data4] (0x00000000
0x0000000000000001 - 0x000000000000000b: DW_OP_consts +3
0x000000000000000b - 0x0000000000000012: DW_OP_consts +7
0x0000000000000012 - 0x000000000000001b: DW_OP_reg0 RAX, DW_OP_piece 0x4
0x000000000000001b - 0x0000000000000024: DW_OP_breg5 RDI+0)
And like this for debug_loc.dwo entries:
DW_AT_location [DW_FORM_sec_offset] (0x00000000
Addr idx 2 (w/ length 190): DW_OP_consts +0, DW_OP_stack_value
Addr idx 3 (w/ length 23): DW_OP_reg0 RAX, DW_OP_piece 0x4)
Simple locations without ranges are printed inline:
DW_AT_location [DW_FORM_block1] (DW_OP_reg4 RSI, DW_OP_piece 0x4, DW_OP_bit_piece 0x20 0x0)
The debug_loc(.dwo) dumping in changed accordingly to factor the code.
Reviewers: dblaikie, aprantl, friss
Subscribers: mgorny, javed.absar, hiraditya, llvm-commits, JDevlieghere
Differential Revision: https://reviews.llvm.org/D37123
llvm-svn: 312042
2017-08-29 21:41:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void DWARFDebugLoc::LocationList::dump(raw_ostream &OS, bool IsLittleEndian,
|
|
|
|
unsigned AddressSize,
|
|
|
|
const MCRegisterInfo *MRI,
|
2019-02-21 08:20:24 +00:00
|
|
|
DWARFUnit *U,
|
2018-05-21 19:36:54 +00:00
|
|
|
uint64_t BaseAddress,
|
[dwarfdump] Pretty print location expressions and location lists
Summary:
Based on Fred's patch here: https://reviews.llvm.org/D6771
I can't seem to commandeer the old review, so I'm creating a new one.
With that change the locations exrpessions are pretty printed inline in the
DIE tree. The output looks like this for debug_loc entries:
DW_AT_location [DW_FORM_data4] (0x00000000
0x0000000000000001 - 0x000000000000000b: DW_OP_consts +3
0x000000000000000b - 0x0000000000000012: DW_OP_consts +7
0x0000000000000012 - 0x000000000000001b: DW_OP_reg0 RAX, DW_OP_piece 0x4
0x000000000000001b - 0x0000000000000024: DW_OP_breg5 RDI+0)
And like this for debug_loc.dwo entries:
DW_AT_location [DW_FORM_sec_offset] (0x00000000
Addr idx 2 (w/ length 190): DW_OP_consts +0, DW_OP_stack_value
Addr idx 3 (w/ length 23): DW_OP_reg0 RAX, DW_OP_piece 0x4)
Simple locations without ranges are printed inline:
DW_AT_location [DW_FORM_block1] (DW_OP_reg4 RSI, DW_OP_piece 0x4, DW_OP_bit_piece 0x20 0x0)
The debug_loc(.dwo) dumping in changed accordingly to factor the code.
Reviewers: dblaikie, aprantl, friss
Subscribers: mgorny, javed.absar, hiraditya, llvm-commits, JDevlieghere
Differential Revision: https://reviews.llvm.org/D37123
llvm-svn: 312042
2017-08-29 21:41:21 +00:00
|
|
|
unsigned Indent) const {
|
|
|
|
for (const Entry &E : Entries) {
|
|
|
|
OS << '\n';
|
|
|
|
OS.indent(Indent);
|
2018-01-16 11:17:57 +00:00
|
|
|
OS << format("[0x%*.*" PRIx64 ", ", AddressSize * 2, AddressSize * 2,
|
2018-05-21 19:36:54 +00:00
|
|
|
BaseAddress + E.Begin);
|
|
|
|
OS << format(" 0x%*.*" PRIx64 ")", AddressSize * 2, AddressSize * 2,
|
|
|
|
BaseAddress + E.End);
|
2018-01-16 11:17:57 +00:00
|
|
|
OS << ": ";
|
[dwarfdump] Pretty print location expressions and location lists
Summary:
Based on Fred's patch here: https://reviews.llvm.org/D6771
I can't seem to commandeer the old review, so I'm creating a new one.
With that change the locations exrpessions are pretty printed inline in the
DIE tree. The output looks like this for debug_loc entries:
DW_AT_location [DW_FORM_data4] (0x00000000
0x0000000000000001 - 0x000000000000000b: DW_OP_consts +3
0x000000000000000b - 0x0000000000000012: DW_OP_consts +7
0x0000000000000012 - 0x000000000000001b: DW_OP_reg0 RAX, DW_OP_piece 0x4
0x000000000000001b - 0x0000000000000024: DW_OP_breg5 RDI+0)
And like this for debug_loc.dwo entries:
DW_AT_location [DW_FORM_sec_offset] (0x00000000
Addr idx 2 (w/ length 190): DW_OP_consts +0, DW_OP_stack_value
Addr idx 3 (w/ length 23): DW_OP_reg0 RAX, DW_OP_piece 0x4)
Simple locations without ranges are printed inline:
DW_AT_location [DW_FORM_block1] (DW_OP_reg4 RSI, DW_OP_piece 0x4, DW_OP_bit_piece 0x20 0x0)
The debug_loc(.dwo) dumping in changed accordingly to factor the code.
Reviewers: dblaikie, aprantl, friss
Subscribers: mgorny, javed.absar, hiraditya, llvm-commits, JDevlieghere
Differential Revision: https://reviews.llvm.org/D37123
llvm-svn: 312042
2017-08-29 21:41:21 +00:00
|
|
|
|
2019-02-21 08:20:24 +00:00
|
|
|
dumpExpression(OS, E.Loc, IsLittleEndian, AddressSize, MRI, U);
|
[dwarfdump] Pretty print location expressions and location lists
Summary:
Based on Fred's patch here: https://reviews.llvm.org/D6771
I can't seem to commandeer the old review, so I'm creating a new one.
With that change the locations exrpessions are pretty printed inline in the
DIE tree. The output looks like this for debug_loc entries:
DW_AT_location [DW_FORM_data4] (0x00000000
0x0000000000000001 - 0x000000000000000b: DW_OP_consts +3
0x000000000000000b - 0x0000000000000012: DW_OP_consts +7
0x0000000000000012 - 0x000000000000001b: DW_OP_reg0 RAX, DW_OP_piece 0x4
0x000000000000001b - 0x0000000000000024: DW_OP_breg5 RDI+0)
And like this for debug_loc.dwo entries:
DW_AT_location [DW_FORM_sec_offset] (0x00000000
Addr idx 2 (w/ length 190): DW_OP_consts +0, DW_OP_stack_value
Addr idx 3 (w/ length 23): DW_OP_reg0 RAX, DW_OP_piece 0x4)
Simple locations without ranges are printed inline:
DW_AT_location [DW_FORM_block1] (DW_OP_reg4 RSI, DW_OP_piece 0x4, DW_OP_bit_piece 0x20 0x0)
The debug_loc(.dwo) dumping in changed accordingly to factor the code.
Reviewers: dblaikie, aprantl, friss
Subscribers: mgorny, javed.absar, hiraditya, llvm-commits, JDevlieghere
Differential Revision: https://reviews.llvm.org/D37123
llvm-svn: 312042
2017-08-29 21:41:21 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-09-27 09:33:36 +00:00
|
|
|
DWARFDebugLoc::LocationList const *
|
|
|
|
DWARFDebugLoc::getLocationListAtOffset(uint64_t Offset) const {
|
|
|
|
auto It = std::lower_bound(
|
|
|
|
Locations.begin(), Locations.end(), Offset,
|
|
|
|
[](const LocationList &L, uint64_t Offset) { return L.Offset < Offset; });
|
|
|
|
if (It != Locations.end() && It->Offset == Offset)
|
|
|
|
return &(*It);
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
void DWARFDebugLoc::dump(raw_ostream &OS, const MCRegisterInfo *MRI,
|
|
|
|
Optional<uint64_t> Offset) const {
|
|
|
|
auto DumpLocationList = [&](const LocationList &L) {
|
2014-03-13 07:52:54 +00:00
|
|
|
OS << format("0x%8.8x: ", L.Offset);
|
2019-02-21 08:20:24 +00:00
|
|
|
L.dump(OS, IsLittleEndian, AddressSize, MRI, nullptr, 0, 12);
|
[dwarfdump] Pretty print location expressions and location lists
Summary:
Based on Fred's patch here: https://reviews.llvm.org/D6771
I can't seem to commandeer the old review, so I'm creating a new one.
With that change the locations exrpessions are pretty printed inline in the
DIE tree. The output looks like this for debug_loc entries:
DW_AT_location [DW_FORM_data4] (0x00000000
0x0000000000000001 - 0x000000000000000b: DW_OP_consts +3
0x000000000000000b - 0x0000000000000012: DW_OP_consts +7
0x0000000000000012 - 0x000000000000001b: DW_OP_reg0 RAX, DW_OP_piece 0x4
0x000000000000001b - 0x0000000000000024: DW_OP_breg5 RDI+0)
And like this for debug_loc.dwo entries:
DW_AT_location [DW_FORM_sec_offset] (0x00000000
Addr idx 2 (w/ length 190): DW_OP_consts +0, DW_OP_stack_value
Addr idx 3 (w/ length 23): DW_OP_reg0 RAX, DW_OP_piece 0x4)
Simple locations without ranges are printed inline:
DW_AT_location [DW_FORM_block1] (DW_OP_reg4 RSI, DW_OP_piece 0x4, DW_OP_bit_piece 0x20 0x0)
The debug_loc(.dwo) dumping in changed accordingly to factor the code.
Reviewers: dblaikie, aprantl, friss
Subscribers: mgorny, javed.absar, hiraditya, llvm-commits, JDevlieghere
Differential Revision: https://reviews.llvm.org/D37123
llvm-svn: 312042
2017-08-29 21:41:21 +00:00
|
|
|
OS << "\n\n";
|
2017-09-27 09:33:36 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
if (Offset) {
|
|
|
|
if (auto *L = getLocationListAtOffset(*Offset))
|
|
|
|
DumpLocationList(*L);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (const LocationList &L : Locations) {
|
|
|
|
DumpLocationList(L);
|
[dwarfdump] Pretty print location expressions and location lists
Summary:
Based on Fred's patch here: https://reviews.llvm.org/D6771
I can't seem to commandeer the old review, so I'm creating a new one.
With that change the locations exrpessions are pretty printed inline in the
DIE tree. The output looks like this for debug_loc entries:
DW_AT_location [DW_FORM_data4] (0x00000000
0x0000000000000001 - 0x000000000000000b: DW_OP_consts +3
0x000000000000000b - 0x0000000000000012: DW_OP_consts +7
0x0000000000000012 - 0x000000000000001b: DW_OP_reg0 RAX, DW_OP_piece 0x4
0x000000000000001b - 0x0000000000000024: DW_OP_breg5 RDI+0)
And like this for debug_loc.dwo entries:
DW_AT_location [DW_FORM_sec_offset] (0x00000000
Addr idx 2 (w/ length 190): DW_OP_consts +0, DW_OP_stack_value
Addr idx 3 (w/ length 23): DW_OP_reg0 RAX, DW_OP_piece 0x4)
Simple locations without ranges are printed inline:
DW_AT_location [DW_FORM_block1] (DW_OP_reg4 RSI, DW_OP_piece 0x4, DW_OP_bit_piece 0x20 0x0)
The debug_loc(.dwo) dumping in changed accordingly to factor the code.
Reviewers: dblaikie, aprantl, friss
Subscribers: mgorny, javed.absar, hiraditya, llvm-commits, JDevlieghere
Differential Revision: https://reviews.llvm.org/D37123
llvm-svn: 312042
2017-08-29 21:41:21 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Optional<DWARFDebugLoc::LocationList>
|
|
|
|
DWARFDebugLoc::parseOneLocationList(DWARFDataExtractor Data, unsigned *Offset) {
|
|
|
|
LocationList LL;
|
|
|
|
LL.Offset = *Offset;
|
|
|
|
|
|
|
|
// 2.6.2 Location Lists
|
|
|
|
// A location list entry consists of:
|
|
|
|
while (true) {
|
|
|
|
Entry E;
|
|
|
|
if (!Data.isValidOffsetForDataOfSize(*Offset, 2 * Data.getAddressSize())) {
|
2018-04-14 22:07:23 +00:00
|
|
|
WithColor::error() << "location list overflows the debug_loc section.\n";
|
[dwarfdump] Pretty print location expressions and location lists
Summary:
Based on Fred's patch here: https://reviews.llvm.org/D6771
I can't seem to commandeer the old review, so I'm creating a new one.
With that change the locations exrpessions are pretty printed inline in the
DIE tree. The output looks like this for debug_loc entries:
DW_AT_location [DW_FORM_data4] (0x00000000
0x0000000000000001 - 0x000000000000000b: DW_OP_consts +3
0x000000000000000b - 0x0000000000000012: DW_OP_consts +7
0x0000000000000012 - 0x000000000000001b: DW_OP_reg0 RAX, DW_OP_piece 0x4
0x000000000000001b - 0x0000000000000024: DW_OP_breg5 RDI+0)
And like this for debug_loc.dwo entries:
DW_AT_location [DW_FORM_sec_offset] (0x00000000
Addr idx 2 (w/ length 190): DW_OP_consts +0, DW_OP_stack_value
Addr idx 3 (w/ length 23): DW_OP_reg0 RAX, DW_OP_piece 0x4)
Simple locations without ranges are printed inline:
DW_AT_location [DW_FORM_block1] (DW_OP_reg4 RSI, DW_OP_piece 0x4, DW_OP_bit_piece 0x20 0x0)
The debug_loc(.dwo) dumping in changed accordingly to factor the code.
Reviewers: dblaikie, aprantl, friss
Subscribers: mgorny, javed.absar, hiraditya, llvm-commits, JDevlieghere
Differential Revision: https://reviews.llvm.org/D37123
llvm-svn: 312042
2017-08-29 21:41:21 +00:00
|
|
|
return None;
|
|
|
|
}
|
|
|
|
|
|
|
|
// 1. A beginning address offset. ...
|
|
|
|
E.Begin = Data.getRelocatedAddress(Offset);
|
|
|
|
|
|
|
|
// 2. An ending address offset. ...
|
|
|
|
E.End = Data.getRelocatedAddress(Offset);
|
|
|
|
|
|
|
|
// The end of any given location list is marked by an end of list entry,
|
|
|
|
// which consists of a 0 for the beginning address offset and a 0 for the
|
|
|
|
// ending address offset.
|
|
|
|
if (E.Begin == 0 && E.End == 0)
|
|
|
|
return LL;
|
|
|
|
|
|
|
|
if (!Data.isValidOffsetForDataOfSize(*Offset, 2)) {
|
2018-04-14 22:07:23 +00:00
|
|
|
WithColor::error() << "location list overflows the debug_loc section.\n";
|
[dwarfdump] Pretty print location expressions and location lists
Summary:
Based on Fred's patch here: https://reviews.llvm.org/D6771
I can't seem to commandeer the old review, so I'm creating a new one.
With that change the locations exrpessions are pretty printed inline in the
DIE tree. The output looks like this for debug_loc entries:
DW_AT_location [DW_FORM_data4] (0x00000000
0x0000000000000001 - 0x000000000000000b: DW_OP_consts +3
0x000000000000000b - 0x0000000000000012: DW_OP_consts +7
0x0000000000000012 - 0x000000000000001b: DW_OP_reg0 RAX, DW_OP_piece 0x4
0x000000000000001b - 0x0000000000000024: DW_OP_breg5 RDI+0)
And like this for debug_loc.dwo entries:
DW_AT_location [DW_FORM_sec_offset] (0x00000000
Addr idx 2 (w/ length 190): DW_OP_consts +0, DW_OP_stack_value
Addr idx 3 (w/ length 23): DW_OP_reg0 RAX, DW_OP_piece 0x4)
Simple locations without ranges are printed inline:
DW_AT_location [DW_FORM_block1] (DW_OP_reg4 RSI, DW_OP_piece 0x4, DW_OP_bit_piece 0x20 0x0)
The debug_loc(.dwo) dumping in changed accordingly to factor the code.
Reviewers: dblaikie, aprantl, friss
Subscribers: mgorny, javed.absar, hiraditya, llvm-commits, JDevlieghere
Differential Revision: https://reviews.llvm.org/D37123
llvm-svn: 312042
2017-08-29 21:41:21 +00:00
|
|
|
return None;
|
|
|
|
}
|
|
|
|
|
|
|
|
unsigned Bytes = Data.getU16(Offset);
|
|
|
|
if (!Data.isValidOffsetForDataOfSize(*Offset, Bytes)) {
|
2018-04-14 22:07:23 +00:00
|
|
|
WithColor::error() << "location list overflows the debug_loc section.\n";
|
[dwarfdump] Pretty print location expressions and location lists
Summary:
Based on Fred's patch here: https://reviews.llvm.org/D6771
I can't seem to commandeer the old review, so I'm creating a new one.
With that change the locations exrpessions are pretty printed inline in the
DIE tree. The output looks like this for debug_loc entries:
DW_AT_location [DW_FORM_data4] (0x00000000
0x0000000000000001 - 0x000000000000000b: DW_OP_consts +3
0x000000000000000b - 0x0000000000000012: DW_OP_consts +7
0x0000000000000012 - 0x000000000000001b: DW_OP_reg0 RAX, DW_OP_piece 0x4
0x000000000000001b - 0x0000000000000024: DW_OP_breg5 RDI+0)
And like this for debug_loc.dwo entries:
DW_AT_location [DW_FORM_sec_offset] (0x00000000
Addr idx 2 (w/ length 190): DW_OP_consts +0, DW_OP_stack_value
Addr idx 3 (w/ length 23): DW_OP_reg0 RAX, DW_OP_piece 0x4)
Simple locations without ranges are printed inline:
DW_AT_location [DW_FORM_block1] (DW_OP_reg4 RSI, DW_OP_piece 0x4, DW_OP_bit_piece 0x20 0x0)
The debug_loc(.dwo) dumping in changed accordingly to factor the code.
Reviewers: dblaikie, aprantl, friss
Subscribers: mgorny, javed.absar, hiraditya, llvm-commits, JDevlieghere
Differential Revision: https://reviews.llvm.org/D37123
llvm-svn: 312042
2017-08-29 21:41:21 +00:00
|
|
|
return None;
|
2013-06-19 21:37:13 +00:00
|
|
|
}
|
[dwarfdump] Pretty print location expressions and location lists
Summary:
Based on Fred's patch here: https://reviews.llvm.org/D6771
I can't seem to commandeer the old review, so I'm creating a new one.
With that change the locations exrpessions are pretty printed inline in the
DIE tree. The output looks like this for debug_loc entries:
DW_AT_location [DW_FORM_data4] (0x00000000
0x0000000000000001 - 0x000000000000000b: DW_OP_consts +3
0x000000000000000b - 0x0000000000000012: DW_OP_consts +7
0x0000000000000012 - 0x000000000000001b: DW_OP_reg0 RAX, DW_OP_piece 0x4
0x000000000000001b - 0x0000000000000024: DW_OP_breg5 RDI+0)
And like this for debug_loc.dwo entries:
DW_AT_location [DW_FORM_sec_offset] (0x00000000
Addr idx 2 (w/ length 190): DW_OP_consts +0, DW_OP_stack_value
Addr idx 3 (w/ length 23): DW_OP_reg0 RAX, DW_OP_piece 0x4)
Simple locations without ranges are printed inline:
DW_AT_location [DW_FORM_block1] (DW_OP_reg4 RSI, DW_OP_piece 0x4, DW_OP_bit_piece 0x20 0x0)
The debug_loc(.dwo) dumping in changed accordingly to factor the code.
Reviewers: dblaikie, aprantl, friss
Subscribers: mgorny, javed.absar, hiraditya, llvm-commits, JDevlieghere
Differential Revision: https://reviews.llvm.org/D37123
llvm-svn: 312042
2017-08-29 21:41:21 +00:00
|
|
|
// A single location description describing the location of the object...
|
|
|
|
StringRef str = Data.getData().substr(*Offset, Bytes);
|
|
|
|
*Offset += Bytes;
|
|
|
|
E.Loc.reserve(str.size());
|
2018-11-17 01:44:25 +00:00
|
|
|
llvm::copy(str, std::back_inserter(E.Loc));
|
[dwarfdump] Pretty print location expressions and location lists
Summary:
Based on Fred's patch here: https://reviews.llvm.org/D6771
I can't seem to commandeer the old review, so I'm creating a new one.
With that change the locations exrpessions are pretty printed inline in the
DIE tree. The output looks like this for debug_loc entries:
DW_AT_location [DW_FORM_data4] (0x00000000
0x0000000000000001 - 0x000000000000000b: DW_OP_consts +3
0x000000000000000b - 0x0000000000000012: DW_OP_consts +7
0x0000000000000012 - 0x000000000000001b: DW_OP_reg0 RAX, DW_OP_piece 0x4
0x000000000000001b - 0x0000000000000024: DW_OP_breg5 RDI+0)
And like this for debug_loc.dwo entries:
DW_AT_location [DW_FORM_sec_offset] (0x00000000
Addr idx 2 (w/ length 190): DW_OP_consts +0, DW_OP_stack_value
Addr idx 3 (w/ length 23): DW_OP_reg0 RAX, DW_OP_piece 0x4)
Simple locations without ranges are printed inline:
DW_AT_location [DW_FORM_block1] (DW_OP_reg4 RSI, DW_OP_piece 0x4, DW_OP_bit_piece 0x20 0x0)
The debug_loc(.dwo) dumping in changed accordingly to factor the code.
Reviewers: dblaikie, aprantl, friss
Subscribers: mgorny, javed.absar, hiraditya, llvm-commits, JDevlieghere
Differential Revision: https://reviews.llvm.org/D37123
llvm-svn: 312042
2017-08-29 21:41:21 +00:00
|
|
|
LL.Entries.push_back(std::move(E));
|
2013-06-19 21:37:13 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-06-29 16:52:08 +00:00
|
|
|
void DWARFDebugLoc::parse(const DWARFDataExtractor &data) {
|
[dwarfdump] Pretty print location expressions and location lists
Summary:
Based on Fred's patch here: https://reviews.llvm.org/D6771
I can't seem to commandeer the old review, so I'm creating a new one.
With that change the locations exrpessions are pretty printed inline in the
DIE tree. The output looks like this for debug_loc entries:
DW_AT_location [DW_FORM_data4] (0x00000000
0x0000000000000001 - 0x000000000000000b: DW_OP_consts +3
0x000000000000000b - 0x0000000000000012: DW_OP_consts +7
0x0000000000000012 - 0x000000000000001b: DW_OP_reg0 RAX, DW_OP_piece 0x4
0x000000000000001b - 0x0000000000000024: DW_OP_breg5 RDI+0)
And like this for debug_loc.dwo entries:
DW_AT_location [DW_FORM_sec_offset] (0x00000000
Addr idx 2 (w/ length 190): DW_OP_consts +0, DW_OP_stack_value
Addr idx 3 (w/ length 23): DW_OP_reg0 RAX, DW_OP_piece 0x4)
Simple locations without ranges are printed inline:
DW_AT_location [DW_FORM_block1] (DW_OP_reg4 RSI, DW_OP_piece 0x4, DW_OP_bit_piece 0x20 0x0)
The debug_loc(.dwo) dumping in changed accordingly to factor the code.
Reviewers: dblaikie, aprantl, friss
Subscribers: mgorny, javed.absar, hiraditya, llvm-commits, JDevlieghere
Differential Revision: https://reviews.llvm.org/D37123
llvm-svn: 312042
2017-08-29 21:41:21 +00:00
|
|
|
IsLittleEndian = data.isLittleEndian();
|
|
|
|
AddressSize = data.getAddressSize();
|
|
|
|
|
2013-06-19 21:37:13 +00:00
|
|
|
uint32_t Offset = 0;
|
[dwarfdump] Pretty print location expressions and location lists
Summary:
Based on Fred's patch here: https://reviews.llvm.org/D6771
I can't seem to commandeer the old review, so I'm creating a new one.
With that change the locations exrpessions are pretty printed inline in the
DIE tree. The output looks like this for debug_loc entries:
DW_AT_location [DW_FORM_data4] (0x00000000
0x0000000000000001 - 0x000000000000000b: DW_OP_consts +3
0x000000000000000b - 0x0000000000000012: DW_OP_consts +7
0x0000000000000012 - 0x000000000000001b: DW_OP_reg0 RAX, DW_OP_piece 0x4
0x000000000000001b - 0x0000000000000024: DW_OP_breg5 RDI+0)
And like this for debug_loc.dwo entries:
DW_AT_location [DW_FORM_sec_offset] (0x00000000
Addr idx 2 (w/ length 190): DW_OP_consts +0, DW_OP_stack_value
Addr idx 3 (w/ length 23): DW_OP_reg0 RAX, DW_OP_piece 0x4)
Simple locations without ranges are printed inline:
DW_AT_location [DW_FORM_block1] (DW_OP_reg4 RSI, DW_OP_piece 0x4, DW_OP_bit_piece 0x20 0x0)
The debug_loc(.dwo) dumping in changed accordingly to factor the code.
Reviewers: dblaikie, aprantl, friss
Subscribers: mgorny, javed.absar, hiraditya, llvm-commits, JDevlieghere
Differential Revision: https://reviews.llvm.org/D37123
llvm-svn: 312042
2017-08-29 21:41:21 +00:00
|
|
|
while (data.isValidOffset(Offset + data.getAddressSize() - 1)) {
|
|
|
|
if (auto LL = parseOneLocationList(data, &Offset))
|
|
|
|
Locations.push_back(std::move(*LL));
|
|
|
|
else
|
|
|
|
break;
|
2013-06-19 21:37:13 +00:00
|
|
|
}
|
2014-02-11 21:22:53 +00:00
|
|
|
if (data.isValidOffset(Offset))
|
2018-04-14 22:07:23 +00:00
|
|
|
WithColor::error() << "failed to consume entire .debug_loc section\n";
|
2013-06-19 21:37:13 +00:00
|
|
|
}
|
2014-03-25 01:44:02 +00:00
|
|
|
|
2018-10-22 11:30:54 +00:00
|
|
|
Optional<DWARFDebugLoclists::LocationList>
|
2018-10-25 10:56:44 +00:00
|
|
|
DWARFDebugLoclists::parseOneLocationList(DataExtractor Data, unsigned *Offset,
|
|
|
|
unsigned Version) {
|
[dwarfdump] Pretty print location expressions and location lists
Summary:
Based on Fred's patch here: https://reviews.llvm.org/D6771
I can't seem to commandeer the old review, so I'm creating a new one.
With that change the locations exrpessions are pretty printed inline in the
DIE tree. The output looks like this for debug_loc entries:
DW_AT_location [DW_FORM_data4] (0x00000000
0x0000000000000001 - 0x000000000000000b: DW_OP_consts +3
0x000000000000000b - 0x0000000000000012: DW_OP_consts +7
0x0000000000000012 - 0x000000000000001b: DW_OP_reg0 RAX, DW_OP_piece 0x4
0x000000000000001b - 0x0000000000000024: DW_OP_breg5 RDI+0)
And like this for debug_loc.dwo entries:
DW_AT_location [DW_FORM_sec_offset] (0x00000000
Addr idx 2 (w/ length 190): DW_OP_consts +0, DW_OP_stack_value
Addr idx 3 (w/ length 23): DW_OP_reg0 RAX, DW_OP_piece 0x4)
Simple locations without ranges are printed inline:
DW_AT_location [DW_FORM_block1] (DW_OP_reg4 RSI, DW_OP_piece 0x4, DW_OP_bit_piece 0x20 0x0)
The debug_loc(.dwo) dumping in changed accordingly to factor the code.
Reviewers: dblaikie, aprantl, friss
Subscribers: mgorny, javed.absar, hiraditya, llvm-commits, JDevlieghere
Differential Revision: https://reviews.llvm.org/D37123
llvm-svn: 312042
2017-08-29 21:41:21 +00:00
|
|
|
LocationList LL;
|
|
|
|
LL.Offset = *Offset;
|
|
|
|
|
|
|
|
// dwarf::DW_LLE_end_of_list_entry is 0 and indicates the end of the list.
|
|
|
|
while (auto Kind =
|
|
|
|
static_cast<dwarf::LocationListEntry>(Data.getU8(Offset))) {
|
2018-10-22 11:30:54 +00:00
|
|
|
|
|
|
|
Entry E;
|
|
|
|
E.Kind = Kind;
|
|
|
|
switch (Kind) {
|
|
|
|
case dwarf::DW_LLE_startx_length:
|
|
|
|
E.Value0 = Data.getULEB128(Offset);
|
2018-10-25 10:56:44 +00:00
|
|
|
// Pre-DWARF 5 has different interpretation of the length field. We have
|
|
|
|
// to support both pre- and standartized styles for the compatibility.
|
|
|
|
if (Version < 5)
|
|
|
|
E.Value1 = Data.getU32(Offset);
|
|
|
|
else
|
|
|
|
E.Value1 = Data.getULEB128(Offset);
|
2018-10-22 11:30:54 +00:00
|
|
|
break;
|
|
|
|
case dwarf::DW_LLE_start_length:
|
|
|
|
E.Value0 = Data.getAddress(Offset);
|
|
|
|
E.Value1 = Data.getULEB128(Offset);
|
|
|
|
break;
|
|
|
|
case dwarf::DW_LLE_offset_pair:
|
|
|
|
E.Value0 = Data.getULEB128(Offset);
|
|
|
|
E.Value1 = Data.getULEB128(Offset);
|
|
|
|
break;
|
|
|
|
case dwarf::DW_LLE_base_address:
|
|
|
|
E.Value0 = Data.getAddress(Offset);
|
|
|
|
break;
|
|
|
|
default:
|
2018-04-14 22:07:23 +00:00
|
|
|
WithColor::error() << "dumping support for LLE of kind " << (int)Kind
|
|
|
|
<< " not implemented\n";
|
[dwarfdump] Pretty print location expressions and location lists
Summary:
Based on Fred's patch here: https://reviews.llvm.org/D6771
I can't seem to commandeer the old review, so I'm creating a new one.
With that change the locations exrpessions are pretty printed inline in the
DIE tree. The output looks like this for debug_loc entries:
DW_AT_location [DW_FORM_data4] (0x00000000
0x0000000000000001 - 0x000000000000000b: DW_OP_consts +3
0x000000000000000b - 0x0000000000000012: DW_OP_consts +7
0x0000000000000012 - 0x000000000000001b: DW_OP_reg0 RAX, DW_OP_piece 0x4
0x000000000000001b - 0x0000000000000024: DW_OP_breg5 RDI+0)
And like this for debug_loc.dwo entries:
DW_AT_location [DW_FORM_sec_offset] (0x00000000
Addr idx 2 (w/ length 190): DW_OP_consts +0, DW_OP_stack_value
Addr idx 3 (w/ length 23): DW_OP_reg0 RAX, DW_OP_piece 0x4)
Simple locations without ranges are printed inline:
DW_AT_location [DW_FORM_block1] (DW_OP_reg4 RSI, DW_OP_piece 0x4, DW_OP_bit_piece 0x20 0x0)
The debug_loc(.dwo) dumping in changed accordingly to factor the code.
Reviewers: dblaikie, aprantl, friss
Subscribers: mgorny, javed.absar, hiraditya, llvm-commits, JDevlieghere
Differential Revision: https://reviews.llvm.org/D37123
llvm-svn: 312042
2017-08-29 21:41:21 +00:00
|
|
|
return None;
|
|
|
|
}
|
|
|
|
|
2018-10-25 21:35:59 +00:00
|
|
|
if (Kind != dwarf::DW_LLE_base_address) {
|
2019-02-01 17:11:58 +00:00
|
|
|
unsigned Bytes =
|
|
|
|
Version >= 5 ? Data.getULEB128(Offset) : Data.getU16(Offset);
|
2018-10-25 21:35:59 +00:00
|
|
|
// A single location description describing the location of the object...
|
|
|
|
StringRef str = Data.getData().substr(*Offset, Bytes);
|
|
|
|
*Offset += Bytes;
|
|
|
|
E.Loc.resize(str.size());
|
2018-11-17 01:44:25 +00:00
|
|
|
llvm::copy(str, E.Loc.begin());
|
2018-10-25 21:35:59 +00:00
|
|
|
}
|
[dwarfdump] Pretty print location expressions and location lists
Summary:
Based on Fred's patch here: https://reviews.llvm.org/D6771
I can't seem to commandeer the old review, so I'm creating a new one.
With that change the locations exrpessions are pretty printed inline in the
DIE tree. The output looks like this for debug_loc entries:
DW_AT_location [DW_FORM_data4] (0x00000000
0x0000000000000001 - 0x000000000000000b: DW_OP_consts +3
0x000000000000000b - 0x0000000000000012: DW_OP_consts +7
0x0000000000000012 - 0x000000000000001b: DW_OP_reg0 RAX, DW_OP_piece 0x4
0x000000000000001b - 0x0000000000000024: DW_OP_breg5 RDI+0)
And like this for debug_loc.dwo entries:
DW_AT_location [DW_FORM_sec_offset] (0x00000000
Addr idx 2 (w/ length 190): DW_OP_consts +0, DW_OP_stack_value
Addr idx 3 (w/ length 23): DW_OP_reg0 RAX, DW_OP_piece 0x4)
Simple locations without ranges are printed inline:
DW_AT_location [DW_FORM_block1] (DW_OP_reg4 RSI, DW_OP_piece 0x4, DW_OP_bit_piece 0x20 0x0)
The debug_loc(.dwo) dumping in changed accordingly to factor the code.
Reviewers: dblaikie, aprantl, friss
Subscribers: mgorny, javed.absar, hiraditya, llvm-commits, JDevlieghere
Differential Revision: https://reviews.llvm.org/D37123
llvm-svn: 312042
2017-08-29 21:41:21 +00:00
|
|
|
|
|
|
|
LL.Entries.push_back(std::move(E));
|
|
|
|
}
|
|
|
|
return LL;
|
|
|
|
}
|
|
|
|
|
2018-10-25 10:56:44 +00:00
|
|
|
void DWARFDebugLoclists::parse(DataExtractor data, unsigned Version) {
|
[dwarfdump] Pretty print location expressions and location lists
Summary:
Based on Fred's patch here: https://reviews.llvm.org/D6771
I can't seem to commandeer the old review, so I'm creating a new one.
With that change the locations exrpessions are pretty printed inline in the
DIE tree. The output looks like this for debug_loc entries:
DW_AT_location [DW_FORM_data4] (0x00000000
0x0000000000000001 - 0x000000000000000b: DW_OP_consts +3
0x000000000000000b - 0x0000000000000012: DW_OP_consts +7
0x0000000000000012 - 0x000000000000001b: DW_OP_reg0 RAX, DW_OP_piece 0x4
0x000000000000001b - 0x0000000000000024: DW_OP_breg5 RDI+0)
And like this for debug_loc.dwo entries:
DW_AT_location [DW_FORM_sec_offset] (0x00000000
Addr idx 2 (w/ length 190): DW_OP_consts +0, DW_OP_stack_value
Addr idx 3 (w/ length 23): DW_OP_reg0 RAX, DW_OP_piece 0x4)
Simple locations without ranges are printed inline:
DW_AT_location [DW_FORM_block1] (DW_OP_reg4 RSI, DW_OP_piece 0x4, DW_OP_bit_piece 0x20 0x0)
The debug_loc(.dwo) dumping in changed accordingly to factor the code.
Reviewers: dblaikie, aprantl, friss
Subscribers: mgorny, javed.absar, hiraditya, llvm-commits, JDevlieghere
Differential Revision: https://reviews.llvm.org/D37123
llvm-svn: 312042
2017-08-29 21:41:21 +00:00
|
|
|
IsLittleEndian = data.isLittleEndian();
|
|
|
|
AddressSize = data.getAddressSize();
|
|
|
|
|
2014-03-25 01:44:02 +00:00
|
|
|
uint32_t Offset = 0;
|
|
|
|
while (data.isValidOffset(Offset)) {
|
2018-10-25 10:56:44 +00:00
|
|
|
if (auto LL = parseOneLocationList(data, &Offset, Version))
|
[dwarfdump] Pretty print location expressions and location lists
Summary:
Based on Fred's patch here: https://reviews.llvm.org/D6771
I can't seem to commandeer the old review, so I'm creating a new one.
With that change the locations exrpessions are pretty printed inline in the
DIE tree. The output looks like this for debug_loc entries:
DW_AT_location [DW_FORM_data4] (0x00000000
0x0000000000000001 - 0x000000000000000b: DW_OP_consts +3
0x000000000000000b - 0x0000000000000012: DW_OP_consts +7
0x0000000000000012 - 0x000000000000001b: DW_OP_reg0 RAX, DW_OP_piece 0x4
0x000000000000001b - 0x0000000000000024: DW_OP_breg5 RDI+0)
And like this for debug_loc.dwo entries:
DW_AT_location [DW_FORM_sec_offset] (0x00000000
Addr idx 2 (w/ length 190): DW_OP_consts +0, DW_OP_stack_value
Addr idx 3 (w/ length 23): DW_OP_reg0 RAX, DW_OP_piece 0x4)
Simple locations without ranges are printed inline:
DW_AT_location [DW_FORM_block1] (DW_OP_reg4 RSI, DW_OP_piece 0x4, DW_OP_bit_piece 0x20 0x0)
The debug_loc(.dwo) dumping in changed accordingly to factor the code.
Reviewers: dblaikie, aprantl, friss
Subscribers: mgorny, javed.absar, hiraditya, llvm-commits, JDevlieghere
Differential Revision: https://reviews.llvm.org/D37123
llvm-svn: 312042
2017-08-29 21:41:21 +00:00
|
|
|
Locations.push_back(std::move(*LL));
|
|
|
|
else
|
|
|
|
return;
|
2014-03-25 01:44:02 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-10-22 11:30:54 +00:00
|
|
|
DWARFDebugLoclists::LocationList const *
|
|
|
|
DWARFDebugLoclists::getLocationListAtOffset(uint64_t Offset) const {
|
2017-09-27 09:33:36 +00:00
|
|
|
auto It = std::lower_bound(
|
|
|
|
Locations.begin(), Locations.end(), Offset,
|
|
|
|
[](const LocationList &L, uint64_t Offset) { return L.Offset < Offset; });
|
|
|
|
if (It != Locations.end() && It->Offset == Offset)
|
|
|
|
return &(*It);
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
2018-10-22 11:30:54 +00:00
|
|
|
void DWARFDebugLoclists::LocationList::dump(raw_ostream &OS, uint64_t BaseAddr,
|
|
|
|
bool IsLittleEndian,
|
|
|
|
unsigned AddressSize,
|
|
|
|
const MCRegisterInfo *MRI,
|
|
|
|
unsigned Indent) const {
|
[dwarfdump] Pretty print location expressions and location lists
Summary:
Based on Fred's patch here: https://reviews.llvm.org/D6771
I can't seem to commandeer the old review, so I'm creating a new one.
With that change the locations exrpessions are pretty printed inline in the
DIE tree. The output looks like this for debug_loc entries:
DW_AT_location [DW_FORM_data4] (0x00000000
0x0000000000000001 - 0x000000000000000b: DW_OP_consts +3
0x000000000000000b - 0x0000000000000012: DW_OP_consts +7
0x0000000000000012 - 0x000000000000001b: DW_OP_reg0 RAX, DW_OP_piece 0x4
0x000000000000001b - 0x0000000000000024: DW_OP_breg5 RDI+0)
And like this for debug_loc.dwo entries:
DW_AT_location [DW_FORM_sec_offset] (0x00000000
Addr idx 2 (w/ length 190): DW_OP_consts +0, DW_OP_stack_value
Addr idx 3 (w/ length 23): DW_OP_reg0 RAX, DW_OP_piece 0x4)
Simple locations without ranges are printed inline:
DW_AT_location [DW_FORM_block1] (DW_OP_reg4 RSI, DW_OP_piece 0x4, DW_OP_bit_piece 0x20 0x0)
The debug_loc(.dwo) dumping in changed accordingly to factor the code.
Reviewers: dblaikie, aprantl, friss
Subscribers: mgorny, javed.absar, hiraditya, llvm-commits, JDevlieghere
Differential Revision: https://reviews.llvm.org/D37123
llvm-svn: 312042
2017-08-29 21:41:21 +00:00
|
|
|
for (const Entry &E : Entries) {
|
2018-10-22 11:30:54 +00:00
|
|
|
switch (E.Kind) {
|
|
|
|
case dwarf::DW_LLE_startx_length:
|
|
|
|
OS << '\n';
|
|
|
|
OS.indent(Indent);
|
|
|
|
OS << "Addr idx " << E.Value0 << " (w/ length " << E.Value1 << "): ";
|
|
|
|
break;
|
|
|
|
case dwarf::DW_LLE_start_length:
|
|
|
|
OS << '\n';
|
|
|
|
OS.indent(Indent);
|
2018-11-16 13:14:26 +00:00
|
|
|
OS << format("[0x%*.*" PRIx64 ", 0x%*.*" PRIx64 "): ", AddressSize * 2,
|
2018-10-22 12:18:30 +00:00
|
|
|
AddressSize * 2, E.Value0, AddressSize * 2, AddressSize * 2,
|
|
|
|
E.Value0 + E.Value1);
|
2018-10-22 11:30:54 +00:00
|
|
|
break;
|
|
|
|
case dwarf::DW_LLE_offset_pair:
|
|
|
|
OS << '\n';
|
|
|
|
OS.indent(Indent);
|
2018-11-16 13:14:26 +00:00
|
|
|
OS << format("[0x%*.*" PRIx64 ", 0x%*.*" PRIx64 "): ", AddressSize * 2,
|
2018-10-22 12:18:30 +00:00
|
|
|
AddressSize * 2, BaseAddr + E.Value0, AddressSize * 2,
|
|
|
|
AddressSize * 2, BaseAddr + E.Value1);
|
2018-10-22 11:30:54 +00:00
|
|
|
break;
|
|
|
|
case dwarf::DW_LLE_base_address:
|
|
|
|
BaseAddr = E.Value0;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
llvm_unreachable("unreachable locations list kind");
|
|
|
|
}
|
|
|
|
|
2019-02-21 08:20:24 +00:00
|
|
|
dumpExpression(OS, E.Loc, IsLittleEndian, AddressSize, MRI, nullptr);
|
[dwarfdump] Pretty print location expressions and location lists
Summary:
Based on Fred's patch here: https://reviews.llvm.org/D6771
I can't seem to commandeer the old review, so I'm creating a new one.
With that change the locations exrpessions are pretty printed inline in the
DIE tree. The output looks like this for debug_loc entries:
DW_AT_location [DW_FORM_data4] (0x00000000
0x0000000000000001 - 0x000000000000000b: DW_OP_consts +3
0x000000000000000b - 0x0000000000000012: DW_OP_consts +7
0x0000000000000012 - 0x000000000000001b: DW_OP_reg0 RAX, DW_OP_piece 0x4
0x000000000000001b - 0x0000000000000024: DW_OP_breg5 RDI+0)
And like this for debug_loc.dwo entries:
DW_AT_location [DW_FORM_sec_offset] (0x00000000
Addr idx 2 (w/ length 190): DW_OP_consts +0, DW_OP_stack_value
Addr idx 3 (w/ length 23): DW_OP_reg0 RAX, DW_OP_piece 0x4)
Simple locations without ranges are printed inline:
DW_AT_location [DW_FORM_block1] (DW_OP_reg4 RSI, DW_OP_piece 0x4, DW_OP_bit_piece 0x20 0x0)
The debug_loc(.dwo) dumping in changed accordingly to factor the code.
Reviewers: dblaikie, aprantl, friss
Subscribers: mgorny, javed.absar, hiraditya, llvm-commits, JDevlieghere
Differential Revision: https://reviews.llvm.org/D37123
llvm-svn: 312042
2017-08-29 21:41:21 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-10-22 11:30:54 +00:00
|
|
|
void DWARFDebugLoclists::dump(raw_ostream &OS, uint64_t BaseAddr,
|
|
|
|
const MCRegisterInfo *MRI,
|
|
|
|
Optional<uint64_t> Offset) const {
|
2017-09-27 09:33:36 +00:00
|
|
|
auto DumpLocationList = [&](const LocationList &L) {
|
2014-03-25 01:44:02 +00:00
|
|
|
OS << format("0x%8.8x: ", L.Offset);
|
2018-10-22 11:30:54 +00:00
|
|
|
L.dump(OS, BaseAddr, IsLittleEndian, AddressSize, MRI, /*Indent=*/12);
|
[dwarfdump] Pretty print location expressions and location lists
Summary:
Based on Fred's patch here: https://reviews.llvm.org/D6771
I can't seem to commandeer the old review, so I'm creating a new one.
With that change the locations exrpessions are pretty printed inline in the
DIE tree. The output looks like this for debug_loc entries:
DW_AT_location [DW_FORM_data4] (0x00000000
0x0000000000000001 - 0x000000000000000b: DW_OP_consts +3
0x000000000000000b - 0x0000000000000012: DW_OP_consts +7
0x0000000000000012 - 0x000000000000001b: DW_OP_reg0 RAX, DW_OP_piece 0x4
0x000000000000001b - 0x0000000000000024: DW_OP_breg5 RDI+0)
And like this for debug_loc.dwo entries:
DW_AT_location [DW_FORM_sec_offset] (0x00000000
Addr idx 2 (w/ length 190): DW_OP_consts +0, DW_OP_stack_value
Addr idx 3 (w/ length 23): DW_OP_reg0 RAX, DW_OP_piece 0x4)
Simple locations without ranges are printed inline:
DW_AT_location [DW_FORM_block1] (DW_OP_reg4 RSI, DW_OP_piece 0x4, DW_OP_bit_piece 0x20 0x0)
The debug_loc(.dwo) dumping in changed accordingly to factor the code.
Reviewers: dblaikie, aprantl, friss
Subscribers: mgorny, javed.absar, hiraditya, llvm-commits, JDevlieghere
Differential Revision: https://reviews.llvm.org/D37123
llvm-svn: 312042
2017-08-29 21:41:21 +00:00
|
|
|
OS << "\n\n";
|
2017-09-27 09:33:36 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
if (Offset) {
|
|
|
|
if (auto *L = getLocationListAtOffset(*Offset))
|
|
|
|
DumpLocationList(*L);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (const LocationList &L : Locations) {
|
|
|
|
DumpLocationList(L);
|
2014-03-25 01:44:02 +00:00
|
|
|
}
|
|
|
|
}
|