-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[llvm-debuginfo-analyzer] Add support for parsing DWARF / CodeView SourceLanguage #137223
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
CarlosAlbertoEnciso
merged 1 commit into
llvm:main
from
jalopezg-git:jalopezg-logicalview-sourcelanguage
Jun 6, 2025
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
69 changes: 69 additions & 0 deletions
69
llvm/include/llvm/DebugInfo/LogicalView/Core/LVSourceLanguage.h
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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"); | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.