llvm-debuginfo-analyzer
These are the notes collected during the development, review and test. They describe limitations, known issues and future work.
LVReader.h
that describe the bumpallocators
.Use a standard (or LLVM) map
with typeinfo
(would need a specialization to expose equality and hasher) for the allocators and the creation functions could be a function template.
As the DebugInfoLogicalView
library is sufficiently exposed via the llvm-debuginfo-analyzer
tool, follow the LLVM general approach and use lit
tests to validate the logical readers.
Convert the unitests
:
llvm-project/llvm/unittests/DebugInfo/LogicalView/CodeViewReaderTest.cpp llvm-project/llvm/unittests/DebugInfo/LogicalView/DWARFReaderTest.cpp
into lit
tests:
llvm-project/llvm/test/DebugInfo/LogicalView/CodeViewReader.test llvm-project/llvm/test/DebugInfo/LogicalView/DWARFReader.test
getInputFileDirectory()
in the unittests
.Rewrite the unittests ReaderTest
and CodeViewReaderTest
to eliminate the call:
getInputFileDirectory()
as use of that call is discouraged.
%d/%x
format strings and uint64_t
type.Incorrect printing of uint64_t
on 32-bit
platforms. Add the PRIx64
specifier to the printing code (format()
).
LVScope::Children
container.Use a chaining iterator over the other containers rather than keep a separate container Children
that mirrors their contents.
TableGen
for command line options.The current trend is to use TableGen
for command-line options in tools. Change command line options to use tablegen
as many other LLVM tools.
LVDoubleMap
to return optional<ValueType>
instead of null pointer
.The more idiomatic LLVM way to handle this would be to have find
return Optional<ValueType>
.
In the comparison functions, pass references instead of pointers (when pointers cannot be null).
StringMap
where possible.LLVM has a StringMap
class that is advertised as more efficient than std::map<std::string, ValueType>
. Mainly it does fewer allocations because the key is not a std::string
.
Replace the use of std::map<std::string, ValueType>
with StringMap
. One specific case is the LVSymbolNames
definitions.
In order to have the same logical functionality as the DWARF reader, such as:
The logical elements must have an unique offset (similar like the DWARF DIE
offset).
initializeFileAndStringTables
to the CodeView Library.There is some code in the CodeView reader that was extracted/adapted from tools/llvm-readobj/COFFDumper.cpp
that can be moved to the CodeView library.
We had a similar case with code shared with llvm-pdbutil
that was moved to the PDB library: D122226
getSymbolKindName
and formatRegisterId
to the CodeView Library.There is some code in the CodeView reader that was extracted/adapted from lib/DebugInfo/CodeView/SymbolDumper.cpp
that can be used.
std::unordered_set
instead of std::set
.Replace the std::set
usage for DeducedScopes
, UnresolvedScopes
and IdentifiedNamespaces
with std::unordered_set
and get the benefit of the O(1) while inserting/searching, as the order is not important.
LVNamespaceDeduction::find
funtion.Optimize the find
method to use the proposed code:
LVStringRefs::iterator Iter = std::find_if(Components.begin(), Components.end(), [](StringRef Name) { return IdentifiedNamespaces.find(Name) == IdentifiedNamespaces.end(); }); LVStringRefs::size_type FirstNonNamespace = std::distance(Components.begin(), Iter);
Factor out printing functionality from the logical elements into a common module.
LVBinaryReader::processLines
.During the traversal of the debug information sections, we created the logical lines representing the disassembled instructions from the text section and the logical lines representing the line records from the debug line section. Using the ranges associated with the logical scopes, we will allocate those logical lines to their logical scopes.
Consider the case when any of those lines become orphans, causing incorrect scope parent for disassembly or line records.
-ffunction-sections
.Only linked executables are handled. It does not support relocatable files compiled with -ffunction-sections
.
.debug_names
section / CodeView public symbols stream.The DWARF and CodeView readers use the public names information to create the instructions (LVLineAssembler
). Instead of relying on DWARF section names (.debug_pubnames
, .debug_names
) and CodeView public symbol stream (S_PUB32
), the readers should collect the needed information while processing the debug information.
If the object file supports the above section names and stream, use them to create the public names.
The following DWARF debug location operands are not supported:
DW_OP_const_type
DW_OP_entry_value
DW_OP_implicit_value
XCOFF
)JSON
or YAML
The logical view uses its own and non-standard free form text when displaying information on logical elements.