1//===- llvm/tools/llvm-debuginfo-analyzer/README.txt ----------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8//
9// This file contains notes collected during the development, review and test.
10// It describes limitations, know issues and future work.
11//
12//===----------------------------------------------------------------------===//
13
14//===----------------------------------------------------------------------===//
15// Remove the use of macros in 'LVReader.h' that describe the bumpallocators.
16//===----------------------------------------------------------------------===//
17https://reviews.llvm.org/D137933#inline-1389904
18
19Use a standard (or LLVM) map with typeinfo (would need a specialization
20to expose equality and hasher) for the allocators and the creation
21functions could be a function template.
22
23//===----------------------------------------------------------------------===//
24// Use a lit test instead of a unit test for the logical readers.
25//===----------------------------------------------------------------------===//
26https://reviews.llvm.org/D125783#inline-1324376
27
28As the DebugInfoLogicalView library is sufficiently exposed via the
29llvm-debuginfo-analyzer tool, follow the LLVM general approach and
30use LIT tests to validate the logical readers.
31
32Convert the unitests:
33  llvm-project/llvm/unittests/DebugInfo/LogicalView/CodeViewReaderTest.cpp
34  llvm-project/llvm/unittests/DebugInfo/LogicalView/ELFReaderTest.cpp
35
36into LIT tests:
37  llvm-project/llvm/test/DebugInfo/LogicalView/CodeViewReader.test
38  llvm-project/llvm/test/DebugInfo/LogicalView/ELFReader.test
39
40//===----------------------------------------------------------------------===//
41// Eliminate calls to 'getInputFileDirectory()' in the unit tests.
42//===----------------------------------------------------------------------===//
43https://reviews.llvm.org/D125783#inline-1324359
44
45Rewrite the unittests 'LFReaderTest' and 'CodeViewReaderTest'to eliminate
46the call:
47
48  getInputFileDirectory()
49
50as use of that call is discouraged.
51
52See: Use a lit test instead of a unit test for the logical readers.
53
54//===----------------------------------------------------------------------===//
55// Fix mismatch between %d/%x format strings and uint64_t type.
56//===----------------------------------------------------------------------===//
57https://reviews.llvm.org/D137400
58https://github.com/llvm/llvm-project/issues/58758
59
60Incorrect printing of uint64_t on 32-bit platforms.
61Add the PRIx64 specifier to the printing code (format()).
62
63//===----------------------------------------------------------------------===//
64// Remove 'LVScope::Children' container.
65//===----------------------------------------------------------------------===//
66https://reviews.llvm.org/D137933#inline-1373902
67
68Use a chaining iterator over the other containers rather than keep a
69separate container 'Children' that mirrors their contents.
70
71//===----------------------------------------------------------------------===//
72// Use TableGen for command line options.
73//===----------------------------------------------------------------------===//
74https://reviews.llvm.org/D125777#inline-1291801
75
76The current trend is to use TableGen for command-line options in tools.
77Change command line options to use tablegen as many other LLVM tools.
78
79//===----------------------------------------------------------------------===//
80// LVDoubleMap to return optional<ValueType> instead of null pointer.
81//===----------------------------------------------------------------------===//
82https://reviews.llvm.org/D125783#inline-1294164
83
84The more idiomatic LLVM way to handle this would be to have 'find '
85return Optional<ValueType>.
86
87//===----------------------------------------------------------------------===//
88// Pass references instead of pointers (Comparison functions).
89//===----------------------------------------------------------------------===//
90https://reviews.llvm.org/D125782#inline-1293920
91
92In the comparison functions, pass references instead of pointers (when
93pointers cannot be null).
94
95//===----------------------------------------------------------------------===//
96// Use StringMap where possible.
97//===----------------------------------------------------------------------===//
98https://reviews.llvm.org/D125783#inline-1294211
99
100LLVM has a StringMap class that is advertised as more efficient than
101std::map<std::string, ValueType>. Mainly it does fewer allocations
102because the key is not a std::string.
103
104Replace the use of std::map<std::string, ValueType> with String Map.
105One specific case is the LVSymbolNames definitions.
106
107//===----------------------------------------------------------------------===//
108// Calculate unique offset for CodeView elements.
109//===----------------------------------------------------------------------===//
110In order to have the same logical functionality as the ELF Reader, such
111as:
112
113- find scopes contribution to debug info
114- sort by its physical location
115
116The logical elements must have an unique offset (similar like the DWARF
117DIE offset).
118
119//===----------------------------------------------------------------------===//
120// Move 'initializeFileAndStringTables' to the COFF Library.
121//===----------------------------------------------------------------------===//
122There is some code in the CodeView reader that was extracted/adapted
123from 'tools/llvm-readobj/COFFDumper.cpp' that can be moved to the COFF
124library.
125
126We had a similar case with code shared with llvm-pdbutil that was moved
127to the PDB library: https://reviews.llvm.org/D122226
128
129//===----------------------------------------------------------------------===//
130// Move 'getSymbolKindName'/'formatRegisterId' to the CodeView Library.
131//===----------------------------------------------------------------------===//
132There is some code in the CodeView reader that was extracted/adapted
133from 'lib/DebugInfo/CodeView/SymbolDumper.cpp' that can be used.
134
135//===----------------------------------------------------------------------===//
136// Use of std::unordered_set instead of std::set.
137//===----------------------------------------------------------------------===//
138https://reviews.llvm.org/D125784#inline-1221421
139
140Replace the std::set usage for DeducedScopes, UnresolvedScopes and
141IdentifiedNamespaces with std::unordered_set and get the benefit
142of the O(1) while inserting/searching, as the order is not important.
143
144//===----------------------------------------------------------------------===//
145// Optimize 'LVNamespaceDeduction::find' funtion.
146//===----------------------------------------------------------------------===//
147https://reviews.llvm.org/D125784#inline-1296195
148
149Optimize the 'find' method to use the proposed code:
150
151  LVStringRefs::iterator Iter = std::find_if(Components.begin(), Components.end(),
152    [](StringRef Name) {
153        return IdentifiedNamespaces.find(Name) == IdentifiedNamespaces.end();
154    });
155  LVStringRefs::size_type FirstNonNamespace = std::distance(Components.begin(), Iter);
156
157//===----------------------------------------------------------------------===//
158// Move all the printing support to a common module.
159//===----------------------------------------------------------------------===//
160Factor out printing functionality from the logical elements into a
161common module.
162
163//===----------------------------------------------------------------------===//
164// Refactor 'LVBinaryReader::processLines'.
165//===----------------------------------------------------------------------===//
166https://reviews.llvm.org/D125783#inline-1246155
167https://reviews.llvm.org/D137156
168
169During the traversal of the debug information sections, we created the
170logical lines representing the disassembled instructions from the text
171section and the logical lines representing the line records from the
172debug line section. Using the ranges associated with the logical scopes,
173we will allocate those logical lines to their logical scopes.
174
175Consider the case when any of those lines become orphans, causing
176incorrect scope parent for disassembly or line records.
177
178//===----------------------------------------------------------------------===//
179// Add support for '-ffunction-sections'.
180//===----------------------------------------------------------------------===//
181https://reviews.llvm.org/D125783#inline-1295012
182
183Only linked executables are handled. It does not support relocatable
184files compiled with -ffunction-sections.
185
186//===----------------------------------------------------------------------===//
187// Add support for DWARF v5 .debug_names section.
188// Add support for CodeView public symbols stream.
189//===----------------------------------------------------------------------===//
190https://reviews.llvm.org/D125783#inline-1294142
191
192The ELF and CodeView readers use the public names information to create
193the instructions (LVLineAssembler). Instead of relying on DWARF section
194names (.debug_pubnames, .debug_names) and CodeView public symbol stream
195(S_PUB32), the readers collects the needed information while processing
196the debug information.
197
198If the object file supports the above section names and stream, use them
199to create the public names.
200
201//===----------------------------------------------------------------------===//
202// Add support for some extra DWARF locations.
203//===----------------------------------------------------------------------===//
204The following DWARF debug location operands are not supported:
205
206- DW_OP_const_type
207- DW_OP_entry_value
208- DW_OP_implicit_value
209
210//===----------------------------------------------------------------------===//
211// Add support for additional binary formats.
212//===----------------------------------------------------------------------===//
213- WebAssembly (Wasm).
214  https://github.com/llvm/llvm-project/issues/57040#issuecomment-1211336680
215
216- Extended COFF (XCOFF)
217
218//===----------------------------------------------------------------------===//
219// Add support for JSON or YAML.
220//===----------------------------------------------------------------------===//
221The logical view uses its own and non-standard free form text when
222displaying information on logical elements.
223
224//===----------------------------------------------------------------------===//
225