comparison lib/DebugInfo/DWARF/DWARFDebugMacro.cpp @ 147:c2174574ed3a

LLVM 10
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Wed, 14 Aug 2019 16:55:33 +0900
parents 803732b1fca8
children
comparison
equal deleted inserted replaced
134:3a76565eade5 147:c2174574ed3a
1 //===- DWARFDebugMacro.cpp ------------------------------------------------===// 1 //===- DWARFDebugMacro.cpp ------------------------------------------------===//
2 // 2 //
3 // The LLVM Compiler Infrastructure 3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // 4 // See https://llvm.org/LICENSE.txt for license information.
5 // This file is distributed under the University of Illinois Open Source 5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 // License. See LICENSE.TXT for details.
7 // 6 //
8 //===----------------------------------------------------------------------===// 7 //===----------------------------------------------------------------------===//
9 8
10 #include "llvm/DebugInfo/DWARF/DWARFDebugMacro.h" 9 #include "llvm/DebugInfo/DWARF/DWARFDebugMacro.h"
11 #include "SyntaxHighlighting.h"
12 #include "llvm/BinaryFormat/Dwarf.h" 10 #include "llvm/BinaryFormat/Dwarf.h"
11 #include "llvm/Support/WithColor.h"
13 #include "llvm/Support/raw_ostream.h" 12 #include "llvm/Support/raw_ostream.h"
14 #include <cstdint> 13 #include <cstdint>
15 14
16 using namespace llvm; 15 using namespace llvm;
17 using namespace dwarf; 16 using namespace dwarf;
18 using namespace syntax;
19 17
20 void DWARFDebugMacro::dump(raw_ostream &OS) const { 18 void DWARFDebugMacro::dump(raw_ostream &OS) const {
21 unsigned IndLevel = 0; 19 unsigned IndLevel = 0;
22 for (const Entry &E : Macros) { 20 for (const Entry &E : Macros) {
23 // There should not be DW_MACINFO_end_file when IndLevel is Zero. However, 21 // There should not be DW_MACINFO_end_file when IndLevel is Zero. However,
27 // Print indentation. 25 // Print indentation.
28 for (unsigned I = 0; I < IndLevel; I++) 26 for (unsigned I = 0; I < IndLevel; I++)
29 OS << " "; 27 OS << " ";
30 IndLevel += (E.Type == DW_MACINFO_start_file); 28 IndLevel += (E.Type == DW_MACINFO_start_file);
31 29
32 WithColor(OS, syntax::Macro).get() << MacinfoString(E.Type); 30 WithColor(OS, HighlightColor::Macro).get() << MacinfoString(E.Type);
33 switch (E.Type) { 31 switch (E.Type) {
34 default: 32 default:
35 // Got a corrupted ".debug_macinfo" section (invalid macinfo type). 33 // Got a corrupted ".debug_macinfo" section (invalid macinfo type).
36 break; 34 break;
37 case DW_MACINFO_define: 35 case DW_MACINFO_define:
53 OS << "\n"; 51 OS << "\n";
54 } 52 }
55 } 53 }
56 54
57 void DWARFDebugMacro::parse(DataExtractor data) { 55 void DWARFDebugMacro::parse(DataExtractor data) {
58 uint32_t Offset = 0; 56 uint64_t Offset = 0;
59 while (data.isValidOffset(Offset)) { 57 while (data.isValidOffset(Offset)) {
60 // A macro list entry consists of: 58 // A macro list entry consists of:
61 Entry E; 59 Entry E;
62 // 1. Macinfo type 60 // 1. Macinfo type
63 E.Type = data.getULEB128(&Offset); 61 E.Type = data.getULEB128(&Offset);