Convert two llvm source files to native line ending, which was also done
upstream. Merging doesn't automatically do this, unfortunately.
This commit is contained in:
parent
e74e149f78
commit
1dcfcfee2a
@ -1,59 +1,59 @@
|
|||||||
//===-- DWARFDebugMacro.h ---------------------------------------*- C++ -*-===//
|
//===-- DWARFDebugMacro.h ---------------------------------------*- C++ -*-===//
|
||||||
//
|
//
|
||||||
// The LLVM Compiler Infrastructure
|
// The LLVM Compiler Infrastructure
|
||||||
//
|
//
|
||||||
// This file is distributed under the University of Illinois Open Source
|
// This file is distributed under the University of Illinois Open Source
|
||||||
// License. See LICENSE.TXT for details.
|
// License. See LICENSE.TXT for details.
|
||||||
//
|
//
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
|
|
||||||
#ifndef LLVM_DEBUGINFO_DWARF_DWARFDEBUGMACRO_H
|
#ifndef LLVM_DEBUGINFO_DWARF_DWARFDEBUGMACRO_H
|
||||||
#define LLVM_DEBUGINFO_DWARF_DWARFDEBUGMACRO_H
|
#define LLVM_DEBUGINFO_DWARF_DWARFDEBUGMACRO_H
|
||||||
|
|
||||||
#include "llvm/ADT/SmallVector.h"
|
#include "llvm/ADT/SmallVector.h"
|
||||||
#include "llvm/ADT/StringRef.h"
|
#include "llvm/ADT/StringRef.h"
|
||||||
#include "llvm/Support/DataExtractor.h"
|
#include "llvm/Support/DataExtractor.h"
|
||||||
#include "llvm/Support/Dwarf.h"
|
#include "llvm/Support/Dwarf.h"
|
||||||
|
|
||||||
namespace llvm {
|
namespace llvm {
|
||||||
|
|
||||||
class raw_ostream;
|
class raw_ostream;
|
||||||
|
|
||||||
class DWARFDebugMacro {
|
class DWARFDebugMacro {
|
||||||
/// A single macro entry within a macro list.
|
/// A single macro entry within a macro list.
|
||||||
struct Entry {
|
struct Entry {
|
||||||
/// The type of the macro entry.
|
/// The type of the macro entry.
|
||||||
uint32_t Type;
|
uint32_t Type;
|
||||||
union {
|
union {
|
||||||
/// The source line where the macro is defined.
|
/// The source line where the macro is defined.
|
||||||
uint64_t Line;
|
uint64_t Line;
|
||||||
/// Vendor extension constant value.
|
/// Vendor extension constant value.
|
||||||
uint64_t ExtConstant;
|
uint64_t ExtConstant;
|
||||||
};
|
};
|
||||||
|
|
||||||
union {
|
union {
|
||||||
/// The string (name, value) of the macro entry.
|
/// The string (name, value) of the macro entry.
|
||||||
const char *MacroStr;
|
const char *MacroStr;
|
||||||
// An unsigned integer indicating the identity of the source file.
|
// An unsigned integer indicating the identity of the source file.
|
||||||
uint64_t File;
|
uint64_t File;
|
||||||
/// Vendor extension string.
|
/// Vendor extension string.
|
||||||
const char *ExtStr;
|
const char *ExtStr;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef SmallVector<Entry, 4> MacroList;
|
typedef SmallVector<Entry, 4> MacroList;
|
||||||
|
|
||||||
/// A list of all the macro entries in the debug_macinfo section.
|
/// A list of all the macro entries in the debug_macinfo section.
|
||||||
MacroList Macros;
|
MacroList Macros;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
DWARFDebugMacro() {}
|
DWARFDebugMacro() {}
|
||||||
/// Print the macro list found within the debug_macinfo section.
|
/// Print the macro list found within the debug_macinfo section.
|
||||||
void dump(raw_ostream &OS) const;
|
void dump(raw_ostream &OS) const;
|
||||||
/// Parse the debug_macinfo section accessible via the 'data' parameter.
|
/// Parse the debug_macinfo section accessible via the 'data' parameter.
|
||||||
void parse(DataExtractor data);
|
void parse(DataExtractor data);
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -1,103 +1,103 @@
|
|||||||
//===-- DWARFDebugMacro.cpp -----------------------------------------------===//
|
//===-- DWARFDebugMacro.cpp -----------------------------------------------===//
|
||||||
//
|
//
|
||||||
// The LLVM Compiler Infrastructure
|
// The LLVM Compiler Infrastructure
|
||||||
//
|
//
|
||||||
// This file is distributed under the University of Illinois Open Source
|
// This file is distributed under the University of Illinois Open Source
|
||||||
// License. See LICENSE.TXT for details.
|
// License. See LICENSE.TXT for details.
|
||||||
//
|
//
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
|
|
||||||
#include "SyntaxHighlighting.h"
|
#include "SyntaxHighlighting.h"
|
||||||
#include "llvm/DebugInfo/DWARF/DWARFDebugMacro.h"
|
#include "llvm/DebugInfo/DWARF/DWARFDebugMacro.h"
|
||||||
#include "llvm/Support/Compiler.h"
|
#include "llvm/Support/Compiler.h"
|
||||||
#include "llvm/Support/Dwarf.h"
|
#include "llvm/Support/Dwarf.h"
|
||||||
#include "llvm/Support/Format.h"
|
#include "llvm/Support/Format.h"
|
||||||
#include "llvm/Support/raw_ostream.h"
|
#include "llvm/Support/raw_ostream.h"
|
||||||
|
|
||||||
using namespace llvm;
|
using namespace llvm;
|
||||||
using namespace dwarf;
|
using namespace dwarf;
|
||||||
using namespace syntax;
|
using namespace syntax;
|
||||||
|
|
||||||
void DWARFDebugMacro::dump(raw_ostream &OS) const {
|
void DWARFDebugMacro::dump(raw_ostream &OS) const {
|
||||||
unsigned IndLevel = 0;
|
unsigned IndLevel = 0;
|
||||||
for (const Entry &E : Macros) {
|
for (const Entry &E : Macros) {
|
||||||
// There should not be DW_MACINFO_end_file when IndLevel is Zero. However,
|
// There should not be DW_MACINFO_end_file when IndLevel is Zero. However,
|
||||||
// this check handles the case of corrupted ".debug_macinfo" section.
|
// this check handles the case of corrupted ".debug_macinfo" section.
|
||||||
if (IndLevel > 0)
|
if (IndLevel > 0)
|
||||||
IndLevel -= (E.Type == DW_MACINFO_end_file);
|
IndLevel -= (E.Type == DW_MACINFO_end_file);
|
||||||
// Print indentation.
|
// Print indentation.
|
||||||
for (unsigned I = 0; I < IndLevel; I++)
|
for (unsigned I = 0; I < IndLevel; I++)
|
||||||
OS << " ";
|
OS << " ";
|
||||||
IndLevel += (E.Type == DW_MACINFO_start_file);
|
IndLevel += (E.Type == DW_MACINFO_start_file);
|
||||||
|
|
||||||
WithColor(OS, syntax::Macro).get() << MacinfoString(E.Type);
|
WithColor(OS, syntax::Macro).get() << MacinfoString(E.Type);
|
||||||
switch (E.Type) {
|
switch (E.Type) {
|
||||||
default:
|
default:
|
||||||
// Got a corrupted ".debug_macinfo" section (invalid macinfo type).
|
// Got a corrupted ".debug_macinfo" section (invalid macinfo type).
|
||||||
break;
|
break;
|
||||||
case DW_MACINFO_define:
|
case DW_MACINFO_define:
|
||||||
case DW_MACINFO_undef:
|
case DW_MACINFO_undef:
|
||||||
OS << " - lineno: " << E.Line;
|
OS << " - lineno: " << E.Line;
|
||||||
OS << " macro: " << E.MacroStr;
|
OS << " macro: " << E.MacroStr;
|
||||||
break;
|
break;
|
||||||
case DW_MACINFO_start_file:
|
case DW_MACINFO_start_file:
|
||||||
OS << " - lineno: " << E.Line;
|
OS << " - lineno: " << E.Line;
|
||||||
OS << " filenum: " << E.File;
|
OS << " filenum: " << E.File;
|
||||||
break;
|
break;
|
||||||
case DW_MACINFO_end_file:
|
case DW_MACINFO_end_file:
|
||||||
break;
|
break;
|
||||||
case DW_MACINFO_vendor_ext:
|
case DW_MACINFO_vendor_ext:
|
||||||
OS << " - constant: " << E.ExtConstant;
|
OS << " - constant: " << E.ExtConstant;
|
||||||
OS << " string: " << E.ExtStr;
|
OS << " string: " << E.ExtStr;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
OS << "\n";
|
OS << "\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void DWARFDebugMacro::parse(DataExtractor data) {
|
void DWARFDebugMacro::parse(DataExtractor data) {
|
||||||
uint32_t Offset = 0;
|
uint32_t Offset = 0;
|
||||||
while (data.isValidOffset(Offset)) {
|
while (data.isValidOffset(Offset)) {
|
||||||
// A macro list entry consists of:
|
// A macro list entry consists of:
|
||||||
Entry E;
|
Entry E;
|
||||||
// 1. Macinfo type
|
// 1. Macinfo type
|
||||||
E.Type = data.getULEB128(&Offset);
|
E.Type = data.getULEB128(&Offset);
|
||||||
|
|
||||||
if (E.Type == 0) {
|
if (E.Type == 0) {
|
||||||
// Reached end of ".debug_macinfo" section.
|
// Reached end of ".debug_macinfo" section.
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (E.Type) {
|
switch (E.Type) {
|
||||||
default:
|
default:
|
||||||
// Got a corrupted ".debug_macinfo" section (invalid macinfo type).
|
// Got a corrupted ".debug_macinfo" section (invalid macinfo type).
|
||||||
// Push the corrupted entry to the list and halt parsing.
|
// Push the corrupted entry to the list and halt parsing.
|
||||||
E.Type = DW_MACINFO_invalid;
|
E.Type = DW_MACINFO_invalid;
|
||||||
Macros.push_back(E);
|
Macros.push_back(E);
|
||||||
return;
|
return;
|
||||||
case DW_MACINFO_define:
|
case DW_MACINFO_define:
|
||||||
case DW_MACINFO_undef:
|
case DW_MACINFO_undef:
|
||||||
// 2. Source line
|
// 2. Source line
|
||||||
E.Line = data.getULEB128(&Offset);
|
E.Line = data.getULEB128(&Offset);
|
||||||
// 3. Macro string
|
// 3. Macro string
|
||||||
E.MacroStr = data.getCStr(&Offset);
|
E.MacroStr = data.getCStr(&Offset);
|
||||||
break;
|
break;
|
||||||
case DW_MACINFO_start_file:
|
case DW_MACINFO_start_file:
|
||||||
// 2. Source line
|
// 2. Source line
|
||||||
E.Line = data.getULEB128(&Offset);
|
E.Line = data.getULEB128(&Offset);
|
||||||
// 3. Source file id
|
// 3. Source file id
|
||||||
E.File = data.getULEB128(&Offset);
|
E.File = data.getULEB128(&Offset);
|
||||||
break;
|
break;
|
||||||
case DW_MACINFO_end_file:
|
case DW_MACINFO_end_file:
|
||||||
break;
|
break;
|
||||||
case DW_MACINFO_vendor_ext:
|
case DW_MACINFO_vendor_ext:
|
||||||
// 2. Vendor extension constant
|
// 2. Vendor extension constant
|
||||||
E.ExtConstant = data.getULEB128(&Offset);
|
E.ExtConstant = data.getULEB128(&Offset);
|
||||||
// 3. Vendor extension string
|
// 3. Vendor extension string
|
||||||
E.ExtStr = data.getCStr(&Offset);
|
E.ExtStr = data.getCStr(&Offset);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
Macros.push_back(E);
|
Macros.push_back(E);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user