[llvm-debuginfo-analyzer] Add support for parsing DWARF / CodeView SourceLanguage (#137223)

This pull request adds support for parsing the source language in both
DWARF and CodeView. Specifically,

- The `LVSourceLanguage` class is introduced to represent any supported
language by any of the debug info representations.

- Update `LVDWARFReader.cpp` and `LVCodeViewVisitor.cpp` to parse the
source language where it applies. Added a new `=Language` attribute;
`getAttributeLanguage()` is internally used to control whether this
information is being printed.
This commit is contained in:
Javier Lopez-Gomez
2025-06-06 16:03:07 +02:00
committed by GitHub
parent 7809b147fa
commit 0f38c54c6f
32 changed files with 202 additions and 22 deletions

View File

@@ -134,12 +134,13 @@ toolchain name, binary file format, etc.
The following attributes describe the most common information for a
logical element. They help to identify the lexical scope level; the
element visibility across modules (global, local); the toolchain name
that produced the binary file.
and source language that produced the binary file.
.. code-block:: text
=global: Element referenced across Compile Units.
=format: Object file format name.
=language: Source language name.
=level: Lexical scope level (File=0, Compile Unit=1).
=local: Element referenced only in the Compile Unit.
=producer: Toolchain identification name.
@@ -231,6 +232,7 @@ toolchain name, binary file format, etc.
=filename
=files
=format
=language
=level
=producer
=publics

View File

@@ -15,6 +15,7 @@
#define LLVM_DEBUGINFO_LOGICALVIEW_CORE_LVELEMENT_H
#include "llvm/DebugInfo/LogicalView/Core/LVObject.h"
#include "llvm/DebugInfo/LogicalView/Core/LVSourceLanguage.h"
#include "llvm/Support/Casting.h"
#include "llvm/Support/Compiler.h"
#include "llvm/Support/MathExtras.h"
@@ -221,6 +222,9 @@ public:
virtual StringRef getProducer() const { return StringRef(); }
virtual void setProducer(StringRef ProducerName) {}
virtual LVSourceLanguage getSourceLanguage() const { return {}; }
virtual void setSourceLanguage(LVSourceLanguage SL) {}
virtual bool isCompileUnit() const { return false; }
virtual bool isRoot() const { return false; }

View File

@@ -107,6 +107,7 @@ enum class LVAttributeKind {
Generated, // --attribute=generated
Global, // --attribute=global
Inserted, // --attribute=inserted
Language, // --attribute=language
Level, // --attribute=level
Linkage, // --attribute=linkage
Local, // --attribute=local
@@ -338,6 +339,7 @@ public:
ATTRIBUTE_OPTION(Generated);
ATTRIBUTE_OPTION(Global);
ATTRIBUTE_OPTION(Inserted);
ATTRIBUTE_OPTION(Language);
ATTRIBUTE_OPTION(Level);
ATTRIBUTE_OPTION(Linkage);
ATTRIBUTE_OPTION(Location);

View File

@@ -419,6 +419,9 @@ class LLVM_ABI LVScopeCompileUnit final : public LVScope {
// Compilation directory name.
size_t CompilationDirectoryIndex = 0;
// Source language.
LVSourceLanguage SourceLanguage{};
// Used by the CodeView Reader.
codeview::CPUType CompilationCPUType = codeview::CPUType::X64;
@@ -549,6 +552,9 @@ public:
ProducerIndex = getStringPool().getIndex(ProducerName);
}
LVSourceLanguage getSourceLanguage() const override { return SourceLanguage; }
void setSourceLanguage(LVSourceLanguage SL) override { SourceLanguage = SL; }
void setCPUType(codeview::CPUType Type) { CompilationCPUType = Type; }
codeview::CPUType getCPUType() { return CompilationCPUType; }

View File

@@ -0,0 +1,69 @@
//===-- LVSourceLanguage.h --------------------------------------*- C++ -*-===//
//
// 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
//
//===----------------------------------------------------------------------===//
//
// This file defines the LVSourceLanguage struct, a unified representation of
// the source language used in a compile unit.
//
//===----------------------------------------------------------------------===//
#ifndef LLVM_DEBUGINFO_LOGICALVIEW_CORE_LVSOURCELANGUAGE_H
#define LLVM_DEBUGINFO_LOGICALVIEW_CORE_LVSOURCELANGUAGE_H
#include "llvm/ADT/StringRef.h"
#include "llvm/BinaryFormat/Dwarf.h"
#include "llvm/DebugInfo/CodeView/CodeView.h"
namespace llvm {
namespace logicalview {
/// A source language supported by any of the debug info representations.
struct LVSourceLanguage {
static constexpr unsigned TagDwarf = 0x00;
static constexpr unsigned TagCodeView = 0x01;
enum TaggedLanguage : uint32_t {
Invalid = -1U,
// DWARF
#define HANDLE_DW_LANG(ID, NAME, LOWER_BOUND, VERSION, VENDOR) \
DW_LANG_##NAME = (TagDwarf << 16) | ID,
#include "llvm/BinaryFormat/Dwarf.def"
// CodeView
#define CV_LANGUAGE(NAME, ID) CV_LANG_##NAME = (TagCodeView << 16) | ID,
#include "llvm/DebugInfo/CodeView/CodeViewLanguages.def"
};
LVSourceLanguage() = default;
LVSourceLanguage(llvm::dwarf::SourceLanguage SL)
: LVSourceLanguage(TagDwarf, SL) {}
LVSourceLanguage(llvm::codeview::SourceLanguage SL)
: LVSourceLanguage(TagCodeView, SL) {}
bool operator==(const LVSourceLanguage &SL) const {
return get() == SL.get();
}
bool operator==(const LVSourceLanguage::TaggedLanguage &TL) const {
return get() == TL;
}
bool isValid() const { return Language != Invalid; }
TaggedLanguage get() const { return Language; }
StringRef getName() const;
private:
TaggedLanguage Language = Invalid;
LVSourceLanguage(unsigned Tag, unsigned Lang)
: Language(static_cast<TaggedLanguage>((Tag << 16) | Lang)) {}
unsigned getTag() const { return Language >> 16; }
unsigned getLang() const { return Language & 0xffff; }
};
} // end namespace logicalview
} // end namespace llvm
#endif // LLVM_DEBUGINFO_LOGICALVIEW_CORE_LVSOURCELANGUAGE_H

View File

@@ -14,6 +14,7 @@ add_lv_impl_folder(Core
Core/LVReader.cpp
Core/LVScope.cpp
Core/LVSort.cpp
Core/LVSourceLanguage.cpp
Core/LVSupport.cpp
Core/LVSymbol.cpp
Core/LVType.cpp

View File

@@ -39,6 +39,7 @@ void LVOptions::resolveDependencies() {
setAttributeFilename();
setAttributeFiles();
setAttributeFormat();
setAttributeLanguage();
setAttributeLevel();
setAttributeProducer();
setAttributePublics();

View File

@@ -1717,11 +1717,19 @@ void LVScopeCompileUnit::print(raw_ostream &OS, bool Full) const {
void LVScopeCompileUnit::printExtra(raw_ostream &OS, bool Full) const {
OS << formattedKind(kind()) << " '" << getName() << "'\n";
if (options().getPrintFormatting() && options().getAttributeProducer())
printAttributes(OS, Full, "{Producer} ",
const_cast<LVScopeCompileUnit *>(this), getProducer(),
/*UseQuotes=*/true,
/*PrintRef=*/false);
if (options().getPrintFormatting()) {
if (options().getAttributeProducer())
printAttributes(OS, Full, "{Producer} ",
const_cast<LVScopeCompileUnit *>(this), getProducer(),
/*UseQuotes=*/true,
/*PrintRef=*/false);
if (options().getAttributeLanguage())
if (auto SL = getSourceLanguage(); SL.isValid())
printAttributes(OS, Full, "{Language} ",
const_cast<LVScopeCompileUnit *>(this), SL.getName(),
/*UseQuotes=*/true,
/*PrintRef=*/false);
}
// Reset file index, to allow its children to print the correct filename.
options().resetFilenameIndex();

View File

@@ -0,0 +1,33 @@
//===-- LVSourceLanguage.cpp ----------------------------------------------===//
//
// 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
//
//===----------------------------------------------------------------------===//
//
// This file implements LVSourceLanguage.
//
//===----------------------------------------------------------------------===//
#include "llvm/DebugInfo/LogicalView/Core/LVSourceLanguage.h"
#include "llvm/DebugInfo/CodeView/EnumTables.h"
#include "llvm/Support/ScopedPrinter.h"
using namespace llvm;
using namespace llvm::logicalview;
StringRef LVSourceLanguage::getName() const {
if (!isValid())
return {};
switch (getTag()) {
case LVSourceLanguage::TagDwarf:
return llvm::dwarf::LanguageString(getLang());
case LVSourceLanguage::TagCodeView: {
static auto LangNames = llvm::codeview::getSourceLanguageNames();
return LangNames[getLang()].Name;
}
default:
llvm_unreachable("Unsupported language");
}
}

View File

@@ -949,6 +949,9 @@ Error LVSymbolVisitor::visitKnownRecord(CVSymbol &Record,
Scope->setName(CurrentObjectName);
if (options().getAttributeProducer())
Scope->setProducer(Compile2.Version);
if (options().getAttributeLanguage())
Scope->setSourceLanguage(LVSourceLanguage{
static_cast<llvm::codeview::SourceLanguage>(Compile2.getLanguage())});
getReader().isSystemEntry(Scope, CurrentObjectName);
// The line records in CodeView are recorded per Module ID. Update
@@ -994,6 +997,9 @@ Error LVSymbolVisitor::visitKnownRecord(CVSymbol &Record,
Scope->setName(CurrentObjectName);
if (options().getAttributeProducer())
Scope->setProducer(Compile3.Version);
if (options().getAttributeLanguage())
Scope->setSourceLanguage(LVSourceLanguage{
static_cast<llvm::codeview::SourceLanguage>(Compile3.getLanguage())});
getReader().isSystemEntry(Scope, CurrentObjectName);
// The line records in CodeView are recorded per Module ID. Update

View File

@@ -172,6 +172,11 @@ void LVDWARFReader::processOneAttribute(const DWARFDie &Die,
if (options().getAttributeProducer())
CurrentElement->setProducer(dwarf::toStringRef(FormValue));
break;
case dwarf::DW_AT_language:
if (options().getAttributeLanguage())
CurrentElement->setSourceLanguage(LVSourceLanguage{
static_cast<llvm::dwarf::SourceLanguage>(GetAsUnsignedConstant())});
break;
case dwarf::DW_AT_upper_bound:
CurrentElement->setUpperBound(GetBoundValue(FormValue));
break;

View File

@@ -15,7 +15,7 @@
; The logical views shows the intermixed lines and assembler instructions,
; allowing to compare the code generated by the different toolchains.
; RUN: llvm-debuginfo-analyzer --attribute=level,format,producer \
; RUN: llvm-debuginfo-analyzer --attribute=language,level,format,producer \
; RUN: --print=lines,instructions \
; RUN: %p/Inputs/hello-world-codeview-clang.o \
; RUN: %p/Inputs/hello-world-codeview-msvc.o 2>&1 | \
@@ -26,6 +26,7 @@
; ONE-EMPTY:
; ONE-NEXT: [001] {CompileUnit} 'hello-world.cpp'
; ONE-NEXT: [002] {Producer} 'clang version 15.0.0 {{.*}}'
; ONE-NEXT: [002] {Language} 'Cpp'
; ONE-NEXT: [002] {Function} extern not_inlined 'main' -> 'int'
; ONE-NEXT: [003] 4 {Line}
; ONE-NEXT: [003] {Code} 'subq $0x28, %rsp'
@@ -43,6 +44,7 @@
; ONE-EMPTY:
; ONE-NEXT: [001] {CompileUnit} 'hello-world.cpp'
; ONE-NEXT: [002] {Producer} 'Microsoft (R) Optimizing Compiler'
; ONE-NEXT: [002] {Language} 'Cpp'
; ONE-NEXT: [002] {Function} extern not_inlined 'main' -> 'int'
; ONE-NEXT: [003] 4 {Line}
; ONE-NEXT: [003] {Code} 'subq $0x28, %rsp'

View File

@@ -30,7 +30,7 @@
; emits both typedefs at the same lexical scope (3), which is wrong.
; GCC and MSVC emit correct lexical scope for both typedefs.
; RUN: llvm-debuginfo-analyzer --attribute=level,format,producer \
; RUN: llvm-debuginfo-analyzer --attribute=language,level,format,producer \
; RUN: --output-sort=kind \
; RUN: --print=symbols,types,lines \
; RUN: %p/Inputs/pr-44884-codeview-clang.o \
@@ -42,6 +42,7 @@
; ONE-EMPTY:
; ONE-NEXT: [001] {CompileUnit} 'pr-44884.cpp'
; ONE-NEXT: [002] {Producer} 'clang version 15.0.0 {{.*}}'
; ONE-NEXT: [002] {Language} 'Cpp'
; ONE-NEXT: [002] {Function} extern not_inlined 'bar' -> 'int'
; ONE-NEXT: [003] {Parameter} 'Input' -> 'float'
; ONE-NEXT: [003] 1 {Line}
@@ -63,6 +64,7 @@
; ONE-EMPTY:
; ONE-NEXT: [001] {CompileUnit} 'pr-44884.cpp'
; ONE-NEXT: [002] {Producer} 'Microsoft (R) Optimizing Compiler'
; ONE-NEXT: [002] {Language} 'Cpp'
; ONE-NEXT: [002] {Function} extern not_inlined 'bar' -> 'int'
; ONE-NEXT: [003] {Variable} 'Input' -> 'float'
; ONE-NEXT: [003] 1 {Line}

View File

@@ -25,7 +25,7 @@
; references to the enumerators 'RED' and 'BLUE'. The CodeView generated
; by GCC and MSVC, does include such references.
; RUN: llvm-debuginfo-analyzer --attribute=level,format,producer,size \
; RUN: llvm-debuginfo-analyzer --attribute=language,level,format,producer,size \
; RUN: --output-sort=name \
; RUN: --print=symbols,types \
; RUN: %p/Inputs/pr-46466-codeview-clang.o \
@@ -37,6 +37,7 @@
; ONE-EMPTY:
; ONE-NEXT: [001] {CompileUnit} 'pr-46466.cpp'
; ONE-NEXT: [002] {Producer} 'clang version 15.0.0 {{.*}}'
; ONE-NEXT: [002] {Language} 'Cpp'
; ONE-NEXT: [002] {Variable} extern 'S' -> 'Struct'
; ONE-NEXT: [002] 1 {Struct} 'Struct' [Size = 1]
; ONE-NEXT: [003] {Member} public 'U' -> 'Union'
@@ -50,6 +51,7 @@
; ONE-EMPTY:
; ONE-NEXT: [001] {CompileUnit} 'pr-46466.cpp'
; ONE-NEXT: [002] {Producer} 'Microsoft (R) Optimizing Compiler'
; ONE-NEXT: [002] {Language} 'Cpp'
; ONE-NEXT: [002] {Variable} extern 'S' -> 'Struct'
; ONE-NEXT: [002] 1 {Struct} 'Struct' [Size = 1]
; ONE-NEXT: [003] {Member} public 'U' -> 'Union'

View File

@@ -31,7 +31,7 @@
; The CodeView generated by MSVC, show those variables at the correct
; lexical scope: '3' and '4' respectively.
; RUN: llvm-debuginfo-analyzer --attribute=level,format,producer \
; RUN: llvm-debuginfo-analyzer --attribute=language,level,format,producer \
; RUN: --output-sort=name \
; RUN: --print=symbols \
; RUN: %p/Inputs/pr-43860-codeview-clang.o \
@@ -43,6 +43,7 @@
; ONE-EMPTY:
; ONE-NEXT: [001] {CompileUnit} 'pr-43860.cpp'
; ONE-NEXT: [002] {Producer} 'clang version 15.0.0 {{.*}}'
; ONE-NEXT: [002] {Language} 'Cpp'
; ONE-NEXT: [002] 2 {Function} inlined 'InlineFunction' -> 'int'
; ONE-NEXT: [003] {Parameter} '' -> 'int'
; ONE-NEXT: [002] {Function} extern not_inlined 'test' -> 'int'
@@ -59,6 +60,7 @@
; ONE-EMPTY:
; ONE-NEXT: [001] {CompileUnit} 'pr-43860.cpp'
; ONE-NEXT: [002] {Producer} 'Microsoft (R) Optimizing Compiler'
; ONE-NEXT: [002] {Language} 'Cpp'
; ONE-NEXT: [002] {Function} extern declared_inlined 'InlineFunction' -> 'int'
; ONE-NEXT: [003] {Block}
; ONE-NEXT: [004] {Variable} 'Var_2' -> 'int'

View File

@@ -28,6 +28,7 @@
; ONE-EMPTY:
; ONE-NEXT: [0x0000000000][001] {CompileUnit} 'test.cpp'
; ONE-NEXT: [0x0000000000][002] {Producer} 'clang version 15.0.0 {{.*}}'
; ONE-NEXT: [0x0000000000][002] {Language} 'Cpp'
; ONE-NEXT: {Directory} 'test.cpp'
; ONE-NEXT: {Directory} 'x:/tests/input'
; ONE-NEXT: {File} 'general'

View File

@@ -15,7 +15,7 @@
; The logical views shows the intermixed lines and assembler instructions,
; allowing to compare the code generated by the different toolchains.
; RUN: llvm-debuginfo-analyzer --attribute=level,format,producer \
; RUN: llvm-debuginfo-analyzer --attribute=language,level,format,producer \
; RUN: --print=lines,instructions \
; RUN: %p/Inputs/hello-world-dwarf-clang.o \
; RUN: %p/Inputs/hello-world-dwarf-gcc.o 2>&1 | \
@@ -26,6 +26,7 @@
; ONE-EMPTY:
; ONE-NEXT: [001] {CompileUnit} 'hello-world.cpp'
; ONE-NEXT: [002] {Producer} 'clang version 15.0.0 {{.*}}'
; ONE-NEXT: [002] {Language} 'DW_LANG_C_plus_plus_14'
; ONE-NEXT: [002] 3 {Function} extern not_inlined 'main' -> 'int'
; ONE-NEXT: [003] 4 {Line}
; ONE-NEXT: [003] {Code} 'pushq %rbp'
@@ -48,6 +49,7 @@
; ONE-EMPTY:
; ONE-NEXT: [001] {CompileUnit} 'hello-world.cpp'
; ONE-NEXT: [002] {Producer} 'GNU C++14 10.3.0 {{.*}}'
; ONE-NEXT: [002] {Language} 'DW_LANG_C_plus_plus'
; ONE-NEXT: [002] 3 {Function} extern not_inlined 'main' -> 'int'
; ONE-NEXT: [003] 4 {Line}
; ONE-NEXT: [003] {Code} 'endbr64'

View File

@@ -30,7 +30,7 @@
; emits both typedefs at the same lexical scope (3), which is wrong.
; GCC emit correct lexical scope for both typedefs.
; RUN: llvm-debuginfo-analyzer --attribute=level,format,producer \
; RUN: llvm-debuginfo-analyzer --attribute=language,level,format,producer \
; RUN: --output-sort=kind \
; RUN: --print=symbols,types,lines \
; RUN: %p/Inputs/pr-44884-dwarf-clang.o \
@@ -42,6 +42,7 @@
; ONE-EMPTY:
; ONE-NEXT: [001] {CompileUnit} 'pr-44884.cpp'
; ONE-NEXT: [002] {Producer} 'clang version 15.0.0 {{.*}}'
; ONE-NEXT: [002] {Language} 'DW_LANG_C_plus_plus_14'
; ONE-NEXT: [002] 1 {Function} extern not_inlined 'bar' -> 'int'
; ONE-NEXT: [003] 1 {Parameter} 'Input' -> 'float'
; ONE-NEXT: [003] 1 {Line}
@@ -76,6 +77,7 @@
; ONE-EMPTY:
; ONE-NEXT: [001] {CompileUnit} 'pr-44884.cpp'
; ONE-NEXT: [002] {Producer} 'GNU C++14 10.3.0 {{.*}}'
; ONE-NEXT: [002] {Language} 'DW_LANG_C_plus_plus'
; ONE-NEXT: [002] 1 {Function} extern not_inlined 'bar' -> 'int'
; ONE-NEXT: [003] 1 {Parameter} 'Input' -> 'float'
; ONE-NEXT: [003] 1 {Line}

View File

@@ -25,7 +25,7 @@
; references to the enumerators 'RED' and 'BLUE'. The DWARF generated
; by GCC, does include such references.
; RUN: llvm-debuginfo-analyzer --attribute=level,format,producer,size \
; RUN: llvm-debuginfo-analyzer --attribute=language,level,format,producer,size \
; RUN: --output-sort=name \
; RUN: --print=symbols,types \
; RUN: %p/Inputs/pr-46466-dwarf-clang.o \
@@ -37,6 +37,7 @@
; ONE-EMPTY:
; ONE-NEXT: [001] {CompileUnit} 'pr-46466.cpp'
; ONE-NEXT: [002] {Producer} 'clang version 15.0.0 {{.*}}'
; ONE-NEXT: [002] {Language} 'DW_LANG_C_plus_plus_14'
; ONE-NEXT: [002] 8 {Variable} extern 'S' -> 'Struct'
; ONE-NEXT: [002] 1 {Struct} 'Struct' [Size = 1]
; ONE-NEXT: [003] 5 {Member} public 'U' -> 'Union'
@@ -46,6 +47,7 @@
; ONE-EMPTY:
; ONE-NEXT: [001] {CompileUnit} 'pr-46466.cpp'
; ONE-NEXT: [002] {Producer} 'GNU C++14 10.3.0 {{.*}}'
; ONE-NEXT: [002] {Language} 'DW_LANG_C_plus_plus'
; ONE-NEXT: [002] 8 {Variable} extern 'S' -> 'Struct'
; ONE-NEXT: [002] 1 {Struct} 'Struct' [Size = 1]
; ONE-NEXT: [003] 5 {Member} public 'U' -> 'Union'

View File

@@ -31,7 +31,7 @@
; The DWARF generated by GCC/Clang show those variables at the correct
; lexical scope: '3' and '4' respectively.
; RUN: llvm-debuginfo-analyzer --attribute=level,format,producer \
; RUN: llvm-debuginfo-analyzer --attribute=language,level,format,producer \
; RUN: --output-sort=name \
; RUN: --print=symbols \
; RUN: %p/Inputs/pr-43860-dwarf-clang.o \
@@ -43,6 +43,7 @@
; ONE-EMPTY:
; ONE-NEXT: [001] {CompileUnit} 'pr-43860.cpp'
; ONE-NEXT: [002] {Producer} 'clang version 15.0.0 {{.*}}'
; ONE-NEXT: [002] {Language} 'DW_LANG_C_plus_plus_14'
; ONE-NEXT: [002] 2 {Function} extern inlined 'InlineFunction' -> 'int'
; ONE-NEXT: [003] {Block}
; ONE-NEXT: [004] 5 {Variable} 'Var_2' -> 'int'
@@ -63,6 +64,7 @@
; ONE-EMPTY:
; ONE-NEXT: [001] {CompileUnit} 'pr-43860.cpp'
; ONE-NEXT: [002] {Producer} 'GNU C++14 10.3.0 {{.*}}'
; ONE-NEXT: [002] {Language} 'DW_LANG_C_plus_plus'
; ONE-NEXT: [002] 2 {Function} extern declared_inlined 'InlineFunction' -> 'int'
; ONE-NEXT: [003] {Block}
; ONE-NEXT: [004] 5 {Variable} 'Var_2' -> 'int'

View File

@@ -28,6 +28,7 @@
; ONE-EMPTY:
; ONE-NEXT: [0x000000000b][001] {CompileUnit} 'test.cpp'
; ONE-NEXT: [0x000000000b][002] {Producer} 'clang version 15.0.0 {{.*}}'
; ONE-NEXT: [0x000000000b][002] {Language} 'DW_LANG_C_plus_plus_14'
; ONE-NEXT: {Directory} '/data/projects/tests/input/general'
; ONE-NEXT: {File} 'test.cpp'
; ONE-NEXT: {Public} 'foo' [0x0000000000:0x000000003a]

View File

@@ -28,7 +28,7 @@
; 8 return ParamUnsigned;
; 9 }
; RUN: llvm-debuginfo-analyzer --attribute=level,format,producer \
; RUN: llvm-debuginfo-analyzer --attribute=language,level,format,producer \
; RUN: --print=scopes,symbols,types \
; RUN: %p/Inputs/pr-57040-test-dwarf-clang.o 2>&1 | \
; RUN: FileCheck --strict-whitespace -check-prefix=ONE %s
@@ -38,6 +38,7 @@
; ONE-EMPTY:
; ONE-NEXT: [001] {CompileUnit} 'test.cpp'
; ONE-NEXT: [002] {Producer} 'clang version 14.0.6'
; ONE-NEXT: [002] {Language} 'DW_LANG_C_plus_plus_14'
; ONE-NEXT: [002] 1 {TypeAlias} 'INTPTR' -> '* const int'
; ONE-NEXT: [002] 2 {Function} extern not_inlined 'foo' -> 'int'
; ONE-NEXT: [003] {Block}
@@ -47,7 +48,7 @@
; ONE-NEXT: [003] 2 {Parameter} 'ParamUnsigned' -> 'unsigned int'
; ONE-NEXT: [003] 4 {TypeAlias} 'INTEGER' -> 'int'
; RUN: llvm-debuginfo-analyzer --attribute=level,format,producer \
; RUN: llvm-debuginfo-analyzer --attribute=language,level,format,producer \
; RUN: --print=scopes,symbols,types \
; RUN: %p/Inputs/pr-57040-test-dwarf-gcc.o 2>&1 | \
; RUN: FileCheck --strict-whitespace -check-prefix=TWO %s
@@ -57,6 +58,7 @@
; TWO-EMPTY:
; TWO-NEXT: [001] {CompileUnit} 'test.cpp'
; TWO-NEXT: [002] {Producer} 'GNU C++17 11.3.0 {{.*}}'
; TWO-NEXT: [002] {Language} 'DW_LANG_C_plus_plus_14'
; TWO-NEXT: [002] 1 {TypeAlias} 'INTPTR' -> '* const int'
; TWO-NEXT: [002] 2 {Function} extern not_inlined 'foo' -> 'int'
; TWO-NEXT: [003] {Block}

View File

@@ -35,7 +35,7 @@
; 8 return ParamUnsigned;
; 9 }
; RUN: llvm-debuginfo-analyzer --attribute=level,producer \
; RUN: llvm-debuginfo-analyzer --attribute=language,level,producer \
; RUN: --compare=types \
; RUN: --report=view \
; RUN: --print=symbols,types \
@@ -51,6 +51,7 @@
; ONE-EMPTY:
; ONE-NEXT: [001] {CompileUnit} 'test.cpp'
; ONE-NEXT: [002] {Producer} 'clang version 14.0.6'
; ONE-NEXT: [002] {Language} 'DW_LANG_C_plus_plus_14'
; ONE-NEXT: [002] 1 {TypeAlias} 'INTPTR' -> '* const int'
; ONE-NEXT: [002] 2 {Function} extern not_inlined 'foo' -> 'int'
; ONE-NEXT: [003] {Block}
@@ -90,7 +91,7 @@
; Changing the 'Reference' and 'Target' order:
; RUN: llvm-debuginfo-analyzer --attribute=level,producer \
; RUN: llvm-debuginfo-analyzer --attribute=language,level,producer \
; RUN: --compare=types \
; RUN: --report=view \
; RUN: --print=symbols,types \
@@ -106,6 +107,7 @@
; THR-EMPTY:
; THR-NEXT: [001] {CompileUnit} 'test.cpp'
; THR-NEXT: [002] {Producer} 'GNU C++17 11.3.0 {{.*}}'
; THR-NEXT: [002] {Language} 'DW_LANG_C_plus_plus_14'
; THR-NEXT: [002] 1 {TypeAlias} 'INTPTR' -> '* const int'
; THR-NEXT: [002] 2 {Function} extern not_inlined 'foo' -> 'int'
; THR-NEXT: [003] {Block}

View File

@@ -18,7 +18,7 @@
; RUN: llvm-mc -arch=wasm32 -filetype=obj \
; RUN: %p/Inputs/hello-world-clang.s -o %t.hello-world-clang.o
; RUN: llvm-debuginfo-analyzer --attribute=level,format,producer \
; RUN: llvm-debuginfo-analyzer --attribute=language,level,format,producer \
; RUN: --print=lines,instructions \
; RUN: %t.hello-world-clang.o 2>&1 | \
; RUN: FileCheck --strict-whitespace -check-prefix=ONE %s
@@ -28,6 +28,7 @@
; ONE-EMPTY:
; ONE-NEXT: [001] {CompileUnit} 'hello-world.cpp'
; ONE-NEXT: [002] {Producer} 'clang version 19{{.*}}'
; ONE-NEXT: [002] {Language} 'DW_LANG_C_plus_plus_14'
; ONE-NEXT: [002] 3 {Function} extern not_inlined 'main' -> 'int'
; ONE-NEXT: [003] 4 {Line}
; ONE-NEXT: [003] {Code} 'nop'

View File

@@ -33,7 +33,7 @@
; RUN: llvm-mc -arch=wasm32 -filetype=obj \
; RUN: %p/Inputs/pr-44884-clang.s -o %t.pr-44884-clang.o
; RUN: llvm-debuginfo-analyzer --attribute=level,format,producer \
; RUN: llvm-debuginfo-analyzer --attribute=language,level,format,producer \
; RUN: --output-sort=kind \
; RUN: --print=symbols,types,lines \
; RUN: %t.pr-44884-clang.o \
@@ -45,6 +45,7 @@
; ONE-EMPTY:
; ONE-NEXT: [001] {CompileUnit} 'pr-44884.cpp'
; ONE-NEXT: [002] {Producer} 'clang version 19{{.*}}'
; ONE-NEXT: [002] {Language} 'DW_LANG_C_plus_plus_14'
; ONE-NEXT: [002] 1 {Function} extern not_inlined 'bar' -> 'int'
; ONE-NEXT: [003] 1 {Parameter} 'Input' -> 'float'
; ONE-NEXT: [003] 1 {Line}
@@ -84,6 +85,7 @@
; ONE-EMPTY:
; ONE-NEXT: [001] {CompileUnit} 'pr-44884.cpp'
; ONE-NEXT: [002] {Producer} 'GNU C++14 10.3.0 {{.*}}'
; ONE-NEXT: [002] {Language} 'DW_LANG_C_plus_plus'
; ONE-NEXT: [002] 1 {Function} extern not_inlined 'bar' -> 'int'
; ONE-NEXT: [003] 1 {Parameter} 'Input' -> 'float'
; ONE-NEXT: [003] 1 {Line}

View File

@@ -28,7 +28,7 @@
; RUN: llvm-mc -arch=wasm32 -filetype=obj \
; RUN: %p/Inputs/pr-46466-clang.s -o %t.pr-46466-clang.o
; RUN: llvm-debuginfo-analyzer --attribute=level,format,producer \
; RUN: llvm-debuginfo-analyzer --attribute=language,level,format,producer \
; RUN: --output-sort=name \
; RUN: --print=symbols,types \
; RUN: %t.pr-46466-clang.o \
@@ -40,6 +40,7 @@
; ONE-EMPTY:
; ONE-NEXT: [001] {CompileUnit} 'pr-46466.cpp'
; ONE-NEXT: [002] {Producer} 'clang version 19{{.*}}'
; ONE-NEXT: [002] {Language} 'DW_LANG_C_plus_plus_14'
; ONE-NEXT: [002] 8 {Variable} extern 'S' -> 'Struct'
; ONE-NEXT: [002] 1 {Struct} 'Struct'
; ONE-NEXT: [003] 5 {Member} public 'U' -> 'Union'
@@ -49,6 +50,7 @@
; ONE-EMPTY:
; ONE-NEXT: [001] {CompileUnit} 'pr-46466.cpp'
; ONE-NEXT: [002] {Producer} 'GNU C++14 10.3.0 {{.*}}'
; ONE-NEXT: [002] {Language} 'DW_LANG_C_plus_plus'
; ONE-NEXT: [002] 8 {Variable} extern 'S' -> 'Struct'
; ONE-NEXT: [002] 1 {Struct} 'Struct'
; ONE-NEXT: [003] 5 {Member} public 'U' -> 'Union'

View File

@@ -34,7 +34,7 @@
; RUN: llvm-mc -arch=wasm32 -filetype=obj \
; RUN: %p/Inputs/pr-43860-clang.s -o %t.pr-43860-clang.o
; RUN: llvm-debuginfo-analyzer --attribute=level,format,producer \
; RUN: llvm-debuginfo-analyzer --attribute=language,level,format,producer \
; RUN: --output-sort=name \
; RUN: --print=symbols \
; RUN: %t.pr-43860-clang.o \
@@ -46,6 +46,7 @@
; ONE-EMPTY:
; ONE-NEXT: [001] {CompileUnit} 'pr-43860.cpp'
; ONE-NEXT: [002] {Producer} 'clang version 19{{.*}}'
; ONE-NEXT: [002] {Language} 'DW_LANG_C_plus_plus_14'
; ONE-NEXT: [002] 2 {Function} extern inlined 'InlineFunction' -> 'int'
; ONE-NEXT: [003] {Block}
; ONE-NEXT: [004] 5 {Variable} 'Var_2' -> 'int'
@@ -66,6 +67,7 @@
; ONE-EMPTY:
; ONE-NEXT: [001] {CompileUnit} 'pr-43860.cpp'
; ONE-NEXT: [002] {Producer} 'GNU C++14 10.3.0 {{.*}}'
; ONE-NEXT: [002] {Language} 'DW_LANG_C_plus_plus'
; ONE-NEXT: [002] 2 {Function} extern declared_inlined 'InlineFunction' -> 'int'
; ONE-NEXT: [003] {Block}
; ONE-NEXT: [004] 5 {Variable} 'Var_2' -> 'int'

View File

@@ -31,6 +31,7 @@
; ONE-EMPTY:
; ONE-NEXT: [0x000000000b][001] {CompileUnit} 'test.cpp'
; ONE-NEXT: [0x000000000b][002] {Producer} 'clang version 19{{.*}}'
; ONE-NEXT: [0x000000000b][002] {Language} 'DW_LANG_C_plus_plus_14'
; ONE-NEXT: {Directory} '{{.*}}/general'
; ONE-NEXT: {File} 'test.cpp'
; ONE-NEXT: {Public} 'foo' [0x0000000002:0x000000007f]

View File

@@ -51,6 +51,7 @@ HELP-ALL: =gaps - Missing debug location (gaps).
HELP-ALL: =generated - Compiler generated elements.
HELP-ALL: =global - Element referenced across Compile Units.
HELP-ALL: =inserted - Generated inlined abstract references.
HELP-ALL: =language - Source language name.
HELP-ALL: =level - Lexical scope level (File=0, Compile Unit=1).
HELP-ALL: =linkage - Linkage name.
HELP-ALL: =local - Element referenced only in the Compile Unit.

View File

@@ -89,6 +89,8 @@ cl::list<LVAttributeKind> cmdline::AttributeOptions(
"Element referenced across Compile Units."),
clEnumValN(LVAttributeKind::Inserted, "inserted",
"Generated inlined abstract references."),
clEnumValN(LVAttributeKind::Language, "language",
"Source language name."),
clEnumValN(LVAttributeKind::Level, "level",
"Lexical scope level (File=0, Compile Unit=1)."),
clEnumValN(LVAttributeKind::Linkage, "linkage", "Linkage name."),

View File

@@ -79,6 +79,10 @@ void checkElementPropertiesClangCodeview(LVReader *Reader) {
EXPECT_EQ(CompileUnit->getBaseAddress(), 0u);
EXPECT_TRUE(CompileUnit->getProducer().starts_with("clang"));
EXPECT_EQ(CompileUnit->getName(), "test.cpp");
LVSourceLanguage Language = CompileUnit->getSourceLanguage();
EXPECT_TRUE(Language.isValid());
ASSERT_EQ(Language, LVSourceLanguage::CV_LANG_Cpp);
ASSERT_EQ(Language.getName(), "Cpp");
EXPECT_EQ(Function->lineCount(), 16u);
EXPECT_EQ(Function->scopeCount(), 1u);
@@ -453,6 +457,7 @@ void elementProperties(SmallString<128> &InputsDir) {
ReaderOptions.setAttributeProducer();
ReaderOptions.setAttributePublics();
ReaderOptions.setAttributeRange();
ReaderOptions.setAttributeLanguage();
ReaderOptions.setAttributeLocation();
ReaderOptions.setAttributeSize();
ReaderOptions.setPrintAll();

View File

@@ -76,6 +76,10 @@ void checkElementProperties(LVReader *Reader) {
EXPECT_EQ(CompileUnit->getBaseAddress(), 0u);
EXPECT_TRUE(CompileUnit->getProducer().starts_with("clang"));
EXPECT_EQ(CompileUnit->getName(), "test.cpp");
LVSourceLanguage Language = CompileUnit->getSourceLanguage();
EXPECT_TRUE(Language.isValid());
EXPECT_EQ(Language, LVSourceLanguage::DW_LANG_C_plus_plus_14);
EXPECT_EQ(Language.getName(), "DW_LANG_C_plus_plus_14");
EXPECT_EQ(CompileUnit->lineCount(), 0u);
EXPECT_EQ(CompileUnit->scopeCount(), 1u);
@@ -315,6 +319,7 @@ void elementProperties(SmallString<128> &InputsDir) {
ReaderOptions.setAttributeProducer();
ReaderOptions.setAttributePublics();
ReaderOptions.setAttributeRange();
ReaderOptions.setAttributeLanguage();
ReaderOptions.setAttributeLocation();
ReaderOptions.setAttributeInserted();
ReaderOptions.setAttributeSize();