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